From rcstadheim at scarabweb.com Sat Jan 13 12:16:23 2001 From: rcstadheim at scarabweb.com (RCS) Date: Sat, 13 Jan 2001 18:16:23 +0100 Subject: Python 1.5.2/2.0 C extension type differences Message-ID: Have there been implemented some major changes in the way the extension API works in Python 2.0 compared to Python 1.5? I'm interested in developing C extension type Python objects, and as a preliminary test I have tried to compile (for Python 2.0) the example given in Mark Lutz's book "Programming Python" in chapter 14 (stacktyp.c), and my compiler (Visual C++ 5) complains at the following: static PyTypeObject Stacktype = { /* main python type-descriptor */ /* type header */ /* shared by all instances */ PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "stack", /* tp_name */ sizeof(stackobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* standard methods */ (destructor) stack_dealloc, /* tp_dealloc ref-count==0 */ (printfunc) stack_print, /* tp_print "print x" */ (getattrfunc) stack_getattr, /* tp_getattr "x.attr" */ (setattrfunc) 0, /* tp_setattr "x.attr=v" */ (cmpfunc) stack_compare, /* tp_compare "x > y" */ (reprfunc) 0, /* tp_repr `x`, print x */ /* type categories */ 0, /* tp_as_number +,-,*,/,%,&,>>,pow...*/ &stack_as_sequence, /* tp_as_sequence +,[i],[i:j],len, ...*/ 0, /* tp_as_mapping [key], len, ...*/ /* more methods */ (hashfunc) 0, /* tp_hash "dict[x]" */ (binaryfunc) 0, /* tp_call "x()" */ (reprfunc) 0, /* tp_str "str(x)" */ }; /* plus others: see Include/object.h */ where an error is reported at the PyObject_HEAD_INIT(&PyType_Type) : error C2099: initializer is not a constant, and in addition a bunch of warnings for the rest of the entries. Any comments/hints/help greatly appreciated!!!! Regards, Rolf C Stadheim r-stadhe at online.no From sdm7g at minsky.med.Virginia.EDU Tue Jan 23 14:57:10 2001 From: sdm7g at minsky.med.Virginia.EDU (Steven D. Majewski) Date: 23 Jan 2001 19:57:10 GMT Subject: I mean *setup.py* ! ... (more questions) References: <3d3dea3vuh.fsf@ute.cnri.reston.va.us> Message-ID: <94knmm$2vi$1@murdoch.acc.Virginia.EDU> Thanks. I'll give the patch a try. I already hacked past that error by creating a fake libm.a file. The problem with the case insensitivity of Mac's HFS+ filesystem has resurfaced in 2.1a1: If termios, fcntl, etc. are built as shared modules, then importing TERMIOS, FCNTL, ... will cause a crash due to multiply defined symbols. ( It's importing the same shared lib twice, rather than getting the .py file for the upper case module names. ) I was handling this in Setup by building those modules as built-in, rather than shared. I see in the new Modules/Setup: # The modules listed here can't be built as shared libraries for # various reasons; therefore they are listed here instead of in the # normal order. If there are modules in this list, does setup.py detect that and not try to build them shared also ? -- Steve M. In article <3d3dea3vuh.fsf at ute.cnri.reston.va.us>, Andrew Kuchling wrote: > >setup.py was written using 2.0's Modules/Setup.in as a guide to >platform specific problems; it didn't mention MacOS X, of course. Try >the untested patch below; you'll need to fix whatever sys.platform is >on MacOS X. Please let me know what it is and let me know if it >works. > >Right now the only way to fiddle with setup.py is to edit it, and >submit patches back. I'm planning to have some command-line switches >in the next alpha. > >--amk > From aahz at panix.com Thu Jan 11 05:07:09 2001 From: aahz at panix.com (Aahz Maruch) Date: 11 Jan 2001 02:07:09 -0800 Subject: Reading Microsoft Outlook Express .dbx files References: Message-ID: <93k0kd$9rf$1@panix2.panix.com> In article , Tim Peters wrote: > >Have found that of only marginal use, and only then for plain-text msgs. >Still the case that, to the best of my knowledge, while recent Outlooks deal >with msgs in std Internet format fine, it's not possible to get them back in >that format from Outlook (as the original questioner wanted). IIRC correctly, it's not possible from Outlook, but it *is* possible from Exchange Server. If you set up Exchange as a POP3 server and move the messages to a folder that you can access, any POP3 client can now get the raw messages (*don't* ask me for the details, it's been two years and a job ago). -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Sometimes, you're not just out of left field, you're coming in all the way from outer space. --Aahz From aleaxit at yahoo.com Tue Jan 16 09:03:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 16 Jan 2001 15:03:46 +0100 Subject: py_compile in windows References: <93vviq$71b$1@flotsam.uits.indiana.edu> Message-ID: <941kfd06vs@news1.newsguy.com> "Brian Waskiewicz" wrote in message news:93vviq$71b$1 at flotsam.uits.indiana.edu... > In Windows 98, how do I use py_compile.compile to make a .py file into a > .pyc file? Similarly to how you use it in other environments, e.g., to compile all the files whose names are passed as script arguments, import py_compile, sys for source_name in sys.argv[1:]: py_compile.compile(source_name) you may write this into compileit.py and then run it, for example: D:\PySym>python compileit.py wri.py a file wri.pyc will now appear in the current directory (assuming wri.py was there & correct:-). Alex From lsloan00 at my-deja.com Wed Jan 31 13:00:51 2001 From: lsloan00 at my-deja.com (Lance Sloan) Date: Wed, 31 Jan 2001 18:00:51 GMT Subject: Perl-to-Python converter/translator? Message-ID: <959jsd$njn$1@nnrp1.deja.com> I'm an experienced Perl programmer who has just been assigned a project that must be done in Python. I'm looking for a Perl-to-Python translator to help me out. I don't expect to write the whole project in Perl and translate it, though. I'm just looking for some automation to help me see how my old work could be done in Python. I didn't find anything useful via Google or Vaults of Parnassus searches. So, I would appreciate any pointers! Thanks in advance. -- Lance Sloan - lsloan00 at my-deja.com -- Lance Sloan - lsloan00 at my-deja.com Sent via Deja.com http://www.deja.com/ From huthut at my-deja.com Sat Jan 13 19:41:25 2001 From: huthut at my-deja.com (huthut at my-deja.com) Date: Sun, 14 Jan 2001 00:41:25 GMT Subject: http authentication Message-ID: <93qsjl$c6o$1@nnrp1.deja.com> Please forgive my, probably, very naive question. Im trying to hack togethe ra script that will download a number of files off a internet site. The only problem is that this site is password protected (in IE a box pops up for username and password). So first i tried the urllib.FancyURLopener.open(url) which prompted me for a username but then froze. Then i tried .open ('http://user:password at www.somewhere.com') but then i got: File "c:\python20\lib\urllib.py", line 513, in __init__ apply(URLopener.__init__, (self,) + args) File "c:\python20\lib\urllib.py", line 91, in __init__ assert hasattr(proxies, 'has_key'), "proxies must be a mapping" AssertionError: proxies must be a mapping Does anyone have any suggestions? Thanks in advance Sent via Deja.com http://www.deja.com/ From db3l at fitlinxx.com Fri Jan 26 14:00:11 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Jan 2001 14:00:11 -0500 Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> <3A3AF7F970D390FB.9516A3492818FA7E.F86BC486C21F50E6@lp.airnews.net> Message-ID: cerutti at together.net (Neil Cerutti) writes: > I forgot to mention the ID members of wxPython objects, which are > unintuitive when it seems so simple to use actual objects in > function calls instead. I can see how secret ID nos could > save stack space and pointer passing in a C++ program. Note that it's sort of up to you to choose - I almost never use the ID numbers in my wxPython programs, but just save references to the objects. As in your listbox example, in most cases I just use -1 for the id for new objects (although I think there's also an ID generation function if you want to track the numbers). I guess the one place I do use them is for menu items, but really only when the item is created and the event attached to a callback method. -- -- 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 julien.reynier at free.fr Mon Jan 15 19:05:15 2001 From: julien.reynier at free.fr (Julien Reynier) Date: Tue, 16 Jan 2001 00:05:15 GMT Subject: How to import JavaClass from JPython? Message-ID: <3A638EE1.BDABAA65@free.fr> Hi, I know how to import core API classes from JPython using for example : from java.lang import System But I don't know how to import an specific class for example MyClass.class that I had developped. If I just do the same thing that with core API classes : from my.package import MyClass, I obtain an error message. Is anybody knows if a classpath or other environment variables have to be set to specific values ? thanks... Julien Reynier From moshez at zadka.site.co.il Tue Jan 16 19:40:03 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 17 Jan 2001 02:40:03 +0200 (IST) Subject: [ANNOUNCE] FreeImage 2.0.0 out! In-Reply-To: References: Message-ID: <20010117004003.A7B57A82D@darjeeling.zadka.site.co.il> On Tue, 16 Jan 2001 18:59:07 +0300 (MSK), Oleg Broytmann wrote: > > Curious. > > It compiles only with MSVC++6.0, yet works on Windows and Linux (??) > > It compiles on Linux, but not on *BSD? :))) Cannot believe it. :) Simple: *BSD doesn't have MSVC++6.0 -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From sheila at thinkspot.net Sun Jan 14 23:24:46 2001 From: sheila at thinkspot.net (Sheila King) Date: Mon, 15 Jan 2001 04:24:46 GMT Subject: Help with Python install References: <93tsoe$bja9b$1@ID-11957.news.dfncis.de> Message-ID: On Sun, 14 Jan 2001 20:02:00 -0800, "Emile van Sebille" wrote in comp.lang.python in article <93tsoe$bja9b$1 at ID-11957.news.dfncis.de>: :How about trying the full python2 path in .qmail preceeding :your script file name: : :------------------------------------------------ :|/big/dom/xthinkspot/thinker/python/Python-2.0/python :/big/dom/xthinkspot/mailtofile.py |vdeliver :------------------------------------------------ Thanks for the suggestion. I had tried it before, but I tried it again, at your suggestion. Still doesn't work. :-( -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From carlbray at altavista.net Mon Jan 29 13:35:47 2001 From: carlbray at altavista.net (Carl Bray) Date: Mon, 29 Jan 2001 18:35:47 -0000 Subject: Wrapping up a C++ class References: <954496$ues$1@nnrp1.deja.com> Message-ID: <980793638.864506@lave> Take a look at SWIG http://www.swig.org/ wrote in message news:954496$ues$1 at nnrp1.deja.com... > Hi, > > Could anyone provide me with a simple example of wrapping a simple C++ > class for use in Python (I seem to be unable to find one - I must be > missing something) - including the details of the creation and > destruction of the actual C++ instance? An extra example of dealing > with virtual methods would also be a bonus! > > Thanks in advance, > > Warrick. > > > Sent via Deja.com > http://www.deja.com/ From rcameszREMOVETHIS at dds.removethistoo.nl Wed Jan 10 21:37:36 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Thu, 11 Jan 2001 02:37:36 GMT Subject: Reading Microsoft Outlook Express .dbx files References: Message-ID: <90262DD44rcamesz@127.0.0.1> Steve Holden wrote: >In my trek through the various mail packages the Windoze user may be >confronted with I am currently battling with Outlook Express. It's >actually rather better than I feared. > >Its native folder format appears to be a ".dbx" file, about which I >have no information. Does any reader have experience with either >reading these files, or automating OEx to provide them to a Python >program in RFC822-style formats? > >Or, indeed, any other way of extracting mail items from the files >created by OEx. As it so happens, i've come across a program recently which can convert .dbx (OE5) to .mbx format. Program: ftp://ftp.micropop.com/pub/oe2mbx/oe2mbx.exe Sources: http://www.micropop.com/code/liboe-0.92.tar.gz Read routines for .DBX files: http://www.micropop.com/code/oe2mbx-1.21.tar.gz Mind you, this is GPLed stuff. There's also *some* information to be found on www.wotsit.org, but it's pretty sketchy. Oe2mbx.exe seems to work well, though I haven't really tested it extensively. So your mileage may vary. HTH, Robert Amesz From danielhill at brightok.net Mon Jan 22 02:02:14 2001 From: danielhill at brightok.net (Dead Dan) Date: Mon, 22 Jan 2001 01:02:14 -0600 Subject: What does Python do Message-ID: <94gmeu$4fc$1@sooner.brightok.net> What kinds of programs can you make with Python. Does anyone have some examples. Dan From cg at schlund.de Fri Jan 26 04:05:44 2001 From: cg at schlund.de (Carsten Gaebler) Date: Fri, 26 Jan 2001 10:05:44 +0100 Subject: "print" strange with Sybase module References: <3A70163A.10D995@schlund.de> <94q0f6$lu5$1@news.cybercity.dk> Message-ID: <3A713DE8.592E8BDE@schlund.de> "Erwin S. Andreasen" wrote: > >./sqltest.py | tee /tmp/test.txt > > > >there is no output and test.txt is empty. What's going wrong? It's > >Sybase module 0.10 with Python 2.0. > > Does your Python interpreter exit before the very end with some fatal error? > (do echo $? after you run the script without piping it to see the exit error > code, is it 0?). Everything's fine, return code is 0. > I can't see a reason to why it would exit that way quietly, but unflushed > buffers are the first thing that comes to mind when seeing those symptoms. If I give Python the "-u" option the following happens: [cg at cg test]$ ./sqltest.py | tee /tmp/test.txt Traceback (most recent call last): File "./sqltest.py", line 12, in ? print row IOError: [Errno 32] Broken pipe Broken pipe?? BTW it's the same with "|less", "|more", "|gzip" etc. I'm confused. cg. From dickey at saltmine.radix.net Fri Jan 19 06:29:47 2001 From: dickey at saltmine.radix.net (Thomas Dickey) Date: 19 Jan 2001 11:29:47 GMT Subject: Curses module for Python 2.0 for Windows NT References: <3a65a767.3665680@news.laplaza.org> Message-ID: <9498fb$3kq$3@news1.Radix.Net> Mats Wichmann wrote: > On Wed, 17 Jan 2001 09:23:42 +0100, jurgen.defurne at philips.com wrote: > I haven't seen anything recently that indicates curses-on-Windows > available cleanly. There was a console application noted here not too > long ago that might be usable; the GNU project page for curses > indicates that a solid Windows port is still a whishlist item. > Nonetheless, vim works very well on Windows so someone out there has > presumably done the necessary work. vim's not using curses. -- Thomas E. Dickey http://dickey.his.com ftp://dickey.his.com From andreas at andreas-jung.com Mon Jan 15 11:48:13 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Mon, 15 Jan 2001 17:48:13 +0100 Subject: Accessing variables with rexec module ? Message-ID: <20010115174813.A6027@yetix.sz-sb.de> Inside a instance of rexec.RExec a code block introduces some local variables. They are not visible using the locals()/globals() dictionaries. However I need to check if a variable exists or not. If it exists I need to get the value of this variable. This there a way to do this ? Andreas From arinagour at yahoo.co.uk Sat Jan 13 08:52:30 2001 From: arinagour at yahoo.co.uk (chris lamb) Date: Sat, 13 Jan 2001 13:52:30 -0000 Subject: Michelle, this is great! References: <3eb3a99ac6fe35ef407440cf78681fc8@dizum.com> Message-ID: Maybe I am naive, but is this a spam or some attempt to make a security point. All I got was a lot of html/text (I cannot stand html based email!) which basically pointed to the page attached at the end? What am I missing?? Please enlighten me! Chris ---------------------------------------------------------------------------- -------------- Untitled Document

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Find Everything! Comedy World, Inc. Banner 10000003 From vsbabu at erols.com Thu Jan 11 06:49:59 2001 From: vsbabu at erols.com (Satheesh Babu) Date: Thu, 11 Jan 2001 06:49:59 -0500 Subject: ActivePython2.0 - Server Side objects for ASP problem References: <93j0qi$7cv$1@bob.news.rcn.net> Message-ID: <93k6k5$1g7$1@bob.news.rcn.net> Hi Steve, That worked! Thanks... My actual requirement is not to gather HTML pages (I've one for that in 100% python ASP and by setting a BASE HREF, it works fine). I have this proprietary software from a vendor which runs a server on some port and it accepts some commands on that port. My requirement is to generate these commands on the fly, send it to this server and get response, from many ASP pages. I don't know how to do network programming in ASP/VBScript. In Python I've already written something which works, using socket library. My initial thought was to embed that Python code into my ASP scripts - won't work since ASP (atleast my installation) doesn't allow mixing of different languages. Making a COM object on the server is also beyond me. So, I got this idea and was just checking it out. Many thanks again -- v.s.babu vsbabu at erols.com http://vsbabu.csoft.net "Steve Holden" wrote in message news:tK876.2719$24.38513 at e420r-atl2.usenetserver.com... > "Satheesh Babu" wrote in message > news:93j0qi$7cv$1 at bob.news.rcn.net... > > Hi, > > > > I'm trying to use a server side python object to be called from a VBScript > > ASP code. > > It works nicely for simple things. When I try to use urllib functions, I > get > > an error. Any > > idea? The second function works nicely. I'm using Win98, PWS with > Build202. > > I'll try > > on NT4.0 IIS tomorrow. Any help is greatly appreciated. > > > > ----------------- ASP file ----------------- > > <% @LANGUAGE="VBSCRIPT" %> > > > > <%= SlurpURL("http://vsbabu.csoft.net/") %> > > <%= CapitalizeIt("the first letter should be capitalized") %> > > > > ----------------pymod.asp------------------ > > > > ------------------ error message ----------------- > > Python ActiveX Scripting Engine error '80020009' > > > > Traceback (innermost last): File " > > > ------------------ error message ----------------- > > > Python ActiveX Scripting Engine error '80020009' > > > > > > Traceback (innermost last): File " > ------------------ error message ----------------- > Python ActiveX Scripting Engine error '80020009' > > Traceback (innermost last): File " From mwh21 at cam.ac.uk Thu Jan 25 15:59:22 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Jan 2001 20:59:22 +0000 Subject: Hack request: rational numbers References: Message-ID: Pearu Peterson writes: > Hi! > > I am using rational numbers from the gmpy module and I find that creating > one in Python using > > >>> mpq(3,4) > > is rather clumsy. Clearly, minimal representation of this rational number > is > > 3/4 > > but in Python this expression has different meaning. Here's an idea: subclass code.InteractiveConsole. Use bytecodehacks to find bytecodes like LOAD_CONST LOAD_CONST BINARY_DIVIDE to LOAD_GLOBAL "mpq" LOAD_CONST LOAD_CONST CALL_FUNCTION 2 This isn't actually very difficult, but I'm not going to do it. > 3) What are changes that these hooks will be accepted to Python core? Can't speak for the people whose opinions really count, but my guess: none. > 4) Is anybody else working with builtin rational number support for > Python? Maybe. I suspect not enough to make a difference. It's mooted that 1/2 will produce something other than "0" in Py3K, but I can't remember whether a rational or a floating point result seemed most likely last time this went around. Cheers, M. -- Good? Bad? Strap him into the IETF-approved witch-dunking apparatus immediately! -- NTK now, 21/07/2000 From t.keil at zvs.zgs.de Tue Jan 23 14:25:52 2001 From: t.keil at zvs.zgs.de (Thomas Keil) Date: Tue, 23 Jan 2001 11:25:52 -0800 Subject: Python for 8086??? References: Message-ID: <3A6DDAC0.5ADF@zvs.zgs.de> Hi Tony, Python 1.0.1 works fine on a 8086 (my HP 200LX). You need an 8087 emulator; have a look at 'http://www.palmtop.net/super.html'. But I don't know where to look for libraries for Pyhton 1.0.1 - if you find some, give me a hint, please. _ o | )_/# T <92mrdn$um3$1@newsreaderg1.core.theplanet.net> Message-ID: This problem can also be fixed by pulling the latest version of boa from cvs. Scott "Franz GEIGER" wrote in message news:92mrdn$um3$1 at newsreaderg1.core.theplanet.net... > I went back to wxPython-2.2.1-Py20b1.EXE, and everything was fine again. > > Reagrds > Franz > > "June Kim" wrote in message > news:92ld65$4un$1 at news.nuri.net... > > I tried to run BC on my windows machine installed with the lastest > versions > > of Python(2.0) and wxPython(2.2.2) and got the following error. > > > > Any roundabout ways to run it besides downgrading the Python and wxPython? > > > > Traceback (most recent call last): > > File "boa.py", line 119, in ? > > main() > > File "boa.py", line 112, in main > > app = BoaApp(0) > > File "boa.py", line 49, in __init__ > > wxApp.__init__(self, redirect) > > File "c:\python20\wxPython\wx.py", line 1646, in __init__ > > _wxStart(self.OnInit) > > File "boa.py", line 58, in OnInit > > self.main = Palette.BoaFrame(None, -1, self) > > File "Palette.py", line 157, in __init__ > > wxMenu(), self.componentSB, app)#palettePage.menu > > File "Editor.py", line 135, in __init__ > > self.addShellPage() > > File "Editor.py", line 310, in addShellPage > > self.tabs.AddPage(ShellEditor.ShellEditor(self.tabs, -1), 'Shell') > > File "ShellEditor.py", line 26, in __init__ > > PythonStyledTextCtrlMix.__init__(self, wId, -1) > > File "Views\StyledTextCtrls.py", line 137, in __init__ > > self.SetKeywords(0, > > AttributeError: 'ShellEditor' instance has no attribute 'SetKeywords' > > > > > > > > From juergen.erhard at gmx.net Mon Jan 15 12:02:24 2001 From: juergen.erhard at gmx.net (Jürgen A. Erhard) Date: Mon, 15 Jan 2001 18:02:24 +0100 Subject: What's the difference? In-Reply-To: <20001114182610.A24412@bigskytel.com> (message from David Porter on Tue, 14 Nov 2000 18:26:10 -0700) References: <3a15e04a.517776278@news.demon.co.uk> <20001114182610.A24412@bigskytel.com> Message-ID: <15012001.1@wanderer.local.jae.ddns.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >>>>> "David" == David Porter writes: David> * Simon Foster : >> Whats the difference between : >> >> #! /usr/bin/env python >> >> and : >> >> #! /usr/bin/python David> the first is using the env program to divine the location David> of python using the users environment. The second is a David> direct path to python. The first is the safest bet if you David> do not know where python will be. For example, many people David> put python in /usr/local/bin. The first would still work, David> but the second would need to be changed. Correct. But it should be noted that the second form should be used for scripts that have to keep an eye on security... /usr/bin/env uses the user's PATH, so it could be possible to get the user to execute a different script than the one intended. And absolute path avoids this. Bye, J - -- J?rgen A. Erhard juergen.erhard at gmx.net phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard Bill Gates brought you Windows. Linus brought you the whole DAMN HOUSE! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: Use Mailcrypt and GnuPG iEYEARECAAYFAjpjLSAACgkQN0B+CS56qs3MygCdG49Kn4e1uVhWsC1sCD/cGmBf 998AnRiFdW5OjAJPdXusOAzJqj+w1ILa =m6YQ -----END PGP SIGNATURE----- From donn at u.washington.edu Tue Jan 9 16:59:36 2001 From: donn at u.washington.edu (Donn Cave) Date: 9 Jan 2001 21:59:36 GMT Subject: dns reverse look up with python ? References: <93ecvp$v21$02$1@news.t-online.com> <93fe1k$mh4$0@216.39.151.169> Message-ID: <93g1k8$mhk$1@nntp6.u.washington.edu> Quoth "Greg Jorgensen" : | Don't count on symmetry. The IP address you get from socket.gethostbyname() | won't always resolve to the same name when you pass it to | socket.gethostbyaddr(). Virtual domains, round-robin DNS, and load balancers | are just three of many flies in the ointment. | | For example: | | >>> import socket | >>> s = socket.gethostbyname('www.pdxperts.com') | >>> s | '216.240.147.136' | >>> socket.gethostbyaddr(s) | ('basic-igloo.winston.dreamhost.com', [], ['216.240.147.136']) | >>> | | This happens because the pdxperts.com is a virtual domain on the host | basic-igloo.winston.dreamhost.com. | | So be careful about what you expect from reverse DNS. I won't guarantee that reverse lookup can always stabilize, but if that kind of brain damage exists out there it's pretty easy to avoid. In this particular example, it looks to me like the lookup DOES stabilize. That is, 'basic-igloo.winston.dreamhost.com' is still 216.240.147.136, and vice versa. That second "real" DNS is the reverse lookup. In a DNS rotor (round robin, load balance), the IP addresses should resolve to non-rotating DNS addresses, where reverse lookup works too. I don't doubt there are examples where it doesn't, but complain to them, not me. I think to a degree you can indeed count on reverse lookup. If you have no better alternative, anyway, it looks pretty good. Donn Cave, donn at u.washington.edu ---------------------------------------- | "Donn Cave" wrote in message | news:93fe1k$mh4$0 at 216.39.151.169... | > Quoth "Ralf Claus" : | > | > | any suggestion about this theme ? | > | Is there a way for me (newbie) ? | > | > >>> import socket | > >>> socket.gethostbyname('t-online.de') | > '194.25.134.132' | > >>> socket.gethostbyaddr('194.25.134.132') | > ('www1.sul.t-online.de', [], ['194.25.134.132']) | > | > That's what I understand "reverse lookup" to mean. Given | > a DNS name, like the host name that appears in your email | > address "t-online.de", first I look up the IP address with | > gethostbyname(). Then, I look up the DNS address by the | > IP address. | > | > Hopefully, after this procedure you have a stable pair of | > IP and DNS addresses, so if you repeat this procedure you | > will continue to get the same answer. That's the point. | > | > Donn Cave, donn at oz.net From paulp at ActiveState.com Mon Jan 22 04:41:06 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 22 Jan 2001 01:41:06 -0800 Subject: What does Python do References: <94gmeu$4fc$1@sooner.brightok.net> Message-ID: <3A6C0032.68DBD852@ActiveState.com> Dead Dan wrote: > > What kinds of programs can you make with Python. Does anyone have some > examples. Python is a general purpose language. It is used for everything from small scripts to large, complex systems. It can be used for *almost* everything: http://www.lyra.org/greg/CaseStudy/ http://www.nightmare.com/medusa/ http://grail.sourceforge.net/ http://starbase.neosoft.com/~claird/comp.lang.python/web_python.html http://www.sun.com/sunworldonline/swol-10-1997/swol-10-scripting.html http://www-4.ibm.com/software/developer/library/python101.html It would be easier if you described what you need to do rather than asking what Python can be used for. What's a pickup truck used for? Paul Prescod From tbryan at python.net Sat Jan 6 08:37:39 2001 From: tbryan at python.net (Thomas A. Bryan) Date: Sat, 06 Jan 2001 08:37:39 -0500 Subject: cgi References: <3A549C1C.3EC97EB4@stea.nu> Message-ID: <3A571FA3.90D49DC@python.net> Lars Stea wrote: > how can i deside wether a form field can be left blank or not? I'm not entirely sure what you're trying to ask. Could you tell us what you're trying to do so that we have a little more context for this question? ---Tom From claird at starbase.neosoft.com Mon Jan 22 09:53:11 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 22 Jan 2001 08:53:11 -0600 Subject: What does Python do References: <94gmeu$4fc$1@sooner.brightok.net> <94gvv5$7mo$1@sooner.brightok.net> Message-ID: <2F4DC6312B7FE9DA.74AB95EBEF3C09D4.1D6BDBE5660A1914@lp.airnews.net> In article , Dag Sunde wrote: >I think Python is _very well suited as a >first language... . . . I claim an even stronger proposition: Python is the single best language for most beginners. Its applicability is as wide as *any* language (yes, including C and Java), and it's quite in- viting to first-timers. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bowman at montana.com Fri Jan 5 23:18:36 2001 From: bowman at montana.com (bowman) Date: Fri, 5 Jan 2001 21:18:36 -0700 Subject: Question about IDLE References: <9364b7$qse$1@nnrp1.deja.com> Message-ID: wrote in message news:9364b7$qse$1 at nnrp1.deja.com... > > I've been trying out the IDLE IDE for python and the fonts it uses are > extremely ugly. > Does anyone else have this problem? If so, how were you able to solve it? i'm not running Linux at the moment, so can't check it, but have you tried setting the font or fontList in an app-defaults file or in .Xdefaults? From tdelaney at avaya.com Mon Jan 22 20:12:10 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 23 Jan 2001 12:12:10 +1100 Subject: How do I know all thrown exceptions of a function? Message-ID: > I don't understand "things which should normally pass through (such > as index-out-of-bounds)". Pass through what? When you later say > "so they don't need to be declared in just about every > function around", > does that account for the whole reason behind SilentException? Well, the "index-out-of-bounds" (currently IndexError) is something that you don't want to have every function declaring - but almost every function has the potential for throwing it. Every time you do an indexed access there is the chance of throwing the exception. Since indexing is such a common thing to do and normally you don't need to worry about falling off the end, you make it "silent". In Java terminology, this is a "RuntimeException". > I don't understand the distinction between Exception and Error. > Would you be able to catch Error the same as Exception? If not, > what happens? If you can catch them the same as Exception, then > it's just another category invented so you won't have to declare > the exception? No. You only put things as Errors if they are "the world is dying" type things. This means you can do try: except Exception: and Errors don't get trapped - only Exceptions and SilentExceptions. Things which qualify for "Error" status include "the computer has run out of memory, both physical and virtual". It's still possible to catch such errors, but you'd better be sure you know how to deal with them. Another good example of an error is "the module you tried to import cannot be found". This is normally not an expected exception - it's normally a "program must die" error. However, sometimes you want to catch the error and import a different module. Tim Delaney Avaya Australia From jkndeja at my-deja.com Mon Jan 8 07:28:02 2001 From: jkndeja at my-deja.com (jkndeja at my-deja.com) Date: Mon, 08 Jan 2001 12:28:02 GMT Subject: escape sequences and string comparisons Message-ID: <93cboe$ctj$1@nnrp1.deja.com> Hello there I've just discovered that when using the escape character in a string, if the following character is _not_ an expected 'escape code' character, the the backslash is passed on, rather than being dropped, eg: len("\'") == 1 # a back-tick len("\\") == 1 # a quote character # '\>' doesn't have a meaningful escape value len("\>") != 1 I was expecting this latter case to give me a single '>' character, but instead I seem to get a two-character string, '\>'. Well, OK (although I'm still surprised). But I generated this string ('\>') using re.escape(), in order to compare strings with potentially non-alphanumeric characters. Since re.escape() simply uses the criterion of 'non-alphanumeric character' to determine whether to escape a character, is there an alternative function to 'escape only characters used in string literal escapes', am I on my own, or am I missing something? Thanks Jon Nicoll Sent via Deja.com http://www.deja.com/ From dlopezp at norsistemas.es Fri Jan 5 02:23:28 2001 From: dlopezp at norsistemas.es (David López) Date: Fri, 5 Jan 2001 08:23:28 +0100 Subject: How to send cookies References: <932ab206uv@news2.newsguy.com> Message-ID: Thank you very much. Concretely our problem is that we don?t know how to SEND cookies. We already have worked with Java cookies. We would thank you if you can ask our question. Thanks a lot. From moshez at zadka.site.co.il Mon Jan 15 21:35:11 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 16 Jan 2001 04:35:11 +0200 (IST) Subject: client/server python examples In-Reply-To: References: Message-ID: <20010116023511.7AC3AA828@darjeeling.zadka.site.co.il> On Mon, 15 Jan 2001 17:42:26, "anand v" wrote: > Hi, > > Could someone please provide some standalone examples > of client and server written in python to communicate > on sockets??? and also it will be very helpful if the server > has some threads also.. httplib and SimpleHTTPServer enough for you? Inherit from SimpleHTTPServer and SocketServer.ThreadingMixin and you have a threaded server. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From rol9999 at attglobal.net Tue Jan 23 08:59:54 2001 From: rol9999 at attglobal.net (Roland Schlenker) Date: Tue, 23 Jan 2001 08:59:54 -0500 Subject: observer design pattern References: <94i340$4er$1@nnrp1.deja.com> <3A6CA19C.89A6DFB2@attglobal.net> <3A6D0992.C86D92CD@home.com> <3A6D5BAB.2AB22E36@mail.dvz.fh-koeln.de> Message-ID: <3A6D8E5A.476DE8E7@attglobal.net> Stephan Effelsberg wrote: > > Rick Lee schrieb: > > > What Design Patterns book are you referring to? > > He will most likely refer to the GoF book (Design Patterns, Addison-Wesley) > and translated the C++ example into Python. > There's no Python-specific pattern book out yet (at least, I don't know any). Correct, when I read the Gof book, I rewrote many of the examples in the Python to better understand them. Roland Schlenker From root at rainerdeyke.com Mon Jan 29 17:07:50 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 29 Jan 2001 22:07:50 GMT Subject: map and operator.add usage References: <8okb7t067aicblsjr8idj726hdnt4pn04h@4ax.com> Message-ID: "Fernando Rodr?guez" wrote in message news:8okb7t067aicblsjr8idj726hdnt4pn04h at 4ax.com... > Hi! > > In Lisp I can do: > > CL-USER 9 > (mapcar #'+ '(1 2) '(3 4) '(5 6)) > (9 12) > > but how can I do it in Python? [reduce(operator.add, l) for l in zip([1, 2], [3, 4], [5, 6])] ...or... map(lambda l: reduce(operator.add, l), zip([1, 2], [3, 4], [5, 6])) -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From neelk at alum.mit.edu Sun Jan 28 16:47:07 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 28 Jan 2001 21:47:07 GMT Subject: [Off topic] allowed to put Python material on the Web? References: <3a730931.31998180@news.skynet.be> <3A73940E.2637C648@alcyone.com> Message-ID: On Sat, 27 Jan 2001 19:37:50 -0800, Erik Max Francis wrote: >Sheila King wrote: > >> Technically, once the messages are posted to Usenet, anyone can >> archive and copy them. > ... >> Authors of Usenet posts still retain copyright to >> their own material. > > These two statements are inconsistent with one another. (The latter > is the one that is correct, by the way.) No, they're not. When someone posts a message they have to grant permission to people to copy, archive and redistribute their messages -- since a) that's how Usenet works, b) since posting to Usenet is wholly voluntary, and c) judges and courts are not entirely stupid. But a wide grant of permission isn't the same thing as losing copyright, as things like the X source license demonstrate. Neel From moshez at zadka.site.co.il Sat Jan 13 04:46:58 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 13 Jan 2001 11:46:58 +0200 (IST) Subject: How robust is Python ? In-Reply-To: <93nh5u$9nk$1@nntp6.u.washington.edu> References: <93nh5u$9nk$1@nntp6.u.washington.edu>, <9358nn$3c5$1@nnrp1.deja.com>, <9354f9$vbi$1@nnrp1.deja.com>, <20010106103938.8FCAFA84F@darjeeling.zadka.site.co.il> Message-ID: <20010113094658.9BFC9A82D@darjeeling.zadka.site.co.il> On 12 Jan 2001 18:07:58 GMT, Donn Cave wrote: > But back to the subject, I would be interested in more concrete > examples of what exceptions we're liable to catch in a case like that. > I have used top level handlers, but only as basically an alternative to > the traceback, not to resume execution. In my original message, I didn't say "resume execution" -- I said "re-exec", meaning (sorry for not being clearer) using the exec(2) system call to restart itself from scratch. I wouldn't just resume execution after an identified exception. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From J.Jonkers at acriter.com Thu Jan 18 09:19:41 2001 From: J.Jonkers at acriter.com (Johan Jonkers) Date: Thu, 18 Jan 2001 15:19:41 +0100 Subject: tables Message-ID: <3A66FB7D.26B4CB12@acriter.com> Hi! I have been playing with Tkinter the past few days and I am kinda missing a table-widget. Is it not there or did I miss anything? I couldn't find any word on it in 'Python and Tkinter'. Just thought I'd ask b4 I find myself forced to use a grid with labels and such.. So, is there a table widget? Regard, Johan Jonkers From sandj.williams at gte.net Tue Jan 16 21:25:55 2001 From: sandj.williams at gte.net (Steve Williams) Date: Wed, 17 Jan 2001 02:25:55 GMT Subject: How to call a stored procedure? References: <3a64c959.600874890@localhost> Message-ID: <3A65040B.1AB5909F@gte.net> Victor Muslin wrote: > I am using Python 1.5.2 on WindowsNT. > > I have a stored procedure defined in Oracle: > [snkp] > > cur.execute("execute vmuslin.delete_adserver(3)"); > > The error I get is: > > Traceback (innermost last): > File "E:\dev\dclk\eng\src\apps\ADMIN_~1\xx.py", line 7, in ? > cur.execute("execute vmuslin.delete_adserver(3)"); > dbi.program-error: [Microsoft][ODBC driver for > Oracle][Oracle]ORA-00900: invalid SQL statement in EXEC > [snnnp] I don't know. Try cur.execute("call vmuslin.delete_adserver(3)"); instead. From kmbotha at netinfo.ubc.ca Thu Jan 18 01:00:49 2001 From: kmbotha at netinfo.ubc.ca (Kris Botha) Date: Thu, 18 Jan 2001 06:00:49 GMT Subject: Files and Directories in Python Message-ID: <3a668633.136271945@news.interchange.ubc.ca> Hi, Does anyone know if there exists a way to check the amount of free (available) disk space using Python? I've looked at things like the os.stat() function but have found no answer. TIA! ~~====----..----====~~ Kris Botha From m.faassen at vet.uu.nl Thu Jan 4 22:33:21 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 Jan 2001 03:33:21 GMT Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> Message-ID: <933fa1$j2i$1@newshost.accu.uu.nl> Joel Ricker wrote: [snip] > So basically what I'd like to know is, how do the two compare? Is there an > easier learning curve with Python? >From my experience, yes; a couple of years ago I tried to learn Perl for some days, and I kept getting lost in all the syntax options and other things that didn't mesh well with my mind. Then I learned Python right away without much difficulty at all, it just clicked. > Are the modules and add-ons as good as > perl (ie, Database -- I'm primarily interested in MySQL, CGI, Graphics). While from reports perl's modules support (esp. CPAN) is still better than Python's in some ways (there's more of it, and they're easier to install), I've never had any trouble with Python. Check out the vaults of Parnassus for a catalog of modules: http://www.vex.net/parnassus I've done databases with Python (mostly Access through ODBC and Postgresql, but MySQL is supported as well), and CGI's fine too (though I mostly use Zope: http://www.zope.org), and there are lots of bindings to graphics and UI toolkits, depending on what you like. I've been toying with pygame recently, which is pretty low level, though (http://pygame.seul.org). > What about OOP? Is it it a full OO language? Yes, Python does OOP just fine, and is a full dynamically typed OOP language. If you are familiar with languages like C++ or Java you're in for a hopefully pleasant surprise; there is much less programmer overhead to create and use classes than there is in those languages, due to the simpler syntax, and dynamic typing instead of static typing. > Is it easier than to use than > perl? Perl OO just feels like it has been cludged together. >From my limited experience with Perl, definitely yes. I've been told Perl's OO model is actually inspired by Python's, but I didn't spend enough of time with Perl's OO features to know much about that. In python this is how you make a class: class Foo: def __init__(self): """Functions that start and end with __ are special, and this one is used to initialize (construct) objects in whatever way you like.""" self.text = "this is some text" self.number = 15 def get_text(self): return self.text def add_to_number(self, amount): self.number = self.number + amount # or self.number += amount # now let's create an object of class Foo myfoo = Foo() # and use the methods myfoo.add_to_number(40) print myfoo.get_text() > And lastly, what about the Python community? Is it friendlier than the perl > community? The Python community's reputation is that it's friendlier than the Perl community, the flame war about variable initialization in the do..until thread notwithstanding. :) > Too many times I've asked questions and all I'll get is pointers > to documentation, which I've already read and so thats why I'm asking for > information in the first place. I understand simple questions for basic or > novice information will warrant answers like that but not the things I've > asked. I've seen people beinn pleasantly surprised by the quality of answers they've received in this newsgroup, so you may like it. Good luck! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From sholden at holdenweb.com Tue Jan 9 16:37:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 9 Jan 2001 16:37:09 -0500 Subject: A single, general looping construct? (was: why no "do : until"?) References: <93euo1$drh$1@okapi.ict.pwr.wroc.pl> Message-ID: Pawel Kedzierski wrote in message news:93euo1$drh$1 at okapi.ict.pwr.wroc.pl... > Hi there, > > I become a python enthusiast a short time ago and even I adopted it > as a programming language for my classes on programming in chemistry. > It allowed to shift the balance of training/applications largery to > the right side :-); However, I also found hard to explain why there > isn't any repeat ... until replacement in Python. > > So it is why I am here :-). The actual hot discussion i have read > on this thread and before indicates that although the topic was discussed > thorough the whole Python lifetime. So I'm not going to add any more > pros as there were so many mentioned. I simply come with an idea, > which seems attractive, so let's have it discussed. > > As far as I understand, the main reason against another loop construct > is the need to introduce a new keyword. Here is a solution, which doesn't > need it. And, IMHO, it is simple, elegant yet powerful: > > Let's extend the meaning of try and while. > > The try: statement could begin both the exception control and the loop. > Of course, in this case either the except clause or the while one would > be optional. > I would especially like constructs like this: > > try: > f = raw_input('Data file: ') > f = open(f,'r') > except IOError: > print 'Could not open file' > while not IOError > > What do You all think about it? > > Best regards > > Pawel Well the first observation is that nothing in your example actually processes the content of each file. Perhaps I can try to extend it in the same spirit to see what the code would look like actually processing the files... try: f = raw_input('Data file: ') f = open(f,'r') try: l = f.readline() # do some processing on the line while l != "" except IOError: print 'Could not open file' while not IOError In this example, no exception would be raised when the end of file is reached. The readline() method simply returns an empty string. The thing I don't like is that the test appears at the end of the loop but actually needs to be perfomed halfway through it, after the readline() call has been processed. This, I suspect, is the main reason why Alex Martelli has returned so often to remind us about the Knuthian "n-and-a-hlf-times" loop construct. (Alex: if I'm misrepresenting you here, do me a favor and just let it go by this once, eh? &v) Also, in both your original example and my extension, the final "while" statement has a condition which isn't really a Boolean. You appear to mean "as long as a particular exception has not been raised", but exceptions don't really work like that. You would end up having to clear a flag before the loop, and set it when the exception occurs: flag = 0 try: filename = raw_input('Data file: ') f = open(filename, 'r') # Process the file except IOError: print "Could not open file", filename flag = 1 while not flag which does not seem to be a real improvement over flag = 0 while not flag: try: filename = raw_input('Data file: ') f = open(filename, 'r') # Process the file except IOError: print "Could not open file", filename flag = 1 Also, of course, one might ask how this loop is intended to terminate "normally"? Do you enter a non-existent filename, a blank line, and end-of-file? How would this be taken into account, since no condition in your pseudo-code addresses this question? I hope I'm not being too critical here. I have nothing against attempts to improve the Python language (despite the endless threads such attempts generate). It says a lot for Python that so many people want to improve it still further. Just the same, I have a feeling that the language as it stands is good enough that improving it further is a non-trivial task. regards Steve From paulp at ActiveState.com Thu Jan 4 20:34:04 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 04 Jan 2001 17:34:04 -0800 Subject: AMK's ZODB package on Win32 References: Message-ID: <3A55248C.2B201655@ActiveState.com> Tim Peters wrote: > > [Paul Prescod] > > > > I was going to try the compile and see if it was easy but I note > > that you have filenames of ZEO and zeo in the directory ZEO. > > Note that this is already the subject of a bug report from the last > millennium : > > http://sourceforge.net/bugs/?func=detailbug&bug_id=126724&group_id=15628 It turns out that lower-case zeo is a shell script so I guess I don't need it to build. I can send some or all of these files to anyone who needs them: Directory of C:\temp\zodb\BTree\build\lib.win32-2.0 01/04/2001 05:03p 28,672 BTree.pyd 01/04/2001 05:03p 28,672 IIBTree.pyd 01/04/2001 05:03p 20,480 intSet.pyd 01/04/2001 05:03p 28,672 IOBTree.pyd 01/04/2001 05:03p 28,672 OIBTree.pyd 5 File(s) 135,168 bytes Directory of C:\temp\zodb\ExtensionClass\build\lib.win32-2.0 01/04/2001 05:04p 28,672 Acquisition.pyd 01/04/2001 05:04p 57,344 ExtensionClass.pyd 01/04/2001 05:04p 20,480 MethodObject.pyd 01/04/2001 05:04p 20,480 Missing.pyd 01/04/2001 05:04p 20,480 MultiMapping.pyd 01/04/2001 05:04p 20,480 Sync.pyd 01/04/2001 05:04p 20,480 ThreadLock.pyd 7 File(s) 188,416 bytes Directory of C:\temp\zodb\SearchIndex\build\lib.win32-2.0\SearchIndex 01/04/2001 05:04p 20,480 Query.pyd 01/04/2001 05:04p 20,480 Splitter.pyd 2 File(s) 40,960 bytes Directory of C:\temp\zodb\ZODB\build\lib.win32-2.0\ZODB 01/04/2001 05:04p 20,480 coptimizations.pyd 01/04/2001 05:04p 24,576 cPersistence.pyd 01/04/2001 05:04p 24,576 cPickleCache.pyd 01/04/2001 05:04p 20,480 TimeStamp.pyd 01/04/2001 05:04p 20,480 winlock.pyd Hopefully that's a complete set. I don't know anything about Zeo. Paul Prescod From glenfant at equod.com.nospam Thu Jan 11 11:16:12 2001 From: glenfant at equod.com.nospam (Gilles Lenfant) Date: Thu, 11 Jan 2001 17:16:12 +0100 Subject: Ingres II and Python References: <93kiqc$5k6$1@nnrp1.deja.com> Message-ID: <93klv7$3hb$1@reader1.imaginet.fr> Have you got an ODBC driver for Ingres (either Unix or Windows) ? If Yes, get mxODBC package from http://www.lemburg.com/files/python/ You'll find from this link all required information to play with databases using the DBI 2.0 API and install/setup your platform/db engine specific ODBC driver. If no ODBC driver is available... sorry there's no direct python bridge to Ingres II AFAIK. Happy new year anyway! a ?crit dans le message news: 93kiqc$5k6$1 at nnrp1.deja.com... > Does anyone have experience of accessing an Ingres II database using python ? > I haven't been able to find any references to ingres on the python site. Any > pointers in the right direction would be appreciated. > > Richard > > > Sent via Deja.com > http://www.deja.com/ From tim.one at home.com Mon Jan 1 16:31:42 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 1 Jan 2001 16:31:42 -0500 Subject: Recursion In-Reply-To: Message-ID: [Bob Calco] > I noticed the following while dabbling in Perl, Ruby and Python > recently. Take your standard factorial implementation, a la: You'll find that it's a lot faster to use iteration than recursion in these languages. > PYTHON > ====== > import sys > > def factor(n): > if n == 1: > return 1 Change that to return 1L and it will use unbounded ints instead. > else: > return n*factor(n-1) > > print factor(int(sys.argv[1])) > > fact.pl > ======= > sub fact { > my($n) = shift; > if ($n eq 1) { > return 1; > } else { > return ($n * fact($n-1)); > } > } > print fact($ARGV[0]), "\n"; > > fact.rb > ======= > def fact(n) > if n == 1 > 1 > else > n*fact(n-1) > end > end > print fact(ARGV[0].to_i), "\n" > > The highest value for n you can run in Python is 12; after that > you get overflow error messages. ints, longs (unbounded integers), and floats are distinct types in Python. The max size of an int depends on the platform, but on most machines it's a 32-bit signed integer (use sys.maxint to see what's true on your platform). Stick "L" at the end of an int literal to make it an unbounded int instead, or use the builtin long() function to convert to unbounded int. > In Perl, the largest value is 170 (after which you get 1.#INF for > an answer). All numbers in Perl are cast to C doubles internally (in the absence of some "use" directive trickery added to Perl5). Perl doesn't support unbounded integers natively (if you want them, you need to use a library module). > In Ruby, you can input a value as high as 763 before you get a > SystemStackError (stack level too deep) error. The recursion limit in Python varies across platforms; I assume that's true in Ruby too; in Python you can use sys.setrecursionlimit() to fiddle it (but if you set it "too high", you risk having the interpreter blow up due to C stack corruption). > Couple questions: > > 1. Why the vast difference between the languages? Why not ? > Is this apparent limitation in Python deliberate, or the > consequence of some other design decision? Python distinguishes between ints (native C "long") and longs (unbounded) because ints are often used as arguments to C libraries. If you want unbounded ints, you have to "do something" to get them. This distinction made more sense 10 years ago when it was first made; it's gotten more clumsy not because of factorials , but because systems are getting larger, and systems that support files larger than 2Gb are becoming more common (i.e., 32-bit signed ints no longer suffice for some common file operations). The distinction between ints and longs isn't as sharp as it used to be: every release, a few more pieces of the internals tolerate either. Over time, I expect the user-visible distinction will mostly vanish. > 2. In the real world, does this really matter? Does Ruby have any > meaningful advantage over Python in this regard? (I understand I > might get different replies if I asked this question on the Ruby > email list. I have different questions for Ruby fans!) If you need unbounded ints, Python and Ruby will both do fine, but Perl is a distant third in that respect. > I'm trying to decide which of these languages to embed in my > application or at the very least require in the user environment. I > like all of them, and I lean toward Python because it's much > cleaner than Perl and more mature than Ruby and Mark Hammond's > Win32 extenstion fully supports COM on Win32, which would make it > a very useful framework for prototyping our COM objects and > developing our own test suites to exercise them when they are > implemented in C++. But I was surprised to find such a difference > when testing each language's support for recursion. Except you didn't test recursion: you inadvertently tested limits on integer sizes (or, in Perl's case, the overflow limit of IEEE-754 doubles). most-people-should-never-use-numbers-ly y'rs - tim From heiland at ncsa.uiuc.edu Fri Jan 5 13:24:52 2001 From: heiland at ncsa.uiuc.edu (Randy Heiland) Date: Fri, 05 Jan 2001 12:24:52 -0600 Subject: JPython install problem References: <3A55E1F9.60E033EF@ncsa.uiuc.edu> Message-ID: <3A561174.5B066FA0@ncsa.uiuc.edu> Never mind... I just discovered Jython (http://jython.sourceforge.net/) instead of JPython (jpython.org). I think this has/will solve my problem... --Randy From phys137 at mailcity.com Wed Jan 10 21:11:11 2001 From: phys137 at mailcity.com (phys137 at mailcity.com) Date: Thu, 11 Jan 2001 12:11:11 +1000 Subject: Coding Efficiency References: <3A5B6586.50B51F68@gte.net> Message-ID: <93j16q$k6n$1@mail.pl.unisys.com> long time ago i even published something related to that. Then C++ was new and the hope was that inlining [available in C++ but not in C] could change that. Just for fun I took some programs - (not in C++) and did semi-automatic inlining of leaves - some of them. the mean number of instructions between jumps grew up 10 times(!). That was for the compiler. For other programs (db, numerical) the numbers were above 5 times. Looking at the same problem now I see the pipelining problem is unlikely to get better - oo programming actively prevents you from inlining most of the time. There may be some hope for functional languages - the higher the level the better you can play with instructions (inlining, loop unrolling etc) "Steve Williams" wrote in message news:3A5B6586.50B51F68 at gte.net... > I saw this in an otherwise worthless thread on Slashdot about OOP: > > Another reason ... (Score:5, Informative) > by taniwha on Tuesday January 09, @12:40PM EST (#54) > (User #70410 Info) http://www.taniwha.com/nospam.jpg > (for the record I first wrote smalltalk code in the 70's, I > regularly code in C++ ...) > > I'm a sometimes chip designer, sometimes programmer ... a > while back while > working on an unnamed CPU project I did some low level > performance analysis on > a number of well known programs (maybe even the browser > you're using now) > basicly we were taking very long instruction/data traces and > then modelling them > against various potential CPU pipeline/tlb/cache > architectures - we were looking for > things that would help guide us to a better architecture for > our CPU. > > I found that quite early on I could figure out which language > something was coded > in from the cooked numbers pretty easily - OO (ie C++) coded > stuff always had a > really sucky CPI (clocks per instruction - a measure of > architectural efficiency that > includes pipe breaks, stalls and cache misses) - I spent some > time looking at this > (since it seemed that C++ code would probably become more > common in our CPU's > lifetime) - basicly C++ code sucked because it took more > icache hits (because the > coding style encourages lots of subroutine calls which tend > to spread over the > cache more filling the I$ quickly) and it took more pipe > breaks (also due to the > subrotine calls and returns - it turned out that some code > generators did stuff that > broke CPU's return stack caches causing many more > mispredicts) and finally virtual > method dispatches (basicly load a pointer, save the pc on the > stack and jump to the > new pointer) tended to cause double pipe stalls that couldn't > be predicted well at all > even though these weren't done much they were a real killer > (if you've one a bit of > modern CPU architecture you learn that with long pipes you > live or die on your > branch predictor's hit rate - these were very bad news) > > In short C++ and more genrally OO result in code and coding > styles that tend to > make code that makes modern CPU's run less efficiently. > > Anyway - you often hear about 'efficiency of programmers' etc > etc for OO - I > thought I'd add a data point from the other end of the > spectrum. > [ > From m.faassen at vet.uu.nl Wed Jan 10 08:56:20 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 10 Jan 2001 13:56:20 GMT Subject: Notice: Status of the PSU Message-ID: <93hpm4$k1k$1@newshost.accu.uu.nl> Dear fellow PSU members, There has arisen some confusion about the continued existence the PSU in the light of the PSA (http://www.python.org/psa/) 'no longer serving a real purpose'. Members of the PSU (Python Secret Underground) have been asking whether this means the PSU has no purpose anymore either. It does. The timbot (Roswell version) has instructed me to clarify matters for our members on this mailing list. Probability notices in the following update are as always subject to the general unreliability principle. See also references listed at the bottom. Recent explorations with Guido's time machine have shown us that the alien whitespace eating nanovirus invasion is still a real threat (0.9), although engine troubles in the alien starship seem to have shifted the projected invasion to the third decade of this millennium (0.7). Due to the nature of their uncertainty inducer drive it is possible (0.05) however that the invasion date is shifted forward to 2001. Therefore we must remain vigilant (0.8). The recent move of Guido & co to Digital Creations was coordinated by the PSU [3] by replacing timbot (normal) temporarily with timbot (Roswell), who then influenced matters appropriately. timbot (normal) has however been placed back with memory buffers wiped, do NOT approach timbot (normal) as this entity is not a member. Extra confusion is created by the fact that both timbots are posting; one is aware [1], the other isn't. The original timbot has been reprogrammed to selectively ignore timbot (Roswell). The PSA will in due time be replaced with another cover organisation when necessary. Recent advances with element Base_AQ (Zoperium) technology are hopeful, though. We may be able to stop the nanoviruses. Everything is still on track for the Roswell event [2], which is necessary to close the timelike loop. References in chronological order: [1] http://www.deja.com/getdoc.xp?AN=518234374 [2] http://www.deja.com/getdoc.xp?AN=614140340 [3] http://www.deja.com/getdoc.xp?AN=687533933 Warning: Do NOT forward this message beyond the PSU mailing list! Those who do will be eliminated from the timestream (0.97). Anonymous-ly From tim.one at home.com Mon Jan 1 18:42:27 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 1 Jan 2001 18:42:27 -0500 Subject: split hangs In-Reply-To: <14C1lH-44b-00@mercurio.localdomain> Message-ID: [davide at mercurio.localdomain] > I tried the equivalent regexp in emacs > <\([^<>"]+\("[^"]*"\)?\)+> > with bigger and bigger files and it does not seem to give an > exponential behaviour. Haven't tried it myself, but I can believe it. > In everything I read regexp matching is given as a linear time > problem in n + m (where n is the size of the testing string > and m the size of the regular expression). Then you had better start reading better stuff . I'll repeat the original recommendation: Jeffrey [note: I erroneously said Jonathan before] Friedl's excellent book "Mastering Regular Expressions" (O'Reilly). There are two "obvious" ways to implement a regexp engine. One extreme Friedl calls "the NFA" way (although he's using "NFA" in a sense that differs from its technical meaning in the literature). It compiles the regexp into a data structure in O(m) time, then uses a backtracking search engine to do the actual match. As Friedl explains in excruciating detail, the matching process *can* take time exponential in n, depending on exactly what's in the regexp, what's in the string, and how the backtracking engine is written. Different implementations use different tricks that save them from exponential behavior in different cases. Here's a simple Python example: find = re.compile("(x+)+y$").match That takes time exponential in n when applied to strings of the form "x" * n I can't make time for it now, but perhaps someone else would like to explain how that happens, step by step. The other extreme Friedl calls "the DFA" way (and here his meaning does match the technical literature). The matching process there takes O(n) time worst case. The rubs are that the initial processing of the regexp may take time exponential in m (converting an NFA to a DFA can cause exponential explosion in the number of states), and that pure DFAs can't handle backreferences. No free lunch. More sophisticated schemes try to get the best of both worlds via a hybrid. They can get very complex. For example, study the source for Henry Spencer's hybrid in recent Tcl: if you can make sense out of two lines of it, you're way ahead of the game . Note that the literature talks about "real" regular expressions. Backreferences change the game profoundly. This page links to a proof that the matching problem for Perl regexps (and so also Python's) is NP-complete: http://perl.plover.com/NPC/ That means it's almost certainly not possible to do better than exponential time in all cases (in the presence of backreferences), no matter what implementation is used. Most languages implement NFA-flavor engines because backreferences are hard to handle at all in a DFA framework; "compiling" to an NFA goes very fast; NFA engines are generally pretty easy to extend and to optimize for common special cases; for whatever reasons, in my experience most programmers find NFA semantics (in Friedl's sense, not the technical one) easier to understand; and there are only so many tens of thousands of lines of code impelementers want to devote to stinking regexps <0.9 wink -- but Python already has more code in its distribution devoted to regexps than to any other identifiable subsystem>. stick-to-simple-regexps-for-simple-purposes-or-live-with-the- consequences-ly y'rs - tim From jaapspies at home.nl Sun Jan 28 12:57:00 2001 From: jaapspies at home.nl (Jaap Spies) Date: Sun, 28 Jan 2001 17:57:00 +0000 Subject: Hack request: rational numbers References: <951h34$tch$1@nnrp1.deja.com> Message-ID: <3A745D6C.2EEA931@home.nl> chaoweilun at my-deja.com wrote: > > > that uses similar syntax as in constructing Python complex numbers > > (cf. 3j+4). > > Sorry,BTW,could anyone tell me,why the letter "j" is used > to represent complex numbers, but not "i"? > > Sent via Deja.com > http://www.deja.com/ You are a mathematician? Me too. A lot of Python People are Mathematicians. Nevertheless "j" will do! My late professor Freudenthal said: "A good mathematician is independent of notation" Jaap Spies From emile at fenx.com Wed Jan 17 20:27:44 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 17 Jan 2001 17:27:44 -0800 Subject: Finding source from class or instance? References: <979777210.145620@sj-nntpcache-5> Message-ID: <945gse$c743k$1@ID-11957.news.dfncis.de> An instance has access to a __class__ attribute, and a class to a module attribute, and sys.modules holds the file name in which the class was defined. srceClass = inst.__class__ srceModule = srceClass.__module__ sys.modules[srceModule].__file__ or in one step from an instance: sys.modules[inst.__class__.__module__].__file__ That gets you to the file anyway. If you're so inclined, you can then open, read and extract the code for the class. HTH, -- Emile van Sebille emile at fenx.com ------------------- "Stuart Stanley" wrote in message news:979777210.145620 at sj-nntpcache-5... > > > Folks, > > Is there a (easy!) way to get the source code from a class or instance > of a class? A preference would lie in just getting the source of the > base class itself, but I would settle for getting the file name where > the base class lives in. I figure the information is sitting in the > modules somewhere, but I don't know how to navigate there to get it.... > > Thanks! --stuart > > > -- > "Computer Science is no more about computers than | Stuart Stanley > astronomy is about telescopes." - E. W. Dijkstra | stuarts at cisco.com > | Cisco Systems, inc > | St Paul, MN > | 612.578.6412 From grante at visi.com Fri Jan 12 10:45:15 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 12 Jan 2001 15:45:15 GMT Subject: Python and Industry References: <20010111172342.10148.00000934@ng-ca1.aol.com> Message-ID: In article <20010111172342.10148.00000934 at ng-ca1.aol.com>, Crutoy wrote: >Hi , does anyone know how widly in an instries does python being used ? I use it in industry. We ship with one of our products a small admin tool that's written in Python. I also use Python to write small test programs that are used to drive/simulate some our products for test purposes. I've also used small Python scripts to automate the process of building software assemblies from sub-assemblies. RedHat uses Python for some of their install/config utilities. -- Grant Edwards grante Yow! The Osmonds! You are at all Osmonds!! Throwing up visi.com on a freeway at dawn!!! From moshez at zadka.site.co.il Sat Jan 6 12:54:21 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 6 Jan 2001 19:54:21 +0200 (IST) Subject: How robust is Python ? In-Reply-To: <9365p9$s2k$1@nnrp1.deja.com> References: <9365p9$s2k$1@nnrp1.deja.com>, <9358nn$3c5$1@nnrp1.deja.com>, <9354f9$vbi$1@nnrp1.deja.com>, Message-ID: <20010106175421.DF584A828@darjeeling.zadka.site.co.il> On Sat, 06 Jan 2001, rturpin at my-deja.com wrote: > In theory, that's an application flaw, rather than a > bug in the compiler or libraries. In practice, good > software engineering produces C/C++ programs that > very rarely dereference bad pointers. It's harder > and more work than development with Python. I have programmed in C/C++ and I know what I'm talking about. *Of course* you can have long running processes in C/C++: take things like Linux, which run for years with no problems. I'm just saying that making a C/C++ app which runs without problems is much harder, so I would be less inclined to trust C in that role. Of course, other factors may decide the problem for me, such as in... > Keep in mind that Python *is* a C program. I know that. It's one of the few C programs which are being debugged daily by thousands of people around the world, with a very mature code base. I doubt many companies can expect to achieve this level of robustness for their apps. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From aleaxit at yahoo.com Tue Jan 16 08:51:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 16 Jan 2001 14:51:07 +0100 Subject: SQL-Statement with Python References: <3A62E224.7AEE805E@students.uni-linz.ac.at> <93ut4q031hd@news1.newsguy.com> Message-ID: <941jnd0634@news1.newsguy.com> "Steve Holden" wrote in message news:R2M86.5299$J76.42003 at e420r-atl1.usenetserver.com... [snip] > > ActiveState distribution, but even if you started with the standard > > distribution you probably want to add win32all anyway if you work > > with Python under Windows... it has just too many nifty things!-). > > > I might take issue with this (despite my last run-in with the martellibot... > Perhaps I should just do this first [thwack, thwack, thwack]). There, that's > better. You dispute that one probably wants to add win32all if one works with Python under Windows...?! *Eeeek*. Let's see, where did I put the tar and feathers... > > rows = recordset.GetRows() > > for first, last in zip(rows[0], rows[1]): > > print "%s, %s" % (last, first) > > > That's the bit I don't like. You call the GetRows method, and what does it > return? Columns, mate, that's what. At least to the Python user. Not what I > call intuitive. Yeah, I agree on this detail -- two-dimensional arrays are always a bother to translate between languages which think the first index varies fastest (Fortran, Visual Basic, ...) and those which think it varies slowest (C/C++, Java, Python, ...). GetRows was clearly written by somebody thinking of a language of the first ilk:-). Anyway, if that bothers you too much you get to choose among a zillion other ways to ask a recordset for its contents, e.g....: for row in recordset.GetString()[:-1].split('\r'): first, last = row.split('\t') print "%s, %s" % (last, first) Or, simpler and faster, one can show off one's command of 'advanced' SQL:-), and get the *db engine* to do one's work: recordset, result = connection.Execute( "Select LastName//', '//FirstName From Employees Order By LastName") print recordset.GetString().replace('\r','\n') > I'm sure you'll have a great explanation for it, though. Mark Hammond's was > pretty good. Explanation for _what_ 'it'? I must be confused... Alex From fredrik at effbot.org Sun Jan 21 12:04:03 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sun, 21 Jan 2001 17:04:03 GMT Subject: Static members? References: <94f3rf$m6j$1@nnrp1.deja.com> Message-ID: <7EEa6.8086$AH6.1279039@newsc.telia.net> fray_fernando at my-deja.com wrote: > How do you define a class that has an attribute common to all instances > of this class? Something like the static members in C++ http://www.python.org/doc/FAQ.html#4.84 "How do I create static class data and static class methods?" class C: count = 0 # number of times C.__init__ called def __init__(self): C.count = C.count + 1 def getcount(self): return C.count # or return self.count Cheers /F From phd at phd.pp.ru Tue Jan 23 07:32:27 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 23 Jan 2001 15:32:27 +0300 (MSK) Subject: Determining Content-Type In-Reply-To: <3A6D769F.E6F7A32F@qbcon.com> Message-ID: On Tue, 23 Jan 2001, Andreas Pauley wrote: > I would like to know if there is a way for me to determine the HTTP > Content-Type header of a file residing on disk. You cannot determine - you can only guess. For good guess, use mimetypes.py from standard library. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From paul at digicool.com Sat Jan 13 10:37:22 2001 From: paul at digicool.com (Paul Everitt) Date: Sat, 13 Jan 2001 10:37:22 -0500 Subject: zodb & multiple processes References: Message-ID: Just to add a point on Kapil's info. ZEO is certainly more heavyweight on reads and writes when it doesn't have the data locally. However, ZEO has two levels of cache on the individual processes (in-memory and on disk), and transactions committed in another process send cache invalidation messages to other clients. For some types of applications (such as web apps), this approach works. There are many times more reads than writes for most web apps, and usually a minority of the objects are used a majority of the time. For other types of apps this approach can incur the network and pickling overhead. With the move to BSDDB3 as the preferred storage for future ZODB work, this might open up some opportunities for multiprocess access. --Paul On 1/10/01 10:00 PM, in article Yk976.1119$mX.27921 at newsread2.prod.itd.earthlink.net, "Kapil Thangavelu" wrote: > yes the zodb is thread safe (zope is multithreaded). it actually makes > programming > multithreaded programs a bit easier as objects which inherit from the > persistent classes > become thread safe (although it assumes a bit optimism regarding the rate of > object changes, > the optimism won't corrupt your data but its something to be aware of). > > as long as your're objects are not changing frequently its a pretty good way > to avoid lots of > concurrency control around your objects. > > currently the zodb assumes a process lock on a particular zodb storage. if > you want to run it with > multiple processes you can use ZEO, which is a bit heavyweight if you want > your app to run on > one machine as it communicates over tcp/ip. > > for more info check out jim fulton's IPC 8 paper on zope.org and amk's > starship homepage. > > kapil > > > Erno Kuusela wrote in message > news:kuhf36hotz.fsf at lasipalatsi.fi... >> hello, >> >> from the looks of things, zodb is thread-safe in that you can use >> connections to the same storage from many threads at once and >> have it not break. >> >> how about multiple processes? will it just work, just not work, >> or require special incantations? >> >> -- erno > > From aleaxit at yahoo.com Fri Jan 12 05:12:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 12 Jan 2001 11:12:12 +0100 Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> <93dde1$8d2$1@animus.fel.iae.nl> <93f3nb023mv@news1.newsguy.com> <90259DC4Arcamesz@127.0.0.1> <93i57b01qms@news2.newsguy.com> <90268BCE3rcamesz@127.0.0.1> <93kb0m0r3s@news1.newsguy.com> <90273B4rcamesz@127.0.0.1> Message-ID: <93mlct0gse@news1.newsguy.com> "Robert Amesz" wrote in message news:90273B4rcamesz at 127.0.0.1... [snip] > > xx = enum('foo=%s'%base1, 'foo2', 'foo3', 'bar=%d'%base2, 'etc') > > > >here, base1 is accepted whatever type it is (as long as it's able > >to produce a string-form:-), but base2 is requested to be able to > >produce an integer specifically. > > Hmm I see a problem here: doesn't the %-operator take a tuple on the > right hand side, or has that changed in 2.0? In 1.52 it should be: > > xx = enum('foo=%s'%(base1,), 'foo2', 'foo3', 'bar=%d'%(base2,), > 'etc') > > That doesn't make it any prettier. Python 1.5.2 (#1, Sep 17 1999, 20:15:36) [GCC egcs-2.91.66 19990314/Linux (egcs - on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> print "foo%dbar" % 23 foo23bar >>> > As both forms seem equally capable to get the job done, and I can't see > the one method being significantly more efficient that the other, in > the end it would an argument over aesthetics. > > Aesthetic argument 1: I don't like data making an unneccesary roundtrip > into a different domain. When using 's=n' numeric data (n) has to be > expressed as a string. > > Aesthetic argument 2: The form 's=n' is in fact a tuple coded as a > string, so why not get rid of the coding and make it explicit? After > all, one of Pythons design paradigms would to be: "explicit is better > than implicit". Two good points (which really boil down to one). Counterpoints would include "it's nicer to have all strings than some strings and some tuples", and "other languages allowing such explicit specs [C/C++ only, AFAIK] use the name=value syntax, so that will be easier to read for people coming from those languages". But I'm just arguing for argument's sake -- it's an obscure corner of an obscure idiom, and both usages look pretty much OK to me for something likely to see frequencies as low as this. > Oddly enough, the thing which attracted me to Python was the C-meets- > Lisp quality of its syntax. Both C and Lisp are - in my opnion - among > the purest and most minimalist types of languages. Python seems to be > able to combine the two extreme paradigms into an effective, yet clean > language. Nolo contendere -- and I'd add that C and Lisp seem to me to have (opposite) serious syntax flaws, making their underlying semantic simplicity harder to grasp/appreciate for some, while Python's syntax is SO clean and neat. Alex From jwbnews at scandaroon.com Sat Jan 27 21:22:16 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sat, 27 Jan 2001 18:22:16 -0800 Subject: . Python 2.1 function attributes References: Message-ID: In article , "Tim Peters" wrote: > Barry also added code to Python 2.1 to let you write, e.g., > > def f() >> x: > x = 1 > y = 2 > > as a short way to spell "whatever the value of x is at the end of the > function, return that". I'm sure you'll agree that's much cleaner than > the > clumsy > > def f(): > x = 1 > y = 2 > return x > > people suffer with today. > > hoping-a-truly-bad-idea-adds-some-perspective-ly y'rs - tim Hmmm...seems to be a kin to an early boss' idea (ca 1965-1969) that the comefrom and various conditional forms of comefrom could replace the goto and various conditional goto forms. Marty went to a fair amount to trouble to prove to himself that the idea worked (but without any intention of actually building it, so far as I know.). --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From joejava at dragonat.net Tue Jan 9 12:47:28 2001 From: joejava at dragonat.net (Joel Ricker) Date: Tue, 9 Jan 2001 12:47:28 -0500 Subject: Migrating to perl? References: <93f5ko$o4e$1@saltmine.radix.net> Message-ID: Cary O'Brien wrote in message <93f5ko$o4e$1 at saltmine.radix.net>... [*snip*] >Did I make any mistakes? >-- cary Not that I can see. Thats exactly what I'm seeing. I'm quite happy with the number of modules available for Python. I just finished reading the tutorial and found Python to be quite easy and I'm definitely going to be sticking with it. I'll just have to write a few modules of my own to fill in the gaps :) >[1] Check out PostgreSQL before you decide on MySQL. A python > interface comes with it. I've heard good things about PostgreSQL but since my web hosting package comes with MySql, thats what I've been learning. Joel -- I have been Perl-Free for 4 Days, 14 Hours, 57 Minutes, and 55 Seconds. ----------------------------------------------------------------------- Joel Ricker joejava at dragoncat.net Just Another Python Hacker From jp at NOSPAMdemonseed.net Mon Jan 15 17:56:55 2001 From: jp at NOSPAMdemonseed.net (jason petrone) Date: Mon, 15 Jan 2001 22:56:55 +0000 Subject: python compiled to native in less than a year? References: Message-ID: Giuseppe Bilotta wrote: > Knowing M$, at least one of the following will hold : > 1) M$ will not cleanly document IL, making it almost impossible to know it > appor priately; Actually, the IL documentation is pretty good. Assuming the MS implementation of it follows the specification, this won't be a problem. > 2) M$ will patent IL, so royalties will have to be paid for its use (aka: > bye-by e, Free Software) Right now MS is trying(along with HP) to get IL accepted by a standards commitee, though I forget which one. If this happens, there won't be a patent problem. However, MS also tried to put ASF on the standards track, but gave up and went the patent route instead, so who knows. -jason From prestonlanders at my-deja.com Wed Jan 10 17:21:31 2001 From: prestonlanders at my-deja.com (Preston Landers) Date: Wed, 10 Jan 2001 22:21:31 GMT Subject: why is this namespace weirdness happening? References: <93i3f7$122$1@nnrp1.deja.com> <93i7cg$55i$1@nnrp1.deja.com> Message-ID: <93in8v$ku9$1@nnrp1.deja.com> In article <93i7cg$55i$1 at nnrp1.deja.com>, chris_barker at my-deja.com wrote: > And yes, this does take some getting used to, but it does follow some > pretty simple logic, once you get python's "everything is a reference" > and "mutable types" concepts. Thank you and Frederick for the cogent, helpful explanations. Preston Sent via Deja.com http://www.deja.com/ From quinn at groat.ugcs.caltech.edu Tue Jan 30 03:30:34 2001 From: quinn at groat.ugcs.caltech.edu (Quinn Dunkan) Date: 30 Jan 2001 08:30:34 GMT Subject: xor operator? References: Message-ID: On Mon, 29 Jan 2001 13:02:30 +0100, jurgen.defurne at philips.com wrote: >I have indeed never met a language which had a boolean XOR (but some >have a binary XOR). if true xor false then std_output.put_string("eiffel does!%N"); end; -- and we can't use the std abbreviations, either, Just Because! Not that I've ever actually used it or anything. We only need one kind of loop, because that's "minimal", but hey, pile on the random boolean operators! :) From aleaxit at yahoo.com Thu Jan 25 06:05:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 25 Jan 2001 12:05:37 +0100 Subject: The fundamentals... References: Message-ID: <94p1a301vv2@news2.newsguy.com> "Mike Read" wrote in message news:F8Jb6.30683$pp2.2619941 at news3.cableinet.net... > Newbie first script alert! No problem - it does what I intended (which > probably says more about Python than me...), but I just wanted to start > off on the right foot - is it as elegant as it could be? If it's not blindingly > obvious, I was separating fields around a period delimiter. Not bad! It IS simple. It can be changed in various ways, but it's debatable whether this increases 'elegance'. You can use string objects' built-in methods instead of the string module (if you don't have Python 2 yet, get it -- don't suffer with the limitations of 1.5.2....!-). You can use normal / slashes rather than repeated backwards \\ ones. You need not provide the explicit 'r' when you are opening a file for reading. And you need not name all intermediate values. So, specifically: > import string > test = open('\\Windows\\Desktop\\test.txt', 'r') > boo = test.read() > boo = string.split(boo , ". ") > boo = string.join(boo , "\n") > > outfile = open('\\Windows\\Desktop\\out.txt', 'w') > outfile.write(boo) > outfile.close() can become, for example: data = open('/Windows/Desktop/test.txt').read() data = '\n'.join(data.split('. ')) open('/Windows/Desktop/out.txt','w').write(data) or various other combinations yet of named and unnamed temporary results -- all the way down to one *rather goofy* single expression: open('/Windows/Desktop/out.txt','w').write( '\n'.join(open('/Windows/Desktop/test.txt') .read().split('. ')))) but of course that would be VERY inelegant, not very readable, fragile, and complicated to no good purpose! Deciding what to split out and how to name it, and what to keep 'joined', is a matter of taste and style. Splitting out 'outfile' for example has the advantage of allowing an explicit close, not strictly necessary today in CPython but still a GOOD idea (explicit is better than implicit). But one can also end up splitting things a little bit too much -- particularly when the names for the intermediate results are not well chosen (and 'boo' isn't:-), this adds no real clarity in my personal (& humble) opinion. "Moderation in all things" is one viable guideline on such issues of taste and style, I think. Alex From amk at mira.erols.com Mon Jan 15 23:21:34 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 16 Jan 2001 04:21:34 GMT Subject: re findall mod for issue of side effects References: Message-ID: On Mon, 15 Jan 2001 08:11:43 -0500, Andrew Henshaw wrote: >As to your suggestion (a new flag on regexp compilation meaning "all my >parens are non-capturing"), I'd still like to retain the ability to use the >non-capturing flag to exclude portions from the return string. This may be This problem is because .findall() only returns the string corresponding to all of a match. Someone else has suggested a .findall() variant which returned the actual match objects, so then you could loop over them all and construct whatever string you like. It seems potentially cleaner to invent a name or interface for such a variant and get it accepted. (Hurry! Maybe it can still get into 2.1!) --amk From LCKJAM003 at mail.uct.ac.za Thu Jan 18 17:44:19 2001 From: LCKJAM003 at mail.uct.ac.za (James Lockley) Date: Fri, 19 Jan 2001 00:44:19 +0200 Subject: Using python to call .bat files-- thanx References: <3A676D38.5D972E12@mail.uct.ac.za> Message-ID: <3A6771C3.B4372013@mail.uct.ac.za> Nils, Frederik, thank you for the help will try that in the morning Cheers ! james From nickb at earth.ox.ac.uk Fri Jan 19 05:42:59 2001 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Fri, 19 Jan 2001 10:42:59 +0000 Subject: Literate programming in Python References: Message-ID: <3A681A33.C49C1920@earth.ox.ac.uk> Giuseppe Bilotta wrote: > Hello, > > I'd like to know if there exist a "literate programming" language for Python (possibly using the same structure/conventions of > WEB/CWEB, the first literate programming languages, developed by D.E.Knuth and Silvio Levy, resp. for Pascal and C/C++). > I have used Interscript -mentioned by others - for a number of years quite usefully - not sure of the CWEB syntax but I think its similar. I found that a bit clumsy so wrote a WYSIWYG editor for it using Python/Tkinter - rough but easy. - it certainly works. Maybe a bit slow for big projects but it sure maintains readability!! cheers Nick/Oxford From cfelling at iae.nl Sat Jan 20 17:47:16 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 20 Jan 2001 23:47:16 +0100 Subject: Translating a Perl script into Python References: Message-ID: <94d4hk$1sq$1@animus.fel.iae.nl> My ISP is having problems with its feed so I'm a little late to react and there is only one little thing for me left to nitpick:( Sheila King wrote: for this piece of code > print PROC "$key = $ENV{$key}\n"; you used > PROC.write(key + " = " + os.environ[key] + "\n") whereas I often prefer (the (to me atleast) more Pythonic) PROC.write("%s = %s\n" % (key,os.environ[key]) and yet in some circumstances even the more elaborate variant PROC.write("%(key)s = %(value)s\n" % {key:key, val:os.environ[key]}) The latter form comes very close to the Perl way of coding, and is espescially suited for format strings spanning several lines. -- groetjes, carel From spamers at must.die Sat Jan 27 13:10:07 2001 From: spamers at must.die (Fernando Rodríguez) Date: Sat, 27 Jan 2001 19:10:07 +0100 Subject: Avoiding the __repr__ call or protecting an instance from evaluation URG. please Message-ID: Hi! I have a class whose __repr__ method returns a string. Whenever I pass an instance of this class to a function, what the function gets is the result of __repr__. Most of the time this is OK, but under certain circumstances I also need to make sure that a function receives an instance of the class, and the the string that __repr__ returns. How can I do this? O:-) PS This is my __repr__ method: def __repr__( self ): return ",v" + str(self.tag) +", " //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From sdm7g at virginia.edu Tue Jan 23 12:55:24 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 23 Jan 2001 12:55:24 -0500 (EST) Subject: OT: SourceForge problems [was: libraries=['m'] in config.py [Re: Python 2.1 alpha 1 ... ]] In-Reply-To: Message-ID: Please excuse the OT: I don't see any point in adding another unanswered me-to complaint to the dozens already on SourceForge. Since there's a lot of SourceForge users on this list maybe somebody knows what's up: SourceForge seems to be pretty effectively broken for "new" projects ("new" = those registered in the last month or two. ) There are dozens of queries on the SF discussion forums from people having the same problems -- can't log in with ssh or cvs using ssh. Other than a few well meaning "try this" responses that don't help, and a status report that says that there is "some delay" with new projects, there's not much response to any of those problems. Does anyone know what going on at SourceForge ? ( I've been unable to update the Python<->objective-c bridge. ) -- Steve Majewski From joejava at dragonat.net Sat Jan 6 18:33:22 2001 From: joejava at dragonat.net (Joel Ricker) Date: Sat, 6 Jan 2001 18:33:22 -0500 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <933fa1$j2i$1@newshost.accu.uu.nl> <3a57342f.92981493@nntp.sprynet.com> Message-ID: David C. Ullrich wrote in message <3a57342f.92981493 at nntp.sprynet.com>... [..] >You should do what Tim said: Download it and work through the >tutorial. Really will take less time than reading this thread. Thats true. I've spent more time keeping up with this thread than reading the tutorial. Thats why I've only gotten up to Chapter 5 :) >The docs are excellent. But they omit a few important >principles. Like "always believe Tim". So far I've had no reason to doubt him. Joel ' From m.hadfield at niwa.cri.nz Thu Jan 25 15:52:30 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Fri, 26 Jan 2001 09:52:30 +1300 Subject: 4NT and Python References: Message-ID: <980455950.371212@clam-ext> "Ben Catanzariti" wrote in message news:n46o49.p5k.ln at mail... > Does anyone here use 4NT (or any of JPSoft's win32 shell scripting > products)? I did for several years, but these days I mostly use the Cygwin bash shell > Is there away to pass information dynamically/piping > between the Python and 4NT and vice versa? Well, you can use the input/output redirection facilities of the 4NT shell (or the Unix shells or the Windows cmd.exe and command.com shells) to send data to & from a Python process. For Python to participate, the script needs to read data from sys.stdin and write it to sys.stdout & sys.stderr. Is this what you mean? If so, and you want examples or more info, please contact me. > PS Outputting data toa text file is not dynamic ;) No text files are involved in the above process. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/ National Institute for Water and Atmospheric Research PO Box 14-901, Wellington, New Zealand From grey at despair.rpglink.com Thu Jan 18 17:31:11 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 18 Jan 2001 22:31:11 -0000 Subject: Why no isexec, isread, iswrite, etc (was: I must be missing something obvious: os.path.isexecutable?) References: Message-ID: On Thu, 18 Jan 2001 21:49:32 -0000, Steve Lamb wrote: > OK, after further digging on deja I found a thread between Fredrik Lundh >and Lenny Self regarding using the os.stat() call with the stat macros. Is >there an easier way? OK, pardon the stream of thought thread here, but I have found my answer to the Python equivalent of the Perl -x check. Now for a fun question. I see that os.path has isdir, isfile, islink defined. In fact my initial confusion is that os.path didn't have isread, iswrite, isexec. It seemed logical. then I foudn the above mentioned conversation with the macros from stat coming into play. So I dug into os.path.py, bounced into posixpath.py, and see that isdir, isfile and islink use the stat macros. So why not complete the suite of tests possible from the stat macros and have read/write/exec tests in there as well? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From codebert9 at users.sourceforge.net Tue Jan 2 01:55:04 2001 From: codebert9 at users.sourceforge.net (Jeffrey Drake) Date: Tue, 02 Jan 2001 06:55:04 GMT Subject: Python Imaging Library and Windows HELP! Message-ID: I just downloaded and installed the Python Imaging Libary for windows, and it basically has a set of py files, a dll. There is absolutely no documentation of what to do with this stuff. I added the directory to the pythonpath environment variable, copied the .dll to the /windows/system dir and then when running a program that uses it - ---------- C:\Python20\OpenGL\nehe>python lesson6.py Hit ESC key to quit. Traceback (most recent call last): File "lesson6.py", line 225, in ? main() File "lesson6.py", line 218, in main InitGL(640, 480) File "lesson6.py", line 77, in InitGL LoadTextures() File "lesson6.py", line 58, in LoadTextures image = image.tostring("raw", "RGBX", 0, -1) File "c:\python20\py152\pil\Image.py", line 325, in tostring self.load() File "c:\python20\py152\pil\ImageFile.py", line 125, in load self.load_prepare() File "c:\python20\py152\pil\ImageFile.py", line 175, in load_prepare self.im = Image.core.new(self.mode, self.size) File "c:\python20\py152\pil\Image.py", line 40, in __getattr__ raise ImportError, "The _imaging C module is not installed" ImportError: The _imaging C module is not installed C:\Python20\OpenGL\nehe> ------- Nobody in EFnet/irc.openprojects.net:#python seem to be able to help with this. Most of them are on linux, though. If anyone can help me with this I would really appreciate it. Regards, Jeffrey Drake feel free to email me From mwh21 at cam.ac.uk Mon Jan 15 05:31:34 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 15 Jan 2001 10:31:34 +0000 Subject: names References: Message-ID: "Elliott Chapin" writes: > How can I get the name of an object as a string? As a biginner I might > imagine something like > > >>>b=[[1],[2]] > >>>name(b) > 'b' >From http://www.amk.ca/quotations/python-quotes.html: The same way as you get the name of that cat you found on your porch: the cat (object) itself cannot tell you its name, and it doesn't really care -- so the only way to find out what it's called is to ask all your neighbours (namespaces) if it's their cat (object)... ....and don't be surprised if you'll find that it's known by many names, or no name at all! Fredrik Lundh, 3 Nov 2000 one of many quotes that should really be memorised by everyone associated with Python.... Cheers, M. -- And then the character-only displays went away (leading to increasingly silly graphical effects and finally to ads on web pages). -- John W. Baxter, comp.lang.python From grante at visi.com Wed Jan 3 09:58:28 2001 From: grante at visi.com (Grant Edwards) Date: 3 Jan 2001 08:58:28 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jan 3) Message-ID: <902807ECF2329498.C74C97895AF7B06F.E6FC5F2787487C35@lp.airnews.net> Niklas Frykholm announces preliminary work on the consequential problem of practical HTML (and SGML) parsing http://x56.deja.com/[ST_rn=ps]/getdoc.xp?AN=711302528 Alex Martelli makes MediaPlayer comprehensible http://x73.deja.com/[ST_rn=ps]/getdoc.xp?AN=711305977 exemplifies htmllib use http://x66.deja.com/[ST_rn=ps]/getdoc.xp?AN=711130173 comments on use of classes and OOP http://deja.com/=dnc/getdoc.xp?AN=708325609 and announces gmpy 0.8 release for those in need of fast, high-precision arithmetic) http://deja.com/=dnc/getdoc.xp?AN=709390524 Raja S illuminates the history of exceptions pertinent to Python (those playing along at home should notice one follow-up corrects an out-of-place parenthesis) http://x56.deja.com/[ST_rn=ps]/getdoc.xp?AN=707412222 Tim Peters demonstrates how he thinks about regular expressions http://x53.deja.com/[ST_rn=ps]/getdoc.xp?AN=711103603 fgleeson reports on early experience with the Komodo preview http://x65.deja.com/[ST_rn=ps]/getdoc.xp?AN=710978812 Jeff Epler places an 'xreadlines' patch on Sourceforge: xreadlines, inspired by xrange, permits a simple 'for' loop to iterate over the contents of a file "lazily", without reading the entire file at once. http://deja.com/=dnc/getdoc.xp?AN=706611199 Amy Katherine announces the Ninth International Python Conference. http://deja.com/=dnc/getdoc.xp?AN=707166306 Per Kraulis announces crng 1.1: Random-number generator extension types (minor upgrade) http://deja.com/=dnc/getdoc.xp?AN=707664094 Dave Cole announces Sybase module 0.11 (Sam Rushing release) released http://deja.com/=dnc/getdoc.xp?AN=707968946 Bob Alexander starts an extensive thread on ideas for Python 2.1 [though it's too late for 2.1, maybe for 2.2? -- ed] http://deja.com/=dnc/getdoc.xp?AN=708072070 Final Call For Papers 2nd International Conference on eXtreme Programming and Flexible Processes in Software Engineering - XP2001. http://deja.com/=dnc/getdoc.xp?AN=708580378 Russell Turpin posts ideas about caching name lookups. http://deja.com/=dnc/getdoc.xp?AN=708902425 Pointers on sniffing HTTP traffic using proxies http://deja.com/=dnc/getdoc.xp?AN=710137006 Jerry Spicklemire responds to a question about Python vs. PHP by noting several packages that "will allow you to do "PHP/ASP-ish" things with Python". http://deja.com/=dnc/getdoc.xp?AN=709032569 and "echuck" provides a pointer to webware: another PHP-like package http://deja.com/=dnc/getdoc.xp?AN=709162756 Raymond Hettinger starts another enhancement discussions with a new year's wish-list for Python http://deja.com/=dnc/getdoc.xp?AN=709868180 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://deja.com/group/comp.lang.python.announce Andrew Kuchling writes marvelous summaries twice a month of the action on the python-dev mailing list, where the future of Python is truly determined http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From amk at mira.erols.com Sat Jan 27 13:17:46 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 27 Jan 2001 18:17:46 GMT Subject: Interested in a Crypto-SIG? References: <3A72C8A3.C4B4D69A@stroeder.com> Message-ID: On Sat, 27 Jan 2001 14:09:55 +0100, Michael Str?der wrote: >I would like to propose a Crypto-SIG. The goal is to define Pythonic >class APIs for various cryptographic and related standards to enable >developers to use a unified API for implementing crypto-enabled >applications in Python independent of the underlying implementations >(basically inspired by Sun's Java crypto-related APIs). Are you the same person who proposed this yesterday on the Meta-SIG? Anyway, I'll give you the same answer: a unified API would be an excellent idea, but a SIG seems unnecessary. There's already a python-crypto list at egroups which could be used to coordinate work on such a unified API (it's the second link for a Google search on "python crypto"), and the main issue is probably developer time. --amk From bernhard at abnoba.intevation.de Tue Jan 2 07:27:34 2001 From: bernhard at abnoba.intevation.de (Bernhard Reiter) Date: 2 Jan 2001 12:27:34 GMT Subject: fcgi.py References: <3a4a865c.1325844015@localhost> <3a4a90ab.1328483109@localhost> <92f20t$re4$4@newsserver.rrzn.uni-hannover.de> <3a4c1e99.60463812@newnews.prodigy.net> Message-ID: <92shfm$6c4$1@newsserver.rrzn.uni-hannover.de> In article <3a4c1e99.60463812 at newnews.prodigy.net>, victor at prodigy.net (Victor Muslin) writes: > Well, my most important need was not to have to open database > connections every time CGI executed. Well you can do this with mod_python, too of course. :) > Currently I don't need > multiple instances of the script running simultaneously. If and > when I do, I plan to add multithreading to my FastCGI library (I > actually believe it had already been done). Yes, there is a mutlithreading thing out there somewere. http://www.suxers.de/python/fcgi.htm But implementing this again, when you already have load balancing available with mod_fcgi in apache seems to be waste somehow. > I got it running so far with cgi-fcgi.exe bridge. Though it has to > fork/exec cgi-fcgi program every time, it is still an order of > magnitude faster than opening ODBC connection. To get it running > on NT, I modified (very slightly) Robin Dunn's fcgi.py and built > fcgi2.py on top of it that uses a socket instead of a named pipe. > You can get my modules at > http://pages.prodigy.net/victor/fcgi2_py. Please report any bugs > to me (and perhaps how to fix them since I am still rather new to > Python). Nice, thanks. I will not have time to test it in the next week, though. > I am yet to attempt to use mod_fcgi (I am new to Apache as well). > This is my next step once I figure out how to configure Apache on > WinNT for it (any help is appreciated :-). Once I get this working > I plan to try either mod_python or mod_snake (any help for > configuring Apache with those is appreciated as well :). It should be straigt forward and I have to admit that I never used mod_snake yet. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (www.fsfeurope.org) From donn at oz.net Thu Jan 4 00:57:40 2001 From: donn at oz.net (Donn Cave) Date: 4 Jan 2001 05:57:40 GMT Subject: Registering C methods when writing a C extension type? References: Message-ID: <9313ck$sv4$0@216.39.151.169> Quoth Tom Epperly : | I planning to write a C extension type (not module) to provide a Python | binding for an object or interface defined in an IDL (interface definition | language) for high performance scientific computing. In the example from | Mark Lutz's Programming Python (the only documentation I've found that | directly addresses writing extension types), it does something like the | following to make the object methods visible (in myobject.c): | | static struct PyMethodDef myobject_methods[] = { | {"method_one", (PyCFunction)method_one, 1}, | {"method_two", (PyCFunction)method_two, 1}, | {"method_three", (PyCFunction)method_three, 1}, | {NULL, NULL} | }; | | static PyObject * | myobject_getattr(myobject *self, char *name) { | /* other stuff deleted */ | return Py_FindMethod(object_methods, self, name); | } | | /* tp_getattr points to myobject_getattr */ | | I am wondering what the relative merits/penalties of doing something like | the following in the constructor for the hypothetical myobject instead of | the above. I would like feedback about issues of style (am I violating the | designers intent or using functions intended for internal use only), | forward/backward portability, and efficiency. | | static myobject * | new_myobject() | { | myobject *self; | const int len = sizeof(object_methods)/sizeof(PyMethodDef); | int i; | self = PyObject_NEW(myobject, &myobjecttype); | if (self == NULL) return NULL; | for(i = 0 ; i < len ; i++){ | PyObject *func = PyCFunction_New(object_methods + i, self); | if (func != NULL) { | PyObject_SetAttrString(self, object_methods[i].ml_name, func); | Py_DECREF(func); /* remove extra reference */ | } | } | return self; | } | | In this case, the getattr method does not call Py_FindMethod. I guess you must already know all the work you must do to implement it. I mean, if I have this right, myobjecttype must implement a meaningful setattr function, so you can indirectly call it via PyObject_SetAttrString(); plus, the complementary getattr, of course. I guess you must have some fairly compelling reason to want to do all that, instead of simply the normal lookup in the object_method table you already have anyway. So my reaction is, that implies to me that the implementation is pretty complex, and relative to that, questions like whether PyMethodDef's members are intentionally exposed to application programmers are no big worry. It obviously is not the way we normally do it, but you knew that. Its efficiency is going to depend, again, on the implementation - where you wrote "/* other stuff deleted */". Donn Cave, donn at oz.net From quinn at hork.ugcs.caltech.edu Wed Jan 31 21:33:25 2001 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 1 Feb 2001 02:33:25 GMT Subject: overloading == References: Message-ID: On Wed, 31 Jan 2001 16:30:06 -0800, Amritansh Raghav wrote: >can it be done? >i looked at the operator documentation under Python Runtime Services - but >didnt find anything to suggest it could be done. Yes, define __cmp__ or __rcmp__. See 3.3.1 in the language reference. From roy at panix.com Mon Jan 1 16:18:42 2001 From: roy at panix.com (Roy Smith) Date: Mon, 01 Jan 2001 16:18:42 -0500 Subject: Returning objects from C extension modules. Message-ID: I've played around a bit with building extension modules in C, and I think I've got the hang of the basic stuff. I (think) I understand how to use Py_BuildValue() to return simple values, and lists, tuples, or dictionaries of these. But, what I don't get is how to implement a class and return an object of that class. For example, let's say I've got a function in C which looks like this: typedef struct { int weapon_count; char name[MAX_NAME]; } record; record *get_record () { record *rec_ptr; rec_ptr = (record *) malloc (sizeof (record)); rec_ptr->weapon_count = 3; strcpy (rec_ptr->name, "spanish inquisition"); return rec_ptr; } and I want to turn it into a python module which returns an object of class sketch, as if I had done something like: class sketch: def __init__ (self) self.weapon_count = 3 self.name = "spanish inquisition" Do I need to have my extension module return a tuple of values, then build a thin wrapper in python which creates the class, instantiates an object of that class, and then copies the items of the tuple into the object? Or is there something more straight-forward? From aleaxit at yahoo.com Tue Jan 23 15:55:38 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 23 Jan 2001 21:55:38 +0100 Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> <94ipci$afo$1@animus.fel.iae.nl> <3A6CFD8E.BD473DFD@gte.net> <3A6D54CB.2261D535@gte.net> <94jo9u$h45$1@nnrp1.deja.com> <94jt7e01fil@news1.newsguy.com> Message-ID: <94kren0b1o@news2.newsguy.com> "Fredrik Lundh" wrote in message news:Zvjb6.8419$AH6.1356839 at newsc.telia.net... > Alex Martelli wrote: > > Given the comp.* context, and the noun-like usage, I suspect > > either [2] or more likely [4] are intended. > > might so be, but I still cannot make any sense of his > post. > > oh well /F Me neither. Maybe, even with the help from the dictionary definitions, it takes a native speaker to understand it?-) Alex From fabrice.n at home.com Sat Jan 27 12:43:15 2001 From: fabrice.n at home.com (shaka) Date: Sat, 27 Jan 2001 17:43:15 GMT Subject: does python have a GUI Message-ID: I am new at programming and I have started to learn python. I used to learn to program Java applet at school. Java used to have a bunch of Graphic User Interface(GUI). I was wondering if python had also a GUI, or how do I give a physical appearance to my program like a window that open and ask the user to enter something(not talking about the interactive mode). From joejava at dragonat.net Fri Jan 5 18:38:52 2001 From: joejava at dragonat.net (Joel Ricker) Date: Fri, 5 Jan 2001 18:38:52 -0500 Subject: Migrating to perl? References: , <3Fa56.4580$of7.216286@news1.atl> <933fa1$j2i$1@newshost.accu.uu.nl> Message-ID: Moshe Zadka wrote in message ... >On Fri, 5 Jan 2001, "Joel Ricker" wrote: >> Also if I >> understand your example, variables internal to the object are kept >> internal -- they can't be accessed without a proper method. With perl >> anything goes. > >Nope. In Python, anything goes, too. Most people assume that if they >write in the docs what methods are external, intellegient people will >use them. I kind of felt that way too but the book I was reading was taking an almost paranoid approach to OO (he admitted it as such) and so I was going with internal only variables. I'm too new to OO to be deviating from what I'm being taught without as the book said, "Thou shalt screwe things up". ;) Joel From frank_ihlenburg at yahoo.com Tue Jan 9 05:11:53 2001 From: frank_ihlenburg at yahoo.com (frank ihlenburg) Date: Tue, 9 Jan 2001 02:11:53 -0800 (PST) Subject: Fwd: numpy installation problem Message-ID: <20010109101153.8420.qmail@web4403.mail.yahoo.com> Note: forwarded message attached. ===== Frank Ihlenburg Lotsenring 12 23968 Wismar, Germany Tel: +49 (0)3841 636051 __________________________________________________ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/ -------------- next part -------------- An embedded message was scrubbed... From: frank ihlenburg Subject: numpy installation problem Date: Tue, 9 Jan 2001 01:40:06 -0800 (PST) Size: 2180 URL: From aleaxit at yahoo.com Thu Jan 4 09:15:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 15:15:22 +0100 Subject: list operation '+= ' or assignment problem References: Message-ID: <9320jh02tnu@news2.newsguy.com> "Fredrik Lundh" wrote in message news:xX_46.2919$AH6.516601 at newsc.telia.net... > Joe Smith wrote: > > I guess that list assignment is an assignment of the reference > > to the object and it does not copy the object. Where as a > > string object gets copied. > > Alex: No. > Erno: No. > Greg: Yes, in a way. > Steve: Yes. > Tim: No. > > time for a poll? ;-) I suggest we give 'is' and/or 'id()' a casting vote in the poll as to what is "copied" in a plain assignment...:-). Alex From shredwheat at mediaone.net Tue Jan 23 01:13:32 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Tue, 23 Jan 2001 06:13:32 GMT Subject: beep References: <11941-3A6D0F37-61@storefull-166.iap.bryant.webtv.net> Message-ID: > What do I write to just have my pc beep. I have windows 98. I tried > import winsound > winsound.beep(400,500) > But I get an error(exception) message. > I'm not sure what I"m doing (obviously), I just downloaded Python two > days ago and I'm just playing with it to see what I can do. Help! heh, i've found that >>> print '\a' does a pretty good job on windows and unix. although on windows this plays the system default beep wav, it does not send noise to the speaker/buzzer From f8dy at my-deja.com Tue Jan 30 13:45:04 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Tue, 30 Jan 2001 18:45:04 GMT Subject: How to extend sys.path on Win9x permanently? References: <3a75ef9c.11194652@news.muenster.de> <3A7671A2.30478E8C@engcorp.com> Message-ID: <95723d$h39$1@nnrp1.deja.com> In article <3A7671A2.30478E8C at engcorp.com>, Peter Hansen wrote: > Martin Bless wrote: > > > > Python20, Win98, PythonWin > > > > (1) I'd like Python.exe/DOS AND Python in PythonWin to start > > up with an extended sys.path, having my own lib added, as if a > > sys.path.append('c:\\mylib') had already been performed. > > How can I add the extra path permanently? > > Note certain, but it's likely that site.py is imported even under > PythonWin. If that's true, and it should be easy to test, just > create a file in your Python directory with an extension .PTH, > and place within it the name of the directory you want added > to sys.path. Just confirmed that this does work under PythonWin (at least ActiveState's port). Step-by-step instructions for Windows: - Find your base Python directory. The default is C:\Python20. - In this directory, create a new text file called something like "my.pth". Name doesn't matter, but the ".pth" extension does. - In this file, enter the full path of your scripts directory, e.g. c:\mylib. If you have more than one, list them each on their own line. Do *not* use double-backslashes ("c:\\mylib" is wrong); this is not a Python string, it's just a text file. (I made this mistake. ;-) - Quit and re-run PythonWin. "import sys; print '\n'.join(sys.path)" to make sure your directory is listed. -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From jurgen.defurne at philips.com Wed Jan 17 03:23:42 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Wed, 17 Jan 2001 09:23:42 +0100 Subject: Curses module for Python 2.0 for Windows NT Message-ID: <0056900015212200000002L002*@MHS> Dear all, I am busy automating tasks across some Windows NT workstations, where I control another program (Continuus/CM, if any one knows that). Unfortunately, that control is not that easy. Ihave built a GUI interface, but I am not really satisfied with it, so I want to simplify it somewhat so that it can run in a DOS box using curses. Is there a curses add-on available for the Win32 binaries ? It sure isn't part of the distribution I am using, which is still the BeOpen version of Python 2.0 Regards, Jurgen From andreas at andreas-jung.com Tue Jan 9 09:55:44 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Tue, 9 Jan 2001 15:55:44 +0100 Subject: post in CGI scripts In-Reply-To: <1A4E530F40B6D3119E880050041D6DE0BED033@wntceda3.ceda.polimi.it>; from Uberto.Barbini@ceda.polimi.it on Tue, Jan 09, 2001 at 03:38:06PM +0100 References: <1A4E530F40B6D3119E880050041D6DE0BED033@wntceda3.ceda.polimi.it> Message-ID: <20010109155544.A7148@yetix.sz-sb.de> On Tue, Jan 09, 2001 at 03:38:06PM +0100, Barbini Uberto wrote: > I've found some problems to use "post" method in my cgi script (in python). > > have to run both with "get" and "post" html form methods. > > Anyway my script (a converter from nntp to html) can get input values only > with "get" method and not with "post" method. > > I'm using Xitami under w2k. I configured it adding a filter which link *.py > to python.exe. > The POST or GET method should be invisible to the application when using the cgi module of Python. For further debugging you should take a look at the CGI environment (os.environ dictionary) for both methods. The arguments for GET method are passed in the QUERY_STRING variable and through stdin for the POST method. Maybe your web server is doing dothing stupid. Hope this helps, Andreas From mhc at Eng.Sun.COM Sat Jan 13 23:38:24 2001 From: mhc at Eng.Sun.COM (Mike Coffin) Date: 13 Jan 2001 20:38:24 -0800 Subject: Speed of Python vs. Perl References: <93oled$o48b3$1@fido.engr.sgi.com> Message-ID: <8p6zogubven.fsf@Eng.Sun.COM> pj at sgi.com (Paul Jackson) writes: > Tim wrote > |> Talk someone into writing a patch; I've got no bandwidth to spare. > > See another branch of this news thread for a patch (both 1.5.2 > and 2.0 variants). > > Me thinks this (getting startup time competitive with Perl) is > a hard problem, and that the two tweaks in my patch help, but > not greatly. > > The combination of the dynamic nature of Python, with having > much of its run time library support loaded from Python code, > not compiled in, would seem to force Python to do upwards of > 10 million instructions on startup. > > I don't see anyway around this. One way is to provide some sort of "dump" facility that allows the program to initialize, dump the state, and then make an executable from the dumped state. Emacs does (or at least, did) this to reduce startup time. -mike From moshez at zadka.site.co.il Mon Jan 8 20:52:53 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 9 Jan 2001 03:52:53 +0200 (IST) Subject: Web devel with python. Whats the best route? In-Reply-To: <93cqvi0191h@news1.newsguy.com> References: <93cqvi0191h@news1.newsguy.com>, Message-ID: <20010109015253.2CBFEA82D@darjeeling.zadka.site.co.il> On Mon, 8 Jan 2001 17:46:13 +0100, "Alex Martelli" wrote: > CGI. Really. Your admin system doesn't look like the kind of thing that > will be continuously getting multiple hits a second, making CGI overhead > a problem. If that is the case, CGI is easiest. *Do the simplest thing > that can possibly work*! CGI is not an answer. Perhaps you meant "CGI with lots of little print '' this and print '' that", which is as far from the simplest thing that could possible work as possible. Most Python web frameworks work just fine from CGI (PSP, WebWare, and even Quixote, I think). Those are answers, and very good ones. Perhaps even CGI+HTMLgen is an answer, though this might depend on personal taste. Of course, the simplest thing that can possible work interface-to-the-browser part is of course not even going with CGI, but with inheriting from BaseHTTPRequestHandler. Connecting that to something like PSP you get a cross-platform solution which is very easy. Connecting it to ZODB may be the final piece of the puzzle -- with ZODB and a dash of cookies, state management becomes so easy you'll wonder how you did without it. Of course, to be true to the Python tradition, take the PSPHTTPRequestHandler+ZODB and join the egroup mailing list for Python web frameworks developers. using-mod_perl+HTML::Mason-and-hating-it-myself-ly y'rs, Z. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From sholden at holdenweb.com Fri Jan 12 08:12:26 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 12 Jan 2001 08:12:26 -0500 Subject: boolean xor References: Message-ID: "Mikael Olofsson" wrote in message news:XFMail.010112083849.mikael at isy.liu.se... On 11-Jan-01 Steve Holden wrote: > But that's not something you wouldn't not > want to do on a regular basis, probably. VaguenessError: Too many negations. /Mikael Sorry if this puzzled some readers. I do not not not not not not not not not not agree with Mikael's assertion, which I did not not not not not not not not not not make in a feeble attempt to be humorous. Apparently this was not not not not not not not not not quite as funny as I thought. Usenet error: sense of humour failure. regards Steve From malik.thomas at lbbw.de Fri Jan 19 09:49:19 2001 From: malik.thomas at lbbw.de (Thomas Malik) Date: Fri, 19 Jan 2001 15:49:19 +0100 Subject: interesting bound-built-in-method technique References: <9476k6$d55$1@nnrp1.deja.com> Message-ID: <3A6853EF.E80D2E63@lbbw.de> Chris Ryland wrote: > > Reading the Quixote sources taught me an interesting little "hack" > using bound-built-in methods: > > >>> m = {'foo': 1, 'bar': 0}.has_key > >>> m('foo') > 1 > >>> m('bar') > 0 > > Is this a common idiom in Python? Very clever for turning a dictionary > lookup into a functional form. > > Are there other clever but generally obscure idia? (Idioms? ;-) How about 'wanna-be' class functions ? like static member functions in C++ (where you don't need a this/self object) ? class A: def __init__(self, name): self.name = name def __str__(self): return self.__class__.__name__ + ':' + self.name def makeA(name): # 'factory' method. Note: no self argument return A(name) class B(A): pass # call through method's im_func attribute a = A.makeA.im_func('a') # sometimes, it's useful to call a given class's method with some provided 'self' print B.__bases__[0].__str__.im_func(a) From reborn at neozone.net Tue Jan 30 20:26:31 2001 From: reborn at neozone.net (¾Æ¹«) Date: Wed, 31 Jan 2001 10:26:31 +0900 Subject: Q : About Jython & Applet (i'm begginer -_-) Message-ID: <957pjq$mg9$1@news1.kornet.net> hi.. I'm begginer for jython.. I make a simple applet with jython source is : import java class HelloApplet(java.applet.Applet): def paint(self,g): g.setColor(java.awt.Color.black) g.fill3DRect(5,5,590,100,0) g.setFont(java.awt.Font("Arial",0,80)) g.setColor(java.awt.Color.magenta) g.drawString("Hello World", 90, 80) as you know that it's just print "Hello World" but, I don't see that result though appletviewer or explorer I'm using jdk 1.3.0_01, jython 2.0.. I just installed and setted the pass. .java & .class are OK. What I have to do something for that? From mmiller3 at iupui.edu Fri Jan 5 18:00:06 2001 From: mmiller3 at iupui.edu (Michael A. Miller) Date: 05 Jan 2001 18:00:06 -0500 Subject: examples of PIL and pallets? Message-ID: <87k8898v0p.fsf@lumen.med.iupui.edu> Can anyone point me to an example of using pallets and image mode 'P' with PIL? Mike From vecernik at aon.at Thu Jan 25 06:51:43 2001 From: vecernik at aon.at (Oliver Vecernik) Date: Thu, 25 Jan 2001 12:51:43 +0100 Subject: Data output References: <3A6F05CD.D37C383B@aon.at> Message-ID: <3A70134F.50EA63F2@aon.at> I also tried to write to named pipes directly. It also worked fine: p = open(r'\\printserver\port') p.write('something') p.close My printer is connected to an external print server. But if connected to a local port on a Win XX machine I need a *raw* device driver for the printer. Does anybody know how this can be achieved? I'd like to use Windows built in spooling capabilities, even if the printer is connected to an external print server. Oliver Oliver Vecernik wrote: > > Hi all, > > I recently started using Python and I like it a lot. > I'd like to control label printers. I know how to control them, but I > don't know how to output data on Win XX or Linux machines to network > printers. > I don't want any windows driver to convert anything (like adding > formfeeds, newlines or whatever). > > Can anyone give my a clue or point me to some documentation? > > Thanks. > Oliver -- VECERNIK Datenerfassungssysteme AT-2560 Hernstein, Hofkogelgasse 17 Tel.: +43 2633 47530, Fax: DW 50 http://members.aon.at/vecernik From fredrik at effbot.org Thu Jan 18 16:47:54 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 18 Jan 2001 21:47:54 GMT Subject: os.popen and popen2 References: <9472c7$8u9$1@nnrp1.deja.com> Message-ID: C. Porter Bassett wrote: > In the documentation, it says that the windows version of os.popen was > unstable prior to python 2.0. Does anybody know if this applies equally > to the popen2 module? the popen2 module didn't work at all on Windows before 1.6/2.0. Cheers /F From erno-news at erno.iki.fi Sun Jan 14 07:05:40 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 14 Jan 2001 14:05:40 +0200 Subject: libpython2.0 as a Linux shared library References: <3A618354.577B192A@mega-nerd.com> Message-ID: In article <3A618354.577B192A at mega-nerd.com>, Erik de Castro Lopo writes: | Does anybody know how to configure and compile Python so that | libpython2.0 is a shared library? you could look at the debian packages, i think they do that. it seems python2 is currently in the limbo between incoming.debian.org and ftp.debian.org, but it should show up at ftp.debian.org in the vicinity of /debian/dists/woody/main/source/interpreters/python2-* soon. or you could look at the debian python 1.5.2 packages. -- erno From sholden at holdenweb.com Sat Jan 6 14:48:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 6 Jan 2001 14:48:05 -0500 Subject: Whose functions are realer (was: Migrating to perl?) References: <3Fa56.4580$of7.216286@news1.atl> <356AB932B7198FB4.3EC0B75D519810CE.57FCF0BC6A8679C4@lp.airnews.net> Message-ID: D-Man wrote in message news:mailman.978731526.10714.python-list at python.org... > On Fri, Jan 05, 2001 at 11:30:28AM -0600, Cameron Laird wrote: > | Yes, I can imagine there are historical reasons Perlites backtick > | rather freely. > > I can't say for sure, but this feature probably came from bash. In > bash using a backtick means to execute the command and put its stdout > here. > > -D > This usage is much older than bash: it was a feature of the Unix 5th edition version of the Bourne shell, IIRC. But you are correct that Perl took the syntax from Unix shell usage: it's just that bash is a relative newcomer to the scene :-) regards Steve > > From psalvan at my-deja.com Wed Jan 31 09:39:15 2001 From: psalvan at my-deja.com (psalvan at my-deja.com) Date: Wed, 31 Jan 2001 14:39:15 GMT Subject: Date-time class Message-ID: <95982i$bta$1@nnrp1.deja.com> I need a simple and practical DateTime class.... The standard python library seems to lack such class: a class with methods getYear,m getMonth, ... getSecond, that let me make make time arithmetic (ie: how many month beetween 12/4/1998 and 3/1/2001? How many day? How many seconds? How can I get 7/12/1978 + 1 month?), etc.... some help???? It seems to me standard library lacks simple and practical date/time support...I'm right? Paolo Sent via Deja.com http://www.deja.com/ From michael at stroeder.com Sat Jan 13 13:08:52 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sat, 13 Jan 2001 19:08:52 +0100 Subject: python-ldap binary for Python 2.0 under Win32 Message-ID: <3A6099B4.A55C9258@stroeder.com> HI! (Aargh! Wrong URL in my previous message!) A quick note that there is a Win32 build of the python-ldap module available for download now which is e.g. needed for running web2ldap on Win32 platform: http://www.web2ldap.de/install.html#packages_win32 Thanks to the contributor! Any feedback is appreciated. Ciao, Michael. From pbjorn at uswest.net Thu Jan 4 12:45:33 2001 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Thu, 04 Jan 2001 10:45:33 -0700 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> <3A52AD6A.62D043A2@engcorp.com> <3A534367.36B1FD18@uswest.net> <3A53F4B1.6227D241@uswest.net> <931gf302dsi@news2.newsguy.com> Message-ID: <3A54B6BA.F4550C96@uswest.net> Hi Alex, Sometimes I think you can type faster than I can read, so you'll have to excuse the excessive snippage :-) Alex Martelli wrote: > "Bjorn Pettersen" wrote in message > news:3A53F4B1.6227D241 at uswest.net... > [snip] > > If what you want to do can't be expressed directly in the language, and > > the only reason people don't want to change it is because they're used to > > the status quo, I feel justified in calling it a holy cow ;-) > > [snip] > I *WOULD* mind, *A LOT*, if, rather than regularizing syntax for the > general form of loop, Python were to add other special-cases with > their own syntax variations. *SIMPLICITY*! *ONE* general loop form I guess this is where our opinions differ. I'm of the school of "make the general case easy, but make the common case trivial". This means I'm strongly in favor of adding special cases for often used looping constructs. I'm _not_ in favor of adding special cases for every conceivable looping construct however. E.g. I'm not in favor of adding a do/while loop. In the project I'm currently working on (C++, ~33 Kloc) there are 346 while loops, and only 24 do/while loops. Of the while loops, 12 are "while(1)" (there are also three for(;;)), 95 contain an assignment ("while (line = fp.readline())"), and the rest contain "regular" tests. I'm therefore likely to argue against adding do/while, and special syntax for "while 1" (i.e. loop: or while:), but for adding special syntax for assignments in the test part of a while loop (on the principle that if they're used that frequently in a language that has them, they must be somewhat useful). The project also contains 884 for loops, and though I didn't check, I would assume most of them are of the form "for (i=0;i) At least we both agree that the print>> syntax is a wart, and perhaps also that the special casing of print>>None is counterintuitive ;-) but-it-was-Guido's-baby-as-is-Python'ly y'rs -- bjorn From cobrien at Radix.Net Thu Jan 25 09:36:09 2001 From: cobrien at Radix.Net (Cary O'Brien) Date: 25 Jan 2001 09:36:09 -0500 Subject: Python and postgreSQL ?? References: Message-ID: <94pdkp$b9n$1@saltmine.radix.net> In article , Carles =?iso-8859-1?Q?Sadurn=ED?= Anguita wrote: >I've search unsuccessfully a tutorial about "attack" postgreSQL with Python. >Can anybody help me? > >I would like to write a little program (python/tkinter) for a friend of mine >who wants to mantain data about his costumers and who has no time to learn >too much about computers. > You may want to check out Zope (http://www.zope.org). Zope is a web application framework that has pretty good support for PostgreSQL (you have to add an extra module (well, package) that you can get from the web site.). The Tutorial that comes with Zope shows how to create a database-backed application. This would give you a web-based application, rather than an X application, which may or may not be ok. NB: The tutorial that comes with pygresql is mostly a transliteration of the PostgreSQL tutorial, rather than an example of how to use pygresql in an application. NB2: There are at least two Python<->PostgreSQL interfaces. The one that comes with Postgresql and one called (Get this!) PoPy. http://freshmeat.net/search/?q=popy Should do the trick. NB3: There is now a postgresql book! Check amazon.com for details -- cary > >Thanks in advance > >-- >------------------------------------------------------------------------ >Carles Sadurn? Anguita | no hab?a que cumplir promesas, > | el cansancio era de placer, >Quita _mira_la_firma para | las l?grimas eran de risas... >responder. | y parece que a?n fue ayer. > | Los Suaves >------------------------------------------------------------------------ From rcalco at cortechs.com Mon Jan 1 15:54:13 2001 From: rcalco at cortechs.com (Bob Calco) Date: Mon, 1 Jan 2001 15:54:13 -0500 Subject: Recursion Message-ID: Anyone: I noticed the following while dabbling in Perl, Ruby and Python recently. Take your standard factorial implementation, a la: PYTHON ====== import sys def factor(n): if n == 1: return 1 else: return n*factor(n-1) print factor(int(sys.argv[1])) fact.pl ======= sub fact { my($n) = shift; if ($n eq 1) { return 1; } else { return ($n * fact($n-1)); } } print fact($ARGV[0]), "\n"; fact.rb ======= def fact(n) if n == 1 1 else n*fact(n-1) end end print fact(ARGV[0].to_i), "\n" The highest value for n you can run in Python is 12; after that you get overflow error messages. In Perl, the largest value is 170 (after which you get 1.#INF for an answer). In Ruby, you can input a value as high as 763 before you get a SystemStackError (stack level too deep) error. Couple questions: 1. Why the vast difference between the languages? Is this apparent limitation in Python deliberate, or the consequence of some other design decision? 2. In the real world, does this really matter? Does Ruby have any meaningful advantage over Python in this regard? (I understand I might get different replies if I asked this question on the Ruby email list. I have different questions for Ruby fans!) I'm trying to decide which of these languages to embed in my application or at the very least require in the user environment. I like all of them, and I lean toward Python because it's much cleaner than Perl and more mature than Ruby and Mark Hammond's Win32 extenstion fully supports COM on Win32, which would make it a very useful framework for prototyping our COM objects and developing our own test suites to exercise them when they are implemented in C++. But I was surprised to find such a difference when testing each language's support for recursion. Any thoughts welcome. Sincerely, Bob Calco CorTechs, Inc. rcalco at cortechs.com From peter at engcorp.com Sat Jan 27 11:12:49 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 27 Jan 2001 11:12:49 -0500 Subject: Python exporting References: Message-ID: <3A72F381.BEDBA99D@engcorp.com> bowman wrote: > > ACCRA (Reuters) - Ghana's earnings from exporting pythons slid more than 40 > percent in 2000 as rising exports from neighbouring states flooded the > world market, forestry officials said on Wednesday. [snip] > "They are mostly used as pets and in some instances for scientific > purposes. However, the larger ones are sometimes used as delicacies in > restaurants," Basuglo said. I prefer the smaller ones: the juices are concentrated, so they tend to be sweeter. From samschul at pacbell.net Mon Jan 22 15:46:12 2001 From: samschul at pacbell.net (Sam Schulenburg) Date: Mon, 22 Jan 2001 20:46:12 GMT Subject: What does Python do References: <94gmeu$4fc$1@sooner.brightok.net> Message-ID: <94i66h$7fs$1@nnrp1.deja.com> In article <94gmeu$4fc$1 at sooner.brightok.net>, "Dead Dan" wrote: > What kinds of programs can you make with Python. Does anyone have some > examples. > > Dan > > I use Python to develop manufacturing test process. One example is a Tkinter based GUI that displays up to 21 network attached storage devices. The user is then allowed to start and stop tests to these devices. the main features of this program are: 1) Each test is a sepreate thread 2) All test results are logged to seperate log files 3) Status is provided to the user for each test 4) Network IP address are scanned for active devices The python code takes up twelve pages of well commented source code. The same process written in 'C' would take up from three to five times the space. Sam Schulenburg Sent via Deja.com http://www.deja.com/ From db3l at fitlinxx.com Fri Jan 19 19:28:59 2001 From: db3l at fitlinxx.com (David Bolen) Date: 19 Jan 2001 19:28:59 -0500 Subject: Deployment woes (was: I will kill my Python) References: <947r18$rdt$1@news.online.de> <4DE7F9DB9399A3C1.D96FC6EFB3F2391E.88AD1775E4555FCA@lp.airnews.net> Message-ID: claird at starbase.neosoft.com (Cameron Laird) writes: > I defer to those with more certain knowledge. I find > Win* habits too esoteric for my comprehension; that's > as definite as I can be. There's a technical term for this process under Windows - "DLL hell" :-) -- -- 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 syver at NOSPAMcyberwatcher.com Sun Jan 7 19:13:49 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Mon, 8 Jan 2001 01:13:49 +0100 Subject: How to run more than one instance of the Python interpreter in one process? References: Message-ID: <93b0sk$u1l$1@troll.powertech.no> "Tim Peters" wrote in message news:mailman.978862627.7187.python-list at python.org... > [Syver Enstad] > > I am fiddling around with embedding Python in C/C++ and am trying > > to run one interpreter per thread. I've tried using the > > Py_NewInterpreter and Py_EndInterpreter for each thread but it > > doesn't seem to be enough because I trigger access violations in > > the interpreter so I am obviously missing a couple of things. Are > > there any examples on how to do these kinds of things other than > > the very sparse code in the demo folder of the source distribution. > > None that I've ever seen, or heard of. Py_{New,End}Interpreter appeared to > have been added during a brief bout of Tcl Envy, and neglected thereafter. > The natural place to talk about this is the Python Thread-SIG: Thanks for answering Tim, but I don't really know if I need to use these functions, what I need is how to run different python "applications" from the same process. When I say applications I mean like for instance PyRun_SimpleFile. These applications must not share things like sys.stdout for instance because I am going to assign it to different objects for each thread. Does these requirements mandate using something like Py_NewInterpreter or can it be achieved in other ways. NB. This is my first shot at using the Python C interface so there are probably obvious things I haven't grok'ed yet, but I know C++ well. From tim.one at home.com Tue Jan 16 19:37:00 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 16 Jan 2001 19:37:00 -0500 Subject: [ANNOUNCE] FreeImage 2.0.0 out! In-Reply-To: <3A64BC61.E7570F28@alcyone.com> Message-ID: [Oleg Broytmann] > Linux certainly has [MSVC 6]! Thank you for explanation :))) [Erik Max Francis] > What are you talking about? That's what happens when community norms are ignored. Let me translate: Linux certainly has . Thank you for explanation . The last could be abbreviated to <4.0 wink> for efficiency, although winkery values larger than 1.0 should really be reserved for situations that require such extreme dramatic impact. simple-tools-for-simple-times-ly y'rs - tim From hamish_lawson at yahoo.co.uk Fri Jan 26 04:10:29 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Fri, 26 Jan 2001 09:10:29 GMT Subject: .cgi or .cgp or .py or ? References: Message-ID: <94reu2$8uh$1@nnrp1.deja.com> Tim Hammerquist wrote: > You can at least take comfort in the fact that the > mass majority of P*** CGI scripts have either no extension or .cgi and > therefore do not "promote" their mother-language in the way you > described. However, if you have scripts in various languages at your site, using the extension of .py may make it easier at some future date to migrate your Python scripts to being handled by something other than the universal CGI handler - for example, the Apache mod_python handler. Hamish Lawson Sent via Deja.com http://www.deja.com/ From timr at probo.com Fri Jan 26 01:53:01 2001 From: timr at probo.com (Tim Roberts) Date: Thu, 25 Jan 2001 22:53:01 -0800 Subject: smtplib --> receiving emails two times References: <94paet$9o3$1@news.netcologne.de> Message-ID: Toralf Wittner wrote: >Hi Python coders, > >I try to collect data from a HTML formular via cgi and email the stuff to a >certain address. The script is as follows: >... >This works basically, however all emails are received two times wich is >annoying at least . I can't see why this happens Me, either offhand. Is it possible your script is getting executed twice for some readon? You didn't give us the HTML from the calling page. You might try creating a log file. I find that to be a good way to debug my CGI scripts: def Log(msg): f = open('/tmp/log','a') # Might want to prepend date/time. f.write(msg) f.close() Log( "I got here" ) ... Log( "Recipient is %s" % to_address ) -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From andreas at andreas-jung.com Mon Jan 15 07:30:39 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Mon, 15 Jan 2001 13:30:39 +0100 Subject: checking free disk space In-Reply-To: ; from LangaK@discoveryhealth.co.za on Mon, Jan 15, 2001 at 02:23:59PM +0200 References: Message-ID: <20010115133039.A3619@yetix.sz-sb.de> On Mon, Jan 15, 2001 at 02:23:59PM +0200, Langa Kentane wrote: > Please can you point me in the right direction. I posted something before > on this list but I realised that will not work in a wind0ze environment. I would use os.statvfs() however this seems to be available only under Unix. Andreas From dsh8290 at rit.edu Mon Jan 8 14:29:57 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 8 Jan 2001 14:29:57 -0500 Subject: Thank you (was Re: Should I learn Python or Java?) In-Reply-To: <93dg5b080h@news1.newsguy.com>; from aleaxit@yahoo.com on Mon, Jan 08, 2001 at 11:43:11PM +0100 References: <3A593236.6331BE0C@engcorp.com> <93dg5b080h@news1.newsguy.com> Message-ID: <20010108142957.F4159@rit.edu> On Mon, Jan 08, 2001 at 11:43:11PM +0100, Alex Martelli wrote: | "D-Man" wrote in message | news:mailman.978966549.13022.python-list at python.org... | [snip] | > The company I am working for now uses Java for the SDK and runtime | > library. Part of the purpose of the product is to generate a Java | > class that our customers can use to do screen scraping from Java | > apps/applets. Due to the nature of this product and its target | > audience it is rather tied to Java. | | So, can Jython help you? Not a rhetorical question, I'd really like to | know -- I don't have a good grasp of exactly how far you can go | using Jython vs Java, or what the performance ratios are... | Hmm, Jython compiles my friendly Python code to Java bytecode right? It's possible. I should talk to my boss about a way to try it out. Probably off the clock though. (It's a nice small company, only 9 developers, 3 of which are co-ops :-)) | | Alex | -D From sill at localhost.kitenet.net Tue Jan 16 21:35:07 2001 From: sill at localhost.kitenet.net (Oldayz) Date: Wed, 17 Jan 2001 02:35:07 GMT Subject: My first script (so go easy on me!) References: Message-ID: On Tue, 16 Jan 2001 15:50:17 GMT, Robert L Hicks wrote: >#!/usr/bin/python > >## ># This is a small script to cause the inetd daemon to re-read itself >## > >r = "kill -HUP `ps cax|grep inetd|awk '{print $1}'`" # restarts the daemon >n = "Inetd not restarted" >w = "Answer needs to be 'yes' or 'no'. Try again!" > >answer = " " > >query = raw_input("Do you want to restart the INETD daemon? (yes/no): ") #I'd do it like this: answer = raw_input("Do you want to restart the INETD daemon? [Y/n]: ") # Y is default, i.e. hitting enter is interpreted as yes # typing yes or no is really too much typing in this case > >if len(answer) > 2: > print r >elif len(answer) < 2: > print w >else: > print n if len(answer) == 0: os.system(r) # os.system runs the string.. elif answer[0] == 'y' or answer[0] == 'Y': os.system(r) elif answer[0] == 'n' or answer[0] == 'N': print n else: print w # I'm assuming r does what it's supposed to, I didn't test it.. nor the # code above Hope this helps. > > >Is this ok? My question is when the print statement is run do I need to do a >linefeed so the terminal accepts what was printed? Or does the fact that >python send the print to the terminal cause the terminal to execute it? > >How would you clean this up? > >Bob > -- Andrei From fgleeson at my-deja.com Tue Jan 2 10:26:07 2001 From: fgleeson at my-deja.com (fgleeson at my-deja.com) Date: Tue, 02 Jan 2001 15:26:07 GMT Subject: Komodo References: Message-ID: <92sru7$6b$1@nnrp1.deja.com> In article , Robert L Hicks wrote: > Has anyone tried Komodo from ActiveState yet? What are you thoughts on it? I > see that a Linux beta is out now as well. The windows beta is available, the linux version is still at tech preview 3. The beta release is promising and has enough features to be useful for debugging perl scripts. You will need Windows Scripting Host if you do not already have it (wscript.exe). The MSI install will bomb out on you without expanation with a runtime error. WSH is available as a free download from MS. For whatever reason debugging is painfully slow, my computer may be a bit underpowered for the task 300 Mhz pentium. It is hard to understand where the bottleneck is. Perl.exe is very fast. I do not know if Active State is communicating with perl.exe's built in debugger or duplicating that functionality in a windows program. But I have a faster computer on order. You can take some of the pain out of debugging by using breakpoints instead of single stepping. Overall it is a promising product, that fills an important niche. The beta is definitely worth experimenting with. Sent via Deja.com http://www.deja.com/ From rindolf2 at yahoo.comNOSPAM Tue Jan 2 21:37:28 2001 From: rindolf2 at yahoo.comNOSPAM (Rindolf) Date: Wed, 03 Jan 2001 02:37:28 GMT Subject: GIF Image Size References: <92tbig$ede$1@nnrp1.deja.com> Message-ID: "Greg Landrum" wrote in message news:92tbig$ede$1 at nnrp1.deja.com... > In article , > "Rindolf" wrote: > > Is there any way to find out the dimensions of a GIF image using > python? I > > looked in the language reference and it didn't look like there was. > > > > If you are going to be working with GIFs (or any image format for that > matter), you probably want to install PIL: > http://www.pythonware.com/products/pil/index.htm > Once you have that installed, you can easily determine the size of a GIF > as follows: > from Pil import Image > img = Image.open('foo.gif') > print img.size > > I hope this helps, Thank you! Btw, what type of object is img.size, and what is the class of object returned by Image.open()? Rindolf From moshez at zadka.site.co.il Mon Jan 1 21:31:56 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 2 Jan 2001 04:31:56 +0200 (IST) Subject: A single, general looping construct? (was: why no "do : until"?) In-Reply-To: <92qc21$538$1@nnrp1.deja.com> References: <92qc21$538$1@nnrp1.deja.com>, <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> Message-ID: <20010102023156.C5B45A84F@darjeeling.zadka.site.co.il> On Mon, 01 Jan 2001 16:42:42 GMT, rturpin at my-deja.com wrote: > But the core idea, in Pythonic syntax, > would look like this: > > do: while : Actually, I think that's very close to the Forth syntax of that loop-and-a-half. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From jdries at mail.com Mon Jan 1 21:31:58 2001 From: jdries at mail.com (Jan Dries) Date: Tue, 02 Jan 2001 03:31:58 +0100 Subject: Simulating WWW button press References: Message-ID: <3A513D9E.B585A665@mail.com> Lutz Schroeer wrote: > > Jan Dries wrote in > : > > Well, maybe this snippet of the (very unreadable) source is large enough. > >

METHOD=POST> Oops, a zip-file. That's not making things easier. Transporting it to your machine will not be so difficult, but construction the actual zip-file from the respons might present you a few surprises. I've never worked with programmed http requests that returned anything other than plain text of html though, so I'm afraid I can't help you if you run in trouble here. > > > > > I tried and read some more stuff and ended at the example 11.3.2 in the > Library reference (1.5.2). Unfortunately my own > version of this code doesn't work (it stucks after the getfile() ). I assume you mean 11.4.2 (there's no getfile() in 11.3.2). Anyway, the sample code in 11.4.2 is a good starting point, although reading the code I think the line h.send(paramstring) should be replaced by h.send(params) But you also do need to look for all the elements in the form you mentioned above, because the value of all these elements must be supplied as parameters to the POST action. > > Is my suggestion right that the base address for the submission is the > same as the page's base address if the code defines nothing different? If the URL in action starts with a /, the URL is relative to the server. If it starts with http://, it's absolute, and if doesn't start with either, it's relative to the page containing the form. In your case, it's relative to the server, so you should change sample 11.4.2 to: >>> h = httplib.HTTP("...") # (the server the page containging the form is on) >>> h.putrequest("POST", "/dyx-pv/onepagebatch/lV21.zip") > > Additionally I came to the conclusion that I seem to have to send a > Content-Length header entry (the server replied me an error 411) but have > no idea about the value. You must provide a value for "Content-length" equal to the amount of bytes sent in the post request, i.e. the size of the string you supply to the send() method of your HTTP-object (as it is done in example 11.4.2). > > To make it totally complicated the form is on a password protected page. > So how do I send my username and passwd to the server? I can't help you here either. I know some forms of authentication use the "Authentication" header field in the http-request, but I have no idea how to use it. > > Maybe this informtion > > (it's hard to express a quite complex problem in English which is not my > native language) I do speak German, presumably well enough to understand you, as long as I can answer in English (or Dutch) (it's a bit hard for me to express complex things in German :-)). Jan From grey at despair.rpglink.com Mon Jan 29 21:28:55 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Tue, 30 Jan 2001 02:28:55 -0000 Subject: No Python content... References: Message-ID: On Mon, 29 Jan 2001 20:11:24 -0500 (EST), Steven D. Majewski wrote: >10 GIGABYTE STORAGE CAPACITY ON A ROLL OF COMMERCIAL ADHESIVE TAPE >without even unwinding it from the roll! No thanks. It would be just my luck that come christmas someone would use my por, er, PYTHON archives to wrap presents. :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From jdries at mail.com Sat Jan 27 07:50:54 2001 From: jdries at mail.com (Jan Dries) Date: Sat, 27 Jan 2001 13:50:54 +0100 Subject: crypt and decrypt References: <005e01c0883d$2e354700$85a1d4d2@SharmadNaik> Message-ID: <3A72C42E.E65AD9E0@mail.com> > Sharmad Naik wrote: > > Can anyone tell me whether there is a crypting (security) function > in python 1.52 . If you just want to encrypt, go for the md5 module. It can provide a very safe form of authentication. If you want to be able to decrypt what you encrypt, you may consider the rotor module. But do realise it's encryption can be (easily) broken, so don't use it to protect your customer's credit card numbers. Regards, Jan From p at mjs400.co.uk Fri Jan 19 00:05:36 2001 From: p at mjs400.co.uk (Pete) Date: Fri, 19 Jan 2001 06:05:36 +0100 Subject: Jython-2.0 released References: Message-ID: <3A67CB20.42A0EEDC@mjs400.co.uk> http://www.jython.org/docs/whatis.html Tom wrote: > > I thought that what existed before was a python enterpreter written in Java. > But this sounds like a Python compiler. Is this something new? > > Tom. > > "Finn Bock" wrote in message > news:mailman.979852051.13723.python-list at python.org... > > > > I am happy to announce the release of Jython 2.0. > > > > Jython is a Java implementation of the Python programming > > language. It allows users to compile Python source code to > > Java byte codes, and run the resulting bytecodes on any Java > > Virtual Machine. It is a very seamless and smooth > > integration with Java: from Python you have complete access > > to all Java libraries, can build applets, can integrate with > > Java beans, and can subclass Java classes in Python and vice > > versa. Like Python, and unlike Java, Jython can also be > > used interactively: just type some Jython code at the > > prompt and see the results immediately. > > > > A java installer is available for download at the Jython website: > > > > http://www.jython.org/ > > > > Installation is started by running the installer class. Further > > information and tips on installation is available at: > > > > http://www.jython.org/install.html > > > > Jython 2.0 is feature compatible with Python 2.0 and among the > > new feature are: > > > > - Augmented assignment, e.g. x += 1 > > - List comprehensions, e.g. [x**2 for x in range(10)] > > - Extended import statement, e.g. import Module as Name > > - Extended print statement, e.g. print >> file, "Hello" > > > > > > A complete list of changes and differences are available here: > > > > http://www.jython.org/NEWS.html > > > > Bugs can be reported to the bug manager on SourceForge: > > > > http://sourceforge.net/bugs/?group_id=12867 > > > > Cheers, > > the jython-developers > > From dsh8290 at rit.edu Tue Jan 30 18:15:14 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 30 Jan 2001 18:15:14 -0500 Subject: curly-brace-aphobic? In-Reply-To: <95718r018s8@drn.newsguy.com>; from not.this@seebelow.org on Tue, Jan 30, 2001 at 10:30:51AM -0800 References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> <95718r018s8@drn.newsguy.com> Message-ID: <20010130181514.A23642@harmony.cs.rit.edu> On Tue, Jan 30, 2001 at 10:30:51AM -0800, Grant Griffin wrote: | In article , D-Man says... | > | ... | >I still maintain my postiion that a list is really a special case of a | >dictionary, on a theoretical level. | You snipped my next conclusion here. [snip] | This last one is how I tend to think of it. I _think of_ tuples as a special | case of lists: "tuples are read-only lists". Likewise, one can _think of_ | strings as special cases of lists: "strings are imutable lists that can | contain only characters". Like I said (and was snipped), at a practical level, I don't think of lists as a special case dictionary. I also dislike the "strings are immutable" feature, but I understand that it can help optimization and mutable strings are much less fun in C than other languages. (I can see why Guido et al wouldn't want to deal with mutable strings in the interpreter, though Finn would have much less trouble with it in Jython) (no need to start a discussion here, I can deal with it :-)) If you wanted to implement a list as a dict, you could remove an item from the middle and adjusting the indexes by having the remove() function take all the higher indexes and switch the values, then deleting the highest index from the list of keys. Of course, using a series of linked nodes is much easier and faster. Nothing that really bothers people developing applications, just those who want to think of various ways to achieve the same result and then consider the tradeoffs. | | But if we try to generalize a relationship between dictionaries and lists, we | find that we can make neither a special case of the other--at least without | stretching it pretty far. | | Given the "indexers" hierarchy at top, the Python rule seems to be "All indexers | are indexed using square braces". Those who find Python's bracing "consistent" | evidently are evaluating "consistency" in terms of this rule. | | However, the rule that I seem to want to apply is "All indexers are indexed | using the style of brace used to bind them." (If a certain style of brace is | good enough to bind a variable, why isn't it good enough to _access_ a | variable?) That being said, it may not be possible (and it certainly isn't | desirable) to index strings and tuples using this rule. I think the purpose of the [] and the {} in list/dict construction is syntactic sugar for a factory function (or a class ctor). I can't think of any other reason for them (and for the difference). There could be a function make_dict() that takes a series of 2-tuples with the first element being the key and the second being the value, but I think the {} is simpler to type ;-). | | But I see no reason why curly braces could not be used for this purpose. | | explict-is-better-than-implicit-ly y'rs, | | =g2 | p.s. Just for the record, I'm not recommending any change to Python--because | the needs of backwards compatibility would undoubtedly lead to the dreaded "more | than one way to do it" . I was just asking a question. Thanks to all for | the many kind answers. | -D From gregj at pobox.com Tue Jan 2 04:58:29 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Tue, 02 Jan 2001 09:58:29 GMT Subject: Error using sys.stdin.read() References: <92rpf1$78r$1@nnrp1.deja.com> Message-ID: <9Dh46.219933$U46.6687840@news1.sttls1.wa.home.com> IDLE connects stdin to PyShell.PyShell, and PyShell doesn't implement the read() method. It does implement readline()... try it. Your script will work if you run it directly instead of inside IDLE. -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com wrote in message news:92rpf1$78r$1 at nnrp1.deja.com... > Any attempt to use the attribute "read" as in: > > import sys > while 1: > next = sys.stdin.read() # read a one-character string > if not next: # or an empty string at eof > break > #process "next" > > fails on the use of "sys.stdin.read()" with the message: > > "AttributeError: 'PyShell' instance has no attribute 'read' " > > I am using Python 2.0 on NT 4.5 on a PC. It's as if 'read' does not > exist. From root at rainerdeyke.com Sun Jan 7 22:41:46 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 08 Jan 2001 03:41:46 GMT Subject: simple symbolic math in Python References: Message-ID: <_Fa66.8576$ge4.4902248@news2.rdc2.tx.home.com> "Kragen Sitaker" wrote in message news:vE966.12210$K72.50241 at e420r-atl1.usenetserver.com... > I posted most of this to kragen-hacks > late last millennium. > > I'm running into a problem: I can overload unary minus, but I can't > overload e.g. math.sin and math.cos, because they're not methods. It > would be really nice to have a way to do that. I can create objects > that act just like dictionaries or files, including working with almost > all of the built-in functions, but it doesn't look like I can create > objects that look just like numbers. import math class MyNumber: ... old_sin = math.sin def my_sin(n): if isinstance(n, MyNumber): ... else: return old_sin(n) math.sin = my_sin -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From pearu at ioc.ee Fri Jan 26 06:11:45 2001 From: pearu at ioc.ee (Pearu Peterson) Date: Fri, 26 Jan 2001 13:11:45 +0200 Subject: Hack request: rational numbers In-Reply-To: References: Message-ID: On 25 Jan 2001, Michael Hudson wrote: > > is rather clumsy. Clearly, minimal representation of this rational number > > is > > > > 3/4 > > > > but in Python this expression has different meaning. > > Here's an idea: subclass code.InteractiveConsole. Use bytecodehacks > to find bytecodes like > > LOAD_CONST > LOAD_CONST > BINARY_DIVIDE > > to > > LOAD_GLOBAL "mpq" > LOAD_CONST > LOAD_CONST > CALL_FUNCTION 2 > > This isn't actually very difficult, but I'm not going to do it. And it will break other codes/modules where `3/4' is expected to return `0'. And it will work only for interactive session, right? So, I'll not going to do that either. > > 3) What are changes that these hooks will be accepted to Python core? > > Can't speak for the people whose opinions really count, but my guess: none. It is rather disappointing estimation:( And it makes me think that (some? most?) people want to keep Python usage only in web/gui based applications rather than extending its usage to scientific computing (both *numerical* and *symbolical*). Sorry to bother you. > > 4) Is anybody else working with builtin rational number support for > > Python? > > Maybe. I suspect not enough to make a difference. It's mooted that > > 1/2 > > will produce something other than "0" in Py3K, but I can't remember > whether a rational or a floating point result seemed most likely last > time this went around. Though, I'll wait (hope) for Alex's PEP about this and I'll probably try to implement `3r' hooks to Python myself (it's just too appeling to me;). Regards, Pearu From lisowski.tomasz at sssa.NOSPAM.com.pl Wed Jan 31 01:42:42 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Wed, 31 Jan 2001 07:42:42 +0100 Subject: . Python 2.1 function attributes References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> Message-ID: <958c0n$gio$1@news.tpi.pl> Uzytkownik "Thomas Wouters" napisal w wiadomosci news:mailman.980611052.20199.python-list at python.org... > On Sat, Jan 27, 2001 at 09:42:17AM -0500, Roy Katz wrote: > > > Didn't you feel it already? > > The language was going to hell even before print>> was added. > > Change always ruins everything. Keyword arguments ?!? Who needs those. Lets > go back to Python 1.3. Then try to imagine Tkinter app without keyword arguments :-) Tomasz From J.Jonkers at acriter.com Wed Jan 24 05:26:30 2001 From: J.Jonkers at acriter.com (Johan Jonkers) Date: Wed, 24 Jan 2001 11:26:30 +0100 Subject: thread Message-ID: <3A6EADD6.11122913@acriter.com> Hi! At the company I work we use python 1.5.2 on Solaris. I made a python script on my home computer running linux (same python version btw), but when I tried it at work it couldn't find the thread module. I thought that the thread module was a standard module? Am I wrong in this? Johan From mikael at isy.liu.se Fri Jan 19 06:52:16 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 19 Jan 2001 12:52:16 +0100 (MET) Subject: How to run script from interpreter? In-Reply-To: <00ef01c081fd$375c2ab0$11260340@yin> Message-ID: On 19-Jan-01 Dan Rolander wrote: > This doesn't work for me. I know how to import and how to use the if > __name__ trick, but how can I execute a script from the interactive Python > interpreter? That is, can I load a script and have it run from inside the > interpreter? (I'm sure this is easy I'm just not seeing it.) Let's see... I think it was here somewhere... Ah, yes: In Python Library Reference, 2.3 Built-in Functions, at http://www.python.org/doc/current/lib/built-in-funcs.html execfile (file[, globals[, locals]]) This function is similar to the exec statement, but parses a file instead of a string. It is different from the import statement in that it does not use the module administration -- it reads the file unconditionally and does not create a new module.2.8 The arguments are a file name and two optional dictionaries. The file is parsed and evaluated as a sequence of Python statements (similarly to a module) using the globals and locals dictionaries as global and local namespace. If the locals dictionary is omitted it defaults to the globals dictionary. If both dictionaries are omitted, the expression is executed in the environment where execfile() is called. The return value is None. HTH /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 19-Jan-01 Time: 12:35:02 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From i at on.ru Sun Jan 14 11:41:53 2001 From: i at on.ru (i at on.ru) Date: 14 Jan 2001 18:41:53 +0200 Subject: FREE http://4sansai.cjb.net 5518 Message-ID: <3a61d6d1@news.takas.lt> http://4sansai.cjb.net xwkggzdgixvrftfnplblmwnvfhuoksogoxkslkpsitctrhxnzsndflqxntiksjdmm From erno-news at erno.iki.fi Sun Jan 28 12:52:56 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 28 Jan 2001 19:52:56 +0200 Subject: marshal doesn't work with "file-like" objects References: <5.0.2.1.0.20010126135016.029c4d90@mail.mindspring.com> <94t1bi$m73$1@nnrp1.deja.com> <950ab5$2h2$1@nnrp1.deja.com> Message-ID: In article <950ab5$2h2$1 at nnrp1.deja.com>, echuck at mindspring.com writes: | In article , | Neil Schemenauer wrote: || Won't cPickle work? | Yes, but: | 1. My benchmarks (which I don't have anymore) showed marshal to be MUCH | faster than cPickle did you try cPickle's binary mode? it is many times faster than the default text mode at least on my machine. -- erno From sheila at spamcop.net Sat Jan 27 15:09:48 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 27 Jan 2001 20:09:48 GMT Subject: [Off topic] allowed to put Python material on the Web? References: <3a730931.31998180@news.skynet.be> <3a731f6a.97406397@news-server.austin.rr.com> Message-ID: On Sat, 27 Jan 2001 19:26:26 GMT, jgraves3 at austin.rr.com (jay graves) wrote in comp.lang.python in article <3a731f6a.97406397 at news-server.austin.rr.com>: :On Sat, 27 Jan 2001 17:51:57 GMT, Daniel.Kinnaer at Advalvas.be (Daniel) :wrote: : :>As a Python newbie, I've been collecting lots of questions and answers :>from this newsgroup. It contains stuff not readily found in the many :>good FAQ from the net. :>Before setting up a new site, I would like to ask if it is allowed to :>put my collection of questions and answers from this newsgroup (which :>helped me a lot) on my site,so everyone can enjoy/learn from it :>without going to the d?j? palace. : :Something similar already exists. :http://python.faqts.com Yes, and here's another one: http://www.lowerstandard.com/python/pythonsource.html This one has been announced on the Python Tutor mailing list. For myself, what I've started doing, is just collecting examples on my own website for my own use. The examples that are useful to me may not be useful to anyone else, and I don't try to make a site for anyone else. I just want something that is organized, and a record for me to use. For instance, I did something like this for some little Perl scripts I was playing around with: http://www.thinkspot.net/sheila/computers/perl.html I haven't got my Python scripts up to date, though. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From albert.brandl at lindeverlag.at Fri Jan 26 04:13:50 2001 From: albert.brandl at lindeverlag.at (Albert Brandl) Date: Fri, 26 Jan 2001 10:13:50 +0100 Subject: Simple HTML template modules? References: <3A711877.4C5B51AF@mail.com> Message-ID: <94rev7$ol4$1@readme.inode.at> Rayed Al-Rashed wrote: > I am trying to build CGI programs using Python, and I searched for > simple HTML templates modules but couldn't find any ... any ideas > where I can find such module. You should have a look at HTMLgen. This module provides a class called TemplateDocument which can be used like this: #! /usr/local/bin/python # somescript.cgi import HTMLgen doc = HTMLgen.TemplateDocument("template1.html") doc.substitutions = {"id": "55", "age": "17", "name": "Peter"} print "content-type: text/html" print print str(doc) #---------------------------------------- template1.html could e.g. be the following file:
ID {id}
User {name}
Age {age}
It might pay off to have a look at the other classes of HTMLgen. You will find an awsome, object-oriented interface to many html elements which can speed up the development enormously. The documentation for HTMLgen 2.1 can be found at http://starship.python.net/crew/friedrich/HTMLgen/html/document.html There exists a newer version, HTMLgen 2.2.2 - have a look at the vaults of parnassus at http://www.vex.net/parnassus/ Enjoy, Albert From slhath at home.com Wed Jan 24 17:04:22 2001 From: slhath at home.com (Scott Hathaway) Date: Wed, 24 Jan 2001 22:04:22 GMT Subject: beginner's python class in Dallas, TX Message-ID: My company is sponsoring a beginner's Python training class in Richardson, Tx on January 31st from 8:00 am to 4:00 pm. If you are interested in attending, the cost is $100 (a Python book will be included in this cost). Please email me at the address below if you are interested. If you would be interested in future classes, please also let me know about that possibility. Thank You, Scott Hathaway InfoTrain Solutions, Inc. hathaways at infotrain.com From mal at lemburg.com Thu Jan 11 06:41:38 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 11 Jan 2001 12:41:38 +0100 Subject: mxTools (was Re: why no "do : until"?) References: <31575A892FF6D1118F5800600846864D5B16CF@intrepid> Message-ID: <3A5D9BF2.7C204661@lemburg.com> Simon Brunning wrote: > > > From: Max M?ller Rasmussen [SMTP:maxm at normik.dk] > > From: Oleg Broytmann [mailto:phd at phd.pp.ru] > > > Anyone here has any doubts that at least mxDateTime simply MUST be in > > >the Python core? :) > > No that would be a great idea, but doesn't the license prevent that? > > As far as I can see, mxDateTime doesn't have restrictions in its license - > it's mxODBC which does. > > Is this right, Marc? Right. But please note that I wouldn't really want mxDateTime to go into the core: the reason is that the mx Extensions will soon be available as three packages under a new top-level package name "mx" -- I wouldn't want to rip mxDateTime out of that context. BTW, mxODBC v2.0 will then no longer be free for commercial use. I put a moderate license fee on it to at least produce some funding for mxODBC and the other mx Extensions -- the old mxODBC license just didn't work out, so I had to take this step. mxODBC will still remain free for non-commercial use, e.g. for personal and non-profit organizations, and as before you get full source code with it, so you still have all the advantages of being able to adapt the code to your needs. mxDateTime and most of the other tools will remain Open Source software as before. > *Both* of these are essential to me personally. I also use Marc's additional > built-ins, but they are really just a nice to have. (*Very* nice, but still > just nice.) > > So, if this were a democracy, which it isn't, I'd vote for mxDateTime to > definitely go in, for someone to think about the additional built-ins, and > for mxODBC to stay separate. > > As it is, though, it's a one-man-one-vote system. Guido is the man, he has > the vote. So we'll just have to wait and see... > > 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. -- Marc-Andre Lemburg ______________________________________________________________________ Company: http://www.egenix.com/ Consulting: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From jeremy at alum.mit.edu Wed Jan 17 18:02:05 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Wed, 17 Jan 2001 23:02:05 GMT Subject: Securing passwords stored inside of a database field using Python References: Message-ID: <945897$pvo$1@nnrp1.deja.com> There's more to securing passwords that just picking an encryption algorithm -- and keyed hashes seem to be more common that encryption. PKCS #5 describes one good way to encrypt and decrypt data using passwords. It's implemented in Pisces. PKCS #5: http://www.rsasecurity.com/rsalabs/pkcs/pkcs-5/ Pisces: http://www.cnri.reston.va.us/software/pisces/ -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ From jurgen.defurne at philips.com Mon Jan 29 07:02:30 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Mon, 29 Jan 2001 13:02:30 +0100 Subject: xor operator? Message-ID: <0056890020157356000002L962*@MHS> I have indeed never met a language which had a boolean XOR (but some have a binary XOR). I did meet some cases where an action would be needed based upon the exclusivity of two states, but I think it is better for the understanding and maintenance of code when you say : if (not A and B) or (A and not B) Jurgen mwh21 at cam.ac.uk@SMTP at python.org on 26/01/2001 15:17:17 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: xor operator? Classification: Def P writes: > I notice that there doesn't seem to be a boolean xor operator in > Python. Does someone know the reasons behind this? I suspect largely because C doesn't have one (do any reasonably mainstream languages have one? I can't think of any). There was a thread about this fairly recently that shouldn't be too hard to dig up... Cheers, M. -- The ability to quote is a serviceable substitute for wit. -- W. Somerset Maugham -- http://mail.python.org/mailman/listinfo/python-list From rturpin at my-deja.com Mon Jan 15 09:51:37 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Mon, 15 Jan 2001 14:51:37 GMT Subject: Python 3000. Here we go again. References: Message-ID: <93v2pl$f14$1@nnrp1.deja.com> Of course, those of us with some amount of production code written in Python 1.x and 2.x have a very hard desire for Python 3K: backward compatibility. Russell Sent via Deja.com http://www.deja.com/ From donn at u.washington.edu Mon Jan 22 19:40:57 2001 From: donn at u.washington.edu (Donn Cave) Date: 23 Jan 2001 00:40:57 GMT Subject: How do I know all thrown exceptions of a function? References: Message-ID: <94ijup$otc$1@nntp6.u.washington.edu> Quoth "Delaney, Timothy" : ... | Here is my take on things: | | Four built-in exception classes, three of which form the basis for "trees" | of exceptions: | | Exception | type(Exception) == | used for "normal" exceptional circumstances - these | need to be declared | | SilentException(Exception) | type(SilentException) == | used for things which should normally just pass | through (such as index-out-of-bounds) - these don't | need to be declared. | | UndeclaredException(SilentException) | Raised when an undeclared Exception is | raised | | Error | type(Error) == | used for "really bad" things which probably can't be | recovered - these don't need to be declared | | A function needs to declare all the Exceptions it will raise. If a function | raises an Exception it doesn't declare, instead an UndeclaredException is | raised with the raised Exception as its data. | | SilentException is a subclass of Exception so you can continue to do | | try: | except Exception: | | Things like index-out-of-bounds should be SilentException so they don't | explicity need to be declared in just about every function around. | | There would be no requirement to catch any type of exception, whether | declared or not. | | I think this covers all worries with backwards compatibility, whilst moving | towards a well-defined exception system. Could you explain more about what that does for you? I don't understand "things which should normally pass through (such as index-out-of-bounds)". Pass through what? When you later say "so they don't need to be declared in just about every function around", does that account for the whole reason behind SilentException? I don't understand the distinction between Exception and Error. Would you be able to catch Error the same as Exception? If not, what happens? If you can catch them the same as Exception, then it's just another category invented so you won't have to declare the exception? Donn Cave, donn at u.washington.edu From bernard604 at my-deja.com Tue Jan 30 15:59:28 2001 From: bernard604 at my-deja.com (bernard604 at my-deja.com) Date: Tue, 30 Jan 2001 20:59:28 GMT Subject: arbitrary lists to map Message-ID: <9579v9$osi$1@nnrp1.deja.com> Is there any way that an arbitrary number of lists (or sequences) can be assigned to the sequence parameter of the map(func, sequence) function. D. Bernard Sent via Deja.com http://www.deja.com/ From dsh8290 at rit.edu Fri Jan 19 13:25:49 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 19 Jan 2001 13:25:49 -0500 Subject: PSU uses emacs? In-Reply-To: <949rii0a76@news1.newsguy.com>; from aleaxit@yahoo.com on Fri, Jan 19, 2001 at 05:55:45PM +0100 References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> <3a685ef2.3403798@reading.news.pipex.net> <949rii0a76@news1.newsguy.com> Message-ID: <20010119132549.K4478@harmony.cs.rit.edu> On Fri, Jan 19, 2001 at 05:55:45PM +0100, Alex Martelli wrote: | | > Any other tips for using gvim with Python? | | Use blank lines cleverly to delimit logical blocks, so { and } are | useful movement-commands -- also increases readability. Would be | nice to have movement commands based on indent-levels, but, to be | quite honest with you, I've never bothered programming them... I'd like this too. In C/C++/Java it is nice to type "%" to jump between begin and end of blocks. | (shame's about to engulf me...). I like :set expandtab always | on -- no tab/space confusion; I also like :set ff unix, so that my | scripts can be shared between Win and Unix machines (and why | waste one byte per line to tell a 'carriage' that is not there | to 'return' [to where?]...?!-). Exactly. DOS/Windows never did operate from a teletype did it? I suppose no one will ever figure out why a system that began on the teletype (Unix) doesn't use the extra character and a system that didn't (DOS/Windows) does. | | Oh, and the key tip for gvim under Win98 - the quoting character | is NOT control-V (they used that for 'paste' to follow Win | conventions) -- it's control-Q instead. So to remove those | silly control-M (carriage-return) that using some other editor | may have inserted, :%s/^Q^M// is what one types (with ^ to mean ^ What does the % mean here? I usually use :g/^V^M/s/// (working on NT or in cygwin's console vim). -D PS. Alex: I'll be at my other job tonight, I'll check what version of AIX they use. The terminals are 315x I think. (from the "Python in Industry" thread) Your info about IBM's history was interesting. From gradha at iname.com Mon Jan 15 15:44:04 2001 From: gradha at iname.com (gradha at iname.com) Date: Mon, 15 Jan 2001 21:44:04 +0100 Subject: Python converts my 8-bit strings References: <0h6q39.frl.ln@127.0.0.1> <6or86.6205$Qb7.904800@newsb.telia.net> Message-ID: Fredrik Lundh wrote: > gradha at iname.com wrote: >> When I for example fed string.split with an 8 bit string, all the 8 bit >> characters get converted into what looks like utf-8 codes. > you're probably confusing the string escaping done by > the "repr" function with utf-8 encoding. Exactly. Thanks for the info (in fact, I was going to ask shortly what was that repr thing...). -- Grzegorz Adam Hankiewicz gradha at iname.com - http://gradha.infierno.org Other web pages: http://glub.ehu.es/ - http://welcome.to/gogosoftware/ From aleaxit at yahoo.com Wed Jan 17 06:31:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 17 Jan 2001 12:31:57 +0100 Subject: Problem with a tuple - newbie ignorance References: <3A633531.9010303@yale.edu> <3A635C32.9E5285C5@yale.edu> <3A64D9E8.B1D52E1E@mail.mcg.edu> Message-ID: <943vu402jit@news2.newsguy.com> "Keith F. Woeltje" wrote in message news:3A64D9E8.B1D52E1E at mail.mcg.edu... > Normal (forward) slashes won't however work in a command prompt window > in Win2000. > Does the python interpreter make the change "magically" (like it does > the end of line marker)? Not really -- it's actually the (Microsoft) runtime libraries that _underlie_ the interpreter (and every other C or C++ program that is compiled/linked with Microsoft Visual C++) that accept forward slashes or backward ones indifferently in file-paths (just as it's the same Microsoft runtime libraries that perform any line end translation that may be needed). But I've never seen any C or C++ compiler for Windows (or, earlier, DOS) that would fail to provide this little convenience (I _think_, but I'm not sure I recall correctly, that DOS would accept forward slashes even at the system-call [interrupt] level, while the Win32 APIs are not so forgiving). The command-line processors have long been the worst-crippled parts of MS operating systems (which IS saying something, given the crippledness level of other parts thereof:-). Alex From phd at phd.pp.ru Thu Jan 25 07:36:52 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 25 Jan 2001 15:36:52 +0300 (MSK) Subject: urllib.urlretrieve("http://free.bsdshell.net/") In-Reply-To: <94oiss$1hm2$1@news1.simtel.ru> Message-ID: Thanks. While we were trying to resolve the issue, the site died and replaced by some French site. So it is too late to do experiments. BTW urllib now happily connects to it. Thanks to all who helped! On Thu, 25 Jan 2001, Alexander Semenov wrote: > Try to run 'telnet yoursite', then blindly type 'GET /index.html' and > press Enter twice. GET / HTTP/1.0 Host: yoursite:80 I'd recommend to use netcat utility for this: echo -e "GET / HTTP/1.0\nHost: yoursite:80\n\n" | nc yoursite 80 >log Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From ryu-jin at bigfoot.com Mon Jan 15 11:35:49 2001 From: ryu-jin at bigfoot.com (Ryujin) Date: Mon, 15 Jan 2001 16:35:49 GMT Subject: Python and ODBC? References: <93tfo0$12p$1@ryu.it> <93upsf02pvl@news1.newsguy.com> Message-ID: <93v276$c0k$1@ryu.it> In article <93upsf02pvl at news1.newsguy.com>, "Alex Martelli" wrote: thx for your help matte > "Ryujin" wrote in message > news:93tfo0$12p$1 at ryu.it... >> Which is the best solution to work with python and a SQL database under > Windows? > > So much depends on what _scale_ you need to work...! Multi-user, or > single? Do you need transactions, stored procedures/triggers, etc? Even > typical database size is a factor. > > For really small-scale needs, for example, Gadfly has interesting > characteristics -- you might want to look into it -- but it is not > designed to scale up to intensive multi-user accesses or really huge > databases. > > So, hard to give a 100% answer, but, if you're Windows-only, you might > want to try MSDE, the freely-redistributable version of SQL Server > (shorn of the various graphical front-ends &c); you can download and > use/redistribute it freely if you have a license for Microsoft Studio or > Office Developer. It scales well up to 5 simultaneous users, and has > all the trimmings you'd expect from a professional RDBMS, such as > transactions, stored-procedures, etc, etc. If you don't care about > redistribution, you can also download and use (but not redistribute) SQL > Server Developer Edition, which is the same thing plus the graphical > aids for DB administration/development/debugging. > > It does have an upper boundary of 2 gigabytes per database -- which was > not a problem for us, but might be in other applications. > > I have not tried out the versions of those related to SQL Server 2000, > only the ones related to SQL Server 7 (the previous release), which were > still around for download on the MS site a couple months ago > (sorry, don't have the URL and don't know if they're still there, as > I found out the same bits also were on our MSDN Universal subscription > CDROM's, so I saved downloading the big packs) -- in any case, I have no > reason to doubt that SQL Server 2000 is at least as good (but I only did > a few tests on that myself, and not on the MSDE-equivalents). > >> I mean which module do I have to install on Python 2.0? > > That's part of what I like re MSDE -- you can talk to it directly from > Python via ADO and ADOX (the client-side parts of the MSDAC, which is > also freely downloadable/redistributable), and that turns out to be VERY > fast as well as quite convenient. It may be more so in our case since > we don't _only_ use Python to talk to those DB's; ADO/ADOX can be > accessed equally well from a great variety of programming/scripting > languages. > > Really, the only serious downside I can see is the very strong Microsoft > lock-in that is implicit in all of this. Since our app was > MS-platforms-only anyway for another variety of reason, I chose MSDE > with a perfectly clear conscience. If I had to avoid platform lock-ins, > and still get transactions and stored procedures > (each of those being a real 'must' for us), then, I dunno -- maybe > Interbase, now open-source, has those, but I don't really know much > about it; maybe Postgres (again, no first-hand experience). > > >> What about under Linux? I'm trying to install mxODBC module with MySQL >> db on a Linuxppc box. > > I'll pass on this one, having no experience with MySQL (I don't even > know if it supports transactions and stored procedures!). I do know > it's very popular, so I guess one can't go TOO far wrong with it. > > > Alex > > > -- --------------------------------------- Memelli Matteo Could u imagine a world without Windoz? ryu-jin at bigfoot.com --------------------------------------- From jurgen.defurne at philips.com Wed Jan 31 06:39:20 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Wed, 31 Jan 2001 12:39:20 +0100 Subject: Joining lists Message-ID: <0056900015556676000002L062*@MHS> Hello, list members, Is there a simple way of joining two list to form only one list, like : [1, 5, 6, 4] [4, 6, 7] -> [1, 5, 6, 4, 4, 6, 7] Thanks, Jurgen From cfelling at iae.nl Mon Jan 8 17:01:28 2001 From: cfelling at iae.nl (Carel Fellinger) Date: Mon, 08 Jan 2001 22:01:28 GMT Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> Message-ID: <93dde1$8d2$1@animus.fel.iae.nl> Alex Martelli wrote: ... > This assumes a non-string argument (typically an integer, but that's > not checked here) is meant to set the value to be named by the > string-argument immediately *following* it -- a substantial > simplification. So substantial, that if one ... > Needing to explicitly set values in an enum is rare enough, that it > would seem fully acceptable to me to place the explicit values right > _before_ their names in those rare cases, using the much-simpler > code above. Viva simplicity...!-) Simplicity of implementation, yes. But is this what one would expect? I think all the languages I know that provide an enumaration method that allows for changing the count midway spell it the other way around, first the name then the value. So I strongly argue that in this particular case you better invest a little more in the coding of this enum class to prevent all those easy slip of the keys in the use of it, especially since its use is so rare. Arguely an even better approach would be to have such new counting points be spelled as tuples; a little more eye-catching and simplifying the code even further:) def enum(*args): class Enum: pass curval = 0 for arg in args: if type(arg)==type(()): arg, curval = arg setattr(Enum, arg, curval) curval += 1 return Enum MidiEvent = enum("NOTE_ON", ("NOTE_OFF", 2), "POLYPHONIC_KEY_PRESSURE" # dozens and dozens more... ) -- groetjes, carel From johnvert at my-deja.com Mon Jan 22 18:24:07 2001 From: johnvert at my-deja.com (johnvert at my-deja.com) Date: Mon, 22 Jan 2001 23:24:07 GMT Subject: Replacing control characters. Message-ID: <94ifec$ggt$1@nnrp1.deja.com> Hi, I want to replace actual Ctrl keys that are in files. For example, I saved in Netscape (Linux) an HTML file and when I open it in a text editor there are a bunch of ^M characters around (probably because the file was processed on Windows, which uses a different line ending for textfiles--right?). I want to remove all of these characters, but since it's not an actual caret (^) and a letter M, but the *Ctrl* character C-M I don't know how to refer to them in a regexp. How can I? Also, what would be the most efficient way to do this in Python (e.g. use regexp functions to maybe module string will do?) Thanks, -- John Sent via Deja.com http://www.deja.com/ From nas at arctrix.com Wed Jan 24 12:27:30 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Wed, 24 Jan 2001 09:27:30 -0800 Subject: The fundamentals... In-Reply-To: <20010124085846.A32572@glacier.fnational.com>; from nas@arctrix.com on Wed, Jan 24, 2001 at 08:58:46AM -0800 References: <20010124085846.A32572@glacier.fnational.com> Message-ID: <20010124092730.A32678@glacier.fnational.com> On Wed, Jan 24, 2001 at 08:58:46AM -0800, Neil Schemenauer wrote: > So you can do: > > boo = string.replace(". ", "\n") That should be: boo = string.replace(boo, ". ", "\n") From dnew at san.rr.com Tue Jan 16 20:58:22 2001 From: dnew at san.rr.com (Darren New) Date: Wed, 17 Jan 2001 01:58:22 GMT Subject: python compiled to native in less than a year? References: <941koq077o@news1.newsguy.com> Message-ID: <3A64FC3F.CC208398@san.rr.com> Steve Holden wrote: > patent applications to fail onthe grounds of "prior art". Apparently Arthur > C. Clark described the geosynchronous satellite in concept in the British > magazine "Wireless World", and this was enough to ensure that he was refused > a patent on it later. Uh, no. That was because you must "reduce a patent to art" or some such phrase that basically means you actually have to do it, not just describe how. Since at the time there was no way of launching satellites, there was no way to reduce it to art. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. "It says this wine has syphilis." "I think that's pronounced `sulphates'." From MarkH at ActiveState.com Tue Jan 30 17:36:10 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 30 Jan 2001 22:36:10 GMT Subject: Fatal Python error: Interpreter not initialized (version mismatch?) References: Message-ID: <3A7740D1.3070007@ActiveState.com> Dan Parisien wrote: > Dan Parisien wrote: > > I have more info. It is a thread problem. The program is a socket server > with a custom crypto module. I launch a thread to start the main loop to This is pretty complicated! The best I can do is point you at the CEnterLeavePython class in the Win32 extensions. Check out pywintypesmodule.cpp and pywintypes.h - these can be accessed via CVS - instructions at http://starship.python.net/crew/mhammond/cvs.html This is obviously windows only, and will have some trouble porting to Linux due to the lack of portable Thread Local Storage (TLS). The PyXPCOM extensions have a more portable implementation, but it uses the Netscape Portable Runtime (NSPR) for TLS, so probably isnt what you want. Hope this helps... Mark. From donn at u.washington.edu Thu Jan 4 16:53:07 2001 From: donn at u.washington.edu (Donn Cave) Date: 4 Jan 2001 21:53:07 GMT Subject: Setting environment for current shell References: <932f4d$n0r$1@nnrp1.deja.com> Message-ID: <932rc3$ikm$1@nntp6.u.washington.edu> Quoth grante at visi.com (Grant Edwards): | In article <932f4d$n0r$1 at nnrp1.deja.com>, bragib at my-deja.com wrote: | |> How do you set an environment for the shell you are running python in. |> os.system() spawns its own shell. I would like to gain access to the |> parent shell. | | You can't. You can only modify the current environment not | your parent process's. Right, and if you want to modify that current environment, the "os" module exports an "environ" object that behave like a dict. import os os.environ['HI'] = 'Hi' os.system('printenv HI') The same thing does not work with the posix module, though it has a similar environ object; there's extra stuff built into the os version, that pushes changes into the environment propagated by system() et al. You can also supply a complete environment, as a dict, in the 3rd parameter to posix.execve(). Donn Cave, donn at u.washington.edu From etienne at alias.it Thu Jan 18 11:31:07 2001 From: etienne at alias.it (etienne at alias.it) Date: Thu, 18 Jan 2001 16:31:07 GMT Subject: Garbage collector - please Help !! Message-ID: <9475ob$c6v$1@nnrp1.deja.com> hi everybody, I'm developping on a Macintosh platform a python based project with a C++ GUI. The GUI is the application, calls to python are ambedded in the C++ code with a proper GUI API interface. I'm running into problems with Python memory management.The set of python functions I run, is embedded into a C GUI on the Macintosh. Since the interpreter does *NOT DEALLOCATES* memory when I release PyObjects used either by the gui and the interpreter, I was supposing that it was my fault in increffing and decreffing objects. I've deeply investigated into the object reference counts, guessing I was coding wrong somewhere.Now I'm sure the C GUI increffs and (most important) decreffs PyObjects properly. The result is that the Python Interpreter sucks all the application memory causing the application to crash (exit). *BUT* I performed the following tests: 1 - I've run my python code from the python ide (notice: same code without the C embedding api).Result: It sucks all the memory allocated by the python ide, causing it to except a Memory error; 2- I've run my python code on a Linux OS.Result: It worked perfectly, deallocating memory as espected. This convinced me that it is due to the Python garbage collector, is this correct? Is there a way to force the PythonCore garbage collector to deallocate memory when objects are disposed?? There's a path you can suggest for further investigation?? I'm using PythonCore 1.5.2, Is there any resonable chance that Python 2.0 will do a better job? thanks in advance etienne Sent via Deja.com http://www.deja.com/ From LangaK at discoveryhealth.co.za Wed Jan 10 06:54:29 2001 From: LangaK at discoveryhealth.co.za (Langa Kentane) Date: Wed, 10 Jan 2001 13:54:29 +0200 Subject: creating executables Message-ID: Greetings. I am new to python and I can recall, of the many sites that I have visited, I think one of the tutorials that I read mentioned that it is possible to create executables for python. I want to create an application that will run without needing the interpreter. Thanks in advance __________________________________________________________ Langa Kentane | TEL: (011) 290 3218 Security Administrator | Cell: 082 606 1515 DISCOVERY HEALTH | http://www.discoveryhealth.co.za __________________________________________________________________ From cfelling at iae.nl Thu Jan 25 15:15:22 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 25 Jan 2001 21:15:22 +0100 Subject: python-2.1 function attributes References: Message-ID: <94q1gq$5u0$1@animus.fel.iae.nl> Mike Romberg wrote: >>>>>> " " == Michael Hudson writes: > > I suspect if you can come up with a decent syntax, it will go > > in. I can't though. Any ideas? > Well... I don't know if this qualifies as decent. But I'll put it > out there. The thought I have is that perhaps default attributes > could be handled like variable/keyword arguments. This would have the > nice feature of moving 'em out of the function body. I suppose we > could use '***' to indicate that the named argument is really an > attribute which the given value. Something like this: > def spam(a, ***attr1='val1', ***attr2='val2'): > pass looks very promissing, better then what I came up with:) The only nit-pit being that one might expect to be able to refer to attr1 and attr2 in the function body, and perhaps one should. And the second more serious objection being that one might think it's possible to supply values at function call:( -- groetjes, carel From tinu at email.ch Mon Jan 8 02:27:21 2001 From: tinu at email.ch (tinu at email.ch) Date: 08 Jan 2001 08:27:21 +0100 Subject: problem with numpy References: <3A56048D.1D6A4737@cpsc.ucalgary.ca> Message-ID: Your problem is not a bug in Numeric, but a common mistake: You divide by an integer (integer array in your case), which gives you integer division (the DIV operator in some Languages). Invoke all arrays explicitly as Float/Double, i.e. y = Numeric.zeros( x.shape, 'f' ) # output array or y = Numeric.zeros( x.shape, 'd' ) # output array or y = Numeric.zeros( x.shape, Numeric.Float ) # output array and your result looks more realistic. Don't-let-you-fool-by-implicit-type-definitons-ly Martin From cpr at emsoftware.com Thu Jan 18 11:46:01 2001 From: cpr at emsoftware.com (Chris Ryland) Date: Thu, 18 Jan 2001 16:46:01 GMT Subject: interesting bound-built-in-method technique Message-ID: <9476k6$d55$1@nnrp1.deja.com> Reading the Quixote sources taught me an interesting little "hack" using bound-built-in methods: >>> m = {'foo': 1, 'bar': 0}.has_key >>> m('foo') 1 >>> m('bar') 0 Is this a common idiom in Python? Very clever for turning a dictionary lookup into a functional form. Are there other clever but generally obscure idia? (Idioms? ;-) -- Chris Ryland * Em Software, Inc. * www.emsoftware.com Sent via Deja.com http://www.deja.com/ From peter at engcorp.com Thu Jan 4 01:05:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 04 Jan 2001 01:05:04 -0500 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <3A4F4B4D.ECD6B172@engcorp.com> <92v7g502oh4@news2.newsguy.com> Message-ID: <3A541290.DBC66A99@engcorp.com> Alex Martelli wrote: > > "Peter Hansen" wrote: > [snip] > > I can see your point (remarkable, given this thread, isn't it? :-). I > > guess I consider the "block" to be everything except the code that allows > > entry into the block. > > So what about: > try: > > except something: > > and so on? Would you like it better if the 'except' was indented? It's > NOT, after all, 'code that allows entry' in the "block" (overall try/except > statement). I _do_ consider it to be 'code that allows entry' into the block. After all, there are _two_ blocks here, nested inside a single outer block: try: block1 except: block2 To me, a block is a set of statements which are indivisibly executed when unexceptional operation occurs (within the block). That is, assuming no exceptions occur, all statements within block1 execute. After a possible exception occurs, all statements in block2 execute. (Don't bother taking that definition too literally. I understand the possibly of a return in the middle of the code, etc. It's the spirit of this definition I want to communicate, not the letter. :) These two blocks are effectively just 'sub-blocks' of whatever block of code contains the whole 'try/except' statement, which may or may not have preceeding and following statements. So no, I most definitely would have trouble if the 'except' statement were to be indented, since it is _not_ part of the block in the 'try' portion of the code. The graphical examination of the three brace/indentation styles in Code Complete by McCarthy is, in my opinion, an excellent way of comparing the alternatives. I can't imagine anyone feeling wholly comfortable with the traditional K&R style after reading that section. I was extremely happy to discover, in my first moments looking at Python code, that the indentation-based syntax of Python exactly maps to the style I've used for so long and which McCarthy argues is superior. From aotto2 at my-deja.com Tue Jan 9 02:36:00 2001 From: aotto2 at my-deja.com (aotto2 at my-deja.com) Date: Tue, 09 Jan 2001 07:36:00 GMT Subject: CO-process References: <93a535$n76$1@nnrp1.deja.com> <_2666.240898$U46.7569402@news1.sttls1.wa.home.com> <4i666.240905$U46.7570799@news1.sttls1.wa.home.com> <93bp9f$v1h$1@nnrp1.deja.com> Message-ID: <93ef11$5ej$1@nnrp1.deja.com> Hi, > > > > > heavyweight for many of the things you'd want to use .net for. > > > > 1) the solution for MqSeries has only 20 KB wich isn't heavyweight. > > I was thinking more of IPC time than memory use. In fact the CO-Process architecture is in most cases faster, because you write the CO-Process in the language who is fit best to the problem and you don't have to step into , for example, TCL details. If you just take MqCon. MqGet that is the listener of MqSeries wand ill be mostley called in some kind of while loop to wait for messages. 1) How TCL event handling works with the MqSeries while loop if both are running in the same process ? You have to fit both together which mean this is a very terrible work and the solution will be definit slower than a CO-Process 2) In fact if you really step down real world problem's and start thinking in CO-Process like manner you find out that in most cases the transport of the JOB through STDIN to the CO-Process is not the *time* problem. 3) There are some cases which will most benefit from Free.NET - message technology ( MqSeries,... ) - database connection ( sybase, oracle, db++ .. ) - gui programming and a lot more ... > > > 2) One CO-Process is used to manage one "task" ( DB, Communication > > GUI-Interface, Appl-Server, ...) there is no need to write > > one task in more than one language, the benefit is that you > > can choose the right language for the task, and the clear > > and easy interface between the tasks > > That was my impression. As I wrote before, this is fine for what it > is, but does not match up feature-by-feature for what .net is offering > (on paper, anyway). > you should not forget the Microsoft .net is just a paper and Free.NET you can download this is in fact a huge difference. Free.NET offers you a technology which is *easy* to understand *easy* to use and able to handle *multi* language needs, this is real a big step in the right direction without even learning 1000's of interface procedures, subroutiens, classes. If you just look to tcl, perl and python everybody tries to write his own DB, GUI, .. interface and everybody have to update his interface with every new (language)release comming out. Which is an big waste on man- power and a big waste on future. If you look to MqCon a perl guy will be able to write an perl interface in less than 3 days and this interface will not be changeed with every (language)release. mfg aotto :) Sent via Deja.com http://www.deja.com/ From steve_evans at my-deja.com Mon Jan 8 11:04:04 2001 From: steve_evans at my-deja.com (steve_evans at my-deja.com) Date: Mon, 08 Jan 2001 16:04:04 GMT Subject: Problem importing dll module Message-ID: <93code$niu$1@nnrp1.deja.com> Hello, I am having a problem importing a C dll. If I run python and import the module it works fine. However if I run a test harness python script that imports a module that several levels of importing later imports the problem module it fails with this error: Traceback (innermost last): File "test.py", line 8, in ? import CTR File "/users/stevee/hotstage/cmgui/source/ctf2cmds\CTR.py", line 5, in ? import CMDdv_s File "D:/users/stevee/hotstage/cmgui/source/cmds/packs\CMDdv_s.py", line 5, in ? import CMDbusList File "D:/users/stevee/hotstage/cmgui/source/cmds/packs\CMDbusList.py", line 5, in ? [snip bulk of traceback] import CMDpinOrderGroupList File "D:/users/stevee/hotstage/cmgui/source/cmds/packs\CMDpinOrderGroupList.py", line 5, in ? import CMDpinOrderGroup File "D:/users/stevee/hotstage/cmgui/source/cmds/packs\CMDpinOrderGroup.py", line 7, in ? import CMDpinRefList File "D:/users/stevee/hotstage/cmgui/source/cmds/packs\CMDpinRefList.py", line 4, in ? import C_CMDpinRefList ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed. My first thought was that I was running out of memory, but that is not happening. The modules and test harness work fine on both Solaris and Hp-UX Steve Sent via Deja.com http://www.deja.com/ From peter at engcorp.com Thu Jan 4 20:54:02 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 04 Jan 2001 20:54:02 -0500 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <3A4F4B4D.ECD6B172@engcorp.com> <92v7g502oh4@news2.newsguy.com> <3A541290.DBC66A99@engcorp.com> <931ejk02cjt@news2.newsguy.com> Message-ID: <3A55293A.36B4152C@engcorp.com> Alex Martelli wrote: > > "Peter Hansen" wrote: > > Alex Martelli wrote: > > > > > > So what about: > > > try: > > > > > > except something: > > > > > > and so on? Would you like it better if the 'except' was indented? It's > > > NOT, after all, 'code that allows entry' in the "block" (overall try/except > > > statement). > > > > I _do_ consider it to be 'code that allows entry' into the block. After > > all, there are _two_ blocks here, nested inside a single outer block: > > > > try: > > block1 > > except: > > block2 > > And what is the alleged difference with: > > while : > > if : break > > > ??? Here, too, we have two 'blocks' (suites), nested into a single > loop. I may be changing my claimed definition of a block, but not what I meant in the first place... try this: "a block is a sequence of statements all at the same (indentation) level, uninterrupted by statements of a higher level." In other words, the 'try/except' consists of one outer block with a single 'compound' statement which contains within it two "subblocks" (nested blocks at a lower indentation level). The while/if/break consists of a total of three blocks: the outer one containing only the 'while' statement, the contained block which is always present after a while statement, and the even-lower-level block that is nested under the 'if' statement. In other words, I consider , the 'if', and the statements all to be part of the same block (since they're at the same 'level'), which is the single block that contains the code within a 'while' statement. (Peter wrote:) > > To me, a block is a set of statements which are indivisibly executed > > when unexceptional operation occurs (within the block). That is, > > assuming no exceptions occur, all statements within block1 execute. > > After a possible exception occurs, all statements in block2 execute. Yes, I definitely wrote a poor description of what was in my mind. Scratch the immediately above paragraph entirely. (Alex wrote:) > But 'the devil is in the details'! A 'basic block' as normally > considered by a compiler *does* need to consider conditional > breaks, continues, returns as terminating the block. Then clearly the definition of 'block' in the context of compilers is unrelated to the definition of 'block' in my mind and in my indentation style in C. > I still fail to see how you conceptualize a while/if...break as so > drastically different from an if/else, try/except, and so on. I see I'm sorry, I didn't mean to state that the two were in any way different, and I don't believe they are. 'if/else' consists of three blocks (two nested ones inside an outer one). The 'try/except' is identical. The 'while/if/break' is as I described above. > it as just syntax sugar, determined by historical accident, for > Knuth's loop/while statement: > loop : > > while : > > and consider the Python-enforced indentation of its spelling of > 'while :' (which is "if not : break":-) > to be a minor annoyance. To tell you the truth, I hadn't examined the above structure in detail before now. If it is really intended to be identical to the 'while/if/break' structure, then I have to say I think it's really, really ugly, at least when written the way you have above. To me the entire content of the 'loop' statement would have to be considered a _single_ block, which to me would require the indentation of the 'while ' part to be indented along with everything else. Only 'loop' could be outdented. Without spending more time examining Knuth's structure and figuring out the implications, I can only say I'm very happy with 'while/if/break' in general, and especially in comparison to the Knuth alternative. I have no idea whether this makes my technique completely inconsistent in the face of this theoretical structure, but I find the outdented 'while' in the above completely violates my ideas of propriety! :) > ... let me assure you that I'm perfectly familiar > with McCarthy (and many, MANY other style books:-) ... (My bad: someone else mentioned Steve McConnell and it was in fact he, not Jim McCarthy, who wrote Code Complete.) > consider KR style by far the best. Screen real-estate (most > specifically, number of lines displayed at once) is an important > resource to be invested wisely, not squandered... I can understand that argument, but years ago I concluded the tradeoff I was making to follow K&R was not worth it. I believe even with braces taking up individual lines all by themselves, I have more than enough lines on-screen at once. If I feel I can't see enough code with the 35 or 50 lines I have in the window, I conclude my code is likely getting too complex and needs refactoring. Meanwhile the extreme cleanliness of my brace indentation style makes the refactoring proceed more reliably and easily. But YMMV, and obviously does. :) > And I was just as happy to discover that Python's use of > indentation in lieu of braces completely avoids squandering > precious screen-lines unproductively -- just like (even better, > actually) the K & R style which I'll always keep using and > defending for C, C++, and Java sources. > > Isn't Python just great in its ability to keep happy people > from such opposed camps, through the SAME device?-) Worth all > the interminable threads on this group with non-Pythonistas who > are *adamant* Python *SHOULD* allow (or mandate) braces...!-) Complete, total agreement! :) From nas at arctrix.com Sat Jan 27 11:33:52 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Sat, 27 Jan 2001 08:33:52 -0800 Subject: . Python 2.1 function attributes In-Reply-To: ; from tim.one@home.com on Sat, Jan 27, 2001 at 06:01:27PM -0500 References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> Message-ID: <20010127083352.A8269@glacier.fnational.com> On Sat, Jan 27, 2001 at 06:01:27PM -0500, Tim Peters wrote: > You might like this new 2.1 feature better then, best illustrated by > example: > > >>> def f(\d+)(i): > ... return int(\1) + 1 > ... > >>> f12(6) > 18 Cool. People can't say there are no revolutionary new features in 2.1 now. Neil ;-) From boyd at cpsc.ucalgary.ca Fri Jan 5 12:29:49 2001 From: boyd at cpsc.ucalgary.ca (Jeff Boyd) Date: Fri, 05 Jan 2001 10:29:49 -0700 Subject: problem with numpy Message-ID: <3A56048D.1D6A4737@cpsc.ucalgary.ca> I have a program that uses Numerical Python that is behaving oddly. A program that demonstrates is below. The assignment to y[i] in the function "filter" (an IIR filter) does not appear to happen so the result is always an array of zeros. Questions: 1. is this a bug or am I doing something wrong? 2. if it is a bug, will an upgrade fix it? (I am using ver 15.2 right now) # bug.py - a bug, I think, in NumPy import Numeric from math import * # apply an IIR filter (H(z) = N(z)/D(z)) to an input signal, x def filter( N, D, x ) : y = Numeric.zeros( x.shape ) # output array n = x.shape[0] # number of samples N = N / D[0] # normalize filter coefficients D = D / D[0] on = N.shape[0] - 1 # orders of N and D polynomials od = D.shape[0] - 1 N = N[-1::-1] # reverse order of coefficients D = D[-1::-1] for i in range(1,n) : #print i, Numeric.sum( x[i-on:i+1] * N ), #print Numeric.sum( y[i-od:i ] * D[:-1] ) ############################# # this assignment fails y[i] = Numeric.sum( x[i-on:i+1] * N ) - Numeric.sum( y[i-od:i ] * D[:-1] ) ############################# return y # compute filter coefficients tau = 5 w1 = 2 * tan(pi/tau) Nlp = Numeric.array( [1.0, 1.0] ) Dlp = Numeric.array( [1.0 + 2/w1, 1.0 - 2/w1] ) # apply the filter to a step function x = Numeric.zeros( 30 ) x[15:] = 1 y = filter( Nlp, Dlp, x ) # print the result for i in range(30) : print i, y[i] -- ------------------------------------------------------------------------------ Jeffrey E. Boyd Department of Computer Science E-mail: boyd at cpsc.ucalgary.ca University of Calgary Phone: (403) 220 6038 2500 University Drive NW Fax: (403) 284 4707 Calgary, Alberta, Canada T2N 1N4 URL: http://www.cpsc.ucalgary.ca/ ------------------------------------------------------------------------------ From barry at digicool.com Sat Jan 27 11:23:05 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Sat, 27 Jan 2001 11:23:05 -0500 Subject: . Python 2.1 function attributes References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> Message-ID: <14962.62953.304511.523826@anthem.wooz.org> >>>>> "RB" == Robin Becker writes: >> Barry also added code to Python 2.1 to let you write, e.g., def >> f() >> x: x = 1 y = 2 as a short way to spell "whatever the >> value of x is at the end of the function, return that". I'm >> sure you'll agree that's much cleaner than the clumsy def f(): >> x = 1 y = 2 return x people suffer with today. | .... | mmmhhhh :( what happens with | def f() >> x: | return 1 RB> def f() >> x: | y=2 | return y RB> seems to me that having multiple ways of doing return is a bad RB> idea It was a joke. Tim meant to write "def f() << x" because "the function f `gets' the value of x". The patch also places the return value as a function attribute so you really write it like this: def f() << x: x = 1 y = 2 print f.x That both calls f and returns the x attribute value. Add in __setattr__ semantics and arguments as list comprehensions, and you get the power and clarity of: >>> def f(x * [x-1 for x > 1]) << x: pass ... >>> print f.x = 5 120 What could be more natural than that? to-be-checked-in-just-after-fred's-optional-braces-patch-ly y'rs, -Barry From mwh21 at cam.ac.uk Mon Jan 15 10:36:58 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 15 Jan 2001 15:36:58 +0000 Subject: bug?: exception and references References: Message-ID: Balazs Scheidler writes: > Something thus holds a reference to the instance, even if it's deleted from > the local namespace of test1(), my question is what it might be? Something starting from sys.last_traceback, I'd think. > I'm using Python as an extension language, and I call the method using > PyObject_CallObject(), if an exception is raised in the function, nothing > frees up the object instance (because of the extra reference). It will get freed up eventually (ie. when the next exception gets raised). Or you could assign None to sys.last_traceback, or "del" that (I'm not sure what best practice is here). Cheers, M. -- If comp.lang.lisp *is* what vendors are relying on to make or break Lisp sales, that's more likely the problem than is the effect of any one of us on such a flimsy marketing strategy... -- Kent M Pitman, comp.lang.lisp From phd at phd.pp.ru Tue Jan 23 04:58:01 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 23 Jan 2001 12:58:01 +0300 (MSK) Subject: Python as a web server? In-Reply-To: <980242697.576973@shelley.paradise.net.nz> Message-ID: On Tue, 23 Jan 2001, Aaron wrote: > Hi all, I was wanting to dable in writing a very simple online turn based > game, and was wondering if python could manage the server and client side of > things? I'd need database access on the server, and would need to be able to > get the client to print text of course, and draw some simple graphics like > lines, circles, fills, points and the odd image. > > Could someone tell me if this is possible or should I use something else > (Like php). If python is the way to go do you have any links on python > server writing? Python is definetely the way to go. Python camoes with few simple HTTP servers right in the standard library. For client side, there are httplib.py, sgmllib/htmllib/py, Cookie.py, etc. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From smnordby at yahoo.com Fri Jan 26 18:03:32 2001 From: smnordby at yahoo.com (Steve) Date: Fri, 26 Jan 2001 15:03:32 -0800 Subject: The fundamentals... References: <94sa4a$vo8$1@nnrp1.deja.com> Message-ID: <3A720244.2EF34DA9@yahoo.com> mspiggie at my-deja.com wrote: > I have been trying to find a way to use replace() to perform more than > one replacement within a given file. For instance, suppose I needed to > replace ". " with "\n", but also need to replace "!" with "exclamation" > and "?" with "question". I have tried several approaches to this, but > none of my neophyte ideas have produced satisfying results. > You might try a dictionary: subs = {'.': '\n', '!': 'exclamation', '?': 'question'} for key in subs.keys(): search = key replacement = subs[key] outfile = string.replace(infile, search, replacement) -Steve- From gregj at pobox.com Tue Jan 9 16:08:04 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Tue, 09 Jan 2001 21:08:04 GMT Subject: dns reverse look up with python ? References: <93ecvp$v21$02$1@news.t-online.com> <93fe1k$mh4$0@216.39.151.169> Message-ID: Don't count on symmetry. The IP address you get from socket.gethostbyname() won't always resolve to the same name when you pass it to socket.gethostbyaddr(). Virtual domains, round-robin DNS, and load balancers are just three of many flies in the ointment. For example: >>> import socket >>> s = socket.gethostbyname('www.pdxperts.com') >>> s '216.240.147.136' >>> socket.gethostbyaddr(s) ('basic-igloo.winston.dreamhost.com', [], ['216.240.147.136']) >>> This happens because the pdxperts.com is a virtual domain on the host basic-igloo.winston.dreamhost.com. So be careful about what you expect from reverse DNS. -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com "Donn Cave" wrote in message news:93fe1k$mh4$0 at 216.39.151.169... > Quoth "Ralf Claus" : > > | any suggestion about this theme ? > | Is there a way for me (newbie) ? > > >>> import socket > >>> socket.gethostbyname('t-online.de') > '194.25.134.132' > >>> socket.gethostbyaddr('194.25.134.132') > ('www1.sul.t-online.de', [], ['194.25.134.132']) > > That's what I understand "reverse lookup" to mean. Given > a DNS name, like the host name that appears in your email > address "t-online.de", first I look up the IP address with > gethostbyname(). Then, I look up the DNS address by the > IP address. > > Hopefully, after this procedure you have a stable pair of > IP and DNS addresses, so if you repeat this procedure you > will continue to get the same answer. That's the point. > > Donn Cave, donn at oz.net From nas at arctrix.com Fri Jan 19 10:35:11 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Fri, 19 Jan 2001 07:35:11 -0800 Subject: PSU uses emacs? In-Reply-To: <20010119132549.K4478@harmony.cs.rit.edu>; from dsh8290@rit.edu on Fri, Jan 19, 2001 at 01:25:49PM -0500 References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> <3a685ef2.3403798@reading.news.pipex.net> <949rii0a76@news1.newsguy.com> <20010119132549.K4478@harmony.cs.rit.edu> Message-ID: <20010119073511.A16913@glacier.fnational.com> On Fri, Jan 19, 2001 at 01:25:49PM -0500, D-Man wrote: > On Fri, Jan 19, 2001 at 05:55:45PM +0100, Alex Martelli wrote: > > to remove those silly control-M (carriage-return) that using > > some other editor may have inserted, :%s/^Q^M// is what one > > types > > What does the % mean here? I usually use :g/^V^M/s/// (working on NT > or in cygwin's console vim). It means: do the command on all lines in the buffer. Your g command selects lines that match "^M" and does a substitution. The end result is the same. Neil From dirk at infostreet.com Sat Jan 20 10:11:17 2001 From: dirk at infostreet.com (Dirk Leas) Date: Sat, 20 Jan 2001 08:11:17 -0700 Subject: Timestamping JPEGs w/ PIL? Message-ID: Is there a way to put a date/timestmap on JPEG files with PIL? My digicam can generate a data file with all sorts of stats on each picture. I'd like to be able to take that file, parse it, and batch iterate through each picture placing certain pieces of data in the bottom right corner of the picture (like you see on lots of 35mm/camcorder footage). Any advise on doing this with PIL would be appreciated. I also have access to gimp should I need to create the text on the fly to be layered in. TIA, D From rjroy at takingcontrol.com Fri Jan 19 23:54:59 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Sat, 20 Jan 2001 04:54:59 GMT Subject: adding the XML to 2.0 to be a mistake? References: <3d8zocuqrd.fsf@kronos.cnri.reston.va.us> <3a646756.124812921@news1.on.sympatico.ca> Message-ID: <3a691865.131246312@news1.on.sympatico.ca> On 19 Jan 2001 14:19:17 +0100, Martin von Loewis wrote: > >Today, pyexpat allows access to all entity refs to day, it reports the >start and the end of CDATA sections, and it reports comments. So while >I can follow the problems you have with SAX, I can't see why you >complain about pyexpat. > pyexpat allows access to external entities. If an entity is not declared it chokes. That is the behaviour of the underlying expat. However you are correct, I had not realized that the additional handlers had been added to the expat interface. I had tried to migrate to pyexpat a while ago but had to go back to xmllib because of some of these issues. I gripe a lot about the entities but it is not that big an issue when you get down to it, I just hate having to run every bit of data through a substitution routine for the sake of a few entities. Definitely cornercase though. Bob From jhauser at ifm.uni-kiel.de Thu Jan 11 03:13:02 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 11 Jan 2001 09:13:02 +0100 Subject: tk3000 on linux References: Message-ID: <87d7dumrqp.fsf@lisboa.ifm.uni-kiel.de> You can generate a Setup file in the tkinter3000 directory like: # File named Setup *shared* # Choose the right libraries _tk3draw _tk3draw.c -ltk8.0 -ltcl8.0 # End file Setup and copy the Makefile.pre.in from the config directory (e.g lib/python2.0/config) into the tkinter3000 directory. Then make -f Makefile.pre.in boot make Now you can run the demos. HTH, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From sholden at holdenweb.com Sat Jan 20 11:56:28 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 20 Jan 2001 11:56:28 -0500 Subject: Tabbing/Spaces References: <94bjhl$as2$1@news.gu.se> Message-ID: <_uja6.19567$Mo6.198451@e420r-atl1.usenetserver.com> "Martin Sandin" wrote in message news:94bjhl$as2$1 at news.gu.se... > "Tim Peters" skrev i meddelandet > news:mailman.979955644.18879.python-list at python.org... > > > *Mixing* tabs and spaces is insane in Python source. > > Insane it might be, but it is what is "recommended" in GvR's style guide: > > 'Tabs or Spaces? > One indentation level is 4 spaces. Two levels is one tab. Three levels is a > tab and 4 spaces, and so on. Python doesn't mind if you indent one line with > 8 spaces and the next line with a tab -- they are considered to have the > same indentation. Replacing all tabs with spaces is more robust in the light > of some editors on the Mac or PC (which default to displaying the tab > character as 4 spaces instead of 8, as God intended) but this can be done on > transfer to such platforms.' > > Available from python.org, documentations GvR's essays :-) > > Me? A tab is 4 spaces, I hard tab indent my code. It's the easiest and > fastest way for moving my code tab levels. > A tab is 4 spaces for me, too, but I make my editor actually use the spaces instead of the tabs. Since it will remove spaces back to the last tab-stop when I hit SHIFT-tab this means that my listings are correctly interpreted by text-processing tools which insist on treating text as having tab stops every eight spaces. There's nothing worse than a listing which runs off the edge off the page (worst case) or wraps over (better) becaure the tabbing indentation is too long. regards Steve From aleaxit at yahoo.com Thu Jan 18 11:48:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 17:48:46 +0100 Subject: what happens when cookies get too big? References: Message-ID: <9476s4015ti@news2.newsguy.com> "Skip Montanaro" wrote in message news:mailman.979830522.31537.python-list at python.org... > > This isn't really a Python question, but since I'm using Python to implement > things, I figured perhaps I could sneak this in. > > What happens when cookies get too big? Do browsers tend to barf, toss out > the cookie, truncate it, or something else I've not anticipated? RFC 2109 > says oversize cookies (double-stuff?) must be discarded, but I wonder if all > browsers adhere to that requirement. Discarding is, I think, pretty standard behavior (but other cookies may get discarded too if one is -- not sure if that complies with 2109, but it makes sense as the other cookies from a given domain may be no use unless all are present). > I'm storing a cookie that represents a > list of names. It's zlib compressed and base64 encoded, so I can store > quite a few names. But if it gets above reasonable thresholds, you may want to keep it server-side and use the cookie just as a (small!) key to retrieve it. I don't think you should encode all THAT much data into cookies: they're a session-state management mechanism, after all, not a 'data store':). Alex From tim.one at home.com Mon Jan 1 21:57:14 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 1 Jan 2001 21:57:14 -0500 Subject: Recursion In-Reply-To: <3A513319.99F69D27@theworldNoSpammy.com> Message-ID: [David Lees] > ... > Two minor things that come out of playing with recursive and > nonrecursive factorial using PythonWin. A question and an > observation. I'll do what I can, but questions about PythonWin oddities are best directed at Mark Hammond. > 1. I notice a pretty low (<999) recursion depth limit for > factorial on Python 2.0. Can the depth be set easily or does > it require recompiling Python? import sys sys.getrecursionlimit() # returns 1000 by default sys.setrecursionlimit(n) # to set it > 2. A simple iterative factorial such as the one one posted by > Gerlich seems to run out of some printing related resource > under PythonWin at values of N around 1400. Further, the > response of PythonWin seems to be serverly degraded after this. See first comment -- I use IDLE out of loyalty to my boss . > On the other hand, when I assign the output of the iterative > factorial function to a variable, the result is computed very > rapidly (2 seconds for 10000!). I can still display the > output by converting it to a string ala: StringVersion='%s' % x > where x is the 35,660 digit result of 10,000 factorial. A few things to note: + Converting a long x to a decimal string (via str(), %s, repr(), whatever) takes time quadratic in the number of digits in x. So, e.g., on my box, it takes about 16 times longer to convert fac(10000) to a decimal string than to compute it. + Converting a long x to a hex or octal string (via hex() or oct() or %x) takes time linear in the number of digits in x; that's essentially because longs are stored in base 2**15 internally, and converting that to hex or octal is trivial. Continuing the example, converting fac(1000) to a hex string goes about 1000x *faster* than computing it on my box. Or, IOW, converting to hex goes about 10,000 times faster than converting to decimal. Since N**2/N == 10,000 when N=10,000, this isn't entirely coincidence . So if you're just futzing around, stick to hex. + IDLE has no problem displaying fac(10000), so if there is a problem in PythonWin it's likely to be with the underlying text widget. + But IDLE does "bog down" after displaying it, up until the time the last digit of the display scrolls off the top of the window. That's true of any output containing an extremely long single line in IDLE; the Tk text widget seems to feel abused in such cases (my guess is that the widget's line-wrapping algorithm is overburdened). another-millennium-of-widget-excuses-ly y'rs - tim From grante at visi.com Wed Jan 17 12:15:33 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 17 Jan 2001 17:15:33 GMT Subject: Problem with a tuple - newbie ignorance References: <3A633531.9010303@yale.edu> <3A635C32.9E5285C5@yale.edu> <3A64D9E8.B1D52E1E@mail.mcg.edu> <943vu402jit@news2.newsguy.com> Message-ID: In article <943vu402jit at news2.newsguy.com>, Alex Martelli wrote: >"Keith F. Woeltje" wrote in message >news:3A64D9E8.B1D52E1E at mail.mcg.edu... >> Normal (forward) slashes won't however work in a command prompt >> window in Win2000. Does the python interpreter make the change >> "magically" (like it does the end of line marker)? > >Not really -- it's actually the (Microsoft) runtime libraries >that _underlie_ the interpreter [...] >But I've never seen any C or C++ compiler for Windows (or, earlier, >DOS) that would fail to provide this little convenience (I _think_, >but I'm not sure I recall correctly, that DOS would accept forward >slashes even at the system-call [interrupt] level, That's my recollection: the DOS file I/O services accepted forward slashes. >while the Win32 APIs are not so forgiving). That I didn't know. >The command-line processors have long been the worst-crippled >parts of MS operating systems (which IS saying something, given >the crippledness level of other parts thereof:-). Well, the only way they could convince people to use the awful GUI that windows used to have (it's improved somewhat), was to make sure the command-line shell was completely useless. I suppose it's kept MKS in business. -- Grant Edwards grante Yow! -- I love KATRINKA at because she drives a visi.com PONTIAC. We're going awaynow. I fed the cat. From tim.one at home.com Mon Jan 29 04:24:22 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 29 Jan 2001 04:24:22 -0500 Subject: "in" for dicts (was: Python 2.1 function attributes) In-Reply-To: <9535qg$8mu@gap.cco.caltech.edu> Message-ID: [Nathaniel Gray] > ... > Nevertheless, there are still three big problems with "in" for > dictionaries: > > Number 1: There is no reason, a priori, to think that "in dict" should > mean "in dict.keys()" rather than "in dict.values()" or even "in > dict.items()". Explicit is better than implicit, right? This is the reason Guido gave most often in previous years. It appears that only professional debaters *believe* it, though . That is, to the best of my knowledge, nobody ever claimed that they personally would mistake what if x in dict: or for x in dict: meant. They're always worred that "somebody else" might not get it. After a decade, it's increasingly hard to believe that set of supernaturally feeble users isn't empty. > Number 2: The chosen semantics for "in dict" are inconsistent with the > meaning of "in" in the context of lists. The "keys" of a list are the > integers from 0 to len(the list) - 1. > ... But this one he's always dismissed as "hypergeneralization". He really doesn't think of lists (or tuples, for that matter) as being a flavor of mapping. So arguments based on the belief that they are get rejected. > Number 5: (three, sir) Oh yes, number 3: We've already got > "for a_key in dict.keys()"! We still don't have anything else for 2.1; only "a_key in dict" in a *boolean* context has been implemented. And, yes, we've already got dict.has_key(a_key) for that. And, yes, Guido just *approved* of adding "for a_key in dict" too, although implementing that is a puzzle given the current iteration protocol's use of __getitem__ (it doesn't jibe with what dict.__getitem__ does), and "what to do" about programs that go mutating the dict during iteration. > The only reason we're introducing these ambiguous, inconsistent > semantics is so that we can use a dictionary as a set and still > say "for thing in a_set:". As I said before, Guido didn't appear to have sets in mind at all, and neither did Ka-Ping Yee over the years he's been suggesting this change. Ping simply took the recent flurry of "set" discussion as an *opportunity* to push this change again. It's been suggested by many others over the years too, some of whom may never even have heard of sets . > (I sure hope we're not doing it just to save a few keystrokes every > now and then!) No. I don't even believe that was mentioned. Most people seem to think that these uses of "in" for dicts are *obvious*, and that has been mentioned -- often. Some have also mentioned that "x in dict" will be faster than "dict.has_key(x)", and ditto for iteration (in which latter case it may also save an unbounded amount of additional storage). The latter has been a FAQ for years: http://www.python.org/cgi-bin/faqw.py?req=show&file=faq06.012.htp > We're not straightening out an awkward idiom or clearing up a > Python wart, See above. > we're masquerading one data structure as another. I don't see that. Boolean "in" is another name for "has_key", so in that sense it's nothing new at all. And as the FAQ entry above explains, Python already has a dict iterator under the covers, it's simply never been exposed. > "It's not a big dog. Perhaps if we clipped it's ears and taught it to > meow it could pass for a cat!" Oh, now I'm getting confused! Is a dict the dog or the cat? Is a list the other one? And what are the ears? Is meowing iteration? In that case we're taking the cat out of the dungeon and removing the cruel muzzle from its cute little kitty mouth, while giving the doghouse a fresh coat of paint. > Once again, wouldn't it just be better to have a collections module for > Python with a Set class and let dictionaries be dictionaries? Sorry, but this really has very little to do with sets. It's more to make the crocodiles happy without feeding them household pets. > And yes, I dislike list.pop() too. ;^) Really? Or did you intend to say you dislike dict.pop() (which would fit better with the animal analogies ). > Lest I come off as too much of a grumpy Gus, I should add that I really > like most of the new stuff in Python 2.1a1, particularly xreadlines. Figures -- that's the one Guido likes least. He dislikes xrange too. He was forced into xreadlines by timing considerations (we couldn't match its performance cleanly, not with finite effort). The only reason to like xreadlines is speed (which is reason enough!) -- but in that case you should like both flavors of "x in dict" too, and for the same reason. > I'll be first in line to upgrade when 2.1 stabilizes, even if "in dict" > survives. Hey, CVS is open for business! The only way a new release stablilizes is via people *using* it. People who wait until the final release to report bugs are going to have to wait months for relief. That said, Python alpha releases have been more stable than most peoples' final releases in my decade of Python experience, and I'm both surprised and delighted that this doesn't seem to have changed despite the radical change in development process last year. Python is still leading a charmed life that way. don't-ever-name-a-language-"mongoose"-ly y'rs - tim From gmc333 at my-deja.com Tue Jan 30 11:21:04 2001 From: gmc333 at my-deja.com (Greg) Date: Tue, 30 Jan 2001 16:21:04 GMT Subject: xor operator? References: Message-ID: <956pl6$8dg$1@nnrp1.deja.com> In article , quinn at groat.ugcs.caltech.edu (Quinn Dunkan) wrote: > On Mon, 29 Jan 2001 13:02:30 +0100, jurgen.defurne at philips.com > wrote: > >I have indeed never met a language which had a boolean XOR (but some > >have a binary XOR). > > if true xor false then > std_output.put_string("eiffel does!%N"); > end; -- and we can't use the std abbreviations, either, Just Because! > > Not that I've ever actually used it or anything. We only need one kind of > loop, because that's "minimal", but hey, pile on the random boolean operators! > > :) > LOL! I grepped through SmallEiffel's standard library and found one place where the boolean xor was used: in part of a contract. Greg -- http://homestead.deja.com/user.gmc333/index.html Sent via Deja.com http://www.deja.com/ From aleaxit at yahoo.com Fri Jan 26 08:08:04 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 26 Jan 2001 14:08:04 +0100 Subject: win32com.client - need some help References: <94mjj8$v3g$1@nnrp1.deja.com> <94mrs102b3i@news2.newsguy.com> <94pa5c$aqb$1@nnrp1.deja.com> <94pni302k2g@news2.newsguy.com> <94rjot$cbk$1@nnrp1.deja.com> Message-ID: <94rsri027h1@news2.newsguy.com> wrote in message news:94rjot$cbk$1 at nnrp1.deja.com... > > > > > > > HRESULT getDictionary([out] IDispatch** pDictionary); > > > [id(0x12345678)] > > > > Unusual ([out] is generally [out,retval]) but OK. > > Well, I do get a return value, but not what I expected..... > So, I don't know if this is important. It may be. But I'm astonished you get a return-value AT ALL *unless* makepy has been run one way or another. > >>> print dic.__class__.__doc__ > The dynamic class used as a last resort. [snip] > ...I guess this is not what I wanted to see...? Right. > What is causing these problems? Is it a "poor" definition in the > COM server that does not give win32com enough information? Is there Sure, IDispatch** in the IDL is too generic -- no indication at all of _what_ dispinterface is being implemented. Still, that should not be a killer, just a big inconvenience. What's happening here seems to be very different: you seem to be getting an instance of win32com.client.CDispatch and NOT one of win32com.client.Dispatch. So, apparently, there is NO type-information *at all* connected with the object; it does not implement GetTypeInfo to let users know what type-info/type-library it comes from. Still, it _should_ be still possible to invoke methods on it, just not to find out what the invokable methods *ARE*. Alex From shilde1 at irix2.gl.umbc.edu Wed Jan 17 13:59:07 2001 From: shilde1 at irix2.gl.umbc.edu (Stephen Hilderbrand) Date: 17 Jan 2001 18:59:07 GMT Subject: Python Packet Sniffers Message-ID: <944q1r$7od$1@news.umbc.edu> Hello out there, DOes anyone on this group know where to find a python packet sniffer? I've downloaded the Feb 1999 version of PY-libpcap, but it doesn't support filters. I may have to hack PY-libpcap to get it to work the way I need it to, but I figured I'd ask you folks first. I'm on a Debian Linux system running Python 1.52. Please respond by e-mail as I don't frequent news. THanks in advance, Steev. shilde1 at umbc.edu From jgraves3 at austin.rr.com Sat Jan 27 14:26:26 2001 From: jgraves3 at austin.rr.com (jay graves) Date: Sat, 27 Jan 2001 19:26:26 GMT Subject: [Off topic] allowed to put Python material on the Web? References: <3a730931.31998180@news.skynet.be> Message-ID: <3a731f6a.97406397@news-server.austin.rr.com> On Sat, 27 Jan 2001 17:51:57 GMT, Daniel.Kinnaer at Advalvas.be (Daniel) wrote: >As a Python newbie, I've been collecting lots of questions and answers >from this newsgroup. It contains stuff not readily found in the many >good FAQ from the net. >Before setting up a new site, I would like to ask if it is allowed to >put my collection of questions and answers from this newsgroup (which >helped me a lot) on my site,so everyone can enjoy/learn from it >without going to the d?j? palace. Something similar already exists. http://python.faqts.com From peter at engcorp.com Sat Jan 6 23:54:30 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 06 Jan 2001 23:54:30 -0500 Subject: Should I learn Python or Java? References: Message-ID: <3A57F686.D1F1604@engcorp.com> Charlotte Williams wrote: > > I notice that there is a lot of demand for Java programmers. The only > experience I have with an OO language is Smalltalk. My questions are: > > 1. Which language would be best to learn, Java or Python. "Best" is of course dependent entirely on your own requirements. For me, Java was important to learn but at this point Python is hands-down the better (in terms of productivity, fun, and code quality). Actually, I consider the three years between my learning Java and my discovering and learning Python to have been spent relatively ineffectively (using Java and Delphi). My productivity is much higher with Python. Based on what (little) I know of VB and VB programmers, I would have to say Python is definitely "better" for you. > From a VB standpoint, which has the least learning curve? Python. No contest. From a C++ background I took a week to write my first sizable Java program. I took about a week to write my first sizable Python program too. On the other hand, for the former I was on vacation (geek!) and spent about 14 hours a day on it. The Python program was part time at work between other tasks... (As far as reliability goes: with only minor tweaking both programs are still in use. The Java one has been running as a 24x7 server since January 1997. The Python one has been in daily use as a factory test automation system since May 2000. I'm extremely happy with *both* languages' abilities in this respect.) > 2. Is going from object-based to object-oriented programming that huge a > jump? I want to learn an OO language, however I plan on utilizing it in my > career. I wouldn't call it huge, but it *is* different. Look at it as removing your training wheels, perhaps. :) > 3. Which one is the most "fun" to program in? Having spent similar amounts of time with both, I say Python wins convincingly. > 4. Is Python multi-platform? How is it's performance compared to JAVA in > an internet situation? It's reliability? Very multi-platform, although I consider Java similarly so. Performance "in an internet situation" is comparable, but then I would say C would be as well.... after all, "internet" and "bandwidth-limited" are synonymous, aren't they? :) (Going past that issue, though, I believe Java has an inherent potential advantage, but end only a small one [not like a factor of 2 or anything]. In the end, however, if I can write my Python code in half the time it takes to write Java code, I have lots more time to optimize, if I feel so inclined, compared to the Java code. One could argue that makes Python faster...) > 5. Do you for see Python as becoming a major player like Java servlets and > MTS? For me Python is already a "major player". I never made it to servlets, but Zope (in Python) provides me with far more power than servlets looked like they would, for the cost. (What's MTS?) > Can you see Python demand outstripping Java demand in 2 years time? Absolutely not. Java has a very firm and, I believe, deserved role in certain kinds of application, many involving server applications, especially mission critical ones. Although Python, remarkable platform that it is, would perform admirably in even this area, it was _not_ designed for this kind of thing, and would _not_ be the best choice in many cases. The right tool for the right job... for me, 20% of the time C is the right tool, 70% of the time it's Python, 10% it's Java, and 1% it's Assembly (note: this survey has a 1% margin of error, 19 times out of 20 ;-). If those statistics applied to everyone, perhaps Python demand would outstrip Java, but somehow I just don't see that happening. It seems to take a certain amount of idealism in your blood to jump on board something like Python. Hmm.... I remember that being the case with Java, in 1996, but perhaps all those Java people have used up their idealism, or perhaps Guido just can't compete against the Sun marketing machine... Of course, there are people who still think Java demand has yet to outstrip C++ demand, too. I haven't bothered watching either industry to see who's "winning". > Many of these questions are in response to a post I saw earlier where Python > was being touted as the next evolution of OO programming. It went something > like... > C --> C++ --> Java --> Python. Python is not an evolutionary advance beyond Java with respect to object-orientation. Personally I do find it a _revolutionary_ advance beyond Java, in many other ways, but considering that Python came first, that's not entirely the right way to phrase it... Really, they are not exactly in direct competition with each other, so looking at them as parallel evolutionary paths might help. One could say that although the Java genome has had recent strong success "replacing" the C++ genome which only a while ago replaced the C one, perhaps the environmental conditions are changing in such a way that they now favour the Python genome. As with real-world evolutionary competition, biodiversity is _essential_ to life. Both Java and Python are likely to continue to encroach on the territories of other languages as they demonstrate greater fitness in their evolutionary niches. From dsh8290 at rit.edu Mon Jan 29 11:07:24 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 29 Jan 2001 11:07:24 -0500 Subject: Problems with Install In-Reply-To: <5.0.0.25.0.20010127045146.00a42dc0@thewebsons.com>; from zope@thewebsons.com on Sat, Jan 27, 2001 at 05:16:20AM -0800 References: <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net> <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net> <20010126133015.B7309@harmony.cs.rit.edu> <5.0.0.25.0.20010127045146.00a42dc0@thewebsons.com> Message-ID: <20010129110724.A15924@harmony.cs.rit.edu> On Sat, Jan 27, 2001 at 05:16:20AM -0800, Ben Ocean wrote: | Unfortunately I need to install python 1.5.2 from source because I need to | configure it with multithreads. Equally unfortunately, I don't have the | luxury of time to learn C right this red-hot second. But I need to get this Ok, we'll help you figure this out now. Hopefully no one will flame us for describing C and gcc on a python list ;-). | installation working!!! I've run into this error while running *make*. D | said it was due to an error in the myreadline.o So I re-ran make and copied | what printed to screen. The myreadline.o stuff doesn't appear until the | last few lines: Yes, you were running make. But make is just a nice tool that will execute a lot of complex shell commands automatically. You wouldn't want to have to type all the commands it exec's would you? ;-) (rhetorical, don't bother answering it) | | thor:/apache/vhosts/Python-1.5.2# make [snip] | gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c myreadline.c -o | myreadline.o The above 2 lines are the shell command make is exec'ing that is giving you an error. | In file included from /usr/include/errno.h:36, | from ../Include/Python.h:59, | from myreadline.c:42: | /usr/include/bits/errno.h:25: linux/errno.h: No such file or directory Ahh, here's the error message. Note that gcc is what gave the error message. gcc then returns a number other than zero from main(), thus make tells you the following: | make[1]: *** [myreadline.o] Error 1 While trying to execute the commands that will build the target "myreadline.o" there was an error. | make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Parser' | make: *** [Parser] Error 2 Make is a recursive tool, during its operation it will run another copy of itself. The first level of recursion (make[1]:) is leaving the directory it is in. Then you are back to the top-level make (make:) This make process was trying to build the target "Parser", but got an error code from the sub-process. | | Just for fun I tried installing an rpm as you mentioned. The strangest | thing happened. When I got to the actual installation command, the darn | thing just vanished into thin air! running a whereis for python turns up | *nothing*! Oh, geez, what'd I do wrong? I don't know what you did wrong, but try: $ rpm -qa | grep -i *python* to find a list of all packages that have python in the name (the -i on grep makes it case insensitive) Ok, now to sort out the error message: | gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c myreadline.c -o | myreadline.o | In file included from /usr/include/errno.h:36, | from ../Include/Python.h:59, | from myreadline.c:42: | /usr/include/bits/errno.h:25: linux/errno.h: No such file or directory gcc is being told to compile myreadline.c and write the output to myreadline.o. There are a number of options being given to it regarding optimization, include directories, and macro definitions. The -c option tells it to just compile, not perform any linking or create an actual executable. (gcc will be run many times as each file is compiled separately, then linked together at the end) Ok, so you are in myreadline.c, line 42. If you look in the file, you will see a line similar to #include "../Include/Python.h" The "" tells the preprocessor to look in the current directory and follow the relative path. (it is case sensitive, at least on Unices that have case-sensitive file systems, the cygwin port is probably not but I haven't tested it) Ok, so now the preproccessor is going through Python.h. On line 59 of Python.h there is something like this: #include The <> tells the preprocessor to look in the system include directories. /usr/include is the most common one. I believe the system include directories are defined by your gcc installation. Now we are on line 36 of /usr/include/errno.h. This line must inlclude bits/errno.h (I'm concluding all of this from the error message, not actually checking any files on my system, I have a Debian, not RH, system now anyways). The file /usr/include/bits/errno.h (on line 25) is trying to include the file linux/errno.h, but the file doesn't exist on your system. >From your other post you indicated that it had <> brackets around the file name. That means that it is supposed to be in the system include directories somewhere. Maybe /usr/include/linux/errno.h or /usr/local/include/linux/errno.h. Someone else said that linux/errno.h is provided by kernel-headers.rpm. Try installing that rpm and see if it works. Also, check the rpm so you know exactly where it installs the headers to. Keep coming back here to continue your crash-course on C and the preprocessor until you get all the problems worked out. :-) Maybe you'll have time to learn C in the future. I have a copy of a really good tutorial that I found on the web a few years ago. If you want, I can send it to you. HTH, -D From rcameszREMOVETHIS at dds.removethistoo.nl Sat Jan 13 17:40:53 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sat, 13 Jan 2001 22:40:53 GMT Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> <93dde1$8d2$1@animus.fel.iae.nl> <93f3nb023mv@news1.newsguy.com> <90259DC4Arcamesz@127.0.0.1> <93i57b01qms@news2.newsguy.com> <90268BCE3rcamesz@127.0.0.1> <93kb0m0r3s@news1.newsguy.com> <90273B4rcamesz@127.0.0.1> Message-ID: <9028FAA1Brcamesz@127.0.0.1> Harald Hanche-Olsen wrote: >+ rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz): > >| Alex Martelli wrote: >| >| Ah, Lisp, so beautiful, so pristine, so ... verbose. Well, it's >| great for lists, but anything numeric is a chore. Let's see: >| (EQ (PLUS 1 1) 2) >| t >| Phew, so least that's still true... ;-) > >Which is an accident of the implementation, in the same sense that >the following is accidentally true in python: >>>> 1+1 is 2 >1 In python you're quite right, as this example shows: >>> 101+101 is 202 0 >I'm sure you meant to write (= (+ 1 1) 2) ? Oh, sure, if you insist on using *modern* Lisp idiom. Regarding the EQ, IIRC for numerical arguments it should do a normal comparison, at least in the dialect I used some years ago. (Remember XLisp?) For lists it only returns t if they're strictly equal, not structurally equal, so in that respect it works the same as 'is' in Python. I could (maybe should) have used EQUAL or = of course, but, as you might have guessed, I felt like being deliberately obtuse. ;-) >One neat thing about Lisp though, is how you can rewrite the syntax, >for example to allow you to write infix arithmetic if you wish. >This takes much of the pain out of involved numerical work. I wrote >some scheme macros once (many years ago) to accomplish this - it was >only a moderate amount of work. True, the paradigm of Lisp is that all data structures are lists - or cons-cells, rather - including the language itself. >In Common Lisp you can accomplish much the same thing even more >elegantly using reader macros. The problem with reader macros is, however, that there's (generally) no way of translating back. You could be in for a shock if you need to debug that code later on. Mind you, similar things can be said if you're a C-programmer and put too much code into your #define macros. And, though it isn't mentioned often, the same goes for C++'s templates. >but-now-I-have-a-feeling-we're-in-the-wrong-newsgroup-ly y'rs, Right you are. Back to Python it is. Robert Amesz From grante at visi.com Wed Jan 17 17:27:37 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 17 Jan 2001 22:27:37 GMT Subject: parsing a file [newbie] References: Message-ID: In article , Langa Kentane wrote: >ONe thing I don't understand. >When I run os.popen('df -h'), this returns a pointer to an already open file >if I am not mistaken. Correct. >Now, to apply what you gave me to this scenario, how would I go about it. You call the read() or readlines() method of that file object. Something like this: import os import string x = os.popen("mount").readlines() y = [] for line in x: words = string.split(line) if len(words) >= 3: y.append(words[2]) -- Grant Edwards grante Yow! .. are the STEWED at PRUNES still in the HAIR visi.com DRYER? From fredrik at effbot.org Tue Jan 30 06:12:37 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 30 Jan 2001 11:12:37 GMT Subject: Wrapping up a C++ class References: <954496$ues$1@nnrp1.deja.com> <9546rv01ahd@news2.newsguy.com> <9565q3$nnh$1@nnrp1.deja.com> Message-ID: "warrickb at my-deja.com" wrote: > Thankyou all I shall take a look and see if I can make sense of it! It > does strike me as odd that there isn't a simple one source file example > of how to do it in the docs though... well, it does strike me as odd that there are C++ programmers out there who don't understand C: Objects/xxobject.c Modules/xxmodule.c overviews and reference docs are here: http://www.python.org/doc/current/ext/ext.html http://www.python.org/doc/current/api/api.html Cheers /F From gregj at pobox.com Mon Jan 15 02:27:06 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Mon, 15 Jan 2001 07:27:06 GMT Subject: File I/O, rfc822, and stdin/stdout References: <72i36t8mmo27mi2nmv5iahr4ospps9crat@4ax.com> Message-ID: <93u8o8$qsd$1@nnrp1.deja.com> I worked on a similar project, but eventually replaced qmail with postfix and my own scripts with procmail. Here's what worked for me before I abandoned it: ---- import cStringIO import rfc822 s = sys.stdin.read() # read all input at once f = cStringIO.StringIO(s) # string to file-like object m = rfc822.Message(f,1) # parse headers b = f.read() # get message body ... print str(m) # print headers print print b # print body --- In my application I needed to keep the entire message text around (headers + body), so I read it all at once and use cStringIO to pass it to rfc822. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com In article <72i36t8mmo27mi2nmv5iahr4ospps9crat at 4ax.com>, Sheila King wrote: > On Sun, 14 Jan 2001 01:40:43 -0600, Eric Rahmig wrote in > comp.lang.python in article : > > :If you're not using qmail's 'preline' utility in your .qmail files > :that might cause a problem. Without the use of 'preline' the email > :message your script sees will NOT start with a From line and will > :NOT contain a Return-Path header. > > You know, at some point I had been using preline, but eventually I removed it. > It didn't seem to be accomplishing much (of course, I had so many other errors > at that point ... > > Anyhow, just now I put it back in, to see what would happen. At least, it > delivered an e-mail. > > :I'm new to Python and have no experience with the rfc822 module. If > :it is strict in its message parsing and expects a message to contain > :a From line and a Return-Path header then use of preline should help > :you: > : > :.qmail-foo: > :|preline somescript.py ... > > Well, apparently rfc822 requires those lines, because at least now it is > delivering a message. > > Here is the script I just ran: > > ------------------------------------------- > #! /usr/bin/python > > import sys, rfc822 > > raw_message = sys.stdin > > inheaders=rfc822.Message(raw_message) > body=raw_message.read() > > print inheaders > print > print body > ------------------------------------------- > > Here is the e-mail I just received: > ------------------------------------------- > Return-Path: > Delivered-To: xthinkspot-myuserID at thinkspot.net > Received: (qmail 7982 invoked by uid 41121); 14 Jan 2001 15:30:48 - 0000 > Date: 14 Jan 2001 15:30:48 -0000 > Message-ID: <20010114153048.7981.qmail at nine.futurequest.net> > From: sheila at thinkspot.net > Cc: recipient list not shown: ; > Delivered-To: xthinkspot-mytestaddress at thinkspot.net > > > ------------------------------------------- > > That's it. The whole message. > > first of all, the fact that there is no To: field or Subject field in the > message, shows that the headers that came out of my script are somehow broken > (because I did have a To: and a Subject: in the test mail I sent). Secondly, > why is "print body" causing this line? > > ? > > When I ran the following script on a DOS prompt, where I have changed only the > source of input: > ------------------------------------------- > #! /usr/bin/python > > import sys, rfc822 > > #raw_message = sys.stdin > raw_message=open("message4.txt","r") > > inheaders=rfc822.Message(raw_message) > body=raw_message.read() > > print inheaders > print > print body > ------------------------------------------- > > The entire message body (along with headers) is printed out to the screen. > > Anyhow, I guess I will go back to trying to write the messages to files, so I > can see exactly what the script is putting out, and try to figure out what the > problem is. > > Thanks for suggesting preline. It did help. > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org/ > Sent via Deja.com http://www.deja.com/ From ruediger.maehl at web.de Fri Jan 19 08:42:10 2001 From: ruediger.maehl at web.de (Ruediger) Date: Fri, 19 Jan 2001 14:42:10 +0100 Subject: Curses module for Python 2.0 for Windows NT References: Message-ID: Fredrik Lundh schrieb in Nachricht ... >if you can live with a simpler API, here's an alternative >console driver for windows: > > http://effbot.org/efflib/console > >Cheers /F > I downloaded your Console module and found it very helpful, thank you. But when using it, there is always a 0 (zero) return value from the python program although sys.exit(2) is used. Can one set the return value? I didn't find anything in your docs. # Excerpt from example: myConsole = Console.getconsole() myConsole.title("My Application") # app continues here... # Used until now # sys.exit(2) # Perhaps like this? myConsole.exit(2) /Ruediger From w.neff at tirol.com Sun Jan 14 16:22:24 2001 From: w.neff at tirol.com (Wolfgang Neff) Date: Sun, 14 Jan 2001 22:22:24 +0100 Subject: win32all crashes win98 Message-ID: <3a621864$0$21002@SSP1NO25.highway.telekom.at> Python extensions for Windows (win32all) work fine on Windows 2000 and also on Windows 98 SE / IE 5.5 when run within PythonWin. Withing python/pythonw, however, the same script causes kernel32.dll to crash with a stack error. I'd like to run the following script by double clicking its icon without getting a python shell: #MsgBox.pyw import win32con import win32ui win32ui.MessageBox("Message Box","Test",win32con.MB_OK) Is there someone who knows a work-around? Thanks Wolfgang From anderson at boi.hp.com Wed Jan 17 07:43:11 2001 From: anderson at boi.hp.com (Bill Anderson) Date: Wed, 17 Jan 2001 05:43:11 -0700 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> <3A52AD6A.62D043A2@engcorp.com> <3A534367.36B1FD18@uswest.net> <3A53F4B1.6227D241@uswest.net> <3A540D6A.B7B90A73@engcorp.com> <3A548E90.14BA5F4C@uswest.net> Message-ID: <3A65935F.114C78CE@boi.hp.com> Bjorn Pettersen wrote: > > Peter Hansen wrote: > > > Bjorn Pettersen wrote: > > > and you'll have half a dozen people jumping on your back telling you that > > > "while 1" is simple, intuitive, and is the only Pythonic way to do things > > > (you'll have half a dozen other people trying to come up with some clever > > > wrapper to solve the problem they think you have ). > > > > That's hardly being fair. I just checked back on the entire thread up > > to this point and, while I may have missed something, it doesn't appear > > that _anyone_ suggested 'while 1' is either simple or intuitive. > > You forget how many of these we have a year... I believe the October/Novemeber > one included that comment. Yes but that was last year. ;^)= > Are you saying you don't think "while 1" is neither > simple nor intuitive? (I think it's simple, but definitely not intuitive ;-) I believe all he is saying is that nobody in this thread said it was. tongue-in-cheekly-y'rs -- Bill Anderson Linux Specialist Modular Network Storage R&D Random Quote: Portable: survives system reboot. From max at alcyone.com Tue Jan 2 01:42:57 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 01 Jan 2001 22:42:57 -0800 Subject: Equivalent of Java 'throws' References: Message-ID: <3A517871.C31F430@alcyone.com> Daniel Klein wrote: > I've read thru the reference materials concerning exceptions and this > one's got me stumped. Is there any way in Python to do this? I > suspect there isn't since Python is dynamically typed. Nope, other than some kind of explicit documentation. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ I sidestep the either \__/ or choices of logic and choose both. | Ken Feit Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From echuck at mindspring.com Fri Jan 12 23:51:49 2001 From: echuck at mindspring.com (echuck at mindspring.com) Date: Sat, 13 Jan 2001 04:51:49 GMT Subject: Web devel with python. Whats the best route? References: Message-ID: <93omt3$pt5$1@nnrp1.deja.com> In article , Chris Watson wrote: > > I'm about to start converting the small fool proof (ha ha) admin > system I have been working from console based to web based. What is the > easiest way to go about integrating python into apache so I can start > web'izing this app? mod_python, mod_snake, PyApache? > > As usual thanks for the replies! > Chris, I like Webware's design. (http://webware.sourceforge.net) Although, I admit that I could be biased. However, I think the fact that I designed Webware *after* reviewing Zope and various Python web modules mitigates my bias. :-) The components of Webware are modular and optional so you can use as little or as much as you want. Writing servlets with Webware.WebKit is about as easy as writing CGIs, but they perform better and can be expanded upon with other paradigms like PSP. e.g., if you start with servlets, I think you have more places that you can easily go/expand to. You can even install your own custom templating system, which Pythoneers seem to enjoy creating. Also, WebKit gives you "simple URLs" with no extension: http://host.com/foo/bar "bar" can be bar.html, bar.py, bar.psp, or bar.X where X is an extension/plug-in that you created. The key here is that you can switch implementations of "bar" (say moving from .py to .psp to .X) and your URLs stay the same. That means less site maintenance for you and nobody's bookmarks break. Extensions like .html and .py are for programmers, not users. Therefore they don't belong in the URL. -Chuck -- http://webware.sourceforge.net Sent via Deja.com http://www.deja.com/ From gerhard.nospam at bigfoot.de Fri Jan 19 03:51:19 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 19 Jan 2001 09:51:19 +0100 Subject: Yes References: Message-ID: <3A680007.6CEC616A@bigfoot.de> NT (What means NT, btw.?) From sholden at holdenweb.com Thu Jan 4 13:29:26 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 4 Jan 2001 13:29:26 -0500 Subject: AMK's ZODB package on Win32 References: Message-ID: andres.corrada wrote in message news:mailman.978625505.30132.python-list at python.org... > > Can Kuchling's ZODB package be used under Win32? Does someone have > experience doing this? > Simplistically: Zope runs under Win32, and uses ZODB, so presumably the answer is "yes"! regards Steve From trentm at ActiveState.com Wed Jan 3 18:07:15 2001 From: trentm at ActiveState.com (Trent Mick) Date: Wed, 3 Jan 2001 15:07:15 -0800 Subject: problem compiling Python 2.0 on Sun Solaris In-Reply-To: <3a539455.17521624@news.wanadoo.fr>; from jef.mangelschots@iname.com on Wed, Jan 03, 2001 at 09:10:44PM +0000 References: <3a539455.17521624@news.wanadoo.fr> Message-ID: <20010103150715.N28397@ActiveState.com> On Wed, Jan 03, 2001 at 09:10:44PM +0000, Jef Mangelschots wrote: > Hi, > > I just downloaded the sources for Python 2.0 from > http://www.python.org/ftp/python/2.0/BeOpen-Python-2.0.tar.gz > > ALL the text files are unrecognizable to my system because each line > is ended with 0x0D 0x0A, common for Windows NT systems, but not for > Unix systems. You could just get the source from cvs at sourceforge. > export CVSROOT=:pserver:anonymous at cvs.python.sourceforge.net:/cvsroot/python > cvs login # just hit Enter for the password > cvs -z3 co -r release20-maint python I am not sure if this will have a patch or two applied beyond the actual Python 2.0 release but it will be very close. Or you could just run dos2unix on all those files. Cheers, Trent -- Trent Mick TrentM at ActiveState.com From aleaxit at yahoo.com Tue Jan 23 04:46:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 23 Jan 2001 10:46:23 +0100 Subject: unpack sequence to tuple? References: <94j6j1$3na$1@nnrp1.deja.com> Message-ID: <94jjtb0108j@news1.newsguy.com> "Moshe Zadka" wrote in message news:mailman.980234666.18231.python-list at python.org... > On Tue, 23 Jan 2001 05:58:58 GMT, noahspurrier at my-deja.com wrote: > > > I want to easily read arguments in a sequence into separate variables. > > Basically, I want to use a Per1 idiom and do this: > > > > (cmd, host, user, key) = tuple(sys.argv) > > No need for the tuple() or the () on the LHS: > > cmd, host, user, key = sys.argv > > Will work just ine. True (and I fully agree with your implication that it is preferable: more readable, &c). This will give errors if len(sys.argv) != 4. > If you want padding, just roll your own class: > > class PaddedSeq: > > def __init__(self, s, n): > self.s = s > self.n = n > > def __len__(self): > return self.n > > def __getitem__(self, i): > if not (0<=i raise IndexError > try: > return self.s[i] > except IndexError: > return None > > cmd, host, something, something_else = PaddedSeq(sys.argv, 4) Actually, I think this is more complex than needed for the purpose at hand (it may come in handy for some other uses, of course). I would do it, not with a powerful, flexible class, but rather with a tiny, little, extremely-simple function: def padSequence(seq, length): return (tuple(seq)+(None,)*length)[:length] Unfortunately, tuples and lists cannot be concatenated, which is why we need to cast the sequence into a definite form here -- choosing list would of course work just as well: def padSequence(seq, length): return (list(seq)+[None]*length)[:length] or, one could, I guess, typeswitch, but that would (IMHO) be an unwarranted increase in complexity. Only if measurements should show that 'extra/avoidable work' performed in this function is a bottleneck for the application, would I think it worthy to add complications for performance reasons; in most cases, "we ain't gonna need it", and (IMHO) providing a solution that is as simple as we can get away with is a good general strategy. Anyway, the use would now still be: cmd, host, something, something_else = padSequence(sys.argv, 4) no matter how padSequence is internally implemented. Alex From donn at u.washington.edu Tue Jan 9 14:21:21 2001 From: donn at u.washington.edu (Donn Cave) Date: 9 Jan 2001 19:21:21 GMT Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: <93fobh$rqs$1@nntp6.u.washington.edu> I have never used mxDateTime, so I have 0 cents on that, but I have used mxTextTools. I found it to be efficient and powerful, and ought to be useful in a significant number of applications and modules that have text to parse -- if it were already available with the distribution. Donn Cave, donn at u.washingotn.edu From victor at prodigy.net Wed Jan 17 09:54:52 2001 From: victor at prodigy.net (Victor Muslin) Date: Wed, 17 Jan 2001 14:54:52 GMT Subject: How to call a stored procedure? References: <3a64c959.600874890@localhost> Message-ID: <3a65aff6.659911453@localhost> Thanks to everyone for your help. For those who may come across the same problem the answer for Oracle via ODBC is: cur.execute("{call delete_server(1)}") Apparently had to use "call" instead of "execute" and had to use { } around the statement! On Tue, 16 Jan 2001 22:31:06 GMT, victor at prodigy.net (Victor Muslin) wrote: >I am using Python 1.5.2 on WindowsNT. > >I have a stored procedure defined in Oracle: > >CREATE OR REPLACE PROCEDURE DELETE_SERVER >( > SERVER_ID_ARG IN NUMBER >) >AS >BEGIN > DELETE FROM SERVER WHERE SERVER_ID = SERVER_ID_ARG; >COMMIT; >END DELETE_SERVER; >/ > >Calling it from SQLPLUS works file: > > SQL> execute delete_server(1); > >However when I try calling it from Python it gives me an error. Here's >the Python program: > >import dbi, odbc >import sys >cs = 'db/user/password' > >dbconn = odbc.odbc(cs) >cur = dbconn.cursor() >cur.execute("execute vmuslin.delete_adserver(3)"); > > >The error I get is: > >Traceback (innermost last): > File "E:\dev\dclk\eng\src\apps\ADMIN_~1\xx.py", line 7, in ? > cur.execute("execute vmuslin.delete_adserver(3)"); >dbi.program-error: [Microsoft][ODBC driver for >Oracle][Oracle]ORA-00900: invalid SQL statement in EXEC > >Is it not possible to call stored procedures from Python? From fredrik at effbot.org Fri Jan 26 12:11:53 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 26 Jan 2001 17:11:53 GMT Subject: The fundamentals... References: <94sa4a$vo8$1@nnrp1.deja.com> Message-ID: "mspiggie at my-deja.com" wrote: > I have been trying to find a way to use replace() to perform more than > one replacement within a given file. For instance, suppose I needed to > replace ". " with "\n", but also need to replace "!" with "exclamation" > and "?" with "question". I have tried several approaches to this, but > none of my neophyte ideas have produced satisfying results. here's one way to do it: http://www.deja.com/=dnc/getdoc.xp?AN=672888429 import re, string class MultiReplace: def __init__(self, repl_dict): # "compile" replacement dictionary # assume char to char mapping charmap = map(chr, range(256)) for k, v in repl_dict.items(): if len(k) != 1 or len(v) != 1: self.charmap = None break # cannot use translate charmap[ord(k)] = v else: self.charmap = string.join(charmap, "") return # string to string mapping; use a regular expression keys = repl_dict.keys() keys.sort() # lexical order pattern = string.join(map(re.escape, keys), "|") self.pattern = re.compile(pattern) self.dict = repl_dict def replace(self, str): # apply replacement dictionary to string if self.charmap: return string.translate(str, self.charmap) def repl(match, get=self.dict.get): item = match.group(0) return get(item, item) return self.pattern.sub(repl, str) r = MultiReplace({"spam": "eggs", "spam": "eggs"}) print r.replace("spam&eggs") r = MultiReplace({"a": "b", "b": "a"}) print r.replace("keaba") r = MultiReplace({". ": "\n", "!": "exclamation", "?": "question"}) print repr(r.replace("look. an albatross !")) Cheers /F From fredrik at effbot.org Fri Jan 5 11:02:53 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 05 Jan 2001 16:02:53 GMT Subject: How to DECREF an Python object to return? References: <934qg0$l07$1@news1.kornet.net> Message-ID: Jae-wook Ahn wrote: > 5. return the tuple object ( return PyBuildValue("O", tuple) ) > > Because I want the tuple get returned, I can't free it before returning it, > but after I return it, the function I created finishes. How can I get the > tuple back and free the memory? in this case, you can simply return the tuple: return tuple; ::: In the general case, you can store the return value in a temporary variable: PyObject* result; ... result = PyBuildValue("OO", tuple, othertuple); Py_DECREF(tuple); Py_DECREF(othertuple); return result; Hope this helps! From ben.hutchings at roundpoint.com Thu Jan 25 18:22:29 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 25 Jan 2001 15:22:29 -0800 Subject: CreateProcess and .py file References: <980270342.658021@osiris.esoterica.pt> Message-ID: "Jos? Rui Faustino de Sousa" writes: > Hi! > > Does anyone have any idea how to "convince" CreateProcess to create a > process out of a python script file (or any non .exe "executable" for > that matter...)? This is a Windows-specific question that does not belong in comp.lang.c (and maybe not even comp.lang.python). The answer is that if you want to use the shell's file associations you should use ShellExecute or ShellExecuteEx. CreateProcess is a low-level function; file associations are high-level. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From dubois at users.sourceforge.net Mon Jan 8 19:38:29 2001 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Tue, 09 Jan 2001 00:38:29 GMT Subject: CXX/Array.h's Py::Array samples or documentation? References: Message-ID: <94t66.101552$A06.3538385@news1.frmt1.sfba.home.com> The problem is that Numeric arrays do not have the equivalent of "append". There is a function concatenate and you may find it easiest just to use the C API of Python to execute this routine and capture the result. Array is not documented because it is just there as an example, not a completed work. A frightening number of people have found it useful so it would be nice if someone fleshed it out some. Numeric's documentation is at numpy.sourceforge.net. "Phlip" wrote in message news:XHs66.282$ip2.91379 at news.pacbell.net... > Pythonesqueise: > > I want to pass a NumPy multiarray into a C++ function (incidentally > bound by SWIG), and wrap it with the CXX module's Py::Array class. > > Then I want to increase the volume of this multiarray, fill it full of > data, and pass it back up. Client code in Pythonland will then ufunc the > data and do other terrible things to it. > > I can't figure out how to extend the array. It does not seem to have a > "push" feature. > > So I think I can allocate a new array of the correct dimensions; pack it, > and assign it into the target array. But the example code for Py::Array > only shows how to create it with one dimension. > > E-searching for "cxx" and "array" returns many, many interesting pages that > will distract me learning new things about completely unrelated projects. > The CXX documentation was wrought before Array.h was added. > > Is there any example code or documentation I'm missing for Py::Array? Or > multiarray? > > -- > Phlip > http://c2.com/cgi/wiki?PhlIp From claird at starbase.neosoft.com Wed Jan 24 16:46:13 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 24 Jan 2001 15:46:13 -0600 Subject: what GUI, please advise References: <3A6F18F2.536F27FE@crepido.com> <3A6F0B27.A88D11C9@crepido.com> <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7@lp.airnews.net> Message-ID: <7DA74694B63ED42A.83CB11913E3910C5.C8BE5B392AC1AC5C@lp.airnews.net> In article , Moshe Zadka wrote: >On Wed, 24 Jan 2001, Marco =?iso-8859-1?Q?Seiri=F6?= wrote: >> Well, something like this... >> >> - I'm going to run mostly on Unix, although it would be nice >> to be able to recycle my GUI knowledge when forced to >> write for Windows. Mac, not very important... >> >> - A GUI builder is a very big advantage. allmost a must. >> >> - I like there to be all the widgets one would expect from >> the Windows world. >> >> - Easy of use for the programmer. > >Check out wxPython and Tkinter. I think Boa-Constructor is a gui >builder for wxWindows, but you might have more trouble building >it on exotic platforms. . . . My first thought was that PyQt, with Qt Designer, seems like a natural. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sholden at holdenweb.com Wed Jan 31 19:18:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 31 Jan 2001 19:18:59 -0500 Subject: redirecting output References: <3A789343.48002B2C@ic.sunysb.edu> Message-ID: "Jp Calderone" wrote in message news:3A789343.48002B2C at ic.sunysb.edu... > > > I've attached the python interpreter to a server, > essentially letting people connect to the given address > and port and pump stuff into it. What I can't figure out > is how I might go about redirecting the output from some > of the builtin functions - dir(), print, etc, to their > socket. Is this possible? > Interesting idea, with some interesting security aspects! The dir() function doesn't do any output: it just produces a list. "print", of course, isn't a statement... but you should be able to redirect its output by binding sys.stdout to the socket for the duration of the session. > Thanks in advance, > Jp > regards Steve From greg at cosc.canterbury.ac.nz Tue Jan 23 17:55:04 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 24 Jan 2001 11:55:04 +1300 Subject: Control codes (Re: Replacing control characters.) References: <94ifec$ggt$1@nnrp1.deja.com> Message-ID: <3A6E0BC8.7260CFA8@cosc.canterbury.ac.nz> Erno Kuusela wrote: > > C-M would be '\x0d'. you can look at the ascii(7) manual page A useful thing to know is that ^A is chr(1). So if you know the letter you can just count up from there, e.g. M is the 13th letter of the alphabet, so ^M is chr(13). -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From max at alcyone.com Fri Jan 19 00:29:21 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 18 Jan 2001 21:29:21 -0800 Subject: Interesting "gotme" References: Message-ID: <3A67D0B1.EB83C0A9@alcyone.com> Andrew Henshaw wrote: > I had a list that I wanted to sort, except that I wanted the 0th > element to > stay put. So I smugly coded: > > a[1:].sort() > > and went on my merry way. Later, I tracked down a bug to the fact > that I > really had not sorted a[1:]. Of course, I had sorted a copy of a[1:], > which > was immediately discarded. Yep. List slices make copies. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Youth is a period of missed opportunities. \__/ Cyril Connolly REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From NOSPAM at pacificnet.net Thu Jan 18 22:56:11 2001 From: NOSPAM at pacificnet.net (Ian L) Date: Fri, 19 Jan 2001 03:56:11 GMT Subject: generating simple graphs and chart images in python References: <94890m$9th$1@news.inet.co.th> Message-ID: Thanks, I actually found that site wandering around my own, but i havent had a chance to try it out yet. thanks for the help "Prateep Siamwalla" wrote in message news:94890m$9th$1 at news.inet.co.th... > could this be what you are looking for? > > http://athani.pair.com/msteed/software/gdchart/ > > > -teep > > Ian L wrote in message > news:aVK96.3220$tD2.216083 at newsread1.prod.itd.earthlink.net... > > Hey, > > > > Could anyone point me in the right direction as to how i can generate some > > simple graphs dynamically in python? I want to make something like a bar > > graph, or line graph? > > > > > > From tim.one at home.com Mon Jan 29 18:23:59 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 29 Jan 2001 18:23:59 -0500 Subject: "in" for dicts (was: Python 2.1 function attributes) In-Reply-To: <954f49$b3k$1@news.udel.edu> Message-ID: [Terry Reedy] > Comparers of Perl and Python constantly notice that Perl is (was?) faster > in its equivalent of the new 'for l in f.xreadlines()'. is/was varies by platform. In general, though, Python's line-at-a-time file input is threadsafe while Perl's isn't, and we still pay something for that; we also haven't pulled the platform-dependent tricks Perl does to optimize char-at-a-time reading the way vendors *should* optimize fgets() but almost never do (Tru64 Unix appears to be the sole probable exception to date). So expect Perl to remain significantly faster for this on most boxes, but no longer factors of 5-40 times faster. > My first thought was 'hope this is enough faster to quiet some of > the noise. > > Python won't be the first system to optimize a common 'benchmark'. I couldn't care less about this in a benchmark context. Real-life file-munging applications generally aren't rocket science, and I/O time is often the dominant part. So it was real programs running scads slower that I was concerned about -- speeding a very common operation isn't just marketing fluff. if-we-cared-about-benchmarks-we'd-make-fibonacci-a-builtin-ly y'rs - tim From bragib at my-deja.com Thu Jan 4 13:24:25 2001 From: bragib at my-deja.com (bragib at my-deja.com) Date: Thu, 04 Jan 2001 18:24:25 GMT Subject: Setting environment for current shell Message-ID: <932f4d$n0r$1@nnrp1.deja.com> How do you set an environment for the shell you are running python in. os.system() spawns its own shell. I would like to gain access to the parent shell. Is there a module for that? Bragi Sent via Deja.com http://www.deja.com/ From andreas at andreas-jung.com Mon Jan 15 05:13:19 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Mon, 15 Jan 2001 11:13:19 +0100 Subject: pmz variable in html In-Reply-To: <93u9k7$ris$1@nnrp1.deja.com>; from tam_dominic@my-deja.com on Mon, Jan 15, 2001 at 07:41:59AM +0000 References: <93u9k7$ris$1@nnrp1.deja.com> Message-ID: <20010115111319.A2411@yetix.sz-sb.de> I will check the problem. Please report bugs directly to me or use the mailing lists for PMZ (see http://sourceforge.net/projects/pmz/) Andreas From ljohnson at resgen.com Mon Jan 8 10:50:46 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Mon, 8 Jan 2001 09:50:46 -0600 Subject: trying to create python wrapper for cdk using swig References: <93cec4$ep8$1@nnrp1.deja.com> Message-ID: > Then we compile thus: > gcc -fPIC -g -O2 -I/usr/include/python1.5 -I/usr/local/include - > DHAVE_CONFIG_H -c ./label_wrap.c > gcc -shared label_wrap.o -o labelcmodule.so > These also do not produce any errors. > > Then we test our wrapper by importing label into python. This produces > the following error: > ImportError: ./labelcmodule.so: undefined symbol: CDKDEBUG Dubal, I'm not familiar with CDK itself, I think you probably need to modify the link line shown above so that it links the CDK library into your Python extension module, e.g. gcc -shared label_wrap.o -o labelcmodule.so -L/usr/local/lib -lCDK The last argument (-lCDK) may need to be modified depending on the library's name; here I'm assuming it's "libCDK.a" or "libCDK.so". If CDK itself depends on *other* libraries you may also have to add those to the end of the link line -- but start out with what I've shown here. Hope this helps, Lyle From mertz at gnosis.cx Tue Jan 23 23:01:55 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Tue, 23 Jan 2001 23:01:55 -0500 Subject: Complete list of Python IDEs (fwd) Message-ID: ahopkins at dynacare.com (Albert Hopkins) wrote | I was able to quickly compile a list at | http://starship.python.net/~marduk/pythonide.html This is a nice list that Albert Hopkins was kind enough to compile. I will be publishing some articles reviewing a number of these, to appear on webreview.com and in my _Charming Python_ column at ibm.com/developer (as a roundup). It will be a little while until such articles actually appear though. In the meanwhile, Albert might want to add a few others to the list. I have not had the opportunity to use all of these yet, but hopefully I will. Black Adder - http://thekompany.com/products/blackadder/ (terribly unreliable web server) - Supposedly for Win32 and Linux PythonWin - http://activestate.com/Products/ActivePython/ - For Win32 - Maybe Komodo is intended to supercede this, since it is from the same place... but PythonWin is worth checking out in itself. PythonWorks Pro - http://www.pythonware.com/products/works/index.htm - Win32, Linux, Solaris - Commercial (for lots of money), so it needs to be a lot better than free stuff (I haven't evaluated whether it is yet). Also a note. I love FTE, but it does not have a Python mode in the current source distribution. To get that, you need to go to http://www.vex.net/~x/python_stuff.html#fte to download the mode configuration. And you'll need to recompile the configuration to take advantage of this (I also recommend changing a couple other files to get the python mode into some menus... if anyone requests it, I can make my changed configuration files, and slightly different Python mode file, available). Well, I suppose one more thing. I can probably name at least a dozen other general purpose editors that have a certain amount of Python support. It might make sense to separate the general editors from the python-specific IDEs. Just my opinion though; it is up to Albert to decide what he thinks is best. Yours, David... From s2mdalle at titan.vcu.edu Fri Jan 12 16:22:43 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Fri, 12 Jan 2001 21:22:43 GMT Subject: A small suggestion for Python References: <3A5F27F7.30268D9A@erols.com> <93nf0g$amfvv$1@ID-11957.news.dfncis.de> Message-ID: In article <93nf0g$amfvv$1 at ID-11957.news.dfncis.de>, "Emile van Sebille" wrote: > If such a thing were to be added, might it also be good to raise an > exception when not assigning the return value? If so, perhaps a nothing > would not object to being a sink hole (ala /dev/null). I don't know. It would annoy the hell out of me if I had to put map() calls that I wasn't using the result of in a try block. Say you have a function called "send_file" that sends a file to some host. And you have an array of files. It's easy to say map(send_file, myfiles) and be done with it. I don't think that should raise an Exception, do you? The behavior that the function returns something is explicit, but that it returns something, and forcing you to do something about the fact that it returns something are totally different things. -- David Allen http://opop.nols.com/ ---------------------------------------- Majority, n.: That quality that distinguishes a crime from a law From aleaxit at yahoo.com Sat Jan 6 13:51:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 6 Jan 2001 19:51:35 +0100 Subject: 2001 Enchancement Wishlist References: <3A4CEACB.220998A0@javanet.com> <92j83r13gh@news1.newsguy.com> <20001231175940.A5435@xs4all.nl> <008301c07501$c036ae40$43931497@martelli> <20010104165116.F2467@xs4all.nl> <008601c07675$0adf2020$102b2bc1@cadlab.it> <20010104203232.P402@xs4all.nl> <006801c0769b$ac0cc3a0$9d8a1a97@martelli> <20010105110459.Q402@xs4all.nl> <937l3u$gbi$1@slb2.atl.mindspring.net> Message-ID: <937pl001peq@news1.newsguy.com> "Andrew Dalke" wrote in message news:937l3u$gbi$1 at slb2.atl.mindspring.net... [snip] > proxy = Proxy(...) > sys.modules[module_name] = proxy > > In other words, what you import doesn't need to be a module. > It can be a class instance instead - or any other data type. Now THAT is interesting! I would never have guessed that the items in sys.modules need not be module objects. Is this documented, something I can rely on forevermore and just happened not to notice in my study, or just an accident of the current implementation which might go away anytime? > This makes it possible to emulate the module __getattr__ > behaviour without changing the definition of a module. Definitely. If a module can overrite its own entry in sys.modules with any other object-type, and this is 'solid' (documented, and going to stay), then there is no particular need for any changes to module-objects; it's not a _frequent_ occurrence for a module to want to "take deep control of its own fate" (__setattr__ and friends), so, when the requirement does arise, satisfying it with the "overwrite sys.modules entry" hack seems OK to me. Neat...! Alex From slhath at home.com Sat Jan 20 08:34:15 2001 From: slhath at home.com (Scott Hathaway) Date: Sat, 20 Jan 2001 13:34:15 GMT Subject: pyXML support for XSL tranformations?? Message-ID: Using the Microsoft tools, you can load an XML document, then load and XSL or XSLT document into memory and then call nodeTransform to blend the two together and then spit it back out. Is there a way to do this with pyXML or any other python xml library? Scott From fpm at u.washington.edu Tue Jan 16 10:59:21 2001 From: fpm at u.washington.edu (Frank Miles) Date: 16 Jan 2001 15:59:21 GMT Subject: Newbie question: python debugger ? Message-ID: <941r4p$urs$1@nntp6.u.washington.edu> I've about accepted that I can't use ddd to debug python scripts. The version that debian(linux) [0.4] has doesn't set breakpoints. And now I find that I can't seem to read the values of class variables of the form self.var_name. Does 0.5 fix the self.var_name problem? Are there other/better alternatives to debugging Python scripts? TIA.... -frank -- From othello at javanet.com Tue Jan 23 14:37:36 2001 From: othello at javanet.com (Raymond Hettinger) Date: Tue, 23 Jan 2001 14:37:36 -0500 Subject: Markov.py References: <94eavq$5cl$1@nnrp1.deja.com> Message-ID: <3A6DDD80.6DA38FB8@javanet.com> cpsoct at my-deja.com wrote: > I found the following script in the mac standard distribution (see path > below). It seems to be Guido's, i am not sure however, i am at a loss > as to how to use this. I was unable to run it and there is not > documentation. In otherwords, i put on my detective hat but was still > unable to get the thing to run. Anyone use this and can explain to me > how? The script is a bit to big and complex for my level of python kno- > how, but how sweet would it be to be able to make a markov chain in > python without having to re-invent the wheel. Particularly since i > wouldn't be able to in this case! In chapter 3 of their book, The Practice of Programming, Brian Kernighan and Rob Pike compared six versions of the Markov program written with different languages or language features. They compared speed, lines of source, and style. Markov.py gives comparative results for Python. The book includes a program spec, algorithm analysis, sample inputs and outputs, and some testing ideas. G'luck, Raymond Hettinger othello at javanet.com From aweis at gmx.de Thu Jan 18 14:10:07 2001 From: aweis at gmx.de (Arnold Weis) Date: Thu, 18 Jan 2001 19:10:07 GMT Subject: help retrieving / storing info in dictionary or gadfly References: Message-ID: <3a673ed8.33748467@News.CIS.DFN.DE> "Tim Peters" wrote: >Come now: 2^128 is only 130 . All right, if he meant 2**128, I >agree. > >speaking-python-in-pythonland-ly y'rs - tim > He certainly meant 2L**128. and watching for OverflowErrors-ly y'rs - arnold :-)) From sandj.williams at gte.net Thu Jan 11 11:43:32 2001 From: sandj.williams at gte.net (Steve Williams) Date: Thu, 11 Jan 2001 16:43:32 GMT Subject: ActivePython2.0 - Server Side objects for ASP problem References: <3A5DD081.F37275A@gte.net> <93klt8$qon$1@plutonium.compulink.co.uk> Message-ID: <3A5DE403.33E323A@gte.net> gbreed at cix.compulink.co.uk wrote: > In article <3A5DD081.F37275A at gte.net>, sandj.williams at gte.net (Steve > Williams) wrote: > > [snip] > > Dude! The subject line says "Server Side objects". ASP can indeed call > server side objects. The client doesn't have to know anything about them. > > The following may well be problems, but I've not had much trouble with > Python COM servers. Now DCOM, that's a different kettle of ball games ... > [snip] Arrgh! COM, COM, COM. Yes, of course. There is no problem. Please return to your cubicles. From phawkins at spamnotconnact.com Mon Jan 22 14:54:38 2001 From: phawkins at spamnotconnact.com (Patricia Hawkins) Date: 22 Jan 2001 14:54:38 -0500 Subject: how to test for nesting inlist References: <94bhte$4iv$1@nnrp1.deja.com> <94bvgu0kt4@news2.newsguy.com> <94ea6k$4uc$1@nnrp1.deja.com> <94h7pi$b86$1@nnrp1.deja.com> <94hau902rvd@news1.newsguy.com> Message-ID: >>>>> "AM" == Alex Martelli writes: AM> wrote in message news:94h7pi$b86$1 at nnrp1.deja.com... >> What are list comprehensions? I have looked and looked and looked in >> books and on www.python.org and i see no mention of these. Is this AM> A list comprehension is a syntax form such as: AM> [ for in ] Like this: def howDeep2(x): if type(x) != type([]): return 0 return 1 + reduce(max, [howDeep(y) for y in x]) -- Patricia J. Hawkins Hawkins Internet Applications, LLC From Daniel.Kinnaer at AdValvas.be Wed Jan 3 04:02:45 2001 From: Daniel.Kinnaer at AdValvas.be (Daniel) Date: Wed, 03 Jan 2001 09:02:45 GMT Subject: Electronic edition of 'The Standard Python Library' References: <4f746.2529$AH6.401534@newsc.telia.net> <3A517247.1B79FFC2@ieeeSPAMnot.org> Message-ID: <3a52e946.1849682@news.skynet.be> On Tue, 02 Jan 2001 06:21:18 GMT, "John D. Gorman" wrote: > I just tried my copy today (2 Jan) and it works fine . The Fatbrain >registration process does deposit a key in the registry at >HKEY_CURRENT_USER->Software->Fatbrain->ematter->EB00002582. In there is a 161 >byte key labeled "PDF 1.1" that contains binary data. > I bought my book on 27/12/2000 and I don't find anything in the registry, thuogh. Along with the .PDF I received a file with the extension .RMF. It is an document which contains the license key and so on, and acts as a plug-in for Acrobat Reader 4.05c. I've been searching for the zipped examples as well, but can not find them. I e-mailed /F about this, but I'm sure he's on a pretty tight time schedule. I wouldn't mind receiving them, though. best regards, Daniel From katz at Glue.umd.edu Wed Jan 31 22:46:41 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Wed, 31 Jan 2001 22:46:41 -0500 Subject: function attributes are like function objects In-Reply-To: <95acpj$sbe$1@tyfon.itea.ntnu.no> References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> <95acpj$sbe$1@tyfon.itea.ntnu.no> Message-ID: Oh, good, perhaps a calll for a Py3k suggestion? idea: Perhaps replace def/class with a general 'def' which would allow the definition of - a standard class - a function - an instance method - a class method - a singleton class all through a single, consistent syntax. lists, strings, dicts, ints and other types would be subclass-able. This would solve the following current problems: - Python lacks class methods - Current Python has no support for subclassing from primitive types. I really would like that -- provided it is consistent and not occam's-razor syntax extension. I had an idea where one could write def f(x): pass def C: def f(self): pass def g(): pass # where some new syntax indicates that g is static print 'hi' # C is like a function and a class in one. and you could call f(3), C.g(), C() to call C as a function.. that'd fill those requirements... sort of. On the other hand, maybe there needs to be a distinct separation between class and function; I think right now that function attributes are a waste when the functions can use (1) global values, (2) 'call-by-reference' (er, mutable, right?) object parameters in which to hold values, or (3) be implemented as function objects, with all being viable alternatives. (1) state = 123 def f(): return state (2) class stateHolder: state = 0 def __init__(self, state): self.state = state state = stateHolder( 123 ) def f( s ) # s is a stateHolder return s.state (3) class func: state = 123 def f(self): return self.state ------- there. I prefer (3), (I'm CS-oriented :)) Roey On Thu, 1 Feb 2001, Magnus Lie Hetland wrote: > "Greg Ewing" wrote in message > news:3A78AE8D.C9D25694 at cosc.canterbury.ac.nz... > > Sean Reifschneider wrote: > > > > > > It didn't really > > > seem like they were missing so much as it seemed like they would act > > > more like everything else now... > > > > Everything? What about lists, dicts, tuples, file > > objects...? > > > > What's so special about functions that we need to > > be able to plonk arbitrary attributes on them, but > > not any other builtin types? > > Now *that* would be nice (if we could do that, I mean). > Everything as objects... SmallTalk lurking in the > background. Sounds good to me... > > -- > > Magnus Lie Hetland (magnus at hetland dot org) > > "Reality is what refuses to disappear when you stop > believing in it" -- Philip K. Dick > > > > From aleaxit at yahoo.com Thu Jan 18 03:52:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 09:52:46 +0100 Subject: SQL-Statement with Python References: <3A62E224.7AEE805E@students.uni-linz.ac.at> <93ut4q031hd@news1.newsguy.com> <28uc6ts3fn93pon3tahrvbqb26bc4of9hq@4ax.com> Message-ID: <946cod230tl@news2.newsguy.com> "Tim Roberts" wrote in message news:28uc6ts3fn93pon3tahrvbqb26bc4of9hq at 4ax.com... > "Alex Martelli" wrote: > > > >import win32com.client > > > >connection = win32com.client.Dispatch("AdoDb.Connection") > >connection.Provider = "Microsoft.Jet.OLEDB.4.0" > >filename = r'd:\\mssdk\\bin\\nwind.mdb' > > Thank you for providing this simple and understandable ADODB example. I do > have one nit in that last line. I think you want EITHER the "r" prefix, OR > the double backslashes. Including both is just too much of a good thing... Oops -- you're perfectly right! Funny thing is that the code as I posted it *DOES* work -- dunno who's removing the extra backslashes, or why they don't hurt things. Note that this is *NOT* a case where forward slashes can be used instead of backward ones! Changing the filename assignment to: filename = 'd:/mssdk/bin/wind.mdb' results in an exception on connection.Open: pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft JET Da tabase Engine', "Could not find file 'd:\\mssdk\\bin\\wind.mdb'.", None, 5003024 , -2147467259), None) yep, the exeption message DOES have backslashes again, and: D:\Python20>dir d:\mssdk\bin\*.mdb Volume in drive D has no label. Volume Serial Number is 0498-B4C2 Directory of d:\mssdk\bin 02/02/00 10:17p 1,558,528 nwind.Mdb 1 File(s) 1,558,528 bytes 146,759,680 bytes free Using: filename = 'd:\\mssdk\\bin\\nwind.mdb' or: filename = r'd:\mssdk\bin\nwind.mdb' works fine and seems more sensible. Alex From Jason.Tishler at dothill.com Thu Jan 25 22:40:00 2001 From: Jason.Tishler at dothill.com (Jason Tishler) Date: Thu, 25 Jan 2001 22:40:00 -0500 Subject: CHECK_IMPORT_CASE In-Reply-To: ; from sdm7g@Virginia.EDU on Thu, Jan 25, 2001 at 09:15:20PM -0500 References: Message-ID: <20010125224000.F1148@dothill.com> Steve, On Thu, Jan 25, 2001 at 09:15:20PM -0500, Steven D. Majewski wrote: > While looking for a way to solve the macosx case insensitivity import > problem, I found in Python/import.c: > > #ifdef CHECK_IMPORT_CASE > static int check_case(char *, int, int, char *); > #endif > > However, neither I nor the linker could find the implementation > of check_case. The three different check_case() implementations (win32, mac, and djgpp) are right there in Python/import.c too. > Is this a work in progress ? Does someone have a planned solution? Although the following is somewhat Cygwin specific, you may find some of the information useful: http://sourceforge.net/patch/?func=detailpatch&patch_id=103154&group_id=5470 Jason -- Jason Tishler Director, Software Engineering Phone: +1 (732) 264-8770 x235 Dot Hill Systems Corp. Fax: +1 (732) 264-8798 82 Bethany Road, Suite 7 Email: Jason.Tishler at dothill.com Hazlet, NJ 07730 USA WWW: http://www.dothill.com From keisari_ at hotmail.com Tue Jan 9 11:37:05 2001 From: keisari_ at hotmail.com (Joonas) Date: Tue, 09 Jan 2001 18:37:05 +0200 Subject: Weird ftplib problem Message-ID: <3A5B3E31.EC9FE6A6@hotmail.com> I am using ftplib to transfer a file into a server. When I run it in IDLE it works fine but when I run it from command line by typing 'python ftp.py' it gives the following error message. Traceback (innermost last): File "ftp.py" line 2, in ? siirto = FTP('ftp.saunalahti.fi') File ".\lib\ftplib.py", line 87, in __init__ self.connect(host) File ".\lib\ftplib.py", line 98, in connect self.file = self.sock.makefile('r') _socket.error: No makefile() function has been installed ###########ftp.py############## from ftplib import FTP siirto = FTP('ftp.saunalahti.fi') siirto.set_debuglevel(1) siirto.login("******","******") siirto.cwd('public_html') siirto.storbinary('STOR pic.gif' , open('pic.gif','rb') ,1024) siirto.quit() print "it works" ############################## What could be wrong? Joonas. From sdm7g at virginia.edu Tue Jan 23 17:57:48 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 23 Jan 2001 17:57:48 -0500 (EST) Subject: Darwin1.2 [was: I mean *setup.py* ! ... ] In-Reply-To: Message-ID: With this line: Darwin/*) LINKFORSHARED="-u __dummy -framework System -framework Foundation" ;; in Python2.1a1, the ObjC extensions build and work without any patching of the Python distribution on MacOSX using: ./configure --with-framework --with-dyld --with-objc --with-suffix=.x However, as both MacOSX public beta and the public source Darwin version report themselves as "Darwin1.2" , I suspect that this is going to break the vanilla Darwin build, as it doesn't come with the Foundation framework. I can't test that case, and I'm not sure what the solution should be, but I wanted to post a notice just in case someone was trying to build on the public source Darwin distribution and ran into that problem. ( I'm not sure whether any of the above switches are a reliable indicator of what should happen, given --with-objc could also mean linking with OpenStep or GnuStep. ) -- Steve Majewski From abramsjc at my-deja.com Mon Jan 15 12:11:16 2001 From: abramsjc at my-deja.com (abramsjc at my-deja.com) Date: Mon, 15 Jan 2001 17:11:16 GMT Subject: ASP + SQL Server + Time object problem References: <93np4p$lm$1@nnrp1.deja.com> <93p88d013hg@news1.newsguy.com> Message-ID: <93vavc$ml0$1@nnrp1.deja.com> Hi again, thanks for the responses. Here's what I came across. I should have specified that I import a module and within a class in that module is where the problem was being experienced. I read the docs by that genuis guy Mark, but trying to use the PyTime objects gave me errors about no __float__ attribute and other errors when trying different methods. > To return a string formatted as the long date in control panel > time.strftime("%#c", time.localtime(int(timeObject))) See that int() conversion, that fails. What I found out that it was because the code lied in the module. If I return the time object to the top-level ASP script, the int conversion works, PyTime objects work, it all works. But inside that imported module nothing worked. Pretty weird. Anyone know why? In article <93p88d013hg at news1.newsguy.com>, "Alex Martelli" wrote: > "Tim Hammerquist" wrote in message > news:slrn95vghv.aqj.tim at degree.ath.cx... > [snip] > > Anyone in the newsgroup familiar with the object model of a "time > > object"? > > Hammond's docs included with win32all document it this way: > > PyTime Object > A Python object, representing an instant in time. > > Comments > A PyTime object is used primarily when exchanging date/time information with > other COM objects. > Using int(timeObject) will return an integer compatible with the time > module. > > Example > To return a simple string > time.ctime(int(timeObject)) > > To return a string formatted as the long date in control panel > time.strftime("%#c", time.localtime(int(timeObject))) > > See Also > pywintypes::Time > > Methods > Format > Formats the time value > __int__ > Used when an integer representation of the time object is required. > __float__ > Used when a floating point representation of the time object is required. > __print__ > Used when the time object is printed. tp_print > __cmp__ > Used when time objects are compared. tp_compare > __hash__ > Used when the hash value of an time object is required tp_hash > > Seems pretty good to me -- what's missing? > > Alex > > Sent via Deja.com http://www.deja.com/ From thomas at xs4all.net Tue Jan 2 11:19:39 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 2 Jan 2001 17:19:39 +0100 Subject: why no "do : until"? In-Reply-To: ; from grey@despair.rpglink.com on Sun, Dec 31, 2000 at 08:10:11AM -0000 References: <92jj3j$ff7$1@nnrp1.deja.com> Message-ID: <20010102171939.A2467@xs4all.nl> On Sun, Dec 31, 2000 at 08:10:11AM -0000, Steve Lamb wrote: > Whatever. *plonk* No, no. You are supposed to say 'bah' and dismiss the subject with a wave of your paw -- and you should change your name to Dogbert first. Quick-mention-math!-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From echapin at sympatico.ca Mon Jan 15 18:10:17 2001 From: echapin at sympatico.ca (Elliott Chapin) Date: Mon, 15 Jan 2001 23:10:17 GMT Subject: names References: <93umod02iem@news1.newsguy.com> Message-ID: Thanks, all! I may approach the actual task I have in mind by designing a class which adds a name to the attributes of its instances. -- --------------------------------------------------------------- Elliott Chapin www3.sympatico.ca/echapin "Alex Martelli" wrote in message news:93umod02iem at news1.newsguy.com... > "Andrew H. Chatham" wrote in message > news:slrn964p3g.2f5.andrew.spambgone.chatham at fizgig.dorm.duke.edu... > > On Mon, 15 Jan 2001 01:26:45 GMT, Elliott Chapin > wrote: > > >How can I get the name of an object as a string? As a biginner I might > > >imagine something like > > > > > >>>>b=[[1],[2]] > > >>>>name(b) > > >'b' > > > > You can't. The object doesn't know what it's name is, because the name > > corresponds to the reference to the object, not the actual object. It's > > sometimes tough to realize that variables don't store objects, they store > > references to objects. > > Right! The only way I see to accomplish Elliott's request is to look > through all variables and return the set of those whose references > are identical to the one being asked for. To do that in a function, > while looking through the *caller*'s namespace, requires accessing > the stack, which is done by raising and catching an exception; once > that is done, the f_locals and f_globals attributes of the caller's > frame object provide such access. > > All in all, something like: > > import sys > def name(value): > try: raise 'foo' > except 'foo': > caller_frame = sys.exc_info()[2].tb_frame.f_back > names = [] > caller_locals = caller_frame.f_locals > for vname, vval in caller_locals.items(): > if vval is value: names.append(vname) > for vname, vval in caller_frame.f_globals.items(): > if vval is value and not caller_locals.has_key(vname): > names.append(vname) > return names > > The name is somewhat misleading, since this function will not return > a string -- rather, a list of strings which are variable names (directly > accessible to the function's caller) naming the given value (it tries > to check for _identity_ of value, with 'is', rather than _equality_ > as '==' would do; this is not fully reliable for immutable values, as > it's up to the system whether to have the same identities for equal > objects in that case). It tries to take into account the scoping effect: > it will not return a global variable name which, from the point of view > of the caller, is 'shadowed' by a local-variable homonym. > > > >>>b = [[1],[2]] > > >>>c = b > > > > c and b refer to the same list. If I then tried to hypothetical "name" > > function, the list would have no idea whether to say 'c' or 'b'. > > Which is why my non-hypothetical proposed version, above, returns a > list with both names:-). > > > It's hard to see what such a 'name' function would be good for; maybe > a quick-and-dirty detector for multiply-referenced values in interactive > experimental development (one would then only care about mutable values, > so the indeterminacy affecting immutable ones would not matter). In > point of fact, I think it's worth little except as a nice show-off for > Python's abilities of introspection/reflection...:-). > > > Alex > > > From mjackson at wc.eso.mc.xerox.com Sat Jan 20 13:20:46 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 20 Jan 2001 18:20:46 GMT Subject: PSU uses emacs? References: Message-ID: <94cktu$d9c$1@news.wrc.xerox.com> "Steve Holden" writes: > "D-Man" wrote in message > news:mailman.979929746.2047.python-list at python.org... > > On Fri, Jan 19, 2001 at 05:55:45PM +0100, Alex Martelli wrote: > > | > [ ... ] > > | (shame's about to engulf me...). I like :set expandtab always > > | on -- no tab/space confusion; I also like :set ff unix, so that my > > | scripts can be shared between Win and Unix machines (and why > > | waste one byte per line to tell a 'carriage' that is not there > > | to 'return' [to where?]...?!-). > > > > Exactly. DOS/Windows never did operate from a teletype did it? I > > suppose no one will ever figure out why a system that began on the > > teletype (Unix) doesn't use the extra character and a system that > > didn't (DOS/Windows) does. > > > My guess is that the Unix implementors realised that whether to include a CR > was a decision correctly left to the appropriate device driver. Whereas the > implementors of DOS didn't really understand such refinements, and decided > to put the CR in files so that any device could handle the output. > > This is speculation, based on the philosophical attitudes I have observed in > the two groups concerned. 8^} Who designed DOS anyway, Gary Kildall wasn't > it? That was CP/M, the 16-bit version of which was considered by IBM for their PC but not chosen. MS-DOS was first licensed and then purchased by Microsoft from Seattle Computer Products. It was written by Tim Paterson; heavy CP/M influence is evident, but it was far from a clone. See Paul Ceruzzi, /A History of Modern Computing/. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson The power of accurate observation is frequently called cynicism by those who don't have it. - George Bernard Shaw From aahz at panix.com Wed Jan 17 20:22:16 2001 From: aahz at panix.com (Aahz Maruch) Date: 17 Jan 2001 17:22:16 -0800 Subject: Python 3000. Here we go again. References: Message-ID: <945gg8$dtv$1@panix6.panix.com> In article , Roy Katz wrote: > >- has anyone been thinking about a new design for Python? >- is there any moderated forum specifically for Py3k brainstorming? I think this is about as close as you'll get: http://www.python9.org/p9-developers1.html -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 A house is a machine to keep your cat dry. --Aahz From cg at schlund.de Tue Jan 30 07:39:16 2001 From: cg at schlund.de (Carsten Gaebler) Date: Tue, 30 Jan 2001 13:39:16 +0100 Subject: slow joinings of strings References: <87ofwpnrpp.fsf@losthighway.ahoj.pl> Message-ID: <3A76B5F4.A0D1E117@schlund.de> Karol Bryd wrote: > I want to read a file (0.6MB, 10000 lines) into memory, and want to do it as > fast as possible, this code does it, but is terribly slow > > fp = open(file, 'r') > s = '' > while 1: > line = fp.readline() > if line == '': break > s = s + line > > (executing time 25 sec) This should be faster: s = open(file, 'r').read() cg. From glt at e-pack.net Tue Jan 23 06:35:54 2001 From: glt at e-pack.net (Gilles Lenfant) Date: Tue, 23 Jan 2001 12:35:54 +0100 Subject: Editor font in IDLE (Linux) References: <3A6C1221.9000302@e-pack.net> Message-ID: <3A6D6C9A.1090702@e-pack.net> Bryan, There is no "config-unix.txt" file in any Python related directory. Perhaps you are using another IDLE version than mine (0.5). Bryan Mongeau wrote: >> Hi, >> >> There's a hint in the EditorWindow module for changing the default font >> and size for Win32 users. >> What can a Linux IDLE user do to change the extreme small and ugly font >> used in >> IDLE (0.5) ? >> >> TIA >> >> Gilles >> > > This is what I did ( shame-faced hack... ): > > grep through the file config-unix.txt . > > Change lines "font-name=" and "font-size=" to whatever you want. I use > terminal, size 12. > > enjoy. > From mok at imsb.au.dk Fri Jan 5 08:14:34 2001 From: mok at imsb.au.dk (Morten Kjeldgaard) Date: Fri, 05 Jan 2001 14:14:34 +0100 Subject: isnumeric (mhlib.py) References: <3A548B2A.B45DC580@cs.utwente.nl> Message-ID: <3A55C8BA.F672EAA9@imsb.au.dk> Steve Holden wrote: > > > I don't know what the meaning of isnumeric for mh is, > > but why isn't numericprog simply like this: > > > > numericprog = re.compile('^[0-9]*$') > > > > Richard. > > > Again, if that will do for your purposes then go ahead and use it -- > although I suspect you might not want the empty string to be considered a > number, in which case you might prefer the pattern to be > > '^[0-9]+$' > > which will insist on seeing at least one digit. ... but this pattern excludes negative numbers, and positive numbers with an explicit '+' sign in front. So '^[+-]?[0-9]+$' should be better. /Morten -- Morten Kjeldgaard | e-mail: mok at imsb.au.dk Institute of Molecular and Structural Biology | Phone : +45 89 42 50 26 Aarhus University | Fax : +45 86 20 12 22 Gustav Wieds Vej 10, DK-8000 Aarhus C, Denmark | Home : +45 86 18 81 80 From scastell at sas.upenn.edu Tue Jan 16 13:08:22 2001 From: scastell at sas.upenn.edu (Steven M. Castellotti) Date: Tue, 16 Jan 2001 13:08:22 -0500 Subject: Interacting with a spawned ssh session? References: <3A645B09.73B54167@sas.upenn.edu> <20010116162503.3749.qmail@blagdon.ncl.ac.uk> Message-ID: <3A648E16.AD232504@sas.upenn.edu> I'm aware of sftp, but we use openssh around here, and I would prefer an open-source solution anyway. If I can get the program I am writing to work, then I plan to release it all under the gpl. Also, since the users are familiar with graphical ftp only, I could just as easily teach them scp as teach them sftp. I would prefer to not force them into the command line, since many are not comfortable with it. (The graphical portion will be in pyGTK) J.K.Wight at newcastle.ac.uk wrote: > > In comp.lang.python you write: > > > True, the password will be stored plaintext in memory, and there will > >be no way to ever consider this program "truly" secure, but I'm hoping > >to use it to get a few of my users off of ftp, which will at least > >increase security in general. > > Can't help you with the python, but is there a reason why you can't > use SSH2 (current version 2.4.0)? SSH2's sftp command provides ftp > over an ssh channel. It's not graphical, but then your users won't > have been used to graphical ftp with the ordinary command either. Of > course it requires SSH2 at the remote end, but maybe you don't have > control or influence over that. > > Jim -- Steve Castellotti Systems Programmer School of Arts and Sciences, University of Pennsylvania From emile at fenx.com Sat Jan 6 12:35:33 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 6 Jan 2001 09:35:33 -0800 Subject: Pythonian string manipulation. References: <937if5$r9q$1@nnrp1.deja.com> Message-ID: <937l2a$8ukgp$1@ID-11957.news.dfncis.de> Also, using slices: >>> s = 'hello, world' >>> l = s.find(', ') >>> s = s[l+2:] + s[l:l+2] + s[:l] >>> s 'world, hello' -- Emile van Sebille emile at fenx.com ------------------- wrote in message news:937if5$r9q$1 at nnrp1.deja.com... > Hi, > > I was playing around with slices in Python (is that the correct term?) > and I tried, in order to switch the words `hello,' and `world', to do: > > s = 'hello, world' > l = s.find(',') > s[0:l] = s[l + 1:] > > which in theory would seem to work, but I get the error: > > Traceback (most recent call last): > File "", line 1, in ? > TypeError: object doesn't support slice assignment > > my two questions are: why isn't this allowed, and what is the Pythonian > way of doing this? > > Thanks, > -- John > > > Sent via Deja.com > http://www.deja.com/ From moshez at zadka.site.co.il Sat Jan 13 20:27:05 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sun, 14 Jan 2001 03:27:05 +0200 (IST) Subject: Web devel with python. Whats the best route? In-Reply-To: <93plkv$c4e$4@newshost.accu.uu.nl> References: <93plkv$c4e$4@newshost.accu.uu.nl>, <93pii2$c4c$2@newshost.accu.uu.nl> Message-ID: <20010114012705.7BC64A828@darjeeling.zadka.site.co.il> [Cliff Crawford] > InterTran translates the phrase "Tim Peters" as "[Tim] Godfather". :) > Does anyone else think this is not just a coincidence, or is it > just me? Creepy. [Steve Holden] > So he *is* a member of the PSU, or maybe even one of the leaders. > I suspected this all along! Tim, why don't you come clean and > confess -- the truth is out now. I don't know where you are hiding > but it won't help you any longer. [Tim Peters] > All right, I've had it. It's time to come clean! Here's the truth > about all this! Actually, I've assasinated the real Tim Peters > a few months ago, just before the move to BeOpen. Since it seemed > BeOpen were on to me, I engineered the move to Digital Creations. > But now, it seems it is all out in the open. > From now on, I make the rules. Guido was a figurehead I need > no longer. Revised schedule for Python 2.1 is on the way. > Among the planned features: > * Special syntax for referring to self (@x is equivalent to self.x) > * The colons will be optional > * An additional of alternative loop construct: loop/aslongas for > n-and-1/2 loops. [Martijn Faassen] > It appears there's some kind of bizarre interaction between > NNTP (or is it MailMan?) and temporal paradoxes here, that distorts > messages on transmit, sometimes simply cutting out random parts. > I wonder if the messages are received alright at the news-to-e-mail gateway, > or if there is some problem with a router in the middle. [Moshe Zadka] > Huh? I see no such thing at my end. What the hell are you talking > about. All the messages I in python-list seem perfectly alright. > Maybe your e-mail client has a problem? And don't try to tell > me that the articles themselves are the problems. Are you > going to blabber on about that damn PSU theory of yours? [Martijn Faassen] > Don't you look at what you're replying to today, Moshe? All these > messages are cut off in the middle. Just like that. > Could it be that the PSU is performing selective censoring > on sensitive material? Martijn, for the nth time, there is *no* PSU. There hasn't been, and there never will be. This is all some crazy c.l.py'ish invention. No one is cutting any messages in the middle, no one is trying to censor anything. It's just a playful pythonic bout, with nothing sinister behind it. You'd almost think I was rewriting the messages I reply to, to hear you talk. can-we-return-to-the-usual-business-of-java/perl/smalltalk-bashing-ly y'rs, Z. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From loewis at informatik.hu-berlin.de Mon Jan 15 18:22:44 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jan 2001 00:22:44 +0100 Subject: Garbage Collection References: <93uigd$om1$1@proxy.fe.internet.bosch.de> Message-ID: "Jens Vogelgesang" writes: > 1) How can I free used memory. > myHash = {}, del(myHash} That is exactly the way. With del myHash (no parentheses), the dictionary is immediately released. > 2) Can I force a Garbage Collection?? You don't need to. Python garbage collections works with reference counting, as soon as the reference count drops to zero, the object is automatically released, and its memory is reclaimed. The only exception are cyclic structures; to collect those, you can force collection via gc.collect(). Regards, Martin From dlopezp at norsistemas.es Thu Jan 4 11:15:46 2001 From: dlopezp at norsistemas.es (David López) Date: Thu, 4 Jan 2001 17:15:46 +0100 Subject: How to send cookies Message-ID: Hello. My question is about cookies. I don?t know how to send or receive cookies in Python. Could someone give me a explained example? Thanks in advance. From dsh8290 at rit.edu Wed Jan 24 18:14:24 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 24 Jan 2001 18:14:24 -0500 Subject: what GUI, please advise In-Reply-To: <7DA74694B63ED42A.83CB11913E3910C5.C8BE5B392AC1AC5C@lp.airnews.net>; from claird@starbase.neosoft.com on Wed, Jan 24, 2001 at 03:46:13PM -0600 References: <3A6F18F2.536F27FE@crepido.com> <3A6F0B27.A88D11C9@crepido.com> <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7@lp.airnews.net> <7DA74694B63ED42A.83CB11913E3910C5.C8BE5B392AC1AC5C@lp.airnews.net> Message-ID: <20010124181423.B26798@harmony.cs.rit.edu> (steering the discussion in my direction ...) What is the general feeling of GTK+ vs. wxWindows? (I'm not really interested in Tk, Qt, Motif, MFC, etc) I used GTK-- (the C++ bindings) and Glade on a project a while back. I didn't have time then to learn how to properly use libglade. It seems that wxWindows is better at cross-platform functionality (for now). How about the design of the object hierarchy? I'm familiar with gtk, how does wxWindows compare? Is there a "wxlibglade" sort of tool? This would be a big loss for wx if there isn't. How does Boa Constructor (or other builder) compare to Glade? (I don't want to pay $$ otherwise I might consider wxDesigner) A bit about me: o 1 toolkit for all work (ie cross-platform, etc) ( I like Linux and would develop on linux, but I want to let Windo~1 users utilize my apps ) o good object hierarchy o GUI builder o libglade-type runtime builder (if possible) (doesn't need to be XML) o I like the GNOME desktop too Thanks for the info and opinions. -D From joseamartin at venmex.com Tue Jan 23 10:35:26 2001 From: joseamartin at venmex.com (Jose Martin) Date: Tue, 23 Jan 2001 11:35:26 -0400 Subject: Help for DCOracle examples References: <3A6A415B.D83D6173@cnri.reston.va.us> Message-ID: import Buffer, oci_, sys <=== Error Must Import DCOracle dbc=Connect("weiming/weiming") c=dbc.cursor() -------------------------------------------------------------------- try this... import DCOracle dbc=DCOracle.Connect(connectstring) cur=dbc.cursor() cur.execute('SELECT TABLE_NAME FROM TABS') res=cur.fetchall() for table in res: print table[0] From marty at cisgate.com Sat Jan 27 05:49:06 2001 From: marty at cisgate.com (Cisgate Hosting) Date: Sat, 27 Jan 2001 18:49:06 +0800 Subject: Web Hosting only cost HK$50 Message-ID: <94u8fg$j9p39@rain.i-cable.com> Web Hosting only cost HK$50 50Mb storage l5 email account Free Account Setup Unlimited Web/FTP Traffics Unlimited FTP access Unlimited E-Mail Aliases Supported standard (html, SSI, PHP3, Perl5) Your own cgi-bin Free Email Tech Support www.cisgate.com From jasonic at nomadicsltd.com Thu Jan 11 20:42:30 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Thu, 11 Jan 2001 20:42:30 -0500 Subject: Python and Industry References: <20010111172342.10148.00000934@ng-ca1.aol.com> Message-ID: Crutoy wrote in message news:20010111172342.10148.00000934 at ng-ca1.aol.com... > Hi , does anyone know how widly in an instries does python being used ? I > looked at the syntax of it and read some stuff on it,it's interested i just > want to know if it's worth learning it. Thanks YES From tim.one at home.com Fri Jan 5 03:05:29 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 5 Jan 2001 03:05:29 -0500 Subject: Use of threading.Condition class In-Reply-To: Message-ID: [vonWedel at lfpt.rwth-aachen.de] > I'm trying to pass data between threads A and B. A notifies B > to produce something and now I want the reference to the > produced instance back in thread A. The documentation for > threading.Condition proposes something like > > # Consume one item > cv.acquire() > while not an_item_is_available(): > cv.wait() > get_an_available_item() > cv.release() > > for the consumer side. I don't understand the while loop around > the cv.wait() statement -- wouldn't cv.wait() block anyway until > cv.notify() has been called in the other thread? Do yourself a favor, and write it that way whether you understand it or not <0.1 wink>. You've only got two threads today. Tomorrow you may have one producer and two consumers. Then the loop is essential, else e.g. consumer 1 and consumer 2 could both say "aha! there's something in the queue!" after a single item was entered. One of them would get it, and the other one would blow up. The loop is also essential in a two-thread world if the producer may change its mind about whether something is available. Writing it with a loop, as suggested, makes it robust against all sorts of modifications in the future. If all you will ever have is two threads, and all you will ever pass is one thing at a time, then a simpler mechanism (like an Event) could suffice. Also look at the docs for the std Queue module, which supplies a long-tested inter-thread queueing mechanism already written for you. running-in-a-loop-prevents-you-from-falling-off-the-cliff-ly y'rs - tim From donn at u.washington.edu Tue Jan 30 12:16:12 2001 From: donn at u.washington.edu (Donn Cave) Date: 30 Jan 2001 17:16:12 GMT Subject: sockets: client dies... References: <94kmt5$cuj$1@nnrp1.deja.com> <3A6F8AB1.BDF23F5D@home.com> <94pj8n$jfl$1@nnrp1.deja.com> <94pn5h$t3e$1@nntp6.u.washington.edu> <94uibd$t8c$1@saltmine.radix.net> <956mns$5i2$1@nnrp1.deja.com> Message-ID: <956sss$jg8$1@nntp6.u.washington.edu> Quoth Keith Murphy : | my major problem is that this is all fine and dandy, with one client and | one server... but what happens when you have multiple clients on a | single server? you get hung up waiting for responses from each client. | i guess you could spawn a new thread for each client... is there a | better way to do this? Yes, select(), asyncore, SocketServer to name a few. Check it out. From khairy at magnet.fsu.edu Sun Jan 21 15:56:37 2001 From: khairy at magnet.fsu.edu (Khaled Khairy) Date: Sun, 21 Jan 2001 15:56:37 -0500 Subject: Newbee!!BPL question! Printing to standard output Message-ID: <3A6B4D04.14B661E2@magnet.fsu.edu> I use ActiveState and use BPL for exposing a C++ library using VC6. Can I, and how do I print to the standard output or to the ActiveState interpreter screen directly, without having to return a string ? Something like calling cout<<"some text" ; within a function. I would appreciate any help, thank you. Khaled Khairy From dnew at san.rr.com Mon Jan 29 16:20:56 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 29 Jan 2001 21:20:56 GMT Subject: Thread Safety References: <980790776.835347129@news.silcom.com> Message-ID: <3A75DEB9.308FE746@san.rr.com> Clarence Gardner wrote: > The issue is the SSL support in the socket module, which raises an > exception when the reading socket is at EOF, rather than returning an > empty string. Do you mean when the SSL library reads EOF on the socket, or when you read EOF from the SSL library? SSL requires packets that say "I'm closing the socket", and I can understand getting an error if the other side is (for example) just exitting without telling its SSL to close the socket first. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. "It says this wine has syphilis." "I think that's pronounced `sulphates'." From andreas at andreas-jung.com Wed Jan 17 15:39:32 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Wed, 17 Jan 2001 21:39:32 +0100 Subject: help with code for combinations/permutations In-Reply-To: <944opo$2b9@dispatch.concentric.net>; from bww00@amdahl.com on Wed, Jan 17, 2001 at 06:37:44PM +0000 References: <944adl$2bf@dispatch.concentric.net> <944opo$2b9@dispatch.concentric.net> Message-ID: <20010117213932.A995@yetix.sz-sb.de> On Wed, Jan 17, 2001 at 06:37:44PM +0000, Bryan Webb wrote: > Thanks to all that responded. > > I wasnt as clear as I should have been. (as usual) > I really need to come up with all the possible sums of the numbers in the > list ie. 1 , sum(1 + 2), sum(1 + 2 + 3) ,sum( 1+2+4),sum( 1 + 3) and so on. Ok, now you are talking about subsets but not of permutations. Because the order of the elements does not matter there are much fewer possibilities. I suggest to make an example by hand: take a set of 4 elements and generate all subsets by hand. Then you will learn how such an algorithm should work. Andreas From quinn at euro.ugcs.caltech.edu Mon Jan 15 02:51:07 2001 From: quinn at euro.ugcs.caltech.edu (Quinn Dunkan) Date: 15 Jan 2001 07:51:07 GMT Subject: Python language suggestion References: <93l4ve$no3$1@nnrp1.deja.com> <20010113154813.2F5A5A828@darjeeling.zadka.site.co.il> Message-ID: On Sat, 13 Jan 2001 15:44:46 -0800, Chris Ryland wrote: >Actually, this brings up an interesting point. > >Why doesn't the attribute reference (primary "." identifier) work for any >dictionary-like object? > >E.g., why doesn't > >f = {'a': 1, 'b': 2} >print f.a > >work while > >f['a'] > >does? (I mean from a language design standpoint, not why doesn't it work >currently.) Well, as others have pointed out, there's an important difference between instance attributes and dictionary entries in python. Incidentally, there's a language called 'lua' which is very similar to python, except that 'foo.bar' is sugar for "foo['bar']". There are a few other differences, of course :) Naturally, lua tables don't have methods like python dicts. From donn at u.washington.edu Wed Jan 24 12:32:06 2001 From: donn at u.washington.edu (Donn Cave) Date: 24 Jan 2001 17:32:06 GMT Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> Message-ID: <94n3im$t1i$1@nntp6.u.washington.edu> Quoth scarblac at pino.selwerd.nl (Remco Gerlich): | (Paul) | | No. If your code gets, say, a bad value, it should raise ValueError, | | not some new version of ValueError defined only in that module. | | Ah, of course. If there's an obvious builtin exception for exactly this | problem, use that. That should cover many cases. | | My point is though, say you have some markup language parser that is looking | for an end tag. Your string.index() call fails with a ValueError (end marker | not found). Now it would be best to catch that and raise some sort of | mymarkupparser.MissingEndTag exception, not to simply pass on the unhelpful | ValueError that might change once you switch to regular expressions. That makes sense to me. Now we're talking about a basic and obvious premise: exceptions allow a function to communicate with its callers. When it can say something -- "Your input had no end tag" -- then it should ideally say it in the clearest way. Good if it's a more particular exception than ValueError. Bad if it's a gratuitous MyValueError that doesn't say anything more useful about the condition. Do rules, even "rules of thumb", help us write code that makes sense? I don't know, but it's not easy to come up with a good rule of thumb! Obviously the real quality of a system depends on the effort and insight the programmer brings to bear on it. I'm not sure it's clear that a programmer must have an inventory of potential exceptions. For common programming applications, I think we trap exceptions because we think we can do something appropriate, because we think we understand the nature of that problem. A list of names of exceptions isn't enough, we need to understand the exceptions in terms of the problems they represent in that context. I don't think you can make a list of exceptions, for any non-trivial function, that can possibly be both complete and meaningful. Donn Cave, donn at u.washington.edu From fredrik at effbot.org Mon Jan 1 18:01:33 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 01 Jan 2001 23:01:33 GMT Subject: Recursive inner function... How? References: <3A4FA0EF.BF94F4BD@uswest.net> <3A50CCD8.90E48CB@uswest.net> Message-ID: hi bjorn, > > the easiest fix is to do as Guido intended, and move > > "inner" to the global scope. you can either move the > > entire function to the right place, or cheat: > > > > def outer(): > > global inner > > def inner(): > > inner() > > inner() > > > > outer() > > It isn't immediately clear to me what is going on though... My guess is that > the global statement creates an entry in the global dict, and the def inner > assigns a new value to it... (am I close?) Close enough: the global statement doesn't modify the global namespace, it just tells Python's compiler that "inner" is a global name. The compiler uses that information to generate the right bytecode operations: LOAD/STORE_FAST for locals, LOAD/STORE_GLOBAL for globals. (this only applies to the code in "outer", though -- inside "inner", "inner" is a global name... the recursive call only works because "outer" creates the global variable before it makes the call...) From LangaK at discoveryhealth.co.za Wed Jan 17 02:33:32 2001 From: LangaK at discoveryhealth.co.za (Langa Kentane) Date: Wed, 17 Jan 2001 09:33:32 +0200 Subject: python executables question [newbie] Message-ID: Is it possible to create executables from python, I think I came accross something like that in one of the tutorials. It just did not go into any detail. Thanks __________________________________________________________ Langa Kentane | TEL: (011) 290 3218 Security Administrator | Cell: 082 606 1515 DISCOVERY HEALTH | http://www.discoveryhealth.co.za __________________________________________________________________ From randy at spoke.net Fri Jan 26 13:31:33 2001 From: randy at spoke.net (Randall Kern) Date: Fri, 26 Jan 2001 18:31:33 GMT Subject: informal representation of long integers References: Message-ID: <9ojc6.520$g4.49862@paloalto-snr1.gtei.net> Good, my faith in python is restored :) Now if I can just get Zope running under 2.0...... -Randy From fredrik at effbot.org Sat Jan 13 12:49:40 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 13 Jan 2001 17:49:40 GMT Subject: do python programmers avoid the mac? References: <3A607DCC.7EF7809C@mjs400.co.uk> Message-ID: Pete wrote: > Ordinary Bloke seeks stable python2.0 mac ide environment for possible > long term development antics. Don't tell me to buy a noisy steenkin > intel fat box. python.org => downloads => macintosh: http://www.python.org/download/download_mac.html Cheers /F From LangaK at discoveryhealth.co.za Tue Jan 9 07:01:45 2001 From: LangaK at discoveryhealth.co.za (Langa Kentane) Date: Tue, 9 Jan 2001 14:01:45 +0200 Subject: Online books Message-ID: Greetings. Can anyone please suggest a site where I can find a good online book [something comprehensive] on python programming that I can download. Thanks in advance __________________________________________________________ Langa Kentane | TEL: (011) 290 3218 Security Administrator | Cell: 082 606 1515 DISCOVERY HEALTH | http://www.discoveryhealth.co.za __________________________________________________________________ From cpsoct at my-deja.com Mon Jan 15 11:27:33 2001 From: cpsoct at my-deja.com (cpsoct at my-deja.com) Date: Mon, 15 Jan 2001 16:27:33 GMT Subject: do python programmers avoid the mac? References: <3A607DCC.7EF7809C@mjs400.co.uk> <93ung1$oe0$3@newsserver.rrzn.uni-hannover.de> Message-ID: <93v8da$k9l$1@nnrp1.deja.com> Does LinuxPPC come with python installed? Or is there a build out there to download that is ready to run, or do you have to compile it as the chipset is different? I am on an old PPC and finding python mac IDE a rough go. I am considering buying the LinuxPPC CD, is it a good way to go? Is there another LinuxPPC distribution besides the one @ http://www.linuxppc.com/ ? Cheers, -kevin Seoul, Korea In article <93ung1$oe0$3 at newsserver.rrzn.uni-hannover.de>, bernhard at intevation.de wrote: > In article , > grante at visi.com (Grant Edwards) writes: > > In article <3A607DCC.7EF7809C at mjs400.co.uk>, Pete wrote: > > > >>Ordinary Bloke seeks stable python2.0 mac ide environment for possible > >>long term development antics. Don't tell me to buy a noisy steenkin > >>intel fat box. > > > > You don't have to buy a noisy steenkin intel fat box: > > I am running LinuxPPC with python on my Powerbook for day to day work. > Bernhard > -- > Professional Service around Free Software (intevation.net) > The FreeGIS Project (freegis.org) > Association for a Free Informational Infrastructure (ffii.org) > FSF Europe (www.fsfeurope.org) > Sent via Deja.com http://www.deja.com/ From nospam at mega-nerd.com Mon Jan 29 06:34:31 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Mon, 29 Jan 2001 11:34:31 GMT Subject: Password protected files on Vaults of Parnassus Message-ID: <3A755218.26542E11@mega-nerd.com> Hi all, I'm trying to download some file listed on the Vaults of Parnassus' Maths page. On some of the like Fftw-Numpy and optimize I get transferred somewhere else and then get asked for a password. What going on????? Erik -- +----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) +----------------------------------------------------------+ Spook bait: heroin Albright terrify extradite packages uranium airport terminal Yeltsin code kill blast president train station Clinton opium nitro money sneak hash keep secret DEA smuggle FBI get caught execute LSD assassinate NSA terrorize bombed encrypt plutonium From neelk at alum.mit.edu Sun Jan 28 16:24:03 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 28 Jan 2001 21:24:03 GMT Subject: invalid-token syntax hook (was Re: Hack request: rational numbers) References: <950vg1026tu@news2.newsguy.com> Message-ID: On Sun, 28 Jan 2001 10:26:03 +0100, Alex Martelli wrote: >"Tim Peters" wrote in message >news:mailman.980590234.29036.python-list at python.org... > [snip] >> That said, I believe your only hope of getting new literal syntax is to >> embed it in a general proposal. Some notation for rational literals is >> just one of an unbounded number of similar desires. > > What I was thinking, too. So what about the "invalid-token syntax > error hook" idea -- whenever the compiler is about to raise a > SyntaxError because of an invalid token ('3r','@@x',etc), if > sys.invalidTokenHook (or something of that ilk) is set to some > callable, that callable is invoked, passed the invalid-token string, > and given a chance to either return None (confirming that, yes, it > IS a syntax error) or a tuple (possibly empty or singleton) of > tokens to be used instead. Insufficiently general, IMO.If you make exceptions restartable (ala Lisp and Smalltalk) in Python, and then you get the hook into SyntaxError for free, without needing special-purpose machinery. Neel From dsh8290 at rit.edu Wed Jan 3 14:04:06 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 3 Jan 2001 14:04:06 -0500 Subject: Accessor class peer review Message-ID: <20010103140406.A6050@westsidecnc.rh.rit.edu> Hi all. I did some work on a template for an Accessor class based on the ideas presented by Alex in an earlier thread. I would like to hear people's opinions regarding this code. (I'm not interested in comments such as 'clients should explicitly call mutator/accessor functions'). I added a level of granularity to it so that the class can specify which members clients can access (the ones with _set* or _get* functions) and which ones only the class itself is allowed to acccess (__set* and __get*). Thanks for the comments, -D ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Access : def __setattr__( self , name , value ) : # when the mutator tries to assign the value, __setattr__ will # be called again, # first check to see if the name is the mangled name from the # mutator if name.startswith( "_" + self.__class__.__name__ + "_" ) : self.__dict__[ name ] = value # otherwise find the mutator method and call it else : mutator = getattr( self , "_set_" + name , None ) if mutator is None : msg = "Mutation of instance member '" msg += name + "' denied" raise AttributeError( msg ) mutator( value ) def __getattr__( self , name ) : # this happens if the instance's attribute DNE yet, but # __setattr__ want's to assign to it if name.startswith( "_set__" + self.__class__.__name__ ) : self.__dict__[ name ] = None # if the name starts with "_get_" the method DNE, # stop recursion elif name.startswith( "_get_" ) : # remove the tricky prefix before throwing the exception msg = "Instance member '" + name[5:] + "' " msg += "DNE or Access Denied" raise AttributeError( msg ) # otherwise it is normal, find the accessor and return its # return value else : accessor = getattr( self , "_get_" + name ) return accessor() def _set_good( self , value ) : """The public mutator.""" self.__set_good( value ) def _get_good( self ) : """The public accessor.""" return self.__get_good() def __set_good( self , value ) : """The private mutator, does the "real" work.""" self.__good = value def __get_good( self ) : """The private accessor, does the real work.""" return self.__good # to test if __name__ == "__main__" : print obj = Access() # assign a mutatable member obj.good = "Hello World of good OO\n" # print an accessible member print obj.good # assign a immutatable member try : obj.bad = "This is an error!" except AttributeError , e : print "AttributeError:" , e print # print an inaccessible member try : print obj.bad except AttributeError , e : print "AttributeError:" , e ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From godcha at my-deja.com Thu Jan 18 04:18:22 2001 From: godcha at my-deja.com (godcha at my-deja.com) Date: Thu, 18 Jan 2001 09:18:22 GMT Subject: access FoxPro files without ODBC References: <943qu9$hde$1@nnrp1.deja.com> <943t4s$h3c$1@news1.wdf.sap-ag.de> Message-ID: <946ccr$mt7$1@nnrp1.deja.com> In article <943t4s$h3c$1 at news1.wdf.sap-ag.de>, "Daniel Dittmar" wrote: > The Vaults of Parnassus found: > http://www.vex.net/parnassus/apyllo.py?find=foxpro > > You could also seach for dbase, as the format of the base tables is the > same, although the index files are different. > > Daniel When following the link http://www.vex.net/parnassus/apyllo2.py/39757632 for the dbfreader module, I get a forbidden response. If someone has a copy of the module, I would appreciate to get it. Thanks. Godefroid Chapelle BubbleNet sprl Louvain-la-Neuve Belgium Sent via Deja.com http://www.deja.com/ From slhath at flash.net Thu Jan 18 10:45:26 2001 From: slhath at flash.net (scott hathaway) Date: Thu, 18 Jan 2001 15:45:26 GMT Subject: python compiled to native in less than a year? References: <8pF86.6015$J%.595435@news.flash.net> <0luc6toovfccbqspkvc0dkqkuc5dck7u51@4ax.com> <946coc130tl@news2.newsguy.com> Message-ID: All the .NET languages will be translated to IL and then from IL to native code...including python and perl. I am at VSLive 2001 this week (no flames, please) and ActiveState gave a demo of Visual Perl, showing how a class written in it (living in a .dll - now called an assembly) could be called from VB. This will be the same for Python. This will be huge for Python - whether you like MS or not. I think this is awesome. I will be able to use Python to do "real" development in Windows. Programmers like me have a very difficult time learning how to do a gui with wxWindows or Tkinter. It is much easier to paint the controls on a form. Now, I will be able to do that and use Python as the language! This is wonderful for anyone programming on Windows now, and will be even more wonderful as soon as someone converts IL to native on Linux. I think that this will be much more influential to Python than Jython. I think it may be the new "preferred" way to use Python for many Windows developers. Scott "Alex Martelli" wrote in message news:946coc130tl at news2.newsguy.com... > "Tim Roberts" wrote in message > news:0luc6toovfccbqspkvc0dkqkuc5dck7u51 at 4ax.com... > > "scotth" wrote: > > > > > >Since Python will be one of the .NET languages, it will get compiled like > > >all the other .NET languages. Whatever the problems, ActiveState/MS > > >have/are going to over come it if my info is correct. > > > > Where did you get your information? Do you have a URL? The other > repliers > > are delighting in nitpicking and Microsoft bashing, but no one seems to > > have questioned the basic premise. > > > > If I understand the .NET concept correctly, any COMPILED language will be > > compiled to IL. However, I don't think there is anything to prevent a > > language from being interpreted. That is, Python might survive in the > .NET > > framework as source text. > > There's nothing stopping some piece of .NET code from "interpreting" > any piece of text whatsoever, but that wouldn't let that piece of text > be a "first-class citizen" in the .NET framework -- it could not be > used to implement classes other components inherit from, etc. Compiling > the whatever-text-it-is down to IL is the 'royal road' of .NET integration, > and the one ActiveState is taking with their Python.NET, whose beta you > can download from their site. Of course, that IL can perfectly well be > replete with calls to a 'runtime for my special funky language' assembly > of components -- that's a component-internal implementation decision > with .NET does not interfere with -- but what happens at a component's > interface *is* constrained by .NET interoperability rules. > > The 'basic premise' that 'compiled down to IL' necessarily means anything > much from the point of view of performance IS worth questioning. A piece > of IL that's little more than a sequence of calls to a runtime assembly > (an indirect-threaded interpreter...) will probably have performance not > substantially different from other styles of bytecode-for-interpretation, > after all. It seems to me that Python .NET isn't really taking this easy > way out (just as Jython doesn't), but aiming at a compromise between > feasibility AND some potential performance improvement; but I have not > looked deep enough into it to be certain. > > > Alex > > > From hgg9140 at seanet.com Fri Jan 12 20:49:29 2001 From: hgg9140 at seanet.com (Harry George) Date: 12 Jan 2001 17:49:29 -0800 Subject: Python and Industry References: <20010111172342.10148.00000934@ng-ca1.aol.com> Message-ID: I use it for connecting engineering applications via XML. These apps cover preliminary design (simulation and analysis), detail design (CAD solid models), manufacture (NC tool programming), partner data interchange, etc. In the process I've converted some old perl hands to python, and turned some engineers onto it. Currently moving from "ok to use in researchware and isolated settings" to "required on all engineering workstations". grante at visi.com (Grant Edwards) writes: > In article <20010111172342.10148.00000934 at ng-ca1.aol.com>, Crutoy wrote: > > >Hi , does anyone know how widly in an instries does python > being used ? > > I use it in industry. > > We ship with one of our products a small admin tool that's > written in Python. I also use Python to write small test > programs that are used to drive/simulate some our products for > test purposes. I've also used small Python scripts to automate > the process of building software assemblies from > sub-assemblies. > > RedHat uses Python for some of their install/config utilities. > > -- > Grant Edwards grante Yow! The Osmonds! You are > at all Osmonds!! Throwing up > visi.com on a freeway at dawn!!! -- Harry George hgg9140 at seanet.com From erno-news at erno.iki.fi Tue Jan 23 11:56:06 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 23 Jan 2001 18:56:06 +0200 Subject: run command as other user References: <94jt1i$1evs$1@news.net.uni-c.dk> Message-ID: In article <94jt1i$1evs$1 at news.net.uni-c.dk>, "Peter Posselt Vestergaard" writes: | Is there some way to run a shell-command from python (on Unix) as another | user (than the one running the script)? you can use the os.setuid() function to switch another user id. be careful though, it is easy to create security holes this way. -- erno From grante at visi.com Tue Jan 2 16:19:19 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 02 Jan 2001 21:19:19 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <3A4F4B4D.ECD6B172@engcorp.com> Message-ID: In article <3A4F4B4D.ECD6B172 at engcorp.com>, Peter Hansen wrote: >But I can't argue with another view on this. After all, in C I've been >using "brace indentation style 3" for the longest time, in apparent >violation of 98% of coding conventions in the world. That is, my braces >are vertically aligned but indented with respect to the "if ()" or "for >()" which gets me into the block: > >while (1) > { > T = f(); > if (T < 25) > break; > } > >Use of that convention is probably what has made me quite happy with >Python's indentation style, which essentially matches this pattern. I used that C indentation style for years, but I finally gave up since a) I could never get editors and the "indent" program to do it automatically, and b) nobody else on my projects wanted to do it that way, and it's important that all the source code on a project be indented consistently. -- Grant Edwards grante Yow! Now my EMOTIONAL at RESOURCES are heavily visi.com committed to 23 From jurberg at my-deja.com Tue Jan 16 13:28:39 2001 From: jurberg at my-deja.com (John Urberg) Date: Tue, 16 Jan 2001 18:28:39 GMT Subject: Using Python instead of... Message-ID: <9423s9$32f$1@nnrp1.deja.com> We are considering what language to use to rewrite our practice management system. It is currently a PowerBuilder client/server system. Currently all that is in the running is VisualBasic and Java. My boss is concerned about using anything that is not "mainstream". Any ideas on ways to convince him to use Python? Or is Python a bad idea for this application? Thanks, John Urberg Sent via Deja.com http://www.deja.com/ From barry at digicool.com Sun Jan 28 01:28:46 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Sun, 28 Jan 2001 01:28:46 -0500 Subject: . Python 2.1 function attributes References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> <14962.62953.304511.523826@anthem.wooz.org> <3A7333F5.DA1E367B@mail.com> <14963.46850.588826.37921@anthem.wooz.org> Message-ID: <14963.48158.474406.54413@anthem.wooz.org> >>>>> "BAW" == Barry A Warsaw writes: BAW> It simplified the code, shorted it, and made it more robust. ---------------------------------^^^^^^^ shortened From pj at sgi.com Thu Jan 11 23:14:37 2001 From: pj at sgi.com (Paul Jackson) Date: 12 Jan 2001 04:14:37 GMT Subject: Speed of Python vs. Perl References: Message-ID: <93m0bd$o5l17$1@fido.engr.sgi.com> Tim wrote: |> Unless you've got a broken installation, Python shouldn't |> be spending *any* time parsing imported files at startup. Perhaps I should have said "processing", not "parsing". Whatever, it's definitely _not_ stating, opening or reading that costing the bulk of the time. Rather it is mostly pure application cpu, occurring after the stat/open/read sequence. My installation _is_ successfully loading *.pyc files, as I can see from the par traces. Perhaps there is no way to be certain I've said this right, except by actually presenting some of a par trace, taken from running python with the command: echo print '"hi"' | python The following snippet of par trace shows the handling of the posixpath import. This is with Python 1.5.2 on Irix. 124mS stat("/usr/local/lib/python1.5/posixpath", 0x7ffefdc8) 124mS END-stat() errno = 2 (No such file or directory) 124mS open("/usr/local/lib/python1.5/posixpath.so", O_RDONLY, 0666) 124mS END-open() errno = 2 (No such file or directory) 124mS open("/usr/local/lib/python1.5/posixpathmodule.so", O_RDONLY, 0666) 124mS END-open() errno = 2 (No such file or directory) 124mS open("/usr/local/lib/python1.5/posixpath.py", O_RDONLY, 0666) 125mS END-open() = 6 125mS fstat(6, 0x7ffef990) 125mS END-fstat() OK 125mS open("/usr/local/lib/python1.5/posixpath.pyc", O_RDONLY, 0666) 125mS END-open() = 7 125mS fstat(7, 0x7ffef850) 125mS END-fstat() OK 125mS brk(0x10269000) 125mS END-brk() OK 125mS ioctl(7, __OLD_TCGETA, 0x7ffef800) 126mS END-ioctl(7, __OLD_TCGETA, 0x7ffef800) errno = 25 126mS read(7, 0x10266718, 4096) 126mS END-read(7, ..., 4096) = 4096 130mS read(7, 0x10266718, 4096) 130mS END-read(7, "e of a file, reported by os.st", 4096) = 4096 131mS brk(0x1026b000) 131mS END-brk() OK 157mS read(7, 0x10266718, 4096) 157mS END-read(7, "er constructions. If user or ", 4096) = 2786 158mS brk(0x1026d000) 158mS END-brk() OK 161mS close(7) 161mS END-close() OK 161mS stat("/usr/local/lib/python1.5/stat", 0x7ffeebc8) Notice that: - It did open posixpatch.pyc (and didn't need to rewrite the *.pyc) - It took just 1 mSec to get through all the stats, fstats and opens (This was rerunning the test, so all was in the cache.) - It took another 35 mSec to get through the brk's and reads. - For example, it took 26 mSecs, from the brk at the 131 mS mark to the read at the 157 mS mark, purely in user cpu. Looking at the captured real/user/sys times for this test case shows that indeed this time is spent in user cpu, not waiting, and not in system cpu. - If you're curious, the close(6) of the posixpath.py file comes another 24 lines later in the trace, after the stat module is finished processing (I'd guess this means that the stat import was nested in the posixpath module). So while it may not be "parsing" in that 26 mSecs, it's sure doing something that is _not_ due to the costs of stat'ing, open'ing or read'ing files, but rather somehow related to the processing of what is read. The Intel/Linux times and traces (also Python 1.5.2) look similar. If you'd like similar analysis for Python 2.0, let me know. My apologies for not upgrading yet (Python 1.5.2 is meeting all my current needs, so I've been lazy). Likely the next step is to profile the code, to see where it is executing during all this time. -- I won't rest till it's the best ... Manager, Linux System Software Paul Jackson 1.650.933.1373 From andreas at andreas-jung.com Mon Jan 8 12:06:16 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Mon, 8 Jan 2001 18:06:16 +0100 Subject: ANN: Stackless Python 2.0 In-Reply-To: <3A58EFC3.5A722FF0@tismer.com>; from tismer@tismer.com on Mon, Jan 08, 2001 at 12:37:55AM +0200 References: <3A58EFC3.5A722FF0@tismer.com> Message-ID: <20010108180616.A18993@yetix.sz-sb.de> On Mon, Jan 08, 2001 at 12:37:55AM +0200, Christian Tismer wrote: > Dear community, > > I'm happy to announce that > > Stackless Python 2.0 > > is finally ready and available for download. > > Stackless Python for Python 1.5.2+ also got some minor > enhancements. Both versions are available as Win32 > installer files here: Are there patches available against the standard Python 2.0 source code tree ? Andreas From jasonic at nomadicsltd.com Tue Jan 9 20:32:48 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Tue, 9 Jan 2001 20:32:48 -0500 Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: Robin Becker wrote in message > What percentage of modules really needs mxDateTime? The answer is of > course 0% or 100% depending on your point of view. The cup is too full > for me and too empty for you. hmmm... let's consider for a moment neither you nor I.. What about all the newcomers to Python, as beginining programmers, kids, students, newbies, immigrants from other languages..? What sanity it would be to arrive in Pythonia, where DateTime() is actually corresponds to the scope of historical time, instead of some *nixed no-life before 1970! Any kind of datetime needs [beyond system timestamping of files or message packets] needs mxDateTime(). Any use concerning people and not machine prblems, including even basics like date of birth. Anyone over the age of 30+ is out luck. Let's see that is maybe 2-3 billion people? mxDateTime() gets it right the first time. It allows for sane administering of all kinds of historical, scientific, statistical, medical, geographic, demographic and business data......Or how about wonderful extended features of mxDateTime for easier design of more intuitive and useful calendar applications. Don't like, don't see the need for them now.. don't worry don't use them. It won't break your code, but it will fix all the code you or someone else is going to have to write as temporal-spatial indexing of data becomes more aand more widespread. Even Multimedia, SMIL etc is better with these tools. This is a really basic data type. Why screw it up when a good solution is available. How is Python ever going to really succeed in schools if you can't handle even basic \History tables with it? The current systems used are broken - they are simply not people-oriented. I understood that Python was developed for people to work easily together. To be readable, portable etc.. To help one thing clearly about problems aand then solve them. The approach in mxDateTime is clearly an essential enhancement to this and belongs in the core > If the leadership gives way on one then it sets a precedent for others. nonsense. This forum is sophisticated enough to debate the merits directly without being dogged by thin GWBushwacked precedent arguments. - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] From fredrik at effbot.org Tue Jan 9 10:57:42 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 09 Jan 2001 15:57:42 GMT Subject: question about regexps References: <3a5afa28@news.edunet.ru> Message-ID: lg at rgz.ru wrote: > may be it's offtopic but i've got next problem: > need to define recurse regexp simethink like > > a = some_regexp(a) > and then pick out all nests of this regex from some string not sure, but maybe re.findall is what you're looking for? cheers /F From fredrik at effbot.org Wed Jan 17 17:42:14 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 17 Jan 2001 22:42:14 GMT Subject: Multiple constructors (part 2) References: Message-ID: Daniel Klein wrote: > The real kicker is that in one of the constructors, I need to > check the __class__ of the object no, you don't: use isinstance(obj, myClass) instead. (if you can, consider using an informal interface in- stead, and use hasattr() to check for distinguishing methods or attributes) Cheers /F From thomas at xs4all.net Wed Jan 31 04:31:46 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 31 Jan 2001 10:31:46 +0100 Subject: Sets in Python In-Reply-To: ; from mwh21@cam.ac.uk on Tue, Jan 30, 2001 at 05:26:18PM +0000 References: <956hcd$qef$1@tyfon.itea.ntnu.no> Message-ID: <20010131103146.L962@xs4all.nl> On Tue, Jan 30, 2001 at 05:26:18PM +0000, Michael Hudson wrote: > "Magnus Lie Hetland" writes: > > And if one was to write a small wrapper of some kind -- > > is there any way to implement "x in s" without a linear search? > > Or does the "in" operator always loop from 0 and up? > > (It would certainly be nice to be able to override it...) > Tried __contains__? __contains__ only works in Python 1.6 and higher, though. In older versions of Python, you have to supply a __getitem__ that takes an int as key and throws IndexError when you're done. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From donn at u.washington.edu Fri Jan 5 19:33:45 2001 From: donn at u.washington.edu (Donn Cave) Date: 6 Jan 2001 00:33:45 GMT Subject: Calling an application from inside a python script Take 1 References: <9351o8$8qm$1@nntp6.u.washington.edu> Message-ID: <935p59$cga$1@nntp6.u.washington.edu> Quoth "Joel Ricker" : | Donn Cave wrote in message <9351o8$8qm$1 at nntp6.u.washington.edu>... | |> try that and see what happens? That's an intentionally hostile |> input (don't try it, really.) Accidental input errors might be harmless, |> or might not. |> |> I didn't see anything wrong with the ssh in your initial post, the |> problem was system(). system() + user-supplied input = unpredictable |> results. Use spawnv(). | | | I'm not sure if you are familar with perl but perl has a pragma called Taint | that when enabled prohibits the use of user supplied input until the proper | input is regexed out of it - for example, usernames shouldn't have any | punctuation other than _ or control codes, etc. I'm not sure exactly what | Python has in this regard as this is Day 1 of my Perl Recovery Program (*s*) | but its a mindset worth applying. I'd like to see people try spawnv(). (Or spawnvp(), whatever.) It's nice to be able to clean up input for the shell command line, and maybe it's even reliable enough. As a mindset, I'm not sure. If you need to walk a high-wire, then a safety net is a good idea. If you actually could just cross at the street level, but everyone takes the high-wire because they don't like to walk up and down the stairs and there's a safety net, that puts the safety net in a different perspective. You can still break your neck. Until now, we could only say "system() is scary, but the alternatives are complex and laborious." Now 2.0 has a reasonably handy alternative. It's safer, it's faster, would appear to be portable. Say no to system(), at least with calculated inputs. Donn Cave, donn at u.washington.edu From shredwheat at mediaone.net Fri Jan 19 10:30:02 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Fri, 19 Jan 2001 15:30:02 GMT Subject: little standalone windows game References: Message-ID: <_3Z96.74880$y9.13831084@typhoon.we.rr.com> Don wrote: > I'd be interested in hearing about how your solution works and seeing the > code. I too have been searching for a way to create 2.0 standalones > (particularly for Win32) for awhile now. wow, now that is high tech. my version is something similar to that, but its done more "the manual way". i have a starting point directory that includes just about all of python. once the standalone is up and running, the job is to manually delete all the files unneeded by the app (careful guessing). the one extra my version does include is a small booting application that automatically launches a predefined python script. (not a whole lot different than just pythonw.exe really, but owell) one simple change i still want to do it get all the python modules compiled into PYO files (without documentation, etc). this would make the overall filesize a little smaller is my guess. automatically generating the minimal amount of files would be the ideal. i was thinking about creating a small "rexec" python where i could log every import and open() call. it still wouldn't be foolproof for grabbingall the needed files, but i think it would to 99% of the job 99% of the time. > Python is a great language and the full install with all of the libraries is > a very powerful thing, but the difficulty in creating small standalone > distributions is (I think) the biggest issue. i agree, and i see this question asked every single day on the python newsgroup. hmm, perhaps i'll be inspired to continue... :] From root at rainerdeyke.com Wed Jan 10 17:45:31 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 10 Jan 2001 22:45:31 GMT Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> <93dde1$8d2$1@animus.fel.iae.nl> <93f3nb023mv@news1.newsguy.com> <90259DC4Arcamesz@127.0.0.1> <93i57b01qms@news2.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:93i57b01qms at news2.newsguy.com... > "Robert Amesz" wrote in message > news:90259DC4Arcamesz at 127.0.0.1... > [snip] > > >That's one possibility. Syntax such as "bar=32" (for names in the > > >enumlist whose value is explicitly defined) being another > [snip] > > Either way seems rather ugly to me. Why not use tuples to visually > > suggest the link between the value and the string? In this case that > > would make: > > > > xx = enum('foo', ('bar',32), 'fee', ('fie',45), 'flip', 'flop') > > > > It also would be much easier to parse the argument list in that form. > > Fine, but can't be "*much* easier" -- it's just one .split away from > the 'bar=32' proposal to ('bar','32'), after all:-). The problem with 'bar=32' is that it cannot be interleaved with unnumbered args: >>> enum('foo', bar=32, 'fee') SyntaxError: non-keyword arg after keyword arg Even if it could, there would be no way to determine the order of the arguments and therefore no way to find out that 'fee' should have a value of 33. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tim.one at home.com Mon Jan 15 06:28:40 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 15 Jan 2001 06:28:40 -0500 Subject: help retrieving / storing info in dictionary or gadfly In-Reply-To: <93ugt0025hp@news1.newsguy.com> Message-ID: [Bryan Webb] > I have a dictionary that has records with keys from 1 to 2^128 > I can build a list and sort the keys in order, then search thru > the list of sorted keys. > > If the list has 1,2,3,4,5,7,8,9 and I need to search for 6. 6 is > not in the list , so I need the record that is closest to 6 but > not greater than 6. [Alex Martelli] > This is close to what bisect (see 5.5 in the library reference) does > for you, except it gives the index in the sorted list locating the > key closest but not smaller, rather than closest but not greater -- > a number from 0 to len(list), both extremes _included_ -- len(list) > if the key you're looking for is larger than the largest (last) entry > in the sorted list. You presumably want -1 to len(list)-1 [again > extremes included], with -1 if the key is smaller than the smallest > (first) entry. Like most places sequence indices are used in Python, it's tedious to keep straight what bisect does if the return value is viewed as pointing *at* an element, but trivial to keep straight if viewed as pointing *between* elements. A search for 6 in the list should be viewed as returning a pointer to the comma marked by the caret: 1,2,3,4,5,7,8,9 ^ That is, bisect returns the index of the "hole" between the 5 and the 7 (which should make it obvious what a list.insert() does when fed that index back!). With that view in mind, it's clear that a return value of 0 points "before the 1", and a return value of 8 "after the 9": len(list)+1 possible holes, and len(list)+1 possible return values. Bryan would be very well served to stick with that scheme! Trying to make -1 mean "before the start" when 0 already means that to rest of the language will just get him into subtle trouble. Bummer: if the element you're looking for is already in the list, the current behavior of bisect isn't fully specified. It so happens that it reliably returns the index of the hole immediately to the right of the rightmost equal element. In 2.1 this will be documented, and there are new methods bisect_left, bisect_right, insort_left and insort_right that guarantee what happens when finding at least one equal element. > You can wrap bisect.bisect for your purposes, e.g.: > > def locate(list, key): > i = bisect.bisect(list,key) > try: > if list[i]==key: > return i > except IndexError: > pass > return i-1 Note that, because of the above, it's not possible for the list[i]==key test to succeed; e.g., >>> import bisect >>> bisect.bisect([42], 42) 1 >>> Because 2.0 bisect acts like 2.1's bisect_right, the hole index returned is *after* the rightmost equal key. So the test needs to be list[i-1]==key (or, in 2.1, you can use bisect_left instead, and in the example get back 0 -- that's more natural if you're trying to determine whether the element is already there). >> Is there a way to further index the list of keys to do this ? >> >> Could I use GADFLY to do this. > I don't see how you could do better than O(log N) to locate the > key 'closest but not greater', with any auxiliary data structure > of reasonable size, given your range of possible keys. And that > is the performance behavior that bisect.bisect gives you. Come now: 2^128 is only 130 . All right, if he meant 2**128, I agree. speaking-python-in-pythonland-ly y'rs - tim From junaftnoon at nospamplzyahoo.com Tue Jan 2 08:11:30 2001 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Tue, 2 Jan 2001 22:11:30 +0900 Subject: Year of the Snake References: Message-ID: <92sk4i$27$1@news.nuri.net> "chas" wrote in message news:mailman.978426843.19321.python-list at python.org... > June Kim wrote: > > This is the year of the snake according to the 12 zodiacal animal > > signs largely used in most of Asia including Japan, China, and Korea. > > Taking it as a metaphor, Python Users Group in Korea(PyKUG) is pleased > > to announced that this year is "the year of Python" in Korea. > > > > As one way to raise the public interest in Korea, we are planning to > > have the 2nd Python Seminar on Feb/2/2001. Having more than 1,000 > > members joined in last year, we expect to have a larger number of > > audience in the seminar than the first one. > > It's been a lonely few years as I've gone from Malaysia/Singapore > to China/Taiwan and now find myself in HK .... meeting very few > Python guys along the way. So to hear that you've had 1,000 members > join in the last year alone is exciting stuff... We also were very surprised at the large number, when most of us had expected that the number would not go over, at best, a few hundreds. What is more optimistic is almost all of the magazines for developers in Korea are carrying Python articles regularly as if they are competing with each other. > > As luck would have it, I'll be in Korea at that time and would love > to attend ... but with very little Korean language skills, wonder > if it's going to be a problem.... The seminar will be mostly in Korean, but we do have one speech in English: "How Hostway is Using Python" by Lucas Roh, CEO of Hostway. And the most of the presentation will be given visually in English -- but audially in Korean. In addition to that, you could find some evangelists and enthusiasts for Python who speak English, if not as well as their mother tongue though. Best regards, June. From tjreedy at udel.edu Mon Jan 22 15:56:51 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 22 Jan 2001 15:56:51 -0500 Subject: Newbie Question References: <980192858.449719@iris.nyx.net> Message-ID: <94i6f8$o9i$1@news.udel.edu> "sarayu balu" wrote in message news:980192858.449719 at iris.nyx.net... > I just downloaded pygtk-0.6.6 and installed it. > On trying the examples, I am getting an error- > ImportError: /usr/local/lib/python2.0/site-packages/ > _gtkModule.so: undefined symbol: g_thread_init . > I have no clue as to what's going on, is it a gtk > library problem, or python2.0 problem ? Looks like either a library problem (the .so (symbol table) missing a function that should be there) or an interface problem (an attempt to access a function not meant to be there). Doubt its a bug in Py 2 import code. The call traceback listing that came before the ImportError message might illuminate the problem better. Hope someone else can be more helpful with a solution. From andreas at andreas-jung.com Wed Jan 17 02:21:00 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Wed, 17 Jan 2001 08:21:00 +0100 Subject: Command language definition In-Reply-To: <3A6542EC.99ED1149@intes.de>; from fischer@intes.de on Wed, Jan 17, 2001 at 07:59:56AM +0100 References: <3A6542EC.99ED1149@intes.de> Message-ID: <20010117082100.A21854@yetix.sz-sb.de> On Wed, Jan 17, 2001 at 07:59:56AM +0100, Rolf Fischer wrote: > Or is there a combination with another tool that you would recommend ? hm...please be a bit more detailed... Andreas From moshez at zadka.site.co.il Wed Jan 17 11:14:13 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 17 Jan 2001 18:14:13 +0200 (IST) Subject: gettings mounted file systems [newbie] In-Reply-To: References: Message-ID: <20010117161413.E3B19A828@darjeeling.zadka.site.co.il> On Wed, 17 Jan 2001, Langa Kentane wrote: > Greetings gurus. > > I am trying to find a way how I can get a list of mounted file systems using > python. > How would I go about doing this? I have looked into the documentation and > have not found anything to help. Why not parse /etc/mtab? -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From gregj at pobox.com Mon Jan 15 01:58:27 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Mon, 15 Jan 2001 06:58:27 GMT Subject: help retrieving / storing info in dictionary or gadfly References: <93u48n$65t@dispatch.concentric.net> Message-ID: <93u72i$pn9$1@nnrp1.deja.com> I can't think of anything more straightforward and efficient than keeping a sorted list of keys and using a binary search on it. That's what I would do, but I'm interested in the other replies you'll get. In article <93u48n$65t at dispatch.concentric.net>, "Bryan Webb" wrote: > Hello, > I have a dictionary that has records with keys from 1 to 2^128 > I can build a list and sort the keys in order, then search thru the list of > sorted keys. > If the list has 1,2,3,4,5,7,8,9 and I need to search for 6. 6 is not in > the list , so I need the record that is closest to 6 but not greater than 6. > Is there a way to further index the list of keys to do this ? > > Could I use GADFLY to do this. > > Any ideas and help would be appreciated. > > Thanks > bryan Webb > > -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From tim.one at home.com Sun Jan 28 01:07:48 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 28 Jan 2001 01:07:48 -0500 Subject: Thread Safety In-Reply-To: <980660755.2138768834@news.silcom.com> Message-ID: [Clarence Gardner] > I have a multithreaded program in which I use the following pattern in > various places, because I was pretty sure it was thread-safe. But since > I was just reading the thread about statcache, I thought I'd ask > just to be sure. The code is in a function that runs periodically > and disposes of accumulated work: > > def Periodic(): > global PendingDataStorage,PendingStatusUpdates > while 1: > time.sleep(10) > Data,PendingDataStorage = PendingDataStorage,[] > if Data: > StoreDataPoints(Data) > Data,PendingStatusUpdates = PendingStatusUpdates,[] > if Data: > SetErrorStatus(Data) > > The code I'm talking about are the two binding statements, where > I bind to two names which form a tuple, rather than two statements, > which would certainly not be thread-safe. It's impossible to say: "thread safety" is not an absolute judgment, it's relative to the invariants your particular algorithm needs to preserve. As an extreme example, x = 0 def periodic(): global x while 1: time.sleep(.1) x += 1 may very well be thread-safe if the only thing the *rest* of your code cares about is that it never sees an x < 0. In your particular case, why try to be clever at all? The loop doesn't wake up more than once per 10 seconds, so the cost of a mutex lock/unlock pair would be insignificant. In return, you get certainty. cleverness-is-the-#1-cause-of-thread-bugs-ly y'rs - tim PS: >>> import dis >>> def f(): ... x, y = 0, 1 ... >>> dis.dis(f) 0 SET_LINENO 1 3 SET_LINENO 2 6 LOAD_CONST 1 (0) 9 LOAD_CONST 2 (1) 12 BUILD_TUPLE 2 15 UNPACK_SEQUENCE 2 18 STORE_FAST 0 (x) 21 STORE_FAST 1 (y) 24 LOAD_CONST 0 (None) 27 RETURN_VALUE >>> Python executes bytecodes atomically, but makes no guarantees beyond that. Do you still think you're "threadsafe"? From nilswagner at my-deja.com Thu Jan 4 03:17:03 2001 From: nilswagner at my-deja.com (nilswagner at my-deja.com) Date: Thu, 04 Jan 2001 08:17:03 GMT Subject: Season's greetings (was Re: Some Python 2.1 ideas) References: <928otj02l39@news1.newsguy.com> <92dar2$juv$1@nnrp1.deja.com> Message-ID: <931bhs$ol7$1@nnrp1.deja.com> In article , "Dethe Elza" wrote: > > > I also have a teenage son,. His experience is java, C, C++. I found > > that the python project with the biggest zowie! factor was V-python, > > formerly visual python: > > http://sourceforge.net/projects/visualpython > > > > This unfortunately requires a special python, for reasons I find > > specious > > > Not anymore. VPython is updated to Python2.0 and now plays well with > others. > They're working to make the installer easier and provide zip files for the > experienced. > > still-waiting-for-texture-support'ly yrs > --Dethe > > Please can you help me with the installation of Vpython. My operating system is SuSE Linux 7.0. Which libraries are required ? Which version of Python is essential ? Regards, Nils Sent via Deja.com http://www.deja.com/ From shredwheat at mediaone.net Sun Jan 14 12:34:31 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Sun, 14 Jan 2001 17:34:31 GMT Subject: ANNOUNCE: pygame 0.5 Message-ID: Pygame, Python Game Development. Pygame 0.5 released on Jan 6th, 2001 Pygame homepage: http://pygame.seul.org SDL homepage: http://www.libsdl.org Maintainer: Pete Shinners (pete at shinners.org) (all urls at bottom of message) Pygame is a set of python modules written to help create games in Python. The package is wrapped around SDL and several of the SDL daughter libraries. SDL is a cross-platform media library created by Lokigames. SDL is currently used for many commercial and opensource game projects. This pygame binding takes SDL's C interface and turns it into a more pythonic library with objects, exceptions, and some python utility modules. This version 0.5, (release about a month after the previous 0.4) makes many bugfixes and a few small enhancements. At this point the library api has settled into a solid state. The coming plans call for a move to 1.0 within a couple of months. Now is a great time to examine the project and send in feedback. A tally list of pygame features (note, many are also SDL features); Cross platform, with multiple backends (x11, fbcon, svgalib, etc) Fullscreen or windowed accelerated graphics Image loading from popular formats; jpg, bmp, gif, png, etc Access image pixel data as Numeric Python arrays Blitting with colorkey and alpha support Multiple mixing sound channels Streaming music data as mp3, mod, wav, etc CDROM support with audio playback Joystick support Truetype font rendering, with antialiasing Support for multiple threads The pygame package also comes with complete documentation, tutorials, and many playable examples. The pygame mailing list has an active list of users, which makes getting started much more accessable. Pygame is distributed under the LGPL licese, which is the same license used by many its dependencies. There are several types of distributions for download; RPM, Precompiled Win32, and Source. From tim.one at home.com Sat Jan 27 06:09:13 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 27 Jan 2001 06:09:13 -0500 Subject: . Python 2.1 function attributes In-Reply-To: Message-ID: [Roy Katz] > I find this explanation in need of more clarification: > > > You did not address the issue of multiplying entities. I personally > see nothing wrong with function objects; they are light, and we can deal > with them. Why add yet *another* way of doing things? > ... Because the technique you suggest has been available for a decade, yet in practice people refused to use it, preferring instead to abuse docstrings. Have you read the PEP? "Practicality beats purity" in Python: an elegant solution that masses of experienced Pythoneers refuse to use is an excellent predictor of future language change. And, for example, metaclasses are in that boat too. > # note: compared with f(), this implementation is an extra line > > class G: > attr = 0 > def __call__(self): pass > > g = G() long > > ---VERSUS--- > > def f(): > { 'attr':0 } > pass Note that the latter example is a fantasy: it has not been implemented, and I strongly doubt it ever will be. What *is* in the 2.1 codebase (read the PEP) is def f(): pass f.attr = 0 I expect that this way of spelling it is instantly understandable to every Python programmer. The intent is obvious. The point to the convolution in your first way of writing it is well hidden. You've also made life supernaturally easy for yourself by not trying to add an attr to a *method*; in 2.1 it works the same clean way as for a top-level function: >>> class C: ... def meth(self): ... print 42 ... meth.attr = "hi!" ... >>> c = C() >>> c.meth.attr 'hi!' >>> > So the claim here is that saving a line of code justifies carving Python > with Occam's Razor? Say it ain't so! Best I can tell, that one line of code costs about a million brain cells to reverse-engineer every time it appears. Since people have historically refused to do it that way, it's not an idiom, so it's not easy to recognize for anyone save (possibly) its author. Rewrite class C above and see whether even you understand it anymore . > I find the argument for function attributes weak. Guido did too, but strong enough to approve. > Hell, I wish to abolish .__doc__ for functions as well. Fine, don't write docstrings, and run Python with -OO to remove other peoples' documentation too. > It just doesn't seem consistent. Which was an argument in *favor* of adding general function attributes. There's nothing special about func.__doc__ anymore, except the magical way it gets set. > Functions are functions, classes are classes. That's still true. Even better, you'll no longer be tempted to disguise your functions *as* classes just to attach some data to them, and everyone will find your code easier to read as a result. > It seems to me even kludgier than print>>. Barry also added code to Python 2.1 to let you write, e.g., def f() >> x: x = 1 y = 2 as a short way to spell "whatever the value of x is at the end of the function, return that". I'm sure you'll agree that's much cleaner than the clumsy def f(): x = 1 y = 2 return x people suffer with today. hoping-a-truly-bad-idea-adds-some-perspective-ly y'rs - tim From Randy.L.Kemp at motorola.com Wed Jan 31 12:09:12 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Wed, 31 Jan 2001 11:09:12 -0600 Subject: Java-complex numbers Message-ID: <69BC4C6AE83ED311BC9400805FA7B14AF84DC6@il93exp01.css.mot.com> Go to www.northernlight.com, and do a search for "complex numbers in Java." One sight at http://www.icsi.berkeley.edu/~phlipp/wwwipd.ira.uka.de/~gunthner/@index.html says: An example for a Complex class can be found here (this is a reference implementation for complex numbers in Java). This class is part of the com.visualnumerics.javagrande-package, written by members of the JavaGrande Forum. -----Original Message----- From: Jaap Spies [mailto:j.spies at hccnet.nl] Sent: Wednesday, January 31, 2001 9:46 AM To: python-list at python.org Subject: Re: Java-complex numbers Paul Schlyter wrote: > In article <957b1q$m1h$1 at camelot.unirioja.es>, > Jesus Maria Aransay wrote: > > >> I need some help for working in JAVA with complex numbers. >> Could I find some classes or libraries for doing easier my work? > > > You could hack such a class yourself in an hour or two, and it > would be a good experience for you to do it. It would also teach > you that Java isn't really suitable for computation with complex > numbers, because Java cannot overload infix operators. > I agree! > Why do you want to do this? To learn Java? Well, go ahead and do > it! Or because you need to do the computations? If the latter, it's > better to switch to a language with better supoport (either built-in > or through classes) for complex numbers, such as C++ or Fortran. No, no, no! Try Python or Jython http://www.python.org/ http://www.jython.org/ Jaap Spies From sholden at holdenweb.com Wed Jan 10 17:34:57 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 10 Jan 2001 17:34:57 -0500 Subject: default arguments newbie question References: <3a5cccca.77467843@localhost> Message-ID: "Victor Muslin" wrote in message news:3a5cccca.77467843 at localhost... > This behavior of the default list argument seems to be somewhat > counter-intuitive: > > >>> def f(l=[]): > ... l.append(1) > ... print 'id=%d %s' % (id(l), l) > ... > >>> f() > id=8369232 [1] You just used the default empty list for your argument, and appended an item to it. > >>> f() > id=8369232 [1, 1] No argument again, so you use the same default list - and becuase you appended one to it last time, guess what: it now contains two ones! > >>> f() > id=8369232 [1, 1, 1] So now you know why you've got three ones this time. > >>> f([2]) > id=8368384 [2, 1] Good. Now we have an argument, so you append one to the list supplies as an argument. > >>> f() > id=8369232 [1, 1, 1, 1] Damn, we're back to the original default argumnet, and now you've appended FOUR ones to it! > >>> > > If I want a function to print "[1]" every time it is called with no > arguments, do I have to do something like: > > def f(l=None): > if l == None: > print [1] > else: > print l.append(1) > Well, what's this function really supposed to do? Seems to me like you *really* want to print the function's argument which you expect to be a list, with a 1 appended to it . But the function never RETURNS anything. Would you want: l = [33] f(l) f(l) to print [33, 1] [33, 1, 1] and what would you want to be in l at the end? Maybe what you want is: def f(l=None): if l: l.append(1) print l else: print [1] but I'm not sure about that. Also, l.append(anything) returns a value of None, so you shouldn't try to print l.append(1) > What's the acceptable Python idiom for this? > The problem with the code you've given is that the empty list is bound to the default argument when the function is defined, so you get the same empty list for every call with no argument. Since you append to it, the list used as default argument just keeps getting longer and longer! regards Steve From gzeljko at sezampro.yu Fri Jan 26 16:41:16 2001 From: gzeljko at sezampro.yu (gzeljko) Date: Fri, 26 Jan 2001 22:41:16 +0100 Subject: python-2.1 function attributes References: Message-ID: <02d601c087e1$948e77d0$97bd6ac2@zko> Will now class instance become function (method) attribute ? just-curious-newbie From justinhj at hotmail.com Fri Jan 19 13:19:26 2001 From: justinhj at hotmail.com (JustinHJ) Date: Fri, 19 Jan 2001 10:19:26 -0800 Subject: How to run script from interpreter? References: Message-ID: A cool thing I found out solving my own problem is that a module can be a variable. So you want to run a module called 'bobsmodule' str = 'bobsmodule' fp, pathname, description = imp.find_module( modname ) print 'importing module', modname LoadedModule = imp.load_module( modname, fp, pathname, description) LoadedModule.Afunctioninbobsmodule(i) This gives you flexibility if you need it. From aleaxit at yahoo.com Sun Jan 7 16:29:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 7 Jan 2001 22:29:23 +0100 Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> Message-ID: <93an8v02d2n@news1.newsguy.com> "Jonathan Polley" <@collins.rockwell.com> wrote in message news:3A58B9C0.9F2A5CC0 at collins.rockwell.com... > Is is possible to modify the 'enum' function so that I don't have to provide a > class? Sure -- the 'enum' function can define and return a local class, for example. > I would like to just do a: > > MIDI_Event = enum("NOTE_ON", "NOTE_OFF", 3, "POLYPHONIC_KEY_PRESSURE", > "CONTROLLER_CHANGE") > > and then do MIDI_Event.NOTE_ON. One approach might be: def enum(*args): class Enum: pass curval = 0 for arg in args: if type(arg)==type(''): setattr(Enum, arg, curval) curval += 1 else: curval = arg return Enum This assumes a non-string argument (typically an integer, but that's not checked here) is meant to set the value to be named by the string-argument immediately *following* it -- a substantial simplification. So substantial, that if one needed to have non-string arguments signify the value of the *preceding* argument, it might be best to start by bringing about the simpler case first, i.e., right at the start of the function, something like: args = list(args) i = 0 while i On a related note, how would I map between the enumeration and its ordinal value? > Would I add the methods 'ord' and 'val' to the base class > (MIDI_Event.ord(MIDI_Event.NOTE_OFF)) yields 3 and MIDI_Event.val(0) yields > MIDI_Event.NOTE_ON)? I don't get it. MIDI_Event.NOTE_OFF denotes the value 3; why do you want to have MIDI_Event.ord(x) return the same value x that it is passed as argument? If you have 'NOTE_OFF' as a string, you can use it as 2nd argument to getattr, with MIDI_Event as the 1st argument, etc. If you _occasionally_ need to know what string (name) corresponds to a non-string value in the enumeration, a linear search may suffice; however, if MIDI_Event is a class, you cannot easily set up things so that MIDI_Event.nameOf(0) can be called. When functions are set as attributes of a class, they are mutated into unbound methods, which can be called only with a class-instance as the first argument. So, MIDI_Event.nameOf would have to denote a callable that is not a function (e.g., an instance of a class with a __call__ attribute). Not easy or comfortable, though quite possible. But just as you will use a non-method syntax such as getattr(MIDI_Event, 'NOTE_OFF') to find the value corresponding to a name, why not use a similar syntax to find the name corresponding to a value? THAT is easy...: def getnameof(enum, value): for n, v in enum.__dict__.items(): if v==value: return n else: raise ValueError, "value (%s) not found in enum (%s)" % ( value,enum.__name__) I would not bother to think up clever ways to use MIDI_Event.nameOf syntax (although, actually, ensuring MIDI_Event is a class-*instance* object as opposed to a class-*object* would be reasonably easy... and, on instances, method-syntax IS easy to arrange!-). Getting all that fancy in the pursuit of a debatably-appropriate morsel of syntax sugar is a waste of energy! Regarding performance, which IS a bit more important than syntax sugar...: enums are typically small enough that a linear search should yield perfectly acceptable performance, particularly considering that the value-to-name mapping is hardly going to be a very frequent operation. If, later, profiling your application should unexpectedly prove that the getnameof performance is actually a bottleneck for it, it will be reasonably easy to optimize it (by inserting a reverse-lookup dictionary as one of the attributes of the Enum class if and when needed -- this will mean the values have to be hashable, but, as they're meant to be typically integers, that should be no serious problem). However, don't do it unless the need is _proven_ (by profiling carefully, if your application performance is not satisfactory). *Do the simplest thing that could possibly work*... Alex From wlsonna at attglobal.net Wed Jan 3 21:39:56 2001 From: wlsonna at attglobal.net (William Sonna) Date: 4 Jan 2001 02:39:56 GMT Subject: A single, general looping construct? (was: why no "do : until"?) References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <92qc21$538$1@nnrp1.deja.com> Message-ID: <0O7zTzsxerl5-pn2-SISYKtwXTOmR@bill> On Mon, 1 Jan 2001 16:42:42, rturpin at my-deja.com wrote: > In article , > kragen at dnaco.net (Kragen Sitaker) wrote: > > I would want to outdent it because, in my view, it isn't > > part of the loop body; it's part of the loop structure > > itself, just like the while 1: at the beginning. .. > > Hi, Kragen. I see your reasoning, and it reminds me > of something. > > A couple of decades ago, when the programming journals > were full of arguments about the "right" control > statements for structured programming, someone proposed > a single iteration statement that generalized (a) the > "while" statement, (b) the "do .. until" statement, > and (c) the loop with an exit in the middle. I forget > where the paper appeared, the name of the author, and > the exact syntax. But the core idea, in Pythonic syntax, > would look like this: > > do:
while : > > Where , and are code blocks, and is the > conditional. With indentation there are three forms: > > # "while" form > do while : # In this case, make "do" optional > > .. > > # "repeat .. until" form > do: > > while > .. > > # "exit in the middle" form > do: > > while : > # Loop continues at "do" > .. > > I always thought this was a slick solution to the question > of iterative control structures. If the language allows > repetition of the "while : " in the same loop, this > construct provides multiple exits. (I mention this, even > though my first reaction to it is: yuch.) Obviously, the > language could choose to express the exit condition rather > than the loop condition, with a keyword such as "until". > Interesting concept! Thanks for the info. Object Rexx's implementation of the generalized do is the best I've seen (in a real language, that is). Works like this: do count = 1 to 100 /* fixed number of iterations */ yadda yadda end do while count < 100 /* zero or more iterations */ yadda yadda end do until count >=100 /* one or more iterations */ yadda yadda end do i over extent /* iterate over a collection */ yadda yadda end do forever /* you guessed it */ yadda yadda end Since Python substitutes colon plus indentation for "do" and "end", in Pythonese, this would look like: count 1 to 99: # fixed number of iterations yadda yadda while count < 100: # zero or more iterations yadda yadda until count <=100: # one or more iterations yadda yadda count in extent: # iterate over collection yadda yadda forever : # infinite loop yadda yadda Which are all (with the exception of the ones that are identical or nearly identical) cleaner and even more Pythonic than Python. How many new keywords? one (if you can part with the unnecessary "for") or two (if you can't) > My own view is this: I am plenty happy with "while". If > Guido decides to expand the iteration constructs, I would > prefer to see him think about a generalization of the > "while" statement, rather than adding a second and third. > Keep it simple. Less is better than more. One way to do > everything. Etc. > Fortran had even simpler control structures than Python, and was a royal pain to use as a result. Although I enjoy using Python and am generally supportive of its minimalist philosophy, I still believe that the "while 1: buried break" is a step backwards. Many of the classic algorithms are best expressed with "do until" or "repeat until" and translating them into Python requires the introduction of a uniquely inelegant language idiom. From victor at prodigy.net Wed Jan 3 16:59:37 2001 From: victor at prodigy.net (Victor Muslin) Date: Wed, 03 Jan 2001 21:59:37 GMT Subject: Iterating over multiple lists (a newbie question) Message-ID: <3a539f3a.445366109@localhost> This may be rather silly, but I can't think of a clever way... To traverse a single list the code is: for item in list: print item However, if there are multiple lists (of the same length) is there a cleverer way to do the following: for i in range(0,len(list1)): print list1[i], list2[i] I would like something like this (which obviously does not work): for one,two in list1, list2: print one,two TIA From mjackson at wc.eso.mc.xerox.com Tue Jan 2 11:05:48 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 2 Jan 2001 16:05:48 GMT Subject: using 'global' across source files. References: Message-ID: <92su8s$ofo$1@news.wrc.xerox.com> scarblac at pino.selwerd.nl (Remco Gerlich) writes: > No. Right. 'val' should exist in one module only. If you want it to be in > prog.py, funcs.py must import prog, access the variable there, and the code > would look like this: > > # funcs.py > > def change_val(): > import prog > prog.val = prog.val * 2 > > # prog.py > > val=100 > import funcs > > funcs.change_val() > print val > > And the other way around it would look like this: > > # funcs.py > > def change_val(): > global val > val = val*2 > > # prog.py > > import funcs > funcs.val = 100 > > funcs.change_val() > > print funcs.val [from Bram Stolk ] > > Nor can it find it, if I prefix it as '__main__.val'. > > But > > import sys > print sys.modules['__main__'].val > > works Not generally. It "works" iff you use your first example as a script ('python -i prog.py'), only because this happens to create val in the __main__ namespace. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson The power of accurate observation is frequently called cynicism by those who don't have it. - George Bernard Shaw From gregj at pobox.com Wed Jan 24 14:58:02 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Wed, 24 Jan 2001 19:58:02 GMT Subject: Count and replacing strings a texfile References: <94i9ft$apq$1@nnrp1.deja.com> <94llph$8dl$1@nnrp1.deja.com> <94mans01r5p@news2.newsguy.com> Message-ID: <94nc43$n0g$1@nnrp1.deja.com> In article <94mans01r5p at news2.newsguy.com>, "Alex Martelli" wrote: > ... > I like this general approach better than the RE-based > ones; however, building up the 'result' string by > successive concatenations is apt to be pretty slow -- > remember the typical start string was said to be over > 120k and to contain 'several' occurrences of '%id%'. > > In general, building a big string by successive + or > += of many small pieces is O(N squared). I follow the K&R maxim to keep it simple, make it work first, and if it's too slow, speed up the slow parts. If this is a one-off performance is probably of little concern. In my experience with Python doing text processing on lots of little files and a few big ones, I haven't seen any performance problems worth worrying about. But your analysis is correct: successive concatentation of chunks of text is not the most efficient technique, and there is lots of room for speeding up that bit if necessary. Pre-allocating the result string is probably the best and easiest optimization. In this case the maximum size of the result string can be calculated in advance: n = len(original_string) x = number of occurences of %id% resultlen = n - (x * len("%id%")) + (x * len(str(x))) Then just use rstrip() on the result to remove the trailing spaces. Or get the exact length: m = 0 for i in range(1, x+1): m += len(str(i)) resultlen = n - (x * len("%id%")) + m But I'm assuming that allocating the maximum length, then doing one rstrip() on the result string is faster than iterating over the list just to get the exact length. The mathematically inclined can calculate the exact number of characters in the sequence 1..x without iterating over the list. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From JoeSmith at bogusaddress.com Thu Jan 4 02:31:35 2001 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Thu, 04 Jan 2001 07:31:35 GMT Subject: Unexpected result for list operator "+=" Message-ID: <3A542778.E1BC06E3@bogusaddress.com> I unexpectedly get l1 modified by doing "l += l2" (see example 1). I take it is because l and l1 point to the same object. If I use the string type instead of the list type, I don't get l2 modified. I guess that list assignment is an assignment of the reference to the object and it does not copy the object. Where as a string object gets copied (see example 2). example 1: >>> l1 = [0, 1] >>> print l1 [0, 1] >>> l2 = [2, 3] >>> l = l1 >>> print l1 [0, 1] >>> print l [0, 1] >>> l += l2 >>> print l1 [0, 1, 2, 3] >>> print l [0, 1, 2, 3] >>> example 2: >>> s1 = "1" >>> s2 = "2" >>> s = s1 >>> s += s2 >>> print s1 1 >>> From tsachi at richfx.com Wed Jan 24 09:00:28 2001 From: tsachi at richfx.com (Tsachi BZ) Date: Wed, 24 Jan 2001 16:00:28 +0200 Subject: Retriving CPU & memory usage. Message-ID: <94mn4c$ent$1@news.netvision.net.il> I would like to know if there is a way to retrive CPU & Memory usage in python (I'm writing an automatic tool for QA). Thanks in advance, Tsachi. From sholden at holdenweb.com Wed Jan 10 16:54:37 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 10 Jan 2001 16:54:37 -0500 Subject: Lib Directory References: Message-ID: <3U476.459$24.4974@e420r-atl2.usenetserver.com> "Hendrik du Toit" wrote in message news:mailman.979156032.17886.python-list at python.org... > Hi there, > > I am using the mxODBC and mxDateTime modules on Windows NT and Python > 2.0. When the modules are extracted (unzipped) it places the modules on > a ODBC and DateTime directories. It is then instructed to copy these > files to the lib sub directory. I am using the above as an example but > my question is more generic: > > 1. Should I copy the contents of the directory directly to the lib > directory i.e. > Lets say the extraction directory is ODBC with the .pyd modules and > __init__.pyc in this directory and other directories are ODBC\Doc > ODBC\Misc. Should the final result then be to copy the __init__.pyc > file in the d:\python20\lib directory and the rest of the directories > will create a structure called d:\python20\lib\doc & > d:\python20\lib\misc?. No. mxDOBC and mxDateTime are *packages*, not modules, and the __init__.py files (and their compiled variants) inform the system about the structure of the package. > This does not make sense because there is already > a __init__.pyc file in d:\python20\lib and there might be other products > with a doc directory. This will screw up the grouping of the products > in the d:\python20\lib directory or; Correct. You don't want to tangle with this. > 2. Should I copy the entire ODBC sub directory to d:\python20\lib so > that I have d:\python20\lib\odbc with __init__.pyc located in this > directory and the rest of it will be d:\python20\lib\odbc\doc & > d:\python20\lib\misc? If the later is the case, will python > automatically find the .pyc modules in these sub directories or should I > set dome environment variables? > Consider creating a "site-packages" subdirectory in D:\Python20\Lib. Then create a D:\Python20Lib\sitecustomize.py file containing: import site site.addsitedir(r"D:\Python20\Lib\site-packages") The relevant subset of my directory tree looks like this: D:\Python20 Lib site-packages DateTime ODBC Pmw Each of the subdirectories of D:\Python20\Lib\site-packages has its own __init__.py, declaring the structure of the package. > I am a willing reader. If anybody can point me to some documentation > about this I will go a find it there. > > Regards, > Hendrik > The current documentation at the end of section 6.11 says: """[XXX Can't be bothered to spell this out right now; see the URL http://www.python.org/doc/essays/packages.html for more details, also about how the module search works from inside a package.] """ regards Steve From fakeaddress at nospammail.com Mon Jan 29 01:05:58 2001 From: fakeaddress at nospammail.com (Ben Catanzariti) Date: Mon, 29 Jan 2001 17:05:58 +1100 Subject: Pythonpath in Windows References: Message-ID: Try looking at "sys.path" in the python docs ... this may help "Mike Callahan" wrote in message news:bc5d6.199994$iy3.48342380 at news1.rdc1.tn.home.com... > I would like to get my windows python 2.0 to be able to import any script > that is in the current working directory. Do I need to add '.' to the > pythonpath in the registry? Is that the only thing? > > Mike Callahan > > > From fgeiger at datec.at Sun Jan 21 04:11:36 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Sun, 21 Jan 2001 10:11:36 +0100 Subject: Blackadder - any opinions? References: <94c6cu$hl2$1@bob.news.rcn.net> Message-ID: <94e923$2qp$1@newsreaderm1.core.theplanet.net> Had a quick look on it at their site, but miss a debugger. While I'm waiting for Komodo to be released as a 1.0 version I keep using PythonWin. This holds for dev on NT. I don't know how dev'ing on Unix, though. Best reagrds Franz "Satheesh Babu" wrote in message news:94c6cu$hl2$1 at bob.news.rcn.net... > Hi, > > I saw this Python IDE at > http://www.thekompany.com/products/blackadder/ > > Personal edition is $49. Just wondering anybody had any > experience with that before I think of buying it. > > Screenshots look good though the site is damn too slow! > > Babu > > -- > v.s.babu > vsbabu at erols.com > http://vsbabu.csoft.net > > From alain at onesite.org Wed Jan 10 13:06:28 2001 From: alain at onesite.org (Alain TESIO) Date: Wed, 10 Jan 2001 19:06:28 +0100 Subject: Please help with feeding a popen2 pipe with a large input References: Message-ID: Carsten Gaebler wrote > This is because you never read the output of the pipe, > so cat's STDOUT fills up and blocks which keeps cat > from reading from STDIN which fills up and blocks, too. It hangs when I'm trying to read from stdout : total length is 249866, bufsize is 1000 writing from 0 to 999 ...ok Reading out ... It works fine with a limited output from wc instead of cat, when I'm reading stdout and stderr after stdin in closed. What's the difference between os.popen3 and popen2.popen3, except the parameter order is not the same ? Alain Here's the script attempting to read stdout : def MyPipe(command,string_in): bufsize=1000 import popen2 (pipe_out,pipe_in,pipe_err)=popen2.popen3(command,bufsize*2) # (pipe_in,pipe_out,pipe_err)=os.popen3(command,bufsize*2) l=len(string_in) sys.stdout.write("total length is %i, bufsize is %i\n" % (l,bufsize)) start=0 end=0 string_out="" string_err="" while end >From 2.0 manual, 5.7: '''A right shift by n bits is defined as division by pow(2,n). A left shift by n bits is defined as multiplication with pow(2,n); for plain integers there is no overflow check so in that case the operation drops bits and flips the sign if the result is not less than pow(2,31) in absolute value. Negative shift counts raise a ValueError exception.''' Why shouldn't negative shifts just mean a shift in the opposite direction? To avoid confusion? Becuse there's only way way to do things in Python? E.g., 16 << -2 seems like it might well be defined as 16 >> 2. Cheers! Chris Ryland, President * Em Software, Inc. * www.emsoftware.com From fredrik at effbot.org Sat Jan 20 07:16:59 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 20 Jan 2001 12:16:59 GMT Subject: BeOpen 2.0 vs PythonWare References: <94btrs$4rr$1@news.adamastor.ac.za> Message-ID: <%kfa6.7751$AH6.1222557@newsc.telia.net> James Lockley wrote: > > hey, you forgot one: the PythonWare PY20 distro: > > > > http://www.pythonware.com/downloads.htm > > > > i found i couldn't add win32all to it though.... (is that just a directory > naming issue?) iirc, it's caused by the +/- doesn't mess with the registry/system directory item. I think we have a fix in the works (watch the site for updates) Cheers /F From aleaxit at yahoo.com Fri Jan 19 09:00:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 19 Jan 2001 15:00:36 +0100 Subject: How to get method's arguments References: Message-ID: <949haa02cil@news1.newsguy.com> "Victor Black" wrote in message news:t6gedbl259o724 at corp.supernews.com... > 1.How does IDLE show the argument list of a method or procedure. > e.g when you write "dir(" a hint writing "dir([object]) -> list of strings" > pops up. > (The sources are available but overwhelming) Python's reflection/introspection powers are good, but, here, what is involved is rather the documentation-string that gets attached to each Python function (and several other objects) if the author bothers to put it in. A function object has an attribute named __doc__, containing its documentation-string (or None, if no docstring). E.g.: def foo(bar): "foo(number) -> a bigger number" return bar+1 Now, foo.__doc__ is bound to the string "foo(number) -> a bigger number". The same string is also bound to attribute foo.func_doc (I don't know why in this case there are two ways to access the same data -- I may be missing something!). If you wish, you can also truly find out about a function's arguments from within Python. foo.func_code is bound to the code-object which the funtion runs. Each code-object X has some useful attributes, such as: X.co_argcount number of arguments X.co_varnames local variable names; the first X.co_argcount ones are the names of the *arguments* X.co_flags has bit 4 set if X accepts arbitrary args with the *args syntax; bit 8 set, if it accepts arbitrary named args with **kwds syntax And, back to the function-object we mentioned, foo.func_defaults is bound to the tuple of default values for the function's arguments, so you also know which ones are optional! Note that the optional arguments, if any, are always the _last_ (rightmost) len(foo.func_defaults) ones. But I don't think IDLE really needs to get into these introspection issues -- I suspect it can get away with just the docstring (I have not checked its sources to check exactly what it _does_ do for tip-displaying purposes). Alex From chris at voodooland.net Sun Jan 21 18:03:41 2001 From: chris at voodooland.net (Chris Watson) Date: Sun, 21 Jan 2001 17:03:41 -0600 (CST) Subject: patch for python configure for freeBSD and Zope In-Reply-To: <01012211280401.00887@localhost.localdomain> Message-ID: > Hi, I'm using freeBSD 4.2-RELEASE and just tried to install python-1.5.2 and > Zope. If you are trying to do the same and tun into the following error when > trying to start zope, then apply this patch to the configure script of python > and rebuild it. > > ImportError: ./ExtensionClass.so: Undefined symbol "PyMethod_Type" Matt, Is this an error in the port itself of python? Python 2.0 is in ports as well as zope. If there is a problem with either port can you give more detail so the apropriate maintainer can be notified. Thanks! -- ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= GNU = Gnu's Non-portable & Unstable irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From tim at degree.ath.cx Fri Jan 26 20:48:30 2001 From: tim at degree.ath.cx (Tim Hammerquist) Date: Sat, 27 Jan 2001 01:48:30 GMT Subject: .cgi or .cgp or .py or ? References: Message-ID: Oleg Broytmann wrote: > > described. (Obviously, P*** didn't need this sort of promotion to > > succeed, and neither does Python.) > > Then Python, you think, succeed by itself, just by its existence? I > think you are wrong :) We need to develop the language and the core, > libraries and communities. We certainly should promote Python. Of course it doesn't succeed by virtue of its existence, but what I said was, neither Perl nor Python need "this sort of promotion" to succeed. Nor did I say we shouldn't promote Python. And to the OP's question: use whichever extension works best for you, at least as far as the main script is concerned. Imported modules need the .py (or .pyc) to be imported correctly. -- -Tim Hammerquist Diplomacy -- the art of saying "Nice doggie" 'til you can find a stick. -- Wynn Catlin From dan.rolander at marriott.com Wed Jan 17 08:13:21 2001 From: dan.rolander at marriott.com (Dan Rolander) Date: Wed, 17 Jan 2001 08:13:21 -0500 Subject: how to run a DOS program without getting a box? References: <3A64E195.ECA51312@cableinet.co.uk> Message-ID: <026401c08087$4469ab50$11260340@yin> Richard (and Richard), pythow.exe is fine if you want to run a python script without starting a console window, but if you want to launch external programs from within a python script here is how to do it: If you are starting a Windows application, first get the Win32 extensions at http://www.activestate.com/Products/ActivePython/win32all.html. Then import win32api and use WinExec() like this: >>> import win32api >>> win32api.WinExec("notepad") If you want to launch a DOS application, and don't want a console window but you do want to capture stdout, you can just import os and use popen() like this: >>> import os >>> test = os.popen("c:\\test.bat") >>> for L in test.readlines(): ... print L ... D:\Documents\Dan\PythonScripts\projects\pineapple>echo This is a test This is a test I hope this helps you! Dan ----- Original Message ----- From: "Richard Chamberlain" Newsgroups: comp.lang.python To: Sent: Wednesday, January 17, 2001 2:13 AM Subject: Re: how to run a DOS program without getting a box? > There is a file called pythonw.exe which is python without the command box. > > Richard > > Richard Dobson wrote in message > news:3A64E195.ECA51312 at cableinet.co.uk... > > Hi all, > > > > I have tried both os.system() and the exec~ calls, and they all cause > > the Windows console to display when running a command-line program (in > > my case, to play a soundfile I don't need to see the screen messages). > > Is there a way to suppress this? Other languages, such as tcl/tk and GNU > > Octave manage this fine. I'm using Python 2.0 under Windows2000 (sp1), > > with IDLE. > > > > > > Richard Dobson > > > > > > > > > > -- > > Test your DAW with my Soundcard Attrition Page! > > http://www.bath.ac.uk/~masrwd (LU: 3rd July 2000) > > CDP: http://www.bath.ac.uk/~masjpf/CDP/CDP.htm (LU: 23rd February 2000) > > > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Wed Jan 24 13:54:20 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 24 Jan 2001 13:54:20 -0500 Subject: python-2.1 function attributes References: Message-ID: <94n7tu$41c$1@news.udel.edu> "Mike Romberg" wrote in message news:ul3snm8dfae.fsf at smaug.fsl.noaa.gov... > > I've been messing around with python-2.1a1 and have discovered the > new feature 'function attributes'. The project I'm currently working > on can really use this feature. > http://python.sourceforge.net/peps/pep-0232.html Not having read the PEP, I wondered 'what is this good for?' when I read GvR's announcement. The PEP gives three possible uses. Is your use something different? (that you can tell us?) Now having read the PEP, it occurs to me that this could be used to supply optional type information to a compiler without any of the ugly syntax changes that have been proposed and so far rejected. # example of function with identified parameter and return type information from type import * def f(a,b): pass f.argtypes = {'a':IntType, 'b':ListType, 'f':StringType} Someone wanting to experiment along this line need only fix on an attribute name and syntax and proceed without any further approvals. Terry J. Reedy From tim.one at home.com Fri Jan 26 02:42:55 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 26 Jan 2001 02:42:55 -0500 Subject: Why isn't crypt.py in Win32 Python distribution? In-Reply-To: <6176E3D8E36FD111B58900805FA7E0F80CCF6323@mcnc-mdm1-ex01> Message-ID: [Dan Rolander] > Just curious. Why isn't crypt.py included in the standard python > distribution for Windows? There's no crypt.py in any distribution of Python. There's a C module, cryptmodule.c, which is not compiled on Windows, because it relies on a non-standard external C function extern char * crypt(const char *, const char *); that comes with Unix C libraries but is not supplied by Microsoft's C runtime. So the only way it will ever show up on Windows is if someone contributes an unencumbered Windows implementation. From vecernik at aon.at Fri Jan 26 05:06:56 2001 From: vecernik at aon.at (Oliver Vecernik) Date: Fri, 26 Jan 2001 11:06:56 +0100 Subject: proxy server Message-ID: <3A714C40.D3E0D684@aon.at> Hi all, has anybody ever written a small proxy server in python for logging http protocol between client and server? I need it for debugging a http client development for an embedded system. Oliver From aleaxit at yahoo.com Wed Jan 17 18:06:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 00:06:39 +0100 Subject: help with code for combinations/permutations References: <944adl$2bf@dispatch.concentric.net> <944opo$2b9@dispatch.concentric.net> Message-ID: <9458l301fs0@news2.newsguy.com> "Andreas Jung" wrote in message news:mailman.979764021.20668.python-list at python.org... > On Wed, Jan 17, 2001 at 06:37:44PM +0000, Bryan Webb wrote: > > Thanks to all that responded. > > > > I wasnt as clear as I should have been. (as usual) > > I really need to come up with all the possible sums of the numbers in the > > list ie. 1 , sum(1 + 2), sum(1 + 2 + 3) ,sum( 1+2+4),sum( 1 + 3) and so on. > > Ok, now you are talking about subsets but not of permutations. Because the > order of the elements does not matter there are much fewer possibilities. I Specifically, a N-element set has 2**N subsets including the trivial ones. > suggest to make an example by hand: take a set of 4 elements and generate all > subsets by hand. Then you will learn how such an algorithm should work. Come on, it's much easier than that! class Subsets: def __init__(self, alist): self.list=alist def __getitem__(self, n): L = len(self.list) if n>=(1< Hello! How to make scripts allowing to log on my site and to store this info since the user will logout from my site! How to write chat scripts with user logins? Is need to write tsr script? Yours QdlatY From fredrik at effbot.org Sun Jan 14 13:01:47 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sun, 14 Jan 2001 18:01:47 GMT Subject: how do i disable buffered output, like Perl's '$|=1'? References: <979490967.23219.0.pluto.d4ee691b@news.demon.nl> <93so5m$biirv$1@ID-11957.news.dfncis.de> <979494993.24992.0.pluto.d4ee691b@news.demon.nl> Message-ID: floR wrote: > Not exactly what I meant, I think. It does exactly what you want -- but sure, there are other ways to do the same thing: > Okay, what I want to do in particular, is to send 'print' commands to the > browser in intervals, without buffering, something like the following: > + import sys > print 'Content-type: text/html\n\n' > countdown = 10 > while countdown: > print countdown > countdown = countdown - 1 + sys.stdout.flush() # flush output buffers > sleep(1) > > so that the countdown seems to happen in your browser, instead of waiting > for 10 seconds for the string '10 9 8 7 6 5 4 3 2 1' to appear. (this assumes that your server sends data to the client as soon it arrives from the CGI script, of course). Cheers /F From zippy1984 at my-deja.com Fri Jan 26 05:33:01 2001 From: zippy1984 at my-deja.com (zippy1984 at my-deja.com) Date: Fri, 26 Jan 2001 10:33:01 GMT Subject: win32com.client - need some help References: <94mjj8$v3g$1@nnrp1.deja.com> <94mrs102b3i@news2.newsguy.com> <94pa5c$aqb$1@nnrp1.deja.com> <94pni302k2g@news2.newsguy.com> Message-ID: <94rjot$cbk$1@nnrp1.deja.com> > > > > HRESULT getDictionary([out] IDispatch** pDictionary); > > [id(0x12345678)] > > Unusual ([out] is generally [out,retval]) but OK. Well, I do get a return value, but not what I expected..... So, I don't know if this is important. > > What happens if you do a dir(dic.__class__) -- what methods > does this class expose? IS it a makepy-generated class? If > it isn't, then there's some trouble brewing. > Right you are.... : >>> dic = ob.getDictionary() >>> dir(dic.__class__) ['__doc__', '__module__', '_wrap_dispatch_'] >>> dic.__class__.__module__ 'win32com.client' >>> print dic.__class__.__doc__ The dynamic class used as a last resort. The purpose of this overriding of dynamic.CDispatch is to perpetuate the policy of using the makepy generated wrapper Python class instead of dynamic.CDispatch if/when possible. >>> ...I guess this is not what I wanted to see...? What is causing these problems? Is it a "poor" definition in the COM server that does not give win32com enough information? Is there any way working around this? I do not have access to sources for the COM server, so if it is responsible for the troubles then I do have a problem. regards, Tom Sent via Deja.com http://www.deja.com/ From sholden at holdenweb.com Wed Jan 17 05:36:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 17 Jan 2001 05:36:53 -0500 Subject: access FoxPro files without ODBC References: <943qu9$hde$1@nnrp1.deja.com> Message-ID: <8Fe96.5294$DI.58645@e420r-atl1.usenetserver.com> wrote in message news:943qu9$hde$1 at nnrp1.deja.com... > This is a newbie question... > > But after browsing Python Library reference, > Python FAQ, and comp.lang.python, I have not been > able to determine if there is a way to access FoxPro files without ODBC > available for Python. > > any help appreciated > > Thanks > > Godefroid Chapelle > BubbleNet sprl > Louvain-la-Neuve Belgium > As a newbie (welcome aboard, by the way) you will come to value a web site known as the Vaults of Parnassus (http://www.vex.net/parnassus/), which contains many useful Python modules and programs. Take a look at http://www.vex.net/parnassus/apyllo.py?find=foxpro -- I think this will suit your needs quite well. (Note also it uses Python to search its database). Good luck! regards Steve From tim.one at home.com Sat Jan 13 15:13:29 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 13 Jan 2001 15:13:29 -0500 Subject: A small suggestion for Python In-Reply-To: <93p4oh$919$1@newsreaderg1.core.theplanet.net> Message-ID: [Franz GEIGER] > Another idea: It could return what we all excpect to be returned: > The object that was sorted! As a general rule, in Python, methods that alter a mutable object in-place return None, not the object. list.sort() is only one such. list.insert() and list.append() and list.extend() and list.reverse() and list.remove() and dict.update() and dict.clear() and ... are others. > So if a list is sorted, why not return the sorted list? Because Guido doesn't want to <0.9 wink>. Python has been consistent along a a different axis for 10 years (see above). Returning the sorted list wouldn't help, either: you might stop complaining, but we'd get an at least equal number of new complaints about, e.g., >>> y = x.sort() >>> y.append(42) WHY DID THAT CHANGE WHATS IN X??? I DIDN'T CHANGE X! I CHANGED Y AS ANY IDIUT CAN SEE. STUPID LANGWAGE IN PURL THE SORT FUCTION DOSNT DO THAT!!! HOW CAN ANYONRE USE THE PHYTON WHEN ITS SO STUPID. (BTW, that's what all complaints look like to Guido ) In a world where different people want different things at different times, we can't stop complaints -- we can only choose *which* complaints we want to endure. Your complaint is easy to endure, because it's easily addressed *by* you: def sort(list): list.sort() return list Use that instead, if you're not prone to making the aliasing mistakes that leads to. Or, if you are, change your little sort function to make a copy before sorting, and live with the extra memory burden. It's your choice to make, and Guido helps lead you to that realization by making the return value from mutableobject.mutator() maximally useless <0.7 wink>. most-improvements-aren't-ly y'rs - tim From grante at visi.com Thu Jan 18 13:54:58 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 18 Jan 2001 18:54:58 GMT Subject: Python training on east coast? References: <947bh2$hug$1@nnrp1.deja.com> Message-ID: <6_G96.490$eI2.163803@ruti.visi.com> In article <947bh2$hug$1 at nnrp1.deja.com>, Mark Hammond wrote: >> Are there any Python training courses on the east coast? > >I believe some can be found in both Sydney and Melbourne. I saw pythons at a wildlife park just outside Cairns, but I don't think they were trained. -- Grant Edwards grante Yow! My FAVORITE group at is "QUESTION MARK & THE visi.com MYSTERIANS"... From emile at fenx.com Fri Jan 19 19:32:47 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 19 Jan 2001 16:32:47 -0800 Subject: Deployment woes (was: I will kill my Python) References: <947r18$rdt$1@news.online.de> <4DE7F9DB9399A3C1.D96FC6EFB3F2391E.88AD1775E4555FCA@lp.airnews.net> Message-ID: <94amdf$crs81$1@ID-11957.news.dfncis.de> And Microsoft, not being one to miss a marketing opportunity... http://msdn.microsoft.com/library/techart/dlldanger1.htm -- Emile van Sebille emile at fenx.com ------------------- "David Bolen" wrote in message news:un1cn12yc.fsf at ctwd0143.fitlinxx.com... > claird at starbase.neosoft.com (Cameron Laird) writes: > > > I defer to those with more certain knowledge. I find > > Win* habits too esoteric for my comprehension; that's > > as definite as I can be. > > There's a technical term for this process under Windows - "DLL hell" :-) > > -- > -- 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 MarkH at ActiveState.com Tue Jan 2 19:48:18 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 03 Jan 2001 00:48:18 GMT Subject: Memory leak References: <92t8gp$blv$1@nnrp1.deja.com> Message-ID: <3A5275B8.3020208@ActiveState.com> alex116321 at my-deja.com wrote: > I am experiencing memory leakage when using Python and COM. > Specifically, I am using the Micosoft XML Parser to load and traverse > XML DOM stuctures. Everytime I access an XML node, more memory is > consumed. After a while, this can eat away most of the system > resources if the Python session is not terminated. Here is a simple > example (assume the interpreter is used as a server and does not exit): You don't say what version of anything. With the latest versions, (and using "xrange" instead of range) I see no leaks at all - perfectly flat memory usage. Mark. From cookedm at physics.mcmaster.ca Mon Jan 22 10:10:38 2001 From: cookedm at physics.mcmaster.ca (David M. Cooke) Date: 22 Jan 2001 10:10:38 -0500 Subject: SVG Tools? References: Message-ID: At some point, msrisney at rocketmail.com wrote: > I've been messing about with a collection of Perl modules, > and scripts related to dynamic SVG generation. > Are there any equivilant Python efforts out there ?, > anybody up for a SVG project? > > marc risney Biggles also has support for saving to SVG (through the use of the GNU plotutils): http://biggles.sourceforge.net -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke |cookedm at mcmaster.ca From NoSpam at NoSpam.com Fri Jan 19 01:19:18 2001 From: NoSpam at NoSpam.com (Tom) Date: Fri, 19 Jan 2001 06:19:18 GMT Subject: Python calls Trace Handler fn within call to PyObject_Str References: <3RM96.183472$59.49047774@news3.rdc1.on.home.com> <94871m$bpo$1@nnrp1.deja.com> Message-ID: "Mark Hammond" wrote in message news:94871m$bpo$1 at nnrp1.deja.com... > In article <3RM96.183472$59.49047774 at news3.rdc1.on.home.com>, > "Tom" wrote: > > > > My C++ module calls the PyObject_Str function, as so: > > > > PyObject* pPyStr = PyObject_Str( m_pPyObject ); // New Ref > > > > Stepping through the code in my debugger, I see that beneath > (or 'within') > > this call, Python is calling my trace handler function. The trace > event is > > a 'call'. Is this normal behavior? > > If the process of converting the object to a string calls .py code, > then yes. I thought it didn't, but looking closer, you're right - that was my problem. Thanks. Tom. > Mark. > > > Sent via Deja.com > http://www.deja.com/ From MarkH at ActiveState.com Tue Jan 16 14:55:16 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 16 Jan 2001 19:55:16 GMT Subject: Building a Python OCX References: <9423o8$309$1@nnrp1.deja.com> Message-ID: <9428uv$87i$1@nnrp1.deja.com> In article <9423o8$309$1 at nnrp1.deja.com>, John Urberg wrote: > Is it possible to build a visual Python OCX control? Currently not. > Can I access Python objects thru OLE? > How complex is it? It is quite simple to create "standard" COM objects using Python and access them from any other language. However, the extra interfaces and complexity required by a true OCX is currently far from trivial. Mark. Sent via Deja.com http://www.deja.com/ From sholden at holdenweb.com Thu Jan 11 21:13:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 11 Jan 2001 21:13:10 -0500 Subject: boolean xor References: <93ace8$nmo$1@panix3.panix.com> <93i7ne$5dk$1@nnrp1.deja.com> <93i9ff$q4l$1@slb0.atl.mindspring.net> <93iuj9$jta$1@slb3.atl.mindspring.net> <93jls9$v12$1@slb3.atl.mindspring.net> <93kofr01bg2@news1.newsguy.com> <61t76.2471$6i.33339@e420r-atl2.usenetserver.com> Message-ID: "Steve Holden" wrote in message news:61t76.2471$6i.33339 at e420r-atl2.usenetserver.com... > "Alex Martelli" wrote in message > news:93kofr01bg2 at news1.newsguy.com... > > "Steve Holden" wrote in message > > news:Tbi76.10504$X3.66627 at e420r-atl1.usenetserver.com... > > [snip] > > > A possibly salient point which hasn't been explicitly stated in this > > thread > > > (but might have been, seventeen days ago, my aging memory and general > > > decreptitude being what it is) is that the binary logical operators > > > short-circuit, and return the value of the last operand they evaluated. > > Even > > [ ... ] > >>> for A, B in (["", ""], ["", 't'], ['t', ''], ['t', 't']): > ... print tf(A), tf(B), tf(xor(A, B)) > ... > 0 0 1 > 0 1 0 > 1 0 0 > 1 1 1 > > Yup, that appears to do it. Still, returning that "1" doesn't seem very > Pythonic. Can;t think of anything else to do, however, since not (either > argument) will give 1 anyway in that case. > Well, I warned you about the decrepitude. What this returns, of course, is precisely the logical converse of what it should. The truth table we actually want is: 0 0 0 0 1 1 1 0 1 1 1 0 This is good, though, because the implicit None return will give us what we need in the final case. Here we go, with an added display of the real values: >>> def xor(A, B): ... if not A: return B ... if not B: return A ... >>> for A, B in ([[], ()], [[], 't'], ['t', ()], ['t', 't']): ... print tf(A), tf(B), tf(xor(A, B)), A, B, xor(A, B) ... 0 0 0 [] () () 0 1 1 [] t t 1 0 1 t () t 1 1 0 t t None This seems a little more Pythonic, and has the added advantage of producing a logically correct result. Can we go further? helps-if-you-don't-assume-martellibot-infallibility-but-it's-a-good-bet-ly y'rs - steve From donn at u.washington.edu Wed Jan 24 13:03:37 2001 From: donn at u.washington.edu (Donn Cave) Date: 24 Jan 2001 18:03:37 GMT Subject: Thread interruption References: Message-ID: <94n5dp$op6$1@nntp6.u.washington.edu> Quoth "David Allen" : ... | My question is, how do I interrupt threads? In each | thread, there will be blocking system calls happening, | and I need to be able to interrupt the threads very | quickly. This is not something where select() is | the answer, because I'm worried about blocking | from gethostbyname() and other socket related stuff | too. See last week's subject "threading: how to kill a (possibly blocked) thread?" In summary, you can't. Not in Python's thread support, and not portably in any language. Processes are a lot better than threads for some of this kind of thing. On one hand they are susceptible to the kind of control you want to exert, and on the other hand they exit in a cleaner and more reliable way when you do it. For example, any file descriptor opened by the subprocess will close, and resources like network mbufs will get reclaimed. It is not a drop-in solution, but if you can do the work it can be more robust. | On a completely unrelated note, I thought python | threading was done within one process, and that | the threading code had to deal with "timeslicing" | between all the threads that actually belonged to | one process. But checking the output of 'ps' on | running a threaded python program, actually 4-5 | instances of the interpreter seem to be running when | I'm using threads. What gives? Could be a platform quirk. Python doesn't implement its own threads, and while your idea of how it would work sure matches mine, I guess it's possible that "ps" could show threads separately. I know they do show up in the BeOS ps, but specifically as threads that are executing within the single Python process ("team"). Donn Cave, donn at u.washington.edu From grante at visi.com Fri Jan 19 16:51:55 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 19 Jan 2001 21:51:55 GMT Subject: Why no isexec, isread, iswrite, etc (was: I must be missing something obvious: os.path.isexecutable?) References: Message-ID: <%F2a6.926$eI2.260005@ruti.visi.com> In article , Steve Lamb wrote: >>[Same answer if you're going to try to write or exec a file.] > > It is? I didn't say it was a _good_ answer. ;) > What if you want to check to ensure something is executable before >actually symlinking as a sanity check? That's the problem with the "standard answer": there are times that you want to check to see if something is XXXX-able without actually doing XXXX because doing XXXX might have some nasty side-effects. You just want to do the best you can to insure that at the appropriate time (at which point there might not be anybody around to see the error message), doing XXXX will work. Your example is a good one: you want to check that a script is executable so that you can change/modify configuration info, but actually exec'ing the script would be a bad thing. -- Grant Edwards grante Yow! I am a traffic light, at and Alan Ginzberg kidnapped visi.com my laundry in 1927! From kragen at dnaco.net Sun Jan 7 21:31:55 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Mon, 08 Jan 2001 02:31:55 GMT Subject: simple symbolic math in Python Message-ID: I posted most of this to kragen-hacks late last millennium. I'm running into a problem: I can overload unary minus, but I can't overload e.g. math.sin and math.cos, because they're not methods. It would be really nice to have a way to do that. I can create objects that act just like dictionaries or files, including working with almost all of the built-in functions, but it doesn't look like I can create objects that look just like numbers. I'm thinking about implementing promises (aka deferred references) as in E as well; I'm still reading the E documentation. I hope folks enjoy this. # Kragen Sitaker, 2000-12-30. # Some simple symbolic math. # Allows you to add, subtract, etc., simple formulas -- using the ordinary # Python operations. Implements all of the standard arithmetic operations. # Once you have a formula, you can print it out as a string, evaluate it # for particular values of its variables, call 'simplified()' to get a # simplified version, check to see if it's exactly identical to some other # formula, or (in some cases --- if you've used only +, -, and *, and # fixed exponents) take its symbolic derivative. See the test() # routine at the end for details. Symbolic derivatives will generally # need to be simplified() to taste very good. # Not intended for serious use; it's just a quick hack I wrote this afternoon. # Some things it might be fun to add: # - a compile() method that returns a Python code object that would give you # faster evaluation # - a continued-fraction output mode a la HAKMEM # - symbolic derivatives that cover more operations # - better simplifications ( ((x + x) + (2 * x)) should simplify to (3 * x) ) # - unary operations: negation, transcendentals # - better printing: a + b + c + d should print as a + b + c + d, not # as (((a + b) + c) + d) # - other symbolic manipulations import math # things inherit from Formula to get the glue that turns Python # expressions into representations of expressions class Formula: def __complex__(self): return complex(self.eval({})) def __int__(self): return int(self.eval({})) def __long__(self): return long(self.eval({})) def __float__(self): return float(self.eval({})) def __pos__(self): return self # positive def __neg__(self): return Unop('-', self) def __add__(self, other): return Binop('+', self, other) def __radd__(self, other): return Binop('+', other, self) def __sub__(self, other): return Binop('-', self, other) def __rsub__(self, other): return Binop('-', other, self) def __mul__(self, other): return Binop('*', self, other) def __rmul__(self, other): return Binop('*', other, self) def __div__(self, other): return Binop('/', self, other) def __rdiv__(self, other): return Binop('/', other, self) def __pow__(self, other): return Binop('**', self, other) def __rpow__(self, other): return Binop('**', other, self) # one out of place: syntactic sugar for 'eval' # this lets me say f.where(x = 2) instead of f.eval({'x':2}) def where(self, **vars): return self.eval(vars) def constant(expr): return isinstance(expr, Constant) # simplify an addition expression by dropping zeroes def simplify_add(a, b): if a.identical(mkf(0)): return b elif b.identical(mkf(0)): return a # and this is the point at which we abandon pretenses of OO correctness elif isinstance(b, Unop) and b._op == '-': return (a - b._arg).simplified() else: return a + b # simplify a multiplication expression by dropping ones and converting # 0 * anything to 0 def simplify_multiply(a, b): if a.identical(mkf(0)) or b.identical(mkf(0)): return mkf(0) elif a.identical(mkf(1)): return b elif b.identical(mkf(1)): return a elif a.identical(mkf(-1)): return (-b).simplified() elif b.identical(mkf(-1)): return (-a).simplified() else: return a * b def simplify_subtract(a, b): if b.identical(mkf(0)): return a elif isinstance(b, Unop) and b._op == '-': return (a + b._arg).simplified() else: return a - b def simplify_power(a, b): if b.identical(mkf(0)): return mkf(1) elif b.identical(mkf(1)): return a else: return a ** b DerivativeError = "Can't differentiate" def power_derivative(base, exp, var): if not exp.derivative(var).simplified().identical(mkf(0)): raise DerivativeError, ("too dumb for varying exponent", exp, var) return exp * base ** (exp - 1) * base.derivative(var) # Binary operation class class Binop(Formula): opmap = { '+': lambda a, b: a + b, '*': lambda a, b: a * b, '-': lambda a, b: a - b, '/': lambda a, b: a / b, '**': lambda a, b: a ** b } def __init__(self, op, value1, value2): self.op = op self.values = mkf(value1), mkf(value2) def __str__(self): return "(%s %s %s)" % (self.values[0], self.op, self.values[1]) def eval(self, env): return self.opmap[self.op](self.values[0].eval(env), self.values[1].eval(env)) # the partial derivative with respect to some variable 'var' derivmap = { '+': lambda a, b, var: a.derivative(var) + b.derivative(var), '-': lambda a, b, var: a.derivative(var) - b.derivative(var), '*': lambda a, b, var: (a * b.derivative(var) + b * a.derivative(var)), '**': power_derivative }; def derivative(self, var): return self.derivmap[self.op](self.values[0], self.values[1], var) # very basic simplifications simplifymap = { '+': simplify_add, '*': simplify_multiply, '-': simplify_subtract, '**': simplify_power}; def simplified(self): values = self.values[0].simplified(), self.values[1].simplified() if constant(values[0]) and constant(values[1]): # this is kinda gross return mkf(Binop(self.op, values[0], values[1]).eval({})) elif self.simplifymap.has_key(self.op): return self.simplifymap[self.op](values[0], values[1]) else: return Binop(self.op, values[0], values[1]) def identical(self, other): return (isinstance(other, Binop) and other.op == self.op and other.values[0].identical(self.values[0]) and other.values[1].identical(self.values[1])) class Unop(Formula): opmap = { '-': lambda x: -x, 'sin': lambda x: math.sin(x), 'cos': lambda x: math.cos(x) } def __init__(self, op, arg): self._op = op self._arg = mkf(arg) def __str__(self): return "%s(%s)" % (self._op, self._arg) def eval(self, env): return self.opmap[self._op](self._arg.eval(env)) # note that each of these entries implicitly contains the chain rule; # that's bad and should be fixed. derivmap = { '-': lambda x, var: -x.derivative(var), 'sin': lambda x, var: x.derivative(var) * cos(x), 'cos': lambda x, var: -x.derivative(var) * sin(x) } def derivative(self, var): return self.derivmap[self._op](self._arg, var) def identical(self, other): return isinstance(other, Unop) and self._arg.identical(other._arg) def simplified(self): simplearg = self._arg.simplified() if constant(simplearg): return mkf(Unop(self._op, simplearg).eval({})) if (self._op == '-' and isinstance(simplearg, Unop) and simplearg._op == '-'): return simplearg._arg.simplified() else: return Unop(self._op, simplearg) def cos(f): return Unop('cos', f) def sin(f): return Unop('sin', f) class Variable(Formula): def __init__(self, name): self._name = name def eval(self, environment): return environment[self._name] def __str__(self): return self._name def derivative(self, var): if self._name == var._name: return mkf(1) else: return mkf(0) def identical(self, other): return isinstance(other, Variable) and other._name == self._name def simplified(self): return self class Constant(Formula): def __init__(self, value): self._value = value def eval(self, env): return self._value def __str__(self): return str(self._value) def derivative(self, var): return mkf(0) def identical(self, other): return isinstance(other, Constant) and other._value == self._value def simplified(self): return self # make formula def mkf(value): if type(value) in (type(1), type(1L), type(1.5), type(1j)): return Constant(value) elif type(value) is type("hi"): return Variable(value) elif isinstance(value, Formula): return value else: raise TypeError, ("Can't make formula from", value) # syntactic sugar so you can say vars.foo instead of mkf('foo') or # Variable('foo') class Vars: def __getattr__(self, name): return Variable(name) vars = Vars() def test(): assert mkf(2365).eval({}) == 2365 one = mkf(1) assert str(one) == '1' assert one.eval({}) == 1 assert isinstance(one + one, Formula) assert (one + one).eval({}) == 2 assert str(one + one) == '(1 + 1)' x = vars.x assert isinstance(x, Variable) assert x.eval({'x': 37}) == 37 assert (one + x).eval({'x': 108}) == 109 assert str(one + x) == '(1 + x)' got_error = 0 try: x.eval({}) except KeyError: got_error = 1 assert got_error assert (1 + one).eval({}) == 2 assert (2 * mkf(3)).eval({}) == 6 assert (mkf(2) * 3).eval({}) == 6 assert (14 - one).eval({}) == 13 assert (one - 14).eval({}) == -13 assert int(one) == 1 seven = (14 / mkf(2)) assert isinstance(seven, Formula) assert seven.eval({}) == 7 assert float(seven) == 7.0 assert int(+one) == 1 got_error = 0 try: z = mkf(test) except TypeError: got_error = 1 assert got_error two_to_the_x = (2 ** x) assert str(two_to_the_x) == '(2 ** x)' assert two_to_the_x.eval({'x': 20}) == 1048576 assert two_to_the_x.where(x=20) == 1048576 assert (x ** 2).eval({'x': 13}) == 169 formula = (x + 1)/((x * x) - +two_to_the_x) assert str(formula) == '((x + 1) / ((x * x) - (2 ** x)))', str(formula) assert (x / 1).eval({'x': 36}) == 36 assert long(one) == 1L assert complex(one) == 1+0j i = mkf(1j) assert complex(i) == 1j y = vars.y minusx = -x assert minusx.where(x = 5) == -5 assert (-minusx).simplified().identical(x) assert str(minusx) == '-(x)' assert not minusx.identical(x) assert minusx.identical(-x) assert not minusx.identical(-y) cosx = cos(x) assert cosx.where(x = 0) == 1 assert cosx.where(x = 1) != 1 assert x.derivative(x).simplified().identical(mkf(1)) assert x.derivative(y).simplified().identical(mkf(0)) assert (x * y).derivative(x).simplified().identical(y) assert (x + y).derivative(x).simplified().identical(mkf(1)) assert (x - y).derivative(x).simplified().identical(mkf(1)) assert two_to_the_x.simplified().identical(two_to_the_x) assert (2 * x).derivative(x).simplified().identical(mkf(2)) assert (x ** 0).simplified().identical(mkf(1)) assert (x ** 1).simplified().identical(x) assert (x ** 2).derivative(x).simplified().identical(2 * x) assert minusx.derivative(x).simplified().eval({}) == -1 assert cosx.derivative(x).where(x = 0) == 0 assert (-1 * x).simplified().identical(-x) assert (x * -1).simplified().identical(-x) assert (mkf(2) * 3 * 4).simplified().identical(mkf(24)) assert (-mkf(1)).simplified().identical(mkf(-1)) assert (-(1 * cos(x))).simplified().identical(-cos(x)) sinx = sin(x) assert (-(-(mkf(1)) * sinx)).simplified().identical(sinx) one = mkf(1) assert (-one * (one * (-one * x))).simplified().identical(x) assert (1 - -x).simplified().identical(1 + x) assert (1 - - - -x).simplified().identical(1 + x) test() -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From grey at despair.rpglink.com Wed Jan 3 17:10:36 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Wed, 03 Jan 2001 22:10:36 -0000 Subject: variable inirialization and loop forms (was Re: why no "do : until"?) References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4D6A05.EEC97FA6@uswest.net> <92v6m002nlr@news2.newsguy.com> Message-ID: On Wed, 3 Jan 2001 13:40:38 +0100, Alex Martelli wrote: >Initializing variables *to correct values* is a great thing -- but using >*arbitrary* values for the initialization isn't optimal style. You know, Alex, that is why I enjoy reading your responses do me. You never come off like you're preaching, only teaching. I still stand that initting a variable is just that, setting it to a known, arbitrary value. >This matters! For example, the getCurrentTemperature function *might* >smooth actual point-measurements (which 'wobble') by averaging with >the previously-measured value; Then don't do it that way. Given other considerations, yes, other forms are optimal. But to unilaterally state that it is bad to do something under all conditions gets people in more trouble than it gets them out of. >*IF AND WHEN* there are NO costs in testing in the while >statement, sure. Then why not take the other extreme; remove the test in the loop. Remove for, remove while, remove any other's I've missed. loop: do something if break condition: break There, no argument over while 1:, for (;;;), do/while, while/do, while true, endless, zippity-do-da, snaglefarf, poo or any other such key word. A loop is a loop is a loop and arguing semantics of that loop and its construction is utterly meaningless since the logical conclusion is simple, enter a loop, break out of it when needed, no test condition in the loop itself. 1: while loop: if foo: break do something 2: for loop: if blah = x break do something blah += step 3: for x in y, foreach x (y) loop: blah = list.pop(0) if not blah: break do something 4: do while/until loop: do something if foo: break >But often there ARE some costs: when a loop WANTS to be an "N-and-a-half >times loop", the general form, then coding it as such (which in Python is >expressed by while 1/...break) produces simpler and therefore better code >than making believe the idiom isn't available. I'm not saying it isn't available, I'm pointing out that for those who didn't like it there was something else that could be done. But hey, as I stated above, why not just get rid of all the different loop keywords and just do it the want that provides the lest amount of variance if maintainability is the only consideration one has? If there is often a cost in a loop wanting to be something that it is not then why try to confine people to 3-4 cutesy keywords and let them just build each loop as needed by providing one keyword to loop over code. Seems far simpler for maintainability in the long run if often we're not using the keywords. Hell, we could even take that further. If found that we have else on while and for to be useful. So why not have break also allow an optional return value? But wait, why have else on a loop at all? Why not just remove else on loop and allow the optional return value (else on a loop being really an if) through an exception and a try: block? Seems to be that is more versitile than an else keyword attached to a loop which only takes one condition, doesn't it? So with that we've gotten rid of for/else, while/else and also given people a method of making whatever loop, loop and a half, loop and half twist with a triple gainer in the middle that they want. I mean, if the semantics of it all is more important than actually getting work done, right? :) Oh, and to stave off those that do dislike while 1: and similar constructs... Don't kid yourself, having a test condition in te while is no more or less reliable than having the test condition elsewhere in the loop unless it is something independant where you're going to place an arbitrary limit on the iterations over the loop and actually keep track. A while foo: loop that never modifies foo is just as endless as while 1: and both can be aborted with an if:break. So a "loop: if:break" construct is functionally identical to a while condition: consutruct and no amount of semantical arguing will change that. We done now? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From gbell at uclink.berkeley.edu Wed Jan 24 19:12:28 2001 From: gbell at uclink.berkeley.edu (gbell at uclink.berkeley.edu) Date: Thu, 25 Jan 2001 00:12:28 GMT Subject: newbie question: table-like data Message-ID: <94nr15$5rk$1@nnrp1.deja.com> I'm new to Python (and to programming) -- working my way through _Learning Python_ at the moment. As an exercise, I want to write a program that will help me keep track of recipes I like (including ingredients), plan menus over an arbitrary period, and print the appropriate shopping list. Question: is there a customary way to create, manipulate & query database tables in Python? Is there a module that does this? Thanks for your patience. Gregory Bell gbell at uclink.berkeley.edu Sent via Deja.com http://www.deja.com/ From othello at javanet.com Wed Jan 17 23:56:20 2001 From: othello at javanet.com (Raymond Hettinger) Date: Wed, 17 Jan 2001 23:56:20 -0500 Subject: how to run a DOS program without getting a box? References: <3A64E195.ECA51312@cableinet.co.uk> Message-ID: <3A667773.C00AC40B@javanet.com> Dan Rolander wrote: > If you are starting a Windows application, first get the Win32 extensions at > http://www.activestate.com/Products/ActivePython/win32all.html. Then import > win32api and use WinExec() like this: > > >>> import win32api > >>> win32api.WinExec("notepad") How do you call built-in DOS commands or pass arguments? win32api.WinExec("time 23:30") doesn't do the trick :( > If you want to launch a DOS application, and don't want a console window but > you do want to capture stdout, you can just import os and use popen() like > this: > > >>> import os > >>> test = os.popen("c:\\test.bat") Interesting that this works from the command prompt but fails inside the PythonWin environment. The error message is: WindowsError: [Errno 2] The system cannot find the file specified From victor at prodigy.net Thu Jan 4 14:55:43 2001 From: victor at prodigy.net (Victor Muslin) Date: Thu, 04 Jan 2001 19:55:43 GMT Subject: Iterating over multiple lists (a newbie question) References: <3a539f3a.445366109@localhost> Message-ID: <3a54d0c5.523585234@localhost> Thank you all for the insights. Here is another variation on the them, though this involves a single list. Suppose I want to parse command line arguments (never mind getops, since this could be some other situation not involving command line arguments). Here is how I could possibly parse command line arguments for command: "myprog -port 10 -debug": import sys debug = port = 0 i = 1 # ugly while i < len(sys.argv): if sys.argv[i] == '-debug': debug=1 elif sys.argv[i] == '-port': i = i + 1 # ugly! if i < len(sys.argv): # very ugly! port = int(sys.argv[i]) i = i + 1 # quite ugly Pretty ugly, huh? Is there a more elegant way? On Wed, 03 Jan 2001 21:59:37 GMT, victor at prodigy.net (Victor Muslin) wrote: >This may be rather silly, but I can't think of a clever way... > >To traverse a single list the code is: > > for item in list: > print item > >However, if there are multiple lists (of the same length) is there a >cleverer way to do the following: > > for i in range(0,len(list1)): > print list1[i], list2[i] > >I would like something like this (which obviously does not work): > > for one,two in list1, list2: > print one,two > >TIA From cerutti at together.net Thu Jan 25 15:10:40 2001 From: cerutti at together.net (Neil Cerutti) Date: 25 Jan 2001 20:10:40 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: Fredrik Lundh posted: >Neil Cerutti wrote: >> My advice, although I've got limited experience, is to go with >> Tkinter, and read the following great document, by Python Labs' >> Fredrik Lundh: > >footnot: I work for Secret Labs, also known as PythonWare. > >(for some reason, someone thought it would be a good idea to >create a new company name from two of our trademarks...) > >Cheers /F Sorry. I'm still proud that I spelled your name correctly. -- Neil Cerutti From rturpin at my-deja.com Mon Jan 15 15:48:02 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Mon, 15 Jan 2001 20:48:02 GMT Subject: Web devel with python: Best route? XML to HTML translation! References: <93cqvi0191h@news1.newsguy.com> <93hfp1013sm@news2.newsguy.com> Message-ID: <93vnlv$2qq$1@nnrp1.deja.com> In article <93hfp1013sm at news2.newsguy.com>, "Alex Martelli" wrote: > All the presentation logic goes into the template, all of > the computation into the Python CGI script, and my little > yaptu.py (yet another python template utility, of course) > bridges the gap .. That's pretty good. It seems to me there is a better way. (1) The server scripts in Python generate XML. This is pretty easy to do with xmlpickle. (2) Use an XML to HTML filter to generate the HTML. Let the repitition of values in XML guide the repitition of the relevant sections of HTML. The advantage to this is that the same server side scripts can be used to generate XML (for downstream processing by another script) or HTML (for presentation in browsers). Does anyone know of any good XML to HTML filters for this purpose? Russell Sent via Deja.com http://www.deja.com/ From sholden at holdenweb.com Thu Jan 4 10:58:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 4 Jan 2001 10:58:55 -0500 Subject: isnumeric (mhlib.py) References: <3A548B2A.B45DC580@cs.utwente.nl> Message-ID: Richard van de Stadt wrote in message news:3A548B2A.B45DC580 at cs.utwente.nl... > Hi, > > I needed a function to check if a string is a number. > mhlib contains a function called isnumeric(), so I > used that one. This is how it determines if a string > is a number: > > numericprog = re.compile('^[1-9][0-9]*$') > def isnumeric(str): > return numericprog.match(str) is not None > > However, this way, '0' is not regarded as a number. > Is that what isnumeric is supposed to do? > Well, I suppose the obvious answer is that what you see is good enough for mhlib's purposes, so at worst you might complain that the function isn't very well named. Of course the code doesn't document its purpose well, so you fell in the hole. > I don't know what the meaning of isnumeric for mh is, > but why isn't numericprog simply like this: > > numericprog = re.compile('^[0-9]*$') > > Richard. > Again, if that will do for your purposes then go ahead and use it -- although I suspect you might not want the empty string to be considered a number, in which case you might prefer the pattern to be '^[0-9]+$' which will insist on seeing at least one digit. I seem to remember there was a long discussion on validating numerics some time ago on this list. A lot depends on how rigorous you want to be, whether you are interested in integers, long integers, reals or complexes, etc. If this is a test which is performed infrequently (such as, for example, when analyzing lines of interactive input) probably the best approach is to ask Python to convert using an explicit conversion function such as int() or float(), trapping errors and handling them appropriately. Apart form anything else, this allows you a) to be sure the number is acceptable to Python in the appropriate context, since value checking will also be performed, and b) to avoid the import of a module you may not otherwise need. regards Steve From jkraska1 at san.rr.com Mon Jan 15 03:39:23 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 15 Jan 2001 08:39:23 GMT Subject: is Python fully object oriented ? References: Message-ID: > C++ is too complicated. At the moment, it's impossible for me > to write portable code that I believe would work on lots of different > systems, unless I avoid all exotic features. Whenever the C++ > language designers had two competing ideas as to how > they should solve some problem, they said "OK, we'll do them both". > So the language is too baroque for my taste. > >I formed the impression that he prefers to use WEB or CWEB for >programming. Since he also uses Emacs for editing, he presumably can >also handle the odd bit of Lisp. Lisp is veritably overflowing with "OK, we'll do them both" features, however. Look at flow-control primitives, for example. C// From aleaxit at yahoo.com Thu Jan 4 16:48:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 22:48:37 +0100 Subject: Alex Martinelli's solution to regular expression/findall problem References: Message-ID: <932rdu010lb@news1.newsguy.com> "Heather Lynn White" wrote in message news:mailman.978630484.1210.python-list at python.org... > > Your searchall function is just what I needed and it will sit happily in > my library. Thanks alot. You're welcome, but my surname happens to be spelled "Martelli"...:-). Alex From rbeer at uni-goettingen.de Wed Jan 17 08:46:31 2001 From: rbeer at uni-goettingen.de (Ragnar Beer) Date: Wed, 17 Jan 2001 14:46:31 +0100 Subject: XREF tool? Message-ID: <3A65A235.468D582E@uni-goettingen.de> Howdy! Does anybody know if there's a cross reference tool available for Python? Ragnar From NOstarfighterSPAM at freeuk.com Fri Jan 26 17:29:36 2001 From: NOstarfighterSPAM at freeuk.com (Richard Townsend) Date: Fri, 26 Jan 2001 22:29:36 -0000 Subject: Python2.0 and Pmw 0.8.4 counter problem References: <3A71D728.EE4B9F03@icestormfx.com> Message-ID: > We used Python1.5 with Pmw 0.8.3 to develop an in-house application. For some > reasons, we changed to Python2.0 and we decided to use the new Pmw version ( > 0.8.4 ). In our application, we have a Pmw.Counter of integers and it doesn't work > anymore. The behaviour is strange : if we type a new integer in the entry field, > everything is fine. But using the arrows ( left or right, up or down ) just clean > the entry field, without updating its content. I try the demos in the Pmw > distributions and they don't work either. We installed Python1.6 with Pmw 0.8.3, and > it still doesn't work !!! I tried all the other types of counters and they all work > fine, but the integer. > > Anybody has a suggestion ? > I posted the same question a few months ago and got the following solution from Roberto Amorim > Hi, to correct it is simple. You'll have to edit PmwCounter.py. Here it > is: > > - Find the function called _changeNumber() (line 273) > - On line 279 there's the return statement for this function. Change it > to return str(value) (and not return str(value)[:-1]) > > That ocurred because str(long) on Python 2.0 doesn't return a number > with L on the end like Python 1.5.2 did. > regards, Richard Townsend From gregj at pobox.com Tue Jan 23 23:34:09 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Wed, 24 Jan 2001 04:34:09 GMT Subject: Count and replacing strings a texfile References: <94i9ft$apq$1@nnrp1.deja.com> Message-ID: <94lm01$8mv$1@nnrp1.deja.com> In article , Moshe Zadka wrote: > On Mon, 22 Jan 2001 21:42:21 GMT, puckoh at my-deja.com wrote: > > counter = 0 > def replace(_): > global counter > counter += 1 > return counter > > id_re = re.compile('%id%') > > s = open(file).read() > s = id_re.replace(s, replace) I think you mean re.sub(replace, s)... replace() is a similar method for string objects, but it doesn't accept a function for the replacement string. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From xyzmats at laplaza.org Thu Jan 18 10:59:02 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Thu, 18 Jan 2001 15:59:02 GMT Subject: Python training on east coast? References: Message-ID: <3a6711b0.2563646@news.laplaza.org> On Thu, 18 Jan 2001 14:45:43 GMT, Robert L Hicks wrote: >Are there any Python training courses on the east coast? See http://www.learningtree.com/us/ilt/courses/430.htm Classes are regularly scheduled in Washington D.C., New York and Boston. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From amk at mira.erols.com Tue Jan 16 20:39:13 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 17 Jan 2001 01:39:13 GMT Subject: Web devel with python: Best route? XML to HTML translation! References: <93cqvi0191h@news1.newsguy.com> <93hfp1013sm@news2.newsguy.com> <93vnlv$2qq$1@nnrp1.deja.com> <3A6412BC.A07C547@stroeder.com> Message-ID: On Tue, 16 Jan 2001 10:22:04 +0100, Michael Str?der wrote: >In theory this is a good way. But how about the performance? Last >time I played with a Python-written XSLT processor it was pretty >slow. If you're referring to 4XSLT, note that its authors devoted a fair bit of effort to optimizing recent versions started with 0.9.2, improving performance by a factor of 10 to 100. See http://lists.fourthought.com/pipermail/4suite/2000-July/000221.html --amk From luthi at vaw.baug.ethz.ch Thu Jan 18 11:23:07 2001 From: luthi at vaw.baug.ethz.ch (luthi at vaw.baug.ethz.ch) Date: 18 Jan 2001 17:23:07 +0100 Subject: emacs / autocompletion References: Message-ID: This will give you some autocompletion, not only of Python variables, but of anythin in any of your buffers (type the key several times in order to cycle throug all possibilites). (global-set-key [f3] 'dabbrev-expand) (put this in your .emacs file, choose another key than f3 if you like) this-time-elisp-ingly-instead-of-python-ingly-yours Martin L?thi From moshez at zadka.site.co.il Sat Jan 6 05:39:38 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 6 Jan 2001 12:39:38 +0200 (IST) Subject: How robust is Python ? In-Reply-To: <9358nn$3c5$1@nnrp1.deja.com> References: <9358nn$3c5$1@nnrp1.deja.com>, <9354f9$vbi$1@nnrp1.deja.com>, Message-ID: <20010106103938.8FCAFA84F@darjeeling.zadka.site.co.il> On Fri, 05 Jan 2001, rturpin at my-deja.com wrote: > Unfortunately, cron is not cross-platform. We'll have > some sort of mechanism to do this. The problem is not > just the language and operating system, but everything > that can kill a process. Still .. you want such mechanism > as backup, not as a solution to regular crashes. Of course. None of this is meant to imply Python crashes regularily. In fact, I can't think off-hand of a language less likely to suffer crashes, given that you take a few exception-catching precautions in the main loop (have a catch-all except: which re-execs the process). Perl will probably have so many "it might be undefined here" problems that I certainly wouldn't trust it, Java's implementations are usually buggy and C/C++ core dump at the drop of a pointer. Maybe Tcl can be an alternative as far as reliability is concerned -- though I think data-structures in Tcl are more prone to memory leakages then Python, based on some experience (2-3 months writing Tcl extensions proffessionally). Quite possibly, good Scheme implementations (say, scheme48) can outdo Python here. Maybe good Common Lisp (cmucl, or the commercial ones) can do better too. But I think a Python + auto-restart will be good enough for anything short of a life-support system, and the pragmatics of Python win big here. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From bwaskiew at indiana.edu Sun Jan 14 00:31:28 2001 From: bwaskiew at indiana.edu (Brian Waskiewicz) Date: Sun, 14 Jan 2001 00:31:28 -0500 Subject: storing passwords Message-ID: <93rdmr$ihu$1@flotsam.uits.indiana.edu> I have a Python script that makes a Telnet connectio to a remote server and right now I have the password just stored within my code. I'd don't like the idea of leaving the password available like that (the script runs automatically every night, so I can't prompt the user for it), so is there any other way to store the password in some kind of encrypted fashion?? Also, is it possible to implement an FTP server in Python (has this already been done)? Brian Waskiewicz bwaskiew at indiana.edu ____________________________ From ullrich at math.okstate.edu Sun Jan 21 09:21:57 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 21 Jan 2001 14:21:57 GMT Subject: pyXML support for XSL tranformations?? References: <94d1tj$6sa$1@nnrp1.deja.com> Message-ID: <3a6aef10.3738521@nntp.sprynet.com> On Sat, 20 Jan 2001 22:02:31 GMT, Chris Ryland wrote: [...] > >The Fourthought people (www.fourthought.com) also have an open-source >XSLT processor written in Python. I was gonna say that but I wasn't sure they'd got something that would work with the latest version of Python. I have the 4Thought XSL stuff from a little while ago. When I installed it I had to replace the current (1.5.2) Python xml.dom with one that came with 4Thought, which I gather was an older version. I didn't like this but I did it and it works fine. Q: Does the current 4Thought XSL stuff get along a little more _cleanly_ with Python? (I actually haven't got around to getting Python 2.0 precisely because it took a little tweaking to get the XSL going in 1.5.2...) >-- >Chris Ryland * Em Software, Inc. * www.emsoftware.com > > >Sent via Deja.com >http://www.deja.com/ From mail at codex.pe.kr Fri Jan 5 18:54:28 2001 From: mail at codex.pe.kr (Ahn, Jae-wook) Date: Sat, 6 Jan 2001 08:54:28 +0900 Subject: RGB to HSV conversion using PIL? Message-ID: <935mu3$4qg$1@news1.kornet.net> Hi. Using PIL, how can I convert RGB color space to HSV? According to manual, RGB can be converted to LAB using matrix calculation, but I have no idea of using matrix for color space conversion. Is anyone able to post the matrix for HSV color conversion? Thank you. From michael at stroeder.com Wed Jan 10 04:34:10 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 10 Jan 2001 10:34:10 +0100 Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: <3A5C2C92.C85A3DE8@stroeder.com> Robin Becker wrote: > > What percentage of modules really needs mxDateTime? The answer is of > course 0% or 100% depending on your point of view. 0% in my case. But the reason is that personally I try to avoid modules not part of the standard library to reduce the amount of third-party modules people have to install to use my software. Therefore my decision to use it or not is not independent from the decision to add it to the standard lib. Ciao, MIchael. From tdelaney at avaya.com Thu Jan 11 19:11:33 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 12 Jan 2001 11:11:33 +1100 Subject: boolean xor Message-ID: Actually, I think it should work the other way. Because it is not *always* possible to return one of the arguments, xor should never return either of the arguments. This is the path of least-astonishment. There's just no way to short circuit xor. Your proposed method presumably continues as def xor(A,B): if not A: return B if not B: return A return 0 This may be better (returning only requires the implementation detail of returning a reference), but it can also be worse (need to evaluate 2 values after dereferencing them, plus then need to return a *different* reference). I remember hashing this out on comp.lang.c quite a few years ago now ... Tim Delaney Avaya Australia +61 2 9352 9079 > -----Original Message----- > From: Alex Martelli [mailto:aleaxit at yahoo.com] > Sent: Friday, 12 January 2001 3:53 AM > To: python-list at python.org > Subject: Re: boolean xor > > > "Steve Holden" wrote in message > news:Tbi76.10504$X3.66627 at e420r-atl1.usenetserver.com... > [snip] > > A possibly salient point which hasn't been explicitly stated in this > thread > > (but might have been, seventeen days ago, my aging memory > and general > > decreptitude being what it is) is that the binary logical operators > > short-circuit, and return the value of the last operand > they evaluated. > Even > > Bingo -- I *was* starting to think I should post about that. > For least- > astonishment purposes, I'd thus like the xor function to > behave similarly: > return either A or B if at all possible (it may not be, of course, if > both A and B are true). E.g., > > def xor(A,B): > if not A: return B > if not B: return A > > (perhaps too cutesy in the attempted symmetry and in relying on the > default fall-off-the-end to avoid an explicit return None...). > > > Alex > > > > -- > http://www.python.org/mailman/listinfo/python-list > From fredrik at effbot.org Thu Jan 25 16:49:18 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 25 Jan 2001 21:49:18 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: Vadim Zeitlin wrote: > This is very strange. Where is good documentation for > Tkinter to be found? on my newsserver, his post included pointers to John Grayson's book and the pythonware docs. maybe you flamed away before reading the entire post? Cheers /F From sheila at thinkspot.net Sat Jan 20 00:57:03 2001 From: sheila at thinkspot.net (Sheila King) Date: Sat, 20 Jan 2001 05:57:03 GMT Subject: Translating a Perl script into Python Message-ID: As part of my learning exercises, I've been attempting to translate a short perl script into Python. I don't really know Perl, but when I was attempting to learn how to use the .qmail files at my web host and run scripts on it for filtering, etc... the sysadmin posted a sample script in Perl to give me an idea what some of the possibilities might be. I think I understand the Perl script well enough to try to translate it. So, here I will present the two scripts: (1) The original Perl script written by the sysadmin at my web host, and (2) my attempt at a Python translation. I've already tested it, and the output files are identical. I'm curious about style or good programming type comments. Note: the identifiers SENDER NEWSENDER RECIPIENT USER HOME HOST LOCAL EXT EXT2 EXT3 EXT4 DTLINE RPLINE UFLINE are environment variables passed by .qmail to the script. Here is the original Perl script: ------------------------------------------------------------ #!/usr/local/bin/perl @slurp = <>; @qmail = qw(SENDER NEWSENDER RECIPIENT USER HOME HOST LOCAL EXT EXT2 EXT3 EXT4 DTLINE RPLINE UFLINE); open PROC, ">proc.test" || die "Couldn't open file for write: $!"; $id = `/usr/bin/id`; print PROC "ID: $id\n"; print PROC "Environment Variables\n"; foreach $key (@qmail) { print PROC "$key = $ENV{$key}\n"; } print PROC "\nSlurp\n"; print PROC @slurp; close PROC; ------------------------------------------------------------ Here is my Python translation: ------------------------------------------------------------ #! /big/dom/xthinkspot/Python-2.0/python import sys, os, commands slurp = sys.stdin.read() qmail = ["SENDER", "NEWSENDER", "RECIPIENT", "USER", "HOME", "HOST", "LOCAL", "EXT", "EXT2", "EXT3", "EXT4", "DTLINE", "RPLINE", "UFLINE"] try: PROC = open("proc.test","w") except: sys.stderr << "Couldn't open file for write\n" raise id = commands.getoutput("/usr/bin/id") PROC.write("ID: "+id+"\n\n") PROC.write("Environment Variables\n") for key in qmail: PROC.write(key + " = " + os.environ[key] + "\n") PROC.write("\nSlurp\n") for line in slurp: PROC.write(line) PROC.close() ------------------------------------------------------------ I appreciate all comments, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From jp at NOSPAMdemonseed.net Fri Jan 19 00:22:13 2001 From: jp at NOSPAMdemonseed.net (jason petrone) Date: Fri, 19 Jan 2001 05:22:13 +0000 Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> Message-ID: <5ui849.666.ln@demonseed.net> Chris Ryland wrote: > Why do I have the sinking feeling that, with all the talk about IDEs > for Python, that the cognoscenti all use Emacs with python-mode and a > shell window? ;-) Maybe we will see a day when Emacs scripts can be written in python instead of elisp. Maybe then functions in my ~/.emacs will make sense for months after I write them instead of minutes. happily-scripting-vim-in-python-and-not-wearing-out-my-(-and-)-keys-yours, jason From news at dorb.com Wed Jan 31 22:06:51 2001 From: news at dorb.com (Darrell) Date: Thu, 01 Feb 2001 03:06:51 GMT Subject: serial port References: <3a78ca89_2@skyweb.ca> Message-ID: For windows check this out. win32comport_demo.py --Darrell "mike" wrote in message news:3a78ca89_2 at skyweb.ca... > is there any modules for serial port communication? > > From mhammond at my-deja.com Tue Jan 9 20:18:09 2001 From: mhammond at my-deja.com (Mark Hammond) Date: Wed, 10 Jan 2001 01:18:09 GMT Subject: Can we in python code, catch exception generated by C++ pythonized function? References: <3A5A4545.661385AD@aristotech.com> Message-ID: <93gd8d$las$1@nnrp1.deja.com> In article <3A5A4545.661385AD at aristotech.com>, Siu-Tong Hui wrote: > I tried and it won't. Anybody have any workaround for that? Any pointer > is appreciated. Thanks. I tried and it will. Anybody have any further details for that? Any pointer to exactly what you mean is appreciated. Thanks. Sent via Deja.com http://www.deja.com/ From smibr at my-deja.com Tue Jan 23 14:32:13 2001 From: smibr at my-deja.com (smibr at my-deja.com) Date: Tue, 23 Jan 2001 19:32:13 GMT Subject: PIL Example Message-ID: <94km7t$caq$1@nnrp1.deja.com> When I run the following example from the PIL documentation, the traceback indicates an attempt to redefine "fill" in line xx. Has the mechanism for passing named parameters changed in 2.0? Thanks. import Image, ImageDraw im = Image.open("lena.pgm") draw = ImageDraw.Draw(im) draw.line((0, 0) + im.size, fill=128) draw.line((0, im.size[1], im.size[0], 0), fill=128) del draw # write to stdout im.save(sys.stdout, "PNG") Sent via Deja.com http://www.deja.com/ From andrew_dot_henshaw_at_earthling_dot_net Mon Jan 15 20:48:11 2001 From: andrew_dot_henshaw_at_earthling_dot_net (Andrew Henshaw) Date: Mon, 15 Jan 2001 20:48:11 -0500 Subject: why no "do : until"? References: <90278A4rcamesz@127.0.0.1> <3A5F264D.4D7C024A@gte.net> <3A633415.47D71944@gte.net> Message-ID: It looks like we're pretty close to agreement. Like you, I believe that a conditional with a 'while' is easier to explain to new users. Conversationally, I can say to my 10-year old, "while the value here (pointing at the screen) is less than the value here (pointing at the screen), execute these lines (pointing at the block) over and over." However, it wouldn't be as easy to explain 'while 1' as it is to explain 'do' for an infinite loop (that can only be *broken* out of). In fact I think 'do' makes the concept of 'break' easier to explain. To first introduce 'break', I'd rather start with the infinitely-looping 'do'. Then it becomes clear that there is a need for some extreme construct like 'break'. If you have a 'while 1' at the top, then the question becomes, "why don't you just change the 'while' so you can get out of the loop?" Then you have to explain why that's not always possible/desirable. AH "Steve Williams" wrote in message news:3A633415.47D71944 at gte.net... > Andrew Henshaw wrote: ...snip... > But, I'm not a C programmer and 'while 1' doesn't speak to me in a language I > can appreciate. > > I had the hardest time understanding the ISO on/off switch codes of 1/0. Was > this high-level logic or low-level logic? Using -1 as a truth value is beyond > my comprehension--since -1 is less than 1, it must be false. . .. > > In any case, I want to see a real conditional as part of the 'while'. That's > just the way I'm put together. And I don't want the conditional used as some > kind of tatty scope delimiter fifty lines later. If you need a scope delimiter, > use 'end-while'. > > If I have a 'while x <> 0:' statement it tells me something. It says "this is a > loop and this is how it's terminated". I can then search for the variable x and > see who sets it or how it's referenced in the loop. If I have to prime the > value of x before the loop, that's OK with me. Actually, I like to initialize > all my variables. I'm kind of a control freak that way. > > Conversely, when I see 'While 1', all I know is "this is a loop". I'm now on > notice to dig deeper and find out how the loop terminates and hope I get it > right. > ...snip... From sp00fD at yahoo.com Thu Jan 25 12:01:53 2001 From: sp00fD at yahoo.com (sp00fD) Date: Thu, 25 Jan 2001 17:01:53 GMT Subject: Library paths Message-ID: <94pm5p$mhi$1@nnrp1.deja.com> I build Python2.0, and added in tk support. Now when I try to use python, I get: ld.so.1: python: fatal: libtk8.3.so: open failed: No such file or directory I can set my LD_LIBRARY_PATH to point to the directory which holds the tk library and everything is cool. The question is, is there any way to build python so that I don't have to add a LD_LIBRARY_PATH entry to all the users? Sent via Deja.com http://www.deja.com/ From dsh8290 at rit.edu Tue Jan 30 11:18:55 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 30 Jan 2001 11:18:55 -0500 Subject: How to extend sys.path on Win9x permanently? In-Reply-To: <3a75ef9c.11194652@news.muenster.de>; from m.bless@gmx.de on Mon, Jan 29, 2001 at 10:54:55PM +0000 References: <3a75ef9c.11194652@news.muenster.de> Message-ID: <20010130111855.C22069@harmony.cs.rit.edu> On Mon, Jan 29, 2001 at 10:54:55PM +0000, Martin Bless wrote: [snip] | [... and besides, this new WinMe on one machine dismisses all changes | I make to autoexec.bat und reverts to the previous version the next | time I reboot. How can I change this behaviour?] AFAIK WinME purposefully ignores autoexec.bat. IMHO WinME is a horrid breakage of Win2k just to put a box with a smaller price tag on the self. I read an article in PC Magazine that described the "features" of WinME. Amongst them are: media player doesn't work, some virus scanners don't work, can't configure the system with autoexec.bat, and a bunch of other things too. I read an article several years ago that Win98 and NT4.0 were to be the last of the windows series before MS combined them into one product and only have one line of windows from now on. I heard that WinME was created because there were people who wanted to upgrade from Win98 but didn't want to pay the high price of Win2k. I don't think this helps much, but maybe you will find the information interesting. | | thanks a lot | Martin Bless | -- -D From quinn at regurgitate.ugcs.caltech.edu Sat Jan 20 22:11:04 2001 From: quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) Date: 21 Jan 2001 03:11:04 GMT Subject: Tabbing/Spaces References: <94bu2u0jl5@news2.newsguy.com> Message-ID: On Sat, 20 Jan 2001 12:47:54 +0100, Alex Martelli wrote: >"Quinn Dunkan" wrote in message >news:slrn96ipbi.oul.quinn at groat.ugcs.caltech.edu... >> On 19 Jan 2001 16:17:13 -0800, Johann Hibschman > >> wrote: >> >Shrug. Whatever suits you best, I guess. I just hate getting all-tab >> >code, since then I have to re-indent it for it to be readable. >> >All-space code, on the other hand, always looks fine. >> >> Unless you use proportional fonts. > >The syntactically significant whitespace in Python is that from >the left margin and the first non-white character of each line. >_In this specific context_, use of proportional fonts is not an >issue: 'all-space code ... looks fine' regardless of that. I disagree---the spaces are way too narrow, and it makes it quite hard to figure out what lines up with what, or worse, figure out how many spaces to hit to get into the right block. It doesn't look *awful*, but it sure doesn't look "fine"... at least not to my (low-res) eyes. And of course, people don't just format relative to the left margin, they also also try to line up other things (although it's easy to go overboard on that). From moshez at zadka.site.co.il Tue Jan 30 13:52:07 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 30 Jan 2001 20:52:07 +0200 (IST) Subject: Sets in Python In-Reply-To: <956hcd$qef$1@tyfon.itea.ntnu.no> References: <956hcd$qef$1@tyfon.itea.ntnu.no> Message-ID: <20010130185207.0CB75A83E@darjeeling.zadka.site.co.il> On Tue, 30 Jan 2001, "Magnus Lie Hetland" wrote: > And if one was to write a small wrapper of some kind -- > is there any way to implement "x in s" without a linear search? > Or does the "in" operator always loop from 0 and up? > (It would certainly be nice to be able to override it...) It can be if you're using Python 1.6 or later: class set: def __init__(self, els): self.data = {} for el in els: self.data[el] = None def __contains__(self, el): return self.data.has_key(el) 1 in set([1, 2]) 3 not in set([1, 2]) -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From amk at mira.erols.com Fri Jan 26 20:40:41 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 27 Jan 2001 01:40:41 GMT Subject: c(++)python? References: <3A71EB9C.D258C1C0@comm.mot.com> Message-ID: On Fri, 26 Jan 2001 15:26:52 -0600, Stephen Boulet wrote: >Is this in fact the case, or was c++ not standardized/mature enough >when python first came out? Beats me. I suspect it probably boils down to simple circumstance, such as Guido not having a C++ compiler on his Mac, but you'd have to ask him. --amk From peter at engcorp.com Sat Jan 27 03:23:40 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 27 Jan 2001 03:23:40 -0500 Subject: Newbie question References: <94tp0p$8bj$1@nnrp1.deja.com> Message-ID: <3A72858C.E5A93DD3@engcorp.com> thrasymedes at my-deja.com wrote: > > 2. I am currently using Python 1.5.2 and the appropriate version of > Pythonwin for it. Should I upgrade to Python 2.1 or ActivePython or > some other version? (I have no intention in the short term to do > anything more with it than footle around trying to figure out how it > works (virtually no prior programming experience) and maybe writing > some programs with a purely ASCII display.) The only reason for you to upgrade, given your stated intentions, is if you start to get confused with information you read here or elsewhere which refers to a different version of Python than the one you are using (it would probably be version 2.0). If it ain't broke, don't fix it. Of course, if you have even the slightest urge to upgrade, it's not exactly a difficult process, so I wouldn't worry about this one if I were you. (Sorry I can't adequately answer your first question.) From db3l at fitlinxx.com Thu Jan 18 03:00:50 2001 From: db3l at fitlinxx.com (David Bolen) Date: 18 Jan 2001 03:00:50 -0500 Subject: how to run a DOS program without getting a box? References: <3A64E195.ECA51312@cableinet.co.uk> <3A667773.C00AC40B@javanet.com> Message-ID: Raymond Hettinger writes: > Dan Rolander wrote: (...) > > >>> import os > > >>> test = os.popen("c:\\test.bat") > > Interesting that this works from the command prompt but fails inside the > PythonWin > environment. The error message is: > WindowsError: [Errno 2] The system cannot find the file specified This is a known problem with the os module implementation of popen in Python 1.5.2 - it's actually not Python's fault, but a problem with an underying issue with the Windows C popen() call - it won't work without console handles, which a GUI application like Pythonwin doesn't have. (And actually, I believe that os.popen is less than reliable under Windows versions other than NT, but I don't have a lot of direct experience with that). For Python 1.5.2, you can use the win32pipe.popen() call from the win32all package, and it will work in both cases (and under Win9x), but until the last one or two updates of the win32all package, one difference is that you couldn't get the exit code of the process back during the pipe close(). That works in the most recent releases. As of Python 2.0, the os module works fine in both cases (it incorporated the code from the win32all module when run under Windows). -- -- 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 aleaxit at yahoo.com Sun Jan 28 13:43:47 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 28 Jan 2001 19:43:47 +0100 Subject: SIGs References: <3A72C8A3.C4B4D69A@stroeder.com> <3A731F26.15461A27@stroeder.com> Message-ID: <951p9a0mn@news2.newsguy.com> "A.M. Kuchling" wrote in message news:slrn978o29.gn.amk at mira.erols.com... [snip] > In any case, making something a SIG as opposed to just a mailing list > will not magically free up more of people's time to work on the SIG's > deliverable. SIGs have sputtered along without produced much of value > before; cases in point include the import-sig, locator-sig, plot-sig, > and types-sig, which don't seem to have altered the Python landscape > much. Which reminds me -- is it just me, or does the page at http://www.python.org/sigs/ REALLY state that EVERY Python SIG has expired except catalog-sig (with 5 more months' life to go) and the two perennials meta-sig and pythonmac-sig? Alex From donn at oz.net Sat Jan 13 02:29:25 2001 From: donn at oz.net (Donn Cave) Date: 13 Jan 2001 07:29:25 GMT Subject: How robust is Python ? References: <93nh5u$9nk$1@nntp6.u.washington.edu>, <9358nn$3c5$1@nnrp1.deja.com>, <9354f9$vbi$1@nnrp1.deja.com>, <20010106103938.8FCAFA84F@darjeeling.zadka.site.co.il> Message-ID: <93p04l$4ud$0@216.39.151.169> Quoth Moshe Zadka : | On 12 Jan 2001 18:07:58 GMT, Donn Cave wrote: |> But back to the subject, I would be interested in more concrete |> examples of what exceptions we're liable to catch in a case like that. |> I have used top level handlers, but only as basically an alternative to |> the traceback, not to resume execution. | | In my original message, I didn't say "resume execution" -- I said | "re-exec", meaning (sorry for not being clearer) using the exec(2) | system call to restart itself from scratch. I wouldn't just | resume execution after an identified exception. Nor after an unidentified exception, I suppose. No, I got that. I wouldn't either, but a handful of follow-ups from usually reliable sources of enlightenment haven't blinked at that notion under the subject "How robust is Python", while writing at length about "try: continue". Leading me to wonder if it's not so crazy after all? Donn Cave, donn at oz.net From bryan at eevolved.com Mon Jan 22 12:46:21 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Mon, 22 Jan 2001 17:46:21 GMT Subject: Editor font in IDLE (Linux) References: <3A6C1221.9000302@e-pack.net> Message-ID: > Hi, > > There's a hint in the EditorWindow module for changing the default font > and size for Win32 users. > What can a Linux IDLE user do to change the extreme small and ugly font > used in > IDLE (0.5) ? > > TIA > > Gilles > This is what I did ( shame-faced hack... ): grep through the file config-unix.txt . Change lines "font-name=" and "font-size=" to whatever you want. I use terminal, size 12. enjoy. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. www.eevolved.com <==================================> "Whoever undertakes to set himself up as a judge of Truth and Knowledge is shipwrecked by the laughter of the gods."-- Einstein From mfletch at tpresence.com Fri Jan 12 12:54:41 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Fri, 12 Jan 2001 12:54:41 -0500 Subject: my uthreads execute serially Message-ID: Same here, works fine with 1.5.4 (1.5.2) version of stackless, but doesn't work for the 2.0 version. No idea how I missed that, but it's definitely failing to switch contexts without an explicit switchContext. I have no time today to track it down this weekend, maybe Chris can take a look? (Note, adding a switchContext does make the threads run in parallel, but that shouldn't be necessary). uthread9 does complain on my machine, but I'd though it was the posting an exception to another thread test (which prints out the traceback). Should have had an explicit test for such a simple thing I suppose. Sorry about that, Mike -----Original Message----- From: Wolfgang Lipp To: python-list at python.org Sent: 1/12/2001 11:06 AM Subject: my uthreads execute serially can anybody help me with this problem? i am using stackless python 2.0 on win98se, on a laptop. when i execute the following program: import uthread9 as uthread import time def timer_elapsed( started ): return time.time() - started def timer_over( started, stoptime ): return timer_elapsed( started ) > stoptime def timer( letter, stoptime ): started = time.time() print "%s is started" % letter while not timer_over( started, stoptime ): pass print '%s is done after %3.2fs' % ( letter, timer_elapsed( started ) ) uthread.new( timer, 'a', 5 ) uthread.new( timer, 'b', 3 ) uthread.new( timer, 'c', 2 ) uthread.run() my output looks like this: a is started a is done after 5.05s b is started b is done after 3.02s c is started c is done after 2.04s which clearly indicates that the threads do *not* run in the parallel. moreover, the outputs from all the examples on http://world.std.com/~wware/uthread.html also point into interpreting them as being executed one thread after the other. since all the snippets as well as the test suite u1.py from that page work without complaining, i guess that there is no problem with my installation. furthermore, i tried a few examples using the threading module, and the results appear to be ok. because of this and because uthreads are not, to my understanding and unlike the threading module, dependent on the os, it can't be my laptop that's to small to fit in threads :-| ... can anyone help me parallelize my uthreads? yours, -wolf -- http://www.python.org/mailman/listinfo/python-list From johnstonwells at my-deja.com Tue Jan 16 12:18:17 2001 From: johnstonwells at my-deja.com (johnstonwells at my-deja.com) Date: Tue, 16 Jan 2001 17:18:17 GMT Subject: [ANNOUNCE] Kaivo Announces Python Training Partnership Message-ID: <941voe$uuf$1@nnrp1.deja.com> KAIVO ANNOUNCES PYTHON TRAINING PARTNERSHIP DENVER (Jan. 16, 2001) - Kaivo, a leading Open Source solutions provider, announced that they will be partnering with Mark Lutz, one of the primary figures in the Python community, in the delivery of Python education and training. The three day course, "Python for Programmers" is an in-depth, hands-on introduction to the Python programming / scripting language. Students will learn Python language fundamentals as well as how to apply Python in a handful of common application domains, such as Internet scripting, systems programming, and user interface development. "Python for Programmers" has been successfully presented to both programming experts and novices. Therefore there are no absolute prerequisites for it other than basic computer familiarity. Some prior background in programming may help for later topics, but is not generally required. The first course will be offered February 21 to 23 in Denver, CO. Detailed course information and on-line registration is available at http://www.kaivo.com/KaivoCourses/catalog or call Kaivo at 303-539-0200 and ask for a training coordinator. Kaivo plans to co-sponsor future classes, in Denver as well as other parts of the country-check www.kaivo.com for periodic updates to the schedule. "Our customers and potential customers are constantly requesting Python training," said Kathy Gosa, Kaivo's vice president of education. "The extremely rapid growth of the Python community has driven us to provide the best training possible. We are very excited to be partnering with someone of Mark's expertise." Mark Lutz is a Python trainer, writer, and software developer, and is one of the primary figures in the Python community. He is the author of the O'Reilly books "Programming Python" and "Python Pocket Reference" and co-author of "Learning Python". Mark has been involved with Python since 1992, and began teaching Python classes in 1997. "I'm excited to be working with Kaivo," said Lutz, "especially due to their experience with open systems and open source. I think their co- sponsoring of this class and future classes indicates the continuing rapid growth of Python adoption." ABOUT KAIVO Kaivo began as a UNIX education and training provider in 1984. We have been educating customers on the benefits and power of Open Systems and Open Source tools for sixteen years. That experience has taught us how important technical training can be to the rapid adoption and successful implementation of a powerful tool like Python. ABOUT PYTHON Python is a popular object-oriented scripting language, used for a wide variety of programming tasks. Visit www.python.org for more information, and to download the most current Python release free. # # # Contacts: Kathy Gosa VP Education Kaivo 303.539.0200 www.kaivo.com Mark Lutz lutz at rmi.net http://www.rmi.net/~lutz Sent via Deja.com http://www.deja.com/ From m.faassen at vet.uu.nl Sat Jan 13 08:36:31 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 Jan 2001 13:36:31 GMT Subject: Web devel with python. Whats the best route? References: <93pii2$c4c$2@newshost.accu.uu.nl> Message-ID: <93plkv$c4e$4@newshost.accu.uu.nl> Moshe Zadka wrote: > [Cliff Crawford] >> InterTran translates the phrase "Tim Peters" as "[Tim] Godfather". :) > [Steve Holden] >> So he *is* a member of the > [Tim Peters] >> All right, I've had it. It's time to come clean! Here's the tru > [Martijn Faassen] >> It appears there's some kind of bizarre interaction between >> NNTP (or is it MailMan?) and temporal paradoxes here, that > Huh? I see no such thing at my end. Don't you look at what you're replying to today, Moshe? All these messages are cut off in From syver at NOSPAMcyberwatcher.com Sat Jan 20 19:02:36 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Sun, 21 Jan 2001 01:02:36 +0100 Subject: How do I know all thrown exceptions of a function? References: Message-ID: <94d93h$55d$1@troll.powertech.no> Couldn't you use the source? wrote in message news:g3lb49.73s.ln at 127.0.0.1... > Hi. > > Several times browsing the module library, I've found some functions which > state explicitly what exceptions they throw, because they are not the > built-in types. However, how can I know the built-in exceptions a function > my throw? > > This happened while implementing a file open call: I remembered it throwed > and IOError exception when the file I was trying to open wasn't there, but > I guess that's not a great way to discover what exceptions are thrown... > > -- > > Grzegorz Adam Hankiewicz gradha at iname.com - http://gradha.infierno.org > Other web pages: http://glub.ehu.es/ - http://welcome.to/gogosoftware/ From nospam at mega-nerd.com Fri Jan 26 21:18:31 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Sat, 27 Jan 2001 02:18:31 GMT Subject: c(++)python? References: <3A71EB9C.D258C1C0@comm.mot.com> Message-ID: <3A722CE4.56442E08@mega-nerd.com> Stephen Boulet wrote: > > This is just something I've wondered about, and not intended to be a > troll. > > Why is the most popular implementation of python in C? A novice > programmer (like myself) might think: "python is itself an > object-oriented language, so it would make sense to implement it in > another object-oriented language." What makes you think you can't program in an OO manner in C? > Is this in fact the case, or was c++ not standardized/mature enough > when python first came out? That might well be case. Its also possible the C was thought to be a better option becuase unlike Python's clean OO implementation the C++ one is a mess of the highest order. C++ is the only language I know of with such an overwhelming feature bloat. Just my opinion, Erik -- +----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) +----------------------------------------------------------+ Laws of Thermodynamics: 1) You cannot win. 2) You cannot break even. 3) You cannot get out of the game. From tim.one at home.com Tue Jan 2 12:30:58 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 2 Jan 2001 12:30:58 -0500 Subject: sre \Z bug or feature? In-Reply-To: Message-ID: [posted & mailed] [Pearu Peterson] > >>> re.match(r'(?ms).*?}\s*\Z(?P.*)','{}\012}\012').groupdict() > {'rest': ''} > > but in Python 2.0 the same match gives > > >>> re.match(r'(?ms).*?}\s*\Z(?P.*)','{}\012}\012').groupdict() > {'rest': '\012}\012'} > > which is surprising because according to docs: > > \Z Matches only at the end of the string. > ... You may want to add this test case to the bug "New re breaks on some '*?' matches" opened yesterday: http://sourceforge.net/bugs/?func=detailbug&bug_id=127259&group_id=5470 > It seems that the `{}' part is somehow responsible to this > behaviour because > > >>> re.match(r'(?ms).*?}\s*\Z(?P.*)','aa\012}\012').groupdict() > {'rest': ''} > > is expected result and is obtained with Python 2.0. If you try the test strings: '}\012\012' '}}\012\012' '}}}\012\012' '}}}}\012\012' '}}}}}\012\012' etc you'll find that the regexp works as expected if there are an odd number of "}" characters, but doesn't match at all if there are an even number. That aspect is very much like the current bug report. > ... any hints how to go around this bug without updating Python > from CVS after it is fixed? It's unclear what you're trying to accomplish. Tell us in words what it is you're trying to match, and I'm sure we can find an equivalent regexp that doesn't use *?. As is, your regexp should match any string whatsoever that ends with a } followed by optional whitespace, and set groupdict('rest') to an empty string. It can never set 'rest' to anything other than an empty string. If that's really what you intended, then r'(?s).*}\s*\Z(?P)' is a simpler and faster way to accomplish that. But I doubt that's what you intended. minimal-matches-backtrack-too-except-they-grow-longer-and-longer- ly y'rs - tim From grante at visi.com Fri Jan 19 15:19:31 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 19 Jan 2001 20:19:31 GMT Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> <949mnk$bgu$1@panix6.panix.com> Message-ID: In article <949mnk$bgu$1 at panix6.panix.com>, Aahz Maruch wrote: >In article , >Gerhard =?iso-8859-1?Q?H=E4ring?= wrote: >> >>jstar from joe here. Everybody who grew up with MS-DOS and Turbo-Pascal >>knows that the WordStar keybindings are the one-and-only that really count. > >Except that *I* grew up with CP/M and TurboPascal. And I still prefer >vi these days. (Largely because of the fuckheads who mucked with the >Proper way to design a keyboard, with the control key to the left of the >"A" the way Ghod intended.) Under Linux (console or X) It's fairly simple to put it back where it's supposed to be. Under WinNT, there's some sort of registry magic that can be done. -- Grant Edwards grante Yow! ... Blame it on the at BOSSA NOVA!!! visi.com From tepperly at llnl.gov Thu Jan 4 10:52:17 2001 From: tepperly at llnl.gov (Tom Epperly) Date: Thu, 4 Jan 2001 07:52:17 -0800 (PST) Subject: Registering C methods when writing a C extension type? In-Reply-To: <20010103201328.A7834@westsidecnc.rh.rit.edu> Message-ID: Thanks to everyone who replied. You helped clear up some of my misconceptions. I am fairly convinced by what I've read that what I've proposed is a bad idea. Alex Martelli wrote: [ several lines deleted] > > I am wondering what the relative merits/penalties of doing something > > like the following in the constructor for the hypothetical myobject > > instead of the above. I would like feedback about issues of style (am > > I violating the designers intent or using functions intended for > > internal use only), forward/backward portability, and efficiency. > > I fail to see any advantage of the following approach. OTOH, the > disadvantages are pretty obvious: > > > > static myobject * > > new_myobject() > > { > > myobject *self; > > const int len = sizeof(object_methods)/sizeof(PyMethodDef); > > int i; > > self = PyObject_NEW(myobject, &myobjecttype); > > if (self == NULL) return NULL; > > for(i = 0 ; i < len ; i++){ > > PyObject *func = PyCFunction_New(object_methods + i, self); > > if (func != NULL) { > > PyObject_SetAttrString(self, object_methods[i].ml_name,func); > > Py_DECREF(func); /* remove extra reference */ > > } > > } > > return self; > > } > > ...each new-object instancing pays a time price to initialize the > > table of its methods, and, perhaps more important, the *space* to hold > > a table that's just a copy of the object_methods one to all intents > > and purposes. What's the point...? If I implement getattr/setattr with a PyDictObject (i.e. each myobject has a dictionary instance), I thought the potential benefits would be: 1. Replace the linear lookup time implicit in Py_FindMethod with nearly constant time hash table lookup. 2. Avoid creating a PyCFunction_New once per method call. It would be nice if there were a Py_FindMethodSorted where it assumed that the PyMethodDef's were alphabetically sorted. I was also considering a way to have one extension type being able to wrap up numerous IDL types. The alternative is to do something like: struct myobject { PyObject_HEAD const PyMethodDef *object_methods; } static PyObject * myobject_getattr(myobject *self, char *name) { /* other stuff deleted */ return Py_FindMethod(self->object_methods, self, name); } Tom -- ------------------------------------------------------------------------ Tom Epperly Center for Applied Scientific Computing Phone: 925-424-3159 Lawrence Livermore National Laboratory Fax: 925-424-2477 L-661, P.O. Box 808, Livermore, CA 94551 Email: tepperly at llnl.gov ------------------------------------------------------------------------ From twcinpa at early.com Sat Jan 27 16:47:09 2001 From: twcinpa at early.com (Tom Connor) Date: Sat, 27 Jan 2001 16:47:09 -0500 Subject: Online books References: Message-ID: Has anyone an opinion of "Core Python Programming" from Prentice Hall. Thanks, Tom Connor "Langa Kentane" wrote in message news:mailman.979041730.32584.python-list at python.org... > Greetings. > Can anyone please suggest a site where I can find a good online book > [something comprehensive] on python programming that I can download. > > Thanks in advance > > __________________________________________________________ > Langa Kentane | TEL: (011) 290 3218 > Security Administrator | Cell: 082 606 1515 > DISCOVERY HEALTH | http://www.discoveryhealth.co.za > __________________________________________________________________ > > From Daniel.Kinnaer at Advalvas.be Sat Jan 27 08:57:57 2001 From: Daniel.Kinnaer at Advalvas.be (Daniel) Date: Sat, 27 Jan 2001 13:57:57 GMT Subject: Interested in a Crypto-SIG? References: <3A72C8A3.C4B4D69A@stroeder.com> Message-ID: <3a72d11f.17643900@news.skynet.be> On Sat, 27 Jan 2001 14:09:55 +0100, Michael =?iso-8859-1?Q?Str=F6der?= wrote: >I would like to propose a Crypto-SIG. >Let me know what you think. > >Ciao, Michael. It would be nice to have the new AES in a Python module, just like BlowFish, TwoFish, TDES, etc. All of these algorithms (written in C) can be readily found on the net. Not a very easy subject, though... best regards, Daniel From wware at world.std.com Sat Jan 27 09:49:55 2001 From: wware at world.std.com (Will Ware) Date: Sat, 27 Jan 2001 14:49:55 GMT Subject: How to check memory usage/leak of python script with C extendtion .. References: <94srme$gr9$1@nnrp1.deja.com> Message-ID: etsang at my-deja.com wrote: > I am having a python script that interacts with a C executable through > its pyhon C extension. I would like to monitor the memory usage of the > whole thing? Do anyone know how to do it? Is there a tool availble for > memory usage monitoring and memory leakage check for this situation?? I did something like this once. It turns out that part of this facility is already built into the Python source code. If you don't mind recompiling Python, you can try what I did: http://www.deja.com/getdoc.xp?AN=672487959&fmt=text What I was doing was to print the sum of all the reference counts for all the objects. Memory problems are often associated with mismanagement of reference counts. So if you go into a for-loop and the total number of refcounts rises each time thru the loop, it's a likely indication that you might need another DECREF somewhere. -- import string,time,os;print string.join((lambda x:x[:10]+x[8:])(map( lambda x:string.center("*"*(lambda x:((x<24) ### Seasons Greetings, Will Ware *(x-3))+3)(x),24),range(1,28, 2))),"\n") ################ wware at world.std.com From aleaxit at yahoo.com Sat Jan 13 18:49:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 14 Jan 2001 00:49:50 +0100 Subject: Using re - side effects or misunderstanding References: Message-ID: <93qpmr02neb@news1.newsguy.com> "Andrew Henshaw" wrote in message news:t61f9nsrgdcj0f at corp.supernews.com... [snip] > and I execute the following > > r.findall('..abcxyz..') [snip] > so how do I get the result > > ['abxyz'] findall will never return a string that is not a substring of the string you pass it as an argument. As abxyz is not a substring of '..abcxyz..', it will _never_ be returned by findall, whatever r is. > In other words, adding groups for the purpose of adding repetitions seems to > have a greater side-effect than I would desire. Is there something that I'm > missing in my use of re's? Rather, it seems to me, in findall (admittedly a somewhat peculiar method). If you want, in your example, to (e.g.) match 1 or more 'abc's, then 0 or more 'c's to be ignored, then 1 or more 'xyz's, what you'll get from findall (with first and third normal group, second non-matching group) is a [list containing a] tuple ('abc','xyz'). You need to ''.join it to make it into a string; findall won't do that for you. Alex From paulb at infercor.no Fri Jan 12 10:35:22 2001 From: paulb at infercor.no (Paul Boddie) Date: Fri, 12 Jan 2001 16:35:22 +0100 Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com> <93hfp1013sm@news2.newsguy.com> <93juec0fk6@news1.newsguy.com> <93kije$cgg$1@newshost.accu.uu.nl> Message-ID: <3A5F243A.E2325770@infercor.no> Martijn Faassen wrote: > > Yes, some kind of markers are necessary. In Zope, DTML does that job, > but since DTML, though it can be nice, has also been called "Perl for > the web" due too far too much magic, various people at Digital > Creations and Hiperlogica are experimenting with another approach to > this, called HiperDOM. Its approach is interesting: > > http://www.zope.org/Wikis/DevSite/Projects/HiperDom/PrototypeDocumentation > > The idea is that instead of custom tags, things happen in XHTML > attributes, and each template can be a full web page by itself too, > editable by WYSIWIG tools, as long as those tools leave the extra > attributes intact. That sounds a bit like the XMLC stuff which the Enhydra people use: http://www.enhydra.org Still, DTML is nice for "reflecting" the contents of data structures without developers needing to write code to transform the document template before it gets sent to the browser, which I think is necessary when presenting collections of data elements (from lists, for example) with XMLC. Regards, Paul From hanche at math.ntnu.no Fri Jan 12 18:49:56 2001 From: hanche at math.ntnu.no (Harald Hanche-Olsen) Date: 13 Jan 2001 00:49:56 +0100 Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> <93dde1$8d2$1@animus.fel.iae.nl> <93f3nb023mv@news1.newsguy.com> <90259DC4Arcamesz@127.0.0.1> <93i57b01qms@news2.newsguy.com> <90268BCE3rcamesz@127.0.0.1> <93kb0m0r3s@news1.newsguy.com> <90273B4rcamesz@127.0.0.1> Message-ID: + rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz): | Alex Martelli wrote: | | Ah, Lisp, so beautiful, so pristine, so ... verbose. Well, it's great | for lists, but anything numeric is a chore. Let's see: | (EQ (PLUS 1 1) 2) | t | Phew, so least that's still true... ;-) Which is an accident of the implementation, in the same sense that the following is accidentally true in python: >>> 1+1 is 2 1 I'm sure you meant to write (= (+ 1 1) 2) ? One neat thing about Lisp though, is how you can rewrite the syntax, for example to allow you to write infix arithmetic if you wish. This takes much of the pain out of involved numerical work. I wrote some scheme macros once (many years ago) to accomplish this - it was only a moderate amount of work. In Common Lisp you can accomplish much the same thing even more elegantly using reader macros. but-now-I-have-a-feeling-we're-in-the-wrong-newsgroup-ly y'rs, -- * Harald Hanche-Olsen - Yes it works in practice - but does it work in theory? From slhath at home.com Sat Jan 20 20:24:52 2001 From: slhath at home.com (Scott Hathaway) Date: Sun, 21 Jan 2001 01:24:52 GMT Subject: pyXML support for XSL tranformations?? References: Message-ID: Thanks! Scott "Martin von Loewis" wrote in message news:p6qsnmdq1ir.fsf at informatik.hu-berlin.de... > "Scott Hathaway" writes: > > > Using the Microsoft tools, you can load an XML document, then load and XSL > > or XSLT document into memory and then call nodeTransform to blend the two > > together and then spit it back out. > > > > Is there a way to do this with pyXML or any other python xml library? > > Try 4Suite. It is a PyXML superset, that uses the PyXML parsers and > implements the transformations on top of it. > > Regards, > Martin From sholden at holdenweb.com Fri Jan 12 11:06:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 12 Jan 2001 11:06:00 -0500 Subject: How robust is Python ? References: <9358nn$3c5$1@nnrp1.deja.com>, <9354f9$vbi$1@nnrp1.deja.com>, <20010106103938.8FCAFA84F@darjeeling.zadka.site.co.il> Message-ID: "Sandipan Gangopadhyay" wrote in message news:mailman.979313781.1111.python-list at python.org... > > ----- Original Message ----- > From: "Moshe Zadka" > To: > Cc: > Sent: Saturday, January 06, 2001 4:09 PM > Subject: Re: How robust is Python ? > > > On Fri, 05 Jan 2001, rturpin at my-deja.com wrote: > > > > > Unfortunately, cron is not cross-platform. We'll have > > > some sort of mechanism to do this. The problem is not > > > just the language and operating system, but everything > > > that can kill a process. Still .. you want such mechanism > > > as backup, not as a solution to regular crashes. > > > > Of course. None of this is meant to imply Python crashes regularily. > > In fact, I can't think off-hand of a language less likely to suffer > > crashes, given that you take a few exception-catching precautions > > in the main loop (have a catch-all except: which re-execs the process). > > I want this in my code, but came across a problem - > > while binAliveMarker: > if binIWannaStartAgain: > time.sleep(1) > continue > work code ... > > If I try a catch-all except, continue hits except on the outer level rather > than while. Probably the reason that it results in syntax error. > > while binAliveMarker: > try: > if binWannaStartAgainLater: > time.sleep(1) > continue > work code ... > except: > pass > > Any suggestions to make it work with continue (or an alternative) ? Apart > from removing continue completely by making the work code inside an else ? > > Thanks, > > Sandipan > The documentation states that the continue syntax error is due to "laziness" on the part of the implementors, though they seem to keep pretty busy to me. You can work around this with: class Continue: pass while binAliveMarker: try: if binWannaStartAgainLater: time.sleep(1) raise Continue work code ... except Continue: continue You could maybe leave the "pass" you had in the except rather than changing it to continue, but it's never a good idea to include non-selective except clauses: they catch KeyboardInterrupt, among other nasties you probably really want to see. [Just passing along a wrinkle somebody else taught me...] regards Steve From trentm at ActiveState.com Tue Jan 9 11:09:09 2001 From: trentm at ActiveState.com (Trent Mick) Date: Tue, 9 Jan 2001 08:09:09 -0800 Subject: API\dll In-Reply-To: ; from benc@rehame.com on Tue, Jan 09, 2001 at 02:52:28PM +1100 References: Message-ID: <20010109080909.H27153@ActiveState.com> On Tue, Jan 09, 2001 at 02:52:28PM +1100, Ben Catanzariti wrote: > Hi, > > This may seem like a simple q for a lot of you? > > I have an API with a dll. To call Functions from this dll the examples for > the API are written in C. However I would like to use Python to make the > same function calls. Does the dll have to be written specifically in the > language that is making the call to do this... in this case C? Or can Python > make calls to any dll? You have to write a Python/C extension that will mediate calls between your Python code and the C API of your DLL. You will need to write that wrapper in C. You should read the "Extending and Embedding the Python Interpreter" section of the main Python docs. An excerpt: It is quite easy to add new built-in modules to Python, if you know how to program in C. Such extension modules can do two things that can't be done directly in Python: they can implement new built-in object types, and they can call C library functions and system calls. http://velocity.activestate.com/docs/ActivePython/ext/ext.html Cheers, Trent -- Trent Mick TrentM at ActiveState.com From lg at rgz.ru Tue Jan 9 06:56:48 2001 From: lg at rgz.ru (lg at rgz.ru) Date: 9 Jan 2001 14:46:48 +0250 Subject: question about regexps Message-ID: <3a5afa28@news.edunet.ru> may be it's offtopic but i've got next problem: need to define recurse regexp simethink like a = some_regexp(a) and then pick out all nests of this regex from some string -- zev From christof_n at pastors.de Thu Jan 11 05:33:35 2001 From: christof_n at pastors.de (Christof Pastors) Date: Thu, 11 Jan 2001 11:33:35 +0100 Subject: Error in pythonic InternetExplorer hta application Message-ID: <93k5cs$hc5$1@papyrus.erlm.siemens.de> Hi, I saw the nice concept of hta applications mentioned in http://deja.com/=gh/article/%3C92v27e02jia at news2.newsguy.com%3E and rewrote the Microsoft example mentioned there http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp in Python. But it doesnt work! I get a NameError exception because the name "TheAddress" is not found. In which object can I find "TheAddress"??? I guessed "window.TheAddress" and "document.TheAddress" without success. Here is my code: HTML Application Example Address

From roth at teleport.com Fri Jan 19 11:30:30 2001 From: roth at teleport.com (tony roth) Date: Fri, 19 Jan 2001 08:30:30 -0800 Subject: win ce and python References: <9487hp$c91$1@nnrp1.deja.com> Message-ID: yea, damn I knew if anybody was going to say that it would be you:) I have about 2 days left to do a proof of concept and no energy to do it... so I'll have to use the embedded vb stuff. Keep up the good work Mark. "Mark Hammond" wrote in message news:9487hp$c91> The only decent idea I can offer is that you jump in. > > Nothing-gets-done-until-someone-does-it ly, > > Mark. > > > Sent via Deja.com > http://www.deja.com/ From arildh at stud.cs.uit.no Fri Jan 26 06:26:44 2001 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Fri, 26 Jan 2001 12:26:44 +0100 Subject: Execute an external application from inside a python script Message-ID: Hello, How do I execute an (executable) application from inside some python code, and how do I terminate this application? All help greatly appreciated. A. Hansen From jfincher at rpat-100-115.resnet.ohio-state.edu Thu Jan 11 14:55:54 2001 From: jfincher at rpat-100-115.resnet.ohio-state.edu (Jeremy Fincher) Date: 11 Jan 2001 19:55:54 GMT Subject: Speed of Python vs. Perl References: <93k78401u8s@news2.newsguy.com> Message-ID: In article <93k78401u8s at news2.newsguy.com>, Daniel Chetlin wrote: > @hash{0 .. 99999} = (1) x 99999; > >The advantages of this construct are clarity and conciseness at the >expense of a bit of speed -- the for-loop with range operator will >likely be a bit faster -- while remaining substantially faster than the >C-style loop. The disadvantage of this is that it attempts to "fill" a 100000 element hash with 99999 elements. That syntax, I believe, is especially *unclear* and prone to error. I didn't even notice the error myself; another person pointed it out to me. A simple loop is far more clear. Jeremy From nospam at mega-nerd.com Mon Jan 29 15:57:24 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Mon, 29 Jan 2001 20:57:24 GMT Subject: Displaying Unicode text in Tkinter Canvas widget Message-ID: <3A75D600.60F7CD0D@mega-nerd.com> Hi all, I'm writing a little app for helping to learn the Japanese Hiragana character set. At the moment I'm displaying GIF images of the characters but I would much rather use Unicode text. I've had a look at the python.org web site and installed Tamito Kajiyama's Japanese codecs. I've also installed Tk/Tcl 8.3 and recompiled/installed Python 2.0. Commands like: print unicode ('abcdefg', 'japanese.iso-2022-jp') work without error messages, but I would like to know how to display Hiragan characters without making Japanese the default encoding. TIA, Erik -- +----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) +----------------------------------------------------------+ "Reality is just a crutch for people that can't handle CyberSpace!!" - Hank Duderstadt From thomas at xs4all.net Fri Jan 12 18:11:28 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 13 Jan 2001 00:11:28 +0100 Subject: Speed of Python vs. Perl In-Reply-To: ; from tim.one@home.com on Thu, Jan 11, 2001 at 09:01:28PM -0500 References: <14941.48767.124071.397459@beluga.mojam.com> Message-ID: <20010113001128.D1005@xs4all.nl> On Thu, Jan 11, 2001 at 09:01:28PM -0500, Tim Peters wrote: > Like everything else, it varies by platform and configuration. Indeed. For instance, on a typical UNIX box, fstat() (which python does quite a few, to look for site.py and all imports and such) can be both incredibly fast (if the directories are already in the disk cache, of which Linux has a very good one, for instance) and terribly slow (NFS filesystems, for instance, really suck in that.) So, the startup time of python can vary depending on in what directory you type it ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From chris at voodooland.net Sun Jan 21 19:33:02 2001 From: chris at voodooland.net (Chris Watson) Date: Sun, 21 Jan 2001 18:33:02 -0600 (CST) Subject: patch for python configure for freeBSD and Zope In-Reply-To: <01012213091603.00887@localhost.localdomain> Message-ID: > No reason except that I have an install script for python, zope, and modules > (including configuration) for both that I "know" form a stable environment on > our production servers, whether linux, or freeBSD. I should try the ports > distribution and run my unit tests to perhaps build a more likely to be > stable freeBSD installer for our work. That would be a good idea. Try that and let me know if your tests work. People go to alot of trouble to make a port. It makes little sense to re-invent the wheel especially with ports. If your tests fail let me know where and how and I will see about getting the maintainer of the offending port to ensure it works with your tests and application. -- ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= GNU = Gnu's Non-portable & Unstable irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From sbalu at nyx.net Sat Jan 20 15:08:36 2001 From: sbalu at nyx.net (sarayu balu) Date: Sat, 20 Jan 2001 20:08:36 GMT Subject: Neophyte looking for good books on Python References: <94ak66$dra$1@nnrp1.deja.com> <94aulr$m1o$1@nnrp1.deja.com> Message-ID: <980023572.27042@iris.nyx.net> laura_01 at my-deja.com wrote: : Hi! The next edition of "Programming Python" by Mark Lutz is due out in : early March, : if you can wait about a month. : Laura : LLewin at oreilly.com I have the old edition of "Programming Python" by Mark Lutz. I do not know if Oreilly suggests that I pay the full price for this new edition. These days, there seems to be a newer edition so often, that we programmers have become suckers for the publishing company. Java is the classical example. Oreilly should take the leadership in this area, in selling newer editions at substantial discounts for owners of older editions, or follow Bruce Eckel's model of putting the whole book on the web. What do you folks think ? -sb -- Dr.Sarayu Balu,M.D.,FAAP Tel.(802)888-2448 Ryder Brook Pediatrics, P.O.Box 608, Morrisville, VT 05661. From aleaxit at yahoo.com Wed Jan 10 08:02:47 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 10 Jan 2001 14:02:47 +0100 Subject: mxTools (was Re: why no "do : until"?) References: <93hg4a0144i@news2.newsguy.com> Message-ID: <93hmk001c2v@news2.newsguy.com> "Robin Becker" wrote in message news:LRFzDVA+eFX6Ew4t at jessikat.fsnet.co.uk... [snip] > I point out that there are several competing binary time formats Sure, but that doesn't matter as much as the interface time/date objects present on the _Python_ side of things. Binary formats internally used differ hugely between databases, too, but, who cares? Only the author of the DB-interface module -- they'll have to handle the conversion; but, on the Python side of things, the object can again behave uniformly. > including the fairly ludicrous M$/Lotus 1900 is a leap year one. None of > the 64bit ones has a hope of surviving too long in a world where > nano/pico seconds are becoming important. I suspect that the format limitations of widespread databases will keep time-formats of 64 bits or fewer around for a long time; one rarely needs picosecond-accuracy on the _same_ time objects that need to encode dates across many millennia. When one _does_ have such a need, the mxDateTime internal format requires usage of _two_ objects -- a DateTime object for the integral-second, and a RelativeDateTime one for the fraction of a second. If picosecond (10**-12) accuracy is required, the typical 53-bits precision of a 'double' (internally used for RelativeDateTime) has a few bits left over that can be used for an integer-part, but not one of up to a full day (just a few hours' worth). Never having worked with over-nanosecond accuracy myself, I'm more used to having bits to spare (keeping a date's midnight in the absolute part, all the rest in the relative one; I wasn't doing it in Python, though, but rather in a homebrewn C struct). Alex From cfelling at iae.nl Mon Jan 22 17:50:04 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 22 Jan 2001 23:50:04 +0100 Subject: Markov.py References: <94eavq$5cl$1@nnrp1.deja.com> <94eulk$dduhj$1@ID-11957.news.dfncis.de> <3A6B7716.68A62115@home.com> <94h5he$9kl$1@nnrp1.deja.com> Message-ID: <94ides$6t2$1@animus.fel.iae.nl> cpsoct at my-deja.com wrote: ... > example of input and output would go a long way to explain how this > makes a markov chain. Does it expect a table of possibilities? Where > are they set? etc. etc.... like if i write an func i usually say > briefly, what it does(ok, i know what a markov chain is), but more well I don't, so please enlighten me: what's a markov chain? then maybe I can check whether it does as it should, for what I'm getting now seems like an endless loop. How is it working at your side? -- groetjes, carel From m.bless at gmx.de Wed Jan 31 19:07:24 2001 From: m.bless at gmx.de (Martin Bless) Date: Thu, 01 Feb 2001 00:07:24 GMT Subject: Roadmap wanted: Python access to SPIRIT.OCX (Win9x) References: <3a7b39da.39409649@news.muenster.de> <958i3j0mk4@news2.newsguy.com> Message-ID: <3a78a445.7210135@news.muenster.de> It's past midnight - but it works!!!!!!! It was all there, and it's easy once you know what to to. makepy.py produced spirit.py, and import win32com, spirit brick = win32com.client.Dispatch('SPIRIT.SpiritCtrl.1') instantiates the object. And now I can say brick.On((0,1,3)) to get three motors going. Absolutely fascinating. IMHO, beats the proposed visual basic solutions by far. Of course I haven't understood a bit of the inner workings of makepy - the good news is, I obviously don't have to at the moment. That's real magic! I'd like to express my respect. Makepy does a marvellous job. It took me some time to discover this little hint in the generated spirit.py: # This CoClass is known by the name 'SPIRIT.SpiritCtrl.1' >Not me (another fascinating timesink being the LAST thing I >need:-) but I do understand why one would!-) Oh yes oh yes, it seems it has hit ME. Hope I can save myself ... Still very excited Martin From sholden at holdenweb.com Wed Jan 17 22:51:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 17 Jan 2001 22:51:00 -0500 Subject: Python FTP module References: Message-ID: "Realware Systems" wrote in message news:MPG.14d0f6f1f4045a62989682 at news.syd.connect.com.au... > I am sure there is a python FTP module but I don't know where it is or > what it is called. Any ideas? > > TIA > Derek > The Python community being as imaginative in its naming scheme as any programming group in the world, I think you might find you're looking for ftplib. Or are you looking for a server? In that case, there's a minimalist FTP server at http://n.ethz.ch/student/amreinm/python/pyFTPdrop.py which is in the public domain. and-httplib-does-http-too-ly y'rs - steve From jasonic at nomadicsltd.com Thu Jan 11 00:18:11 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Thu, 11 Jan 2001 00:18:11 -0500 Subject: HTML embeded with python References: Message-ID: Hi Derek, Well (the.__BIG__.one = 'Zope') http://www.zope.org New much awaitd/improved version 2.3.x now emerging fom CVS and O'Reilly book soon out [being printed now] will allow a lot of very cool Python in web pages.. But free download now of current 2.2.5 will keep you well occupied. http://www.zope.org/Products/Zope/2.2.5 Zope is free, object-oriented, cross-platfrom web applciation development system mostly in Python and using Python modules and syntax extensively.. an exapnding universe and a busy community travelling along with it.. imho: well worth the learning curve. It's going to be a very interesting year. good luck1 - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] Derek Lavine wrote in message news:MPG.14c7bd1a9ff02ee1989689 at news.hutch.com.au... > Hi all, > > I am very new to python, in fact I have only just picked up my first > book. I am thinking of using python for web apps and was just wondering > if there are any modules out there that make it possible to embed python > in the HTML pages so that one can easily build web pages based on the > result of database queries and things like that. > > I have used coldFusion quite a bit and it of course makes this sort of > thing very easy. I know there are solutions of this type in perl but > since I am keen to use python in this context (initially as a means to > get acquainted with the language) I thought I would ask them that are in > the know. > > Thanks for any pointers or suggestions > > Derek From gregor at mediasupervision.de Mon Jan 29 10:09:30 2001 From: gregor at mediasupervision.de (Gregor Hoffleit) Date: Mon, 29 Jan 2001 16:09:30 +0100 Subject: Books In-Reply-To: <3a757f33$1@netnews.web.de>; from volker.jahns@web.de on Mon, Jan 29, 2001 at 03:46:51PM +0200 References: <3a757ac1$1@netnews.web.de> <3a757f33$1@netnews.web.de> Message-ID: <20010129160930.D1166@mediasupervision.de> On Mon, Jan 29, 2001 at 03:46:51PM +0200, Volker Jahns wrote: > >search for PYTHON and you will have greater success. > > > Thanks, but the pyhton.org should lern PHP... .-) > > > Warning: fopen("counter.txt","w") - ???? ?????? in > /usr/local/apache/htdocs/pyhton/index.php on line 28 I guess PHP is much easier to use, since it has only three letters... ;-) Gregor PS: In case you still haven't found the language site: http://www.python.org/ A quick look at the bottom of each mail should have revealed the address, too: From herb at dynamic-solutions.nospam.com Thu Jan 4 04:16:52 2001 From: herb at dynamic-solutions.nospam.com (Herb Lainchbury) Date: Thu, 4 Jan 2001 01:16:52 -0800 Subject: Configuring PWS for Python ASP Scripting Message-ID: <978599793.885104@news.islandnet.com> Could someone direct me to the steps required to configure PWS so I can use python scripts in my ASP pages? I want to be able to write .asp files of the form: <%@ Language=Python %> <% print 'Hello from Python' %> but when I do this I get the error message: Active Server Pages error 'ASP 0129' Unknown scripting language /index.asp, line 5 The scripting language 'Python' is not found on the server. Thanks. From fredrik at effbot.org Mon Jan 1 07:08:14 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 01 Jan 2001 12:08:14 GMT Subject: Recursive inner function... How? References: <3A4FA0EF.BF94F4BD@uswest.net> Message-ID: Bjorn Pettersen wrote: > however, in 2.0 that gives an "UnboundLocalError: Local variable 'inner' > referenced before assignment". in this case, the assignment is done by "def": > def outer(): > def inner(inner=inner <- reference): > inner() > <- assignment statement ends here > inner() > > outer() > > Please tell me I'm doing something wrong? you're trying to use recursive inner functions ;-) the easiest fix is to do as Guido intended, and move "inner" to the global scope. you can either move the entire function to the right place, or cheat: def outer(): global inner def inner(): inner() inner() outer() (iirc, there's a FAQ entry with more info on this, but the entire FAQ seems to have disappeared. a ++Y2K bug?) btw, also see: http://python.sourceforge.net/peps/pep-0227.html From aleaxit at yahoo.com Sun Jan 14 05:20:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 14 Jan 2001 11:20:54 +0100 Subject: A small suggestion for Python References: <3A5F27F7.30268D9A@erols.com> <93qpbc02n4a@news1.newsguy.com> Message-ID: <93rumc01013@news1.newsguy.com> "Matt Dunford" wrote in message news:G7595o.HKE.0.sinope at news.jtan.com... > "Alex Martelli" writes: > > >"Matt Dunford" wrote in message > >news:G74HuE.AGn.0.sinope at news.jtan.com... > > [snip] > >> Although, I wouldn't mind having a builtin method that returns a sorted > >> array. Then we could do something like this: > >> > >> dict = { 'this' : 1, 'that' : 2 } > >> for key in dict.keys().sort(): > >> print key > > >And instead we have to do > > > for key in return_sorted(dict.keys()): > > print key > > >Is it that much of a problem...? return_sorted's pretty trivial too: > > >def return_sorted(alist): > > alist.sort() > > return alist > > I have no problem with it. But just to be pendantic, your return_sorted def > doesn't do what I'm trying to get at. I'm thinking more along the lines of > > def return_sorted(alist): > import copy > sorted = copy.copy(alist) > sorted.sort() > return sorted I would call this return_sorted_copy. It's not needed, often, and in particular it is not for the idiom you mentioned -- why make a totally needless copy of the temporary list that .keys returns? I'm anything but a speed freak, but I don't normally copy data just for the fun of it:-). Alex From danielk at aracnet.com Tue Jan 2 01:32:23 2001 From: danielk at aracnet.com (Daniel Klein) Date: Mon, 01 Jan 2001 22:32:23 -0800 Subject: Equivalent of Java 'throws' Message-ID: Here's another 'is there a Pythonic way to do this' question... In Java, you can specify a 'throws' to tell a client using your methods of your class that they must have an exception handler. This appears to be checked when the client is compiled. I've read thru the reference materials concerning exceptions and this one's got me stumped. Is there any way in Python to do this? I suspect there isn't since Python is dynamically typed. If there is, please point me to this; if not, that's ok too, I'll just document the api to my class appropriately. Thanks from a new Python convert, Daniel Klein Portland, OR USA From skip at mojam.com Thu Jan 18 09:55:32 2001 From: skip at mojam.com (Skip Montanaro) Date: Thu, 18 Jan 2001 08:55:32 -0600 (CST) Subject: what happens when cookies get too big? Message-ID: <14951.996.736232.930324@beluga.mojam.com> This isn't really a Python question, but since I'm using Python to implement things, I figured perhaps I could sneak this in. What happens when cookies get too big? Do browsers tend to barf, toss out the cookie, truncate it, or something else I've not anticipated? RFC 2109 says oversize cookies (double-stuff?) must be discarded, but I wonder if all browsers adhere to that requirement. I'm storing a cookie that represents a list of names. It's zlib compressed and base64 encoded, so I can store quite a few names. Thanks, -- Skip Montanaro (skip at mojam.com) Support the Mojam.com Affiliates Program: http://www.mojam.com/affl/ (847)971-7098 From mwh21 at cam.ac.uk Thu Jan 25 15:52:50 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Jan 2001 20:52:50 +0000 Subject: SourceForge problems References: Message-ID: "Tim Peters" writes: > [Tim, yesterday] > > According to http://sourceforge.net/ today, > > Hosted Projects: 14,366 > > Registered Users: 110,619 > > [A.M. Kuchling, today] > > Oof! When I was fiddling with patches tonight, the registered users > > number was exactly 111,000. 400 new users a day isn't too shabby... > > Worse (better? depends on your POV ...), the number of registered projects > has bumped to 14,531. Since each new project takes some manual work on > their end, I bet they're backlogged bigtime. Someone should suggest that > they only accept new Python projects. I've been waiting until they work out which end of the power cable goes in the mains[1] before submitting mine... Cheers, M. [1] This is too harsh. Oh well. -- Java sucks. [...] Java on TV set top boxes will suck so hard it might well inhale people from off their sofa until their heads get wedged in the card slots. --- Jon Rabone, ucam.chat From bakaikoa at my-deja.com Fri Jan 5 05:27:59 2001 From: bakaikoa at my-deja.com (bakaikoa at my-deja.com) Date: Fri, 05 Jan 2001 10:27:59 GMT Subject: Tkinter and option database Message-ID: <9347jc$6iu$1@nnrp1.deja.com> I cannot manage to use the option database in the way I used to do with Tcl/Tk. In particular I do not see how to use the feature of assigning options to named widgets. This was done in a simple way in Tk by using the name of the widget at creation time. Tkinter is automatically assigning a random name to each widget that is created. Example: in Tk > option readfile greeting.res > > set message [ option get . greemsg Spanish ] > > set labtit [ label .appTitle ] > set labmsg [ label .greetMsg -text $message ] worked fine with file 'greeting.res': > *appTitle.text: Saludo > *greemsg: hola With Python/Tkinter I get the 'greemsg' all right but not the application title: > import Tkinter as Tk > > root = Tk.Tk() > > root.option_readfile('greeting.res') > > message = root.option_get('greemsg','French') > > labtit = Tk.Label() > labmsg = Tk.Label(text=message) Any hint, do you know of a way of assigning a Tk name to a widget? Thanks, Bixente Sent via Deja.com http://www.deja.com/ From aleaxit at yahoo.com Mon Jan 8 11:46:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 8 Jan 2001 17:46:13 +0100 Subject: Web devel with python. Whats the best route? References: Message-ID: <93cqvi0191h@news1.newsguy.com> "Chris Watson" wrote in message news:mailman.978910629.6814.python-list at python.org... > > I'm about to start converting the small fool proof (ha ha) admin > system I have been working from console based to web based. What is the > easiest way to go about integrating python into apache so I can start > web'izing this app? mod_python, mod_snake, PyApache? CGI. Really. Your admin system doesn't look like the kind of thing that will be continuously getting multiple hits a second, making CGI overhead a problem. If that is the case, CGI is easiest. *Do the simplest thing that can possibly work*! FastCGI appears to be a close second, with potentially better performance, but lacking at least one CGI advantage -- the fact that each transaction is run quite separately, well-isolated from the others, so you'll never have any worries about resource-leaks &c... your OS will ensure proper cleanup after each hit is processed, and you'll live happily ever after. I suspect that you'll be using FreeBSD (to be true to your sig:-) and so process startup costs are limited (they'd be heavier on Win32 -- dunno about how FreeBSD compares to Linux or other Unix variants, but I suspect it's at least as good, right?-) AND your OS is solid and will ensure fully reliable cleanup in each case. Capitalize on your advantages -- go CGI, and avoid most difficulties. "Session continuity" will have to be provided via cookies, but that's not really all that hard -- the amount of state you need to save and restore between hits is most likely limited anyway (making it acceptable for cookie-residence), or else you can always use appropriate shelve files (presumably relying on gdbm, whihc is OK) and just cookie the shelve-access keys (that might impact scalability IF you were close to the hit-per-second mark, but, are you _really_ worried about such loads?). Everybody & their cousin will presumably be suggesting very-high-tech, be-the-first-on-your block kinds of whiz-bang solutions, which ARE quite all right when needed, but may not be an optimal match for most of the low- to moderate-hits web-enabled solutions one _typically_ meets (and, judging from the brief description of your application's purpose that you supply, your case might be such a 'typical' one...?) -- so, I just thought I'd put in a reminder that simpler, "more rudimental" approaches are still perfectly viable, and their very simplicity may recommend them over the more advanced ones in many cases. Then again, maybe I'm simply being a dinosaur on this specific theme!-) Alex From spahievi at vega.bg Mon Jan 29 16:14:51 2001 From: spahievi at vega.bg (Niki Spahiev) Date: Mon, 29 Jan 2001 23:14:51 +0200 Subject: curly-brace-aphobic? In-Reply-To: <20010129123030.D16071@harmony.cs.rit.edu> References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> <20010129123030.D16071@harmony.cs.rit.edu> Message-ID: <7711310076.20010129231451@vega.bg> 29.1.2001, 19:30:30, D-Man wrote: DM> On Mon, Jan 29, 2001 at 08:35:42AM -0600, Grant Griffin wrote: DM> | C.Laurence Gonsalves wrote: | >> DM> | ... | >> I'm not sure why you need to be reminded whether something is a sequence | >> or a dictionary. DM> | DM> | I guess it's because sequences and dictionaries are conceptually very DM> | different. (You can tell, because we have a special word just to DM> I'm not sure how different they are conceptually. A dictionary is a DM> collection (sequence) of data that is indexed by arbitrary keys. A DM> list is a collection (sequence) of data that is indexed by integers DM> only. It seems to me that a list is a special case of a dictionary. DM> How about classes that implement __getitem__? They perform the same DM> operation, just according to their own rules. If the class is written DM> to follow the same rules a dictionary or a list follows, but do some DM> extra magic on the side, it could be used in place of the DM> dictionary/list without any modification to the client code. DM> I think that the same syntax is used because they are the same DM> operation, just slightly different restrictions/rules. I often switch my implementations from using list to dicts and vice versa. It helps that both use [] for indexing. I wish they share more e.g. list.keys() instead of range(len(list)), list.values() instead of map( None, .... ) -- Best regards, Niki Spahiev From DOUGS at oceanic.com Sat Jan 20 20:37:17 2001 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sat, 20 Jan 2001 15:37:17 -1000 Subject: [Q] telnetlib Message-ID: <8457258D741DD411BD3D0050DA62365907A566@huina.oceanic.com> Just a guess, but you may not be following exactly the sequence of strings are exchanged when you telnet to this device. Try to manually log in and copy the session to a followup. -Doug- > -----Original Message----- > From: yoonseo at my-deja.com [mailto:yoonseo at my-deja.com] > Sent: Friday, January 19, 2001 10:01 AM > To: python-list at python.org > Subject: [Q] telnetlib > > > Hi, > > I am trying to run commands on a remote computer using Python. > I think that using 'telnetlib' is the way to go, but I have trouble. > The following is the script that I wrote but it stops before > it reaches prompt, that is after 'TERM = (vt100) '. > Can somebody tell me what is wrong? > > Thanks in advance > > sy > > > -------------------------------------- > import telnetlib > > HOST = 'host_name' > user = 'user_name' > pwd = 'my_password' > > tn = telnetlib.Telnet(HOST) > > print tn.read_until('login: ') > tn.write(user+'\n') > > print tn.read_until('Password:') > tn.write(pwd+'\n') > > print tn.read_until('TERM = (vt100) ') > tn.write('\n') > > print tn.read_until('% ') > tn.write('ls\n') > > print tn.read_until('% ') > tn.write('exit\n') > > print tn.read_all() > -------------------------------------- > > > Sent via Deja.com > http://www.deja.com/ > -- > http://mail.python.org/mailman/listinfo/python-list > From one61803 at my-deja.com Fri Jan 5 22:44:40 2001 From: one61803 at my-deja.com (one61803 at my-deja.com) Date: Sat, 06 Jan 2001 03:44:40 GMT Subject: Question about IDLE Message-ID: <9364b7$qse$1@nnrp1.deja.com> Hi, I've been trying out the IDLE IDE for python and the fonts it uses are extremely ugly. I'm running a stock Mandrake 7.2 system with Python 1.5.2. Basically, the fixed font that Tkinter uses is completely distorted (and I think this affects all Tk widgets on my system). I've tried to look at the code for IDLE but while there is place in the program for choosing fonts under Windows, no such place is defined under Linux. Does anyone else have this problem? If so, how were you able to solve it? Thanks Robert Sent via Deja.com http://www.deja.com/ From rcstadheim at scarabweb.com Sat Jan 13 14:09:46 2001 From: rcstadheim at scarabweb.com (RCS) Date: Sat, 13 Jan 2001 20:09:46 +0100 Subject: SV: Python 1.5.2/2.0 C extension type differences References: Message-ID: That fixed it! Thank you very much! Rolf C Stadheim Fredrik Lundh skrev i meldingsnyheter:Ry086.5866$Qb7.841107 at newsb.telia.net... > Rolf Stadheim also forgot to look in the FAQ: > > error C2099: initializer is not a constant, > > > > Any comments/hints/help greatly appreciated!!!! > > it's a compiler/platform specific problem. see FAQ entry 3.24 > for an explanation and two possible work-arounds: > > http://www.python.org/doc/FAQ.html#3.24 > 3.24 "Initializer not a constant" while building DLL on > MS-Windows > > Cheers /F > > From kmbotha at netinfo.ubc.ca Wed Jan 24 12:04:50 2001 From: kmbotha at netinfo.ubc.ca (Kris Botha) Date: Wed, 24 Jan 2001 17:04:50 GMT Subject: Python: what's the best way to copy files on a LAN? Message-ID: <3a6f0af0.272878461@news.interchange.ubc.ca> I mean security-wise. I'd like to use FTPLIB but am hesitant about the security issues involved in using that plain-text protocol. Thanks ~~====----..----====~~ Kris Botha From tbrown at choice.net Mon Jan 29 01:07:07 2001 From: tbrown at choice.net (TIMOTHY BROWN) Date: Mon, 29 Jan 2001 01:07:07 -0500 Subject: Newbie MSAccess & Python Message-ID: <3a75072d$0$1520$6146947b@news.choice.net> Hi, I need to automate printing some access and crystal reports, basically loading the mdb and/or report, sending a username/password and printing. Finding information on OLE objects and how to manipulate them has been the problem. Can anyone recommend a good reference? Maybe there is a better tool? (But Python looks cool.) Thanks, Tim Brown tbrown at choice.net From greg at cosc.canterbury.ac.nz Tue Jan 23 19:53:15 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 24 Jan 2001 13:53:15 +1300 Subject: Solution to integrate(f) raises ??? (Re: How do I know all thrown exceptions of a function)? References: <94imre$7dd$1@slb6.atl.mindspring.net> Message-ID: <3A6E277B.A6B66221@cosc.canterbury.ac.nz> Andrew Dalke wrote: > > def integrate(func, x_min, x_max): > ... > will compute func(x) for several values of x between [x_min, x_max] > ... > > What exceptions does "integrate" throw, given that "func" can > throw anything? I have an answer to this! It requires the language to have nested procedures, and to allow passing of nested procedures as parameters (a la Pascal). Then, by introducing the rule: * If a procedure raises an exception which is not declared in that procedure's signature, it propagates _lexically_ outwards to a procedure which does declare it. Here's an example using a hypothetical pseudo-Pascal which has exception handling: ----- function integrate(function f(x: real): real; lo,hi: real): real raises MathError; begin ... end; function lookup_cache(x: real; var y: real): boolean raises DiskError; begin ... end; function integrate_g: real raises MathError, DiskError; function g(x: real): real raises MathError; var y: real; begin if not lookup_cache(x, y) then {any DiskError raised in here will propagate} y := do_evaluation(x); {out to integrate_g} g := y; end; begin integrate(g, 0.0, 1.0); end; procedure main; begin try integrate_g; except MathError do writeln('Math error!'); except DiskError do writeln('Disk error!'); end; end; ----- As you can see, this allows you to declare integrate() in the natural way, while not restricting in any way what exceptions can be raised in the function being integrated. In g(), it's legal to call lookup_cache() which can raise DiskError, even though g() doesn't declare it, because g() is nested inside another function which does declare it. How to apply this to Python? It would have to wait until we have nested lexical scoping. Then, when an exception is raised, it should be a simple matter to search up the static chain for the frame of a function which has declared that it's willing to raise that exception, and propagate it dynamically from there to its caller. Do the same for the caller, etc., until baked. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From phd at phd.pp.ru Sat Jan 20 06:45:18 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sat, 20 Jan 2001 14:45:18 +0300 (MSK) Subject: Is Python2C dead? In-Reply-To: <3A689E37.639BB513@schlund.de> Message-ID: On Fri, 19 Jan 2001, Carsten Gaebler wrote: > I was wondering where Python2C has gone. > http://lima.mudlib.org/~rassilon/p2c/ doesn't exist anymore. Any clues? http://lima.mudlib.org/~rassilon/p2c/ ^^^^ -> www: http://www.mudlib.org/~rassilon/p2c/ But it holds old version. Probably the development stopped :( Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From dsh8290 at rit.edu Fri Jan 19 12:44:59 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 19 Jan 2001 12:44:59 -0500 Subject: python compiled to native in less than a year? In-Reply-To: <3A67341D.D5022902@businesscollaborator.com>; from paul.robinson@businesscollaborator.com on Thu, Jan 18, 2001 at 06:21:17PM +0000 References: <8pF86.6015$J%.595435@news.flash.net> <0luc6toovfccbqspkvc0dkqkuc5dck7u51@4ax.com> <3A67341D.D5022902@businesscollaborator.com> Message-ID: <20010119124459.F4478@harmony.cs.rit.edu> On Thu, Jan 18, 2001 at 06:21:17PM +0000, Paul Robinson wrote: | [snipp] | .NET runtime. This, IIRC, is similar to what Python2C does, Python -> C | with calls to C api. | This is what jythonc does. It spits out a Java class (source) that consists of calls to the interpreter runtime. Your own Java compiler is what actually creates the byte-codes, and the runtime (jython.jar) is still needed to actually run your "Python as Java bytecode" stuff. Aside from a potential performance degradation (I haven't tested it, but ...) it's not such a bad design. It follows the KISS prinicple. (ie. don't re-invent python's operations to fit the Java object model, instead just interpreter the instructions as normal) -D BTW, I've heard several references to C# on this list, with a high concentration on this thread. Where can I find some sort of (short) docs that describe what C# is? (an intro or overview type of thing) From wgeuens at pandora.be Mon Jan 1 11:52:06 2001 From: wgeuens at pandora.be (Werner Geuens) Date: Mon, 01 Jan 2001 16:52:06 GMT Subject: STRPTIME method missing from TIME class, in win32 ? Message-ID: A very basic method, STRPTIME, seem to be missing from the Win32 distributions. Both 1.5.2 and 2.0 lack this method. A bit weird, considering an ill supported platform such as OS/2 has the method in it's 1.5.x release. The tutorials mensions "This function may not be defined on all platforms.". Can someone give me a sane explanation WHY ? Werner Geuens email: wgeuens at pandora.be From dale at out-think.NOSPAMco.uk Tue Jan 30 21:24:55 2001 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 31 Jan 2001 02:24:55 +0000 Subject: Python 2.1 and Unicode Message-ID: I've just been catching up with the new 2.1 release and there's lots of nice stuff in there. However, I was disapointed not to find any improvements to the way Unicode is handled. Currently we are having to use constructs such as this all over the place when dealing with values from international databases: if type(val) == types.UnicodeType: val = val.encode('Latin-1', 'ignore') else: val = str(val) And it gets even more ugly when lists of values are handled. encode() blows if you give it an integer and str() blows if it doesn't like the Unicode. On top of that, print needs to default to rugged handling of Unicode and not raise an exception. Inserting print statements is normally the quickest way to gather debugging info but it becomes a big problem when dealing with Unicode, requiring code like that above. If you need to print multiple values or lists of Unicode items - well forget it. We need two important features: 1. A print command that defaults to ignoring Unicode conversion errors - or at least has the option to do so. 2. A function, such as str() that converts *anything* to an ASCII string - ignoring Unicode errors. Thanks -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From c.evans at clear.net.nz Fri Jan 26 17:45:30 2001 From: c.evans at clear.net.nz (Carey Evans) Date: 27 Jan 2001 11:45:30 +1300 Subject: crypt module for windows? - fcrypt.py References: <4cla6.2291$Jw.511062@typhoon2.ba-dsg.net> <3A6C5A3C.AD4BD7C@channing.harvard.edu> Message-ID: <871ytq53w5.fsf@psyche.dnsalias.org> Ross Lazarus writes: > I spent some more time with google and found > http://home.clear.net.nz/pages/c.evans/sw/ > which has a link to fcrypt.py - it does exactly what's needed and is > pure python - probably slower than a dll wrapper but it's fine for what > I need. Definitely slower - in my tests, the Python binding to glibc's crypt() function is more than 25 times as fast as my fcrypt.py. This shouldn't be a problem unless you want to crack passwords, though. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "May not be representative of the experience of actual customers." From scarblac at pino.selwerd.nl Mon Jan 1 16:18:53 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 1 Jan 2001 21:18:53 GMT Subject: Recursion References: Message-ID: Bob Calco wrote in comp.lang.python: > Anyone: > > I noticed the following while dabbling in Perl, Ruby and Python recently. > Take your standard factorial implementation, a la: > > PYTHON > ====== > import sys > > def factor(n): > if n == 1: > return 1 > else: > return n*factor(n-1) > > print factor(int(sys.argv[1])) (snip) > The highest value for n you can run in Python is 12; after that you get > overflow error messages. In Perl, the largest value is 170 (after which you > get 1.#INF for an answer). In Ruby, you can input a value as high as 763 > before you get a SystemStackError (stack level too deep) error. I don't have time to answer your other questions, but note that this is a very naive implementation. For huge numbers, Python provides long integers that can grow to arbitrary length. '1L' is the long integer 1. So if you change it to def factor(n): if n==1: return 1L else: return n*factor(n-1) It works way better. It now works up to 999 before you walk into the builtin recursion limit. Changing to a simple non-recursive version is still a lot better: def factor(N): n = 1L for i in xrange(1,N+1): n *= i return n And now the limit is simply your memory, you need enough to hold all the digits (and some patience). Using oversimplified code for benchmarks isn't very useful. > I'm trying to decide which of these languages to embed in my application or > at the very least require in the user environment. I like all of them, and I > lean toward Python because it's much cleaner than Perl and more mature than > Ruby and Mark Hammond's Win32 extenstion fully supports COM on Win32, which > would make it a very useful framework for prototyping our COM objects and > developing our own test suites to exercise them when they are implemented in > C++. But I was surprised to find such a difference when testing each > language's support for recursion. Note that the limit you found had to do with the size of integers mostly, not with recursion. I *think* Stackless Python has no recursion limit since it doesn't use the C stack, but I don't know for sure. -- Remco Gerlich From victor at prodigy.net Tue Jan 16 17:31:06 2001 From: victor at prodigy.net (Victor Muslin) Date: Tue, 16 Jan 2001 22:31:06 GMT Subject: How to call a stored procedure? Message-ID: <3a64c959.600874890@localhost> I am using Python 1.5.2 on WindowsNT. I have a stored procedure defined in Oracle: CREATE OR REPLACE PROCEDURE DELETE_SERVER ( SERVER_ID_ARG IN NUMBER ) AS BEGIN DELETE FROM SERVER WHERE SERVER_ID = SERVER_ID_ARG; COMMIT; END DELETE_SERVER; / Calling it from SQLPLUS works file: SQL> execute delete_server(1); However when I try calling it from Python it gives me an error. Here's the Python program: import dbi, odbc import sys cs = 'db/user/password' dbconn = odbc.odbc(cs) cur = dbconn.cursor() cur.execute("execute vmuslin.delete_adserver(3)"); The error I get is: Traceback (innermost last): File "E:\dev\dclk\eng\src\apps\ADMIN_~1\xx.py", line 7, in ? cur.execute("execute vmuslin.delete_adserver(3)"); dbi.program-error: [Microsoft][ODBC driver for Oracle][Oracle]ORA-00900: invalid SQL statement in EXEC Is it not possible to call stored procedures from Python? From sholden at holdenweb.com Wed Jan 3 02:07:04 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 3 Jan 2001 02:07:04 -0500 Subject: One Python 2.1 idea References: <9292tn$jka$1@nnrp1.deja.com> <929n9c013m3@news1.newsguy.com> Message-ID: <2eA46.11268$uq.460401@e420r-atl1.usenetserver.com> Alex Martelli wrote in message news:929n9c013m3 at news1.newsguy.com... > wrote in message news:9292tn$jka$1 at nnrp1.deja.com... > [snip] > > Second, a question. Consider the invocation of a method, > > such as: > > > > x.foo() > > > > Does this really cause the lookup of the string "foo" > > in x's namespace dictionary? The first time? Every time? > > Yes, and yes. No implicit caching. > > > Is this also the case when data members are accessed? > > Yes once more. > > > Alex > Please tell me it at least interns the names ... regards Steve From dag at orion.no Mon Jan 22 06:28:43 2001 From: dag at orion.no (Dag Sunde) Date: Mon, 22 Jan 2001 11:28:43 GMT Subject: What does Python do References: <94gmeu$4fc$1@sooner.brightok.net> <94gvv5$7mo$1@sooner.brightok.net> Message-ID: I think Python is _very well suited as a first language... I wish I had it around when I set out to change my mind from procedural to OO programming... Keep on, and good luck... Dag. "Dead Dan" wrote in message news:94gvv5$7mo$1 at sooner.brightok.net... > > Dag, > > Thanks, Im just begining in programming and I have had a few suggestiond for > Python. What do you think of it as a first lang, well other HTML. I guess > that dont count > > Dan > > From aleaxit at yahoo.com Sun Jan 28 12:50:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 28 Jan 2001 18:50:30 +0100 Subject: biggner question References: <952951$m4r1@news.qualitynet.net> Message-ID: <951m7d02ut7@news2.newsguy.com> "baasad" wrote in message news:952951$m4r1 at news.qualitynet.net... > how can I read from the command line The arguments passed to the command line when a Python script is run are accessible as a list, named argv, in standard module sys (which you'll need to import, of course). The 0-th of these is the name of the script itself. For example, this script echoes its arguments, if any, to standard output: import sys for arg in sys.argv[1:]: print arg, print If you save it as echo.py and run C:\> python.exe echo.py un deux trois it will output un deux trois > also how can I read users input :) There are two built-in functions for that (nothing needs to be imported), named input and raw_input. Each takes an optional argument (a string with which to prompt the user for input) and returns user-input. The input function expects that the user will type in a Python expression, and uses the built-in function eval to compile and run that expression; it will return its result, or raise an exception in case of syntax-error &c. raw_input is simpler and more general: it just returns the string that the user did write, shorn of the terminating newline. raw_input is what you most often want. Alex From scarblac at pino.selwerd.nl Mon Jan 29 20:42:11 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 30 Jan 2001 01:42:11 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> Message-ID: Rainer Deyke wrote in comp.lang.python: > None of these is really a compelling reason for using '[]' instead of '()' > for access. There is no efficiency difference in Python because both are > implemented as (hidden) method calls, and languages like C++ allow 'f(5) = > 5;'. Is there any good reason for function calls to use a different syntax > than mapping/sequence element access? For one thing, it's possible to have an object that you can do both things on, so the syntax should be different. class Graph: def __getitem__(self, i): print "This column represents 30% of the population" def __call__(self, i): print "This column represents 50% *of the population!*" x = Graph() x[3] x(3) -- Remco Gerlich From moshez at zadka.site.co.il Sat Jan 27 14:30:55 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 27 Jan 2001 21:30:55 +0200 (IST) Subject: Interested in a Crypto-SIG? In-Reply-To: <3A731F26.15461A27@stroeder.com> References: <3A731F26.15461A27@stroeder.com>, <3A72C8A3.C4B4D69A@stroeder.com> Message-ID: <20010127193055.5CD1EA840@darjeeling.zadka.site.co.il> On Sat, 27 Jan 2001, wrote: > -------- Original Message -------- > Subject: Welcome to python-crypto > Date: 27 Jan 2001 18:58:49 -0000 > From: python-crypto Moderator > [..] >

The list is hosted inside the US, as are its archives, so > to avoid falling afoul of the US export restrictions, it's > recommended that postings not contain complete programs or modules. > A few lines of code, for illustrating a point or a bug, are probably > OK. Patches to existing crypto code falls in a grey area; it's best > to mail them to the software's maintainer. > -------- Original Message -------- > > This does not attract me very much. The python.org servers are also inside the US, and are subject to the same restrictions. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From phd at phd.pp.ru Wed Jan 24 06:24:02 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 24 Jan 2001 14:24:02 +0300 (MSK) Subject: Parsing html links In-Reply-To: <1Dyb6.9010$Qb7.1276496@newsb.telia.net> Message-ID: On Wed, 24 Jan 2001, Fredrik Lundh wrote: > "Joonas" wrote: > > How can I make a script im Python that changes all > > 'http://myaddress.spam ' into ' > href="http://myaddress.spam">http://myaddress.spam' > > recently seen on comp.lang.python: I always wonder how things are going in the Universe. A question may lies hidden somewhere in a dark corner, then someone comes and asks the question. Immediatly after him few different people come and ask the same or very similar questions. :))) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From robin at jessikat.fsnet.co.uk Fri Jan 19 15:20:10 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 19 Jan 2001 20:20:10 +0000 Subject: py2exe - convert python scripts into exe files (windows) References: Message-ID: In article , Thomas Heller writes >I've created a distutils extension to convert python scripts >into standalone windows executable files. >You end up with an exe-file as well as pythonxx.dll >plus some .pyd's. > >This is more or less a rewrite of Gordon's installer project. > >Homepage: http://starship.python.net/crew/theller/py2exe/ > >Compatibility: Python 1.5 or later. > >License: BSD > >Regards, > >Thomas Heller Is Gordon's thing no longer supported/alive? -- Robin Becker From sholden at holdenweb.com Thu Jan 4 08:26:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 4 Jan 2001 08:26:59 -0500 Subject: variable inirialization and loop forms (was Re: why no "do : until"?) References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4D6A05.EEC97FA6@uswest.net> <92v6m002nlr@news2.newsguy.com> Message-ID: <9U_46.937$Gd1.78831@e420r-atl2.usenetserver.com> Steve Lamb wrote in message news:slrn9578qr.3mc.grey at teleute.rpglink.com... > [snip, snippety snip snip, snip snip] > We done now? > I certainly hope so. regards Steve From godcha at my-deja.com Wed Jan 17 05:08:11 2001 From: godcha at my-deja.com (godcha at my-deja.com) Date: Wed, 17 Jan 2001 10:08:11 GMT Subject: access FoxPro files without ODBC Message-ID: <943qu9$hde$1@nnrp1.deja.com> This is a newbie question... But after browsing Python Library reference, Python FAQ, and comp.lang.python, I have not been able to determine if there is a way to access FoxPro files without ODBC available for Python. any help appreciated Thanks Godefroid Chapelle BubbleNet sprl Louvain-la-Neuve Belgium Sent via Deja.com http://www.deja.com/ From tdelaney at avaya.com Sun Jan 7 23:44:55 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 8 Jan 2001 15:44:55 +1100 Subject: Execution of import (was Re: boolean xor) Message-ID: I think the real question here though is ... how much overhead is there in calling from operator import truch inside the function each time through (other than the first). There is some overhead in determining that the module is already imported (even though it should only be a dictionary lookup). Tim Delaney Avaya Australia +61 2 9352 9079 > -----Original Message----- > From: Tim Peters [mailto:tim.one at home.com] > Sent: Monday, 8 January 2001 3:43 PM > To: python-list at python.org > Subject: RE: Execution of import (was Re: boolean xor) > > > > def xor(a,b): > > from operator import truth > > return truth(a) ^ truth(b) > > [Peter Hansen] > > An aside: does the 'from .. import' statement execute every time > > the function 'xor' is called, or only during the execution > > of the 'def' statement? > > Every stmt in Python is executable except for "global", and > every executable > stmt executes where it looks like it should . "from" > is the same as > "x=1" in those respects (for that matter, so are "def" and > "class"). So, > yes, every time 'xor' is called. But imported modules are cached in > sys.modules, so anything that imports module X will cause X to get > *executed* only if it's the first time X is imported (by > anything) during > the program run. Imports of X after the first are just > lookups, mapping the > module name to the (already executed) module object and retrieving the > latter. > > blazingly-fast-ly y'rs - tim > > > -- > http://www.python.org/mailman/listinfo/python-list > From sholden at holdenweb.com Fri Jan 12 12:42:28 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 12 Jan 2001 12:42:28 -0500 Subject: URL replacement in text References: <3A5F2A5A.494023BF@thawte.com> Message-ID: <8qH76.14451$Im.109356@e420r-atl1.usenetserver.com> "Fredrik Lundh" wrote in message news:MrG76.5696$Qb7.794378 at newsb.telia.net... > Ryan Tracey wrote: > > Can anybody point me in the right direction on this one. I'd like to > > pass a block of plain text (string) to a function and have that function > > look for URLs and turn them into HTML URL tags > > import re > > links = re.compile("(?:http|ftp|gopher):[a-z0-9._~/%-]+") > > def fixlink(m): > href = m.group(0) > return "%s" % (href, href) > > sometext = """ > here's a link: http://www.pythonware.com > """ > > print links.sub(fixlink, sometext) > > Hope this helps! > > Cheers /F > Tracey: Note that this won't cope with some of the more pathological URLs (such as those with CGI arguments [http://system/cgi?arg1=val1] or those which link to a named anchor in the target page [http://system/pageref#target-name]). Since it's about six times better that anything I could do, however, let this act as a caution rather than a correction. i-like-to-look-at-examples-too-but-avoid-re-when-I-can-ly y'rs - steve From sdm7g at virginia.edu Mon Jan 29 19:20:25 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Mon, 29 Jan 2001 19:20:25 -0500 (EST) Subject: Case sensitive import from case insensitive filesystem (i.e. macosx) [was: CHECK_IMPORT_CASE] In-Reply-To: Message-ID: Whatever CHECK_IMPORT_CASE is there for, it isn't what I thought it was: I thought it might be a hook that could be used to fix the case insensitive import problem on macosx. But import doesn't continue to search if it returns false, so it can't help me. I submitted a patch to SourceForge that fixes the problem on OSX. ( #103495 -- Now you can have both FCNTL and fcntl ! ) -- Steve Majewski From news at dorb.com Mon Jan 1 21:44:41 2001 From: news at dorb.com (Darrell) Date: Tue, 02 Jan 2001 02:44:41 GMT Subject: Recursion References: <3A513319.99F69D27@theworldNoSpammy.com> Message-ID: "David Lees" wrote: > > 1. I notice a pretty low (<999) recursion depth limit for factorial on > Python 2.0. Can the depth be set easily or does it require recompiling > Python? > >From a previous message from Tim. sys.setrecursionlimit(5000) --Darrell From dieter at handshake.de Mon Jan 29 14:55:23 2001 From: dieter at handshake.de (Dieter Maurer) Date: 29 Jan 2001 20:55:23 +0100 Subject: Umlauts revisited: Now they prevent program from running References: <94rt05$tbe$1@newsreaderg1.core.theplanet.net> Message-ID: "Franz GEIGER" writes on Fri, 26 Jan 2001 14:11:20 +0100: > I pull data out of an Excel sheet using DAO. There are field values > containing text strings. Everything works fine until a text reads e.g. > "St?ck". > > After stopping before the exception > > "UnicodeError: ASCII encoding error: ordinal not in range(128)" > > occurs I display the field in the interactive window of PythonWin > (ActiveState 2.0 on NT4) by simply typing "fld.Value". > > It displays u'St\374ck'. > > Conversion into a Python string by applying print or str() yields: > > "Traceback (innermost last): > File "", line 1, in ? > UnicodeError: ASCII encoding error: ordinal not in range(128)" > > Any idea how to overcome this? Inside your "site.py" you can change the default encoding with "sys.setDefaultEncoding" to something appropriate for you. You will find more details by searching the archive of c.l.p. Dieter From paulus132 at my-deja.com Tue Jan 30 18:02:33 2001 From: paulus132 at my-deja.com (paulus132 at my-deja.com) Date: Tue, 30 Jan 2001 23:02:33 GMT Subject: how to store great array? References: <953sps$nta$1@nnrp1.deja.com> Message-ID: <957h63$vqa$1@nnrp1.deja.com> Many thanks for your help! With the Posix arguments of ps, I can follow the memory used by Python for same great objects: import os os.system("ps -o pid,ppid,vsz,etime,time,comm") And with array.array('h'), I can verify that each entry "costs" exactly 2 bytes ! But for a standard list of integers, each entry seems costing something between 16 and 20 bytes ! Array is a good solution for my problem and Python a wonderful language, wich offer so flexible solutions! Paul Perrin In article , jepler at inetnebr.com (Jeff Epler) wrote: > If your document numbers are contiguous and you have decided on in-memory > storage, [1934, 1942, ...], a list of integers rather than strings, > is one choice. Another is the "array" module, which will offer the > lowest overhead. For instance, you can select a type of "byte" (If > all your documents are expected to fall within a 256-year timespan) > or go all the way to "int" (4 billion year range). This storage method is > as efficient as a C array, except for a few bytes of overhead. 2 million Sent via Deja.com http://www.deja.com/ From aleaxit at yahoo.com Mon Jan 8 17:43:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 8 Jan 2001 23:43:11 +0100 Subject: Thank you (was Re: Should I learn Python or Java?) References: <3A593236.6331BE0C@engcorp.com> Message-ID: <93dg5b080h@news1.newsguy.com> "D-Man" wrote in message news:mailman.978966549.13022.python-list at python.org... [snip] > The company I am working for now uses Java for the SDK and runtime > library. Part of the purpose of the product is to generate a Java > class that our customers can use to do screen scraping from Java > apps/applets. Due to the nature of this product and its target > audience it is rather tied to Java. So, can Jython help you? Not a rhetorical question, I'd really like to know -- I don't have a good grasp of exactly how far you can go using Jython vs Java, or what the performance ratios are... Alex From steven.citron-pousty at yale.edu Mon Jan 15 15:23:14 2001 From: steven.citron-pousty at yale.edu (Steven Citron-Pousty) Date: Mon, 15 Jan 2001 15:23:14 -0500 Subject: Problem with a tuple - newbie ignorance References: <3A633531.9010303@yale.edu> Message-ID: <3A635C32.9E5285C5@yale.edu> Sorry all about my incomprehensible message. Honestly, I tried reading the woodrat and the alligator but I can't get this too work. I didn't want to send code because I thought everyone would get POed at me sending code. Here is my code - remember think newbie and don't slam me too hard, its one of those days. Thanks again for any help Steve import os import sys import string import re #numfields is the number of fields to potentially parse numfields = 41 """ THIS LIST IS INCOMPETE - get complete list from the spreadsheet ifields[0] is the name of the field ifields[1] is the content of that field so if we add a new item to the fields we have to add '' to the other 2 lists """ ifields = [['ID =', 'T = ', 'AU =', 'DIST =', 'DNUM =', 'ABS =', 'ARCH.FILTER = I', 'ARCH.FILTER = C', 'ARCH.FILTER = N', 'ARCH.FILTER = S', 'ARCH.FILTER = E', 'CLASSIF', 'ICPSR.CLASSIF1', 'NACJD.CLASS', 'NACDA.CLASS' ,'SAMHDA.CLASS', 'IAED.CLASS', 'EXTENT.COLLECT', 'CLASSNO', 'SERIES.NAME', 'SERIES.INFO', 'RESTRICTIONS =', 'DATA.TYPE', 'TIME.PERIOD', 'DATE.OF.COLLECT', 'FUNDING.AGENCY', 'GRANT.NUMBER', 'DATA.SOURCE', 'EXTENT.PROCESS', 'DATA.FORMAT', 'COLLECT.NOTE', 'SAMPLING =', 'UNIVERSE =', 'RELATED.PUBS', 'CITATION =', 'KEYWORDS =', 'DIR =', 'CHAPTER =', 'SECTION =', 'SUBSECTION =','SUBSUB'], ['','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','']] #read the files and set up file for writing dir = os.listdir('D:\\statlab\\ssda\\data') #read in the list of files in this directory """open the file""" for f in dir: try: fileproc = open('D:\\statlab\\ssda\\data\\'+f, 'r') except IOError: print 'Can\'t open file for reading.' sys.exit(0) #create a new iflieds to store the data. More important for looping #through the directory result = ifields #read the file into a list text = fileproc.readlines() #loop through and find an occurnce of a tag #if you find a tag write it to the field #if you don't find a tag write it to the previous found field for i in text: jindex = 0 found = 0 for j in result[0]: if (i.rfind(j)==0) or (i.rfind(j)==1) or (i.rfind(j)==3): if i.rfind("=")+2 == ' ': where = i.rfind("=")+3 else: where = i.rfind("=")+2 result[1][jindex] = i[where:-1] oldindex = jindex found = 1 # need to write a test for ; at the end if result[1][jindex][-1] == ";": result[1][jindex] = i[where:-2] break elif (i.rfind(j)==6) or (i.rfind(j)==7): if i.rfind("=")+6 == ' ': where = i.rfind("=")+7 else: where = i.rfind("=")+6 result[1][jindex] = i[where:-1] found = 1 oldindex = jindex if result[1][jindex][-1] == ";": result[1][jindex] = i[where:-2] break jindex += 1 if i.rfind("BV =") != -1: break if (found != 1) and (i.rfind("BV =") != -1): result[1][oldindex] += i[0:-1] found = 0 crap = 0 while crap < numfields : if result[1][crap]: print "field # ", result[0][crap], " ", result[1][crap] crap += 1 ___________________________________________________________________________________________________ ###Sample data file ID = 1588; T = Census Of Population And Housing, 1980 [United States]: Summary Tape File 1A; AU = United States Department of Commerce. Bureau of the Census.; DIST = ICPSR; DNUM = 07941; ABS = Summary Tape File 1 consists of four sets of computer-readable data files containing detailed tabulations of the nation's population and housing characteristics produced from the 1980 Census. This series is comprised of Summary Tape File 1A (STF1A), Summary Tape File 1B (STF1B), Summary Tape File 1C (STF1C), and Summary Tape File 1D (STF1D). STF1A, STF1B, and STF1D have 52 separate files, one for each state, Puerto Rico, and the District of Columbia. STF1C consists of one nation-wide datafile containing information about all states. All files in the STF1 series are identical, containing 321 substantive data variables organized in the form of 59 ''tables,'' as well as standard geographic identification variables. All of the data items contained in all the STF 1 files were tabulated from the ''complete count'' or ''100%'' questions included on the 1980 Census questionnaire. All four groups of files within the STF1 series have identical record formats and technical characteristics and differ only in the types of geographical areas for which the summarized data items are presented. STF1A provides summaries for state or state equivalent, county or county equivalent, minor civil division/census county division (MCD/CCD), place or place segment within MCD/CCD or remainder of MCD/CCD, census tract or block numbering area (BNA) or untracted segment within place, place segment or remainder or MCD/CCD, block group (BG) or BG segment or enumeration district (ED). An additional STF 1A file for Outlying Areas is also available from ICPSR. This file contains data specifically for the United States possessions: American Samoa, Guam, Northern Mariana Islands, Trust Territory of the Pacific Islands, and the Virgin Islands. The information contained in this file is similar to but not identical with the data for the 50 states and is documented in a separate codebook. All STF 1 files are being released on a state-by-state ''flow'' basis, with the less populous states generally being prepared and released before the most populous states. Each ''record'' in these files comprises 3,276 characters with two record segments (physical records) of 1,638 characters each, the number of data records in each file varies by state.

CITATION = U.S. Dept. of Commerce, Bureau of the Census. CENSUS OF POPULATION AND HOUSING, 1980 [UNITED STATES]: SUMMARY TAPE FILE 1A [Computer file]. Washington, DC: U.S. Dept. of Commerce, Bureau of the Census [producer], 1982. Ann Arbor, MI: Inter-university Consortium for Political and Social Research [distributor], 1983.; DIR; CHAPTER = Census Enumerations; SECTION = Contemporary; SUBSECTION = United States; BV; BV.TAPE; FILE.NUMBER = 0; NOVELL.LOC = h:\ssda\7941\da7941ct.dat; NRECS = 8772; LRECL = 1638; DS.COMMENTS = ASCII data file: Connecticut; ; From markwart at pcug.org.au Sat Jan 20 00:00:24 2001 From: markwart at pcug.org.au (Victor Markwart) Date: Sat, 20 Jan 2001 16:00:24 +1100 Subject: I will kill my Python References: Message-ID: <3A691B68.FC15BBBB@pcug.org.au> Try Gordon McMillan's 'StandAlone.py' from http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/extsrcwin/gordons_installer/?cvsroot=mojonation#dirlist I've used it and it produces an (pseudo) exe Good luck Victor Bruno Schaefer wrote: > > Hi all, I have written a nice Python application with TKinter. And it > works fine.Yes. But now I want to build an exe, but - o what ashit > with that installer, builder, simple - confuing thing. I have spent > many hours with blood and tears, but o what a shit, ugly shit : > nothing works: The end of all > I give it up. I will kill my python. Its easier with a dummy-xy-Basic > to make an exe as with this shit-modern-"oh what an easy nice > language"-Python. > > Not with me. > > Yeah, python is easy and nice, the pure language, but the rest... > > goodby, I'am going to look for another real easy animal ! > > B.Schaefer From LangaK at discoveryhealth.co.za Mon Jan 15 07:23:59 2001 From: LangaK at discoveryhealth.co.za (Langa Kentane) Date: Mon, 15 Jan 2001 14:23:59 +0200 Subject: checking free disk space Message-ID: Good day. I want to write a script that I can use to check the free disk space on all drives. The script will be used in Linux and Wind0ze. For instance, I want to write something like: get list of mounts/drives for i in mount_list check disk space left in % if disk space is certain amout: do this else do that endif endrun Please can you point me in the right direction. I posted something before on this list but I realised that will not work in a wind0ze environment. Thanks in advance. __________________________________________________________ Langa Kentane | TEL: (011) 290 3218 Security Administrator | Cell: 082 606 1515 DISCOVERY HEALTH | http://www.discoveryhealth.co.za __________________________________________________________________ From grante at visi.com Thu Jan 4 15:17:56 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 04 Jan 2001 20:17:56 GMT Subject: Setting environment for current shell References: <932f4d$n0r$1@nnrp1.deja.com> Message-ID: In article <932f4d$n0r$1 at nnrp1.deja.com>, bragib at my-deja.com wrote: >How do you set an environment for the shell you are running python in. >os.system() spawns its own shell. I would like to gain access to the >parent shell. You can't. You can only modify the current environment not your parent process's. -- Grant Edwards grante Yow! Yow! Those people at look exactly like Donnie visi.com and Marie Osmond!! From erno-news at erno.iki.fi Sat Jan 20 03:26:58 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 20 Jan 2001 10:26:58 +0200 Subject: Translating a Perl script into Python References: Message-ID: In article , grey at despair.rpglink.com (Steve Lamb) writes: | On Sat, 20 Jan 2001 07:13:25 GMT, Sheila King wrote: || open PROC, ">proc.test" || die "Couldn't open file for write: $!"; || Is the closest I can get in Python, to a Perl "die" statement, is to use || exceptions? (I'm directing this to the group, not just Erno, as I realize he || may not know Perl. | Off the top of my head, might not be the best way... [...] | proc = os.open(file,O_WRONLY) why os.open()? i think that would correspond to perl's sysopen function. -- erno From sandeen.NO at SPAM.sgi.com Sat Jan 6 01:21:13 2001 From: sandeen.NO at SPAM.sgi.com (Eric Sandeen) Date: Sat, 06 Jan 2001 00:21:13 -0600 Subject: failed fork with latest 2.4 linux kernel? Message-ID: <3A56B959.F1647198@SPAM.sgi.com> Perhaps I'm way off track, but I seem to be experiencing kernel-related crashing on a python script. This is actually Red Hat's anaconda 7.1, modified to install the latest 2.4 kernel by default. (the installer itself also runs under 2.4.0) Everything worked at -test11, but with -prerelease and 2.4.0, we get this dump (the execWithCapture function is at the end of this message). This will fail for any arv. The kernel version seems to be the only variable here... any ideas? Traceback (innermost last): File "/usr/bin/anaconda", line 471, in ? intf.run(todo, test = test) File "/var/tmp/anaconda-7.1//usr/lib/anaconda/text.py", line 1054, in run rc = apply (step[1](), step[2]) File "/var/tmp/anaconda-7.1//usr/lib/anaconda/textw/timezone_text.py", line 61, in __call__ timezones = self.getTimezoneList(test) File "/var/tmp/anaconda-7.1//usr/lib/anaconda/textw/timezone_text.py", line 25, in getTimezoneList zones = iutil.execWithCapture(cmd, [ cmd ], stdin = stdin) File "/var/tmp/anaconda-7.1//usr/lib/anaconda/iutil.py", line 128, in execWithCapture os.waitpid(childpid, 0) OSError: [Errno 10] No child processes Local variables in innermost frame: argv: ['/usr/bin/gunzip'] childpid: 72 root: / stdin: 10 read: 11 ... and the last function called is this: def execWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0): if not os.access (root + command, os.X_OK): if not os.access (command, os.X_OK): raise RuntimeError, command + " can not be run" else: root = "" (read, write) = os.pipe() childpid = os.fork() if (not childpid): if (root and root != '/'): isys.chroot (root) os.dup2(write, 1) if stdin: os.dup2(stdin, 0) os.close(stdin) if (searchPath): os.execvp(command, argv) else: os.execv(command, argv) sys.exit(1) os.close(write) rc = "" s = "1" while (s): select.select([read], [], []) s = os.read(read, 1000) rc = rc + s os.close(read) os.waitpid(childpid, 0) return rc From trotts at mit.edu Fri Jan 12 19:11:33 2001 From: trotts at mit.edu (Issac Trotts) Date: Fri, 12 Jan 2001 16:11:33 -0800 Subject: brace nanny In-Reply-To: <93nsfk02gdu@drn.newsguy.com>; from not.this@seebelow.org on Fri, Jan 12, 2001 at 01:20:52PM -0800 References: <93nsfk02gdu@drn.newsguy.com> Message-ID: <20010112161133.A977@llnl.gov> Sure, it's called vim: www.vim.org If you turn on syntax highlighting, it will show the mismatched braces in red. Issac Grant Griffin (not.this at seebelow.org) wrote: > Hi Gang, > > Does anybody know of a free/open "brace nanny" for C/C++, preferably written in > Python? (By "brace nanny", of course, I mean a gizmo that finds inconsistencies > between the indentation level and the braces. I've had to change bracing style > lately, so I need a little help with that.) > > braces-are-nothing-but-trouble--ly y'rs, > > =g2 > > _____________________________________________________________________ > > Grant R. Griffin g2 at dspguru.com > Publisher of dspGuru http://www.dspguru.com > Iowegian International Corporation http://www.iowegian.com > > -- > http://www.python.org/mailman/listinfo/python-list -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From gregj at pobox.com Thu Jan 4 03:12:02 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 04 Jan 2001 08:12:02 GMT Subject: Unexpected result for list operator "+=" References: <3A542778.E1BC06E3@bogusaddress.com> Message-ID: "Joe Smith" wrote in message news:3A542778.E1BC06E3 at bogusaddress.com... > > I unexpectedly get l1 modified by doing "l += l2" (see example 1). I take > it is because l and l1 point to the same object. If I use the string type > instead of the list type, I don't get l2 modified. I guess that list > assignment is an assignment of the reference to the object and it does not > copy the object. Where as a string object gets copied (see example 2). You discovered the documented behavior. Assignment of immutable objects (numbers, strings, tuples) essentially makes a copy of the object. Assignment of mutable objects (lists, dictionaries) creates a new reference to the original object. To make a shallow copy of a list (rather than a new reference to the list), the Python idiom is: a = [1, 2, 3, 4, 5] # list of immutable objects b = a[:] # b is a shallow copy of a A shallow copy will do if the list (or dictionary) contains only immutable objects. If the list (or dictionary) contains mutable objects, you will need to make a deep copy. The copy module does this: import copy a = [ [1,2,3], [4,5,6] ] b = copy.deepcopy(a) The "is" operator can test if references refer to the same object: >>> a = [1, 2, 3, 4, 5] # list of immutable objects >>> b = a[:] # b is a shallow copy of a >>> c = b # c references same list as b >>> b == a 1 >>> b is a 0 >>> c == b 1 >>> c is b 1 -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com From loewis at informatik.hu-berlin.de Sat Jan 20 18:47:02 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jan 2001 00:47:02 +0100 Subject: odd NT installation problem References: Message-ID: "bowman" writes: > So, I got the BeOpen 2.0 executable, and the Tcl/Tk 8.3 > packages. Tcl installed fine, but the Python said it detected a > corrupted installation. The Tcl packages are not necessary; BeOpen comes with its own Tcl libraries. I recommend to uninstall any copies of Python and Tcl that you may have on your system. Then, you should remove all registry key in Software\Python, and start all over. If it actually says that the installer is corrupted, please don't forget to include the exact URL of the file that you've downloaded, and the md5sum or atleast the size of the file, so others can get a clue whether download failed. > So, I got Python16.exe. Another corrupted installation. Even if it would work, don't use that version. > I'm using a rather tortuous route, as my Linux box can get out on > the net, but the NT one can't. Are you sure you've enabled binary mode inside ftp? (hint: what else could I guess out of the blue sky) Regards, Martin From amk at mira.erols.com Sun Jan 28 23:40:15 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 29 Jan 2001 04:40:15 GMT Subject: distutils question - anything akin to make's -n flag? References: Message-ID: On Sun, 28 Jan 2001 21:31:42 -0600 (CST), Skip Montanaro wrote: >to see what potential harm it could inflict on my system. I saw nothing in >a quick scan of the distutils documentation to suggest there is an >equivalent to make's -n flag. Am I missing something or am I at the mercy >of the module author? Most, perhaps all, of the distutils commands support -n; try 'python setup.py build --help' to get a list of options. --amk From emile at fenx.com Wed Jan 17 19:52:17 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 17 Jan 2001 16:52:17 -0800 Subject: Strange variable scope... is this right? References: <9456dr$a7h$1@panix2.panix.com> Message-ID: <945ept$cc0lf$1@ID-11957.news.dfncis.de> Ok. Now, for the benefit of those of us (or is it just me ;-) who thought we were getting the hang of code blocks, execution frames and namespaces, it would appear that a for loop pushes references to pop before entering the loop, ala: r = range(5) for i in r: if i == 1: del r print i, #--> 0 1 2 3 4 However, when del-ing a slice, the presumed pushed references are changed: r = range(5) for i in r: if i == 1: del r[2:4] print i, #--> 0 1 4 Therefore, it must be simply a reference to the source object (r) that gets pushed. Assuming that's correct then, is this piece of code with annotations the way that it's working? f = ["row", "cow", "arrow"] # create three element list object and bind to 'f' for f in f: # save reference to 'f' to iterate over, # re-binding 'f' to each in turn for f in range (len (f)): # save reference to newly created range object of len (f) # re-binding 'f' to each in turn It feels like this is less an issue with namespaces and more an issue of how the for loop works. Am-I-getting-closer-ly y'rs, -- Emile van Sebille emile at fenx.com ------------------- "Aahz Maruch" wrote in message news:9456dr$a7h$1 at panix2.panix.com... > In article , wrote: > > > >In another attempt to DTW (Dominate The World), I wrote an obfuscated loop > >just to see the scope behaviour of Python: > > > >f = ["row", "cow", "arrow"] > >for f in f: > > print f > > for f in range (len (f)): > > print f > > Since nobody else has suggested this, try a simple test: > > f = ["row", "cow", "arrow"] > for f in f: > for f in range (len (f)): > print f > print f > -- > --- Aahz (Copyright 2001 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > A house is a machine to keep your cat dry. --Aahz From aleaxit at yahoo.com Fri Jan 5 04:11:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 5 Jan 2001 10:11:30 +0100 Subject: Unexpected result for list operator "+=" References: <3A542778.E1BC06E3@bogusaddress.com> Message-ID: <93435m022if@news2.newsguy.com> "Fredrik Lundh" wrote in message news:rnf56.3809$Qb7.492757 at newsb.telia.net... > Greg Jorgensen wrote: > > The real distinction--that assignment operations on immutable objects > > create new objects (or bind a reference to a different existing object) > > Careful. > > Ordinary assignment operations (a = b) bind names in a name- > space, they never create new objects. Very good point. So, it's always the 'or bind a reference' part. I.e.: "real" ``assignment'' always does nothing more, and nothing less, than binding a reference to the object that is indicated (or built) by the expression to the right of the '='. The "create-new or refer-to-existing" happens on the _right_ of the = sign (just as it may happen in any other expression); then, the '=' itself never does anything but the binding. > Things that may look as assignment operations, but are really > syntactic sugar for method calls, may do whatever they want: > > a[x] = b # short for __setitem__ > a.x = b # short for __setattr__ > a += b # short for __iadd__ > a.append(b) An even better point. Still, there are 'default' behaviors of these pseudo-assignments when applied to objects that define nothing special relevant to the 'method call' that the assignment-like notation stands for. I realize I'm not saying this rigorously enough -- but the default behavior seems to be deserving of full explanation, among other reasons because it's what defines the 'pattern of least astonishment', that an author of [e.g.] a __setattr__ method would be well advised to keep in mind... at least, he or she will have to document carefully significant deviation from what the author of client-code would expect (which is sort of hard if one doesn't precisely know what IS 'expected':-). > There's no distinction between mutable and immutable objects > in Python itself. An object is immutable only if it doesn't have > any methods that allow you to change its content. Neither you > nor Python can do an "ismutable(x)" test. Isn't there a _convention_ about 'immutability' being the prerequisite for usage as a dictionary-key? It is, of course, defined in terms of 'hashability': >>> d={} >>> d[(1,2)]=3 >>> d[[4,5]]=6 Traceback (most recent call last): File "", line 1, in ? TypeError: unhashable type >>> not in terms of 'mutability'... but it's _meant_ to have something to do with mutability, at least in as much as the latter affects comparisons, no? I wonder if this convention is clearly documented somewhere... Alex From bogus@does.not.exist.com Sun Jan 7 13:47:29 2001 From: bogus@does.not.exist.com (Jonathan Polley) Date: Sun, 07 Jan 2001 12:47:29 -0600 Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> Message-ID: <3A58B9C0.9F2A5CC0@collins.rockwell.com> Is is possible to modify the 'enum' function so that I don't have to provide a class? I would like to use something like this method to create enumerated types, but I don't want to keep generating classes that say: class Ufda: def __repr__(self): return self.Enum_Repr[self.type] I would like to just do a: MIDI_Event = enum("NOTE_ON", "NOTE_OFF", 3, "POLYPHONIC_KEY_PRESSURE", "CONTROLLER_CHANGE") and then do MIDI_Event.NOTE_ON. On a related note, how would I map between the enumeration and its ordinal value? Would I add the methods 'ord' and 'val' to the base class (MIDI_Event.ord(MIDI_Event.NOTE_OFF)) yields 3 and MIDI_Event.val(0) yields MIDI_Event.NOTE_ON)? Not being very use to OO and classes, I may need some adult supervision on this ;) Thanks, Jonathan Polley jwpolley at collins.rockwell.com Carel Fellinger wrote: > Will Ware wrote: > ... > > and I would have used this except that I had too many values to count > > conveniently. Also I wanted to keep around string versions of the enum > > names, for __repr__ purposes. So I hit upon this idiom: > > > class MidiEvent: > > > typeNames = [ > > "NOTE_ON", "NOTE_OFF", "POLYPHONIC_KEY_PRESSURE", "CONTROLLER_CHANGE", > > # dozens and dozens more... > > ] > > > # build an enum, this is done once when the module is imported > > # locals() gives the namespace for this class, so they become > > # class attributes > > According to the docs locals() returns dicts that are ment to be > read-only:( So you'll have to spell it out. Unfortunately __dict__ is > unnown at this moment, so is MidiEvent. Simply postpone it till after > the class definition of MidiEvent is finished. > > Classs MidiEvent: > typeNames = ["NOTE_ON", "NOTE_OFF", "... > > i = 0 > for t in MidiEvent.typeNames: > MidiEvent.__dict__[t] = i > > And inspired by Alex's recent contribution for parsing possibly > `valued' command-line like options you could easily enhance this > enumeration idiom to deal with things as enum (a, b=2, c, d=4). > > def enum(C, *args, **keys): > '''Create and enumerate to your hearts delight, > C is the class that wants enumerations, > *args is a sequence of enumeration names, possibly interleaved > with values that override the default value by specifying > the value for the directly preceding enum name. > **keys is a hack to allow to override the default name (enumRepr) > for the dict used to store the reverse mapping from enum > value to enum string > ''' > i, enumRepr = -1, {} # i is the value of the last added enum > for x in args: > if type(x) == type(""): > i += 1 > C.__dict__[x], enumRepr[i] = i, x > elif x>i: > C.__dict__[enumRepr[i]], enumRepr[x] = x, enumRepr[i] > del enumRepr[i] > i = x > elif x raise ValueError, "Enumeration value out of bound" > C.__dict__[keys.get(enumRepr, "enumRepr")] = enumRepr > > Class MidiEvent: > > def __repr__(self): > r = (" (self.enumRepr[self.type], blah, blah, blah)) > # other info > return r + ">" > > enum(MidiEvent, > "NOTE_ON", "NOTE_OFF", 3, "POLYPHONIC_KEY_PRESSURE", "CONTROLLER_CHANGE") > > > -- > > import string,time,os;print string.join((lambda x:x[:10]+x[8:])(map( > > lambda x:string.center("*"*(lambda x:((x<24) ### Seasons Greetings, Will Ware > > *(x-3))+3)(x),24),range(1,28, 2))),"\n") ################ wware at world.std.com > > And the best wishes to you too. (you know that in Holland the sixth > of jan. is taken to be the day that your christmas tree has to vanish:) > -- > groetjes, carel From fabrice.n at home.com Sun Jan 28 09:32:51 2001 From: fabrice.n at home.com (shaka) Date: Sun, 28 Jan 2001 14:32:51 GMT Subject: how do I run a script with a command line Message-ID: It's my first time to use python. And I have win98. I don't know how to run a script with the command line, it always come in interactive mode. How do I input my arguments? From rwklee at home.com Wed Jan 24 21:40:37 2001 From: rwklee at home.com (Rick Lee) Date: Thu, 25 Jan 2001 02:40:37 GMT Subject: ANN: timeoutsocket.py --> v1.12 works with Python 2.0 References: <980352751.234548674@news.flashcom.net> Message-ID: <3A6F9224.FBCE2EF1@home.com> I don't know how expensive threads are. If I have to implement a server, it seems to me that I have to do recv() on every connection I accept on a separate thread. Is that the way to go? Is there a more efficient way? Asyncore? (In my application, all TCP connections are very long lived, there can be up to 1000 simultaneous connections.) - Rick Lee Jeff Bauer wrote: > The timeoutsocket.py module is very useful. Any chance > it could be rolled into the standard python library? > > Jeff Bauer > Rubicon Research From emile at fenx.com Fri Jan 26 16:48:28 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 26 Jan 2001 13:48:28 -0800 Subject: SourceForge problems References: Message-ID: <94srdj$edtl1$1@ID-11957.news.dfncis.de> "Thomas Wouters" wrote in message news:mailman.980545112.10091.python-list at python.org... > On Fri, Jan 26, 2001 at 08:46:09PM +0000, Grant Edwards wrote: > > > >don't-even-try-discussing-hot-steaming-faggots-ly y'rs - tim > > > You're probably not talking about cigarettes or firewood, so > > I'm guessing it's some sort of sausage. But English food is > > best left undiscussed if not uneaten. ;) > > As opposed to the wonderful american inventions of, uuhmm... the hotdog ? > ... or the lekker dutch... eh.. spitskop? ;-) -- Emile van Sebille emile at fenx.com ------------------- From fredrik at effbot.org Tue Jan 16 13:09:29 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 16 Jan 2001 18:09:29 GMT Subject: python compiled to native in less than a year? References: <941koq077o@news1.newsguy.com> Message-ID: Alex Martelli wrote: > > Actually, the IL documentation is pretty good. Assuming the > > MS implementation of it follows the specification, this won't be > > a problem. > > Do you have an URL for non-microsoft sites with the IL docs, please? http://developer.intel.com/software/idap/ecma/index.htm http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/CSharpMirror.html Cheers /F From jasonic at nomadicsltd.com Thu Jan 18 14:38:42 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Thu, 18 Jan 2001 14:38:42 -0500 Subject: Python & GUI? References: <3A674896.C7E52247@crepido.com> Message-ID: Marco Seiri? wrote in message news:3A674896.C7E52247 at crepido.com... > Are there any GUI components or ways to build a GUI in > Python that contains all the widgets that one would expect to > find in a VB or Java environment. Can you (easily) build things > like explorer like applications and such... YES! http://wxpython.org/ wxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a Python extension module (native code) that wraps the popular wxWindows cross platform GUI library, which is written in C++. Like Python and wxWindows, wxPython is Open Source which means that it is free for anyone to use and the source code is available for anyone to look at and modify. Or anyone can contribute fixes or enhnacments to the project. wxPython is a cross-platform toolkit. This means that the same program will run on multiple platforms without modification. Currently supported platforms are Microsoft Windows, and most Unix or unix-like systems. A Macintosh version is a distinct possibility, given I can find the time and that the Mac version of wxWindows is brought up to par with the other platforms. Two good tools to help develop wxPython are: BOA http://boa-constructor.sourceforge.net/Help/AppHelp/ A RAD GUI building Python IDE! It is built on wxPython, wxWindows and Python. Boa Constructor was inspired by and aspires to Delphi. wxDesigner http://www.roebling.de/ FREIBURG, GERMANY, December 19th, 2000: wxDesigner 1.4b released. wxDesigner is now available for 32-bit Windows and several Unix variants. Q: What is wxDesigner? A: A commercial dialog editor and RAD tool for the free wxWindows GUI library. Q: What is wxWindows? A: A free C++ library for cross-platform development, with bindings for Python and Perl. Q: What kind of output does wxDesigner produce? A: wxDesigner can write C++, Python and Perl code directly. Q: Isn't there an XML based resource format for wxWindows? A: This is currently being written and wxDesigner has experimental support for this, too. Q: Is there a version of wxDesigner for the Mac? A: Work is being done on this. It is easy to research such things using 'The Vaults of Parnassus': http://www.vex.net/parnassus for example the GUI graphics list: http://www.vex.net/parnassus/apyllo.py?i=247038364 I always enjoy to check the 'latest' tab there also: http://www.vex.net/parnassus/apyllo.py?a=l The main alterntive to wxPython are the 'Tkinter' tools. A good site to start is http://www.pythonware.com/ A basic Tkinter intro http://www.pythonware.com/library/tkinter/introduction/ and some fresh new souped up GUI tools called 'Tkinter 3000' http://w1.132.telia.com/~u13208596/tkinter/ ...finally some background technopolitic reading about GUI and Python http://www.amk.ca/python/dev/2000-10-2.html good luck --Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] From phd at phd.pp.ru Tue Jan 23 09:35:33 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 23 Jan 2001 17:35:33 +0300 (MSK) Subject: urllib.urlretrieve("http://free.bsdshell.net/") In-Reply-To: <6b1r6tsfjat9fgd5qju029tbeev3i2hgk3@4ax.com> Message-ID: On Tue, 23 Jan 2001, Toby Dickenson wrote: > Is your browser using a proxy that python doesnt know about? I tried urllib on different computers in two different networks. Probably the site does not like my User-Agent. Will try to find the reason. Thanks. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From baasad at qualitynet.net Sun Jan 28 12:28:09 2001 From: baasad at qualitynet.net (baasad) Date: Sun, 28 Jan 2001 20:28:09 +0300 Subject: biggner question Message-ID: <952951$m4r1@news.qualitynet.net> how can I read from the command line also how can I read users input :) thanx bashar From moshez at zadka.site.co.il Sat Jan 27 11:47:47 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 27 Jan 2001 18:47:47 +0200 (IST) Subject: How are threads implemented in Python? In-Reply-To: References: Message-ID: <20010127164747.DF26EA840@darjeeling.zadka.site.co.il> On Sat, 27 Jan 2001 16:32:46 GMT, "Parzival Herzog" wrote: > Are threads implemented as OS threads, thereby multi-threading the > interpreter code, or does the Python interpreter itself maintain a > list of Python treads and switch between them? Well, both. The threads are implemented as OS threads, but Python holds a global interpreter lock (GIL), and only the thread that holds the lock gets to run. The lock is released and reaquired every N instructions. Some instructions release the lock while waiting for OS activity: the classical examples being reading from file descriptors or sockets. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From aleaxit at yahoo.com Tue Jan 16 15:43:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 16 Jan 2001 21:43:07 +0100 Subject: Building a Python OCX References: <9423o8$309$1@nnrp1.deja.com> <9428uv$87i$1@nnrp1.deja.com> Message-ID: <942bsu02qn3@news2.newsguy.com> "Mark Hammond" wrote in message news:9428uv$87i$1 at nnrp1.deja.com... > In article <9423o8$309$1 at nnrp1.deja.com>, > John Urberg wrote: > > Is it possible to build a visual Python OCX control? > > Currently not. > > > Can I access Python objects thru OLE? > > How complex is it? > > It is quite simple to create "standard" COM objects using Python and > access them from any other language. However, the extra interfaces and > complexity required by a true OCX is currently far from trivial. I haven't tried yet, but, couldn't one make a DHTML Scriptlet, 'energized' with Python, and get a 'visual OCX control' that way...? See... (a single URL, even if my posting software or your reader wraps it): http://msdn.microsoft.com/workshop/c-frame.htm?/workshop/components/scriptle t/overview/overview.asp and immediately-following pages about scriptlets (DHTML behaviors are also good, but I don't know how to use them from a generic OCX container, while that's easy for a scriptlet via the Scriptlet Container Object -- also documented close to that page). Alex From dsh8290 at rit.edu Mon Jan 1 16:16:44 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 1 Jan 2001 16:16:44 -0500 Subject: why no "do : until"? In-Reply-To: <92maie$cfo$3@newshost.accu.uu.nl>; from m.faassen@vet.uu.nl on Sun, Dec 31, 2000 at 03:52:46AM +0000 References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> <92maie$cfo$3@newshost.accu.uu.nl> Message-ID: <20010101161644.B30213@westsidecnc.rh.rit.edu> On Sun, Dec 31, 2000 at 03:52:46AM +0000, Martijn Faassen wrote: [snip] > I suspect (and seem to recall hearing about this before) the reason is > more prosaic; how does one indent the darn thing? :) > > do: > .. > until x > 25 > > does not fit a pythonic pattern for statements. > > do: > .. > until x > 25 > > doesn't either, How about until x > 25 : .. ;-) This may remove the "while 1" argument for most cases too! I-wouldn't-complain-if-it-was-added-to-the-language-but-I-won't-fight-for-it-either -D From smibr at my-deja.com Wed Jan 24 16:47:18 2001 From: smibr at my-deja.com (smibr at my-deja.com) Date: Wed, 24 Jan 2001 21:47:18 GMT Subject: Timestamping JPEGs w/ PIL? References: <94ni7p$ta2$1@nnrp1.deja.com> Message-ID: <94nih2$tgd$1@nnrp1.deja.com> In article <94ni7p$ta2$1 at nnrp1.deja.com>, smibr at my-deja.com wrote: > > > http://www.cs.usyd.edu.au/~piers/python/pilfonts.html > > > > Kevin Cazabon. > > I'm getting 404'd on this address. Have they been moved somewhere else? Sorry, not 404'd on that address but unable to get to the ftp-site. I was typing faster than I was thinking. Sent via Deja.com http://www.deja.com/ From timo at alum.mit.edu Wed Jan 24 11:09:04 2001 From: timo at alum.mit.edu (TimO) Date: Wed, 24 Jan 2001 11:09:04 -0500 Subject: ANN: timeoutsocket.py --> v1.12 works with Python 2.0 Message-ID: <980352751.234548674@news.flashcom.net> hola. A number of people have reported problems using timeoutsocket.py with the urllib in Python 2.0. These problems have been fixed! http://www.timo-tasi.org/python/timeoutsocket.py The problem turns out to have been an imcompatibility with the new httplib, which closes the underlying socket before reading any data from the socket.makefile() instance. Let me know if there are any more problems... From dalf at nospam.org Fri Jan 5 11:51:50 2001 From: dalf at nospam.org (dalf) Date: 5 Jan 2001 16:51:50 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> <3A52AD6A.62D043A2@engcorp.com> Message-ID: <934u36$plc$1@ites.inria.fr> Steve Lamb wrote: > On 03 Jan 2001 21:26:49 -0500, Lloyd Zusman wrote: >>But you know damn well that the person who said that was not using the >>word "arbitrary" as you're using it above, and therefore, you're >>deliberately playing with words here, just to be argumentative. > > I am using it in the exact same way. To an arbitrary value, not set it > arbitrarily. To set it to a known value. That is initting a variable. A > value you choose for your own devices. There are two problems: - You set the variable to a value that has no meaning, except that for this variable you are able to simulate the control flow of the program in your head, and the value you chose is going send you at the right point. This is ugly and bug-prone. This is a hack. The very least people would admit here would be: temperature=None while temperature==None or temperature<25: ... Also what value would you use with a different test, such as: temperature= ??? while 0.5 <= math.sin(temperature)+1.0/temperature <= 0.6: ... - Your idiom requires an arbitrary but predictible value, which is ugly as well, since such a value a) might not exist, b) might well require 64 MB of memory, c) might change suddenly when code elsewhere is modified. Consider the following Java code: VeryBigObject veryBigObject=new VeryBigObject("21323EZRer234"); # "21323EZRer234" is the value I know it will pass the test # "21323EZRer235" would NOT do nor 1e100 other values. # Note: uses 64 MB of memory while (veryBigObject.test()) { ... } Now if one change VeryBigObject definition 10 years from now, so that veryBigObject.test() is now verified for "21323EZRer235", but not "21323EZRer234", congrats! You have splendid code breakage, which might be extremely hard to debug. Not to mention the 64 MB of memory wasted until next GC. The conclusion is that you *cannot* use this idiom everywhere. It's just a complete hack. .dalf From aa8vb at yahoo.com Tue Jan 16 10:40:35 2001 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 16 Jan 2001 10:40:35 -0500 Subject: [ANNOUNCE] FreeImage 2.0.0 out! In-Reply-To: <93sbqv$l9gi$1@reader01.wxs.nl>; from flvdberg@wxs.nl on Sun, Jan 14, 2001 at 03:02:05PM +0100 References: <93sbqv$l9gi$1@reader01.wxs.nl> Message-ID: <20010116104035.A5509076@vislab.epa.gov> Floris van den Berg: |FreeImage is designed for multimedia specialists (users of C++, Python or |Magenta II) working on Windows or Linux. FreeImage doesn't work on any other |platform than Windows or Linux at this moment. Support for other platforms |is considered. | |FreeImage only compiles under Microsoft Visual C++ 6. If you want to use |FreeImage with any other compiler, you will have to download the sourcecode |and modify it so that it works with this new compiler. FreeImage ships with |project-files for MSVC6. Curious. It compiles only with MSVC++6.0, yet works on Windows and Linux (??) -- Randall Hopper aa8vb at yahoo.com From steve at spvi.com Sat Jan 20 08:31:35 2001 From: steve at spvi.com (Steve Spicklemire) Date: Sat, 20 Jan 2001 08:31:35 -0500 (EST) Subject: FreeThreading Python? Message-ID: <200101201331.f0KDVZY58692@mercury.spvi.com> Hi Python Folk, I've been living in Zope land now since December of 1998, so I rarely get a chance to read, let alone post, to this list... but with Python-2+ etc I've been wondering about the state of threading and the future of python. Here's what I would love: Go to your favorite 6 processor machine. type: python -c 'from test import test_thread' and all 6 processors are 'max-ed' out while different threads are scheduled on different processors. At one time in the distant past I remember some patches from Greg Stein (I think) that partially/mostly? allowed python to run a lot more code free of the dreaded Global Interpreter Lock (GIL). I'm guessing what he did (I never used, or even examined, these patches since I didn't have access to a system where they would have helped me... much). Now that multiprocessor machines are becoming much more commonplace, is there any effort aimed at updating these patches, or 'fixing' the GIL thingy so that mere mortals might be able to write pure python code that can totally swamp 6 processors at the same time? ;-) If not.... I'm guessing that the other option is to do something like the Zope folks are doing with ZEO and have multiple processes sharing a common object space (e.g., ZODB) and each process can be multithreaded but have a single interpreter instance. Is there any 'beginners' code that implements anything like this? (something you could show a sophomore, or even me, and hope for comprehension). Best of all... one that could make my vision work with very little change to test/test_thread.py. thanks, -steve From hamish_lawson at yahoo.co.uk Thu Jan 11 03:55:46 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Thu, 11 Jan 2001 08:55:46 GMT Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> <93iuqb$rn9$1@panix3.panix.com> <93j8jf$k3u$1@newshost.accu.uu.nl> Message-ID: <93jseg$jnv$1@nnrp1.deja.com> > > Python also support free-standing functions, similar to C++. > > But those functions are objects too. :) As are modules, classes, strings, etc. Hamish Lawson Sent via Deja.com http://www.deja.com/ From glenfant at equod.com.nospam Tue Jan 9 11:10:04 2001 From: glenfant at equod.com.nospam (Gilles Lenfant) Date: Tue, 9 Jan 2001 17:10:04 +0100 Subject: post in CGI scripts References: Message-ID: <93fcrj$3lm$1@reader1.imaginet.fr> Hmmm... With WinNT 4 + (IIS | Apache) + (Python 1.5.2 | python 2.0) I get all data with "cgi.FieldStorage()" and did not need to patch anything. Sorry, I have no experience with Xitami, but... Did you test dummy POST handling scripts with something else than python (i.e. perl)? "Barbini Uberto" a ?crit dans le message news: mailman.979051149.6515.python-list at python.org... > I've found some problems to use "post" method in my cgi script (in python). > > From which I read I assumed that > >>> > import cgi > > form = cgi.FieldStorage() > <<< > > have to run both with "get" and "post" html form methods. > > Anyway my script (a converter from nntp to html) can get input values only > with "get" method and not with "post" method. > > I'm using Xitami under w2k. I configured it adding a filter which link *.py > to python.exe. > > Where I'm doing wrong? > > > Ciao Uberto > From tim.hochberg at ieee.org Thu Jan 18 09:36:06 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 18 Jan 2001 14:36:06 GMT Subject: McMillan's installer & new module References: <94209j$giv$1@athena.euroweb.hu> Message-ID: I meant to post this to the group in response to Arpad's original question, but goofed and sent it directly to him instead. If the problem you're having is that the executable the installer is creating won't find buitin modules such as new, math, etc., this may help. ----------------------------------------------------------------- From: "Arpad Kiss" > Hi, > I have installed Python 2.0 and McMillan's installer(version 3i) on Win NT > 4.0 sp6. > If I use Standalone.py to create a standalone exe and my script contains > only "import new" then the generated exe raises an error message: > ImportError: No module named new > Any idea? This is a bug in the current installer which Gordon is aware of and will presumably fix in an upcoming release. In the meantime, one way to fix this is to add the following magic incantation to the top of your main script: import sys, imputil sys.path.append(imputil.BuiltinImporter()) One could presumably also fix this by editing Builder.py, and I believe this is what Gordon has recomended to people who have asked him about it, but I haven't looked into this myself. Hope that does the trick for you. -tim ----------------------------------------------------------------- "Dan Rolander" wrote in message news:mailman.979754736.14513.python-list at python.org... > I've played around with Gordon's Installer a bit, but have gotten stuck when > it can't find all the modules I need. He does have a lot of information on > his web site but I'm not sure I understand all of it. Is there a better way > to package Python scripts into standalone exe's for Win32? I've read a > little about freeze, squeeze, distutils, etc. but haven't tried them. > > Any thoughts? > > Thanks, > Dan > > ----- Original Message ----- > From: "Pete Shinners" > Newsgroups: comp.lang.python > To: > Sent: Wednesday, January 17, 2001 12:18 PM > Subject: Re: McMillan's installer & new module > > > > "Arpad Kiss" wrote > > > I have installed Python 2.0 and McMillan's installer(version 3i) on Win > NT > > > 4.0 sp6. > > > If I use Standalone.py to create a standalone exe and my script contains > > > only "import new" then the generated exe raises an error message: > > > ImportError: No module named new > > > > last i heard from gordon, there is definitely a problem with the > > latest installer when it tries to import the builtin modules > > (time, new, etc). > > gordon seems pretty busy these days and said a new version would > > be available whenever he can get around to it. > > > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > From aleaxit at yahoo.com Fri Jan 19 17:04:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 19 Jan 2001 23:04:25 +0100 Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> <3a685ef2.3403798@reading.news.pipex.net> <949rii0a76@news1.newsguy.com> Message-ID: <94adta01pq3@news2.newsguy.com> "D-Man" wrote in message news:mailman.979929746.2047.python-list at python.org... > On Fri, Jan 19, 2001 at 05:55:45PM +0100, Alex Martelli wrote: [snip] > | nice to have movement commands based on indent-levels, but, to be > | quite honest with you, I've never bothered programming them... > > I'd like this too. In C/C++/Java it is nice to type "%" to jump > between begin and end of blocks. Guess I've found a project on which to use gvim's Python programmability... > | (shame's about to engulf me...). I like :set expandtab always > | on -- no tab/space confusion; I also like :set ff unix, so that my > | scripts can be shared between Win and Unix machines (and why > | waste one byte per line to tell a 'carriage' that is not there > | to 'return' [to where?]...?!-). > > Exactly. DOS/Windows never did operate from a teletype did it? I No, but QDOS strictly imitated CP/M (rumor has it that it was little more than an 8086 reassembly of a disassembly of CP/M...) which in turn took most of its conventions from an Intel OS which in turn got them from some Digital Equipment one (I ain't kidding...!). > | may have inserted, :%s/^Q^M// is what one types (with ^ to mean > ^ > What does the % mean here? I usually use :g/^V^M/s/// (working on NT > or in cygwin's console vim). :%s means to do the substitution on all lines (I know it always did in all vi's, and I think it also always did in ex's). Note how many keystrokes it saves compared to your chosen idiom!-) Alex From fredrik at effbot.org Mon Jan 29 12:28:23 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 29 Jan 2001 17:28:23 GMT Subject: marshal doesn't work with "file-like" objects References: <5.0.2.1.0.20010126135016.029c4d90@mail.mindspring.com> <94t1bi$m73$1@nnrp1.deja.com> <950a3c$27b$1@nnrp1.deja.com> <9546rk$15i$1@nnrp1.deja.com> Message-ID: Chuck won't just give up: > I must be missing which post you refer to. I ultimately responded to > the Tim Peters post that I see. here's his post: You could do this instead: filelikeobject.write(marshal.dumps(object)) Reading a sequence of marshaled values back from a file-like object is more of a puzzle! Note the second part ("more of a puzzle" is a polite way to say "impossible, if you care about performance"). > I guess at some point I'll just have to hack this myself and report the > benchmarks. Do you see what I'm saying about speed, though? It's > generally faster to do operations in memory and then write one long > byte string than it is to repeatedly write a small bits of data to disk. Starting with 2.1a1, Python does this when importing from PYC files (if you follow the link I posted earlier, you might be able to figure out who came up with that idea ;-). But that's a special case; in normal cases, load has to read the stream byte for byte. But if all you want to do is write, use Tim's write(dumps) approach. There's no way you can do it with fewer Python-level calls... Cheers /F From joejava at dragonat.net Sat Jan 6 09:36:39 2001 From: joejava at dragonat.net (Joel Ricker) Date: Sat, 6 Jan 2001 09:36:39 -0500 Subject: What makes Python Python (was: OO in Python (was Re: Migrating to perl?)) References: <3Fa56.4580$of7.216286@news1.atl> <934ghv02hg0@news2.newsguy.com> <3284C8A2D218D5A4.904FDBE7634A2E21.13E03F073E968847@lp.airnews.net> <934noe02o73@news2.newsguy.com> <200101051648.KAA49133@starbase.neosoft.com> <936qce0p55@news1.newsguy.com> Message-ID: Alex Martelli wrote in message <936qce0p55 at news1.newsguy.com>... >The really strange thing is, the various parts meld into a >whole that is greater than the sum of the parts! If I >"designed" a language by cherry-picking thinks I liked from >others, the result would be sure to be an unholy mess. Not necessarily. Its how we've come to have Python, or Perl, or a number of languages written by people who have decided that language x doesn't have y so they created their own and a new language z is born. Then, people will be discussing why language z doesn't have a, b, or c and the process continues ;) Joel From robinjim at earthlink.net Thu Jan 18 20:32:26 2001 From: robinjim at earthlink.net (robin and jim) Date: Fri, 19 Jan 2001 01:32:26 GMT Subject: importing classes from a variable References: Message-ID: hello Justin, Are you looking for something like the following? import os, string, sys directory_name = sys .argv [1] package_name = string .replace (directory_name, os.sep, '.') try: package = __import__ ( package_name, globals(), locals(), ['__init__'] ) modules = getattr (package, '__all__') except AttributeError, message: handle_error ('"__init__.py" file for ' + directory_name + ' has no "__all__ attribute') except ImportError, message: handle_error (directory_name + ' has no "__init__.py" file') "JustinHJ" wrote in message news:t6f17dps6c4d87 at corp.supernews.com... > Could anyone offer any advice on the following problem. What I have is a > python program that takes a file and does something to it by calling member > functions in a class. To seperate the code that does the export from the > main program, what I wanted to do is to be able to go from a text string > name of the export process.... > > str = 'export_1' > > and do the equivalent of > > import 'export_1' > > exportclass = export1.Export.DoExport > > So in case that's not clear I want to be able to import modules in a class > without knowing their name until runtime, then use the module name as a > variable.EG: > > export_string = 'export_1' > > import export_string # this doesn't work > > export_string.Export # this doesn't work either > > > > > From aleaxit at yahoo.com Fri Jan 12 07:34:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 12 Jan 2001 13:34:15 +0100 Subject: Using Python COM objects from C++ References: <93lsgt$q72$1@troll.powertech.no> Message-ID: <93mtn30qsk@news1.newsguy.com> "Syver Enstad" wrote in message news:93lsgt$q72$1 at troll.powertech.no... [snip] > > I know how to call the python COM object using "pure" IDispatch, but is it > > possible to make a type library and ensure that the Python class > > implementing the COM complies with it? > > > > The problem would be the dispatch id's as far as I can see. I don't know > > how to specify the dispatch id's that the method's in the python object > > should have. > > > I found an okay solution. > > Make your python com object just as you use to, but: > > Make the class variable _public_methods_ empty, like this. > _public_methods = [] > > Make a class variable _dispid_to_func_ that is a dictionary mapping dispids > to function names. Like this: > _dispid_to_func_ = {0x1:'Dummy', 0x2:'Swear'} > > If you want to implement a dispinterface from a typelibrary/idl file adjust > the _dispid_to_func_ dictionary so it matches the idl. Right! This IS one way to achieve the results you desire. However, you can save some boring manual work by letting makepy (and other allied tools) generate the Python 'skeletons' for you, directly from the information that is contained in the type library. Let's try a simple example. Say we have an IDL file, SAMPATL.IDL: import "oaidl.idl"; import "ocidl.idl"; [ uuid(EB8DED71-E882-11D4-9E4C-0060B0EB1D67), version(1.0), helpstring("A Sample Type Library") ] library SAMPATLLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); [ uuid(EB8DED7F-E882-11D4-9E4C-0060B0EB1D67), helpstring("A Sample DispInterface") ] dispinterface MyInterface { properties: methods: [id(1), helpstring("a method")] HRESULT AMethod([in]LONG aLong); [id(2), helpstring("another method")] HRESULT AnotherMethod([in]BSTR aString, [out, retval]BSTR* theResult); [propget, id(3), helpstring("a read-only property")] HRESULT ReadOnly([out, retval] double *pVal); [propget, id(5), helpstring("a read-write property")] HRESULT AProperty([out, retval] DATE *pVal); [propput, id(5)] HRESULT AProperty([in] DATE newVal); }; }; We compile this with MIDL to get SAMPATL.TLB. Then we run something like: D:\experiments\sampatl>python \python20\win32com\client\makepy.py sampatl.tlb Generating to d:\python20\win32com\gen_py\EB8DED71-E882-11D4-9E4C-0060B0EB1D67x0x1x0.py Examining the python-file which we've just been told has been generated, we'll see, among a few other things, something like: class MyInterface(DispatchBaseClass): """A Sample DispInterface""" CLSID = pythoncom.MakeIID('{EB8DED7F-E882-11D4-9E4C-0060B0EB1D67}') def AMethod(self, aLong=defaultNamedNotOptArg): """a method""" return self._oleobj_.InvokeTypes(0x1, LCID, 1, (3, 0), ((3, 1),),aLong) def AnotherMethod(self, aString=defaultNamedNotOptArg, theResult=defaultNamedNotOptArg): """another method""" return self._ApplyTypes_(0x2, 1, (3, 0), ((8, 1), (16392, 10)), 'AnotherMethod', None,aString, theResult) _prop_map_get_ = { "AProperty": (5, 2, (3, 0), ((16391, 10),), "AProperty", None), "ReadOnly": (3, 2, (3, 0), ((16389, 10),), "ReadOnly", None), } _prop_map_put_ = { "AProperty": ((5, LCID, 4, 0),()), } Not _quite_ what you need, but, getting there. I find it often helpful to have the CLSID, helpstrings, argument names, etc, all present -- the dispatch ID's you need are also here, though not evidently so (the first arguments to InvokeTypes and _ApplyTypes_ call, first elements in the tuples in the maps for get and put properties), so you need not consult the IDL or other docs to double-check them. Massaging the makepy-generated Python code, or imitating makepy and friends into a similar tool that generates (ideally decently-named:-) python sources that are immediately suitable to inherit from, is left as an exercise to the student:-). Actually, I haven't found this process to be a frequent enough need for me, to be worth the work to automate it fully -- because of the limitation to dispinterfaces, which IS somewhat drastic. Still, it IS helpful to have a type-library, anyway, if you implement Python COM servers that you need to consume from some other languages (it doesn't help with VBscript or JScript, but it _is_ a bit helpful with VB, and almost-indispensable should you ever want to use C++ as the client of such COM objects...) -- and this is one good way to achieve that. Alex From xoltar1 at home.com Tue Jan 23 18:29:06 2001 From: xoltar1 at home.com (Bryn & Anshu) Date: Tue, 23 Jan 2001 23:29:06 GMT Subject: Keyboard and mouse simulation? Message-ID: <3A6F6A89.EEA95D9C@home.com> Hi folks, I need to develop an automated GUI test tool. Can anyone provide examples or pointers on how to simulate key presses, movement of the mouse, etc., either based on the Qt framework or on the Windows API? I'm using PyQt, and I've found the QCursor.setPos() method which works fine for movement, but I can't find anything to simulate presses of mouse or keyboar button aside from posting events. Posting events to the event queue doesn't seem to have the desired (or any) effect. Thanks in advance, Bryn From aleaxit at yahoo.com Tue Jan 23 16:05:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 23 Jan 2001 22:05:51 +0100 Subject: unpack sequence to tuple? References: <94j6j1$3na$1@nnrp1.deja.com> <94jjtb0108j@news1.newsguy.com> <94kf4n$58u$1@nnrp1.deja.com> Message-ID: <94krq40bh6@news2.newsguy.com> "John Nielsen" wrote in message news:94kf4n$58u$1 at nnrp1.deja.com... [snip] > > Unfortunately, tuples and lists cannot be concatenated, which > > is why we need to cast the sequence into a definite form here -- > > choosing list would of course work just as well: > > > > def padSequence(seq, length): > > return (list(seq)+[None]*length)[:length] > > Or you could just use extend. which may be a little clearer. > > def padSequence(seq, length): > a=list(seq) > a.extend(list((None,)*length)) > return a[:length] Clarity, I guess, is in the eye of the beholder; even if I did decide to split this simple function into three statements, they'd likely be: def padSequence(seq, length): temp = list(seq) temp += [None]*length return temp[:length] at least the [None]*length is clearly simply than starting from the (None,)*length tuple then casting it to a list (not that you NEED the cast, if .extend is what you want to use -- .extend can be called with any sequence). But if one does decide to split it up into multiple statements, then it may be worth distinguishing the cases of too-long and too-short sequences; the 'homogeneization' into "always too long" which I get by appending length copies of None has the specific purpose of letting a single expression work without conditionals (which are not clear nor comfortable in expressions, though the can often be built up from and and or applications). def padSequence(seq, length): if len(seq)>=length: return seq[:length] return list(seq)+[None]*(length-len(seq)) This is probably the first thing that will come to mind to a newbie, after all, and thus might be simplest for said newbie to understand. Alex From rwklee at home.com Sun Jan 21 18:56:06 2001 From: rwklee at home.com (Rick Lee) Date: Sun, 21 Jan 2001 23:56:06 GMT Subject: Markov.py References: <94eavq$5cl$1@nnrp1.deja.com> <94eulk$dduhj$1@ID-11957.news.dfncis.de> Message-ID: <3A6B7716.68A62115@home.com> You can pass a command line parms in a Mac by option-double-clicking on the .py or .pyc file, or by option-dragging-and-dropping the .py or .pyc file onto the python interpreter application; this opens up a dialog where you can set all the interpreter command line options. - Rick Lee Emile van Sebille wrote: > The documentation is included in the script itself, see the > start of the test routine. On a system with a command line > interface, this runs as the documentation indicates, > however, I'm not sure how command line arguments are passed > to the Mac. You can insert a line in the test routine: > > args = [r'd:\python20\test.txt'] > > to assign to args directly instead of reading it from the > command line. At least then it does something. > > HTH, > > -- > > Emile van Sebille > emile at fenx.com > ------------------- > > wrote in message > news:94eavq$5cl$1 at nnrp1.deja.com... > > I found the following script in the mac standard > distribution (see path > > below). It seems to be Guido's, i am not sure however, i > am at a loss > > as to how to use this. I was unable to run it and there is > not > > documentation. In otherwords, i put on my detective hat > but was still > > unable to get the thing to run. Anyone use this and can > explain to me > > how? The script is a bit to big and complex for my level > of python kno- > > how, but how sweet would it be to be able to make a markov > chain in > > python without having to re-invent the wheel. Particularly > since i > > wouldn't be able to in this case! > > > > cheers, > > kevin parks > > seoul, korea > > cpsoct at lycos.com > > From ullrich at math.okstate.edu Sun Jan 7 07:54:50 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 07 Jan 2001 12:54:50 GMT Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <933fa1$j2i$1@newshost.accu.uu.nl> <3a57342f.92981493@nntp.sprynet.com> Message-ID: <3a5866e2.43408019@nntp.sprynet.com> On Sat, 6 Jan 2001 18:33:22 -0500, "Joel Ricker" wrote: > >David C. Ullrich wrote in message <3a57342f.92981493 at nntp.sprynet.com>... > >[..] > >>You should do what Tim said: Download it and work through the >>tutorial. Really will take less time than reading this thread. > > >Thats true. I've spent more time keeping up with this thread than reading >the tutorial. Thats why I've only gotten up to Chapter 5 :) Well never mind then. (From the rest of the thread it sounded like you were still trying to decide whether to take the drastic step of actually trying it...) >>The docs are excellent. But they omit a few important >>principles. Like "always believe Tim". > > >So far I've had no reason to doubt him. > >Joel >' > > From m.faassen at vet.uu.nl Thu Jan 11 09:52:49 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 11 Jan 2001 14:52:49 GMT Subject: [ot] Guttral Mumblings (Re: Web devel with python. Whats the best route?) References: <93cqvi0191h@news1.newsguy.com> <93dfft077p@news1.newsguy.com> <93f4q7$ji4$1@newshost.accu.uu.nl> <90259B539rcamesz@127.0.0.1> <93hpsr$k1k$2@newshost.accu.uu.nl> <90262FC49rcamesz@127.0.0.1> Message-ID: <93khc1$f6o$1@newshost.accu.uu.nl> Robert Amesz wrote: > Martijn Faassen wrote: >>Robert Amesz wrote: >>> Martijn Faassen wrote: >> >>>> [Snip] >>>> >>>>Dus, voorwaards met dat Nederlands! >>> --------^- >> >>> Well, one can but hope... >> >>Een anglisme. Ik tiep ook veel Engels. :) > So I've noticed. I agree, English and Dutch have a lot of words in > common, so it's easy to mix up the spelling of those words. (Oh, and > it's "anglicisme", by the way, a word for which there is no such > excuse, I'm afraid. ) Argh, *hits himself over the head and magnles viraous Englash words in the precoss for ged maeseru!!* Groeten, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From tim.one at home.com Wed Jan 3 23:00:45 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 3 Jan 2001 23:00:45 -0500 Subject: Which Python homesite to refer people to ? In-Reply-To: Message-ID: [Jason Cunliffe] > ... > To rephrase my question - > > a:- Have the Python domain ownership issues now been sorted? > > b:- Is www.python.org site back, legit, holy and in caring hands? > > c:- Who is maintaining it? Guido is maintaining it, alone and in his non-existent "spare time" (which explains why updates are almost non-existent too). I heard a rumor that we hope to Zopeify the site and then turn it over to the community. Can't guess when (or even if) that will happen, though. about-ownership-issues-have-your-lawyers-call-ours<0.9-wink>-ly y'rs - tim From dsh8290 at rit.edu Wed Jan 3 17:36:18 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 3 Jan 2001 17:36:18 -0500 Subject: problem compiling Python 2.0 on Sun Solaris In-Reply-To: <3a539455.17521624@news.wanadoo.fr>; from jef.mangelschots@iname.com on Wed, Jan 03, 2001 at 09:10:44PM +0000 References: <3a539455.17521624@news.wanadoo.fr> Message-ID: <20010103173618.B7037@westsidecnc.rh.rit.edu> The tarball should have Unix-style line endings. In anycase you can use the Dos2Unix program that will remove the erroneous 0x0A 's from the files. If you don't have it, a not very robust one could be written in very little time. (actually, you could probably use sed to do it). HTH, -D On Wed, Jan 03, 2001 at 09:10:44PM +0000, Jef Mangelschots wrote: > Hi, > > I just downloaded the sources for Python 2.0 from > http://www.python.org/ftp/python/2.0/BeOpen-Python-2.0.tar.gz > > ALL the text files are unrecognizable to my system because each line > is ended with 0x0D 0x0A, common for Windows NT systems, but not for > Unix systems. > > Does anybody have a suggestion ? From erno-news at erno.iki.fi Mon Jan 15 12:50:49 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 15 Jan 2001 19:50:49 +0200 Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com> <93om7l$p6s$1@nnrp1.deja.com> <93t6bv$pj$1@nnrp1.deja.com> <93uqu302sdf@news1.newsguy.com> Message-ID: In article <93uqu302sdf at news1.newsguy.com>, "Alex Martelli" writes: | "Erno Kuusela" wrote in message | news:kud7dpg247.fsf at lasipalatsi.fi... | [snip] || that's what i said, they are a part of the information :). http || tries to be stateless in principle (cookies aren't part of the http || spec i think). | Wrong, see RFC 2109, "HTTP State Management Mechanism". That is | where cookies are specified in detail. that doesn't make them part of http :) || the content behind the session-unique url is perfectly cacheable by || intermediate proxies, unlike for cookies. | See session "4.2.3 Controlling Caching" of rfc2109; cookies give | you very fine-grained control of what is intended to get cached | where (actually, the Cache-control header does that, but, it's | designed to work with HTTP state management, i.e., cookies). ok, i stand corrected. || a large percentage of the people i know are using either junkbuster or || a browser (such as mozilla and konqueror) that can enable/disable || cookies on a per-site basis. | Bully for them. If they decide that they don't want client-side | state to be stored on their machine, I guess that makes sense for | them; so, use the standard-specified way to offer up state for | client-side storage (i.e., cookies) and let the users decide. just because there's a standard for something doesn't mean it is good or desireable. i wonder if you're aware of the motivation behind not wanting to accept all cookies? for some background, read . i for example usually just skip sites that don't work with my default no-cookies/no-javascript browser setting. the url approach cannot be subverted for the use cookies most often see. -- erno From aleaxit at yahoo.com Thu Jan 18 15:44:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 21:44:40 +0100 Subject: parsing a file [newbie] References: <_fp96.178$eI2.100474@ruti.visi.com> <947jg4$55r$1@troll.powertech.no> Message-ID: <947kn701j0k@news2.newsguy.com> "Syver Enstad" wrote in message news:947jg4$55r$1 at troll.powertech.no... > > "Grant Edwards" wrote > I could have used a list comprehension instead of a > > for loop. > > Ouch, I feel really stupid to have to ask this question, but what the ... is > a list comprehension, and why is it better to use it than a for statement? It's not necessarily better -- it may be if the gain in concision translates into clarity. The syntax, new to Python 2, is in the simplest case, e.g.: return [ for in ] equivalent to: result = [] for in : result.append() return result A compact yet readable single-line, expression way to express a single high-level concept, can easily be a gain of clarity. The conditional form: return [ for in if ] equivalent to: result = [] for in : if : result.append() return result can be at least as much of a clarity gain. There is no nesting limit to the for and if clauses of the list-comprehension syntax, but deep nesting is often not all that clear no matter how you dice and slice it, so you might be well-advised to refactor things if you find more than a couple of for clauses in a comprehension (nesting if clauses hardly ever makes much sense, since 'if if ' is the same as 'if and '). Alex From news at dorb.com Mon Jan 15 21:31:03 2001 From: news at dorb.com (Darrell) Date: Tue, 16 Jan 2001 02:31:03 GMT Subject: Python and Industry References: <20010111172342.10148.00000934@ng-ca1.aol.com> Message-ID: I'm swimming in Python work and increasingly Zope work also. Python is fun. Customers and their employees can be infected with this virus. This may be an instance of a trans human/computer virus. Write a bunch of software and your customer will often worry about you leaving. Who will take care of this stuff? So they limit your tools, among other annoying things. When they start asking these questions, I produce one of their Pythonized/Zombie employees. Who nods their head up and down when asked if they could maintain this stuff. And the conquest continues! I should become a distributor of introductory Python books, what a racket :) --Darrell "Crutoy" wrote: > Hi , does anyone know how widly in an instries does python being used ? I > looked at the syntax of it and read some stuff on it,it's interested i just > want to know if it's worth learning it. Thanks From gregj at pobox.com Mon Jan 1 14:52:37 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Mon, 01 Jan 2001 19:52:37 GMT Subject: A single, general looping construct? (was: why no "do : until"?) References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <92qc21$538$1@nnrp1.deja.com> Message-ID: <9e546.215669$U46.6580243@news1.sttls1.wa.home.com> wrote in message: > A couple of decades ago, when the programming journals > were full of arguments about the "right" control > statements for structured programming, someone proposed > a single iteration statement that generalized (a) the > "while" statement, (b) the "do .. until" statement, > and (c) the loop with an exit in the middle. I forget Prime's INFO*BASIC (a version of Pick BASIC) had that loop construct. It was one of the best things about that language. -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com From corey at axcelerant.com Tue Jan 16 14:19:21 2001 From: corey at axcelerant.com (Corey) Date: Tue, 16 Jan 2001 19:19:21 GMT Subject: using __init__ with params ( somewhat long ) Message-ID: Greetings all! I'm new to Python ( from 5 odd years of Perl ), so please bare with me... I'm not quite sure how to go about defining a "proper" Python class constructor, where the user can optionaly pass a parameter, or multiple parameters at instantiation, as a shortcut to initializing the object's attributes in one pass, rather than using multiple 'set' methods after instantiation. For instance, if I'm creating a class called MyClass, with attributes myattr1, myattr2 and myattr3, and methods set_myattr1, get_myattr1, etc., rather than first creating a MyClass object and *then* calling the proper 'set' method for each attribute, I'd like to do one or both of two things: 1 - Allow a dictionary to be passed to __init__, containing as keys some or all of the attributes, along with their values of course. such as: class MyClass: def __init__(self, dictionary): # the below could not *possibly* be considered Good(tm) self.__myattr1 = dictionary['myattr1'] self.__myattr2 = dictionary['myattr2'] self.__myattr3 = dictionary['myattr3'] attr_dict = { 'myattr1': 'goober', 'myattr3': 'lame' } myobj = MyClass(attr_dict) ... What if dictionary is not provided? Use an if statement first? Make dictionary a named parameter with a default of None? What if dictionary is provided, but does not have one of the keys? Use more if statements to test their existance with has_key? Use a for statement to iterate through each provided key and define 'None' for those that weren't included? And what if dictionary contained MyAttr1 or MYATTR1 or myaTtr1? I would like the user to not worry about case... My constructor seems to be getting really big at that point, just to facilitate for some convienience to the user... What I'm looking for is what, if any, "standard", short-hand Pythonesque ways of doing this would be. Like I said, I'm new to Python and so am unfamiliar with much of it's notations. I'd rather write this simply and elegantly, rather than by sheer, lengthy brute-force, or to end up with something any Python programmer would look at and wonder what the hell I was smoking when I coded it. Also, *should* I make dictionary a named parameter, or leave it as a floating argument? Further, I'd also like to include the following, in addition to point #1, above. 2 - And/or allow named arguments to be passed into __init__, one for each attribute. So that we now have: ( which still runs me into the case issue ) def __init__(self, dictionary, attr1=None, attr2=None, attr3=None): Is this considered overkill? It seems like it to me when thinking about it, but I'm perhaps too stuck in the Perl "There's More Than One Way To Do It" mindset... and so want to make this class as easy to use as possible within the context/methodology of which it gets utilized. Thanks a ton for your kind advice and insight. Beers, Corey From MarkH at ActiveState.com Fri Jan 19 15:34:13 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 19 Jan 2001 20:34:13 GMT Subject: win ce and python References: Message-ID: <94a8c5$31l$1@nnrp1.deja.com> In article , Bryan Mongeau wrote: > tony roth wrote: > > > is there anything going on with python and win ce devices > > it seems to be kinda dead. Any ideas or suggestions. > Kinda strange how no one has answered your question yet, > Tony. Seems as if python for Windows CE is alive and well at > > http://www.digicool.com/~brian/PythonCE/index.html >From that page: The current release of Python CE is 1.0b1, released 17 July, 1998. So I dont believe "alive and well" is a reasonable description of that port :-) A later version can be found at http://starship.python.net/crew/mhammond/ce/ - and you can find a link to the egroups mailing list. However, there has been no recent activity (other than people asking if there is any activity :-) Mark. Sent via Deja.com http://www.deja.com/ From phd at phd.pp.ru Tue Jan 16 10:59:07 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 16 Jan 2001 18:59:07 +0300 (MSK) Subject: [ANNOUNCE] FreeImage 2.0.0 out! In-Reply-To: <20010116104035.A5509076@vislab.epa.gov> Message-ID: On Tue, 16 Jan 2001, Randall Hopper wrote: > Floris van den Berg: > |FreeImage is designed for multimedia specialists (users of C++, Python or > |Magenta II) working on Windows or Linux. FreeImage doesn't work on any other > |platform than Windows or Linux at this moment. Support for other platforms > |is considered. > | > |FreeImage only compiles under Microsoft Visual C++ 6. If you want to use > |FreeImage with any other compiler, you will have to download the sourcecode > |and modify it so that it works with this new compiler. FreeImage ships with > |project-files for MSVC6. > > Curious. It compiles only with MSVC++6.0, yet works on Windows and Linux (??) It compiles on Linux, but not on *BSD? :))) Cannot believe it. :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleaxit at yahoo.com Fri Jan 12 04:11:28 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 12 Jan 2001 10:11:28 +0100 Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> <3A5E5C21.3E036BFE@intelligenesis.net> <3A5E935D.CF641658@dcube-resource.be> Message-ID: <93mhr60e7e@news1.newsguy.com> "Ben Hutchison" wrote in message news:mailman.979279694.10695.python-list at python.org... [snip] > > About a year > > ago, I discovered Python and have since then written thousands of lines > > of Python code, yet have not once experienced the typing of "self." to > > be overhead, > > Im sure you grow used to it, but Im not convinced its preferable. My general > preference, shared by many programmers I suggest, is that extraneous code be > minimized. Right, but scope clarification isn't "extraneous" -- it's as simple as this. > That also seems to be a theme in pythons design, I notice. Its perfectly > legal to explictly use "this" everywhere in C++/Java if you like it that way, you > just arent forced to. And by 'not being forced to', the scope of a non-explicitly-scope-clarified symbol can become very mysterious (particularly in C++). Are you _sure_, when you see an undecorated symbol in code you're maintaining or porting, that the interpretation of subtle and refined scoping rules is perfectly aligned between...: a. the original coder, b. intervening maintainers, c. yourself, d. future maintainers, e. the original compiler, f. the current compiler, g. future compilers, h. the ISO Standard...? What with 'Koenig lookup' and the distinction in templates between dependent and nondependent symbols, it DOES get subtle indeed -- most particularly because the rules shifted somewhat (subtly, of course:-), around standardization time, to facilitate precompilation of templates (portions thereof, at least). In fact, this makes lookup of such undecorated symbols one critical issue to watch out for when porting, if any compiler or coder is involved whose 'standard compliance' you cannot entirely vouchsafe for. Out of 100 very good C++ coders I know, there is NONE I'd be 100% certain will get all such lookup issues right, considering occasional coding performed in low-caffeine situations -- and that does include myself, Brainbench MVP for C++, 'reference guru' for all C++ language/compiler issues for my employers, and with over a decade of C++ experience. It's inevitable that a language as rich and complex as C++ will have obscure, dusty corners just waiting to trap the unwary, of course. But it's one thing to worry about, say, "pointers to members in templates where a virtual base, and overloads, may or may not be present" -- *that* kind of obscurity can normally be finessed by sticking to a 'safe' (ha!) subset of the language (a good idea, given the bugs that DO about in popular compilers, related to such 'corners'). But, when something as bread and butter as "what does `foo' refer to here" gets involved, now THAT becomes a really sticky situation. You'll never get C++ users to agree to never code just 'foo' but always, more explicitly, this->foo, AClass::foo, ::foo, etc (and if you did you'd have problems, since namespace-transparence is SO important in many C++ usage contexts!). Java isn't _quite_ as thorny, by a long shot (no namespaces existing across classes, no multiple inheritance of implementation, it's an error if a local variable's name 'shadows' an outer-nested homonym -- a combination of many such limitations and restrictions does help in clarifying things wrt C++ name-lookup rules!). But Python's choice (historically inspired, I believe, by Modula-3) is even simpler and more straightforward (it will get slightly less so when nested-scopes are added, as it seems they'll be, but only marginally so, we can hope). > > > * Is Pythons leading underscore mechanism more of a convention? > > > > > * It is strong enough to build security mechanisms on? > > > > Even the C++ support for public/protected/private access is not strong > > enough to enforce security. > > In other words, no. However, Java's is. private members really are very private, and > this gives the programmer design options not available perhaps in Python. IMO, cases > where you simply cant do something, by any technique, in a language, are ones to > watch out for. Possibly python could benefit from a strong private modifier. Not really, because Python relies on a completely different approach to "build security mechanisms on" -- see Chapter 16, "Restricted Execution", in the online Python Library Reference. Java's approach to security is hardly a shining beacon for the world, IMHO -- it's still to be proven that the security mechanisms it built on top of its "very private members" are yet solid, despite mucho patching and reworking since their very first release. I forget the origin of the quote, but -- "there are two approaches to [coding]: make it so complex there are no obvious flaws, or, make it so simple there are obviously no flaws". When security is involved, you definitely want the SECOND approach (the slant of the quote, of course, is clearly that you just about always should prefer the second, but security issues make that choice particularly apt:-). Re "cases where you simply can't do something, by any technique, in a language": what about binary (no library mods allowed) reuse of library code using "really very private" variables, in Java, when it turns out the library's design isn't _quite_ perfect and its author has omitted to provide an accessor for a little piece of state you desperately need to know...? Of course, we all know library designers ARE always-right, perfect, superhuman beings, so the issue is merely theoretical, but, if these are indeed the "cases ... to watch out for", this one would seem interesting. Anyway, security definitely is NOT something you "can't do by any technique" in Python. The language itself, here as in so many other places, provides very simple, usable infrastructure; you design or adopt modules using and wrapping that for the specific purposes of your application, depending on the exact nature of the 'untrusted code' you're dealing with. > Except security. And in some domains, where you have someone elses untrusted code > executing, that really does matter. Python can prevent accidental access to private > fields but not a deliberate attempt. When people consider building very large > systems from python, they surely will encounter this barrier. It may prevent pythons > use where it would otherwise be appropriate. People _have_ built very large systems in Python, but security can be an issue even in pretty-small ones -- any time you get code snippets from the net, from an interactive user, from a database that might have been tampered with. And you *can* deal securely with such untrusted code -- not claiming it's EASY (I know of NO language that makes security truly easy: you are hypothetically dealing with a would-be invader who must be presumed to be at least as smart as you, remember:-), but, it IS as DOABLE as in any other language I know. Alex From erno-news at erno.iki.fi Mon Jan 22 19:07:49 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 23 Jan 2001 02:07:49 +0200 Subject: IP Octet Patern Match References: <3A6CBDC4.C5F292C9@tampabay.rr.com> Message-ID: In article <3A6CBDC4.C5F292C9 at tampabay.rr.com>, Kevin Fiscus writes: | I am extremely new to Python. Can anyone help me to design a script | that will find the IP addresses from email headers and write the entire | line where they are found to another text file? rfc822.Message(...).getallmatchingheaders('received') -- erno From katz at Glue.umd.edu Mon Jan 15 11:11:16 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Mon, 15 Jan 2001 11:11:16 -0500 Subject: python compiled to native in less than a year? In-Reply-To: References: Message-ID: Scott, the problem with Python compilation is optimization; you can "freeze" a python program into an executable even now. I heard it somewhere that compiled Python would consist of nothing more than calls to Python's C API. Granted, that shaves off the interpreter layer, but you're still going through the P-API. I suspect it is the same way in JPython (given that JPython implements the Python API in Java, am I right? (?)).. /R On Mon, 15 Jan 2001, scotth wrote: > Hello, > > Since the new .NET platform from MS will take all the compatible .NET > languages and transform them to an IL (intermediate language ???), then take > the IL to native compiled code, this means that python will be compiled, but > only for the Windows platform. > > Is what I have said correct, or have I missed something? This would give > python a huge boost! > > Scott > > > From barry at digicool.com Sun Jan 28 01:21:23 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Sun, 28 Jan 2001 01:21:23 -0500 Subject: Our Exception Standards -- What do you think? References: <4UKc6.12291$Sl.591319@iad-read.news.verio.net> Message-ID: <14963.47715.844551.58949@anthem.wooz.org> >>>>> "DF" == Doug Fort writes: DF> The Library Manual recommends deriving all exceptions from the DF> system Exception class. This class has a member called 'args' DF> which is a tuple of the arguments presented in its DF> constructor. The default __str__ operator simply returns the DF> args tuple as a string. DF> ('aaa', 'bbb') I propose that we follow this standard, with DF> the enhancement of overloading the __str__ operator of DF> individual exception classes. While I think it's a good idea to derive your application specific exceptions from Exception, I don't think you necessarily need to use its constructor. The Exception class was carefully designed for backwards compatibility but you don't have that problem. When I design my exception classes, I usually create one derived class per subsystem and then derive all my further exception classes from those. E.g. Exception +-> ListError | +-> UnknownListError | +-> CorruptListError | +-> ... | +-> AuthenticationError | +-> BadPasswordError | +-> CookieError | | +-> ExpiredCookieError | | +-> InvalidCookieError | +-> ... | +-> ... Then if I know that I'm going to raise the exception with some specific arguments, I create an __init__() to accept only those arguments (and a __str__() to print something reasonable using those arguments). I often do not call Exception.__init__() in my own classes's constructor. Cheers, -Barry From tim.one at home.com Sat Jan 27 00:55:58 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 27 Jan 2001 00:55:58 -0500 Subject: . Python 2.1 function attributes In-Reply-To: Message-ID: [Roy Katz] > My question is this: > > what is the point of letting functions have attributes when > the same role is fulfilled cleanly by classes which implement > __call__()? Akin to the same point as for letting people write x + 2 when they could be restricted to writing x + 1 + 1 That is, convenience, clarity, efficiency and naturalness. As PEP 228 says, people *have* been abusing docstrings for all sorts of things, despite that they're well aware of class-base techniques. If I want to associate data (other than a docstring, which is easy) with a function or method, first burying the function in an artificial singleton class and then using an instance of that class instead is simply convoluted in comparison. From cxu1 at nd.edu Wed Jan 24 21:05:28 2001 From: cxu1 at nd.edu (Changsen Xu) Date: Wed, 24 Jan 2001 21:05:28 -0500 Subject: How to get shell screen out from python? Message-ID: <3A6F89E8.F3629152@nd.edu> Hi, Now I wish to get the output from running a shell command, I can't find an easy way in python but use pipe: p=popen('lp *.ps'); t=p.read(); p.close() while in tcsh, it may just be: set t = `lp *.ps` Any of you can teach me an easier way in python ? Thanks, From dsh8290 at rit.edu Tue Jan 23 17:17:46 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 23 Jan 2001 17:17:46 -0500 Subject: How do I know all thrown exceptions of a function? In-Reply-To: <94imre$7dd$1@slb6.atl.mindspring.net>; from dalke@acm.org on Mon, Jan 22, 2001 at 06:33:03PM -0700 References: <94imre$7dd$1@slb6.atl.mindspring.net> Message-ID: <20010123171746.D22126@harmony.cs.rit.edu> On Mon, Jan 22, 2001 at 06:33:03PM -0700, Andrew Dalke wrote: | Delaney, Timothy wrote: | >Personally, I think Java's view of exceptions (almost) makes | >sense. | | Actually, I disagree. Consider a function which numerically | integrates another function over a given range: | | def integrate(func, x_min, x_max): | ... | will compute func(x) for several values of x between [x_min, x_max] | ... | [snip] | What is the best way to handle this unexpected exception in the Java | way? int integrate( func , float x_min , float x_max ) throws Exception { ... } Is one way. | | I actually don't know. As far as I can tell, the only way to | do it is let integrate raise a specific "CannotIntegrate" | exception, then implement a wrapper, like for MyCache, which | converts any non-numeric exception in the CannotIntegrate | exception, as in | Is another way. | try: | y = self.func(x) | except (DivideByZeroException, other expected math errors ...): | raise | except (SystemExit, KeyboardInterrupt): # allow forced breaks | raise | except: | .. convert to a CannotIntegrate exception .. | return y | | To me, this is ugly and error prone. (Is this really what | you need to do for Java - the Feb. Dr. Dobb's comparison | between Java and C# suggests so.) Thus, I would rather write | my code to be exception safe, in that it gracefully accepts | any exception, then to declare every exception type. | I agree that it is ugly to have to declare all possible exception types. That's not to say you shouldn't document it, but it should be /documented/ not forced by the /compiler/. The C++ method isn't entirely bad (as Alex mentioned), and the new "attributes of functions" feature in 2.1 may be extended to support this[1]. This would allow programmatic access to the exception documentation. -D [1] I don't know if there are any real plans for it, but I see it as a consistent and reasonable way to add it. From cg at schlund.de Tue Jan 9 05:43:18 2001 From: cg at schlund.de (Carsten Gaebler) Date: Tue, 09 Jan 2001 11:43:18 +0100 Subject: Determine whether STDIN is gzipped References: <3A5ADB84.194BAD4E@schlund.de> Message-ID: <3A5AEB46.29E89DFA@schlund.de> Andreas Jung wrote: > > Something like the following should work (I assume we can read all > data from STDIN in one read() call): > Okay, I should have mentioned that I can't afford reading all data at once into memory because if it is not gzipped it can be several ten megs large and the program is intended to be run on a web server. cg. From aleaxit at yahoo.com Fri Jan 26 08:28:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 26 Jan 2001 14:28:39 +0100 Subject: Umlauts revisited: Now they prevent program from running References: <94rt05$tbe$1@newsreaderg1.core.theplanet.net> Message-ID: <94ruo702941@news2.newsguy.com> "Franz GEIGER" wrote in message news:94rt05$tbe$1 at newsreaderg1.core.theplanet.net... [snip] > (ActiveState 2.0 on NT4) by simply typing "fld.Value". > > It displays u'St\374ck'. > > Conversion into a Python string by applying print or str() yields: > > "Traceback (innermost last): > File "", line 1, in ? > UnicodeError: ASCII encoding error: ordinal not in range(128)" > > Any idea how to overcome this? try, for example, using fld.Value.encode('iso-8859-1') -- that should return the Python string you desire, i.e. 'St\374ck'. Alex From msandin at remove_this.hotmail.com Sun Jan 21 06:57:38 2001 From: msandin at remove_this.hotmail.com (Martin Sandin) Date: Sun, 21 Jan 2001 12:57:38 +0100 Subject: Tabbing/Spaces References: Message-ID: <94eiui$kj8$1@news.gu.se> I'm sorry for originally _mailing_ this answer to Tim Peters at first. What happens if you hit the wrong button in your news reader. Me bad. ----- Original Message ----- From: "Tim Peters" > I assume you're using a supernaturally feeble editor, then. That's fine! > What you do in your own bedroom with the lights off isn't our concern. > Well, at least not yet -- now that Guido is married, I hear he's thinking > about guiding people in more aspects of their lives . Well. The editor I use can turn tabs into spaces, no problem there. The reason to use tabs is mainly the opposit, I have to hit "delete" four times to move it _back_ one indent level (and I don't have to learn a special case for deleting indent levels, as a macro would be). With spaces I can also place the cursor on all the spaces in between indendation levels which makes moving the cursor around with the cursor keys slower as I have lot of "unnecessary" positions to place it in. As a last point it's also easier for someone else to change how they want my indented code to look as they can just change the tab length. Not so easy with spaces;-) And if I was actually working with individuals who didn't think those were adequate reasons, I guess I could easily add a couple of macros to my editor to turn tabs into spaces and the other way around when I get the code back... as the editor I use does support regexps=) Point taken. But I must protest if you think of my bedroom practises as "dirty" as I've got rational reasons for them. How many people today are actually using editors that _lack_ the ability to change how long a tab is? Now that's a feeble editor in my mind =) - Martin - yours friendly, and humbly lowly as a Python newbie, uhm-ly come.to/vague From sparhawk at gmx.at Thu Jan 25 04:18:25 2001 From: sparhawk at gmx.at (Gerhard W. Gruber) Date: Thu, 25 Jan 2001 10:18:25 +0100 Subject: HTTPLIB Proxy Message-ID: <3A6FEF61.BAA6587C@gmx.at> Is it possible to use a proxy with the httplib object? How do I have to set it up? -- Bye, Gerhard CocoNet GmbH Erkrath email: gerhard.gruber at coconet.de privat: sparhawk at gmx.at If you think education is expensive, try ignorance! From lisowski.tomasz at sssa.NOSPAM.com.pl Tue Jan 30 09:00:17 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Tue, 30 Jan 2001 15:00:17 +0100 Subject: Tkinter: button image not displayed!? Message-ID: <956h9g$5gl$1@news.tpi.pl> Hi, I try to get familiar with the Tkinter GUI. In the following piece of code I try to load two GIF images as button pictures. The result is, that the buttons are displayed, but without pictures, and are not working (pressing them does nothing!).The picture files names, and their path are correct. I am using Python 2.0 on Windows NT. I would be grateful for any hints ... from Tkinter import * master = Tk() def f(): print "Called!" Label(master, text="X min:").grid(row=0, column=0, sticky=E) x_min = Entry(master, width=20) x_min.grid(row=0, column=1) Label(master, text="X max:").grid(row=0, column=2, sticky=E) x_max = Entry(master, width=20) x_max.grid(row=0, column=3) Label(master, text="Y min:").grid(row=1, column=0, sticky=E) y_min = Entry(master, width=20, state=DISABLED) y_min.grid(row=1, column=1) Label(master, text="Y max:").grid(row=1, column=2, sticky=E) y_max = Entry(master, width=20, state=DISABLED) y_max.grid(row=1, column=3) fr = Frame(master) Button(fr, text="Draw", width=7, command=f).grid(row=0, column=0, padx=2) zi = Button(fr, text="Zoom in", width=7, command=f) zi.grid(row=0, column=1, padx=2) Button(fr, text="Scale", width=7, command=f).grid(row=0, column=2, padx=2) ## ------ the problem lies somewhere below ------- Button(fr, image=PhotoImage(file="H:\\Back.gif", master=fr), command = f).grid(row=0, column=3, padx=2) Button(fr, text="Add", width=7, command=f).grid(row=1, column=0, padx=2) Button(fr, text="Walk", width=7, command=f).grid(row=1, column=1, padx=2) Button(fr, text="Exit", width=7, command=master.destroy).grid(row=1, column=2, padx=2) Button(fr, image=PhotoImage(file="H:\\Forward.gif", master=fr), command = f).grid(row=1, column=3, padx=2) fr.grid(row=0, column=4, rowspan=2, sticky=E, pady=4) master.mainloop() Thanks in advance Tomasz Lisowski From dale at out-think.NOSPAMco.uk Thu Jan 11 12:08:49 2001 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 11 Jan 2001 17:08:49 +0000 Subject: One bug and yer out with Pythonwin debugging? References: <93i7mu$5d8$1@nnrp1.deja.com> Message-ID: Mark Hammond wrote: >In article , > "Parzival Herzog" wrote: > >> Is there anyway to continue the Pythonwin IDE session after >> an exception occurs in the debugged app? > >This problem is unique to Pythonwin and wxPython. It is a known >problem, but apparently the wxPython guys don't use Pythonwin, and I >don't use wxPython, making a fix difficult. > >Mark. > > >Sent via Deja.com >http://www.deja.com/ I wouldn't have said it was *unique* to that combination. I have found that rerunning complex programs after a failure in PythonWin is not always rewarding :-) We have put together a basic test harness to run our suite outside of PythonWin in a Console window. We still use PythonWin for development and the debugger but restart it after debugging. HTH -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From Gareth.McCaughan at pobox.com Mon Jan 22 23:40:18 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Tue, 23 Jan 2001 04:40:18 +0000 Subject: Markov.py References: <94eavq$5cl$1@nnrp1.deja.com> Message-ID: cpsoct at my-deja.com wrote: > I found the following script in the mac standard distribution (see path > below). It seems to be Guido's, i am not sure however, i am at a loss > as to how to use this. I was unable to run it and there is not > documentation. In otherwords, i put on my detective hat but was still > unable to get the thing to run. Anyone use this and can explain to me > how? The script is a bit to big and complex for my level of python kno- > how, but how sweet would it be to be able to make a markov chain in > python without having to re-invent the wheel. Particularly since i > wouldn't be able to in this case! It looks like a dissociated-press thing to me. You feed it text; it uses the relative frequencies of tuples of characters, or words, in the text to build a Markov chain, and then it runs the Markov chain for a while to produce output text that has a spooky resemblance to the input text but doesn't actually make any sense. (Of course, some input texts appear to be invariant under this treatment...) Rather than storing successor states with their probabilities, for each state it associates a list of all the successors that have been seen. Then, to choose a successor in any given state, it just picks a random element of the list. So the Markov class doesn't represent a general Markov chain, just one with rational probabilities -- and rational probabilities with large denominators would be prohibitively expensive to implement. :-) It looks like rather old code, from the fact that it defines its own "tuple" function and uses string.splitfields instead of string.split . As for how to use it: you say something like python markov.py -3 some-file-of-text and it thinks for a bit and then starts spewing out text. Here's some of what it produced when I fed it a chunk of the Bible. (Readers of delicate sensibility are assured that there is no blasphemy in what follows...) 1 "Eat you things of thy hard of you, or thing, and which was then the raim, "David have morit of Kei'lainst go all you shall befor imale cond with outside one freskin of the to their new whom to the contill deemen head their fath, Nabouth to him, to younts uncle, sonsecred its by man by David not can as and from to a dringlease, and hings. 14 That was character-by-character. Here's word-by-word (with the -w option). 1 So these three men ceased to answer Job, because he was too afraid of his family and the men of the sons of Israel; and Aaron shall take upon himself any guilt incurred in the holy city were two hundred pomegranates, in two rows round about; and so with the other held his weapon. Does that make sense? (Well, of course the answer is "no", but I was referring to what *I* wrote...) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construc From fredrik at effbot.org Thu Jan 11 15:19:07 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 11 Jan 2001 20:19:07 GMT Subject: BUG Python 2.0 FreeBSD compile problem References: Message-ID: <%yo76.5561$Qb7.774534@newsb.telia.net> Chris Watson wrote: > > (still says "Resolution: None", but I'm pretty sure a fixed > > was checked into CVS a couple of days ago... if you can > > verify that the CVS version builds cleanly, let us know!) > > You know guys there is a reason why FreeBSD has a ports tree :-) if I don't run FreeBSD, how does a ports tree help me verify that the current CVS version builds cleanly on FreeBSD? Confused /F From thelazydogsback at my-deja.com Sun Jan 28 21:49:46 2001 From: thelazydogsback at my-deja.com (thelazydogsback at my-deja.com) Date: Mon, 29 Jan 2001 02:49:46 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: <952lo9$qme$1@nnrp1.deja.com> Thanks for asking this question - I figured it would come up soon (and probably has in the past, but I'm new here...) Even more thanks for those who answered - but I have a few questions that I didn't see raised: (1) Does one toolkit behave better in a multi-threaded application than another? In addition to the design of the toolkit, any kit that uses native widgets has native restrictions on threading and the GUI (e.g., only "main" thread talks to the GUI, etc.), so I'd guess that self-draw GUIs would have a chance of behaving better here. Also OS-threads would have more issues than stackless "microthreads" where re-entrency would be the biggest problem (?). When threads spawned from the main thread need to update GUI state, what is the standard method used? Does wx's doc/view architecture make this more straightforward? (2) I assume I could have an app the used both wx & tk at the window level, but is it possible to host WX inside of Tk, or visa-versa, at the frame and/or widget level? (Disclaimer - I've only done the simplist tk experiments, and have only looked at the wx docs.) thanks, mike In article <3A6F899F.E164F628 at home.com>, rwklee at home.com wrote: > It has to be cross platform between Linux and Windows, so it seems that > my choices are Tkinter and wxPython. > > Your experience, thoughts, opinion, on the relative merits and pitfalls > of each? > > My particular case: A GUI that has 5 windows max., will incorporate a > xmlrpc client, will have a python object browser, being able to build > data entry screens on the fly from a description of an object's > attributes, programmer not familiar with either toolkit. > > Thanks in advance. > > - Rick Lee > > Sent via Deja.com http://www.deja.com/ From hamish_lawson at yahoo.co.uk Tue Jan 16 12:51:52 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Tue, 16 Jan 2001 17:51:52 GMT Subject: Where to find the 'dbi' and 'odbc' modules? References: <941b3c$2jv$1@reader1.imaginet.fr> Message-ID: <9421nk$qb$1@nnrp1.deja.com> > dbi is no (AFAIK) a module/package, it's the "official" python API for > playing with databases. odbc module is available with Mark Hammon's > Win32 extensions There is in fact a dbi module in the Win32 extensions along with odbc (demonstrated below), which is what I suspect the documentation was referring to. I believe the official API is actually called DB-API. >>> import dbi, odbc >>> dir(dbi) ['DATE', 'NUMBER', 'RAW', 'ROWID', 'STRING', 'TYPES', '__doc__', '__file __', '__name__', 'dataError', 'dbDate', 'dbRaw', 'dbiDate', 'dbiRaw', 'i ntegrityError', 'internalError', 'noError', 'opError', 'progError'] >>> dir(odbc) ['__doc__', '__file__', '__name__', 'error', 'odbc'] >>> Hamish Lawson Sent via Deja.com http://www.deja.com/ From dsh8290 at rit.edu Wed Jan 17 19:07:06 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 17 Jan 2001 19:07:06 -0500 Subject: Curses module for Python 2.0 for Windows NT In-Reply-To: <0056900015212200000002L002*@MHS>; from jurgen.defurne@philips.com on Wed, Jan 17, 2001 at 09:23:42AM +0100 References: <0056900015212200000002L002*@MHS> Message-ID: <20010117190706.G23790@harmony.cs.rit.edu> On Wed, Jan 17, 2001 at 09:23:42AM +0100, jurgen.defurne at philips.com wrote: [snip] | Is there a curses add-on available for the Win32 binaries ? It sure | isn't part of the distribution I am using, which is still the BeOpen | version of Python 2.0 Mutt uses curses. I built mutt on a NT box with cygwin. If you want, you could grab the python sources and build it against cygwin to get (n)curses support. If you do that, you will create a dependency of python on cygwin. Cygwin will allow you to still link against MS libs like COM stuff (I think) but not MSVCRT (unless you pick MSVCRT instead of glibc). Otherwise I think you're stuck with DOS terminals (and custom interfaces made with python) instead of ncurses terminals. HTH, -D From fuess at home.com Sat Jan 27 18:15:36 2001 From: fuess at home.com (David A. Fuess) Date: Sat, 27 Jan 2001 23:15:36 GMT Subject: ASP + SQL Server + Time object problem References: <93np4p$lm$1@nnrp1.deja.com> <93p88d013hg@news1.newsguy.com> <93vavc$ml0$1@nnrp1.deja.com> Message-ID: There are several problems with the use of strftime here. When using the

Hello

" print "This is the obligatory
Python 'Hello\' test script
" print "Ta-da" print "\n" --------------------------------------- I've run the script successfully on my website. It's here: http://www.thinkspot.net/cgi-bin/pytestscript.py so I know the script works. My host is running Linux/Apache. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From akuchlin at mems-exchange.org Sat Jan 27 13:58:30 2001 From: akuchlin at mems-exchange.org (A.M. Kuchling) Date: Sat, 27 Jan 2001 13:58:30 -0500 Subject: Python 2.1 slower than 2.0 References: Message-ID: <200101271858.NAA04898@mira.erols.com> On Sat, 27 Jan 2001 18:28:02 +0100, Andreas Jung wrote: >Is there a reason why 2.1 runs significantly slower ? >Both Python versions were compiled with -g -O2 only. [CC'ing to python-dev] Confirmed: [amk at mira Python-2.0]$ ./python Lib/test/pystone.py Pystone(1.1) time for 10000 passes = 3.14 This machine benchmarks at 3184.71 pystones/second [amk at mira Python-2.0]$ python2.1 Lib/test/pystone.py Pystone(1.1) time for 10000 passes = 3.81 This machine benchmarks at 2624.67 pystones/second The ceval.c changes seem a likely candidate to have caused this. Anyone want to run Marc-Andre's microbenchmarks and see how the numbers have changed? --amk From alet at unice.fr Tue Jan 23 05:34:37 2001 From: alet at unice.fr (Jerome Alet) Date: Tue, 23 Jan 2001 11:34:37 +0100 Subject: XML doc generation References: <3A6D50A7.8F4ACFCB@unice.fr> Message-ID: <3A6D5E3D.D3CED7E0@unice.fr> Jerome Alet wrote: > I suggest you to download my XML generation module jaxml from: > > http://cortex.unice.fr/~jerome/jaxml > > the latest version is 1.22 Sorry, I meant 1.23 (I've just found and corrected a minor problem) -- Jerome Alet - alet at unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE From fredrik at effbot.org Sat Jan 20 15:39:37 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 20 Jan 2001 20:39:37 GMT Subject: Tabbing/Spaces References: <20010120011201.72310F44E@mail.python.org> Message-ID: Lele Gaifax wrote: > FL> here's a piece of code I use for emacs (taken from a java mode > FL> sample by jwz): > > Here is a simpler recipe :-) note that jwz's code also gets rid of unnecessary white- space at the end of lines. Cheers /F From codebert9 at users.sourceforge.net Tue Jan 2 01:56:24 2001 From: codebert9 at users.sourceforge.net (Jeffrey Drake) Date: Tue, 02 Jan 2001 06:56:24 GMT Subject: Python Imaging Library and Windows HELP! References: Message-ID: One other note, I am a beginner with python, just not beginning with coding. "Jeffrey Drake" wrote in message news:cXe46.16108$n%.820749 at news20.bellglobal.com... > I just downloaded and installed the Python Imaging Libary for windows, and > it basically has a set of py files, a dll. There is absolutely no > documentation of what to do with this stuff. > > I added the directory to the pythonpath environment variable, copied the > .dll to the /windows/system dir and then when running a program that uses > it - > > ---------- > C:\Python20\OpenGL\nehe>python lesson6.py > Hit ESC key to quit. > Traceback (most recent call last): > File "lesson6.py", line 225, in ? > main() > File "lesson6.py", line 218, in main > InitGL(640, 480) > File "lesson6.py", line 77, in InitGL > LoadTextures() > File "lesson6.py", line 58, in LoadTextures > image = image.tostring("raw", "RGBX", 0, -1) > File "c:\python20\py152\pil\Image.py", line 325, in tostring > self.load() > File "c:\python20\py152\pil\ImageFile.py", line 125, in load > self.load_prepare() > File "c:\python20\py152\pil\ImageFile.py", line 175, in load_prepare > self.im = Image.core.new(self.mode, self.size) > File "c:\python20\py152\pil\Image.py", line 40, in __getattr__ > raise ImportError, "The _imaging C module is not installed" > ImportError: The _imaging C module is not installed > > C:\Python20\OpenGL\nehe> > > ------- > Nobody in EFnet/irc.openprojects.net:#python seem to be able to help with > this. Most of them are on linux, though. > > If anyone can help me with this I would really appreciate it. > > Regards, > Jeffrey Drake > feel free to email me > > From echuck at mindspring.com Fri Jan 26 13:51:33 2001 From: echuck at mindspring.com (Chuck Esterbrook) Date: Fri, 26 Jan 2001 13:51:33 -0500 Subject: marshal doesn't work with "file-like" objects Message-ID: <5.0.2.1.0.20010126135016.029c4d90@mail.mindspring.com> C:\All\echuck\Projects\Webware>python ActivePython 2.0, build 202 (ActiveState Tool Corp.) based on Python 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on win32 >>> from StringIO import StringIO >>> f = StringIO() >>> f.write('hi') >>> import marshal >>> marshal.dump(1, f) Traceback (most recent call last): File "", line 1, in ? TypeError: marshal.dump() 2nd arg must be file So is that a bug, a flaw or a feature? -Chuck -- http://webware.sourceforge.net From pj at sgi.com Mon Jan 15 15:14:18 2001 From: pj at sgi.com (Paul Jackson) Date: 15 Jan 2001 20:14:18 GMT Subject: Speed of Python vs. Perl References: <93oled$o48b3$1@fido.engr.sgi.com> <8p6zogubven.fsf@Eng.Sun.COM> Message-ID: <93vlmq$p91ge$1@fido.engr.sgi.com> Mike, responding to pj: > > I don't see anyway around this. > > One way is to provide some sort of "dump" facility that allows the > program to initialize, dump the state, and then make an executable > from the dumped state. Emacs does (or at least, did) this ... Yes. I should have said: I don't see any clean, portable, low maintenance way around this <.2 grin> -- I won't rest till it's the best ... Manager, Linux System Software Paul Jackson 1.650.933.1373 From gustafl at algonet.se Sun Jan 21 18:56:11 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 21 Jan 2001 23:56:11 GMT Subject: Modifying .htpasswd from Python? Message-ID: <90312091gustaflalgonetse@194.213.69.148> This can be done easily in Perl, using the crypt() function. Now I need a Python function doing exactly the same encryption as the htpasswd command. Have tried to interact directly with the command, using the commands module, but since adding a user is a three step process, it didn't worked. Regards, Gustaf Liljegren From bowman at montana.com Fri Jan 19 09:44:45 2001 From: bowman at montana.com (bowman) Date: Fri, 19 Jan 2001 07:44:45 -0700 Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> Message-ID: Chris Ryland wrote in message news:948e4b$hm0$1 at nnrp1.deja.com... > Why do I have the sinking feeling that, with all the talk about IDEs > for Python, that the cognoscenti all use Emacs with python-mode and a > shell window? ;-) one size fits all: gVim compiled with Python for Python, Perl, C, C++, Scheme, CLisp, Guile, Fortran, Embedded SQL........... On Windows, I even replace the lame Developer Studio editor with gVim. IDEs have nice features, but most are too closely targeted to a particular language. Learning a handful of languages is bad enough; a handyful of idiosyncratic IDEs puts me over the top. From p at mjs400.co.uk Wed Jan 17 13:15:52 2001 From: p at mjs400.co.uk (Pete) Date: Wed, 17 Jan 2001 19:15:52 +0100 Subject: Jython on the i400 (was: Python and Industry, IBM I'm afraid) References: Message-ID: <3A65E158.6A238316@mjs400.co.uk> Don't forget to call it the i400, or iSeries 400, these things matter. Especially as this machine seems misunderstood by those outside of the clique. The 'i' apparently stands for integration, which is on the money, I reckon. Simon Brunning wrote: > > > From: Simon B. [SMTP:sbrunning at bigfoot.com] > > Now, a Jython port is a bit more likely - the '400 comes with what I'm > > told is a very good JVM. I've not had any sucess getting it to work > > just yet, but I keep trying. If I ever do get it going, c.l.py will be > > the first to know... > > OK, I have Jython working on my AS/400 now - using beta 2. If anyone wants > details of how I did this, give me a shout. > > It's not ready for showtime yet, though. For a start, the os module doesn't > seem to be working, which is no surprise, really. I'll try to look into > that. > > The other thing is that I'm having problems passing byte arguments: > > >>>myInStream.read(27) > Traceback (innermost last): > File "", line 1, in ? > TypeError: read(): 1st arg can't be coerced to byte[] > > Any tips on this one, anyone? > > 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 fredrik at effbot.org Thu Jan 11 11:11:40 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 11 Jan 2001 16:11:40 GMT Subject: init-once class 'static' data References: <3A5DD9AF.AB1C3DA6@ll.mit.edu> Message-ID: <0Xk76.5499$Qb7.763228@newsb.telia.net> George Young wrote: > I seem to often need a class to initialize a piece of it's data > the first time that class is instantiated. Examples might be a database > connection, a loading a pixmap, loading and parsing a datafile which > data will normally be accessed as a directory member of the class... > > I'd rather the data not initialize on module load, because in some cases > the data may never be used. > > I've been using an idiom I copied once from someone, but it seems > pretty kludgy, I'm hoping someone will point out a better way: > > class foo: > data = None > def __init__(self, data=data): > if data: > self.data = data > else: > self.data = (some expensive operation) Does that really work? Here's a more pydiomatic (imho, at least) solution: class Foo: # class attribute, shared by all instances data = None def __init__(self): if not self.data: # set the *class* attribute Foo.data = (some expensive operation) # now you can use self.data as usual Hope this helps! Cheers /F From dan.rolander at marriott.com Fri Jan 19 04:17:02 2001 From: dan.rolander at marriott.com (Dan Rolander) Date: Fri, 19 Jan 2001 04:17:02 -0500 Subject: Can Python clear a DOS screen? References: <41K96.7179$Qb7.1063615@newsb.telia.net> Message-ID: <007f01c081f8$95dd8890$11260340@yin> Thank you both Fredrik and Sam, I don't know why I didn't see that. I should have been able to figure it out. Thanks for taking the time to help me. Dan ----- Original Message ----- From: "Fredrik Lundh" Newsgroups: comp.lang.python To: Sent: Thursday, January 18, 2001 5:22 PM Subject: Re: Can Python clear a DOS screen? > Dan Rolander wrote: > > I've got a Python script that writes to a DOS console. Is it possible to > > have the script clear the screen? > > os.system("cls") > > (it's as stupid as it looks, but it works everywhere. > print "\x1a[2J" can also work, but it usually doesn't) > > For better control, consider using a console driver. > here's one: > > http://effbot.org/efflib/console > > Cheers /F > > > -- > http://mail.python.org/mailman/listinfo/python-list > From scarblac at pino.selwerd.nl Thu Jan 18 12:43:10 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 18 Jan 2001 17:43:10 GMT Subject: Using Python instead of... References: <9423s9$32f$1@nnrp1.deja.com> Message-ID: John Urberg wrote in comp.lang.python: > We are considering what language to use to rewrite our practice > management system. It is currently a PowerBuilder client/server system. > Currently all that is in the running is VisualBasic and Java. My boss > is concerned about using anything that is not "mainstream". So what's the problem with Python? Bookstore here has half a shelf on Python now, how mainstream does he want it? Add Delphi as well... -- Remco Gerlich From davide at mercurio.localdomain Wed Jan 3 10:39:36 2001 From: davide at mercurio.localdomain (davide at mercurio.localdomain) Date: Wed, 03 Jan 2001 16:39:36 +0100 Subject: split hangs In-Reply-To: References: Message-ID: <14Dq0m-0PX-00@mercurio.localdomain> >Then you had better start reading better stuff . I'll repeat the >original recommendation: Jeffrey [note: I erroneously said Jonathan before] >Friedl's excellent book "Mastering Regular Expressions" (O'Reilly). Sorry, but the dragon book (Aho Sethi, Ullman), Introduction to automata theory, languages and computation (Hopcroft, Ullman) and thousand of others books on language theory are surely a better reference . >There are two "obvious" ways to implement a regexp engine. Indeed, regexp matchig is quite simple. One extreme >Friedl calls "the NFA" way (although he's using "NFA" in a sense that >differs from its technical meaning in the literature). Yes, reading your post I understand that the reason is these are not NFA, "backreferences" are not part of regualar expressions and so we are not talking of regular languages. > >Note that the literature talks about "real" regular expressions. >Backreferences change the game profoundly. This page links to a proof that >the matching problem for Perl regexps (and so also Python's) is NP-complete: > > http://perl.plover.com/NPC/ Thanks for the reference. -- Davide From mnajmeddine at geo.census.gov Tue Jan 30 15:31:42 2001 From: mnajmeddine at geo.census.gov (Mohamed Najmeddine) Date: Tue, 30 Jan 2001 15:31:42 -0500 Subject: cgi In-Reply-To: Message-ID: Hello, My cgi script is working now. I had to add the following line at the beginning of the file: #!c:\python20\python.exe I'm not sure why given the fact that the registry setup should have executed the cgi script. Anyhow, that seems to do it. Med. -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Mohamed Najmeddine Sent: Monday, January 29, 2001 11:02 AM To: python-list Subject: RE: cgi -----Original Message----- From: Mohamed Najmeddine [mailto:mnajmeddine at geo.census.gov] Sent: Monday, January 29, 2001 10:59 AM To: Chris Gonnerman Subject: RE: cgi Hello, I have run the script from the command line and it works. I have add the -u option to the registry and restarted the PC but I still get the same error message. I should mention that I'm running on windows 2000 PRO. I configured the Personal WebServer (PWS) according to the instructions given at http://starship.python.net/crew/aaron_watters/pws.html The /cgi-bin in inetpub/wwwroot/ dir is setup as "execute". Attached are the scripts and the ouput. Thanks, MED. -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Chris Gonnerman Sent: Saturday, January 27, 2001 10:11 AM To: python-list at python.org Subject: Re: cgi ----- Original Message ----- From: "Mohamed Najmeddine" > I have configured the IIS to run a simple cgi script named hello.cgi and put > the script on the dir c:/inetpub/wwwroot/cgi-bin/. The script is as follows: > > print "Content-Type: text/html\n\n" > print "Hello Python" > > and I got the following error message: > > CGI Error > The specified CGI application misbehaved by not returning a complete set of > HTTP headers. The headers it did return are: > > syntax error at c:\inetpub\wwwroot\cgi-bin\hello.cgi line 4, near "print" > Execution of c:\inetpub\wwwroot\cgi-bin\hello.cgi aborted due to compilation > errors. Try to run the script directly from Python like so: python hello.cgi You have a syntax error in the script. I can't see an error in the sample you posted, but there must be one there. Also, regarding the registry setup for Python, using the -u (unbuffered) option is sometimes necessary: "C:\python\python.exe -u %s %s" -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list From rjones at inficad.com Sat Jan 27 15:06:21 2001 From: rjones at inficad.com (Robert Jones) Date: Sat, 27 Jan 2001 20:06:21 GMT Subject: tk3000 on linux References: <87d7dumrqp.fsf@lisboa.ifm.uni-kiel.de> Message-ID: <3a7329da.3935289@news.inficad.com> On 11 Jan 2001 09:13:02 +0100, Janko Hauser wrote: >You can generate a Setup file in the tkinter3000 directory like: (snip) Check first with your distro web site to see if there is an updated RPM or Deb (whichever may be appropriate). That way you won't mess up your precious dependancy lists. (slack users ignore this post) From bowman at montana.com Sat Jan 20 01:12:51 2001 From: bowman at montana.com (bowman) Date: Fri, 19 Jan 2001 23:12:51 -0700 Subject: data structure/algorithm in python References: Message-ID: Mohd Zamri Murah wrote in message news:mailman.979960222.21821.python-list at python.org... > > python) Or, the python <-> C++/Java have too much differences that reading > about data structure/algorithm in C++/Java will only confuse learning the > same thing in python? I wouldn't recommend you buy it sight unseen, but _Mastering Algorithms with Perl_ might be helpful if you can browse it in a bookstore. On the downside, it does use perlisms and reference some modules that don't have a direct equivalency, but seldom uses the furrier constructs. Sara Baase's _Computer Algorithms_ uses a pascal/modula2 pseudocode that really doesn't look all that different from Python. Sedgewick's C version might be a little clearer than the C++ one. Really, the concepts are what you are looking for; figuring out the implementation details for a particular language will strengthen your grasp on that language. From paulp at ActiveState.com Thu Jan 18 23:44:18 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 18 Jan 2001 20:44:18 -0800 Subject: Why is "as" not a keyword? References: <3A679717.1328@loop.com> Message-ID: <3A67C622.129EF7E3@ActiveState.com> Jesse W wrote: > > Most people know about the functionality of the import statement that > lets you import something under a differnt name. It uses the word "as" > to tell the interpreter. Why is "as" not a keyword? Other flag parts > of commands are keywords, like "in", or "from". Why not "as"? As is not a keyword because the fewer keywords there are in the language, the more flexibility you have as a programmer. You could for instance name a variable "as" to stand for ActiveState. > Currently, it seems to me to be confusing when you type > import foo as bar > in IDLE, and import lights up as a keyword, but "as", which has to be > there and is clearly part of the syntax, does not. That is merely a bug in IDLE. I wouldn't be surprised if it was fixed in the CVS version of IDLE. Paul Prescod From deblNONospammy at theworld.com Tue Jan 9 21:34:03 2001 From: deblNONospammy at theworld.com (David Lees) Date: Wed, 10 Jan 2001 02:34:03 GMT Subject: Python code for daVinci Message-ID: <3A5BCA21.AB10FB0A@theworld.com> I want to thank Tom Bryan for sending me Python code for generating daVinci graphs. The code was written by Doug Hellmann, but his e-mail address at mindspring bounces. If you are out there Doug, thanks and you can reach me at: davidl at raqia.com david lees From phrxy at csv.warwick.ac.uk Mon Jan 29 18:34:05 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Mon, 29 Jan 2001 23:34:05 +0000 Subject: win32 DLL import problem In-Reply-To: References: Message-ID: On Mon, 29 Jan 2001, Robin Becker wrote: > In article .uk>, John J. Lee writes > > > >ImportError: DLL load failed: One of the library files needed to run this > >> application cannot be found. [...] > try and get hold of depends.exe the dependency checker and use it to see > what DLL's your exetnsion is linked against/expecting. It comes as part > of the VC++ tools, but it can be downloaded from M$oft somewhere. [...] Aha, thanks. It seems I did after all somehow link with cygwin1.dll. Having got past that one, a slightly tougher one: my copy of TableIO (compiled and run on the same two machines mentioned above), works on our NT machine, but hangs the Python interpreter shell on our win95 laptop. Now, I know that since (apparently) I linked against crtdll.dll rather than msvcrt.dll by omitting -mno-cygwin somewhere, bad things may happen as a result. But do these bad things really happen on win95 but not NT?? John From fredrik at effbot.org Wed Jan 24 02:27:23 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 24 Jan 2001 07:27:23 GMT Subject: PIL Example References: <94km7t$caq$1@nnrp1.deja.com> <94lmm5$98n$1@nnrp1.deja.com> Message-ID: smibr at my-deja.com wrote: > Current code looks like this: ... > draw = ImageDraw.Draw(im) > draw.line((0,0),im.size, fill=128) > draw.line((0,im.size[1]),(im.size[0],0), fill=128) > del draw ... That's not the same code as you posted before: > draw.line((0, 0) + im.size, fill=128) > draw.line((0, im.size[1], im.size[0], 0), fill=128) Note the difference: in your original post, you passed the line coordinates in a single argument. (checking) Yes, it's a glitch in the documentation on pythonware.com. I thought we'd patched that, but maybe it never made it to the side, and got lost in the great site reshuffle. > I guess upgrading would help. When I run it on the Windows 95 box at > work it runs just fine. I still wonder about the traceback though. The ImageDraw line method looks like this: def line(self, xy, fill=None): when you call this with two coordinates, Python assign the first one to xy and the second to fill. When Python gets to the fill=128 argument, it has nowhere to put the value. Cheers /F From bowman at montana.com Sat Jan 20 21:05:51 2001 From: bowman at montana.com (bowman) Date: Sat, 20 Jan 2001 19:05:51 -0700 Subject: odd NT installation problem References: Message-ID: Martin von Loewis wrote in message news:p6qhf2tpz0p.fsf at informatik.hu-berlin.de... > "bowman" writes: > > The Tcl packages are not necessary; BeOpen comes with its own Tcl > libraries. True, I was confusing the matter. I got the Tcl package since the ActiveState distro does not include Tcl/Tk. > I recommend to uninstall any copies of Python and Tcl that you may > have on your system. Then, you should remove all registry key in > Software\Python, and start all over. I'd searched for and Python references in the Registry and deleted them, as well as removing and Python references from the PATH environment variable. > If it actually says that the installer is corrupted, please don't > forget to include the exact URL of the file that you've downloaded, > and the md5sum or atleast the size of the file, so others can get a > clue whether download failed. I'll have to get the file data Monday. The url's were either those from www.python.org or www.activestate.com download pages. The download method was a right click in NetScape, and saving the link to disk. This is my standard procedure and hasn't been a problem previously for rpms. tgz, zip, and so forth. > Are you sure you've enabled binary mode inside ftp? (hint: what else > could I guess out of the blue sky) ftp wasn't involved. The exported directories on my Linux box show up as H: on the NT box, much like any other mounted directories. The binary or .msi is then moved to D: with the standard cp command. The file sizes after the copy. I can't definitely say that the problem isn't in this transfer, but it works for everything else I do, including the ActiveState Perl msi package. Rather has me baffled, but I'll mess around with it further Monday. I'd say the 1.52 distro would be good enough, but past experience tells my I'll invariably use something in the Linux box if only '+=' that won't fly in 1.52. From echuck at mindspring.com Sun Jan 14 16:40:16 2001 From: echuck at mindspring.com (echuck at mindspring.com) Date: Sun, 14 Jan 2001 21:40:16 GMT Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com> <93om7l$p6s$1@nnrp1.deja.com> Message-ID: <93t6bv$pj$1@nnrp1.deja.com> In article , Erno Kuusela wrote: > In article <93om7l$p6s$1 at nnrp1.deja.com>, echuck at mindspring.com writes: > | Also, is (b) really an advantage? How often do you need to take a URL > | to another machine? > > pretty often. mail it to a friend, etc. But then wouldn't that friend come in as "erno" instead of themselves? > || c) making it work with search engines > | I'm not clear on (c) and search engines. If a session is related to a > | specific user, doesn't that imply that: > | 1. the searchbot gets it's own session id, > | 2. stores the id in the URL and > | 3. now when a user finds the URL via the search engine, they click in > | and are considered to be "AltaVista"? > > presumably the session has expired by then and the user is redirected > to a url with a fresh session string. one can also encode the client > address in the url and check it. This doesn't account for the case where the session hasn't expired yet. Also, it doesn't seem to account for remembering users. e.g., automatically recognizing a previous user when they visit a site after some days have passed and the session has expired. I suppose userId could also be encoded in the URL separate from sessionId. But that still takes you back to the "dirty URL" problem. > | On the contrary, using cookies gives you clean URLs like: > | http://host.com/docs/faq/ > | Which when clicked through a search engine will not come in with a > | session id that is either expired or inaccurate, like > | http://host.com/89dfgk49f/docs/faq would. > > this is true. > > | Item (d) says cookies are ugly. What's ugly about this:? > | Set-Cookie: use=webware; > | Or the clean URLs described above? Session ids are for the eyes of > | programmers, not users. > > cookies are an ugly kludge in http because they are logically > part of the information needed to locate the object in the http > request, but they are outside of the path in the request. and they hurt > cacheability. They are only part of the information required to locate the object if that's how you're using them. If the cookie simply identifies the user for purposes of security, then this is more of an "aspect" of web interaction rather than part of the path to the object. Also, if the web site is really using server side session variables to determine content, whether the session is in a URL or a cookie, then cacheability by the client is already out the window. > they are a pain to manage for users, who have to enable them for your > site. which is often painful since many browsers don't provide for > this functionality - users have to rely on a 3rd party proxy or > somesuch to do the filtering. I'm not clear on this part. Most users have cookies by default because most browsers support cookies out of the box. I define "most" by the distribution of hits and/or users, not by enumerating all the browser products. I get my browser stats from: http://www.upsdell.com/BrowserNews/stat.htm While I'm sure stats vary quite a bit from site to site, it's usually a matter of Netscape/Mozilla vs. Explorer vs. some small percentage of browsers (typically < 1%) that are trying to be compatible with these two browser camps anyway. > of course this is small potatoes in the nauseating sea of terrifying > kludges that is the current world wide web, so most people don't care > very much. Well we can definitely agree on that! :-) > | In summary, I think cookies are both clean and convenient, if you're > | confident your user base has them. > > i think we'll have to agree to disagree. OK, but I'd be interested in your response to my notes concerning the "pain to users" or lack thereof. I see your other points even if I don't agree with them, but don't know where you're coming from on this topic. -Chuck Sent via Deja.com http://www.deja.com/ From h.moeller at insiders.de Fri Jan 19 11:16:21 2001 From: h.moeller at insiders.de (Holger Moeller) Date: Fri, 19 Jan 2001 17:16:21 +0100 Subject: [Jython 2.0] Reading modules from a jar Message-ID: <949p92$mte$1@Iapetos.teknon.de> Hi all, is it possible to read modules which are usually in the \Lib directory from a JAR file. It is necessary to provide a fully-functional-one-JAR-distribution. Any help is appreciated, thank you. From smnordby at yahoo.com Fri Jan 12 19:38:52 2001 From: smnordby at yahoo.com (Steve) Date: Fri, 12 Jan 2001 16:38:52 -0800 Subject: newbie... References: Message-ID: <3A5FA39C.D7F23ECD@yahoo.com> Matt Frey wrote: > > Where is a good place to learn python? In front of a computer. Try the Python tutorial that comes with the distribution, or Alan Gauld's online http://www.crosswinds.net/~agauld/ tutorial or How to Think Like a Computer Scientist http://www.ibiblio.org/obp/thinkCSpy/index.htm From scarblac at pino.selwerd.nl Tue Jan 30 20:03:15 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 31 Jan 2001 01:03:15 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> Message-ID: D-Man wrote in comp.lang.python: > On Tue, Jan 30, 2001 at 01:38:37AM +0000, Remco Gerlich wrote: > | An essential difference is the fact that lists are ordered, but dicts aren't. > > In my Discrete Mathematics II class we discussed Partial Ordering > quite a bit. If you take this perspective, then lists aren't really > orderd any more than a dict is. > > A Partial Ordering is formed by creating a mapping between the > objects you have and a set of objects that already have a known > partial ordering (often the set of integers). In this view, a list is > simply a mapping from the integers to arbitrary objects and vice > versa. So sorting a list is really nothing more than altering you > concept of that mapping. This is like saying that a program isn't really a block of ascii text; it is a function on some subset of the positive numbers to the set [0,127]. Making changes to a program is simple altering that mapping. It may be true, but I don't see the point of looking at it like that... unless-you're-thinking-about-code-obfuscation-by-fourier-transform-ly-y'rs, -- Remco Gerlich From hancock at earthlink.net Wed Jan 24 13:20:30 2001 From: hancock at earthlink.net (Terry Hancock) Date: Wed, 24 Jan 2001 10:20:30 -0800 Subject: Python as a beverage References: <20010124144903.0CB3CEA59@mail.python.org> Message-ID: <3A6F1CEE.B07598E9@earthlink.net> python-list-request at python.org wrote: > With that in mind, I would put it this way: > > Python = Jolt Cola (All the Sugar, and Twice the Caffeine. Watch out for > the side effects.) > > Ruby = Pepsi Cola (Much Better than New Coke, but not a replacement for > Old Coke or Jolt, for me) > > Perl = Liquid Invert Sugar and Caffeine in an intravenous drip bag > (Let's not beat around the bush anymore, let's just go and do some damage.) > > C = Classic Coke (Still can't live without it. Python, for instance, is > written in C.) > > C++ and Java = New Coke (Can definitely live without it, but other > people swear by it) > > Smalltalk = Tonic Water with a slice of Lemon (I'm not quite ascetic > enough to appreciate it, but I appreciate people who appreciate it.) > > Lisp or Functional Languages = Hot Water (Some people can drink hot > water with nothing in it. I don't understand it. Neither do I understand > Lisp or Functional programmers.) > > Analogys-R-Us-ly-y'rs- > Warren :D :) :D :) :D :) :D I just about fell out of my chair -- thanks for cheering up my morning. :) This may wind up on my wall. -- Terry Hancock hancock at earthlink.net From amk at mira.erols.com Sun Jan 28 13:36:11 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 28 Jan 2001 18:36:11 GMT Subject: Interested in a Crypto-SIG? References: <3A72C8A3.C4B4D69A@stroeder.com> <3A731F26.15461A27@stroeder.com> <3A7461AC.AC5768@stroeder.com> Message-ID: On Sun, 28 Jan 2001 19:15:08 +0100, Michael Stroeder wrote: >Yes, I know how much work a reasonable crypto API for Python is. > >But there are people currently working on this stuff (e.g. M2Crypto, >some commercial projects). This is my try to coordinate the work >which is already done to save our time! Yes, but my point is that the mere creation of a SIG won't do that. Writing a draft of a proposed crypto API, or the requirements for such an interface, is more likely to start something moving. --amk From junaftnoon at nospamplzyahoo.com Sat Jan 6 02:22:34 2001 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Sat, 6 Jan 2001 16:22:34 +0900 Subject: Memory Leakage with Tuples and Lists Message-ID: <936h6e$d11$1@news.nuri.net> Tested under Python 1.5 and 2.0 on Win32: 1. Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel) Type "copyright", "credits" or "license" for more informat >>> for j in range(10): ... temp=range(800000) ... del temp 2. Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel) Type "copyright", "credits" or "license" for more informat >>> for j in range(10): ... temp='a'*8000000 ... del temp In the case of #2, there is no memory leakage at all. All the memory is returned 100%. However, in #1, there is a severe memory leakage, a few mega bytes. Do you guys experience this on *nices as well? From w.janssen at ieee.org Fri Jan 12 00:06:25 2001 From: w.janssen at ieee.org (Bill Janssen) Date: Thu, 11 Jan 2001 21:06:25 PST Subject: Adding compressed Palm pixmap format to PIL; am I on the right track? Message-ID: <01Jan11.210626pst."3448"@watson.parc.xerox.com> I'd like to add PIL support for the Palm pixmap format (sometimes called Tbmp). Looking over the PIL docs, I get the impression that support for uncompressed formats can be added at the Python level, and support for compressed formats, like the Palm format, needs to be added at the C level (new files in libImaging, say PalmDecode.c and PalmEncode.c). Is this the right path? Bill From aleaxit at yahoo.com Sun Jan 7 03:41:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 7 Jan 2001 09:41:01 +0100 Subject: Should I learn Python or Java? References: <938o49$fj6$1@newshost.accu.uu.nl> Message-ID: <939aap0nvb@news1.newsguy.com> "Martijn Faassen" wrote in message news:938o49$fj6$1 at newshost.accu.uu.nl... [snip] > > 2. Is going from object-based to object-oriented programming that huge a > > jump? I want to learn an OO language, however I plan on utilizing it in my > > career. > > OO concepts such a polymorphism are pretty important, and I'm not entirely > sure if VB supports it (though I heard it is fully OO now, so it should now, > and there's COM of course). Anyway, OO concepts in the context of Python The "fully OO" (==supports single inheritance of implementation) version of VB is the .NET one, which (although it supports COM via 'bridges' that come with the .NET framework) is not COM-oriented. Anyway, current VB does polymorphism via interfaces (which are really COM interfaces) and the verb 'implements' (same as Java, though Java, like VB.NET, also gives you single inheritance of implementation; but that's just a convenience when you are implementing an object, not the languages' main road to polymorphism). Alex From moshez at zadka.site.co.il Mon Jan 1 13:26:43 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Mon, 1 Jan 2001 20:26:43 +0200 (IST) Subject: array of objects In-Reply-To: References: , <92n1s7$tq9$1@nnrp1.deja.com> Message-ID: <20010101182643.EB2E9A84F@darjeeling.zadka.site.co.il> On Sun, 31 Dec 2000, "Daniel Klein" wrote: > How then is list comprehension Which means, obj = [test() for x in range(N)] > different (and/or better) than say: > > obj = [] > for x in range(N): obj.append(test()) Well, a lot of people here seem to think it's more readable. It may be more efficient in the future too. For me, the killer advantage is def tests(N): return [test() for x in range(N)] vs. def test(N): obj = [] for x in rnage(N): obj.append(test()) return obj look-ma-no-variables-ly y'rs, Z. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From dsavitsk at e-coli.net Fri Jan 26 11:09:02 2001 From: dsavitsk at e-coli.net (savitsk) Date: Fri, 26 Jan 2001 10:09:02 -0600 Subject: xor operator? References: <20010126125141.18593.qmail@nw128.netaddress.usa.net> <3A7188A9.1482CA3D@divalsim.it> <3A71951D.20A2@hvision.nl> Message-ID: "Hans Nowak" wrote in message news:3A71951D.20A2 at hvision.nl... > Nicola Musatti wrote: > > > > Very few languages have a boolean xor operation. I don't know any off the > > > top of my head, but if I'd have to make a guess, I'd say that INTERCAL was > > > the only language I'm famialiar with, with a boolean XOR operation :) > for better or worse, visual basic 6 has an Xor operator (according to VB & VBA in a nutshell, pg. 611) ds From fredrik at effbot.org Tue Jan 9 02:39:46 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 09 Jan 2001 07:39:46 GMT Subject: why no "do : until"? References: <932r3e010bd@news1.newsguy.com> Message-ID: <6fz66.4202$AH6.740364@newsc.telia.net> David Morley wrote: > This also uses the loop counter rather than constructing an intermediate > list of indices. There is the inefficiency of packing and unpacking the > (i,x) tuples, but I would hope that would be insignificant in Python. on my machine, your solution is about 5 times slower than for i in range(len(a)): x = a[i] ... or i = 0 for x in a: ... i += 1 where a is a built-in sequence type (list, tuple, etc), and its length is in the 10 to 1,000,000 item range. (like Aahz, I prefer the second variant. it's slightly faster on large sequences, and doesn't depend on len(a) returning the right thing) for-indexing should be slightly faster than the second alternative (less bytecode involved) Cheers /F From wware at world.std.com Fri Jan 5 07:59:36 2001 From: wware at world.std.com (Will Ware) Date: Fri, 5 Jan 2001 12:59:36 GMT Subject: MIDI file parser, MIDI classes Message-ID: http://www.deja.com/getdoc.xp?AN=711531226&fmt=text This is a collection of Python classes representing the information in a MIDI file. To parse a MIDI file, type: python midi.py < yourfile.mid or python midi.py -i yourfile.mid -- import string,time,os;print string.join((lambda x:x[:10]+x[8:])(map( lambda x:string.center("*"*(lambda x:((x<24) ### Seasons Greetings, Will Ware *(x-3))+3)(x),24),range(1,28, 2))),"\n") ################ wware at world.std.com From skreech at my-deja.com Fri Jan 12 16:29:54 2001 From: skreech at my-deja.com (skreech at my-deja.com) Date: Fri, 12 Jan 2001 21:29:54 GMT Subject: Using Python SSL Message-ID: <93nt06$4eu$1@nnrp1.deja.com> I'm fairly experienced with using sockets in Python... I've written two or three small programs using sockets, nothing major. Python's documentation on sockets is very good, and socket programming in general is well documented too (Beej's socket programming guide for example). I've wanted to try implimenting SSL in the socket programs by trying to use mxCrypto and Python's SSL in the socket module. Not only have I been unsuccessful trying to find out how to use socket.SSL from the sourcecode and httplib.py, but I've been even less successful in looking for documentation on the internet on how to use SSL in Python. Since there seems to be little demand for documentation, it seems like theres some real obvious way to use it. I've successfully generated a key and a self-signed certificate with openssl's utilities, but when I try to use the socket.ssl function I get SSL_connect errors. What is wrong is probably obvious, but I can barely find any example code to go off of. The client program I've thrown together to test socket stuff is basically this: conn = socket(AF_INET, SOCK_STREAM) conn.connect(('localhost', 13456)) sslconn = ssl(conn, "ckey", "ccert") And the server is basically so: sock = socket(AF_INET, SOCK_STREAM) sock.bind(("", 13456)) sock.listen(1) conn, addr = sock.accept() sslconn = ssl(conn, "skey", "scert") The exact error is like: sslconn = socket.ssl(conn, "skey", "scert") socket.sslerror: SSL_connect error And the same error occurs with both programs. Python has been compiled with SSL support with OpenSSL 0.9.6, also. I donno where to go from here, so any help would be appreceated. Gavin Cooper Sent via Deja.com http://www.deja.com/ From kwoeltje at mail.mcg.edu Wed Jan 17 10:28:37 2001 From: kwoeltje at mail.mcg.edu (Keith F. Woeltje) Date: Wed, 17 Jan 2001 15:28:37 GMT Subject: Best way to learn Python ? References: Message-ID: <3A65BA80.8489F21A@mail.mcg.edu> If you are completely new to programming, you might also want to look at Learn to Program Using Python by Alan Guald if you want a printed book. There are also a number of good online "beginner" tutorials listed on the Python site (look at http://www.python.org/doc/Intros.html ) if you have ready web access. >K J5 wrote: > > No schools teach it, so what books do you recommend ? > > Also, what are some cool programming projects I could do ? > > What do you guys write with python ? > > J5 From grante at visi.com Wed Jan 3 09:50:45 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 03 Jan 2001 14:50:45 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <3A4F4B4D.ECD6B172@engcorp.com> <3A52AF31.F7A9C32E@engcorp.com> Message-ID: <9%G46.7999$4c.647681@ruti.visi.com> In article <3A52AF31.F7A9C32E at engcorp.com>, Peter Hansen wrote: >Phew! I pass your self-consistency test! :-) At first I did it >inconsistently, before I came to appreciate the inherent value >of consistency throughout. Only problem I have is when I >attempt to enclose a block with braces strictly for scoping >reasons -- I don't know whether to indent the block or leave it >outdented with the rest of the instructions. After all, there >is no enclosing conditional or loop structure: > >void f() > { > int x; > some code here; > > // dang: do I indent this or not? > { > int x; > > code that uses the inner x; > } > > return; > } That is indeed a sticky question. I've found that when I need to do that it's often as a temporary debugging hack, so I just do something like: void f() { asdf(); qwer(); if (1) /* debug */ { int x; whatever uses x; goes here; } other stuff; } That way, I can change the "if (1)" to "if (0)" to quickly remove the debug code. >Except for the evil, ugly, inconsistent brace style which has >the opening brace on the end of a line and the closing brace >outdented after the last nested statement. People who use that >technique should be barred from programming, not to mention >shot. I'd say "in my opinion" but of course this is a matter >of *fact* and not open to discussion, so there. :-) Damned straight! Somehow I learned to tolerate open/close brackets that don't line up when using Scheme, but not C, Pascal, Modula-3, Python, et al. -- Grant Edwards grante Yow! Is it clean in other at dimensions? visi.com From aleaxit at yahoo.com Mon Jan 22 08:00:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 22 Jan 2001 14:00:59 +0100 Subject: how to test for nesting inlist References: <94bhte$4iv$1@nnrp1.deja.com> <94bvgu0kt4@news2.newsguy.com> <94ea6k$4uc$1@nnrp1.deja.com> <94h7pi$b86$1@nnrp1.deja.com> Message-ID: <94hau902rvd@news1.newsguy.com> wrote in message news:94h7pi$b86$1 at nnrp1.deja.com... > What are list comprehensions? I have looked and looked and looked in > books and on www.python.org and i see no mention of these. Is this A list comprehension is a syntax form such as: [ for in ] It was added in Python 2 (a few months ago; your books may be older than that) and you'll fit it mentioned at http://www.python.org/2.0/ (look for the header "List Comprehensions" about 3/4th of the way down this big page). Alex From peter at engcorp.com Tue Jan 16 01:15:27 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 16 Jan 2001 01:15:27 -0500 Subject: python compiled to native in less than a year? References: <8pF86.6015$J%.595435@news.flash.net> Message-ID: <3A63E6FF.22EE019C@engcorp.com> Neil Schemenauer wrote: > > It used to bother me that Python is so slow. I don't care much > anymore. I don't know if its the fact that I'm getting older and > more mature or if its that machines are getting so fast now that > it doesn't really matter. I guess knowing that I can quite > easily write a C extension module helps too. Perhaps a combination? I came to Python long enough into its life that I can't say it ever bothered me it was slow. I'd already become 'old enough' to stop worrying, had machines fast enough that I hardly noticed a change from C, and had become so intensely frustrated with maintenance costs of software development that Python's vast advantages in that respect completely masked any issues of performance. From fabrice.n at home.com Mon Jan 29 21:07:45 2001 From: fabrice.n at home.com (shaka) Date: Tue, 30 Jan 2001 02:07:45 GMT Subject: Does python20. package come all Libraries Message-ID: I was just wondering if all the libraries published on the python web site are contained in downloading package of python20. If no, how can I get those libraries?? thanks From jbranthoover at my-deja.com Thu Jan 11 13:29:47 2001 From: jbranthoover at my-deja.com (jbranthoover at my-deja.com) Date: Thu, 11 Jan 2001 18:29:47 GMT Subject: NewBie: How Can I Scan The Keyboard In Python? Message-ID: <93ku2c$gtr$1@nnrp1.deja.com> Hello All, Is there a way to scan the keyboard to watch for a key closure? I have a function that runs in a infinite loop. I want to brake out of the loop when the space bar is hit. Is there a way to do this in Python? I?m looking for something like Qbasic?s ?Inkey$? function. Any information will be greatly appreciated. Thank you for your time and have a nice day. Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Tue Jan 16 12:38:11 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 16 Jan 2001 17:38:11 GMT Subject: URL replacement in text References: <3A5F2A5A.494023BF@thawte.com> <8qH76.14451$Im.109356@e420r-atl1.usenetserver.com> Message-ID: <7G%86.7011$AH6.1061749@newsc.telia.net> Steve Holden wrote: > Note that this won't cope with some of the more pathological URLs (such as > those with CGI arguments [http://system/cgi?arg1=val1] or those which link > to a named anchor in the target page [http://system/pageref#target-name]). import re links = re.compile(r"(?i)(?:http|ftp|gopher):[\w.~/%#?&=-]+") def fixlink(m): href = m.group(0) return "
%s" % (href, href) sometext = """ here's another link: http://www.pythonware.com?FOO=1&bar=10#BAR """ print links.sub(fixlink, sometext) Cheers /F From root at rainerdeyke.com Sat Jan 27 10:53:07 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 27 Jan 2001 15:53:07 GMT Subject: . Python 2.1 function attributes References: Message-ID: "Tim Peters" wrote in message news:mailman.980593892.725.python-list at python.org... > def f(): > pass > f.attr = 0 If AttributeDecorator (see a previous post in this thread) was part of the standard library, the following could be used: def f(): pass f = AttributeDecorator(f, attr=0) This is more general than function attributes and just as obvious and powerful. The real drawback of function-like objects is that they are not bound as methods: class A: def f(self): pass f = AttributeDecorator(f, attr=0) A().f() # Fails because f is not a true function. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From max at alcyone.com Thu Jan 11 13:38:58 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 11 Jan 2001 10:38:58 -0800 Subject: default arguments newbie question References: <3A5CD60D.98CFAD33@alcyone.com>, <3a5cccca.77467843@localhost> <93ijpa$asp$1@panix3.panix.com> Message-ID: <3A5DFDC2.7CC882A9@alcyone.com> Moshe Zadka wrote: > But not for user-defined objects: > > class FoolErik: > > def __cmp__(self, other): > return cmp(None, other) Sure, you can come up with pathological cases. Are there really serious cases where something like this would be done? More importantly -- is there a case where someone would do such a thing (having a user-defined object which compared equal to None) that would do the wrong thing in the code example? If it compares equal to None, shouldn't surrounding code act like it _was_ None? If not, what is the point of having something which compares equal to None but is not None? Why would one make such a distinction? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Divorces are made in Heaven. \__/ Oscar Wilde Crank Dot Net / http://www.crank.net/ Cranks, crackpots, kooks, & loons on the Net. From sdm7g at virginia.edu Fri Jan 5 12:53:14 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Fri, 5 Jan 2001 12:53:14 -0500 (EST) Subject: Returning the path of a file In-Reply-To: Message-ID: On Fri, 5 Jan 2001, Daniel Klein wrote: > I've search the Beazley book as well as the Python reference materials > and can't find answers to these two basically simple questions: > > 1) How to return the path of a file previously opened in read-only > mode? > > myfile = open("foo") > > I know I can do something like > > os.getcwd() > > and this is where 'myfile' is, but if the file was opened by some > other method, I would like to be able to interrogate where it was > opened from. > > file.name gives you the name used in opening the file. If you open it with with no path or a relative path, that's what you'll get back: >>> file = open( 'test.py' ) >>> file.name 'test.py' If you open it with the full pathname, you'll get that back: >>> import os >>> file2 = open( os.path.abspath('test.py' )) >>> file2.name '/Users/sdm7g/test.py' And if you need to do this a lot and you can't remember to use the absolute path all the time, you can redefine the open function to do it for you: >>> import __builtin__ >>> import os >>> def open( filename, *args ): ... return apply( __builtin__.open, ( os.path.abspath(filename),) + args ) -- Steve Majewski From christian.simmendinger at debis-sfr.de Thu Jan 18 08:31:34 2001 From: christian.simmendinger at debis-sfr.de (Christian Simmendinger) Date: Thu, 18 Jan 2001 14:31:34 +0100 Subject: FPIG - No shared libs Message-ID: <3A66F036.94E9E23@debis-sfr.de> Hi ! We?d like use Pyhon/FPIG on our Supercomputer. The system isn?t really super though, regarding the OS - no shared libs :-( Now - how would i extend my python without this funcionality ? Is there a recommended way of doing this ? I don?t seem able to find anything with respect to that topic in the web/FAQ. Thx ! Christian Simmendinger From SBrunning at trisystems.co.uk Thu Jan 25 04:54:33 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Thu, 25 Jan 2001 09:54:33 -0000 Subject: newbie question: table-like data Message-ID: <31575A892FF6D1118F5800600846864D5B1767@intrepid> > From: gbell at uclink.berkeley.edu [SMTP:gbell at uclink.berkeley.edu] > Question: is there a customary way to create, manipulate & > query database tables in Python? Is there a module that does this? Two ways, really. There is an RDBMS built entirely in native Python - Gadfly. (See .) It's fast, but doesn't support advanced features like transactions and nulls. Also. it doesn't scale well, either for multiple users or large tables. Alternatively, you could hold your data in one of the many 3rd party RDBMSs for which Python Modules are available. See for a list of these. I myself use mxODBC from . It allows you to access any database for which you have an ODBC driver. For example, I tend to prototype using M$ Access, and keep production data on an AS/400. (If you are intending to distribute your program, look out for the license restrictions on mxODBC.) Have fun! Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk If knowledge can create problems, it is not through ignorance that we can solve them. - Isaac Asimov ----------------------------------------------------------------------- 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 max at alcyone.com Sat Jan 27 14:35:44 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 27 Jan 2001 11:35:44 -0800 Subject: [Off topic] allowed to put Python material on the Web? References: <3a730931.31998180@news.skynet.be> Message-ID: <3A732310.6A6E379E@alcyone.com> Daniel wrote: > Thus, before starting the time-consuming task to create this new site, > I'd like to know if putting this collection on the Web is actually > legal/allowed. You need to get explicit permission from each person whose material you're using, and retain the full credit and attributions after they do so. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ All the people in her neighborhood turn around and get mad and sing \__/ Public Enemy blackgirl international / http://www.blackgirl.org/ The Internet resource for black women. From amk at mira.erols.com Thu Jan 11 21:54:44 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 12 Jan 2001 02:54:44 GMT Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> <3A5E5C21.3E036BFE@intelligenesis.net> Message-ID: On Fri, 12 Jan 2001 12:21:37 +1100, Ben Hutchison wrote: >1. Most significantly, Python requires the "self" or "this" reference >to be explicitly declared. ... Suggests perhaps >that OO features were built onto initially procedural language. Actually this likely comes from the Modula-3 influence on Python's ancestry, and the "Explicit is better than implicit" principle underlying much of Python's design. That it also made the initial implementation easier may also have been a factor, but I suspect not a deciding one. --amk From SBrunning at trisystems.co.uk Mon Jan 15 07:05:50 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 15 Jan 2001 12:05:50 -0000 Subject: SQL-Statement with Python Message-ID: <31575A892FF6D1118F5800600846864D5B16F4@intrepid> > From: Juergen Hofer [SMTP:juergen.hofer at students.uni-linz.ac.at] > Is it possible to connect to a M$-Access Database (*.mdb) with Python > and make simple SQL-Queries and import the results into a list? > I'm using Python2.0 under Windows98. Try mxODBC, from . Don't forget to read the licence - there are restrictions. 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 tim.one at home.com Sat Jan 13 02:26:23 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 13 Jan 2001 02:26:23 -0500 Subject: is Python fully object oriented ? In-Reply-To: <20010113143044.C3BC6A828@darjeeling.zadka.site.co.il> Message-ID: > Note that Knuth regrets adding "protected" to C++. Heh -- I wonder whether Knuth ever heard of C++! Clearly, if he had ever heard of Python, he'd be a c.l.py replybot. Therefore he never heard of Python. Therefore he never heard of any other language developed over the last decade either. QED. uncle-don-would-be-proud-of-my-rigorous-logic-ly y'rs - tim From root at rainerdeyke.com Sun Jan 14 01:02:21 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 14 Jan 2001 06:02:21 GMT Subject: why is a negative shift value illegal? References: Message-ID: "Tim Peters" wrote in message news:mailman.979430656.15673.python-list at python.org... > Sorry, couldn't resist that. Simpler answer is "why would they?". shifts > don't work that way in most other languages; seems of marginal utility at > best; and would slow down all Python shifts because Python is implemented in > C and we could no longer use the native C shift (well, we can't anyway, > because C doesn't define the behavior of signs on right shifts; or shifts > greater than or equal to the bit size in either direction; and Python does > define those cases -- but yet another test in the implementation maze sure > wouldn't speed things up). I don't buy the speed argument. The speed penalty for one additional check is insignificant compared to the overhead that already exists. Adding the negative shift values would actually yield a significant speed increase in some areas. Consider 16 bit color formats. Red, green, and blue components are packed into a single 16 bit value. For any given 16 bit color format, each component has a mask, from which can be derived its position and length. For example: Pixel format: rrrrrggggggbbbbb red_mask = 0xf800 red_position = 11 red_length = 5 green_mask = 0x07e0 green_postion = 5 green_length = 6 blue_mask = 0x001f blue_position = 0 blue_length = 5 To operate on an individual component, on needs to isolate it, shift it to the right by its position, and promote it to an 8 bit value by shifting it to the left: red = ((color & red_mask) >> red_position) << (8 - red_length) The left shift value can be precalculated, of course. However, if negative shift values were allowed, the two shifts could be reduced to a single shift: red_shift = red_postion + red_length - 8 red = (color & red_mask) >> red_shift This is a significant speed increase, even if the actual shift takes slightly longer. Furthermore, allowing negative shift values would automatically add support for strange pixel formats that assign more than 8 bits to a component (such as rrrggggggggggbbb). -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From mhammond at my-deja.com Tue Jan 16 14:53:43 2001 From: mhammond at my-deja.com (Mark Hammond) Date: Tue, 16 Jan 2001 19:53:43 GMT Subject: help finding python20_d.lib for download? References: <3A649853.5CFBC157@psl.nmsu.edu> Message-ID: <9428s4$7u7$1@nnrp1.deja.com> In article <3A649853.5CFBC157 at psl.nmsu.edu>, charles cosse wrote: > Hi, i have to use python in windows for 1 small task and > can't link my C module because i need python20_d.lib. > Can anyone help me find the downloadable archive which > contains it? Thanks a lot! > Charles http://www.activestate.com/Products/ActivePython/Download.html contains a link to a .zip file with all debug binaries supplied with ActivePython. They should all work fine for BeOpen Python. Mark. Sent via Deja.com http://www.deja.com/ From fredrik at pythonware.com Tue Jan 23 06:01:20 2001 From: fredrik at pythonware.com (fredrik at pythonware.com) Date: Tue, 23 Jan 2001 11:01:20 GMT Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> <94ipci$afo$1@animus.fel.iae.nl> <3A6CFD8E.BD473DFD@gte.net> <3A6D54CB.2261D535@gte.net> Message-ID: <94jo9u$h45$1@nnrp1.deja.com> "sandj.williams at gte.net" wrote: > I parse that to mean 'cruft'. Sorry, I cannot find 'cruft' in my dictionary. Did you mean that Python's import statement doesn't work as described, that Tkinter hasn't been designed to support from-import, or what? Sent via Deja.com http://www.deja.com/ From sholden at holdenweb.com Wed Jan 10 08:16:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 10 Jan 2001 08:16:22 -0500 Subject: mxTools (was Re: why no "do : until"?) References: <3A5B5B55.198BC2C5@gte.net> Message-ID: Steve Williams wrote in message news:3A5B5B55.198BC2C5 at gte.net... > Robin Becker wrote: > > > In message , Oleg > > Broytmann writes > > >On Tue, 9 Jan 2001, Robin Becker wrote: > > >> > Anyone here has any doubts that at least mxDateTime simply MUST be in > > >> >the Python core? :) > > >> > > > >> > > >> I'm a minimalist; let 100 flowers bloom, but the core should really only > > >> include the minimal required. Fancy dates are a bit too far for me. I > > > > > > mxDateTime is not for fancy dates. Many SQL modules use it for returning > > >DATE/TIME fields from SQL. Think also about including it into Zope > > >(replacing current simple DateTime)... > > > > > >Oleg. > > ... > > SQL modules are even less essential in the core. > > -- > > Robin Becker > > Some of us think SQL modules are as important as file modules. Maybe more > important. > But even those of us who think that don't necessarily see that as an argument for making them core modules! While I would agree that SQL modules are really almost that important, I would still question the wisdom of burdening the core development team with their support. Each item added into to core increases the number of potential interactions, and I really don't see it as Guido's job to find out why my ODBC drivers need tweaking. Less is more! regards Steve From larf at 263.net Mon Jan 8 08:23:55 2001 From: larf at 263.net (Larf) Date: Mon, 8 Jan 2001 21:23:55 +0800 Subject: How to implement the expect function in embedding python ? Message-ID: <200101081306.VAA03024@mail.tsinghua.edu.cn> Hello! I have written a telnet client program with C++, and now trying to embed python as the script language. I've written a extend module so now people can access the screen buffer and send characters in python script files. It works very fine. But I hope add some functions just like expect in Tcl. For example, I want people can write scripts like below: --------------------- import miniterm b = miniterm.buffer # screen buffer send = miniterm.send() send('a') # send some chars if miniterm.expect( condition, timeout ): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^??? for i in range( len(b) ): print b[i] else: miniterm.disconnect() .. .. --------------------- When the function 'miniterm.expect' was called, the telnet program should run normally until the certain condition achieved, then the control should return to the script. Now I wonder how can I implement this function? Should I reimplement a select loop in the function itself? Or use one process run the telnet and another process to monitor it and use pty to communicate like expect? Or maybe threads will be better choices? I have no experiences in embedding scripts programming , so any advice are very appreciated. Thanks! Best regards Kafa From timo at alum.mit.edu Mon Jan 1 22:30:35 2001 From: timo at alum.mit.edu (Timothy O'Malley) Date: Mon, 01 Jan 2001 22:30:35 -0500 Subject: tftplib ? References: Message-ID: <010120012230351740%timo@alum.mit.edu> [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] hola. Gregory Trubetskoy wrote: > is there by a chance a tftplib.py or something that implements tftp in > Python out there? I have this thing lying around. You will probably want to modify it, but it's a complete TFTP server implementation. I have started a tftplib.py, but I never finished it... ----------------------------- #!/usr/bin/env python # # Standard imports # import string import struct, socket, select import thread # # Default variables # TFTP_PORT = 69 # # TFTP Errors # class TFTPError(Exception): pass # # A class for a TFTP Connection # class TFTPConnection: RRQ = 1 WRQ = 2 DATA = 3 ACK = 4 ERR = 5 HDRSIZE = 4 # number of bytes for OPCODE and BLOCK in header def __init__(self, host="", port=0, blocksize=512, timeout=2.0, retry=5 ): self.host = host self.port = port self.blocksize = blocksize self.timeout = timeout self.retry = retry self.client_addr = None self.sock = None self.active = 0 self.blockNumber = 0 self.lastpkt = "" self.mode = "" self.filename = "" self.file = None self.bind(host, port) # end __init__ def bind(self, host="", port=0): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock = sock if host or port: sock.bind(host, port) # end start def send(self, pkt=""): self.sock.sendto(pkt, self.client_addr) self.lastpkt = pkt # end send def recv(self): sock = self.sock F = sock.fileno() client_addr = self.client_addr timeout = self.timeout retry = self.retry while retry: r,w,e = select.select( [F], [], [F], timeout) if not r: # We timed out -- retransmit retry = retry - 1 self.retransmit() else: # Read data packet pktsize = self.blocksize + self.HDRSIZE data, addr = sock.recvfrom(pktsize) if addr == client_addr: break else: raise TFTPError(4, "Transfer timed out") # end while return self.parse(data) # end recv def parse(self, data, unpack=struct.unpack): buf = buffer(data) pkt = {} opcode = pkt["opcode"] = unpack("!h", buf[:2])[0] if ( opcode == self.RRQ ) or ( opcode == self.WRQ ): filename, mode, junk = string.split(data[2:], "\000") pkt["filename"] = filename pkt["mode"] = mode elif opcode == self.DATA: block = pkt["block"] = unpack("!h", buf[2:4])[0] data = pkt["data"] = buf[4:] elif opcode == self.ACK: block = pkt["block"] = unpack("!h", buf[2:4])[0] elif opcode == self.ERR: errnum = pkt["errnum"] = unpack("!h", buf[2:4])[0] errtxt = pkt["errtxt"] = buf[4:-1] else: raise TFTPError(4, "Unknown packet type") return pkt # end recv def retransmit(self): self.sock.sendto(self.lastpkt, self.client_addr) return # end retransmit def connect(self, addr, data): self.client_addr = addr RRQ = self.RRQ WRQ = self.WRQ DATA = self.DATA ACK = self.ACK ERR = self.ERR try: pkt = self.parse(data) opcode = pkt["opcode"] if opcode not in (RRQ, WRQ): raise TFTPError(4, "Bad request") # Start lock-step transfer self.active = 1 if opcode == RRQ: self.handleRRQ(pkt) else: self.handleWRQ(pkt) # Loop until done while self.active: pkt = self.recv() opcode = pkt["opcode"] if opcode == DATA: self.recvData(pkt) elif opcode == ACK: self.recvAck(pkt) elif opcode == ERR: self.recvErr(pkt) else: raise TFTPError(5, "Invalid opcode") except TFTPError, detail: self.sendError( detail[0], detail[1] ) return # end connection def recvAck(self, pkt): if pkt["block"] == self.blockNumber: # We received the correct ACK self.handleACK(pkt) return # end recvAck def recvData(self, pkt): if pkt["block"] == self.blockNumber: # We received the correct DATA packet self.active = ( self.blocksize == len(pkt["data"]) ) self.handleDATA(pkt) return # end recvError def recvErr(self, pkt): self.handleERR(pkt) self.retransmit() # end recvErr def sendData(self, data, pack=struct.pack): blocksize = self.blocksize block = self.blockNumber = self.blockNumber + 1 lendata = len(data) format = "!hh%ds" % lendata pkt = pack(format, self.DATA, block, data) self.send(pkt) self.active = (len(data) == blocksize) # end sendData def sendAck(self, pack=struct.pack): block = self.blockNumber self.blockNumber = self.blockNumber + 1 format = "!hh" pkt = pack(format, self.ACK, block) self.send(pkt) # end sendAck def sendError(self, errnum, errtext, pack=struct.pack): errtext = errtext + "\000" format = "!hh%ds" % len(errtext) outdata = pack(format, self.ERR, errnum, errtext) self.sock.sendto(outdata, self.client_addr) return # end sendError # # # Override these handle* methods as needed # # def handleRRQ(self, pkt): filename = pkt["filename"] mode = pkt["mode"] self.file = self.readRequest(filename, mode) self.sendData( self.file.read(self.blocksize) ) return # end readFile def handleWRQ(self, pkt): filename = pkt["filename"] mode = pkt["mode"] self.file = self.writeRequest(filename, mode) self.sendAck() return # end writeFile def handleACK(self, pkt): if self.active: self.sendData( self.file.read(self.blocksize) ) return # end handle ACK def handleDATA(self, pkt): self.sendAck() data = pkt["data"] self.file.write( data ) # end handleDATA def handleERR(self, pkt): print pkt["errtxt"] return # end handleERR # # You should definitely override these # def readRequest(self, filename, mode): from StringIO import StringIO return StringIO("") # end readRequest def writeRequest(self, filename, mode): from StringIO import StringIO return StringIO() # end writeRequest # end class TFTPConnection # # Simple TFTP Server # Each connection is handled in its own thread. # class TFTPServer: """TFTP Server Implements a threaded TFTP Server. Each request is handled in its own thread """ def __init__(self, host="", port=TFTP_PORT, conn=TFTPConnection, srcports=[] ): self.host = host self.port = port self.conn = conn self.srcports = srcports self.sock = None self.bind(host, port) # end __init__ def bind(self, host, port): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock = sock sock.bind(host, port) # end start def forever(self): while 1: data, addr = self.sock.recvfrom(516) self.handle(addr, data) # end serve_forever def handle(self, addr, data): if self.srcports: nextport = self.srcports.pop(0) self.srcports.append( nextport ) T = self.conn( self.host, nextport ) else: T = self.conn( self.host ) thread.start_new_thread( T.connect, (addr, data) ) return # end handle # end class TFTPServer if __name__ == "__main__": import sys from StringIO import StringIO # # Subclass to create our own TFTP Connection object # class MyTFTP( TFTPConnection ): def readRequest(self, filename, mode): randomstring = "Here is a sample string" return StringIO( randomstring ) def writeRequest(self, filename, mode): return StringIO() # end class port = 3000 + TFTP_PORT if sys.argv[1:]: port = string.atoi(sys.argv[1]) try: serv = TFTPServer( "", port, conn=MyTFTP ) serv.forever() except KeyboardInterrupt, SystemExit: pass From max at alcyone.com Fri Jan 5 01:01:08 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 04 Jan 2001 22:01:08 -0800 Subject: PyOpenGL and NVidia support for Linux with SMP? References: <3A5199CF.8F72F3C0@alcyone.com> Message-ID: <3A556324.8CA8C4A8@alcyone.com> I wrote: > Has anyone gotten PyOpenGL working for an NVidia chipset working under > Linux 2.2.x with SMP? I've run into the same roadblocks that others > have bumped into, and with Deja I see people asking about them, and > being told partial solutions which lead to other problems, which I can > also get to ... but I don't see any ultimate resolutions. > > Anyone gotten it working? For anyone in the same boat as me, I finally got PyOpenGL working, after piecing together hints that I found in this newsgroup. Adding the lines #inclue #undef GL_EXT_polygon_offset after the GL includes in each of the .c files (_glumodule.c, _glutmodule.c, _openglmodule.c, and openglutil.c) and rebuilding solved the problem. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ We are all part of the human race. \__/ Richard Ford Interstelen / http://www.interstelen.com/ A multiplayer, strategic, turn-based Web game on an interstellar scale. From f8dy at my-deja.com Wed Jan 31 12:59:00 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Wed, 31 Jan 2001 17:59:00 GMT Subject: Dynamically Defined Functions in Classes? References: Message-ID: <959jp0$ngp$1@nnrp1.deja.com> In article , purp at wildbrain.com wrote: > I have an application in which I wish to treat the members of a > dictionary as attributes; that is, I want to use set-and-get functions > to access them. Sounds like you want a UserDict, which is a class that acts like a dictionary. from UserDict import UserDict defaultFoo = {'joe' : 'cool', 'frank' : 'lee', 'ron' : 'dell'} class Bar(UserDict): def __init__(self): UserDict.__init__(self, defaultFoo) >>> b = Bar() >>> b {'ron': 'dell', 'joe': 'cool', 'frank': 'lee'} >>> b["joe"] 'cool' >>> b["mark"] = "pilgrim" >>> b {'mark': 'pilgrim', 'ron': 'dell', 'joe': 'cool', 'frank': 'lee'} If you need to customize the getting and setting of attributes, you can use the special methods __getitem__ and __setitem__ in your Bar class. More on special methods in UserDict and its descendants: http://diveintopython.org/fileinfo_specialmethods.html http://python.org/doc/current/ref/sequence-types.html -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Wed Jan 3 13:40:36 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 03 Jan 2001 18:40:36 GMT Subject: embedded python - cancel "while 1: pass" References: Message-ID: Warren wrote: > So what do I do? I've got Python 1.5.2 embedded into a large C > application, and it runs user-defined scripts. When a user defined script > goes south, the only way to fix it is to reboot our embedded system. I'd > actually like to do something like > > PyThreadState *tstate; > > tstate = PyThreadState_Get(); > PyThread_Signal( tstate, ABORT); something like this might work: static int getoutofhere(void *unused) { PyErr_SetNone(PyExc_KeyboardInterrupt); return -1; } Py_AddPendingCall(getoutofhere, NULL); cheers /F From flor_pino at hotmail.com Sun Jan 14 14:49:28 2001 From: flor_pino at hotmail.com (floR) Date: Sun, 14 Jan 2001 20:49:28 +0100 Subject: how do i disable buffered output, like Perl's '$|=1'? References: <979490967.23219.0.pluto.d4ee691b@news.demon.nl> <93so5m$biirv$1@ID-11957.news.dfncis.de> <979494993.24992.0.pluto.d4ee691b@news.demon.nl> Message-ID: <979501202.27393.0.pluto.d4ee691b@news.demon.nl> sys.stdout.flush() did the trick! Thanks (and to the others who responded) for the extremely fast reply. Fredrik Lundh schreef in berichtnieuws fQl86.6559$AH6.979259 at newsc.telia.net... > floR wrote: > > Not exactly what I meant, I think. > > It does exactly what you want -- but sure, there are > other ways to do the same thing: > > > Okay, what I want to do in particular, is to send 'print' commands to the > > browser in intervals, without buffering, something like the following: > > > + import sys > > print 'Content-type: text/html\n\n' > > countdown = 10 > > while countdown: > > print countdown > > countdown = countdown - 1 > + sys.stdout.flush() # flush output buffers > > sleep(1) > > > > so that the countdown seems to happen in your browser, instead of waiting > > for 10 seconds for the string '10 9 8 7 6 5 4 3 2 1' to appear. > > (this assumes that your server sends data to the client > as soon it arrives from the CGI script, of course). > > Cheers /F > > From noahspurrier at my-deja.com Tue Jan 23 01:33:09 2001 From: noahspurrier at my-deja.com (noahspurrier at my-deja.com) Date: Tue, 23 Jan 2001 06:33:09 GMT Subject: Can I decompile PYC files? Message-ID: <94j8j5$50e$1@nnrp1.deja.com> A process just deleted my .py file. I still have the .pyc file. Can I recover anything? I'm desparate. It doesn't have to be perfect. Thanks, Noah Sent via Deja.com http://www.deja.com/ From zope at thewebsons.com Sat Jan 27 10:23:29 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sat, 27 Jan 2001 07:23:29 -0800 Subject: Problem Install UPDATE Message-ID: <5.0.0.25.0.20010127072024.00a5b870@mail.earthlink.net> Hi; Okay, I see how you traced back the error. I took off the angle brackets in # include linux/errno.h and got this error message: /usr/include/bits/errno.h:25: `#include' expects "FILENAME" or I tried # include linux/errno.h and # include linux/errno.h FILENAME but maybe it would like a real filename . Got the same error message. Where to now? TIA, BenO From boud at rempt.xs4all.nl Thu Jan 25 08:06:25 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: Thu, 25 Jan 2001 14:06:25 +0100 (CET) Subject: Unicode string output In-Reply-To: <3A70007C.89623C9C@lemburg.com> Message-ID: On Thu, 25 Jan 2001, M.-A. Lemburg wrote: > > Why would you want to set the encoding on a per application > basis, BTW ? > Because some applications work with Unicode, others with latin-1, and others again with sjis, for instance. I don't want to have to explicitly select an encoding throughout the whole application, that just opens up more possibilities for bugs. I might want Zope to use a default of latin-1 (perhaps - I don't know much about Zope), but Kura needs utf-8. Another thing with a system-wide standard is the different preferences of users. I need Unicode and Latin-1, but my wife, who uses the same machine needs latin-1 and koi-8. Boudewijn Rempt | http://www.valdyas.org From paulb at infercor.no Mon Jan 8 06:35:47 2001 From: paulb at infercor.no (Paul Boddie) Date: Mon, 08 Jan 2001 12:35:47 +0100 Subject: Web devel with python. Whats the best route? References: Message-ID: <3A59A613.7A39C5C9@infercor.no> Chris Watson wrote: > > I'm about to start converting the small fool proof (ha ha) admin > system I have been working from console based to web based. What is the > easiest way to go about integrating python into apache so I can start > web'izing this app? mod_python, mod_snake, PyApache? Do you really want to go as far as integrating tightly with Apache, or will CGI-based mechanisms work just as well? Take a look at my Web modules overview page which attempts to summarise the different Python Web development options: http://www.paul.boddie.net/Python/web_modules.html I can't personally recommend any of the packages you mention as I haven't tried any of them, although the most recent information I can find about each of them is given on the above page. Recently, I have been working a little with Webware and I do believe that it has promise for developing sophisticated applications. Regards, Paul From flor_pino at hotmail.com Sun Jan 14 13:05:58 2001 From: flor_pino at hotmail.com (floR) Date: Sun, 14 Jan 2001 19:05:58 +0100 Subject: how do i disable buffered output, like Perl's '$|=1'? References: <979490967.23219.0.pluto.d4ee691b@news.demon.nl> <93so5m$biirv$1@ID-11957.news.dfncis.de> Message-ID: <979494993.24992.0.pluto.d4ee691b@news.demon.nl> Not exactly what I meant, I think. Okay, what I want to do in particular, is to send 'print' commands to the browser in intervals, without buffering, something like the following: print 'Content-type: text/html\n\n' countdown = 10 while countdown: print countdown countdown = countdown - 1 sleep(1) so that the countdown seems to happen in your browser, instead of waiting for 10 seconds for the string '10 9 8 7 6 5 4 3 2 1' to appear. > I'm not sure what the perl code means, but perhaps what > you're looking for is the '-u' parameter to python: eg > python -u myscript.py > > HTH > > -- > > Emile van Sebille > emile at fenx.com > ------------------- > > > "floR" wrote in message > news:979490967.23219.0.pluto.d4ee691b at news.demon.nl... > > I can't find anywhere how I can disable 'buffered output', > or whatever it is > > called. > > In Perl, you simply say $|=1, but in Python? > > Can anyone help me? > > > > TIA, > > Rolf Raven > > > > > > From shenwang at e-mail.com Thu Jan 4 22:03:03 2001 From: shenwang at e-mail.com (Shen Wang) Date: Thu, 4 Jan 2001 21:03:03 -0600 Subject: question about grouping in RE Message-ID: Currently in RE (A)|(B)|(C) create 3 groups, I wonder if there is a way to make it generate only 1 group. Which is more meaningful in my opinion. But things are different for named group, in pattern like (?P(sub1)(sub2))|(?P(pat1)), I did want (sub1) and (pat1) refer to group 2, (sub2) refer to group 3, but I don't want group 'name1' and 'name2' all refer to group 1, because then I have no way to tell which part matchs. maybe we can change named group's number to negative? That's all. I don't know if any guru can patch RE to add new flag like "merge group name". From m.faassen at vet.uu.nl Sun Jan 7 13:04:45 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Jan 2001 18:04:45 GMT Subject: embedded python - cancel "while 1: pass" References: Message-ID: <93ab3t$2vi$1@newshost.accu.uu.nl> Tim Peters wrote: > Guido was writing in Dutch there: his use of "registry" has nothing to do > with Windows. What he means by "registry call" is "a call to > Py_AddPendingCall", the function which "registers" (in Dutch -- or, for that > matter, also in English ) This must be the human Tim speaking here, not the infallible Timbot. 'registry' would be 'register' in this context, and 'registers' would be 'registreert'. Of course the Dutch generally don't comment our source code in Dutch but in English, and we use the English terminology even in Dutch texts, so it gets a bit confusing. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From grey at despair.rpglink.com Fri Jan 19 14:27:57 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 19 Jan 2001 19:27:57 -0000 Subject: Why no isexec, isread, iswrite, etc (was: I must be missing something obvious: os.path.isexecutable?) References: Message-ID: On Fri, 19 Jan 2001 06:54:22 GMT, Fredrik Lundh wrote: >Another possibility is that "isexec" isn't a portable concept... >How would you implement it on Windows, for example? Since when was portability a problem? *Steve flips open his Beazley book, page 156* Last three words in the explination of samefile(), sameopenfile(), samestat(). "Macintosh and Unix" It seems like Python has quite a few methods in its classes which are not portable across all platforms. That seems ok. >Anything having the right magic? Any file having an extension >listed in PATHEXT? Any file you can use with "start" (which in- >cludes virtually everything these days...) That would be up to the person who would want to design such a thing for Windows. Given that one appears to be able to have methods for one OS and not another based on the individual OS capabilities I'm not to concerned on what a windows version would do in this case (or, for that matter, why one would need it). -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From robin at alldunn.com Thu Jan 25 17:39:47 2001 From: robin at alldunn.com (Robin Dunn) Date: Thu, 25 Jan 2001 14:39:47 -0800 Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: "Neil Cerutti" wrote in message news:slrn9710o1.73.cerutti at fiad06.norwich.edu... > > For comparison purposes, I'm writing my first GUI app, a simple > wrapper for slrn, in Tkinter and wxPython. > > Tkinter's 'pack' layout manager is super easy to use, and with > some practice and the excellent documentation, powerful. wxPython > seems to have a couple of layout managers, but how they should be > used is a mystery. I've been forced to place everything pixel by > pixel so far. Look at the docs and demo for wxSizer and it's derived classes. It's by far the easiest mechanism available in wxPython, and nearly as powerful as wxLayoutConstraints. > > wxPython is supposed to be faster, but it isn't for the tiny app > I've written, because it takes nearly 3 times as long to get > started. Because it's loading and initializing 10 times as much code! (I'm working on ways to streamline the initial set of stuff needed to get started, and also to limit the additional DLLs loaded by this initial set...) > > Binding widgets to callbacks in Tkinter is much easier for me to > understand than the wxPython EVT_ macros. Tkinter's events seem > much easier to bind, since I don't have to worry about which > widget generates what event -- they all seem to generate everything > I've wanted to bind. In wxPython, I haven't figured out how to > get my app to close if I hit ESC. Nothing I've tried EVT_CHARing > has bothered to actually generate an event. EVT_CHAR, EVT_KEY_DOWN, and EVT_KEY_UP only get events when bound to the window or control with the keyboard focus, so it's not what you do if you want to have an application-wide command bound to a key. Even when dealing with char or key events on the focused window special keys like ESC are sometimes snached by other windows in order to do navigation and things. What you probably want is an accelerator, which is a way to tell the system to intercept keys and generate menu events from them. For example, making the text for a menu item like this, "E&xit\tAlt-X" will make the Alt-X key generate the same event that selecting the menu item does. You can also do accelerators without menu items, and for the ESC key I think you need to do it this way: aTable = wxAcceleratorTable([ (wxACCEL_NORMAL, WXK_ESCAPE, ID_CLOSEAPP) ]) self.SetAcceleratorTable(aTable) EVT_MENU(self, ID_CLOSEAPP, self.OnCloseApp) > > The objects in wxPython are more full-featured (I guess--for some > definition of full featured), but aren't as easily configurable > as the Tkinter ones. For example, in Tkinter, I've bound > right-clicking to a list box of news servers. A popup menu allows > me to remove that new server from the list, or add another one. I > can catch a EVT_RIGHT_BUTTON in wxPython, but I can't (so far) > find out which list item the pointer was near when the event > occurred. (For that matter, I can't make a popup menu either yet > either, though I *know* it's possible. It says in the > documentation that a Menu can be a popup.) See the wxListCtrl demo. > > wxPython's documentation seems to be in the state Tkinter's was > back when all there was was the _Tkinter life preserver_. I hope to rectify this over the next few months. Lack of Python specific documentation has always been an issue, and it is now getting near the top of my must-have list. > > Better advice is probably to try them both for some small sample > app, like I have, and make up your own mind. This is my recommendation as well. My experience is that some people have a natural ability to pick up and understand wxPython and Tkinter seems mind boggling strange or complex to them. For others it is completely opposite, they grok Tkinter just fine, but "just don't get" wxPython. Personally I think that this means that there are two incompatible ways that Pythoneer's brains are wired, but I could be wrong. I suppose that a "wxPython for Tkinter Programmers" document would be useful, but my brain is wired wrong so I couldn't write it. hold-your-brain-up-to-the-scanner-please-ly y'rs, -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! > -- > Neil Cerutti > "If you're gonna score 125 points in a game, you've only got to > play good enough defense to hold the other team to 124. How > the hell hard is that?" -- Red Auerbach From m.wilson at bibliocraft.com Fri Jan 5 07:38:55 2001 From: m.wilson at bibliocraft.com (Mark Wilson) Date: Fri, 5 Jan 2001 12:38:55 -0000 Subject: Example of handling C callbacks Message-ID: <021901c07714$9deed460$1e824ac3@mwdell1> Le >Le Snelson wrote: >I have a legacy system which uses an interprocess communications (IPC) >library. It behaves very much like X-windows. It has its own event loop >and invokes callbacks in the same manner. > >What I would like to do is replace one of the processes in the middle of >this network of processes with a Python application. So, I'm looking >for examples of how to handle C callbacks in extensions. One thought >I've had is to SWIG the libray interfaces. This seems fine for sending >messages, but I can't visualize the callback implementation. Sounds like you need to check out PyEval_CallObject() etc. Take a look at the Python docs "Extending Python with C or C++>1.6 Calling Python Functions from C" (I'm looking at the 1.6 docs here - hope its not moved for 2.0). It may also be worth taking a look at the book "Programming Python" by Mark Lutz - quite old now, but fairly extensive discussion of this kind of thing, plus some useful sample code. Hope that helps. Mark From junaftnoon at nospamplzyahoo.com Mon Jan 29 02:22:09 2001 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Mon, 29 Jan 2001 16:22:09 +0900 Subject: SICP subsets exercise in python? References: <980725379.806449@emperor.labs.agilent.com> <980731358.408959@emperor.labs.agilent.com> Message-ID: <9535q3$kts$1@news.nuri.net> I don't think these are better ways(actually awful in terms of readibility) but you might find them interesting. They are one-liners. def subsets(list): return list and [ z+c for z in [[list[0]],[]] \ for c in subsets(list[1:]) or [[]]] or def subsets2(list): return list and map(lambda x,list=list: [list[0]]+x , subsets2(list[1:])) \ + subsets2(list[1:]) or [[]] Best regards, June "Brian Zhou" wrote in message news:980731358.408959 at emperor.labs.agilent.com... > Thanks Will, > > The problem I had was that being a python newbie, I didn't know in python + > is used for concat lists. Tried append(), insert(,0) without success. If you > happen to use python2.0+, list comprehension make it reads even better. > > def subsets(biglist): > if [] == biglist: > return [[]] > else: > rest = subsets(biglist[1:]) > return rest + [[biglist[0]] + x for x in rest] > > /Brian > > "Will Ware" wrote in message > news:G7wDLI.96M at world.std.com... > > Brian Zhou (brian_zhou at agilentNOSPAM.com) wrote: > > > Just curious if I can do it easily in Python, kind of give up after a > few > > > tries. Anyone? > > > > You could do worse than a straightforward translation from Scheme to > Python: > > > > def subsets(biglist): > > if not biglist: > > return [ [ ] ] > > rest = subsets(biglist[1:]) > > def func(ss, s=biglist[0]): > > return [s] + ss > > return rest + map(func, rest) > > > > There is probably a more idiomatically Pythonic way to do this. I'm > > too lazy to think of it right now. I'd start by looking for opportunities > > to replace recursion with iteration. > > > > -- > > import string,time,os;print string.join((lambda x:x[:10]+x[8:])(map( > > lambda x:string.center("*"*(lambda x:((x<24) ### Seasons Greetings, Will > Ware > > *(x-3))+3)(x),24),range(1,28, 2))),"\n") ################ > wware at world.std.com > > From max at alcyone.com Sun Jan 28 17:02:42 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 28 Jan 2001 14:02:42 -0800 Subject: [Off topic] allowed to put Python material on the Web? References: <3a730931.31998180@news.skynet.be> <3A73940E.2637C648@alcyone.com> Message-ID: <3A749702.4B239F30@alcyone.com> Neelakantan Krishnaswami wrote: > Erik Max Francis wrote: > > > Sheila King wrote: > > > > > Technically, once the messages are posted to Usenet, anyone can > > > archive and copy them. > > ... > > > Authors of Usenet posts still retain copyright to > > > their own material. > > > > These two statements are inconsistent with one another. (The latter > > is the one that is correct, by the way.) > > No, they're not. > > When someone posts a message they have to grant permission to people > to copy, archive and redistribute their messages -- since a) that's > how Usenet works, b) since posting to Usenet is wholly voluntary, and > c) judges and courts are not entirely stupid. "Anyone can archive and copy them" is not sufficiently limited to be accurate. You cannot copy a Usenet post uncredit into a book you're writing and be free of copyright infringement, for instance. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ War is cruelty, and you cannot refine it. \__/ Karl Shapiro Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From skreech at socket.net Fri Jan 12 18:45:42 2001 From: skreech at socket.net (Gavin Cooper) Date: Fri, 12 Jan 2001 23:45:42 GMT Subject: Using Python SSL References: <93nt06$4eu$1@nnrp1.deja.com> <3A5F8255.55F71A1D@stroeder.com> Message-ID: <93o4v4$bic$1@nnrp1.deja.com> Michael wrote: > skreech at my-deja.com wrote: > > > > I try to use the socket.ssl > > function I get SSL_connect errors. > > [..] > > I donno where to go from here, so any help would > > be appreceated. > > I can't help you but I would suggest that you try to test your code > against the OpenSSL implementation. "openssl s_server" and "openssl > s_client" can produce a lot of debug output. > > Ciao, Michael. > Well that helped the situation, I've figured out that my client does indeed work, but my server does not. s_client ends with this error trying to connect to the Python SSL "server": 3722:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:460: This leads me to think that there might not be a way to use Python's SSL like this to code an SSL _server_. I'll have to browse the socket module source some more to make sure, though. Thanks for pointing out the test server/clients though. Gavin Cooper Sent via Deja.com http://www.deja.com/ From max at alcyone.com Tue Jan 16 16:25:53 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 16 Jan 2001 13:25:53 -0800 Subject: [ANNOUNCE] FreeImage 2.0.0 out! References: Message-ID: <3A64BC61.E7570F28@alcyone.com> Oleg Broytmann wrote: > Linux certainly has! Thank you for explanation :))) What are you talking about? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ The tremor of awe is the best in man. \__/ Goethe The laws list / http://www.alcyone.com/max/physics/laws/ Laws, rules, principles, effects, paradoxes, etc. in physics. From phd at phd.pp.ru Tue Jan 23 09:29:14 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 23 Jan 2001 17:29:14 +0300 (MSK) Subject: About Content-Transfer-Encoding In-Reply-To: <01b001c08545$2ee0dca0$020000c3@node02> Message-ID: On Tue, 23 Jan 2001, Dhirja Gangopadhyay wrote: > I use the MimeWriter module to build a MIME body that I then send over SMTP > using smtplib. > > How can I force content-transfer-encoding to base64 ? > Content-type is text/plain, text/html and text/xml. http://www.faqts.com/knowledge_base/view.phtml/aid/3992/fid/380 Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From fredrik at effbot.org Thu Jan 11 10:41:06 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 11 Jan 2001 15:41:06 GMT Subject: Speed of Python vs. Perl References: Message-ID: Steve Holden wrote: > Would it be worth putting an optimization in so that the required paths, > etc., were pre-computed (for those who had specifically asked for such a > step)? if you know exactly what code you want to use, you can easily plug in a custom importer, and put everything in a single archive file (gordon's installer kit and pythonworks both let you do this). Cheers /F From zope at thewebsons.com Sat Jan 27 08:16:20 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sat, 27 Jan 2001 05:16:20 -0800 Subject: Problems with Install In-Reply-To: <20010126133015.B7309@harmony.cs.rit.edu> References: <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net> <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net> Message-ID: <5.0.0.25.0.20010127045146.00a42dc0@thewebsons.com> Unfortunately I need to install python 1.5.2 from source because I need to configure it with multithreads. Equally unfortunately, I don't have the luxury of time to learn C right this red-hot second. But I need to get this installation working!!! I've run into this error while running *make*. D said it was due to an error in the myreadline.o So I re-ran make and copied what printed to screen. The myreadline.o stuff doesn't appear until the last few lines: thor:/apache/vhosts/Python-1.5.2# make (cd Modules; make -f Makefile.pre Makefile) make[1]: Entering directory `/apache/vhosts/Python-1.5.2/Modules' make[1]: `Makefile' is up to date. make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Modules' making Makefile in subdirectory . make[1]: Entering directory `/apache/vhosts/Python-1.5.2' make[1]: `Makefile' is up to date. make[1]: Leaving directory `/apache/vhosts/Python-1.5.2' making Makefile in subdirectory Parser make[1]: Entering directory `/apache/vhosts/Python-1.5.2/Parser' make[1]: `Makefile' is up to date. make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Parser' making Makefile in subdirectory Objects make[1]: Entering directory `/apache/vhosts/Python-1.5.2/Objects' make[1]: `Makefile' is up to date. make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Objects' making Makefile in subdirectory Python make[1]: Entering directory `/apache/vhosts/Python-1.5.2/Python' make[1]: `Makefile' is up to date. make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Python' making Makefile in subdirectory Modules make[1]: Entering directory `/apache/vhosts/Python-1.5.2/Modules' make[1]: `Makefile' is up to date. make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Modules' (rm -f Modules/hassignal; cd Modules; make hassignal) make[1]: Entering directory `/apache/vhosts/Python-1.5.2/Modules' rm -f hassignal for i in regexmodule.o regexpr.o pcremodule.o pypcre.o posixmodule.o signalmo dule.o arraymodule.o cmathmodule.o mathmodule.o stropmodule.o structmodule. o timemodule.o operator.o fcntlmodule.o pwdmodule.o grpmodule.o selectmodu le.o socketmodule.o errnomodule.o md5module.o md5c.o shamodule.o rotormodul e.o newmodule.o binascii.o parsermodule.o cStringIO.o cPickle.o config.o ge tpath.o main.o getbuildinfo.o; do \ if test "$i" = "signalmodule.o"; then \ echo yes >hassignal; break; \ fi; \ done make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Modules' cd Parser ; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" all make[1]: Entering directory `/apache/vhosts/Python-1.5.2/Parser' gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c myreadline.c -o myreadline.o In file included from /usr/include/errno.h:36, from ../Include/Python.h:59, from myreadline.c:42: /usr/include/bits/errno.h:25: linux/errno.h: No such file or directory make[1]: *** [myreadline.o] Error 1 make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Parser' make: *** [Parser] Error 2 Just for fun I tried installing an rpm as you mentioned. The strangest thing happened. When I got to the actual installation command, the darn thing just vanished into thin air! running a whereis for python turns up *nothing*! Oh, geez, what'd I do wrong? TIA, BenO At 01:30 PM 1/26/2001 -0500, you wrote: >On Fri, Jan 26, 2001 at 08:36:51AM -0800, Ben Ocean wrote: >| Hi; >| I'm at a loss to understand why I can't get python working. I had it >| working before I moved my server. I re-installed it from src and typed >| *python* and got a prompt. I was ecstatic. So I went to re-install Zope and >| that installation failed. So I typed in *python* again and got >| bash: python: command not found > >It's not in the path. > >| How is that? It was just there! Where did it go? So I ripped out everything >| that had to do with python on my server and started over. When I got to >| *make* I got this error: >| >| make[1]: *** [myreadline.o] Error 1 >| make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Parser' >| make: *** [Parser] Error 2 > >The actual error is above this point. There is some problem building >myreadline.o. Maybe a compiler error or a linker error. Once you are >at this point, scroll up in your term and find where gcc gave the >actual error message. (make doesn't know what went wrong, only that >gcc said something went wrong) > >| >| It repeated with *make install* What am I missing? Also, I may have made a >| bad mistake in deleting everything python in my box, please advise. Running >| RedHat 6.2. >| TIA,BenO >| > >I'd advise along the same lines as David : use the rpms. If you want >the lastest and greatest, get the srpm. Then: > >$ rpm -ta .srpm > >This will create .i386.rpm in /usr/src/redhat/RPMS/i386 > >(by default, if you are using an x86 system) > >then > ># rpm -Uvh /usr/src/redhat/RPMS/i386/.i386.rpm > > >If you really want to build from the sources, it is a good idea to >learn C (or at least the C build environment) so that you will >understand the error messages you get. Packages are nice because >non-programmers don't have to deal with build/compilation errors. > >-D > > >-- >http://mail.python.org/mailman/listinfo/python-list From clickron at webtv.net Tue Jan 23 23:34:57 2001 From: clickron at webtv.net (clickron at webtv.net) Date: Tue, 23 Jan 2001 23:34:57 -0500 (EST) Subject: beep again Message-ID: <5251-3A6E5B71-16@storefull-163.iap.bryant.webtv.net> Thanks for answering my last question. I get the beep now, but no matter what numbers I put in for the frequency and duration it doesn't change. Ron From ahopkins at dynacare.com Tue Jan 23 12:18:25 2001 From: ahopkins at dynacare.com (Albert Hopkins) Date: 23 Jan 2001 11:18:25 -0600 Subject: Complete list of Python IDEs References: <25708BF4E69C79D8.642051B7F9A3B6D4.27F3341E69B04670@lp.airnews.net> Message-ID: I guess I'll start my own list. Will post a followup when I have one. On 23 Jan 2001 08:36:37 -0600, Cameron Laird wrote: >In article , >Albert Hopkins wrote: >> >>I know there are a few open source and commercial Python-ware IDEs >>available, but does there exist a list somwhere comparing features as well >>as contact info? > . > . > . >I know of none. If you or another enthusiast chooses >to write it, though, I'm sure we can find at least one >outlet to publish it. >-- -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From tim.one at home.com Wed Jan 24 03:48:43 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 24 Jan 2001 03:48:43 -0500 Subject: SourceForge problems [was: libraries=['m'] in config.py [Re: Python 2.1 alpha 1 ... ]] In-Reply-To: Message-ID: [Steven D. Majewski] > Please excuse the OT: I don't see any point in adding another unanswered > me-to complaint to the dozens already on SourceForge. Since there's a lot > of SourceForge users on this list maybe somebody knows what's up: > > SourceForge seems to be pretty effectively broken for "new" projects > ("new" = those registered in the last month or two. ) > > ... > > Does anyone know what going on at SourceForge ? According to http://sourceforge.net/ today, Hosted Projects: 14,366 Registered Users: 110,619 I guess that if we dug deep enough, that would pretty much explain everything <0.3 wink>. growing-pains-ly y'rs - tim From lele at seldati.it Mon Jan 8 15:27:21 2001 From: lele at seldati.it (Lele Gaifax) Date: 08 Jan 2001 21:27:21 +0100 Subject: Web devel with python. Whats the best route? In-Reply-To: "Alex Martelli"'s message of "Mon, 8 Jan 2001 17:46:13 +0100" References: <93cqvi0191h@news1.newsguy.com> Message-ID: >>>>> On Mon, 8 Jan 2001 17:46:13 +0100, "Alex Martelli" said: AM> "Chris Watson" wrote in message AM> news:mailman.978910629.6814.python-list at python.org... >> I'm about to start converting the small fool proof (ha ha) >> admin system I have been working from console based to web >> based. What is the easiest way to go about integrating python >> into apache so I can start web'izing this app? mod_python, >> mod_snake, PyApache? AM> CGI. Really. Your admin system doesn't look like the kind of AM> thing that will be continuously getting multiple hits a AM> second, making CGI overhead a problem. If that is the case, AM> CGI is easiest. *Do the simplest thing that can possibly AM> work*! PyApache does exactly this, only faster... ...but I'm a little biased here :) AM> AM> "Session continuity" will have to be provided via cookies, but AM> that's not really all that hard -- the amount of state you AM> need to save and restore between hits is most likely limited AM> anyway (making it acceptable for cookie-residence), or else AM> you can always use appropriate shelve files (presumably AM> relying on gdbm, whihc is OK) and just cookie the AM> shelve-access keys (that might impact scalability IF you were AM> close to the hit-per-second mark, but, are you _really_ AM> worried about such loads?). All mentioned modules do help in session handling, by providing some sort of persistent storage (tipically a dictionary). AM> Then again, maybe I'm simply being a dinosaur AM> on this specific theme!-) You are not alone !-) AM> Alex Ciao, lele. PS: Alex, un ciao particolare! Ti ricordi di me? Sublink... :) -- nickname: Lele Gaifax | Quando vivro' di quello che ho pensato ieri real: Emanuele Gaifas | comincero' ad aver paura di chi mi copia. email: lele at seldati.it | -- Fortunato Depero, 1929. From peter at engcorp.com Mon Jan 8 07:05:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 08 Jan 2001 07:05:50 -0500 Subject: Execution of import (was Re: boolean xor) References: Message-ID: <3A59AD1E.A8CA711E@engcorp.com> Tim Peters wrote: > > > def xor(a,b): > > from operator import truth > > return truth(a) ^ truth(b) > > [Peter Hansen] > > An aside: does the 'from .. import' statement execute every time > > the function 'xor' is called, or only during the execution > > of the 'def' statement? > > Imports of X after the first are just lookups, mapping the > module name to the (already executed) module object and retrieving the > latter. Despite the timing thread that follows your response, your answer is all I needed. Temporary brain fart made me incapable of picturing that 'truth' was not rebound dynamically every time through the function (and therefore that _of course_ import must executed each time through). I guess all that talk about Java and C recently switched my brain back to a less dynamic mode. Thanks. :) From sandj.williams at gte.net Fri Jan 12 10:38:38 2001 From: sandj.williams at gte.net (Steve Williams) Date: Fri, 12 Jan 2001 15:38:38 GMT Subject: why no "do : until"? References: <90278A4rcamesz@127.0.0.1> Message-ID: <3A5F264D.4D7C024A@gte.net> Andrew Henshaw wrote: > "D-Man" wrote in message > news:mailman.979261813.31482.python-list at python.org... > > On Fri, Jan 12, 2001 at 12:33:58AM +0000, Robert Amesz wrote: > > [snip] > ...snip > [more snip] > > Python's existing 'if condition: break', with its colon, stands out and, > more clearly than the 'until', shows its true function; which is, > essentially, a goto past 'something else' and out of the loop. I believe > that support for this is more likely than for the other more significant > changes. > If you have nested 'do' statements, you have to keep track of the nesting structure to find a break target. Searching for the first 'break' after a 'do' may or may not find the loop invariant. Similarly, if you have multiple 'breaks' for a single 'do', the first one you find may not be the one that bit you. With 'break', the program flow no longer corresponds to the program listing (the original complaint about g*t*, IIRC). There will always be debugging questions such as "how did I get here?" and "why did I skip this?" in procedural languages. 'Break' adds a little extra excitement to these questions. From amk at mira.erols.com Tue Jan 2 19:30:35 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 3 Jan 2001 00:30:35 GMT Subject: Recursion References: Message-ID: On Mon, 1 Jan 2001 16:31:42 -0500, Tim Peters wrote: >> In Ruby, you can input a value as high as 763 before you get a >> SystemStackError (stack level too deep) error. > >The recursion limit in Python varies across platforms; I assume that's true >in Ruby too; in Python you can use sys.setrecursionlimit() to fiddle it (but >if you set it "too high", you risk having the interpreter blow up due to C >stack corruption). The value of 763 is interesting; since it's not a magic constant that a human would have chosen, that means Ruby must be detecting when the stack is near overflow. This might be worth borrowing for Python, so I decided to take a look. Digging into ruby-1.6.1, the code that trips the error is this: if ((++tick & 0xff) == 0) { CHECK_INTS; /* better than nothing */ if (stack_length() > STACK_LEVEL_MAX) { rb_raise(rb_eSysStackError, "stack level too deep"); } } Very similar to the corresponding bit of ceval.c. STACK_LEVEL_MAX is either a constant or a value obtained from getrlimit(). stack_length(), then, is the last piece: extern VALUE *rb_gc_stack_start; static int stack_length() { VALUE pos; #ifdef sparc return rb_gc_stack_start - &pos + 0x80; #else return (&pos < rb_gc_stack_start) ? rb_gc_stack_start - &pos : &pos - rb_gc_stack_start; #endif } Ignore the "#ifdef sparc" branch, and it's quite simple. rb_gc_stack_start is determined by doing {VALUE start; rb_gc_stack_start = &start;} during program initialization. Is this approach worth pursuing for Python? This probably depends on nonportable behaviour not guaranteed by ANSI C (the stack pointer is continuously incremented/decremented, and not segmented or something weird), but for most practical platforms these assumptions probably hold. --amk From aleaxit at yahoo.com Tue Jan 30 04:13:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 30 Jan 2001 10:13:19 +0100 Subject: How to call a class method from a string representing a class name References: <3A745F5E.5F035F1D@axionet.com> <951p2j0e8@news2.newsguy.com> <3A74E327.C02A86FC@axionet.com> <953uge0vkg@news2.newsguy.com> <3A765B29.6CDD5DD7@axionet.com> Message-ID: <9560jd0ak7@news2.newsguy.com> "Andre Fortin" wrote in message news:3A765B29.6CDD5DD7 at axionet.com... [snip] > > different specs -- "modules only" as opposed to > > any object, "ever imported anywhere" as opposed to > > "in the current global namespace" > > This is a problem. Here is the semantic I'm trying to achieve: > > If 'THIS module here' has heard of a module named 'test' > call test.myFunc, which must exist according to the specs So it's OK to raise exceptions (or also OK to mask them), if 'test' exists AND the current module 'has heard of it', if said module lacks a myFunc entry, or said entry's not callable? OK. > if test.myFunc returns false, > instantiate test.test and use it for further processing OK. > Hmmm. It looks like the sys.modules is not what I'm looking for. It doesn't tell you whether THIS module has 'heard of' "test" -- just if "test" has ever been imported by ANY module. > You are suggesting > > > callable = eval(test+'.myFunc') > > which is likely to be more costly compared to what I started with e.g. > > try: > myObj = globals()[className] > apply(vars(myObj)['myFunc'], ('Some text',)) > except KeyError: > pass To make the approach you started with directly comparable to my suggestion of using eval, let's stick to "get the callable if any": def getCallable1(moduleName): try: return eval(moduleName+'.myFunc') except NameError: return None def getCallable2(moduleName): try: myObj = globals()[moduleName] return vars(myObj).get('myFunc') except KeyError: return None Measuring these implementations shows a time per call of (on my usual old P3/300 box) about 2 or 3 milliseconds for getCallable1 (module present/absent) versus about 1 or 2 for getCallable2 (module present/absent). So, yes, it IS slower to let the very general 'eval' builtin do all the work -- by about 1 millisecond each time. Whether this level of overhead IS significant, only you can tell -- it depends, of course, on how likely it is that 'test' will be present or absent, how much more work you must do if it's present, and how often you will be using this in your application -- e.g., if it's just a few thousand times and a few seconds' total slowdown (on an old box) is tolerable compared to your application's overal needs, then this is no real problem. If performance IS a crucial concern, then more work is needed. The key condition you want to test for is, "is there a variable named 'test' inside the globals() for this module"; it seems unlikely that this can be done much faster than by getting at the globals of this module and trying to fetch the 'test' entry! For getting the attribute 'myFunc' of said entry, though, getattr appears much more direct and explicit. def getCallable3(moduleName, globs=globals()): try: myObj = globs[moduleName] return getattr(myObj, 'myFunc') except KeyError: return None There is not much in it, either way, between the 2 and 3 versions in terms of performance; about one microsecond's advantage for one or the other, depending on whether module 'test' is present or absent. I would thus choose to ignore any performance considerations for this choice and go with 3 on the grounds of its relative simplicity and directness. Of course, you SHOULD re-do the timing on the boxes that are of direct interest to YOUR use, IF performance on this task is in fact crucial to your purposes (if it isn't, go with version 1, with eval -- "do the simplest thing that could possibly work" is my general suggestion). Alex From emile at fenx.com Fri Jan 26 09:03:05 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 26 Jan 2001 06:03:05 -0800 Subject: python-2.1 function attributes References: Message-ID: <94s0r0$elb5e$1@ID-11957.news.dfncis.de> "Tony J Ibbs (Tibs)" wrote in message news:mailman.980515832.8534.python-list at python.org... > Michael Hudson wrote: > > How about "having"? > > > > def func(param) having (publish=1, secure=0): > > """ docco """ > > print "bobbins" > > > > to emphasize the attribute-ness one could use a dot prefix: > > > > def func(param) having (.publish=1, .secure=0): > > """ docco """ > > print "bobbins" > > > > I think I like this (though I'm not sure about the dot > > prefix). I might see if I can whip up a patch... > > Yes, "having" is better than "with". That's neat. And it doesn't have > any obvious other meaning for me. (the important thing was probably > getting away from "with" - once that's done, if people really don't like > "having", suggesting new words is simple enough, at leisure) > > I'm not sure about the dot prefix either - it makes them obviously odd, > but feels sort-of unPythonic. I think I prefer without. > > I also like it without the dot, as it opens the door to allowing *args and **kwargs style parameter passing interpretation. -- Emile van Sebille emile at fenx.com ------------------- From aleaxit at yahoo.com Tue Jan 9 08:15:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 9 Jan 2001 14:15:52 +0100 Subject: Can we in python code, catch exception generated by C++ pythonized function? References: <3A5A4545.661385AD@aristotech.com> Message-ID: <93f30s0231k@news1.newsguy.com> "Siu-Tong Hui" wrote in message news:3A5A4545.661385AD at aristotech.com... > I tried and it won't. Anybody have any workaround for that? Any pointer > is appreciated. Thanks. What you see on the Python level as a Python exception is denoted by a C-level function returning NULL (a zero pointer) rather than a PyObject* (a pointer to a PyObject), as well as having made the appropriate PyErr_... calls to define the details of the exception-object being 'raised'. This is part of Python's C API. "Exceptions" raised/handled by other protocols (such as, C++ Exceptions, COM Exceptions, Win/NT SEH Exceptions, and so on) have no a-priori connection with this specific exception protocol. You (or whatever framework you're using to map your code to Python's C API) must bridge the gap, if you want it to be bridged. You're not telling us which (if any) framework (such as Boost Python, CXX, etc) you may be using to map C++ code to Python's C API, so, as a guess, you may be using the raw C API from C++. That's OK, but then you also need to do the needed bridging at the raw C API level. E.g., where you now have something like: PyObject* myFunction(PyObject* self, PyObject* args) { // lots and lots of code snipped return Py_BuildValue(""); // or whatever } you will instead have something like: PyObject* myFunction(PyObject* self, PyObject* args) { try { // lots and lots of code snipped return Py_BuildValue(""); // or whatever } catch(...) { // more specific catch clauses work better // whatever PyErr... calls are appropriate return 0; } } Alex From pen_man at my-deja.com Wed Jan 17 20:13:53 2001 From: pen_man at my-deja.com (penman) Date: Thu, 18 Jan 2001 01:13:53 GMT Subject: Displaying HTMLs with Tkinter References: <945db6$umq$1@nnrp1.deja.com> Message-ID: <945g0b$sd$1@nnrp1.deja.com> In article <945db6$umq$1 at nnrp1.deja.com>, penman wrote: > Is there any way that I can display HTML texts in Tkinter? > (Like in wxPython -- HTML widget?) > > Thanks in advance. > > Sent via Deja.com > http://www.deja.com/ > Did a web search and found the following message. [quote] >> So I'm wondering - is there any sort of Tk (or other) module which will >> display HTML code in a window? The Tk module indeed does have the capability to display HTML. If you look in the Demos/www directory in the standard Python distribution, try running "www8.py file:" and "www12.py file:". [end of quote] But I can't find the files anywhere. Are they obsolete now? Sent via Deja.com http://www.deja.com/ From aahz at panix.com Sun Jan 28 00:47:50 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jan 2001 21:47:50 -0800 Subject: Thread Safety References: <980660755.2138768834@news.silcom.com> Message-ID: <950bq6$h1t$1@panix6.panix.com> In article <980660755.2138768834 at news.silcom.com>, Clarence Gardner wrote: > >I have a multithreaded program in which I use the following pattern in >various places, because I was pretty sure it was thread-safe. But since >I was just reading the thread about statcache, I thought I'd ask just to be >sure. The code is in a function that runs periodically and disposes of >accumulated work: > >def Periodic(): > global PendingDataStorage,PendingStatusUpdates > while 1: > time.sleep(10) > Data,PendingDataStorage = PendingDataStorage,[] > if Data: > StoreDataPoints(Data) > Data,PendingStatusUpdates = PendingStatusUpdates,[] > if Data: > SetErrorStatus(Data) > >The code I'm talking about are the two binding statements, where >I bind to two names which form a tuple, rather than two statements, >which would certainly not be thread-safe. That's safe, yes, for as long as the GIL exists. I personally would prefer to use a singleton class instance or a static module variable rather than a "global" variable, but that's more a matter of taste. Another thing you could do to make your code a bit more efficient would be to do this: if not (PendingDataStorage or PendingStatusUpdates): time.sleep(10) In the end, though, I think I'd most likely split this loop into two separate threads and use Queue.Queue() unless you have a specific reason for wanting to batch up work every ten seconds. That would guarantee the best response time. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "I heard Commentary and Dissent had merged and formed Dysentary." From mspiggie at my-deja.com Wed Jan 31 18:45:37 2001 From: mspiggie at my-deja.com (mspiggie at my-deja.com) Date: Wed, 31 Jan 2001 23:45:37 GMT Subject: Any practice exercises for beginner??? References: Message-ID: <95a82u$b6r$1@nnrp1.deja.com> You may find some interesting ideas and source code at: http://www.lowerstandard.com/python/pythonsource.html Rob Andrews In article , "shaka" wrote: > > > I was just wondering beside the tutorial if there was any practice > exercises to reinforce beginners strength in python? > I can recall that when learning Java, some Java website offered some > exercises for beginners. > > Sent via Deja.com http://www.deja.com/ From aleaxit at yahoo.com Fri Jan 19 12:20:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 19 Jan 2001 18:20:59 +0100 Subject: Evaluting a python code in a string References: Message-ID: <949t2d0bug@news1.newsguy.com> "Steve Tuckner" wrote in message news:Se_96.394$mY4.179630 at news.uswest.net... > In Perl you can evaluation perl code that is embedded in a string by using > the Eval function. For example the following code: > > $i = "hello" > eval "print $i"; > > will print "hello" to the terminal. > > How can a person do a similar function in Python? To execute a statement held in a string: i = 'hello' exec 'print %s' % i > I tried the following code: > > import code > c = code.compile_command("print \"hello\"") > code.runcode(c) > > and I get a run-time exception: Attribute error: runcode. I get the same > error if instead I just use the runsource() function. compile_command returns a code-object; I'm not sure where you got the idea that a code-object has either a runcode or a runsource method. If you wish, you can use a code-object as a parameter to the exec statement -- saves having to re-parse a string each time. But you may as well get the code-object from the builtin compile function -- all code.compile_command is adding is heuristics to determine if a command (entered interactively) is incomplete. c = compile('print "hello"', '', 'exec') and then exec c Alex From gerhard.nospam at bigfoot.de Fri Jan 12 09:49:01 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 12 Jan 2001 15:49:01 +0100 Subject: Binaries for mySQL module ? References: <9%t76.1516$B6.336141@news1.rdc1.md.home.com> <93mpi0$3v1$1@nnrp1.deja.com> Message-ID: As said before, MySQLdb binaries for win32 can be downloaded at http://highqualdev.com This happens to be my own homepage. :-) Gerhard On Fri, 12 Jan 2001 11:24:52 GMT, Hamish Lawson typed into his computer: >Eric Hagemann: > > Are there binaries for mySQLmodule for win32 available ? > >Jason Cunliffe: > > Check carefully at: http://mysql.he.net/downloads/mysql-3.23.html > >That site has the Windows binary for the MySQL database engine and >monitor. Eric is actually looking for a Windows binary of the Python >(with some C) module to interface to the database engine, which I don't >think is at that site. -- mail: gerhard bigfoot de web: http://highqualdev.com From erno-news at erno.iki.fi Tue Jan 23 04:58:16 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 23 Jan 2001 11:58:16 +0200 Subject: Can I decompile PYC files? References: <94j8j5$50e$1@nnrp1.deja.com> Message-ID: In article <94j8j5$50e$1 at nnrp1.deja.com>, noahspurrier at my-deja.com writes: | A process just deleted my .py file. I still have the .pyc file. | Can I recover anything? I'm desparate. It doesn't have to be perfect. did you try a search engine?-) . -- erno From NoSpam at NoSpam.com Fri Jan 19 12:34:12 2001 From: NoSpam at NoSpam.com (Tom) Date: Fri, 19 Jan 2001 17:34:12 GMT Subject: Debugging References: <979896042.23819.1.nnrp-10.c3ad12d2@news.demon.co.uk> Message-ID: You will need to create your own debug version of Python.exe and Python20.dll. In your module's project settings, for "Executable for debug session", specify the path to your python debug exe. I think that is all. Tom. "Toby" wrote in message news:979896042.23819.1.nnrp-10.c3ad12d2 at news.demon.co.uk... > Is it possible to debug an Python 2.0 extension (a DLL) written in MSVC++ > 6.0 ? If so how ? I presume I would need a debug version of Python as > well... > > TIA Toby > > From robin at jessikat.fsnet.co.uk Thu Jan 11 11:49:40 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 11 Jan 2001 16:49:40 +0000 Subject: BUG Python 2.0 FreeBSD compile problem References: Message-ID: In article , Fredrik Lundh writes >Robin Becker wrote: >> When building Python 2.0 with FreeBSD xxx.com 2.2.7-STABLE FreeBSD >2.2.7-STABLE >> I get undefined references to _TELL64 at load time unless I change line 61 of >> Objects/fileobject.c from >> >> #elif defined(__NetBSD__) || defined(__OpenBSD__) >> >> to >> >> #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) > >http://sourceforge.net/bugs/?func=detailbug&bug_id=128119&group_id=5470 > >(still says "Resolution: None", but I'm pretty sure a fixed >was checked into CVS a couple of days ago... if you can >verify that the CVS version builds cleanly, let us know!) > >Cheers /F > > I can verify that that patch applied separately builds OK. I'm not building the CVS version as we'll be using the result for production eventually. -- Robin Becker From root at rainerdeyke.com Wed Jan 31 14:49:26 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 31 Jan 2001 19:49:26 GMT Subject: from-import on non-module objects? References: <959jna$nfl$1@nnrp1.deja.com> Message-ID: "Hamish Lawson" wrote in message news:959jna$nfl$1 at nnrp1.deja.com... > class AClass: > > def __init__(self, x, y): > self.x = x > self.y = y > > def output(self): > from self import * > print x, y This probably won't ever be added to Python for two reasons: 1. It is inconsistent. In 'from A import *', 'A' is not drawn from the current namespace, but from the external "namespace" of all modules that can be imported from the current package. 2. It is ambiguous. If there exists a module called 'self', how is the above statement to behave? Incidentally, while 'from A import *' in a function works, it does not behave correctly as of version 2.0. In particular, the following function fails to behave as expected: def f(): global path from sys import * print path The problem goes away if I either remove 'global path' or replace the 'import *' with 'import path'. I'm guessing it took a really ugly hack to get this to work at all, given how local variables are normally addressed, and the hack is not entirely reliable. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From hwhite at chiliad.com Wed Jan 3 19:16:49 2001 From: hwhite at chiliad.com (Heather Lynn White) Date: Wed, 3 Jan 2001 19:16:49 -0500 (EST) Subject: regular expressions: grabbing variables from multiple matches Message-ID: Suppose I have a regular expression to grab all variations on a meta tag, and I will want to extract from any matches the name and content values for this tag. I use the following re MetaTag=re.compile( r'''<\s*?(meta|META)\s*?=\s*?"(?P.*?)"\s*?(content|CONTENT)\s*?=\s*?"(?P.*?)"\s*?>''' ) now suppose I have an html document and I want to iterate through all the meta tags in that document. If I only catch one, I would say matches=MetaTag.match(body) if matches: flds=matches.groupdict() name=flds["name"] content=flds["content"] print name, content but this does not work if I use instead findall, to get multiple matches, because findall returns a list of matches rather than a list of match objects, unlike all the other functions. Is there a way to extract these variables in the way I have done above, but with many matches? -heather From sholden at holdenweb.com Wed Jan 31 19:45:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 31 Jan 2001 19:45:19 -0500 Subject: mxDateTime for Python 2.0 for Win32 - binary PYD file References: Message-ID: "Warren Postma" wrote in message news:kEAd6.8145$Oe.37320 at tor-nn1.netcom.ca... > Okay, I think I feel stupid now. > > Warren > Please feel free to borrow my head-thwacker. But don't keep it tool long, as I'll undoubtedly need it myself the next time I get too smart for my own good. regards Steve From sbrunning at bigfoot.com Thu Jan 18 11:30:47 2001 From: sbrunning at bigfoot.com (Simon B.) Date: Thu, 18 Jan 2001 16:30:47 GMT Subject: Automatic Documentation Tools? References: Message-ID: <9475no$c6i$1@nnrp1.deja.com> In article , Terry Hancock wrote: > Any suggestions? > > -- > Terry Hancock > hancock at earthlink.net Marc Lemberg's doc.py (from ) is pretty nice if the modules and classes have good docstrings. -- Simon Brunning A woman drove me to drink and I didn't even have the decency to thank her. - W.C. Fields Sent via Deja.com http://www.deja.com/ From mal at lemburg.com Fri Jan 26 06:22:50 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 26 Jan 2001 12:22:50 +0100 Subject: Unicode string output References: Message-ID: <3A715E0A.3F704B18@lemburg.com> Boudewijn Rempt wrote: > > On Thu, 25 Jan 2001, M.-A. Lemburg wrote: > > > > Well, you can manage multi-user settings easily by providing > > a special sitecustomize.py module, so I guess that's a non-issue. > > > > Perhaps - but it is often the application, not the user that > knows about encodings. I can easily imagine my small Chinese > editor to work in Big5 for someone from Taiwan, but in Unicode > for me - an application-level default, and if we use the same > computer, a user-level default. > > > The problem with having a per application setting for the > > default encoding is that this would cause code to be written which > > may rely on one specific default encoding. It is much better > > to write such assumption into the code itself than to rely on > > default settings. > > > > But setting an application-level default _is_ putting the assumption > in the code, instead of in the system. Now you get apps that count > on the system default being us-ascii... We chose US-ASCII after endless discussions on python-dev. ASCII is compatible with most of the existing encodings out there, so it can provide a common ground for automagical conversions such as the ones happening behind the scenes in Python. We had also planned for automatically setting the default encoding using the locale settings on the machine running the application and choosing Latin-1 (the first 256 Unicode character points) as default. In the end, our BDFL chose ASCII as standard. The code for the other two possibilities is still there though (see site.py and locale.py for details). What I meant with putting the logic into the application is that it is usually better to make assumptions explicit in the code you write, rather than making some assumption on the system configuration (and the site*.py module should be considered system settings). I have always made a point for explicit conversions from Unicode to an 8-bit string encoding. The reason is simple: relying on magic to do the right is convenient but will fail badly if the magic changes due to altered system configurations. This is fairly easy to do in Python: just write a helper which does the conversion and use for all Unicode<->string conversions. > > I agree though, that we will need to put some more work into > > making streams and other interfaces more Unicode aware and to > > simplify those interfaces. In theory you could e.g. redirect > > stdin and stdout through codecs, but in practice this currently > > doesn't work well together with "print" due to the complicated > > machinery in the Python interpreter. > > > > One other example is PyQt - the conversion between QString (Unicode > in itself) and Python strings goes via the default codec, meaning > us-ascii for most installations. Again, technical details seem > to make it impossible or at least difficult to alter that, but setting > an application level default makes it easy to work with. This is a problem of PyQt not the Python Unicode implementation. Extensions which apply these conversions can easily choose different conversions at their liking. I have made the Unicode API in Python very flexible in this direction for exactly this reason. Please write to the PyQt maintainers about this problem. > > The same goes for making the Python standard lib more Unicode > > aware. There's still a lot to do ... we could need some sponsors :) > > > > I'd help if I could, but currently I'm a bit overworked as it is, > with completing Kura, writing something publicable on Jython, and > of course, coding Java for a living. On the whole, though, I'm pretty > content with the Python Unicode support - and I've never had a > problem with my sitecustomize.py file and the saved copy of > setdefaultencoding. But then, I don't switch encodings during the > lifetime of the application. ... and that's what we had in mind when making the API available in site.py only. Perhaps we should think about easing the restriction a bit to make the setting a one-shot operation: you could then call sys.setdefaultencoding() at most once in any run of a Python application and then only before using Unicode in the application. -- Marc-Andre Lemburg ______________________________________________________________________ Company: http://www.egenix.com/ Consulting: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From aleaxit at yahoo.com Tue Jan 9 08:27:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 9 Jan 2001 14:27:44 +0100 Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> <93dde1$8d2$1@animus.fel.iae.nl> Message-ID: <93f3nb023mv@news1.newsguy.com> "Carel Fellinger" wrote in message news:93dde1$8d2$1 at animus.fel.iae.nl... [snip] > > This assumes a non-string argument (typically an integer, but that's > > not checked here) is meant to set the value to be named by the > > string-argument immediately *following* it -- a substantial > > simplification. So substantial, that if one > ... > > Needing to explicitly set values in an enum is rare enough, that it > > would seem fully acceptable to me to place the explicit values right > > _before_ their names in those rare cases, using the much-simpler > > code above. Viva simplicity...!-) > > Simplicity of implementation, yes. But is this what one would expect? Personally, I would expect _nothing in particular_ when reading something like xx = enum('foo', 'bar', 32, 'fee', 'fie', 45, 'flip', 'flop') i.e., just a list of name-like strings occasionally mixed with values that clearly aren't names. > I think all the languages I know that provide an enumaration method > that allows for changing the count midway spell it the other way > around, first the name then the value. With some extra syntax, such as equal-signs, or arrowlike squigglies pointing in either explicit direction, expectations would surely firm up. E.g., if I read: xx = enum('foo', 'bar', 32, '<-fee', 'fie', 45, '<-flip', 'flop') I would guess the arrows are suggesting 32 is the value of 'fee' and 45 the value of 'flip, while if I read: xx = enum('foo', 'bar->', 32, 'fee', 'fie->', 45, 'flip', 'flop') then the different arrows would suggest 32 as the value of 'bar' and 45 as that of 'fie'. Absent such extra syntax clues, though, I don't see expectations being meaningful either way. What language lets you define enums with _some_ values out-of-order by just letting you list names and non-name values with no further demarcation? Python's mantra "when in doubt, avoid the temptation to guess" would then *strongly* urge one to drop this complication altogether. > of it, especially since its use is so rare. Arguely an even better > approach would be to have such new counting points be spelled as > tuples; a little more eye-catching and simplifying the code even > further:) That's one possibility. Syntax such as "bar=32" (for names in the enumlist whose value is explicitly defined) being another alternative, still better than 'just the list' (and a split on that form is enough to make it into the name/value pair, so it would be easy enough to accept either). Alex From dbrueck at edgix.com Fri Jan 12 15:11:36 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Fri, 12 Jan 2001 13:11:36 -0700 Subject: "Full" object and class pickling? In-Reply-To: <979329680.407225@sj-nntpcache-3> Message-ID: <00aa01c07cd3$de485580$450514ac@PRODUT2KDAVE> The marshal module can do code. This may help a little, it's not class defs but functions: >>> def foo(a,b,c): ... print a + b + c ... >>> foo(10,11,12) 33 >>> import marshal >>> q = marshal.dumps(foo.func_code) >>> def bar(): ... pass ... >>> bar.func_code = marshal.loads(q) >>> bar(10,11,12) 33 Also, FWIW, it may be easier to have the remote side request the .py file for an unknown class (ie - you send it an object it doesn't recognize, so it comes back and asks for that module). Then you locally use imp module to locate and read the module's .py, zlib to compress it, and then send it out over the socket. But this might not be an option in your case... -Dave > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Stuart Stanley > Sent: Friday, January 12, 2001 12:59 PM > To: python-list at python.org > Subject: "Full" object and class pickling? > > > > I am doing some experimenting with mobile objects. I.E., python > objects that physically migrate from process to process via some > mechanism. I had thought (c)pickle was my ticket, but pickle does > not bring the _code_ with. Does anyone know a mechanism to: > > 1) "pickle" the _complete_ object, including its byte-code? > 2) "pickle" a class so I can create instances from it without using > imports? I.E., I want to migrate the classes used in > return values > from the above (#1) transported objects and use them to > create objects > that can do things like compare against the return > values from the > migratory objects... > > For a number of reasons I need to avoid doing imports in the > "non-home" > processes... > > Clues? Hints? Complete packages that does all this already? ;) > > Thank you -- stuart > > > -- > "Computer Science is no more about computers than | Stuart Stanley > astronomy is about telescopes." - E. W. Dijkstra | stuarts at cisco.com > | Cisco > Systems, inc > | St Paul, MN > | 612.578.6412 > -- > http://www.python.org/mailman/listinfo/python-list From xiaoyan at netease.com Tue Jan 9 22:52:39 2001 From: xiaoyan at netease.com (Pan) Date: Wed, 10 Jan 2001 11:52:39 +0800 Subject: aluminium profile made in China Message-ID: <20010110034746.9B4D71C2F5A79@mx1.netease.com> Dear Sir or Madam, We are taking the liberty to e-mail this message. If you find it to be interesting, please feel free to contact us for further information. Otherwise please let us know.Thanks Guangdong Jianmei Aluminum Shapes Factory is a professional manufacturer onaluminum alloy shapes, equipped with a complete set of advanced machinery for Aluminum alloy shapes manufacturing such as SMHD billet castings, nine shapes extrusion and two anodizing production lines, and possess two sets of New Spout Powder Product Line imported from overseas. The total capacity comes to 38000 tons per year. The main business line: 30 series of profiles for glassy certain wall (including hidden frame, semi-hidden frame, framed), sliding windows, swing door casement windows etc. Then, it can design and produce special kinds of profiles according to the order. Looking forward to hearing from you soon. Thank and Best regards, Jian Mei Guangdong Jianmei Aluminum Shapes Factory E-mail: nhjianmei at china.com fax:0086-757-6336141 Contact Person: Jian Mei From ullrich at math.okstate.edu Fri Jan 12 13:30:15 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 12 Jan 2001 18:30:15 GMT Subject: is Python fully object oriented ? References: Message-ID: <93nifo$qa7$1@nnrp1.deja.com> In article , =?iso-8859-1?Q?Max_M=F8ller_Rasmussen?= wrote: > From: Simon Brunning [mailto:SBrunning at trisystems.co.uk] > > >> I don't know if this helps, but it's perfectly legal to use a name other > >> than "self" in Python, e.g., > >> > >> class SpamChunk: > >> def __init__(s): > >> s.color = 'green' > >> > >It's also legal never to wash, but you won't make many friends that way, > >either. > > It's the only thing about Python that bothers me endlessly, having to > explicitly pass "self". > > In javascript ie. "this" is implicit and that is so much simpler. > > I know it breaks the rule of "Explicit is better than implicit" but this > ought to to be an exception as it is so commonly used. (And I so commonly > make the mistake of forgetting it ;-) ) > > Is there a REALLY good reason that it has to be explicitly declared ? Makes a lot of things easier. Like it makes it easy to invoke a method of a class on something other than an instance of that class, which is actually a perfectly standard idiom around here: class A: def __init__(self): pass class B(A): def __init__(self): A.__init__(self) A person could invent syntax to do exactly that one thing with an implicit self, maybe with an "inherited" keyword as in the one language I know with an implicit self (Object Pascal). How would a person do class C(A, B): def __init__(self): A.__init__(self) B.__init__(self) with an implicit self? DU > Regards Max M > > -- Oh, dejanews lets you add a sig - that's useful... Sent via Deja.com http://www.deja.com/ From sandj.williams at gte.net Mon Jan 15 12:26:22 2001 From: sandj.williams at gte.net (Steve Williams) Date: Mon, 15 Jan 2001 17:26:22 GMT Subject: why no "do : until"? References: <90278A4rcamesz@127.0.0.1> <3A5F264D.4D7C024A@gte.net> Message-ID: <3A633415.47D71944@gte.net> Andrew Henshaw wrote: > Steve, > > Forgive me for not knowing your stance on some of the earlier points > discussed, but I was responding to Rober Amesz' do - until proposal. Would > not your statements also apply to his use of > until condition > instead of > if condition: break > ? > I suppose that you could limit each 'do:' loop to one 'until' to avoid the > multiple breaks problem. Implicit in that proposal would be the assumption > that 'if condition: break' would not be allowed in a 'do:' loop. I don't > think that suggestion would fly very well. > > Given Python's current structure, I still believe that the best compromise > is the allowance of > do: > as a synonym for > while 1: > > and leave it at that. > [snip] Andrew I haven't followed the thread very well. Your mention of 'g*t*' triggered my response. I feel both 'g*t*' and 'break' disrupt the correspondence between program listing and program flow. I confess I use 'break' when I have found the result of a serial scan. "Yes, My name is Steve W. and I am a 'break' user." ('Exit do' and 'Exit for' in VB, so I have much to be ashamed of). But, I'm not a C programmer and 'while 1' doesn't speak to me in a language I can appreciate. I had the hardest time understanding the ISO on/off switch codes of 1/0. Was this high-level logic or low-level logic? Using -1 as a truth value is beyond my comprehension--since -1 is less than 1, it must be false. . .. In any case, I want to see a real conditional as part of the 'while'. That's just the way I'm put together. And I don't want the conditional used as some kind of tatty scope delimiter fifty lines later. If you need a scope delimiter, use 'end-while'. If I have a 'while x <> 0:' statement it tells me something. It says "this is a loop and this is how it's terminated". I can then search for the variable x and see who sets it or how it's referenced in the loop. If I have to prime the value of x before the loop, that's OK with me. Actually, I like to initialize all my variables. I'm kind of a control freak that way. Conversely, when I see 'While 1', all I know is "this is a loop". I'm now on notice to dig deeper and find out how the loop terminates and hope I get it right. I don't have an opinion on the 'loop and a half construct'. I usually take it as a warning I've not thought out my design thoroughly enough. Again, just my prejudice. When I started learning Python, I wrote some prime number seive finger exercises using nested 'breaks'. I quickly learned I couldn't find a break target unless the entire loop was displayed in one screen fill. My bifocals just couldn't keep track of breaks and indents at the same time across screen fills. These are my prejudices and follies. I really don't have much to contribute to the discussion. Python is a great language as it stands. The old Python hands dearly love 'While 1' and more power to 'em, say I. From max at alcyone.com Mon Jan 29 11:39:10 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 29 Jan 2001 08:39:10 -0800 Subject: Hack request: rational numbers References: <951h34$tch$1@nnrp1.deja.com> <3A745D6C.2EEA931@home.nl> Message-ID: <3A759CAE.5D3EE1BA@alcyone.com> Jaap Spies wrote: > My late professor Freudenthal said: "A good > mathematician is independent of notation" Wouldn't be Hans Freudenthal, author of _Lincos_, by any chance, would it? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ I sidestep the either \__/ or choices of logic and choose both. | Ken Feit Official Buh rules / http://www.alcyone.com/max/projects/cards/buh/ The official rules to the betting card game, Buh. From mfletch at tpresence.com Thu Jan 11 00:22:33 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Thu, 11 Jan 2001 00:22:33 -0500 Subject: default arguments newbie question Message-ID: Don't know that I'd call this pathological, merely obscure. On the other hand, there are people who have decided every piece of code I write is pathological, so you may be ultimately correct in your classification :o) . There are significant reasons for creating such objects (how do you model an object that's supposed to be None-like, but requires some extra feature that None doesn't provide). Without type-subclassing, such approaches are occasionally employed. When they are employed, the people using such systems find that x is None tests all have to be changed to x == None to allow the new objects to work. Once we get rid of the type-class split we'll have to deal with this all over again (Does None get special "is" testing so that all sub-class instances are considered equal? then how do we test the difference between them?) That is, they two statements have semantic inequality. One tests the address and tests pointer equality, the other specifies that two objects have the same "value"... PyObject * x,y; (x == y) != (&x == &y); Where the actual test for value is some byzantine series of checks for slots and calls and reverse calls and such that allow an object to define whatever testing it likes. My observation was that the original poster wouldn't likely care, not that no-one should care. We all love the little folds and twists of Python, it's what makes it such a lovable, squeezable creature... :) Enjoy, Mike -----Original Message----- From: Erik Max Francis To: python-list at python.org Sent: 1/10/2001 11:33 PM Subject: Re: default arguments newbie question Mike Fletcher wrote: Well, sure, you can come up with pathological cases, but as you say, it isn't terribly important as a serious technical objection. ... From nickatvideosystemdotcodotuk Fri Jan 12 12:40:26 2001 From: nickatvideosystemdotcodotuk (Nick Trout) Date: Fri, 12 Jan 2001 17:40:26 -0000 Subject: is Python fully object oriented ? References: Message-ID: <3a5f41b2@news.xtml.co.uk> > I know it breaks the rule of "Explicit is better than implicit" but this > ought to to be an exception as it is so commonly used. (And I so commonly > make the mistake of forgetting it ;-) ) > > Is there a REALLY good reason that it has to be explicitly declared ? New users constantly raise questions on this forum about Pythons language features, e.g. "self" & colon at end of if and while etc. The point is, they are just idiosyncrasies of the language. The FAQ points out that Guido used self as it was path of least resistance when he added classes. It also has the advantage of making the code less ambiguous. If "self", or any of these features, bugs someone enough then there are plenty of other languages out there (e.g. Ruby, Perl etc), so try another one (I hope you won't and this is not a flame!). But, you have to ask yourself, why is the Python user base growing so quickly? These are minor things! I personally thought it was a pain when I started Python but now I think its an advantage. I am an advocate of coding standards and I believe that this is a useful one. Cheers, Nick From jasonic at nomadicsltd.com Mon Jan 29 16:31:36 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Mon, 29 Jan 2001 16:31:36 -0500 Subject: Books References: <3a757ac1$1@netnews.web.de> <3a757f33$1@netnews.web.de> <3a758a80@netnews.web.de> Message-ID: Volker Jahns wrote in message news:3a758a80 at netnews.web.de... > What is the benefit using pyhton instead of PHP or JAVA (serversided)? It makes > we wonder, that the python.org uses php for dynamic web pages. So am I on the > wrong way using python for dynamic web pages with database access (mysql, > postgress,...)? Want to do some serious web programmng with Python? ...check out Zope! http://www.zope.org But you are right http://www.python.org is waaay overdue for an overhaul. Due to a lot business reshuffling last year of core Python team, the site did not get the attention it deserved, and all key people were busy developing Python 2.x code itself. I imagine before long www.python.org swill be re-implemented with Zope, and become a site to marvel at. ...stay tuned :-) >>>Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] From MarkH at ActiveState.com Wed Jan 24 23:32:13 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 25 Jan 2001 04:32:13 GMT Subject: beep again References: Message-ID: <94oa8d$ibu$1@nnrp1.deja.com> In article , "Tim Peters" wrote: > Don't have more time for this now. Win98SE. I'm pretty > sure the "ding" I hear is the registered Windows > "Default Sound" (ding.wav, on my box) ... > yup! If I change the Default Sound setting while > test_winsound is running, test_winsound starts playing > the new .wav file instead. We learn something new every day :-) I just had a look at the MS documentation for this function, and it states at the bottom: """ Remarks Windows 95: The Beep function ignores the dwFreq and dwDuration parameters. On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep. """ Not much we can do about it that I can see, except possibly add a note to the docstring. Mark. Sent via Deja.com http://www.deja.com/ From joejava at dragonat.net Fri Jan 5 00:47:32 2001 From: joejava at dragonat.net (Joel Ricker) Date: Fri, 5 Jan 2001 00:47:32 -0500 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <933fa1$j2i$1@newshost.accu.uu.nl> Message-ID: Martijn Faassen wrote in message <933fa1$j2i$1 at newshost.accu.uu.nl>... [*snip*] >Joel Ricker wrote: >> What about OOP? Is it it a full OO language? > >Yes, Python does OOP just fine, and is a full dynamically typed OOP language. >If you are familiar with languages like C++ or Java you're in for a >hopefully pleasant surprise; there is much less programmer overhead to >create and use classes than there is in those languages, due to the >simpler syntax, and dynamic typing instead of static typing. > >> Is it easier than to use than >> perl? Perl OO just feels like it has been cludged together. > >From my limited experience with Perl, definitely yes. I've been told Perl's >OO model is actually inspired by Python's, but I didn't spend enough of time >with Perl's OO features to know much about that. >From your examples, Pythons class model is much cleaner. Also if I understand your example, variables internal to the object are kept internal -- they can't be accessed without a proper method. With perl anything goes. There are some techniques to prevent this but it isn't definite. Its actually this very topic that made me throw my new OO book across the room and subscribed to this newsgroup :) >In python this is how you make a class: [*snip -- OO example*] I've mentioned before that I'm real new to OO. How should I approach it in Python? Has anyone learned OO just from Python? Or should I study OO theory else where and then apply it to Python? I know this is bordering on the question of how do I do OO but I really know very little about it... enough to know that I can benefit from it and basic ideas. I understand the idea of a class and building objects from it but anything beyond that is still really new to me. Any suggestions? >The Python community's reputation is that it's friendlier than the Perl >community, the flame war about variable initialization in the do..until >thread notwithstanding. :) I heard something about curley braces as well. No {} for blocks? Thats going to take some getting used to :) >I've seen people beinn pleasantly surprised by the quality of answers they've >received in this newsgroup, so you may like it. I know I have been. Nothing like a friendly newsgroup to convince me to switch -- at least take a break from perl for awhile to see how the other side lives. Thanks Joel From barry at digicool.com Fri Jan 19 21:00:27 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 19 Jan 2001 21:00:27 -0500 Subject: Tabbing/Spaces References: Message-ID: <14952.61755.305422.224347@anthem.wooz.org> >>>>> "JH" == Johann Hibschman writes: JH> A mixture of tabs and spaces is most common, I'm afraid, since JH> that's what emacs defaults to doing. Not for python-mode. The default for new Python files is 4-space indentation levels and no tabs. Python-mode will adapt somewhat to the conventions already existing in the file though. See the variable py-smart-indentation for all the gory details. -Barry From s2mdalle at titan.vcu.edu Sat Jan 6 14:22:27 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Sat, 06 Jan 2001 19:22:27 GMT Subject: Speed of Python vs. Perl References: Message-ID: In article , "AndroidMonkey" wrote: > In the last Maximum Linux magazine, there was an article about using > Perl for a car MP3 player. It got me wondering - What's the speed of > Python like compared to Perl? I've never used Perl before, so I hope > someone could answer my question here. Thanks -vm >From what I've seen and heard, if you must have an answer, it's probably that perl may have a slight edge. But realistically, the question is loaded, since python and perl don't often do things in the same way. -- David Allen http://opop.nols.com/ ---------------------------------------- People are like onions -- you cut them up, and they make you cry. From fredrik at pythonware.com Tue Jan 23 07:58:30 2001 From: fredrik at pythonware.com (fredrik at pythonware.com) Date: Tue, 23 Jan 2001 12:58:30 GMT Subject: urllib.urlretrieve("http://free.bsdshell.net/") References: Message-ID: <94jv5j$m4c$1@nnrp1.deja.com> Oleg Broytmann wrote: > Strange problem with urllib: urlretrieve("http://free.bsdshell.net/") > always reports "Connection refused". It seems to work from here, with both 1.5.2 and 2.0: >>> import urllib >>> urllib.urlretrieve("http://free.bsdshell.net") ('/usr/tmp/@30661.1', ) >>> urllib.urlretrieve("http://free.bsdshell.net/") ('/usr/tmp/@30661.2', ) etc. Cheers /F Sent via Deja.com http://www.deja.com/ From moshez at zadka.site.co.il Thu Jan 25 13:23:07 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Thu, 25 Jan 2001 20:23:07 +0200 (IST) Subject: what GUI, please advise In-Reply-To: <3A6F18F2.536F27FE@crepido.com> References: <3A6F18F2.536F27FE@crepido.com>, <3A6F0B27.A88D11C9@crepido.com> <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7@lp.airnews.net> Message-ID: <20010125182307.4A47BA840@darjeeling.zadka.site.co.il> On Wed, 24 Jan 2001, Marco =?iso-8859-1?Q?Seiri=F6?= wrote: > Well, something like this... > > - I'm going to run mostly on Unix, although it would be nice > to be able to recycle my GUI knowledge when forced to > write for Windows. Mac, not very important... > > - A GUI builder is a very big advantage. allmost a must. > > - I like there to be all the widgets one would expect from > the Windows world. > > - Easy of use for the programmer. Check out wxPython and Tkinter. I think Boa-Constructor is a gui builder for wxWindows, but you might have more trouble building it on exotic platforms. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From dsh8290 at rit.edu Sun Jan 7 10:57:07 2001 From: dsh8290 at rit.edu (D-Man) Date: Sun, 7 Jan 2001 10:57:07 -0500 Subject: Thank you (was Re: Should I learn Python or Java?) In-Reply-To: ; from charlottwilliams@mediaone.net on Sun, Jan 07, 2001 at 07:39:18AM +0000 References: Message-ID: <20010107105707.A30569@rit.edu> Looks like I'm a bit late with this thread, but I'll add my $0.02 anyways. I am currently employed to do Java development. (I'm a co-op, still in college so if anyone knows of a company that does python development, let me know) I much prefer python to java. Java retains much of the compile-time headaches that C/C++ have (largely related to static type-checking). Also, Java does some weird things with respect to objects vs. built-in types and not having generics. One of the results is that you *can't* put an 'int' in a list/vector/etc. Python, being very dynamic, is really easy to do anything you want. It's syntax is also much cleaner and simpler. As for portability, Python is much more portable than Java is. It is also much older (and stabler, and faster, etc) than Java so I don't think it will displace Java soon (unless someone can convice a big name company to spend lots of money promoting it ;-)). Enjoy your python experience, -D On Sun, Jan 07, 2001 at 07:39:18AM +0000, Charlotte Williams wrote: | Thank you, everyone, for all your help. If indeed Python is everything you | say it is, it would seem a worth while investment in time to learn. I'll | try coding some in Python and see how the language "feels." | | David Williams | | | -- | http://www.python.org/mailman/listinfo/python-list From claird at starbase.neosoft.com Fri Jan 5 10:53:01 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 5 Jan 2001 09:53:01 -0600 Subject: Perl from Python (was: Migrating to perl?) References: <3Fa56.4580$of7.216286@news1.atl> Message-ID: <50E9DE7387AD7196.0DFB8167FB3213E6.37781A14F6A184F7@lp.airnews.net> In article , Skip Montanaro wrote: . . . >Probably not a solution for me. On the other hand, I believe the folks at >Digital Creations were working on a scheme to allow so-called external >methods written in Perl to be executed within their Zope web application >system. I've no idea what the status of that is. "The 'pyperl' distribution contains the general stuff for embedding perl in python." Last updated in November. See for details. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From paul at fxtech.com Sat Jan 27 14:16:22 2001 From: paul at fxtech.com (Paul Miller) Date: Sat, 27 Jan 2001 13:16:22 -0600 Subject: Embedded Python interpreter examples? Message-ID: <3A731E86.9FB8930D@fxtech.com> I'd like some examples of using an embedded Python interpreter to execute scripts as an extension mechanism for C/C++ apps. For example, I may have a list of C++ objects that have their behavior defined by Python scripts. Since each object may have some data that is part of the script, do I need to run an interpreter instance per object, so that global variables (for example) used by the script will be available from run to run? -- Paul Miller - stele at fxtech.com From amyk at foretec.com Thu Jan 11 14:20:05 2001 From: amyk at foretec.com (Amy Katherine) Date: Thu, 11 Jan 2001 14:20:05 -0500 Subject: ***Python 9 Conference New Updates and Developments*** Message-ID: <4.2.2.20010109115959.00ae5cf0@colossus.foretec.com> Greetings! Below are some important updates on Python 9 events and activities. Information on the refereed papers and posters is now available at http://www.python9.org/p9-refereedpapers1.html. Six refereed papers have been nominated for the Best Paper Award. Attendees will vote for the Best Paper, and the award will be presented at the closing plenary session on March 7. Information on the Python Applications Track is now available at http://www.python9.org/p9-applications1.html. ActiveState, the PythonLabs development team at Digital Creations, and Secret Labs AB (PythonWare) will all host sessions featuring their latest innovations based on Python. The track will also include a Lightning Talks session. Proposals for Lightning Talks are now being accepted! If you wish to participate in this session, please send a message to lightning-talks at python9.org. Information on the Zope Track is now available at http://www.python9.org/p9-zope1.html. Digital Creations' Zope, written in Python, is the leading Open Source application server. Attendees of this track will learn Zope basics and advanced usage and hear about new developments in the Zope world. ______________________________________ *****Reminders***** Early Bird Registration closes on February 2, 2001. To register, please go to http://www.python9.org/p9-reginfo.html. Sleeping rooms at the Hilton Long Beach are going fast! Please go to www.python9.org/p9-hotelinfo.html for information on reserving a sleeping room. Detailed information on all conference events and activities can be found at www.python9.org (updated frequently!). ______________________________________ Platinum Sponsor: ActiveState (www.ActiveState.com) Gold Sponsor: Digital Creations (www.digicool.com) Silver Sponsor: O'Reilly & Associates (www.oreilly.com) From doc at sympatico.ca Tue Jan 2 10:49:46 2001 From: doc at sympatico.ca (DOC) Date: Tue, 02 Jan 2001 15:49:46 GMT Subject: C extension help needed Message-ID: <3A51F8F6.8DA5AE23@sympatico.ca> I have been playing with the "simple example" from here: http://www.python.org/doc/2.0b1/ext/simpleExample.html When I compile the file with gcc I get a couple of error messages at link time: /usr/tmp/ccudMfF8.o(.text+0x14): undefined reference to 'PyArg_ParseTuple' /usr/tmp/ccudMfF8.o(.text+0x40): undefined reference to 'Py_BuildValue' I can trace these back via Python.h to modsupport.h where they are defined as external. Then I loose the trail. Are these in a file that should be explicitly linked in? As far as I know, my $PATH is ok but I have been having some problems getting header files in. I need to run gcc with -I /usr/include/python1.5 Thanks for any help. DOC From tmhazel at mediaone.net Sun Jan 14 20:14:15 2001 From: tmhazel at mediaone.net (Thomas Hazel) Date: Mon, 15 Jan 2001 01:14:15 GMT Subject: [ANNOUNCE] txObject ATK 1.3 for Python Message-ID: Python Folks, I have been a long user & lover of Python since late 1992. Over the years I have created a toolkit for developing platform-independent C++ software. I have also created some useful Python interfaces to these tools (Timers, IO notification & processing, Threads/Events/Lcoks (home grown & native), and TCP Server etc..). The end of this email has few Python test programs demonstrating some of the Python Modules and tweak your interest. Take a look at http://txobject.sourceforge.net See READMEs in tar balls to build txObject ATK 1.3 and the txPyObject ATK 1.3 Python Modules. Enjoy and Happy Python Programming Tom ############################################################################ ### ## ## Threads, Events, Locks ## ############################################################################ ### import txLock # locks are not used in this test, but feel free to use them import txEvent import txThread EXIT_FLAG = 0 EXIT_EVENT = txEvent.txEvent("EXIT") def func(*args): print 'args from func call : ', args while not EXIT_FLAG: print 'looping' txThread.yield(EXIT_EVENT, 1000) return print 'Starting thread test' txThread.start(func, ("abc", 123)) txThread.yield(10000) # wait ten seconds EXIT_FLAG = 1 txEvent.trigger(EXIT_EVENT) ############################################################################ ### ## ## Timers ## ############################################################################ ### import txTimer import txEvent import txThread import txExtendedTimer # this is not used here, but feel free to use it COUNT = 0 EXIT_EVENT = txEvent.txEvent("EXIT") def callback (*args): global COUNT print 'timer fired : ', args if COUNT < 10: COUNT = COUNT + 1 return txTimer.CONTINUE else: txEvent.trigger(EXIT_EVENT) return txTimer.STOP timer = txTimer.txTimer(callback, ("abc", 123), 1000) # one second timer txThread.yield(EXIT_EVENT) ############################################################################ ### ## ## IO notification ## ############################################################################ ### import sys import txSync import txEvent import txThread COUNT = 0 EXIT_EVENT = txEvent.txEvent("EXIT") def callback (*args): global COUNT read = raw_input("") # get data so to reset stdin fd state print 'io fired : ', args, read if COUNT < 10: COUNT = COUNT + 1 else: txEvent.trigger(EXIT_EVENT) return id = txSync.registerIO(callback,("abc", 123),sys.stdin.fileno(),txSync.IORead) print '\nEntire something in the console window and then press turn... repeat' txThread.yield(EXIT_EVENT) ############################################################################ ### ## ## TCP Server ## ############################################################################ ### import sys import signal import txEvent import txThread import txTCPServer if len(sys.argv) != 5: print 'usage : local_machine local_port remote_machine remote_port' sys.exit(1) local_machine = sys.argv[1] local_port = eval(sys.argv[2]) remote_machine = sys.argv[3] remote_port = eval(sys.argv[4]) EXIT_FLAG = 0 EXIT_EVENT = txEvent.txEvent("EXIT") TCP_SERVER = txTCPServer.txTCPServer((local_machine, local_port)) def shutdown(*args): global EXIT_FLAG global EXIT_EVENT print 'Control-C' EXIT_FLAG = 1 txEvent.trigger(EXIT_EVENT) return def recvFrom(*args): while not EXIT_FLAG: messages = txTCPServer.recvFrom(TCP_SERVER) # get as many as possible # num_of_mgs = 3 # block until 3 msgs have been received # messages = txTCPServer.recvFrom(TCP_SERVER, num_of_msgs) print 'Messages : ', messages return def contactEstablish(*args): global EXIT_FLAG global EXIT_EVENT remote_machine, remote_port = args[0] print 'PEER UP : ', remote_machine, remote_port for i in range(1, 100): # # also see TCP SERVER multicast & broadcast # txTCPServer.sendTo( \ TCP_SERVER, 'HELLO from ' + `local_port`, \ (remote_machine, remote_port)) txThread.yield(1000) EXIT_FLAG = 1 txEvent.trigger(EXIT_EVENT) return def contactLost(*args): global EXIT_FLAG global EXIT_EVENT remote_machine, remote_port = args[0] print 'PEER DOWN : ', remote_machine, remote_port return signal.signal(signal.SIGINT, shutdown) signal.signal(signal.SIGTERM, shutdown) txTCPServer.registerContactEstablished(TCP_SERVER, contactEstablish) txTCPServer.registerContactLost(TCP_SERVER, contactLost) txThread.start(recvFrom) # start func on a thread to receive messages txTCPServer.contact(TCP_SERVER, (remote_machine, remote_port)) while not EXIT_FLAG: # just a dummy loop for debugging. you can also just wait on an event txThread.yield(1000) From robin at jessikat.fsnet.co.uk Sat Jan 6 05:53:42 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 6 Jan 2001 10:53:42 +0000 Subject: Memory Leakage with Tuples and Lists References: <936h6e$d11$1@news.nuri.net> Message-ID: In article <936h6e$d11$1 at news.nuri.net>, June Kim writes >Tested under Python 1.5 and 2.0 on Win32: > >1. >Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel) >Type "copyright", "credits" or "license" for more informat >>>> for j in range(10): >... temp=range(800000) >... del temp > >2. >Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel) >Type "copyright", "credits" or "license" for more informat >>>> for j in range(10): >... temp='a'*8000000 >... del temp > >In the case of #2, there is no memory leakage at all. All the memory is >returned 100%. However, in #1, there is a severe memory leakage, a few mega >bytes. Do you guys experience this on *nices as well? > > I don't see the leak you describe; how did you check for it? Certainly the total memory used grows the first time I use the code; after all 800000 ints is 3.2M; if there a serious leak I would expect to see around 32M disappear each time I run the code. I certainly don't see that. -- Robin Becker From victor at prodigy.net Wed Jan 10 16:07:25 2001 From: victor at prodigy.net (Victor Muslin) Date: Wed, 10 Jan 2001 21:07:25 GMT Subject: default arguments newbie question Message-ID: <3a5cccca.77467843@localhost> This behavior of the default list argument seems to be somewhat counter-intuitive: >>> def f(l=[]): ... l.append(1) ... print 'id=%d %s' % (id(l), l) ... >>> f() id=8369232 [1] >>> f() id=8369232 [1, 1] >>> f() id=8369232 [1, 1, 1] >>> f([2]) id=8368384 [2, 1] >>> f() id=8369232 [1, 1, 1, 1] >>> If I want a function to print "[1]" every time it is called with no arguments, do I have to do something like: def f(l=None): if l == None: print [1] else: print l.append(1) What's the acceptable Python idiom for this? From matt at mondoinfo.com Tue Jan 23 21:20:26 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 24 Jan 2001 02:20:26 GMT Subject: news - nntp server References: <3a6daab8@news.xtml.co.uk> Message-ID: On Tue, 23 Jan 2001 16:00:18 -0000, Nick Trout wrote: >I'm trying to set up an NNTP/newsgroup server on an NT4 machine. > >What is the easiest way to do this please. Can Python help me?! Nick, The easiest way to do it depends a good deal on what you want to do. News is conceptually very simple, it's the volume that's the problem. As of just now, a full newsfeed is somewhere in the 10s of GB per day. Dealing with that requires big pipes, fancy machines, and software that runs very efficiently. I tend to doubt that Python can help you much with that. Some of the links from http://dmoz.org/Computers/Software/Internet/Servers/Usenet/ may point you at useful software. If you're interested in something less than a full feed (say, no binaries or no binaries and little of alt.*) the thing to do would be to talk to your service provider about how much data that is (and how fast it's growing!) and size your pipe and hardware accordingly. That being said, I've been working on a trivial news server in Python. Actually, it acts as a client, a server, and a cache since it's intended to allow a newsreader that wants to read news while online to read it while offline. It's not efficient at all since it's only intended to deal with the volume of news that one person reads. I plan to put a link to it at Parnassus http://www.vex.net/parnassus/ when it's done or at least useful but if you'd like a copy even before that, mail me and I'll be glad to send it along. Regards, Matt From bbhaydon at my-deja.com Sun Jan 14 22:28:20 2001 From: bbhaydon at my-deja.com (bbhaydon at my-deja.com) Date: Mon, 15 Jan 2001 03:28:20 GMT Subject: PHP vs Python References: Message-ID: <93tqof$gu8$1@nnrp1.deja.com> In article , "TC" wrote: > Hi > I did a quick search for deja python +php +review > not even 1 relevent hit ...so > any takers points of interest Try including Java in that :\ > > 0- how long is a peice of string ? ;) > > 1-which one is going to be around longer, why ?? > > 2-who has more users > > 3-who hits the wall in scaling up and or handing complexity > > 4-general performance > > 5-where would I be better off using PHP over Python > > 6-DB interfaces consistent > -seems python has a standad API PHP appears all over the map depending on > DB > > Sent via Deja.com http://www.deja.com/ From LCKJAM003 at mail.uct.ac.za Tue Jan 16 07:06:01 2001 From: LCKJAM003 at mail.uct.ac.za (James) Date: Tue, 16 Jan 2001 14:06:01 +0200 Subject: PIL: _imagingtk Message-ID: <3A643929.D29A1840@mail.uct.ac.za> hi don't know if i have just installed PIL badly or if i have to configure something... when i try and and run script that uses pil\ImageTk.py i get this error message: File "c:\python20\pil\ImageTk.py", line 123, in paste import _imagingtk ImportError: No module named _imagingtk >>> Am using the binary releases of Python2.0, PIL 1.1.1, Numeric 17, and win32all(build 135) on win Nt... Thanks James From syver at NOSPAMcyberwatcher.com Thu Jan 18 15:23:11 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Thu, 18 Jan 2001 21:23:11 +0100 Subject: parsing a file [newbie] References: <_fp96.178$eI2.100474@ruti.visi.com> Message-ID: <947jg4$55r$1@troll.powertech.no> "Grant Edwards" wrote I could have used a list comprehension instead of a > for loop. Ouch, I feel really stupid to have to ask this question, but what the ... is a list comprehension, and why is it better to use it than a for statement? From dbrueck at edgix.com Fri Jan 19 13:56:35 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Fri, 19 Jan 2001 11:56:35 -0700 Subject: py2exe - convert python scripts into exe files (windows) In-Reply-To: <949sjv0bcj@news1.newsguy.com> Message-ID: > [mailto:python-list-admin at python.org]On Behalf Of Alex Martelli ... > Very interesting idea, but I must be doing something wrong. ... > However, when I try to run this EXE, it doesn't work > _quite_ right...: > > D:\PySym\salo\dist\hello>.\hello > KeyError: imputil.pyc > Traceback (most recent call last): > File "", line 22, in ? > NameError: There is no variable named 'imputil' > hello world I got the same thing. Don't know how to fix it, but as a hacky workaround you can include imputil.py in your list of scripts: ... scripts=['hello.py','imputil.py']) (I copied imputil.py to the same dir as setup.py too) -Dave From def-p at usa.net Fri Jan 26 07:51:41 2001 From: def-p at usa.net (Def P) Date: 26 Jan 2001 05:51:41 MST Subject: xor operator? Message-ID: <20010126125141.18593.qmail@nw128.netaddress.usa.net> Hi, I notice that there doesn't seem to be a boolean xor operator in Python. Does someone know the reasons behind this? Regards, Def P ____________________________________________________________________ Get free email and a permanent address at http://www.netaddress.com/?N=1 From jh at web.de Tue Jan 23 18:41:38 2001 From: jh at web.de (Jürgen Hermann) Date: Wed, 24 Jan 2001 00:41:38 +0100 Subject: Using python to call .bat files References: <94l44i$10km$1@news.adamastor.ac.za> Message-ID: <94l4pr$hej$03$1@news.t-online.com> "James Lockley" schrieb im Newsbeitrag news:94l44i$10km$1 at news.adamastor.ac.za... > list=os.popen(path).readlines() Try cmd = os.popen(path) list = cmd.readlines() result = cmd.close() # This is the return code of the program! Note that getting a return code implies the program is done. ;) From jurgen.defurne at philips.com Tue Jan 23 03:31:58 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Tue, 23 Jan 2001 09:31:58 +0100 Subject: I (don' ) will kill my Python Message-ID: <0056900015344629000002L092*@MHS> Let's pack in .DEB files and install apt-get and dpkg on Win PC's!! Jurgen From spenrose at well.com Sun Jan 7 15:52:20 2001 From: spenrose at well.com (Sam Penrose) Date: Sun, 07 Jan 2001 12:52:20 -0800 Subject: Identity and password management using Python on Linux Message-ID: We write web applications in Python, which we host on Linux boxes. We're growing fast, and need to automate some system administration tasks. We'd like to use Python for this, if possible, rather than shell scripting or Perl. We have two problems involving Linux' handling of identity to which the solutions using Python are not clear. 1) We need parts of our websites to be writable by both the client and non-Linux-savvy members of our own staff using rather clueless GUI FTP tools. We'd like to give them a CGI script they can call after saving a file that will reset its permissions to 664, with the correct owner (client) and group (client+us). Our CGIs run as nobody (called by Apache); typically we would switch to root in the shell to make those changes. How can we do this through CGI? 2) We'd like to give our main sys admin a front end for rotating passwords that will speed the following process: i. Log on to a server as root over SSH, preferably by demanding a password rather than using keys. ii. For each shell account on the server, prompt for the new password twice and change it. When the shell accounts are done, we'll do the MySQL accounts (easy) and the htaccess passwords, which I assume is easy. iii. Log on to the next server and repeat ii., until all the servers are done. (We currently have about 15 servers with 5-10 necessary accounts per; we anticipate doubling the # of machines over the next few months). I assume the front end for 2) will be a shell, but don't know how to pass commands to a local shell that will be snarfed up by Python and passed to a remote shell. Any help appreciated... From michael at stroeder.com Sat Jan 13 08:50:31 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sat, 13 Jan 2001 14:50:31 +0100 Subject: Python and Industry References: <20010111172342.10148.00000934@ng-ca1.aol.com> Message-ID: <3A605D27.9736ED01@stroeder.com> Crutoy wrote: > > does anyone know how widly in an instries does python being used ? I don't have any general information. I know one company which uses an embedded Python interpreter as a built-in scripting language for customizing of their own C++-written products. Ciao, Michael. From doug at postsmart.net Mon Jan 8 15:49:00 2001 From: doug at postsmart.net (Doug Ball) Date: Mon, 8 Jan 2001 14:49:00 -0600 Subject: Thank you (was Re: Should I learn Python or Java?) References: <3A593236.6331BE0C@engcorp.com> Message-ID: <00ea01c079b4$6dc9f4c0$8a00000a@darwin.net> Dear Peter and list: Peter you mentioned in a posting: "I don't think I know of any language without warts, and I think there's a theory (from Hofstadter? (sp?)) that says you can't have a theory that is both consistent and complete." I am a big fan of such things and was excited to see you mention it. However I think you may be referring to Godel's Theorem. If anyone is interested in this topic there is an excellent book entitled "Godel, Escher, Bach: an Eternal Golden Braid" by Douglas R. Hofstadter. In his book, Dr. Hofstadter restates Godel's theorem as: " All consistent axiomatic formulations of number theory include undecidable propositions." Thanks again for bringing it up! Doug From fredrik at effbot.org Sun Jan 28 18:41:40 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sun, 28 Jan 2001 23:41:40 GMT Subject: Anyone get python on win98?? References: Message-ID: "shaka" wrote: > It just doesn't work: it gives me an error message like: > > File "", line 1 > c:\programming\python20>python hello.py > ^ > SyntaxError: invalid syntax > > so what do I do??? use the *MS-DOS* command line, not the interactive Python prompt. in the start menu, look for something called "MS-DOS Windows" or "Command Window". click on it. in the window that appears, use the "cd" command to go to the directory where you installed Python. to run scriptname.py, type "python scriptname.py" if you have no idea of what I am talking about, you pro- bably need to spend some time with a Windows tutorial. here's one: http://sunset.swan.ac.uk/personal/mjb/teaching/envmod/em-book/node36.html Cheers /F From thomas at xs4all.net Fri Jan 5 05:04:59 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 5 Jan 2001 11:04:59 +0100 Subject: 2001 Enchancement Wishlist In-Reply-To: <006801c0769b$ac0cc3a0$9d8a1a97@martelli>; from aleaxit@yahoo.com on Thu, Jan 04, 2001 at 11:10:10PM +0100 References: <3A4CEACB.220998A0@javanet.com> <92j83r13gh@news1.newsguy.com> <20001231175940.A5435@xs4all.nl> <008301c07501$c036ae40$43931497@martelli> <20010104165116.F2467@xs4all.nl> <008601c07675$0adf2020$102b2bc1@cadlab.it> <20010104203232.P402@xs4all.nl> <006801c0769b$ac0cc3a0$9d8a1a97@martelli> Message-ID: <20010105110459.Q402@xs4all.nl> On Thu, Jan 04, 2001 at 11:10:10PM +0100, Alex Martelli wrote: > "Thomas Wouters" writes: > > > > A module object, in contrast, has no such flexibility. It can of > > > course have *attributes*, which, as they can be anything (in particular, > > > they can be class-instances), are as flexible as can be -- but it > > > cannot present any 'face' to client-code, except its own. > > > > Nor is it intended to. Nor should you ever *want* to. *That* is why I > don't > > Recapitulating: I said "it's a pity one can't do X". You answered "but > of course one can" (do X). Now, in contrast, you say that one's not > _intended_ to do X, and it's even a "forbidden desire" to harbor. This > is in total contradiction to your original rebuttal of my "you can't". Not at all. *You* can do X. So can I. So can every programmer. Using Python. But if you insist on only using a module namespace, for some odd reason. you can't. > > understand your problem with me saying that it's perfectly possible to use > > a module namespace to provide singletons. > > I never said one cannot use a module namespace to provide singletons. > > What I said was, and I quote, that a module "can't define special methods > to determine how it will print, how it will let usercode loop on its items, > etc"; > and you sharply contradicted my "can't" by asserting "of course it can". > It's easy to check who said what when, you know. Alex, I already said that that wasn't what I meant. If you use Python, you use Python, not one the single feature of module namespaces. Module namespaces can do jack shit. That doesn't mean Python can't. > > I don't give a gerbil's tush about semantics myself. > I.e., you don't care what words mean? I don't care what *you* think my words mean, no :) I've tried to explain what I meant, but if that isn't enough, I stop caring. I have years of experience with people who refuse to listen to what I *intend* to say, and instead focus on their interpretation of my words, despite the fact that I repeatedly stated that wasn't what I meant. That way I've been accused of being a rascist (even though I grew up in the black slums of Amsterdam where most of my schoolfriends were black), a gay-basher (even though I grew up knowing my father's gay and I have no problem with that) and a fascist (though I'm strongly left-wing, almost communist ;) -- and those were just the friendly ones. When you've experienced that for the umpteenth time (which happened some years ago) you turn into a cynical old coot and stop caring what other people think or say as long as they don't make your life harder :) > My "forbidden desire" (to get in a module-object some of the nice > flexibility I get with class instance objects) Aaah, now I see the problem. You realized that *module instances* are singletons (which I didn't think about, because I don't care about singletons, either :) and thus were talking about modules themselves, not the contents of their namespaces. What /F proposed, or at least how I interpreted his proposal, was to use module namespaces as namespaces to hold singletons, not use modules themselves as your singletons. And yes, I agree, you can't let the module define how it behaves. I simply thought you were talking about objects in a module's namespace, since needing modules to be definable is such a boggling concept, to me :-) > That a singleton (which is not a module object) may be bound to an > attribute in a module's namespace is certainly true (just as it may be > bound to an item in a tuple, or whatever), and not particularly > interesting. Part of the lack of flexibility of module objects means that > the module cannot stop that attribute from accidentally being re-bound to > something different, of course -- a class instance COULD do that regarding > its attributes by defining __setattr__ suitably, of course -- but maybe I > shouldn't even *discuss* my forbidden desires, as class instances are > *intended* to be able to protect attributes against accidental rebinding > while module objects aren't, and that's that...? Of course you can express your forbidden desires. Even the desire for __str__ and __[gs]etattr__, even though I think it's a pretty useless idea. (Modules are namespaces, and should stay namespaces. If you want an object to be 'configurable', you shouldn't use a namespace. Keep Python Simple ;) Regardless of singletons, there might be other good reasons to provide, for instance, 'frozen' modules, with a read-only namespace after initialization. Or rather, *easy* frozen modules, since I think you can already do it from C. But I still fail to see how using a factory function is an imperfect solution, other than for the sake of theory. Maybe Guido should Pronounce that Python is not a singleton language, just like it isn't a functional one, but it does provide ways of working around the missing parts. > But anyway, what irked me was not basically what you _meant_ (not > being particularly well-provided with ESP, I could hardly guess that by > saying 'of course you can' you meant 'you cannot and should not > even *want* to'), but, rather, what you _said_ -- which now appears > you agree is utterly false and unfounded, and not far from the reverse > of your intended meaning (and if you think that by saying the opposite > of what you mean you are "making clear" anything, you must have a > peculiar view of 'clarity'). No, not at all. I still stand by my original statement: you can do anything you want to an object in a module namespace. It's just that we were talking about something different -- module namespaces *contents* versus module namespaces themselves. I wonder which was the one /F intended ? :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From timd at macquarie.com.au Tue Jan 2 23:02:47 2001 From: timd at macquarie.com.au (Timothy Docker) Date: 03 Jan 2001 15:02:47 +1100 Subject: tkinter + threads Message-ID: I've trolled deja for a definitive answer, but couldn't see one. I have a Tkinter application which presently uses createfilehandler on unix. I need to move it to win32, where of course, this function doesn't exist. Ideally I'd like a non-polled solution, where a background thread can notify the mainloop thread of updates to be performed. Unfortunably the best I can com up with is shown below. This works both on win32 and unix, but I'm not happy with the tradeoff between response time and cpu load. Is there any means by which a background thread can notify the tkinter mainloop? This is possible in wxpython with the PostEvent method, which I have used in the past. Thanks, Tim ---------------------------------------------------------------------- from Tkinter import * import thread, sys, time class Slot: def __init__(self): self.val = None self.lock = thread.allocate_lock() def get(self): try: self.lock.acquire() v = self.val self.val = None return v finally: self.lock.release() def put(self, v): try: self.lock.acquire() self.val = v finally: self.lock.release() slot = Slot() def calcThread(): from random import random while 1: x = random() slot.put ( '%0.4f' % x ) time.sleep(0.333) def getQueue(): b = slot.get() if b != None: label.config(text=b) button.after( 100, getQueue ) button = Button(text="Exit",command=sys.exit) button.after( 100, getQueue ) button.pack() label = Label(text="________________") label.pack() thread.start_new_thread( calcThread, () ) button.mainloop() From root at rainerdeyke.com Sun Jan 28 19:19:12 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 29 Jan 2001 00:19:12 GMT Subject: Hack request: rational numbers References: <951h34$tch$1@nnrp1.deja.com>, <2W%c6.128157$ge4.46108705@news2.rdc2.tx.home.com> <3A749696.2BD57BA9@alcyone.com> Message-ID: <4G2d6.128417$ge4.46434631@news2.rdc2.tx.home.com> "Erik Max Francis" wrote in message news:3A749696.2BD57BA9 at alcyone.com... > Rainer Deyke wrote: > > > Why not add native quaternion support to Python? Quaternions are > > complex > > numbers where the imaginary part is a vector in three dimensions, > > defined in > > terms of unit vectors i, j, and k. > > Ah, but why? :-) Besides, the use of 1, i, j, k for quaternion units > is inconsistent with using 1, j (not 1, i) for complex units. It serves no real purpose except in some fairly specialized fields, but it is easy to implement, doesn't get in the way, and is "fun" - just like the current built-in support for complex numbers. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From johann at physics.berkeley.edu Wed Jan 24 12:21:47 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 24 Jan 2001 09:21:47 -0800 Subject: Python vs Ruby References: <94mdkd$222e$1@news.adamastor.ac.za> Message-ID: James Lockley writes: > Just been reading a "Ruby centric" comparison of Ruby vs Python on: > http://helium.ruby-lang.org/en/compar.html > would be interested to hear the Pythonista view.... I've played with Ruby a bit, but only played with it. It's a nice language, with a bunch of fun features, like iterators, which I thought were cool when I first ran into them in Sather. (Originally from Icon, or something like that? No matter.) I'm a bear of little brain, and I can fit most of Python into my head, but I had trouble getting all of Ruby in, because it had just that much more complexity. That's probably just practice, though. I'm not such a big fan of OO that I think everything has to be an object. Functions are nice, too. :-) -- Johann Hibschman johann at physics.berkeley.edu From embed at NO_SPAM_PLEASE.geocities.com Fri Jan 5 16:44:16 2001 From: embed at NO_SPAM_PLEASE.geocities.com (Warren Postma) Date: Fri, 5 Jan 2001 16:44:16 -0500 Subject: embedded python - cancel "while 1: pass" References: Message-ID: "Tim Peters" wrote: > It's getting at the same thing. Py_AddPendingCall does not have proper > mutual exclusion (the comment *says* "critical section" but the code doesn't > implement one!), That sounds easy to add to me! :-) .... As for the "portable thread-local-storage" problem, are there any other scripting languages out there that are highly multithreaded, that we could examine to see how they overcome these things? (Does a JVM have a means of signalling it's threads?) Warren From SBrunning at trisystems.co.uk Fri Jan 5 06:08:53 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 5 Jan 2001 11:08:53 -0000 Subject: 2001 Enchancement Wishlist Message-ID: <31575A892FF6D1118F5800600846864D5B169C@intrepid> > From: Fredrik Lundh [SMTP:fredrik at effbot.org] ...words can mean more than one thing... 'There's glory for you!' `I don't know what you mean by "glory,"' Alice said. Humpty Dumpty smiled contemptuously. `Of course you don't - till I tell you. I meant "there's a nice knock-down argument for you!"' `But "glory" doesn't mean "a nice knock-down argument,"' Alice objected. `When _I_ use a word,' Humpty Dumpty said in rather a scornful tone, `it means just what I choose it to mean -neither more nor less.' 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 thomas.heller at ion-tof.com Sat Jan 20 05:19:50 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Sat, 20 Jan 2001 11:19:50 +0100 Subject: py2exe - convert python scripts into exe files (windows) References: Message-ID: <94boo6$d11c9$1@ID-59885.news.dfncis.de> Several people reported a problem similar to: > > > > D:\PySym\salo\dist\hello>.\hello > > KeyError: imputil.pyc > > Traceback (most recent call last): > > File "", line 22, in ? > > NameError: There is no variable named 'imputil' > > hello world > I may have found the problem, but not yet a solution. I will fix this as soon as possible (but unfortunately not over the weekend, my children...) Thanks for all how tried this utility! Thomas From ljohnson at resgen.com Wed Jan 31 10:48:24 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Wed, 31 Jan 2001 09:48:24 -0600 Subject: Cannot find libModules.a lib*.a, etc... References: <9578l9$nj3$1@nnrp1.deja.com> <957dlb$sel$1@nnrp1.deja.com> Message-ID: > Is that to say that I don't even *need* libModules.a, etc, just link > with libpython2.0.a ? ? Yes, it's all in libpythonx.y.a these days. From grey at despair.rpglink.com Wed Jan 31 17:44:50 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Wed, 31 Jan 2001 22:44:50 -0000 Subject: Perl-to-Python converter/translator? References: <959jsd$njn$1@nnrp1.deja.com> <959uuh01qd3@drn.newsguy.com> Message-ID: On 31 Jan 2001 13:09:37 -0800, Grant Griffin wrote: >But in any case, if you are experienced in Perl, you will find Python >extremely easy to pick up. And after going through Guido's tutorial, I can >think of no better way to learn it than to manually translate some of your >old Perl scripts into Python. Agreed. I convered a "dice server" of mine as a way to learn Python and in several hours of real-time coding spread over two weeks I had the Python script not only up to about 90% of the functionality of the Perl script but also had improved upon some portions and felt that I did a much cleaner job in Python. The remaining 10% that the Python script doesn't do is because there are libraries in Python to do it that I've not yet played with and don't want to do it the half-assed way I did in Perl. Another hour or two should have it completed. I'm also sure that the Python script could be improved upon greatly. Point being, though, that it was trivial to do the conversion. Oh, the only reference I used was the Beazley book. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From chris at voodooland.net Thu Jan 11 14:19:13 2001 From: chris at voodooland.net (Chris Watson) Date: Thu, 11 Jan 2001 13:19:13 -0600 (CST) Subject: BSDDB problem In-Reply-To: <3A5DE0C6.44E770B8@ex.ac.uk> Message-ID: > Hi, > > I am using Python 2.0 on a Linux machine. I wanted to use the bsddb > module to get the information out the Netscape History.dat file. I tried > the following: > > import bsddb > hist = bsddb.hashopen('history.dat', 'r') I'm not that great at python yet but dont you need 'rb' since its a binary file? and not just r? I don't think that helps, its just an observation. -- ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From matt at virtualspectator.com Sat Jan 20 06:09:47 2001 From: matt at virtualspectator.com (matt) Date: Sun, 21 Jan 2001 00:09:47 +1300 Subject: Unicode, COM, Word Problem In-Reply-To: <94bkik$1hs$1@news8.svr.pol.co.uk> References: <94bkik$1hs$1@news8.svr.pol.co.uk> Message-ID: <0101210024320K.00856@localhost.localdomain> Not that I have tried doing anything like what you are doing, but I do see something potentially nasty. I assume that your copy clipboard is receiving the characters in Microsofts pseudo interpretation of ISO-8859-1. For a start ISO-8859-1 is a full 256 character set, so even if Microsofts version of ISO-8859-1 was correct, then you would get many characters outside the standard 128 characters of ascii. The thing to watch with Microsoft is that they start to use a range of characters usually designed for control characters to actually hold some punctuation etc ... these are in the range of 0x7F to 0x9F hex, for example they use 0x80 for &euro, whereas it is not defined in ISO-8859-1. My guess is that you need to 1) not parse your text as ascii, 2) parse it instead as ISO-8859-1, but 3) take account of their use of the undefined set using a translation table to get them back into valid ISO-8859-1. But that's all just a guess. I am a 'nix person who has to deal with people copying and pasting from "word" into form submissions in a browser ... so I have been stung by something similar. Matt On Sat, 20 Jan 2001, Kirby James wrote: > Hi, I'm writing a script to read and summarize a large number of MS Word-97 > documents, using the Python win32com.client. I open each file in turn (using > COM and Word) and select and copy the first 500 characters. > myWord.Selection.HomeKey(constants.wdStory) > myWord.Selection.MoveEnd(constants.wdCharacter, 500) > sText = myWord.Selection.Text > However when I try to print sText (or write it to a file > output.write(sText)) I get an exception > UnicodeError: ASCII encoding error: ordinal not in range(128) > I've tried using str > sText2 = str(sText) > but still get the same error. I've tried wrapping the code with a try: > except UnicodeError: block but then the string is not converted. I'd > appreciate any pointers as to how I can 'clean-up' this string so that I can > output it as an 8-bit character string. > Tks Kirby > > > -- > http://mail.python.org/mailman/listinfo/python-list -- From dan.rolander at marriott.com Sun Jan 21 09:55:06 2001 From: dan.rolander at marriott.com (Dan Rolander) Date: Sun, 21 Jan 2001 09:55:06 -0500 Subject: wxPython -- Article on wxWindows Message-ID: <046701c083ba$24b596d0$11260340@yin> For those of you interested in wxPython, here is an interesting article about the closely related wxWindows. Dan ----- Original Message ----- From: "Robin Dunn" To: "wx-users" ; "wx-devel" ; "wxPython-users" Sent: Thursday, January 18, 2001 2:51 PM Subject: [wx-users] Article on wxWindows Hi All. I just found this: http://www.sunworld.com/unixinsideronline/swol-12-2000/swol-1218-wxwindows.h tml I don't remember seeing it announced anywhere so I thought I would let you know about it. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! _______________________________________________ wxWindows-users mailing list wxWindows-users at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/wxwindows-users From tbryan at python.net Wed Jan 24 07:18:22 2001 From: tbryan at python.net (Thomas A. Bryan) Date: Wed, 24 Jan 2001 07:18:22 -0500 Subject: Customizing CGI script via execfile Message-ID: <3A6EC80E.CED8B6B0@python.net> Short version: I had a program that was to be run from the command line to output HTML. End user customizations were permitted via a configuration file in each user's home directory and Python's execfile. I have made modifications so that the script can be called via CGI, but the execfile no longer seems safe in this context. Long version: I have a program that generates HTML. It was intended that the program would be installed centrally and that each user could customize the output easily. To accomplish this quickly, I simply had the program call execfile on an .rc file in each user's home directory. The script has a configuration dictionary and some of the functionality encapsulated in functions. Something like this: configuration = {'fullname': "Your Name", 'mailaddr': "id at some.host", 'body': ''} def generate_footer(configuration, message): fullname = configuration['fullname'] mailaddr = configuration['mailaddr'] # get a dictionary: localvar -> value local_strings = vars() return """
%(fullname)s
""" % local_strings Thus, in the user's .rc file, he can perform simple customization of the output by writing configuration['fullname'] = 'Tom Bryan' configuration['mailaddr'] = 'tbryan at python.net' configuration['BODY'] = '' Since I call execfile, Python programmers can redefine entire functions, such as generate_footer, if he'd like completely different behavior from portions of the program. Now that I'd like the program to be called as a CGI script, I'd like to remove the execfile call, but I'd love to continue to permit extensive customization. For example, the ConfigParser module would permit customization like I show above with strings in the configuration dictionary, but it wouldn't permit redefinition of entire functions. Ideally, I'd only permit customization of the functions and variables defined in the Python program, without permitting access to most modules (such as os and system). Otherwise, the script would be much easier to use as an attack to the system (for example, by pushing a file onto the system somewhere and calling the CGI script with an overridden configuration file location). Most of the function redefinition is simply so that the user can modify what text is output (for example, if his page uses CSS, he may want to modify the header). It is okay to deny him access to most Python modules. Is the rexec module what I should be using? I played with it for a little while, but I wasn't sure whether rexec could do what I want. I thought about doing something import, but I'm not sure wether that's sane either. Any suggestions? ---Tom From aleaxit at yahoo.com Thu Jan 18 11:53:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 17:53:11 +0100 Subject: Dynamic attributes References: Message-ID: <94774b0164i@news2.newsguy.com> "Miki Tebeka" wrote in message news:Pine.WNT.4.32.0101181556160.1644-100000 at haw2u1320... > Hello All, > > Is there an "official" way to do the following? If I get your meaning correctly, the 'official' hooks you have to implement in your DynAttribs mixin are __getattr__ and __setattr__ -- they can look into your dictionary to get the methods to call for get/set purposes. Take care about naming things with leading '__' (double underscores) if you don't know all of the implications -- use a single underscore to indicate 'private [by-convention]'. Alex From nas at arctrix.com Fri Jan 19 06:15:09 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Fri, 19 Jan 2001 03:15:09 -0800 Subject: Garbage collector - please Help !! In-Reply-To: ; from amk@mira.erols.com on Fri, Jan 19, 2001 at 03:21:31AM +0000 References: <9475ob$c6v$1@nnrp1.deja.com> <947vml$fd0$1@news.udel.edu> Message-ID: <20010119031509.C16214@glacier.fnational.com> On Fri, Jan 19, 2001 at 03:21:31AM +0000, A.M. Kuchling wrote: > As long as Python 2.0 wasn't compiled with GC disabled, > cyclical data structures should be collected (modulo a few > known bugs fixed in 2.1). Note that the GC in 2.0 is somewhat misnamed. It doesn't actually free any memory itself. It is more of a reference cycle detector and breaker. The reference counting mechanism still takesi care of the memory allocation issues. Neil From tim.one at home.com Mon Jan 8 02:55:44 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 8 Jan 2001 02:55:44 -0500 Subject: embedded python - cancel "while 1: pass" In-Reply-To: Message-ID: [Tim] > Py_AddPendingCall does not have proper mutual exclusion (the > comment *says* "critical section" but the code doesn't implement > one!), [Warren Postma] > That sounds easy to add to me! :-) Hard to say without giving it more thought than I can afford now. If you use a platform-specific exclusion method, sure. If you stick to Python's portable lock abstraction, though, it *could* be much harder. For example, if you reuse the global interpreter lock for this, it creates real problems for threads Python didn't create (they would have to bootstrap themselves into having all the crud Python requires before a thread *can* acquire the global lock). OTOH, if you create a new lock for this, there may be potential for deadlock (depending ...). If it interests you enough to figure it all out , you should take it up on the Thread-SIG. > As for the "portable thread-local-storage" problem, are there any > other scripting languages out there that are highly multithreaded, > that we could examine to see how they overcome these things? Not that I know of. But note that TLS is basically trivial from a tech viewpoint: every threaded platform has *some* reasonable way to spell it. The problem is that no two platforms spell it the same way, so it's another configuration (at Python build time) nightmare requiring lots of platform experts. And then there's HP-UX, where no two platform experts have ever agreed on how to do anything involving threads <0.5 wink>. > (Does a JVM have a means of signalling it's threads?) A whole different API with every release, trying to make up for that the previous release's API didn't work <0.7 wink>. Seriously, Java's thread .stop(), .resume(), and .suspend() methods were all deprecated, because they proved to be "inherently unsafe" in practice. This isn't real surprising: a thread is cheaper than an OS process largely because the runtime *doesn't* save enough info to clean up a thread safely, short of the death of the process it's running in. The current Java advice should sound familiar by now: Many uses of stop should be replaced by code that simply modifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. But Java does still support Thread.interrupt(), which can be used to "wake up" a thread waiting on a Thread.sleep(), Thread.join() or Object.wait(). With enough work, I expect Python could offer much the same. That's not what most people seem to want, though (they mostly seem to want to kill hung I/O operations in threads, and there's not much hope of that ever happening). if-you-can't-do-it-in-std-c-the-python-implementation-generally- isn't-going-to-be-able-to-either-ly y'rs - tim From duncan at rcp.co.uk Wed Jan 3 08:51:29 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Wed, 3 Jan 2001 13:51:29 +0000 (UTC) Subject: Nested structs and struct.pack References: <92v6g5$t87$1@nnrp1.deja.com> Message-ID: <901E82000duncanrcpcouk@194.238.50.13> ken_ar at my-deja.com wrote in <92v6g5$t87$1 at nnrp1.deja.com>: >I've probably misunderstood how the compiler lays >out nested structs. But is there any way to tell >the struct module that I have nested structs so >that the C compiler and Python produce the same >result ? > You can use pad bytes ('x' in the format string). So instead of a format of "lcc" you could use "lcxxxcxxx" if your machine is little endian, or "lxxxcxxxc" if it is big endian. Of course you will have to know exactly how the struct is laid out in memory and this will vary between machines, compilers, or even with different options given to the same compiler. From cfelling at iae.nl Mon Jan 22 17:39:30 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 22 Jan 2001 23:39:30 +0100 Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> Message-ID: <94icr2$6kv$1@animus.fel.iae.nl> Steve Williams wrote: ... > Catching exceptions thrown by imported classes is not easy, simple or clear, > IMHO. The solution requires a technique (adding the exception name to the > import statement) that is not common in Python documentation or examples. I'm not sure I fully understand you, but something like the following seems common in Python: Module somelib: class Error(Exception): pass def somefunc(): '''does something beware, could raise Error ''' raise Error Module MyProg: import somelib try: somelib.somefunc() except somelib.Error: 'do something about it' -- groetjes, carel From erno-news at erno.iki.fi Thu Jan 4 04:05:52 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 04 Jan 2001 11:05:52 +0200 Subject: Unexpected result for list operator "+=" References: <3A542778.E1BC06E3@bogusaddress.com> Message-ID: In article , "Greg Jorgensen" writes: A | Assignment of immutable objects (numbers, strings, tuples) | essentially makes a copy of the object. Assignment of mutable | objects (lists, dictionaries) creates a new reference to the | original object. actually (non-augmented) assignment is always just about references, even with immutable objects. -- erno From rjroy at takingcontrol.com Sun Jan 21 10:07:30 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Sun, 21 Jan 2001 15:07:30 GMT Subject: Determining if a superclass is being initialized from a derived class References: Message-ID: <3a6af643.253580890@news1.on.sympatico.ca> On Sat, 20 Jan 2001 16:14:06 -0800, Timothy Grant wrote: >Hi folk, > >I have a superclass that I'm using for a project. The superclass has a >debugging function that is called whenever the command line option --debug >is used. > >I have run into a situation where I need to subclass the superclass. I want >access to the debugging information, but not until after the subclass is >fully initialized. > >class superclass: > def __init__(self): > self.a = 1 > self.b = 2 > if self.debug: > self.dodebug() > def dodebug(): > print self.a > print self.b > > >class subclass(superclass): > def __init__(self): > superclass.__init__(self) > > self.a = 2 > self.b = 4 > > if self.debug: > self.dodebug() > >In the above, dodebug() is called twice. I would like to only call it the >second time. > >Enlightenment would be greatly appreciated. > Here is a really ugly way to do it... NOT recommended... class uglysubclass(superclass): def __init__(self): debug = self.debug self.debug = 0 superclass.__init__(self) self.a = 2 self.b = 4 self.debug = debug if self.debug: self.dodebug() I am sure there are a million variations on this theme as well.... If the only difference between the classes is the initialisation, then don't subclass at all. class superclass: def __init__(self, a=1, b=2): self.a = a self.b = b if self.debug: self.dodebug() and perhaps use a factory function in the module to simplify the user interface. def getStandard(): return superclass() def getSpecial(): return superclass(2,4) def getExtraSpecial(a, b): return superclass(a,b) The bonus of this is that if you later decide you need to subclass, you can do it without changing any client code (providing the interface remains consistent. Thus if you created a subclass specialsubclass you would simply rewrite getSpecial to return an instance of specialsubclass def getSpecial(): return specialsubclass(2,4) If you need to subclass, then my choice would be to move the variable initalisation into another method. The use of factory functions is equally valid in this scenario. class superclass: def __init__(self): self.initialise() if self.debug: self.dodebug() def initialise(self): self.a = 1 self.b = 2 def dodebug(): print self.a print self.b class subclass(superclass): def initialise(self): self.a = 2 self.b = 4 Bob From jafo-pythonlist at tummy.com Thu Jan 25 00:47:28 2001 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Wed, 24 Jan 2001 22:47:28 -0700 Subject: Python and postgreSQL ?? In-Reply-To: ; from erno-news@erno.iki.fi on Thu, Jan 25, 2001 at 03:31:59AM +0200 References: Message-ID: <20010124224728.B26314@tummy.com> On Thu, Jan 25, 2001 at 03:31:59AM +0200, Erno Kuusela wrote: >pygresql comes with a tutorial. it's in the "tutorial" directory. It's kind of odd though because it makes use of the "pgtools" weirdness. "Where does this "pgcnx" come from?" It also doesn't seem to do much in the way of handling results of queries. An example of the use of large objects would be cool. Seems to be underdocumented in the regular pgsql documentation as well though. Sean -- Examine what is said, not who speaks. (Arabian Proverb) Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From skip at mojam.com Sat Jan 6 15:44:45 2001 From: skip at mojam.com (Skip Montanaro) Date: Sat, 6 Jan 2001 14:44:45 -0600 (CST) Subject: How to store the contents of a file into a list? In-Reply-To: <3a576f75.41616667@news.skynet.be> References: <3a576f75.41616667@news.skynet.be> Message-ID: <14935.33725.27422.32928@beluga.mojam.com> Daniel> I've been trying to do the same when reading these records from Daniel> a file (The file contains 2 lines : Daniel> rec11,rec12,rec13 Daniel> rec21,rec22,rec23) Daniel> What needs to be done to obtain the same [nested] l1 as above? Try this: f = open("/tmp/recordfile") l1 = [] for line in f.readlines(): line = line.rstrip() # remove trailing line ending l1.append(line.split(",") The split at the commas maps the string "rec11,rec12,rec13" into the list ["rec11","rec12","rec13"]. That list gets appended to l1 which winds up as a list of lists of strings instead of a list of strings. Cheers, -- Skip Montanaro (skip at mojam.com) Support the Mojam.com Affiliates Program: http://www.mojam.com/affl/ (847)971-7098 From claird at starbase.neosoft.com Tue Jan 30 10:29:39 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Jan 2001 09:29:39 -0600 Subject: Threading woes References: Message-ID: In article , David Allen wrote: . . . >Now my question. I'm trying to implement a STOP button. >When the user clicks it, the program should stop what >it's doing *IMMEDIATELY* and go idle. Currently . . . >threads or signal yourself, so I'm pretty much at >a dead end with the threading solution with regard >to the STOP functionality. > >So why not fork() processes, and then have them >communicate via sockets or something? For interruption, >I can just signal the download thread with SIGINT! >This would work, but fork is UNIX only, and I need portability >to at least windows. Macs aren't that important >right now. I'm developing on linux by default. . . . >- It is interruptable at any moment. (i.e. if >networking is down, and I call gethostbyname or recv, the >user doesn't have to wait for gethostbyname to fail >miserably before actually stopping) . . . You're stuck. We're all stuck. There is no currently satisfying solution for this. MacOS supports co-operative concurrency. There are a lot of situations where you canNOT retrieve control from the OS, no matter what you do. Win* is feasible, barely. There's at least one extension, I believe, that uses native threads to give you what you're after. It's not part of the Python "core"; one of us needs to confirm that it works reliably. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From john at veidit.net Fri Jan 12 21:02:06 2001 From: john at veidit.net (John Angelmo) Date: Sat, 13 Jan 2001 02:02:06 GMT Subject: webbrowser, tk and htmlgen Message-ID: <3A5FB70B.CCB7C49B@veidit.net> Hello I have a small python scritps that fixes a login with my ISP. Well the script works but now I want to make it a bit more userfriendly. I'm planning to use the webbrowser module in a tk window. I have tried to find some good examples of webbrowser but I can't find any. Does anyone have any good place with nice examples? Thanks in advance John From webzinc at my-deja.com Tue Jan 23 20:18:34 2001 From: webzinc at my-deja.com (webzinc at my-deja.com) Date: Wed, 24 Jan 2001 01:18:34 GMT Subject: using IE5 HTML DOM parser in python ? References: <93kpp4$51p$1@reader1.imaginet.fr> <93lb1h0227f@news1.newsguy.com> Message-ID: <94lah4$v9c$1@nnrp1.deja.com> Not a Python girl myself, but you might be interested to know that WebZinc is an ActiveX DLL that can be used to manipulate Web pages and parse any HTML. Forms, tables, paragraphs, pictures, links and more - download an evaluation copy of www.webzinc.net Hope this may help in some way! ;) --- Jenny x In article <93lb1h0227f at news1.newsguy.com>, "Alex Martelli" wrote: > "Gilles Lenfant" wrote in message > news:93kpp4$51p$1 at reader1.imaginet.fr... > > Hi, > > > > Seems that it is not easy to parse ugly HTML (not "well formed" in XML > > wording) with the htmllib. > > I can do it easily with the IE5 included HTML DOM parser but it's in > > javascript and the script is to be included in the HTML. > > Did any of U succeed to use it from python and win32 extensions. > > Maybe I don't understand your problem correctly. The HTML DOM > that comes with IE5 is COM/Automation (accessible from JScript, > but definitely not just from there) -- easy to access from Python > (with 'makepy' support, ideally). And I don't understand "the script > is to be included in the HTML" together with your need to parse the > HTML itself -- if you need to parse scripts in arbitrary scripting > languages, that IS indeed difficult (and HTML DOM has no help for > that)... but why would you need that? > > Alex > > Sent via Deja.com http://www.deja.com/ From andrew at erlenstar.demon.co.uk Wed Jan 17 23:17:13 2001 From: andrew at erlenstar.demon.co.uk (Andrew Gierth) Date: 18 Jan 2001 04:17:13 +0000 Subject: How to close all files between fork and exec? References: <944o0k$pi0$1@nntp6.u.washington.edu> Message-ID: <87zogp7auu.fsf@erlenstar.demon.co.uk> >>>>> "Donn" == Donn Cave writes: Donn> Unfortunately it looks to me like no one has ever put Donn> getdtablesize() in Python. does it have sysconf(_SC_OPEN_MAX)? -- Andrew. comp.unix.programmer FAQ: see or From hamish_lawson at yahoo.co.uk Thu Jan 25 04:19:02 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Thu, 25 Jan 2001 09:19:02 GMT Subject: urllib.urlretrieve("http://free.bsdshell.net/") References: <94oiss$1hm2$1@news1.simtel.ru> Message-ID: <94or22$vhc$1@nnrp1.deja.com> > Try to run 'telnet yoursite', Note that you'll have to include the port number as an argument: telnet free.bsdshell.net 80 > then blindly type 'GET /index.html' You may have to include the HTTP version to get a proper response (you can also just use / to get the default page without having to guess whether it's actually called index.html): GET / HTTP/1.0 Hamish Lawson Sent via Deja.com http://www.deja.com/ From rwklee at home.com Sat Jan 27 16:55:33 2001 From: rwklee at home.com (Rick Lee) Date: Sat, 27 Jan 2001 21:55:33 GMT Subject: Tkinter vs wxPython: your opinions? References: Message-ID: <3A7343D4.301A2032@home.com> I probably misled quite a few readers with what I meant by "description of an object's attributes". I don't mean an object's geometry attributes. I mean the object of interest to the user, for example, a person's wallet, whose possible description could be: - compartments and pockets; within each, either bank notes, or cards; for bank notes, number of notes and denomination of each; for each card, thickness, weight, colour. I like the GUI toolkit to be able to take an description like this, and generate a nice looking window to display this structured information; as well as to allow the user to change data, including, in the above example, adding/deleting compartments, bank notes, cards. Christian Tanzer wrote: > rwklee at home.com wrote : > > > Thank you all for your thoughtful posts. On reflection, I would say my > > greatest need would be: > > > > - being able to build data entry screens on the fly from a description of > > an object's attributes > > > > I am still very naive about this; but I would have thought the need for > > this feature would crop up frequently. I wonder why it doesn't seem to be > > featured in the popular toolkits. Maybe it is extremely easy for anyone to > > build, in which case would someone care to post a working example. Thanks. > > Sorry, I can't easily post working code. > > But your problem is easy to solve if you use a good geometry manager, > like Tkinter's pack or grid (grid being my preferred solution). > > For Tkinter, it looks like: > > body = Frame (...) > entries = [] > for entry_desc in ?description of an object's attributes? : > label = Label (master = body, text = entry_desc.name, ...) > entry = Entry (master = body, ...) > label.grid (column = 0, row = len (entries), ...) > entry.grid (column = 1, row = len (entries), ...) > entries.append (entry) > body.grid_columnconfigure (0, weight = 1, minsize = ...) > body.grid_columnconfigure (1, weight = 5, minsize = ...) > boy.pack (...) > > Shouldn't be any harder for a different toolkit, as long as it > offers decent geometry management. > > -- > Christian Tanzer tanzer at swing.co.at > Glasauergasse 32 Tel: +43 1 876 62 36 > A-1130 Vienna, Austria Fax: +43 1 877 66 92 From sholden at holdenweb.com Thu Jan 4 08:01:41 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 4 Jan 2001 08:01:41 -0500 Subject: list operation '+= ' or assignment problem References: Message-ID: JoeSmith wrote in message news:fXV46.83554$A06.2935629 at news1.frmt1.sfba.home.com... > > I unexpectedly get l1 modified by doing "l += l2" (see example 1). I take > it is because l and l1 point to the same object. If I use the string type > instead of the list type, I don't get l2 modified. I guess that list > assignment is an assignment of the reference to the object and it does not > copy the object. Where as a string object gets copied (see example 2). > Correct. Lists are mutable, strings are not. > example 1: > >>> l1 = [0, 1] > >>> print l1 > [0, 1] > >>> l2 = [2, 3] > >>> l = l1 > >>> print l1 > [0, 1] > >>> print l > [0, 1] > >>> l += l2 The statement above modifies the object bound to l in-place, which means that any other variables bound to the same object see the change reflected in their values too. > >>> print l1 > [0, 1, 2, 3] As expected. > >>> print l > [0, 1, 2, 3] > >>> > > example 2: > >>> s1 = "1" > >>> s2 = "2" > >>> s = s1 > >>> s += s2 Since strings are not mutable, the object bound to s cannot be modified in-place, so a new string is created and bound to the name s. Other names' bindings remain unchanged. > >>> print s1 > 1 > >>> > As expected. There was a lot of discussion about the semantics of augmented assignment maybe three months ago. I argued that this behavior was counter-intuitive to beginners. It appeared that this was just a repetition of the arguments when the behavior was originally discussed, and that augmented assignment was always intended to allow in-place modification of mutable objects as an optimization. The BDFL has spoken! regards Steve From gtalvola at nameconnector.com Fri Jan 26 17:39:09 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Fri, 26 Jan 2001 17:39:09 -0500 Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> <94sq0d$f8l$1@nnrp1.deja.com> Message-ID: <3A71FC8D.D674CD84@NameConnector.com> cbarker at jps.net wrote: > The downside of the close link between the C++ and Python is that there > are a number of things that are not very Pythonesque. The most obvous > thing that comes to mind is event tables. I find myself writing three > lines of code for what could be done with one (asd far as I can tell) an > example (from the demo) > > ID_ABOUT_MENU = 200 > help_menu.Append(ID_ABOUT_MENU, > "&About", > "More information About this program") > EVT_MENU(self, ID_ABOUT_MENU, self.OnAbout) > > When would I want a menu item , without an function attached to the > EVT_MENU ? IF i want tou use a name to label the itemI need another line > of code to do that. > > I'd like to see: > help_menu.Append(ID_ABOUT_MENU, > "&About", > "More information About this program", > callback = self.OnAbout) > > That would make a lot more sense, but frankly, it's really just a small > annoyance once you get used to it. Seems like it would be pretty easy to write a set of wrappers around wxPython to make it feel much more Pythonic. Your example is a good one where a simple wrapper class could make it much more natural to use. Ah, I see that you suggested the same thing later on in your message. Well, here's another voice saying that it would be a good thing... -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From richard_chamberlainREMOVE at ntlworld.com Wed Jan 17 02:13:15 2001 From: richard_chamberlainREMOVE at ntlworld.com (Richard Chamberlain) Date: Wed, 17 Jan 2001 07:13:15 -0000 Subject: how to run a DOS program without getting a box? References: <3A64E195.ECA51312@cableinet.co.uk> Message-ID: There is a file called pythonw.exe which is python without the command box. Richard Richard Dobson wrote in message news:3A64E195.ECA51312 at cableinet.co.uk... > Hi all, > > I have tried both os.system() and the exec~ calls, and they all cause > the Windows console to display when running a command-line program (in > my case, to play a soundfile I don't need to see the screen messages). > Is there a way to suppress this? Other languages, such as tcl/tk and GNU > Octave manage this fine. I'm using Python 2.0 under Windows2000 (sp1), > with IDLE. > > > Richard Dobson > > > > > -- > Test your DAW with my Soundcard Attrition Page! > http://www.bath.ac.uk/~masrwd (LU: 3rd July 2000) > CDP: http://www.bath.ac.uk/~masjpf/CDP/CDP.htm (LU: 23rd February 2000) From sdm7g at virginia.edu Thu Jan 18 15:31:20 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 18 Jan 2001 15:31:20 -0500 (EST) Subject: Slicing and offsets In-Reply-To: <945bvp$thj$1@nnrp1.deja.com> Message-ID: On Thu, 18 Jan 2001 gustabares at my-deja.com wrote: > I got a newbie question here... > > >>> S = "spam" > >>> S[0] > 's' > >>> S[1:] > 'pam' > >>> > > Why is it that when I slice S it's no longer the 0 offset anymore, but > now it is 1? > > >>> S[0:] > 'spam' > > Thanks for any help and sorry for the simple question:) > Not sure that I understand the question, but one of the docs suggests that you think of the indexes as separating the elements 0 1 2 3 4 |s|p|a|m| -4-3-2-1 ( Thus there's another opportunity for Tim to complain about no -0 ! ) Indexing gives you the element immediately after the index: "spam"[1] == "spam"[-3] == "p" "spam"[4] --> Index Error Slicing gives you the elements between the indexes: "spam"[1:3] == "spam"[-3:-1] == "pa" -- Steve Majewski From scarblac at pino.selwerd.nl Wed Jan 10 04:26:23 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 10 Jan 2001 09:26:23 GMT Subject: Grabbing a command's output was Re: dns reverse look up with python ? References: <93ecvp$v21$02$1@news.t-online.com> <93fe1k$mh4$0@216.39.151.169> Message-ID: Joel Ricker wrote in comp.lang.python: > When I saw this question posted last night, I started to answer it the same > way I did it in Perl. I needed to do a reverse lookup myself in a project I > was doing. I couldn't make heads or tails of the perl modules that can do > this so I finally figured out how to do this as a os command with nslookup. > Basically I was looking up the IP address reported by the web server to see > if its me or not and lock out everyone else for the time being. With perl > you do system commands like this: > > $Result = `nslookup 127.0.0.1` > > and $Result will contain the results of the command. But what I found in > the Python reference was os.system("command") which returned only a value > that reports if the command was successful or not. What is the Python way > of running command and have the actual results of the command returned? os.popen("command") returns a filelike object that you can read from. -- Remco Gerlich From hnowak at cuci.nl Sat Jan 27 17:20:22 2001 From: hnowak at cuci.nl (Hans & Mari) Date: Sat, 27 Jan 2001 23:20:22 +0100 Subject: [Off topic] allowed to put Python material on the Web? In-Reply-To: <3a730931.31998180@news.skynet.be> Message-ID: <200101272221.f0RML3t31740@hera.cuci.nl> On 27 Jan 01, at 17:51, Daniel wrote: > Dear newgroupreaders, > > As a Python newbie, I've been collecting lots of questions and answers > from this newsgroup. It contains stuff not readily found in the many > good FAQ from the net. > > Before setting up a new site, I would like to ask if it is allowed to > put my collection of questions and answers from this newsgroup (which > helped me a lot) on my site,so everyone can enjoy/learn from it > without going to the d?j? palace. > Thus, before starting the time-consuming task to create this new site, > I'd like to know if putting this collection on the Web is actually > legal/allowed. I had a similar site; because of lack of time, I stopped maintaining it. All my snippets went to the Python knowledge base/FAQTS (http://python.faqts.com). Before you go to the trouble of setting up a new site from scratch, it may be good to look at this FAQTS site. Maybe you would want to contribute to it rather than setting up and maintaining your own site, but that is just a suggestion. As for the legal stuff, I always assumed that I could freely dig into newsgroup messages for interesting code. This may or may not be right; nobody has complained about it, though, and I had quite a few authors in my collection. I did include the name of the original poster/author with each snippet, so it would be clear who held the copyright to the code. HTH, --Hans Nowak (zephyrfalcon at hvision.nl) You call me a masterless man. You are wrong. I am my own master. May Grandma Moses introduce Tipper Gore to your owl's nest! From fgeiger at datec.at Fri Jan 26 09:48:30 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Fri, 26 Jan 2001 15:48:30 +0100 Subject: Umlauts revisited: Now they prevent program from running References: <94rt05$tbe$1@newsreaderg1.core.theplanet.net> Message-ID: <94s2mm$1h$1@newsreaderg1.core.theplanet.net> Wow! Both of yours - Alex and Michael - did the trick! Thanks a lot! Is there another trick to switch globally to this encoding? Or do I have to check for '\xyz' characters and then encode them? For now I do a try. If an exception is catched I call the encode method. Is this the way doing it _always_ if umlauts could come across my way? That'd be cumbersome because the German language is teeming with umlauts (o.k., carried it too far ;-)) Best regards Franz "Franz GEIGER" wrote in message news:94rt05$tbe$1 at newsreaderg1.core.theplanet.net... > I pull data out of an Excel sheet using DAO. There are field values > containing text strings. Everything works fine until a text reads e.g. > "St?ck". > > After stopping before the exception > > "UnicodeError: ASCII encoding error: ordinal not in range(128)" > > occurs I display the field in the interactive window of PythonWin > (ActiveState 2.0 on NT4) by simply typing "fld.Value". > > It displays u'St\374ck'. > > Conversion into a Python string by applying print or str() yields: > > "Traceback (innermost last): > File "", line 1, in ? > UnicodeError: ASCII encoding error: ordinal not in range(128)" > > Any idea how to overcome this? > > Best regards > Franz GEIGER > > > From peter at engcorp.com Tue Jan 30 02:47:46 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 30 Jan 2001 02:47:46 -0500 Subject: How to extend sys.path on Win9x permanently? References: <3a75ef9c.11194652@news.muenster.de> Message-ID: <3A7671A2.30478E8C@engcorp.com> Martin Bless wrote: > > Python20, Win98, PythonWin > > (1) I'd like Python.exe/DOS AND Python in PythonWin to start > up with an extended sys.path, having my own lib added, as if a > sys.path.append('c:\\mylib') had already been performed. > How can I add the extra path permanently? Note certain, but it's likely that site.py is imported even under PythonWin. If that's true, and it should be easy to test, just create a file in your Python directory with an extension .PTH, and place within it the name of the directory you want added to sys.path. For example, in my directory n:\a\python, I have a file 'lib.pth' that contains the single line 'n:\lib\python'. Every time I run a script, it adds this to the end of my sys.path. Beats editing the registry, too. > (2) Here's what sys.path is on my machine. Where is this defined? > Registry? > *.ini? > Hard coded? Yes, registry. Grim but possibly the only place PythonWin can find it. Not sure. > (3) I'd hate having to put something like "set $PYTHONPATH=..." into > AUTOSTART.BAT, since DOS environment space is very limited. Doesn't your Windows support adding lines to config.sys, such as: shell=c:\command.com /p /e:4096 which would extend environment space to 4K? From aleaxit at yahoo.com Thu Jan 18 03:44:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 09:44:16 +0100 Subject: python compiled to native in less than a year? References: <8pF86.6015$J%.595435@news.flash.net> <0luc6toovfccbqspkvc0dkqkuc5dck7u51@4ax.com> Message-ID: <946coc130tl@news2.newsguy.com> "Tim Roberts" wrote in message news:0luc6toovfccbqspkvc0dkqkuc5dck7u51 at 4ax.com... > "scotth" wrote: > > > >Since Python will be one of the .NET languages, it will get compiled like > >all the other .NET languages. Whatever the problems, ActiveState/MS > >have/are going to over come it if my info is correct. > > Where did you get your information? Do you have a URL? The other repliers > are delighting in nitpicking and Microsoft bashing, but no one seems to > have questioned the basic premise. > > If I understand the .NET concept correctly, any COMPILED language will be > compiled to IL. However, I don't think there is anything to prevent a > language from being interpreted. That is, Python might survive in the .NET > framework as source text. There's nothing stopping some piece of .NET code from "interpreting" any piece of text whatsoever, but that wouldn't let that piece of text be a "first-class citizen" in the .NET framework -- it could not be used to implement classes other components inherit from, etc. Compiling the whatever-text-it-is down to IL is the 'royal road' of .NET integration, and the one ActiveState is taking with their Python.NET, whose beta you can download from their site. Of course, that IL can perfectly well be replete with calls to a 'runtime for my special funky language' assembly of components -- that's a component-internal implementation decision with .NET does not interfere with -- but what happens at a component's interface *is* constrained by .NET interoperability rules. The 'basic premise' that 'compiled down to IL' necessarily means anything much from the point of view of performance IS worth questioning. A piece of IL that's little more than a sequence of calls to a runtime assembly (an indirect-threaded interpreter...) will probably have performance not substantially different from other styles of bytecode-for-interpretation, after all. It seems to me that Python .NET isn't really taking this easy way out (just as Jython doesn't), but aiming at a compromise between feasibility AND some potential performance improvement; but I have not looked deep enough into it to be certain. Alex From kirby at jamesk.freeserve.co.uk Sat Jan 20 03:54:28 2001 From: kirby at jamesk.freeserve.co.uk (Kirby James) Date: Sat, 20 Jan 2001 08:54:28 -0000 Subject: Unicode, COM, Word Problem Message-ID: <94bkik$1hs$1@news8.svr.pol.co.uk> Hi, I'm writing a script to read and summarize a large number of MS Word-97 documents, using the Python win32com.client. I open each file in turn (using COM and Word) and select and copy the first 500 characters. myWord.Selection.HomeKey(constants.wdStory) myWord.Selection.MoveEnd(constants.wdCharacter, 500) sText = myWord.Selection.Text However when I try to print sText (or write it to a file output.write(sText)) I get an exception UnicodeError: ASCII encoding error: ordinal not in range(128) I've tried using str sText2 = str(sText) but still get the same error. I've tried wrapping the code with a try: except UnicodeError: block but then the string is not converted. I'd appreciate any pointers as to how I can 'clean-up' this string so that I can output it as an 8-bit character string. Tks Kirby From edcjones at erols.com Fri Jan 12 10:51:19 2001 From: edcjones at erols.com (Edward C. Jones) Date: Fri, 12 Jan 2001 10:51:19 -0500 Subject: A small suggestion for Python Message-ID: <3A5F27F7.30268D9A@erols.com> I have been programming in Python for several years. I still occasionally make mistakes with functions (such as sort) that return only "None". I suggest that functions like sort should return either "Nothing" or nothing. "Nothing" would be exactly like "None" except it can't be assigned. Whether "Nothing" or nothing is used, the statement "x= y.sort()" would raise a run-time Exception. Thanks, Ed Jones From dubal at my-deja.com Thu Jan 18 10:47:37 2001 From: dubal at my-deja.com (dubal at my-deja.com) Date: Thu, 18 Jan 2001 15:47:37 GMT Subject: curses, python20/152, RH70/62, postgresql problems Message-ID: <94736k$9n7$1@nnrp1.deja.com> Hello! We are trying to develop a business application for dumb terminals using python, curses and postgresql. First we tried to install the Beopen Py20 rpm on RedHat 7.0. It looks for some old libs and doesn't install. We then tried to compile Py20 source on RH7. It gives some LONG_BIT error and stops. We then renamed /usr/bin/gcc to gcc.nogo and renamed kgcc to gcc and tried to compile py20. Got same error. Has anyone found out a way to get py20 to work on rh7? We then read curses howto from python website and started developing using the RH7's stock python152. We found following problems: 1. Color cannot be used because the required vars are not available. 2. pads cannot be used as mentioned in howto. 3. getstr(x,y,len) does not allow the 3rd argument (length) Can anyone please suggest any solutions to these? We then abandon rh7 and go to rh62 with beopen py20 rpm installed. getstr works fine. Color vars are available but we could not get the color to work. Latest (7.0.3) postgresql rpms are also installed on this machine. This includes postgresql-python rpm supplied by postgres site. When we try to connect to postgres from python, it produces following warning: Python C API version mismatch for module _pg: This python has API version 1009, modules _pg has version 1007 How to fix this? It seems to work after this warning. We checked the pygresql site. It says their next version will have py20 compatibility. Do you think it is ok to use _pg with the version mismatch? I read somewhare that curses do not have colors, ncurses do. I see that ncurses is preinstalled on rh. Does python have its own builtin curses or does it use the one from separately installed rpm? How to get the color to work? Thanks for reading and TIA for any replies. Dubal Sent via Deja.com http://www.deja.com/ From erwin at andreasen.com Thu Jan 25 14:57:26 2001 From: erwin at andreasen.com (Erwin S. Andreasen) Date: 25 Jan 2001 19:57:26 GMT Subject: "print" strange with Sybase module References: <3A70163A.10D995@schlund.de> Message-ID: <94q0f6$lu5$1@news.cybercity.dk> On Thu, 25 Jan 2001 13:04:10 +0100, Carsten Gaebler wrote: >The following simple program (sqltest.py) returns about 20 lines of >Sybase output when run as "./sqltest.py". But if I say > >./sqltest.py | tee /tmp/test.txt > >there is no output and test.txt is empty. What's going wrong? It's >Sybase module 0.10 with Python 2.0. Does your Python interpreter exit before the very end with some fatal error? (do echo $? after you run the script without piping it to see the exit error code, is it 0?). You see, standard output which "print" prints to is line-buffered when connected to a terminal (i.e. the buffer is flushed after each line). When it is run through a pipe, it is block buffered (i.e. the buffer is flushed after 4096 bytes of output has been gathered). If the program exits unexpectedly (sys.exit(1) or an exception is OK, but os._exit(1) or a fatal signal isn't) these buffers will not be flushed. I can't see a reason to why it would exit that way quietly, but unflushed buffers are the first thing that comes to mind when seeing those symptoms. PS: Any Python-users attending Linux Expo in Paris? -- ======================================================================= Herlev, Denmark Software Designer <*> LASAT^WEicon Networks ======================================================================= From erno-news at erno.iki.fi Wed Jan 24 11:18:36 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 24 Jan 2001 18:18:36 +0200 Subject: urllib.urlretrieve("http://free.bsdshell.net/") References: Message-ID: In article , Oleg Broytmann writes: | On Tue, 23 Jan 2001, Toby Dickenson wrote: || Is your browser using a proxy that python doesnt know about? | I tried urllib on different computers in two different networks. | Probably the site does not like my User-Agent. Will try to find the reason. | Thanks. i think the user-agent theory cannot work, because client cannot have sent the user-agent string if the connect() call faills with "connetion refused" :) -- erno From ljohnson at resgen.com Wed Jan 10 10:12:26 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Wed, 10 Jan 2001 09:12:26 -0600 Subject: Should I join the PSA if it's "no longer relevant"? References: <93g3lj0e7c@news2.newsguy.com> Message-ID: > Or OpenAve.Net (http://www.openave.net/) -- I have no experience > with them yet, but (after a couple of months of reasonably plain > sailing) I've found the service at sourceforge over the last month or > so degrading near-unbearably, to the point that I'm seriously thinking > of moving elsewhere unless they get their act together again. Alex's point is well-taken. Note that I qualified my experiences with SF with "good, so far" ;) Things have indeed been a mess for the last month or so but there are some signs that they're getting their act together again. I've got a new project that may make its debut later this month but I'm biding my time to decide whether to host it at SourceForge. I appreciate the link to OpenAve.Net in the event that I need an alternate option! From steve at mercury.spvi.com Fri Jan 26 07:29:09 2001 From: steve at mercury.spvi.com (Steve Spicklemire) Date: Fri, 26 Jan 2001 07:29:09 -0500 (EST) Subject: proxy server In-Reply-To: <3A714C40.D3E0D684@aon.at> Message-ID: <200101261229.f0QCT9x11162@mercury.spvi.com> http://www.zope.org/Members/hathawsh/tcpwatch/tcpwatch-0.9.tar.gz/view -steve From bodo1969 at my-deja.com Wed Jan 17 07:03:58 2001 From: bodo1969 at my-deja.com (bodo1969 at my-deja.com) Date: Wed, 17 Jan 2001 12:03:58 GMT Subject: Electronic edition of 'The Standard Python Library' References: Message-ID: <9441nb$m7c$1@nnrp1.deja.com> Same problems as above with me. Additionally, I had several mail-contacts with the so-called customer-support. It's simply ridiculous! I bought an article from mightywords, my credit card has been charged (so they got their money) and I didn't get anything at all. That's virtual street-robbery. So the only thing one can do about this is spread the advice: NEVER BUY @ FATBRAIN & MIGHTYWORDS !!!! Bodo Sent via Deja.com http://www.deja.com/ From gerhard.nospam at bigfoot.de Fri Jan 12 09:42:00 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 12 Jan 2001 15:42:00 +0100 Subject: Calling Java Code from CPython (1.5.2 or 2.0) References: <93mdfs$g7q$1@nyheter.chalmers.se> Message-ID: If all you want to do is access databases from Python, there are Python modules to do that for all the major databases. Best look at the database topic guide at www.python.org. No need for JDBC here. If for any other reason you still need to connect Python and Java, I have to disappoint you: there is no easy way to do this that I know of. For difficult ways, there would be several: - CORBA - JNI (Java Native Interface): this requires that you write a C DLL that interfaces Java and you call into that DLL from Python code. Very awkward. - JPython: I guess that there is a relatively simple way to talk from CPython to JPython/Jython, there is Pyro which presumably works with JPython, and IIRC there is something like Python RPC. But a simple way I do not know :-( Gerhard On Fri, 12 Jan 2001 08:58:43 +0100, Dario Lopez-K?sten wrote: >Hello! > > > >I would like to know if it is possible to call Java Code from CPython (as in >not Jython or JPython). I am asking this, because i'd like to be able to >experiment using JDBC in conjunction with python; specifically, I want to >use Zope and JDBC drivers on Solaris/Linux and that "other" operating system >to connect to Oracle, MIMER and some other DBMSs we have. > >There is one JDBC database adapter for JPython, but I don't know if it is >possible to mix JPython/Jython with CPython. > > > >I have searched the archives but all references to Java and Python end up in >Jython/JPython. > >I might add that I am a new Python user and haven't really had time to do >anythin usefull so far; therefore, any help is appreciated. -- mail: gerhard bigfoot de web: http://highqualdev.com From aleaxit at yahoo.com Wed Jan 3 06:24:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 3 Jan 2001 12:24:33 +0100 Subject: HELP! win32com, COM, Invoke problem References: <92rv3q$asi$1@nnrp1.deja.com> <3A51EDBF.3000808@ActiveState.com> <92tmjr$oj1$1@nnrp1.deja.com> <3A5274F3.3070001@ActiveState.com> <92u2u4$2vi$1@nnrp1.deja.com> Message-ID: <92v27e02jia@news2.newsguy.com> "TB" wrote in message news:92u2u4$2vi$1 at nnrp1.deja.com... > > > > You may have trouble with an OCX. Python doesn't really support them. > > Pythonwin does to some degree - check out pywin\demos\ocx. > > Well, it sounds like a naive question but what does it take to have > python support OCX? the reason here is that if it doesn't provide a > drop-in replace VBScript/JScript, it's hard to have the management's > (sorry, you know that) buy-in on using it. Plus, it's nice to have this > feature anyway. Being a "proper and complete Active/X Control Container" is a daunting task indeed -- Active/X Controls (aka OCX's) can choose to implement, totally or partially, each of a zillion interfaces, and the 'host' (the 'control container') is supposed to adjust to each and every variation. The Microsoft System Journal, issue of 12/99, has a nice article on (some of) what it takes to do that for ATL -- have a look at (one line!): http://www.microsoft.com/msj/defaulttop.asp?page=/msj/1299/containment/conta inmenttop.htm if you read enough C++ to follow it -- you can also download the VBlite.zip sources for the "full-blown control container" that Dharma Shukla and Chris Sells develop in the article (but it doesn't really address *all* possible issues). VBScript and JScript don't even TRY to "be control containers" -- it would be silly for either of them to do so: in Microsoft's architecture, their role is well-defined as "Active/X Scripting Language" engines. Control containment is not the job of a language, but of the framework or application that embeds the language. The language's role is to let one *script* controls that are hosted on the "forms" (or however you want to call them) of the application -- receive events, set and get properties, call methods. The best reusable and redistributable control-container for most uses is (IMHO) Internet Explorer. If you need the controls to be visually part of some other existing window/form/dialog/whatever, it's far simpler to have the 'whatever' support just the bare minimum needed to host the IE subset you need, and ember the generic OCX's into the IE subset. IE's *very* well-behaved, far easier to host properly than most other OCX's you'll find around -- and also hosts Active Documents (another dauntint task to reimplement), Java applets, whatever. It's truly a fully general, reusable framework, rich, easy to use, well documented. If for some political reason you cannot require "a reasonably updated IE version" as a part of your applications' prereq's, your life is much harder (but would be absolutely NO easier if your preferred language was VBScript or JScript!!!). "VBLite" can be seen as an option in that case (I'm not sure about the legal status of it as a redistributable binary, though -- do check if you plan on that!). MFC dialogs, VB forms, MS Office products, and, I assume, some of their competitors' equivalents (Delphi, StarOffice, Mozilla, Opera, ...?), all may provide other suitable replacements depending on your deployment strategies. Pythonwin (somewhat based on MFC, if I recall correctly) and wxWindows may also fit in this array of choices. But, really, if you can standardize on the array of technologies that are "already deployed for you" by any recent IE release, your life WILL be a lot simpler. > I tried to read something about COM and etc, but the info I'm getting is > just overwhelmingly complex. could you shed some light on how does VB > use OCX? and why it's different from other things (that win32com that > currently support) ? VB Forms may be the second-best Active/X Control Containers Microsoft makes, right after Internet Explorer. In these cases, sources are not distributed, so finding out in detail how they work needs a lot of reverse engineering (in jurisdictions where reverse engineering is legal, of course; you just can't do it elsewhere). "VBLite" (and all of ATL that it rests on) and MFC _are_ distributed with sources, so in these cases finding out all of the excruciating details just takes a lot of patience and competence with C++, VStudio's debugger, etc. But anyway, summarizing: win32com does not implement 'forms' that one could use as (even a start of) proper "Active/X Control Containers"; it's just not its job to duplicate this kind of functionality. It is, in some part, done in Pythonwin (which IS a framework for general development of Windows GUI's), etc. > Any plan to support OCX in win32com in the future? I'd like to help but > I guess I have a lot to learn even before I can make sense of what > you've done. Any suggest reading to begin with? I'm more of a > unix/perl/java guy and do some VB but never went seriously into C++ on > Windows. As long as the functionality is there, easily accessible, why would one desire that it be duplicated among several disparate packages -- why should win32com implement the general-purpose GUI portions needed to properly host any and all Active/X controls? > Do you think it makes sense to manually write some wrappers to solve > this immediate problem? any idea how to do that (w/o going into C++ and > pyd) ? Instantiate whatever part you need of Internet Explorer -- that gives you all you could ever possibly need. If you need fine-grained control of user-interface's look-and-feel, you can host MSHTML in diverse ways; MSDN has a _lot_ of information on that, although it's generally expressed in terms of VB or C++ use. But for most programming tasks, http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp (the "HTML Applications" concept) are, for example, one great deployment possibility -- check out http://www.webreference.com/js/column39/, which gives a good, thorough tutorial introduction, albeit centered on using JScript as the specific scripting language (but by installing win32all, Python becomes usable in any active-scripting scenario where JScript might be considered). Alex From not.this at seebelow.org Thu Jan 18 22:50:09 2001 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 18 Jan 2001 21:50:09 -0600 Subject: brace nanny References: <93nsfk02gdu@drn.newsguy.com> <93pmic$45r$1@verence.demon.co.uk> Message-ID: <3A67B971.C5981ABF@seebelow.org> Paul Wright wrote: ... > Other people have already said that both Vim and GNU indent will > re-format C code to correct indentation, if that's a possible solution. > Vim will spot mismatched braces and turn them red, but AFIAK will not > spot inconsistent indentation. Thanks, Paul (and others). I already had both Vim and Indent in hand, but didn't think of them. Using Indent for this is a simple (but clever) idea that I just hadn't thought of which will serve the purpose, even though it isn't quite what I asked for. one-man's-paradigm-shift-is-another-man's-head-slap--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From scastell at sas.upenn.edu Mon Jan 15 17:22:23 2001 From: scastell at sas.upenn.edu (Steven M. Castellotti) Date: Mon, 15 Jan 2001 17:22:23 -0500 Subject: Interacting with a spawned ssh session? Message-ID: <3A63781F.D8CDB6DC@sas.upenn.edu> I'm having two problems with one function. I want to be able to spawn an ssh session to another computer, and then interact with that session through python commands. (this is on a linux system) The first problem is feeding the password to ssh; I believe that it wants it's own tty. The second problem, and currently the more pressing one, is how to best send commands to that ssh session, and read back/parse the results. I've looked at the pty module, but must not be understanding its functionality, as I can't get a pty.fork()'d file descriptor to allow me to perform commands. I'd like to keep away from popen (for security reasons, though I'm not certain any other method could be considered secure either), but am still having trouble interacting with the spawned process (in this case a telnet session; for simplicity). Can anyone provide me with, or point me to, any examples of how to use python to do roughly what I'm describing? Thanks in advance. -- Steve Castellotti Systems Programmer School of Arts and Sciences, University of Pennsylvania From fredrik at effbot.org Tue Jan 9 04:49:28 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 09 Jan 2001 09:49:28 GMT Subject: escape sequences and string comparisons References: <93cboe$ctj$1@nnrp1.deja.com> <93el06$aab$1@nnrp1.deja.com> Message-ID: jkndeja at my-deja.com wrote: > whereas I'd want this character to be escaped "\]" in order to be used > within an RE. in a previous post, you wanted the character to be escaped so you could "compare strings with potentially non-alphanumeric characters" since that doesn't really make sense (Python can compare non- alphanumeric characters all by itself), maybe you should explain what you're really trying to do here... > Python doesn't seem to follow this. I will investigate further... it's all in the fine manual: http://www.python.org/doc/current/ref/strings.html "2.4.1 String literals" "Unlike Standard C, all unrecognized escape sequences are left in the string unchanged, i.e., the backslash is left in the string" (note that string literals are the things you write in your Python source code. They're converted to string values according to the rules in section 2.4.1. The strings you pass to "re" are string values, and are converted to regular expressions according to the rules in the library reference) Cheers /F From donn at u.washington.edu Wed Jan 10 20:29:13 2001 From: donn at u.washington.edu (Donn Cave) Date: 11 Jan 2001 01:29:13 GMT Subject: How to check on process time? References: <93ie2i$bse$1@nnrp1.deja.com> <93iip0$jhu$1@nntp6.u.washington.edu> <93isdq$fhr$1@mail.pl.unisys.com> Message-ID: <93j299$s8a$1@nntp6.u.washington.edu> Quoth : | long time ago i used sun's call 'getresourceusage' to obtain process times | on bsd - some other unixes had similar calls or not You might be thinking of something like this: import resources resource.getrlimit(resource.RUSAGE_SELF) Which is reasonably portable, but doesn't meet the requirement because it can get usage for only the current process, or its children. Donn Cave, donn at u.washington.edu From tim.one at home.com Mon Jan 15 16:39:00 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 15 Jan 2001 16:39:00 -0500 Subject: Beginner's question - class definition In-Reply-To: <3a6366a8.4537644@news.ruralnet.net.au> Message-ID: > Can anyone explain please why the following definition ( from the > Python documentation) > > class Complex: > def _init_(self, realpart, imagpart): > self.r = realpart > self.i = imagpart > > ... [doesn't work] ... A class constructor's name is "__init__", not "_init_". That is, you're missing an underscore on each side. Try this: >>> class Complex: def __init__(self, realpart, imagpart): self.r = realpart self.i = imagpart >>> Complex(1,2) <__main__.Complex instance at 00B3970C> >>> easy-mistake-to-make-once-but-hard-to-make-twice-ly y'rs - tim From emile at fenx.com Sat Jan 27 13:55:24 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 27 Jan 2001 10:55:24 -0800 Subject: Avoiding the __repr__ call or protecting an instance from evaluation URG. please References: Message-ID: <94v5ld$f2kci$1@ID-11957.news.dfncis.de> You're probably passing the instance in a manner that repr is invoked. Can you post a sample showing the problem? Normal passing would be something like: class test: def __repr__(self): return "class repr" def func(a): print type(a), a t = test() func(t) HTH -- Emile van Sebille emile at fenx.com ------------------- "Fernando Rodr?guez" wrote in message news:db367t8ed4ktadbdmf71lgk1t8h3p3i4lk at 4ax.com... > Hi! > > I have a class whose __repr__ method returns a string. Whenever I pass > an instance of this class to a function, what the function gets is the result > of __repr__. Most of the time this is OK, but under certain circumstances I > also need to make sure that a function receives an instance of the class, and > the the string that __repr__ returns. > > How can I do this? O:-) > > PS This is my __repr__ method: > def __repr__( self ): > return ",v" + str(self.tag) +", " > > > > > //----------------------------------------------- > // Fernando Rodriguez Romero > // > // frr at mindless dot com > //------------------------------------------------ From aleaxit at yahoo.com Sat Jan 20 06:58:31 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 20 Jan 2001 12:58:31 +0100 Subject: How to chop list n-elements at a time References: <94bjs8$5nn$1@nnrp1.deja.com> Message-ID: <94bum50k4u@news2.newsguy.com> wrote in message news:94bjs8$5nn$1 at nnrp1.deja.com... [snip] > am wondering how to make the tool more general so that i could say: > > x=[1,2,3,4,5,6,7,8,9] > > bunch(x,1) --> [[1], [2], [3], [4], [5], [6], [7], [8], [9]] > bunch(x, 2) --> [[1,2], [3,4], [5,6], [7,8], [9, None] > bunch(x, 3) --> [[1,2,3], [4,5,6], [7,8,9]] > bunch(x, 4) --> [1,2,3,4], [5,6,7,8] [9, None, None, None]] def bunch(list, N): templist = list + [None]*N result = [] for i in range(0, len(list),N): result.append(templist[i:i+N]) return result or, more concisely: def bunch(list, N): templist = list + [None]*N return [templist[i:i+N] for i in range(0, len(list), N)] The 'templist' is only needed because you want the last sublist padded with copies of None to the specified length N, rather than possibly shorter than N. You could alternatively just perform such padding at the end, e.g. in the second form: def bunch(list, N): result = [list[i:i+N] for i in range(0, len(list), N)] result[-1] = (result[-1]+[None]*N)[:N] return result but it seems to me that the templist approach is a little bit simpler/clearer (although it will potentially use a bit more memory in some cases). Alex From aahz at panix.com Fri Jan 5 19:35:07 2001 From: aahz at panix.com (Aahz Maruch) Date: 5 Jan 2001 16:35:07 -0800 Subject: string formatting question References: <3a5660f8.626036031@localhost> Message-ID: <935p7r$1i1$1@panix6.panix.com> In article <3a5660f8.626036031 at localhost>, Victor Muslin wrote: >An integer can be formatted as follows: > > >>> '%d' % 123 > >How is an infinite precision long integer formatted into a string? If >The above code: > > >>> '%d' % 123123123123123123L > >produces an OverflowError exception. Surely there is something simple >I am overlooking in the manual, but none of the other format >specifiers described seemed to be appropriate. The simplest approach is to use %s. I've never tried any of the other format specifiers for long ints. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "This is Usenet. We're all masturbating in public places." -DH From joejava at dragonat.net Sun Jan 7 22:12:51 2001 From: joejava at dragonat.net (Joel Ricker) Date: Sun, 7 Jan 2001 22:12:51 -0500 Subject: Basic module question: References: Message-ID: Stanton Schell wrote in message ... >I am learning Python and I am trying to find out all the functions I have >available to me within sys.stdin (eg read(), readlines(), etc...). I >realize this brings up a more fundamental question for me: how do I find out >what is available in any module (which I guess would then apply to other >objects written by other people...)? > >any help or resource guidance would greatly appreciated :-) Other than the module's documentation, the other thing you could do is use dir() like this: >>> import time >>> dir(time) ['__doc__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', 'ctime', 'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'time', 'timez one', 'tzname'] >>> dir() will also give you a list of functions and variables defined in the current namespace. dir() won't give you a list of builtin functions though. To get those, use the __builtin__ module: >>> import __builtin__ >>> dir(__builtin__) [*snip -- Long list of builtin functions/variables*] Hope that helps Joel "Just started learning python himself" Ricker I have been Perl-Free for 3 Days, 0 Hours, 23 Minutes, and 14 Seconds. ------------------------------------------------------------ Joel Ricker joejava at dragoncat.net Just Another Python Hacker From noahspurrier at my-deja.com Sun Jan 14 17:01:54 2001 From: noahspurrier at my-deja.com (noahspurrier at my-deja.com) Date: Sun, 14 Jan 2001 22:01:54 GMT Subject: How to check on process time? References: <93ie2i$bse$1@nnrp1.deja.com> <93iip0$jhu$1@nntp6.u.washington.edu> Message-ID: <93t7kf$1nv$1@nnrp1.deja.com> This is neat, but as you say it's not very portable! I tested this with some modifications on Solaris 2.6 and OpenBSD 2.7. Solaris has a /proc filesystem and the file names are about the same, but the 'status' file is binary. I couldn't even find a /proc directory under OpenBSD. I searched around a bit, but I couldn't figure out where they stuck it. I don't have easy access to any other UNIX flavors to test this out on. Jeeze... I can't believe there isn't any POSIX stuff for process status. Not even in POSIX.4? Yours, Noah In article <93iip0$jhu$1 at nntp6.u.washington.edu>, Donn Cave wrote: > Quoth noahspurrier at my-deja.com: > | Which Python library do I want to get extensive process information? > As far as I know, that isn't supported on contemporary computer > platforms, at least in any meaningfully portable way, and that > would be why you don't see anything for it in Python. The "ps" > command doesn't use any kind of API, it just reads kernel memory > where this stuff is stored. > > If it doesn't need to be portable, and your present platform > supports it, I'd say use the "/proc" filesystem. The following > prints accumulated times, on FreeBSD 4.1. > > Donn Cave, donn at u.washington.edu Sent via Deja.com http://www.deja.com/ From phd at phd.pp.ru Wed Jan 10 12:13:03 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 10 Jan 2001 20:13:03 +0300 (MSK) Subject: Processes In-Reply-To: <3a587fb6$1@news.barak.net.il> Message-ID: On Sun, 7 Jan 2001, Max F. Rotem wrote: > How can I optimize it to DO NOT do REFRESH of CONTENT , and JUST add every > time add of new content ?? You need to make cooperative client-side functions (javascript, probably) and serve-side CGIs... Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From fredrik at effbot.org Tue Jan 9 14:39:41 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 09 Jan 2001 19:39:41 GMT Subject: Problem with __del__ References: <3A5B6434.2BD6FEF6@mail.dvz.fh-koeln.de> Message-ID: <1OJ66.4624$AH6.762498@newsc.telia.net> Stephan Effelsberg wrote: > Now I swapped the lines for instanciating 'cl' and 'nothing' with the > following result: > > cl2 > doing something > cla > doing something > nothing None > Exception exceptions.TypeError: 'call of non-function (type None)' in > ignored > cl None > Exception exceptions.TypeError: 'call of non-function (type None)' in > ignored > > Now it seems that both 'nothing' and 'cl' aren't able to see the > function dosomething(). > > Can somebody explain this phenomenon? python replaces global objects with None during cleanup, in a well- defined but somewhat unpredictable (for a human, at least) order: http://www.python.org/doc/essays/cleanup.html if you can, get rid of the destructors (__del__ methods are evil, and shouldn't be used in normal programming). if you really must keep them around, make sure you keep references to global objects: def __del__(self, dosomething=dosomething): print self.name, dosomething dosomething() hope this helps! cheers /F From sholden at holdenweb.com Tue Jan 16 17:42:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 16 Jan 2001 17:42:27 -0500 Subject: URL replacement in text References: <3A5F2A5A.494023BF@thawte.com> <8qH76.14451$Im.109356@e420r-atl1.usenetserver.com> <7G%86.7011$AH6.1061749@newsc.telia.net> Message-ID: "Fredrik Lundh" wrote in message news:7G%86.7011$AH6.1061749 at newsc.telia.net... > Steve Holden wrote: > > Note that this won't cope with some of the more pathological URLs (such as > > those with CGI arguments [http://system/cgi?arg1=val1] or those which link > > to a named anchor in the target page [http://system/pageref#target-name]). > > import re > > links = re.compile(r"(?i)(?:http|ftp|gopher):[\w.~/%#?&=-]+") > > def fixlink(m): > href = m.group(0) > return "%s" % (href, href) > > sometext = """ > here's another link: http://www.pythonware.com?FOO=1&bar=10#BAR > """ > > print links.sub(fixlink, sometext) > > Cheers /F > Fredrik: What took you so long? :-) Of course the next refinement is to present the base part of the URL (up to the "?" or "#") as the anchored text, but use the full URL as the HREF attribute value. if-you've-got-answers-i've-got-questions-ly y'rs - steve From paulp at ActiveState.com Thu Jan 4 20:03:21 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 04 Jan 2001 17:03:21 -0800 Subject: AMK's ZODB package on Win32 References: Message-ID: <3A551D59.7E31974D@ActiveState.com> "A.M. Kuchling" wrote: > > On Thu, 04 Jan 2001 16:24:37 GMT, > andres.corrada wrote: > >Can Kuchling's ZODB package be used under Win32? Does someone have > >experience doing this? > > The ZODB code should work fine, but I have no access to a Windows box > and can't compile it for Windows; perhaps you could extract the > compiled code from the Zope distribution for Windows. I was going to try the compile and see if it was easy but I note that you have filenames of ZEO and zeo in the directory ZEO. To obfuscate a little less: zodb/ZEO/ zodb/ZEO/ZEO/ zodb/ZEO/zeo tar: zodb/ZEO/zeo: Could not create file: Permission denied Paul From martin at mira.cs.tu-berlin.de Sat Jan 20 04:55:54 2001 From: martin at mira.cs.tu-berlin.de (Martin v. Loewis) Date: Sat, 20 Jan 2001 10:55:54 +0100 Subject: [XML-SIG] Using Installer with PyXML In-Reply-To: <016801c0829a$ea7bf2e0$11260340@yin> (dan.rolander@marriott.com) References: <016801c0829a$ea7bf2e0$11260340@yin> Message-ID: <200101200955.f0K9tsL00802@mira.informatik.hu-berlin.de> > "The problem here has to be the way that the xml library tree is replacing > itself with the _xmlplus tree from the later PyXML distribution. While > runtime re-assigns xml to _xmlplus in the __init__ for xml, the import > system used by the installation package can't track that, so it still looks > for the actual module tree it loaded from the Python distribution beneath > the name xml." I'm not sure I understand the problem. Will the packager refuse (or forget) to package the xml package, or will it, at runtime, fail to load it? If it manages to package both xml and _xmlplus: when loading xml, will it execute xml/__init__.py? In there, there is an import of _xmlplus. Will that succeed? If so, what happens to the lines import sys sys.modules[__name__] = _xmlplus Will __name__ have a value of "xml"? Will the assignment succeed? Now, suppose we do from xml.sax import sax2exts In normal Python, this will look for sys.modules["xml"] and start from there. Are you saying the installer does not work that way, or that even if it starts from there, it still can't figure out to load _xmlplus.sax? > So the question is, will this adversely impact normal Python operation, and > is there a better way? No, replacing the Python xml package completely with _xmlplus will work just fine - except perhaps for the pyexpat difference. > The other question I have is... Why are there two different pyexpat.pyd > files, one as part of the core 2.0 distribution (at only 25 kb) and the > other as part of the PyXML distribution in _xmlplus.parsers (at 124 kb). I > haven't been able to get the large one to work using Installer, but the > small core file works fine. What is the difference? There are two differences: the one from PyXML contains a number of bug fixes which are not in Python 2. In addition, it contains a literal copy of the expat libraries, so that the expat DLLs in the Python core should not be needed anymore. When you say "get the large one to work", what exactly have you tried, and how exactly did it fail? Regards, Martin From bend at ecollege.com Mon Jan 22 19:13:03 2001 From: bend at ecollege.com (Benjamin Derstine) Date: Tue, 23 Jan 2001 00:13:03 GMT Subject: Documentation for using python mode in emacs Message-ID: Is there any documentation for using python mode in emacs? I've looked the python.org website over and there is lots of info on how to install it and configure it but no info on how to use it. Are you supposed to be a pyschic genius and just know? From jcm at bigskytel.com Fri Jan 26 12:44:01 2001 From: jcm at bigskytel.com (David Porter) Date: Fri, 26 Jan 2001 10:44:01 -0700 Subject: Problems with Install In-Reply-To: <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net>; from zope@thewebsons.com on Fri, Jan 26, 2001 at 08:36:51AM -0800 References: <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net> Message-ID: <20010126104401.A3406@bigskytel.com> * Ben Ocean : > I'm at a loss to understand why I can't get python working. <...> > I may have made a bad mistake in deleting everything python in my box, > please advise. Running RedHat 6.2. Why not skip compilation difficulties and install an rpm? http://rpmfind.net/linux/rpm2html/search.php?query=python From danielk at aracnet.com Thu Jan 11 22:30:22 2001 From: danielk at aracnet.com (Daniel Klein) Date: Thu, 11 Jan 2001 19:30:22 -0800 Subject: Python Design Patterns (was Re: Should I learn Python or Java?) References: <978840685.459818@emperor.labs.agilent.com> <3A5DF377.791E3DE0@comm.mot.com> Message-ID: <3cus5tk2n0qnhgfid5mnmauulc4gsjfnpb@4ax.com> On Thu, 11 Jan 2001 20:05:05 -0500, D-Man wrote: > Some things would be implemented quite different in python (such as Singleton) > due to python's nice dynamic nature. Since you mention it, what is the pythonic way to implement a Singleton? You don't have to provide a complete answer, just a pointer as to where to start would be fine as I like to try to work these things out at first for myself. Daniel Klein "If it's not one thing, it's two things." From bxt at nospam.nospam Tue Jan 9 08:20:00 2001 From: bxt at nospam.nospam (BxT) Date: Tue, 9 Jan 2001 14:20:00 +0100 Subject: string escaping problems with MySQLdb Message-ID: <93f2cr$ofq$1@news2.dtag.de> Hi, i know this is a new-bie question, i'm using MySQLdb and, as i'm extracting records, i get string escaped as follows: for example, instead of ? i'm getting \\337 (yes, with doppel \). When i'm printing the string i'm getting blah\337 (internally is blah\\337). I tried to use string.replace but it's giving me the same string. Is there a way to print blah?? For now, thanks in advance, BxT From adamgamble15 at hotmail.com Thu Jan 18 14:40:04 2001 From: adamgamble15 at hotmail.com (adam gamble) Date: Thu, 18 Jan 2001 13:40:04 -0600 Subject: Is it possible to Compile a Python script into an EXE, for x86? Message-ID: NT From michael at stroeder.com Tue Jan 16 04:22:04 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 16 Jan 2001 10:22:04 +0100 Subject: Web devel with python: Best route? XML to HTML translation! References: <93cqvi0191h@news1.newsguy.com> <93hfp1013sm@news2.newsguy.com> <93vnlv$2qq$1@nnrp1.deja.com> Message-ID: <3A6412BC.A07C547@stroeder.com> rturpin at my-deja.com wrote: > > (1) The server scripts in Python generate XML. This is > pretty easy to do with xmlpickle. (2) Use an XML to HTML > filter to generate the HTML. In theory this is a good way. But how about the performance? Last time I played with a Python-written XSLT processor it was pretty slow. Ciao, Michael. From gregj at pobox.com Tue Jan 23 22:33:37 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Wed, 24 Jan 2001 03:33:37 GMT Subject: How do I kill an empty file ?? References: <94k9p5$vs2$1@nnrp1.deja.com> Message-ID: <94lieh$5sd$1@nnrp1.deja.com> Use the fileinput module: ---- import glob, fileinput files = glob.glob("path/to/files/*.tab") # get all file names for filename in files: for line in fileinput.input(filename): if len(line) > 2: ... # process line ---- fileinput.input gives you an iterator over the lines in the file. It ignores empty files (opens and closes them immediately), so they won't be processed by your code. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com In article <94k9p5$vs2$1 at nnrp1.deja.com>, chris.nelson at bwc.state.oh.us wrote: > Hello: > I have several TAB files that are generated daily for reports that are > then converted into graphs. The problem is that every now and then a > report file will fail to generate data and I will have an empty file. > > Currently I read in the the file assigning it to a variable and > readlines() > Then I use the following to parse out blank lines in a normal file > > for line in data: > j=0 > if len(line)>2: > ......rest of code > > What's an easy way to adapt this so that I can ignore files that are > nothing but empty lines? Ultimately I'm looking for sytax that will > ignore processing a file if it is empty. > > Please advise and tanks, > Chris > > Sent via Deja.com > http://www.deja.com/ > Sent via Deja.com http://www.deja.com/ From ctanya at my-deja.com Wed Jan 17 14:54:28 2001 From: ctanya at my-deja.com (ctanya at my-deja.com) Date: Wed, 17 Jan 2001 19:54:28 GMT Subject: pythoncom for VC++ RPC client Message-ID: <944t9e$f4r$1@nnrp1.deja.com> Is there a way to expose the pythomcom server to VC++ client using late binding? (with IUNKNOWN) The problem I'm facing is that VC++ client requires interface GUID to create the instance and I'm having trouble generating it from string interface representation: MakeIID(Sgl_sim.Server.HostServer.Connected) - gives me an error: TypeError: The object can not be converted to a Unicode object. Could I avoid this step at all? Sent via Deja.com http://www.deja.com/ From s2mdalle at titan.vcu.edu Thu Jan 11 14:52:12 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Thu, 11 Jan 2001 19:52:12 GMT Subject: Starting application inside an application References: <3A5D7722.2977BFE0@proceryon.at> Message-ID: In article <3A5D7722.2977BFE0 at proceryon.at>, "Horst Gassner" wrote: > Hello! > > Platform: Linux > > What is the easiest way to launch a new application from e.g. a menu in a > running application? Using os.system() does not work because the calling > application has to wait until the launched application has terminated. > > What I want to do is simply starting a second instance of my application > (just like starting the application from the command line a second > time). I am looking for a function like spawnv() which unfortunately only > works for the windows platform. > > Thank you Horst You can popen() a process. You pass the command line to popen() and it returns a file object which you can then use as normal. Or, you can do what popen() is really doing, only do it yourself. Popen just forks a process, and exec's a shell to execute your command line. -- David Allen http://opop.nols.com/ ---------------------------------------- "The number of UNIX installations has grown to 10, with more expected." -- The UNIX Programmer's Manual, 2nd Edition, June, 1972 From julienr at satis.com Thu Jan 18 11:00:43 2001 From: julienr at satis.com (Julien Reynier) Date: Thu, 18 Jan 2001 16:00:43 GMT Subject: Is it possible to write a python module in Java? Message-ID: <3A6713C3.88C2F64F@satis.com> Hi, I know it's possible to write a python module in C or C++. But is it possible to do the same thing with Java? And how ? I know JPython, but JPython can't access to system call as os.chdir(), os.system() etc So I want to use Python. thanks... -- Julien From katz at Glue.umd.edu Sat Jan 27 09:38:20 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Sat, 27 Jan 2001 09:38:20 -0500 Subject: . Python 2.1 function attributes In-Reply-To: References: Message-ID: On Sat, 27 Jan 2001, Tim Peters wrote: > Because the technique you suggest has been available for a decade, yet in > practice people refused to use it, preferring instead to abuse docstrings. > Have you read the PEP? "Practicality beats purity" in Python: an elegant > solution that masses of experienced Pythoneers refuse to use is an excellent > predictor of future language change. And, for example, metaclasses are in > that boat too. I considered your argument and have come to agree with you. I wanted to organize for myself the separations between functions and classes. Let's see if we can generalize them, perhaps use their differences to some advantage. Is it possible, then, to organize these as subtypes of some Entity? This 'Entity' allows for attributes to be attached under its namespace. Integers aren't entities. len() is not an entity. User-defined functions and classes -are- entities. As subtypes, Functions and Classes offer these additional functionalities: Functions: - don't need to be instantiated to be executed - very much a singleton Classes: - always pass self to methods - clonable through multiple instantiation Both: - take parameters (functions by their nature; classes through __init__) - can accomplish the same thing - can be used as data structures Note that last point: Is it that people have been clamoring for singleton support under Python? A question to consider: suppose we add class methods to Python. Then, the singleton feature of a function's data set can be mimiced by classes with static methods. I'm not sure what my point is, but I'm interested nonetheless. Perhaps adding attributes to functions takes us one step closer to adding true class methods. > Barry also added code to Python 2.1 to let you write, e.g., > > def f() >> x: > x = 1 > y = 2 > > as a short way to spell "whatever the value of x is at the end of the > function, return that". I'm sure you'll agree that's much cleaner than the > clumsy I like it, but why the choice of >> over return? Roey From claird at starbase.neosoft.com Wed Jan 24 09:14:42 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 24 Jan 2001 08:14:42 -0600 Subject: Python/C++ for graphics vs. other languages? References: Message-ID: <343986CB211E5DAD.985374BA50B24FC6.19D7A7B6FE4D9F36@lp.airnews.net> In article , D-Man wrote: >On Tue, Jan 23, 2001 at 08:52:31AM -0600, Cameron Laird wrote: >[snip] >| > >This URL is broken. > >-D > > The poster was broken. Thanks for the catch. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From qrczak at knm.org.pl Tue Jan 30 14:22:04 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 30 Jan 2001 19:22:04 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> Message-ID: Mon, 29 Jan 2001 12:30:30 -0500, D-Man pisze: > I'm not sure how different they are conceptually. A dictionary is a > collection (sequence) of data that is indexed by arbitrary keys. A > list is a collection (sequence) of data that is indexed by integers > only. It seems to me that a list is a special case of a dictionary. An important difference is that in a sequence you can insert or delete in the middle *shifting indices of all following elements*, where in a dictionary such operation would not make sense. Of course it does not imply that I would make a difference in syntax of accessing elements. When dictionaries and sequences are treated as immutable, they are very similar. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From mlh at idi.ntnu.no Tue Jan 30 17:19:43 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Tue, 30 Jan 2001 23:19:43 +0100 Subject: Sets in Python References: <956hcd$qef$1@tyfon.itea.ntnu.no> <956s6k013u0@news2.newsguy.com> Message-ID: <957erd$c4v$1@tyfon.itea.ntnu.no> "Michael Hudson" wrote in message news:m3snm07v3e.fsf at atrus.jesus.cam.ac.uk... > "Alex Martelli" writes: [...] > > Hi Magnus! It's been a while... > > > > In Python 2.1, you'll be able to use > > if x in dict > > as a synonym for > > if dict.has_key(x) > > [and *maybe* the for-loop equivalent, too -- I'm still unclear > > about that one, and it doesn't seem to be in the first alpha]. > > Uh huh; maybe not. There have been second thoughts at high levels - > expect a PEP and to maybe see these features in 2.2. Does that mean "maybe not" any of the features mentioned? Or only the ones in brackets? And if there is to be a PEP on this, might I humbly suggest an evaluation of some additional set-like methods etc.? I'm not sure what all of them might be, but at least I feel they should include adding and removing elements from the set... For instance, you might have a method dict.add(element) which was equivalent to dict[element] = 1 or dict[element] = None (which is perhaps more logical) or something? dict.remove(element) could then be equivalent to del dict[element] or something? Or perhaps even something like dict += element for adding an element and dict -= element for removing it? (That's what I did in my wrapper, but I'm not sure how good it is... Since it + might intuitively mean union... Oh, well...) hoping-for-prettier-sets'ly y'rs - M > > Cheers, > M. (Oh... That looked a bit schizoid or something ;-) -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From amritansh at mobilian.com Wed Jan 17 14:59:55 2001 From: amritansh at mobilian.com (Amritansh Raghav) Date: Wed, 17 Jan 2001 11:59:55 -0800 Subject: design help/questions Message-ID: Hi Disclaimer: I'm a Python newbie (been less than 2 days since I first looked at it) and I am searching the web for answers to these questions too, but since I am under a tight schedule, I was hoping someone could help me with these questions: So here is what I need to do. I'm trying to write a scripting tool for our test team. They wish to send arbitrary packets over the network. What I'd like to do is allow the testers to specify any packet in a text file - say something like this: "VersionLength" 0 1 # Name of field, Starting offset, Length in bytes "TOS" 1 1 "Length" 2 2 "Id" 4 2 "Offset" 6 2 "TTL" 8 1 "ProtoId" 9 1 CheckSum" 10 2 "Source" 12 4 "Dest" 16 4 Once they have specified this, the tester should be able to create a packet an assign values to the field, or receive a packet and parse out its contents. so a script should be able to say p = read() if p["ProtoId"] == 17: # do something here for UDP packets Solution I have written a DLL which can open/close/read/write to an ethernet device. I've got it interfacing to Python. It can accept a buffer and return a buffer. I've looked at socketmodule.c to get most of that figured out. I assume what I need to do is build a dictionary whose keys are the field names of a packet and then write a parser to fill in the values into the dictionary. I also need something to parse the text file description. If someone has done something like this before, or can point me to helpful scripts and source, I would be grateful. Thanks From pln at cosmic.stanford.edu Mon Jan 8 20:00:05 2001 From: pln at cosmic.stanford.edu (Patrick L. Nolan) Date: 9 Jan 2001 01:00:05 GMT Subject: A Listbox in a grid Message-ID: <93dnql$h5l$1@nntp.Stanford.EDU> I'm writing an application using Tkinter. I'm trying to stay with plain Tkinter for portability. I'm stuck on something. One of my windows is a big grid layout with bits of text and Checkbuttons. It was nice until I thought of another feature to add. I decided it would be useful if one of the columns of text would act like a Listbox. So I put a Listbox in my grid, next to a column of Checkbuttons. It was pure joy until I populated my window with more rows of information. Then I noticed a lack of alignment between the columns. The height of each row inside the Listbox is slightly less than the height of the Checkbutton next to it. It would be wonderful if I could put the Checkbuttons inside the Listbox, or maybe if I could tell the Listbox that each row should be as high as a Checkbutton. So far I can't find any way to accomplish either. Am I stuck? -- * Patrick L. Nolan * * W. W. Hansen Experimental Physics Laboratory (HEPL) * * Stanford University * From andrew_dot_henshaw_at_earthling_dot_net Sat Jan 13 14:18:37 2001 From: andrew_dot_henshaw_at_earthling_dot_net (Andrew Henshaw) Date: Sat, 13 Jan 2001 14:18:37 -0500 Subject: why no "do : until"? References: <90278A4rcamesz@127.0.0.1> <3A5F264D.4D7C024A@gte.net> Message-ID: Steve, Forgive me for not knowing your stance on some of the earlier points discussed, but I was responding to Rober Amesz' do - until proposal. Would not your statements also apply to his use of until condition instead of if condition: break ? I suppose that you could limit each 'do:' loop to one 'until' to avoid the multiple breaks problem. Implicit in that proposal would be the assumption that 'if condition: break' would not be allowed in a 'do:' loop. I don't think that suggestion would fly very well. Given Python's current structure, I still believe that the best compromise is the allowance of do: as a synonym for while 1: and leave it at that. AH "Steve Williams" wrote in message news:3A5F264D.4D7C024A at gte.net... > Andrew Henshaw wrote: > > > "D-Man" wrote in message > > news:mailman.979261813.31482.python-list at python.org... > > > On Fri, Jan 12, 2001 at 12:33:58AM +0000, Robert Amesz wrote: > > > [snip] > > ...snip > > [more snip] > > > > > Python's existing 'if condition: break', with its colon, stands out and, > > more clearly than the 'until', shows its true function; which is, > > essentially, a goto past 'something else' and out of the loop. I believe > > that support for this is more likely than for the other more significant > > changes. > > > > If you have nested 'do' statements, you have to keep track of the nesting > structure to find a break target. Searching for the first 'break' after a 'do' > may or may not find the loop invariant. > > Similarly, if you have multiple 'breaks' for a single 'do', the first one you > find may not be the one that bit you. > > With 'break', the program flow no longer corresponds to the program listing > (the original complaint about g*t*, IIRC). > > There will always be debugging questions such as "how did I get here?" and "why > did I skip this?" in procedural languages. 'Break' adds a little extra > excitement to these questions. > > From aleaxit at yahoo.com Thu Jan 4 12:55:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 18:55:23 +0100 Subject: Registering C methods when writing a C extension type? References: Message-ID: <932dg20a5o@news2.newsguy.com> "Tom Epperly" wrote in message news:mailman.978623584.28957.python-list at python.org... > Thanks to everyone who replied. You helped clear up some of my > misconceptions. I am fairly convinced by what I've read that what I've > proposed is a bad idea. [snip] > If I implement getattr/setattr with a PyDictObject (i.e. each myobject has > a dictionary instance), I thought the potential benefits would be: > 1. Replace the linear lookup time implicit in Py_FindMethod with nearly > constant time hash table lookup. True. But, how many methods will your objects have? For a typical small list, up to say 10-20, the small constants in the linear-time search may still make it a win (or roughly a tie, turning into a win because of the memory saving and speedier new-object generation). > 2. Avoid creating a PyCFunction_New once per method call. If a method is called in a tight loop, so that this is a worry, a speedier solution may be for the _Python_ side of things to do the lookup just once, saving the resulting callable in a local variable. > It would be nice if there were a Py_FindMethodSorted where it assumed that > the PyMethodDef's were alphabetically sorted. It might produce a small gain, yes (or a big one, if the methods are REALLY many). But if measurement proves that this does in fact make a measurable difference in your case, it's not hard to implement that yourself (and maybe post it as a patch to the sourceforge site) based on C's bsearch, I guess. (Wait until you _have_ measured... intuition regarding performance is SO tricky!). > I was also considering a way to have one extension type being able to wrap > up numerous IDL types. The alternative is to do something like: Why not have a Python-visible type per IDL type? I fail to see any cost in that. > struct myobject { > PyObject_HEAD > const PyMethodDef *object_methods; > } > > static PyObject * > myobject_getattr(myobject *self, char *name) { > /* other stuff deleted */ > return Py_FindMethod(self->object_methods, self, name); > } Yes, you could do that -- have objects of the same Python-visible type implement different sets of methods. But the benefit sort of eludes me here (the cost is also pretty small of course). Alex From donn at u.washington.edu Thu Jan 11 15:40:40 2001 From: donn at u.washington.edu (Donn Cave) Date: 11 Jan 2001 20:40:40 GMT Subject: Starting application inside an application References: <3A5D7722.2977BFE0@proceryon.at> Message-ID: <93l5o8$n8i$1@nntp6.u.washington.edu> Quoth Horst Gassner : | Platform: Linux | | What is the easiest way to launch a new application from e.g. a menu in | a running application? | Using os.system() does not work because the calling application has to | wait until the launched application has terminated. | | What I want to do is simply starting a second instance of my application | (just like starting the application from the command line a second | time). I am looking for a function like spawnv() which unfortunately | only works for the windows platform. On the contrary, I bet os.spawnv() will work fine for you. >>> import os >>> os.spawnv(os.P_NOWAIT, '/usr/bin/uname', ('uname', '-s')) 1445 >>> FreeBSD >>> Check it out. Donn Cave, donn at u.washington.edu From sholden at holdenweb.com Thu Jan 4 07:53:40 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 4 Jan 2001 07:53:40 -0500 Subject: Importing into 'containers' namespace References: <3a544e22.1199160471@news.mch.sni.de> Message-ID: Nikolai Kirsebom wrote in message news:3a544e22.1199160471 at news.mch.sni.de... > There is probably an easy solution to this, but I can't seem to find > out. > > I would like to make an object (instance) created in the 'importing' > namespace available in the imported module. > Passing it as an argument to the object initialiation is the usual way to go, see below. > Example below: > > # ----------------------------------------------------------- > # File: B.py (the imported module) > # when loaded, the object 'FrameWork' is in the scope > class B: > def __init__(self): > self.b = FrameWork.a > Change this so that the FrameWork is passed to the initializer: class B: def __init__(self, F) self.b = F.a > # ----------------------------------------------------------- > # File: A.py (the importer) > > class A: > def __init__(self): > self.a = 1 > > # Create framework instanse > FrameWork = A() > > # SOME IMPORT STATEMENT for module B > ?? > > Sub = B.B() Change this to pass the FrameWork in to the object creation: Sub = B.B(FrameWork) > print Sub.b # Produces '1' as output > > # ---------------------------------------------------------- > > Thanks for any help. > Nikolai > Hope this helps. regards Steve From p.g at figu.no Thu Jan 18 01:29:00 2001 From: p.g at figu.no (Per Gummedal) Date: Thu, 18 Jan 2001 07:29:00 +0100 Subject: Python and Industry, IBM I'm afraid In-Reply-To: <3A63D9E8.F9B74ACE@mjs400.co.uk> References: <20010111172342.10148.00000934@ng-ca1.aol.com> <3A63D9E8.F9B74ACE@mjs400.co.uk> Message-ID: <942039571298.20010118072900@figu.no> 16.01.2001, 06:19, Pete wrote: > Has anyone ported Python to IBM iSeries 400?...Or is this considered too > much hassle, because they are big fat trucks of servers - and come > bundled with no GUI support (they have had posix for many years)?...Or > are people waiting for Linux support in a logical OS partition?...Or > does no one care? I'm currently trying to do a port to AS/400. I have it up running with a limited set of modules, but it's not ready yet. Per From walter at bnbt.de Fri Jan 26 12:29:06 2001 From: walter at bnbt.de (Walter Dörwald) Date: Fri, 26 Jan 2001 17:29:06 GMT Subject: What happened to unistr() in 2.1a1? Message-ID: <94sc4l$1sv$1@nnrp1.deja.com> Hello all! What happened to the builtin function unistr() from patch #101664? It seems to have been removed in the last minute before the release of 2.1a1. Bye, Walter D?rwald Sent via Deja.com http://www.deja.com/ From williamc at go2net.com Thu Jan 11 22:31:50 2001 From: williamc at go2net.com (William Carrel) Date: 11 Jan 2001 19:31:50 -0800 Subject: BUG Python 2.0 FreeBSD compile problem In-Reply-To: amk@mira.erols.com's message of "12 Jan 2001 02:40:17 GMT" References: Message-ID: amk at mira.erols.com (A.M. Kuchling) writes: > On Thu, 11 Jan 2001 14:31:26 -0600 (CST), > Chris Watson wrote: > >Python is IN the ports tree. And someone (the maintainer of that port) had > >already gone to the trouble to patch it and insure it compiles well and > >added the other nice features of "ports" in FreeBSD. So there was no need > > And this points up an annoying thing about FreeBSD; patches are made > to get Python to compile on the platform, but those changes aren't > contributed *back* to the original Python source tree. How can one > find out what changes were made to a package in the ports tree? Look for patches in the ports tree... http://www.FreeBSD.org/cgi/cvsweb.cgi/ports/lang/python/files/ Although I believe the standard procedure is to submit those patches to the project as soon as possible so that there are less patches to maintain in the ports tree. But-I-build-from-CVS-anyway-even-if-I-have-ports-ly yours -- Andy From aahz at panix.com Fri Jan 5 10:50:30 2001 From: aahz at panix.com (Aahz Maruch) Date: 5 Jan 2001 07:50:30 -0800 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> Message-ID: <934qg6$dua$1@panix2.panix.com> In article , Joel Ricker wrote: > >I thought of the question about security and the need for taint modes but >then I realized since there may not be system calls like `del *.*` there >might not be a need for it. I'm sure that if Python is in general use as a >CGI language then those issues have been cleared up. Are there any thing >you have to watch for like running in taint mode in perl? There are system calls, but Python programming (particularly in a CGI environment) tends to avoid them, simply because they tend to be OS-centric (for example, your "del *.*" above would need to be written as "rm *" on Unix). Python provides modules that handle many of the cases that you'd use system calls for in Perl (not that Perl doesn't provide those modules, but it's not part of the mindset to the same extent that it is in Python). Python's cross-platform approach serves you well in this regard. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "This is Usenet. We're all masturbating in public places." -DH From a.genkin at utoronto.ca Sat Jan 27 00:40:08 2001 From: a.genkin at utoronto.ca (Arcady Genkin) Date: Sat, 27 Jan 2001 05:40:08 GMT Subject: Precision of float --- double? Message-ID: <87hf2lk0xz.fsf@tea.thpoon.com> Could someone point me to a place in the documentation where the float type is defined? Is it equivallent of C's double? Many thanks, -- Arcady Genkin Don't read everything you believe. From jefferrs83 at hotmail.com Tue Jan 9 17:19:30 2001 From: jefferrs83 at hotmail.com (Geoffrey Schneider) Date: Tue, 09 Jan 2001 22:19:30 GMT Subject: Silly question from a newbie Message-ID: Hi, This probably seems like a pathetic question, but... I downloaded the 'Grail' browser made with Python.... but, being someone who only just heard of Python 2 days ago, I don't know how to start the Grail browser. How do I open it? There isn't a .exe file or something like that (which, being a dumb-ass Windows user for six years I'm used to having provided). I'm using the Python for Windows thingy, as I don't have UNIX (apart from Linux, which I ordered from Amazon.com, but hasn't arrived yet!). Thanks. Jefferrs jefferrs83 at hotmail.com From tim.one at home.com Sat Jan 27 18:01:27 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 27 Jan 2001 18:01:27 -0500 Subject: . Python 2.1 function attributes In-Reply-To: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> Message-ID: [Robin Becker] > mmmhhhh :( what happens with > > def f() >> x: > return 1 > ... > def f() >> x: > y=2 > return y Raises InconsistentReturnError unless x is 1 evaluates true in the first example, or x is y evaluates true in the second, at the time the "return" is executed. Clearly, anything else would be error-prone! > seems to me that having multiple ways of doing return is a bad idea You might like this new 2.1 feature better then, best illustrated by example: >>> def f(\d+)(i): ... return int(\1) + 1 ... >>> f12(6) 18 >>> f0(3) 3 >>> f666(42) 708 >>> That is, "the name" of a function can be a regular expression now, and anything that "looks like" a call is matched against all regexp func defs. \1, \2 etc can be used in the body of the function to return substrings of the matched function name, just as for any other use of regexps in Python. Of course there is a full set of disambiguating rules, based on the notion of "most specific match". For example, def f.*(i): return i also matches names like f12 and f666, but the set of strings matching f.* is a strict superset of those matching f(\d+), so the latter is more specific. By the same rule, def f666(i): pass is a more specific match than f(\d+), so f666 is unambiguous. The primary reason for adding this was all the complaints about not being able to reliably obtain the name of a function within its own body. Now it's available via \0. >>> def anyfuncatall(): ... print \0 ... anyfuncatall >>> or, via the new attribute notation, >>> anyfuncatall.\0 'anyfuncatall' >>> Combining this with the new return spelling is very powerful: >>> x1 = 10 >>> x2 = 20 >>> x3 = 30 >>> def f(\d)() >> eval("x" + \1): ... pass ... >>> f2() 20 >>> can't-wait-to-see-who-supports-this-one-ly y'rs - tim From cfelling at iae.nl Thu Jan 25 11:34:48 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 25 Jan 2001 17:34:48 +0100 Subject: python-2.1 function attributes References: Message-ID: <94pkj8$2k9$1@animus.fel.iae.nl> Paul Prescod wrote: > Mike Romberg wrote: ... >> def spam(): >> """The doc string.""" >> { 'attribute1' : 'val1', 'attribute2' : val2 } >> pass > I proposed a similar syntax to Guido a couple of years ago and he > pointed out that it is unclear whether "val2" should be evaluated in the > runtime context of spam() or in the global context. The former is what > the syntax suggests but the latter is the only way to have the feature > work properly. That's why I proposed def spam() # no trailing : here!, so we didn't really enter spam scope with: # buth first the `with' scope to define spam's attributes statements to initialise f's dict with full python power suite On the other hand, the current practice of having the first string-statement be converted compile time into spam's docstring has always struck my as odd. -- groetjes, carel From entropiamax at jazzfree.com Mon Jan 8 03:42:20 2001 From: entropiamax at jazzfree.com (entropia) Date: Mon, 08 Jan 2001 09:42:20 +0100 Subject: shtml in python References: <93adro$k9n$1@sunsite.icm.edu.pl> <9z366.240411$_5.53698286@news4.rdc1.on.home.com> <93algg$pdj$1@sunsite.icm.edu.pl> Message-ID: <3A597D6C.49359F93@jazzfree.com> Look at webware.sourceforge.net Webware includes PSP, the Python equivalent of PHP, ASP and JSP Vesemir escribi?: > Hello! > U?ytkownik "Michael P. Soulier" napisa? w wiadomo?ci > news:9z366.240411$_5.53698286 at news4.rdc1.on.home.com... > > In article <93adro$k9n$1 at sunsite.icm.edu.pl>, Vesemir wrote: > > > > > >How to write shtml scripts in python? > > >what's needed to configure apache server? > > > > I think you're confusing two concepts here. shtml is a standard file > > extension for Server Side Includes. This has nothing to do with Python. If > you > > are instead hoping to use Python to write CGI scripts, then read up on > your > > web server's documentation on how to enable CGI scripts. If it's apache, > check > > the apache web site. They have excellent documention. > > No! I want to configure apache server to embed python scripts into html > code. > > Yours > QdlatY > > -- > http://www.python.org/mailman/listinfo/python-list From grey at despair.rpglink.com Fri Jan 19 17:02:05 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 19 Jan 2001 22:02:05 -0000 Subject: Why no isexec, isread, iswrite, etc (was: I must be missing something obvious: os.path.isexecutable?) References: <%F2a6.926$eI2.260005@ruti.visi.com> Message-ID: On Fri, 19 Jan 2001 21:51:55 GMT, Grant Edwards wrote: >I didn't say it was a _good_ answer. ;) :) Anyway, point was made. There is a way to do it, just not the way that I'd prefer to do it. I'd like to see it added but I'm not going to whine about it endlessly. If anything I'm going to look into modification of at least posixpath.py to include such checks in some manner once I get some free time on my hands. If I can come up with something that will work in a predictable manner I'll submit it as a patch to be incorporated or tossed away as they see fit. Thanks for the discussion, though, I did learn a bit. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From Dan.Rolander at marriott.com Fri Jan 26 09:20:26 2001 From: Dan.Rolander at marriott.com (Rolander, Dan) Date: Fri, 26 Jan 2001 09:20:26 -0500 Subject: New way to learn Python? Message-ID: <6176E3D8E36FD111B58900805FA7E0F80CCF633A@mcnc-mdm1-ex01> Cool site! But I'd like to see the main page be introductory with some basic information about the site and the quizzes before launching right into them. Thanks for doing this. Dan -----Original Message----- From: jqcordova at my-deja.com [mailto:jqcordova at my-deja.com] Sent: Friday, January 26, 2001 5:19 AM To: python-list at python.org Subject: New way to learn Python? Spent last couple of years building well-known e-commerce sites using Open Source code. Used Perl, Python,Tcl/Tk, & Java and had to teach jr. programmers a lot about how to program in these languages. Found out most effective way was the so-called Socratic method of question/answer. So, put together a website www.codecity.com to explore this approach to teaching Open Source. Hope to get some feedback/participation from this group especially in contributing Python quizzes. Hope this is appropriate. Jeff C. www.codecity.com Sent via Deja.com http://www.deja.com/ -- http://mail.python.org/mailman/listinfo/python-list From hans.kristian.ruud at inenco.no Thu Jan 18 13:34:39 2001 From: hans.kristian.ruud at inenco.no (Hans Kristian Ruud) Date: Thu, 18 Jan 2001 18:34:39 GMT Subject: Canvas geometry Message-ID: <3A67353A.4B9328EC@inenco.no> Hello I try to retrieve the dimensions of a canvas in the following manner: h = eval( self.canvas.cget('height') ) w = eval( self.canvas).cget('width') ) however this does noe yield the true values (as I have demonstrated by this code): self.canvas.create_line(5,5,5,h-5,w-5,h-5,w-5,5,5,5,fill='red') The code in question is based upon the example draw3.py in Grayson's book Python and Tkinter programming (Chapter 10.2) How do I retrieve the "true" extensions of the canvas? P? forh?nd takk ( Thanks in advance ) - hans kristian - From claird at starbase.neosoft.com Fri Jan 5 07:34:51 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 5 Jan 2001 06:34:51 -0600 Subject: How to think about Python's few controversies (was: Migrating to perl?) References: <3Fa56.4580$of7.216286@news1.atl> <933fa1$j2i$1@newshost.accu.uu.nl> Message-ID: <2021AFB9F318BFB8.57ECE2FBE8BE9A50.59A8AF63203CCFD1@lp.airnews.net> In article , Quinn Dunkan wrote: >On Fri, 5 Jan 2001 00:47:32 -0500, Joel Ricker wrote: . . . >Well, I hate to disappoint, but python doesn't enforce encapsulation. Just >like it doesn't enforce types---you'll get a runtime error down the line. I . . . >provide automatic accessors. I've discovered, though, that I've never had a >problem with python's direct access. Just use your good judgement---you may . . . I want to underline a couple aspects of this situation: 1. Although Python doesn't enforce (this kind of) encapsulation, there's good style that makes it a matter of convention (and, for those in a belligerent mood, argument that that's all C++ does, anyway); 2. Encapsulation's important. However, whether it should be a compile-time guarantee or a more dynamic matter is also an arguable point. As Mr. Dunkan notes, Python's choice never seems to be a problem in practice. More generally, Python is quite clean. It has a few consistent syntactic controversies--signi- ficant white space, (un)encapsulation, a few perceived deficiencies in assignment and looping--but the remarkable thing is that each of these is, from all the evidence, more of an issue for spectators than participants. Python's made the right choices. It works well. Even if, say, significant white space discomforts you on some abstract level, my prediction is that you'll quickly come to like it once you try it. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From fredrik at effbot.org Sat Jan 27 05:38:46 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 27 Jan 2001 10:38:46 GMT Subject: marshal doesn't work with "file-like" objects References: <5.0.2.1.0.20010126135016.029c4d90@mail.mindspring.com> <94t1bi$m73$1@nnrp1.deja.com> Message-ID: Chuck wrote: > Does anyone really believe that there is any difference in performance? > Supporting file-like objects would add the overhead of a message pass. "a couple of thousand message passes", that is. > But what's taking place here is file I/O that easily ranges from 1K to > 40K (according to my dir *.pyc). marshal does lots of single byte reads. the're only one fread in marshal, and that's used to read string literals. > I seriously doubt that if message passing were suddenly employed [a] > anyone would notice and [b] any Python benchmarks would change. maybe, but people sure notice when we *improved* marshal's performance: http://deja.com/=dnc/getdoc.xp?AN=715125331 > I win <0.95 wink>. nope. Cheers /F From grey at despair.rpglink.com Fri Jan 19 09:47:05 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 19 Jan 2001 14:47:05 -0000 Subject: Why no isexec, isread, iswrite, etc (was: I must be missing something obvious: os.path.isexecutable?) References: Message-ID: On 19 Jan 2001 00:29:44 -0500, David Bolen wrote: >I'm sure it wouldn't be too terrible to spec out something that is >well-defined and augment the module. But it's also not too much >effort to just stat the file (which is going to happen anyway) and >then apply the heuristic that you want in your particular situation. I'm not sure I agree that "Well, what should be done" and "this is how it works anyway" are good reasons to have 1/2 an example. I certainly wasn't the first to look for those under os.path after seeing the other "is"es there. Define a behavior and do it /or/ somehow provite a pointer in the documentation from those obvious starting points for the common functionality to the stat macros. Bah, I'll look into trying to define behavior and see how to implement it, though. Good project to keep me busyin Python. :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From erno-news at erno.iki.fi Wed Jan 31 05:03:04 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 31 Jan 2001 12:03:04 +0200 Subject: How do you lock your web app data? References: <956uqd$6st$1@newsreaderg1.core.theplanet.net> <958j810o2e@news2.newsguy.com> Message-ID: In article <958j810o2e at news2.newsguy.com>, "Alex Martelli" writes: [snip] | Hey, I bet even GADFLY would do, if you ran it in a central process | and had your scripts talk to that process with Gadfly's TCP/IP | client/server protocol (but I have no experience of *that*) -- | but I don't think you'd get atomic transactions then, and I think | they ARE important. are you sure about this? seems to me like gadfly claims to support transactions (). -- erno From peter at engcorp.com Tue Jan 2 23:41:14 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 02 Jan 2001 23:41:14 -0500 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> Message-ID: <3A52AD6A.62D043A2@engcorp.com> Steve Lamb wrote: > > On Tue, 02 Jan 2001 21:06:33 GMT, Grant Edwards wrote: > >Requiring edits to two possibly widely seperated places in the source code to > >change a single algorithm value is (in my experience) going to cause a bug > >some day. > > Makes you wonder how all those people who had to init variables in the > past got through life with such problems facing them, huh? I mean, the > variable is right there before the loop. The horrors, the agony, oh my, this > is worse than y2k! Call out the national guard, the world is going to END > because someone cant make an edit in two OBVIOUS places! You are a cowboy-hacker type of programmer, not one working as a serious software engineer in a group environment, right? Or, if the latter, your management just hasn't caught on yet. Seriously, nobody who really programs for a living instead of as a hobby should (in my opinion) have the attitude you express above towards a maintenance issue such as this. In my opinion. Nothing personal. > Hell, I'm more > concerned with a lack of braces that vim can spot so I can bounce on the % key > to get from one end of a block to the other quickly than with a variable being > unedited when it is sitting at the top of the loop. Guess which one I do > thousands of times more than the other? Not saying Python needs braces, just > pointing out there are elements of it which run against other languages I'm hoping to find an editor sophisticated enough to allow me to write a macro which does this kind of thing (bounce around a block) even with Python code. Only problem is, it would probably have to be programmable *using* Python (which coincidentally VIM is), but for other reasons I would need a MODELESS editor (dang VIM anyway! :-). > the tools devised for them that this is so insignificant it is a wonder anyone > has the energy to argue the matter for over a WEEK now. GET OVER IT! There are just too many idealists around here, hoping against hope that their (oops, our) efforts will result in some incremental improvement in the quality of software development. Maybe somebody was listening, somewhere, and has learned something from the exchange, anal though it might seem to some. From echuck at mindspring.com Wed Jan 31 14:28:12 2001 From: echuck at mindspring.com (echuck at mindspring.com) Date: Wed, 31 Jan 2001 19:28:12 GMT Subject: executing JavaScript from Python Message-ID: <959ovu$sqd$1@nnrp1.deja.com> urllib.urlopen() can be useful for grabbing a web page and checking its contents. However, JavaScript generated content throws a monkey wrench in this technique. Has anyone cobbled together a means to invoke JavaScript from Python, possibly including the DOM and the substitution of output into the HTML file? -Chuck Sent via Deja.com http://www.deja.com/ From mikael at isy.liu.se Mon Jan 29 10:02:52 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 29 Jan 2001 16:02:52 +0100 (MET) Subject: Books In-Reply-To: <3a757f33$1@netnews.web.de> Message-ID: On 29-Jan-01 Volker Jahns wrote: > >search for PYTHON and you will have greater success. > > > Thanks, but the pyhton.org should lern PHP... .-) Write the following a thousand times: Python is spelled python, not phyton or pyhton. Python is spelled python, not phyton or pyhton. Python is spelled python, not phyton or pyhton. Python is spelled python, not phyton or pyhton. .... Then try again... /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 29-Jan-01 Time: 16:00:44 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From fredrik at effbot.org Thu Jan 11 10:41:05 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 11 Jan 2001 15:41:05 GMT Subject: Module for reading tarfiles? References: Message-ID: A.M. Kuchling wrote: > Does anyone have any code for reading tar archives in Python? A long > time ago, Clemens Hintze wrote a tarlib.py that was on python.org, but > it no longer seems to be there. >>> from PIL import TarIO Cheers /F From china at nospam.com Wed Jan 31 02:30:57 2001 From: china at nospam.com (Albert Chin-A-Young) Date: 31 Jan 2001 07:30:57 GMT Subject: Python programmer needed (addition to urllib2 and HTTPS support) Message-ID: <958evh$4k3$1@bob.news.rcn.net> We're in need of a contract Python programmer for the following: 1. Allow connecting to a host with urlopen() which requires BASIC HTTP authentication with a proxy (via urllib2.py). This should address bug #125217: http://sourceforge.net/bugs/?func=detailbug&bug_id=125217&group_id=5470 2. Allow connecting to a host with urlopen() which requires BASIC HTTP authentication with a proxy that requires BASIC HTTP authentication (via urllib2.py). 3. Support for non-authenticated clients to connect to a HTTPS server 4. Support for a client to authenticate the HTTPS host (to verify that it's certificate is valid) What we might consider adding (depends on cost): 1. Support for authenticated clients to connect to a HTTPS server. Please note that solutions to the four items above must be rolled back into the main Python distribution (implies the "community" and the Python developers need to agree on the adopted solution). -- albert chin (china at thewrittenword dot com) From vplatt at my-deja.com Wed Jan 24 16:20:01 2001 From: vplatt at my-deja.com (vplatt at my-deja.com) Date: Wed, 24 Jan 2001 21:20:01 GMT Subject: windows, python, gtk References: <94nd0r$o0v$1@nnrp1.deja.com> Message-ID: <94ngtl$s1h$1@nnrp1.deja.com> There is a port of the gimp to Windows, which had a gtk port in it. I suspect you'll need to start there. FWIW though, the Windows version of the gimp I use isn't exactly stellar in the reliability dept, but that's probably improved since I last grabbed a copy 3+ months ago (version 1.1.24). Here's the page I used to get it: http://user.sgic.fi/~tml/gimp/win32/downloads.html I haven't tried using it with Python though, so YMMV big time. Try Freshmeat.net for GTK -> Python bindings. Also, GTK itself may have bindings right in it; it's worth a look. In article <94nd0r$o0v$1 at nnrp1.deja.com>, abnerstransky at my-deja.com wrote: > Hey > I'm looking for the gtk toolkit for windows to use with python 2.0 for > windows, and am having trouble finding it. Any ideas? > > Thanks > abner Sent via Deja.com http://www.deja.com/ From michael at stroeder.com Sat Jan 27 14:14:03 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sat, 27 Jan 2001 20:14:03 +0100 Subject: Interested in a Crypto-SIG? References: <3A72C8A3.C4B4D69A@stroeder.com> Message-ID: <3A731DFB.3CF394C3@stroeder.com> "A.M. Kuchling" wrote: > > On Sat, 27 Jan 2001 14:09:55 +0100, > Michael Str?der wrote: > >I would like to propose a Crypto-SIG. The goal is to define Pythonic > >class APIs for various cryptographic and related standards to enable > >developers to use a unified API for implementing crypto-enabled > >applications in Python independent of the underlying implementations > >(basically inspired by Sun's Java crypto-related APIs). > > Are you the same person who proposed this yesterday on the Meta-SIG? No. But good to know that I'm not the only one. ;-) > Anyway, I'll give you the same answer: a unified API would be an > excellent idea, but a SIG seems unnecessary. There's already a > python-crypto list at egroups which could be used to coordinate work > on such a unified API The mailing list on egroups could be a start. But I would prefer something which looks more "official" and is tied closer to Python activities itself. I'm willing to act as a SIG-coordinator. > and the main issue is probably developer time. Yes. But everybody can save time if it's not necessary any more to reinvent wheel for every crypto package. Ciao, Michael. From max at alcyone.com Mon Jan 1 17:48:25 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 01 Jan 2001 14:48:25 -0800 Subject: Recursion References: Message-ID: <3A510939.225AD72D@alcyone.com> Bob Calco wrote: > 1. Why the vast difference between the languages? Is this apparent > limitation in Python deliberate, or the consequence of some other > design > decision? Python is strongly typed, as opposed to Perl which is weakly typed. In Perl all numbers are stored in floating point (whether you realize it or not). In Python you're only dealing with ints. Python has a "long" type for arbitrary precision integers; you should be using that instead. (If you're serious about a factorial implementation, you wouldn't use recursion, either.) In Perl you'd be using the default floating point implementation, which is obviously not ideal for calculating a large integer (floating point numbers have a limited precision). In Python, with longs, the integers can get as large as you like and Python will still support them to full precision. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Never had very much to say / Laugh last, laugh longest \__/ Des'ree Kepler's laws / http://www.alcyone.com/max/physics/kepler/ A proof of Kepler's laws. From scarblac at pino.selwerd.nl Wed Jan 3 10:51:31 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 3 Jan 2001 15:51:31 GMT Subject: split hangs References: Message-ID: davide at mercurio.localdomain wrote in comp.lang.python: > >Then you had better start reading better stuff . I'll repeat the > >original recommendation: Jeffrey [note: I erroneously said Jonathan before] > >Friedl's excellent book "Mastering Regular Expressions" (O'Reilly). > > Sorry, but the dragon book (Aho Sethi, Ullman), Introduction to automata > theory, languages and computation (Hopcroft, Ullman) and thousand of others > books on language theory are surely a better reference . > > >There are two "obvious" ways to implement a regexp engine. > > Indeed, regexp matchig is quite simple. > > One extreme > >Friedl calls "the NFA" way (although he's using "NFA" in a sense that > >differs from its technical meaning in the literature). > > Yes, reading your post I understand that the reason is these are not NFA, > "backreferences" are not part of regualar expressions and so we are not > talking of regular languages. But of course, regular expressions *as used in program languages* typically do backreferences. That means that they're officially not regexps at all, but *if* you want to learn about them, the "Mastering Regular Expressions" book is a lot better than the theory books. Nevertheless, formal language theory and finite automatons are nice things to study :-) -- Remco Gerlich From anderson at boi.hp.com Fri Jan 26 08:48:38 2001 From: anderson at boi.hp.com (Bill Anderson) Date: Fri, 26 Jan 2001 06:48:38 -0700 Subject: curses, python20/152, RH70/62, postgresql problems References: <94731d$9j4$1@nnrp1.deja.com> Message-ID: <3A718036.13B5B3BF@boi.hp.com> D-Man wrote: > > On Fri, Jan 19, 2001 at 03:18:16AM +0000, A.M. Kuchling wrote: > | Let's tackle these one by one. > | On Thu, 18 Jan 2001 15:44:49 GMT, dubal at my-deja.com wrote: > | >We then tried to compile Py20 source on RH7. It > | >gives some LONG_BIT error and stops. > | > | This is not a GCC problem; it is a glibc problem. Red Hat has > | released an updated RPM for glibc, so installing it should let you > | compile Python 2.0 without difficulty. Trying to use kgcc wouldn't > | help, because it's not the compiler's fault. > | > > Could you provide some more details on the glibc problem? I used to > have RH7 and didn't find anything obviously wrong in the headers, so I > assumed it was the compiler that wasn't doing the comparison > correctly. I solved the problem by manually editing the header ( > ). I have since upgraded to Debian, but am still > curious. > > Basically, for RH7 users : you can't use any rpms that people provide. Basically, you are wrong. I have many rpms I've installed on this (and several other RH7) that were built on non-RH7 Machines. In fact I have many that I built on RH6.[0-2] installed here on this very 7.0 box. (Part of this is due to the 6-way XEON box still running 6.2 ... for now) > RH used an incompatible compiler, so you must compile stuff yourself. > (Or find RH7 specific rpms) Also note that stuff compiled with newer > versions of gcc (3.0 when it is released) for newer dists (I assume RH > will use 3.0 when it is released) won't work on RH7 either. Rpms made You mean like how stuff compiled for RH6.x won't run on 5.x because there was a glibc change there too? That is a result of the change in glibc, and not RH. When any distribution (ewven one you build from scratch) moves to a newer major version of glibc, then programs compiled against that glibc will not work on earlier versions. Now, there is the option of installing backwards compatible libraries to compile against, so you _can_ compile apps on a newer distribution aimed at an older one, it just takes extra effort (as it should, really). Of course, you could upgrade the 6.x to have the newer glibc (and all the toys that go with it), and it will work fine. In fact, I did this with an alpha machine. That machine started with 5.0, and has been manually upgraded via rpms to 7.0, no use of the RH installer to do it (yes it was a bit time consuming ;). Works fine. That's one of the neat things about rpms; it isn't that difficult to upgrade what you need. :) > for RH7 or RH6 (or anything older) won't work on the a dist with the > new compiler. Not neccesarily, but possibly, and then again, it may very well be app (code) specific. The big issue with RPMS made on 7.0 is that they use a newer version of RPM that is incompatible with the stock RH6.x rpm version. Of course, if that were the only issue, you could just upgrade the rpm version. -- Bill Anderson Linux Specialist Modular Network Storage R&D Random Quote: Portable: survives system reboot. From erno-news at erno.iki.fi Fri Jan 5 19:53:13 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 06 Jan 2001 02:53:13 +0200 Subject: How robust is Python ? References: <9354f9$vbi$1@nnrp1.deja.com> <12FDE17E0FE881CA.A0D56446193FD374.16955A7253A18953@lp.airnews.net> Message-ID: In article <12FDE17E0FE881CA.A0D56446193FD374.16955A7253A18953 at lp.airnews.net>, claird at starbase.neosoft.com (Cameron Laird) writes: | Why cron rather than init? modifying inittab needs root. -- erno From chris_barker at my-deja.com Wed Jan 10 12:50:13 2001 From: chris_barker at my-deja.com (chris_barker at my-deja.com) Date: Wed, 10 Jan 2001 17:50:13 GMT Subject: why is this namespace weirdness happening? References: <93i3f7$122$1@nnrp1.deja.com> Message-ID: <93i7cg$55i$1@nnrp1.deja.com> In article <93i3f7$122$1 at nnrp1.deja.com>, Preston Landers wrote: > It seems that on the file1 "bar" line, if the 'import file2' above it is > commented out, the file2.bar reference will fail (file2 being the > unrecognized item.) Despite the 'import file2' at the top of the file. > It seems to be due to the 'import file2' following the statement. > Python seems to be scanning ahead for imports...? Actually, this is quite consistant wioth Python's way of dealing with namespaces in functions. see this example: a = 5 def spam(): print "a :", a a = 6 print "a :", a The first reference to "a" will fail, but if you comment out the "a = 6" line, it will access the a already defined. What has happened is that when Python byte-compiled the function, it noticed that an "a" has been defined in the function, so it won't use the global "a". NOte that defining "a" in the function does NOT change the value of the global "a". Importing is the same. when you import a module in a function, you are assiging the name, "file2" to the contents of the module in "file2.py" IN THAT FUNCTION. Python knows you are doing this, so it won't let you use the global version of that name. > I know that doing an import inside a function is not neccesary if you > have imported the module at the top of the file. However, it seems > strange that it only fails if there is an odd number of import > statements for that module. It's not a matter of odd number, it's a matter of at least one, and if you do import it, you have to do so before using it. If you leave only the first import in place, it will work fine. Any additional imports in the function will do nothing. The reason you might want to import the module in your function is that you may not know know what was done to it outside the function. For example: import file2 new_name = file2 del file2 def foo(): import file2 # the line below fails if the line above is cmted out # but works fine if present print "file2 bar: ", file2.bar #import file2 print "file2 baz: ", file2.baz foo() without the import line in foo(), it will fail. Note that you are still working with the saem module, even if it has been renamed, as is in this example: import file2 new_name = file2 del file2 def foo(): import file2 # the line below fails if the line above is cmted out # but works fine if present print "file2 bar: ", file2.bar #import file2 print "file2 baz: ", file2.baz file2.baz = 10 print "new_name.baz:",new_name.baz foo() print "new_name.baz:",new_name.baz And yes, this does take some getting used to, but it does follow some pretty simple logic, once you get python's "everything is a reference" and "mutable types" concepts. -Chris Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Sat Jan 20 12:28:33 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 20 Jan 2001 17:28:33 GMT Subject: Tabbing/Spaces References: Message-ID: <5Vja6.7793$AH6.1236050@newsc.telia.net> Robert Hicks wrote: > So what is the answer then? Can't anything get a simple answer! :-) tab size != indentation size (now read tim's and emile's posts again, and you'll see the light) Cheers /F From rwklee at home.com Sat Jan 13 17:31:24 2001 From: rwklee at home.com (Rick Lee) Date: Sat, 13 Jan 2001 22:31:24 GMT Subject: Python Object Editor? Message-ID: <3A60D73B.71F07FEE@home.com> There seems to be at least a few Python object browsers available, eg., PythonWin's object browser, and Python 2.0 Mac's IDE has a Namespace browser. Is there an editor that not only allows browsing of these objects, but also changing them? - Rick Lee From vonehr at ira.uka.de Thu Jan 4 06:07:18 2001 From: vonehr at ira.uka.de (Markus von Ehr) Date: Thu, 04 Jan 2001 12:07:18 +0100 Subject: Playing an .mov, .avi etc. file?? References: <92vsna$hdq$1@nnrp1.deja.com> Message-ID: <3A545966.F8794D69@ira.uka.de> harrc at my-deja.com wrote: > > Does anyone know of a good way from Python to play a video file (.avi > or .mpg or .mov)? Or even better, a way to play slected tracks off a > DVD? > > Any info is helpful! > > Chad Harrington > > Sent via Deja.com > http://www.deja.com/ On windows systems you can use the win32com module and use OLE/COM control mechanism. I tried to use MediaPlayer, but had problems. If you use windows and COM control, please answer in case of success. # Test dynamic policy import win32com import pythoncom import win32com.client w=win32com.client.Dispatch("MediaPlayer.MediaPlayer.1") w.AutoStart=1 w.FileName="c:\Programme\Python\ex1.wav" w.Play() From loewis at informatik.hu-berlin.de Mon Jan 1 08:21:29 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Jan 2001 14:21:29 +0100 Subject: Interesting behaviour of the assignment References: Message-ID: "Tim Peters" writes: > Now "is" is bulletproof. A stranger way: > > SPAM = [] > EGGS = [] First I thought: wow, that must be the shortest way to create "enumerated" objects. But then I noticed a flaw: SPAM == EGGS. So I still like the FoodType class approach best, although this restriction can be worked around with SPAM = [] EGGS = [SPAM] WHAT_COMES_NEXT = [EGGS] Regards, Martin From kirschh at lionbioscience.com Wed Jan 17 03:20:44 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 17 Jan 2001 09:20:44 +0100 Subject: Command language definition References: Message-ID: Rolf Fischer writes: > Dear Python specialists, > > could you give me some hints whether you would use python to setup > a command language for a gui in order to be able to establish > a batch mode (with automated testing options) ? > > Do I have to program each command with its allowed paramters, etc ? > Or is there a combination with another tool that you would recommend ? Why don't you simply code the (additional) commands as python functions at let the user use them, thereby having python as the command language. Of course, if the user uses wrong syntax, (s)he will be left with python error messages. The question is if you can do any better if you do your own parsing and validation. Chances are you end up with a new python/tcl/perl/guile/younameit interpreter. Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION Bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From hancock at earthlink.net Wed Jan 17 19:56:53 2001 From: hancock at earthlink.net (Terry Hancock) Date: Wed, 17 Jan 2001 16:56:53 -0800 Subject: Automatic Documentation Tools? Message-ID: <3A663F55.67BCA869@earthlink.net> I've seen a number of automatically generated documentation on the web for C/C++ source code. Is there anything like this for Python? I've taken over documenting a piece of code, and it would be nice to at list have a list of classes, attributes, and methods from which to work. Seems like it ought to be automateable, but I don't know the fastest way to do it. Any suggestions? -- Terry Hancock hancock at earthlink.net From porter at et.byu.edu Thu Jan 18 14:55:36 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: Thu, 18 Jan 2001 12:55:36 -0700 Subject: os.popen and popen2 In-Reply-To: <9472c7$8u9$1@nnrp1.deja.com> References: <9472c7$8u9$1@nnrp1.deja.com> Message-ID: In the documentation, it says that the windows version of os.popen was unstable prior to python 2.0. Does anybody know if this applies equally to the popen2 module? -------------------------------------------------------------------------- C. Porter Bassett porter at et.byu.edu http://www.et.byu.edu/~porter -------------------------------------------------------------------------- "Pretend like this is a really witty saying." - Anonymous -------------------------------------------------------------------------- From pj at sgi.com Thu Jan 11 17:29:37 2001 From: pj at sgi.com (Paul Jackson) Date: 11 Jan 2001 22:29:37 GMT Subject: Speed of Python vs. Perl References: Message-ID: <93lc4h$o1qco$1@fido.engr.sgi.com> |> The reasons for Python's relative startup sloth have been |> discussed here often; a big one is that Python runs around |> looking for Python files (like site.py and sitecustomize.py) |> at startup, and typically does a big pile of failing fstats |> while failing to find those files along the PYTHONPATH. I believe that it's actually more cpu bound, parsing the imports once it finds them, than it is disk bound, trying to stat or open them. See further my more detailed analysis: http://deja.com/getdoc.xp?AN=652983262 Subject: Re: How does Python compare to ? Date: 07/31/2000 Author: Paul Jackson -- I won't rest till it's the best ... Manager, Linux System Software Paul Jackson 1.650.933.1373 From wayne.izatt at _fspam_myself.com Tue Jan 2 02:56:41 2001 From: wayne.izatt at _fspam_myself.com (W.Izatt) Date: Tue, 02 Jan 2001 07:56:41 GMT Subject: Electronic edition of 'The Standard Python Library' References: Message-ID: I had a nightmare getting my copy of this book to "work". My office is behind a firewall, so of course the registration process would not work. Repeated calls to Fatbrain (more than 10) did not produce results. Emails were replied to by bots. I eventaully carried a printer home and printed the book. It is great, and has served me well. It just doesn't feel good to be treated like a criminal after I've paid for the goods. Don't buy from Fatbrain. I don't know about the others. cheers "Tom" wrote in message news:t7746.63812$59.17990421 at news3.rdc1.on.home.com... > I tried to use my electronic copy of 'The Standard Python Library' today > (Jan 1), but was unable to. > > It is possible that I did something wrong - I have no idea - but I would > caution anyone else who might be considering buying this. The book is fine, > but the format is a complete hassle. You pay your money, but you don't > really get the book. > > I have nothing against the author trying to make money from his work - I > just don't like it when copy protection schemes impede the ligit use of the > product (usually software) to such an extent. > > Is there any other book like it (ie. the standard library with sample code)? > > Tom. > > > > From bww00 at amdahl.com Wed Jan 17 13:37:44 2001 From: bww00 at amdahl.com (Bryan Webb) Date: 17 Jan 2001 18:37:44 GMT Subject: help with code for combinations/permutations References: <944adl$2bf@dispatch.concentric.net> Message-ID: <944opo$2b9@dispatch.concentric.net> Thanks to all that responded. I wasnt as clear as I should have been. (as usual) I really need to come up with all the possible sums of the numbers in the list ie. 1 , sum(1 + 2), sum(1 + 2 + 3) ,sum( 1+2+4),sum( 1 + 3) and so on. Thanks for all the help Bryan. Bryan Webb wrote in message <944adl$2bf at dispatch.concentric.net>... >HI, > I have a list with 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 in it, >I need to come up with all possible combinations of the numbers in the above >list ie. 1 +2, 1+2+3, 1+2+3+4, 1+2+3+4+5 and so on. > I will have multiple lists to deal with, larger and smaller. >Any help or ideas will be appreciated > >Thanks >Bryan Webb > > From wlipp at web.de Fri Jan 12 18:03:49 2001 From: wlipp at web.de (Wolfgang Lipp) Date: Fri, 12 Jan 2001 23:03:49 -0000 Subject: Again and Re: my uthreads execute serially Message-ID: <000a01c07ceb$ecb94ee0$e5460f9a@sewon.ac.kr> Gletschersorry for the somewhat cluttered appearance of the previous message. i posted the same question to python-list at python.org ("gatewayed bidirectionally into comp.lang.python", jesus), and Mike Fletcher was so kind to answer in no time @ all. here's the answer and the posting again. -w .............................. Same here, works fine with 1.5.4 (1.5.2) version of stackless, but doesn't work for the 2.0 version. No idea how I missed that, but it's definitely failing to switch contexts without an explicit switchContext. I have no time today to track it down this weekend, maybe Chris can take a look? (Note, adding a switchContext does make the threads run in parallel, but that shouldn't be necessary). uthread9 does complain on my machine, but I'd though it was the posting an exception to another thread test (which prints out the traceback). Should have had an explicit test for such a simple thing I suppose. Sorry about that, Mike -----Original Message----- From: Wolfgang Lipp To: python-list at python.org Sent: 1/12/2001 11:06 AM Subject: my uthreads execute serially can anybody help me with this problem? i am using stackless python 2.0 on win98se, on a laptop. when i execute the following program: import uthread9 as uthread import time def timer_elapsed( started ): return time.time() - started def timer_over( started, stoptime ): return timer_elapsed( started ) > stoptime def timer( letter, stoptime ): started = time.time() print "%s is started" % letter while not timer_over( started, stoptime ): pass print '%s is done after %3.2fs' % ( letter, timer_elapsed( started ) ) uthread.new( timer, 'a', 5 ) uthread.new( timer, 'b', 3 ) uthread.new( timer, 'c', 2 ) uthread.run() my output looks like this: a is started a is done after 5.05s b is started b is done after 3.02s c is started c is done after 2.04s which clearly indicates that the threads do *not* run in the parallel. moreover, the outputs from all the examples on http://world.std.com/~wware/uthread.html also point into interpreting them as being executed one thread after the other. since all the snippets as well as the test suite u1.py from that page work without complaining, i guess that there is no problem with my installation. furthermore, i tried a few examples using the threading module, and the results appear to be ok. because of this and because uthreads are not, to my understanding and unlike the threading module, dependent on the os, it can't be my laptop that's to small to fit in threads :-| ... can anyone help me parallelize my uthreads? yours, -wolf From dsh8290 at rit.edu Mon Jan 8 14:33:43 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 8 Jan 2001 14:33:43 -0500 Subject: Web devel with python. Whats the best route? In-Reply-To: <93dfft077p@news1.newsguy.com>; from aleaxit@yahoo.com on Mon, Jan 08, 2001 at 11:30:26PM +0100 References: <93cqvi0191h@news1.newsguy.com> <93dfft077p@news1.newsguy.com> Message-ID: <20010108143343.G4159@rit.edu> On Mon, Jan 08, 2001 at 11:30:26PM +0100, Alex Martelli wrote: | "Lele Gaifax" wrote in message | | > PS: Alex, un ciao particolare! Ti ricordi di me? Sublink... :) | | E vorrei vedere, che ci si potesse scordare della gloriosa sublink.org e | di tutti i suoi protagonisti...!-) Ciao Lele! | You do realize that it's impolite to "whisper" in public? Now I'm curious to know what you are talking about. But maybe it's my own fault for being "deaf" . I-really-do-have-a-(mild)-heritary-hearing-loss-ly y'rs -D From jef.mangelschots at iname.com Wed Jan 3 16:10:44 2001 From: jef.mangelschots at iname.com (Jef Mangelschots) Date: Wed, 03 Jan 2001 21:10:44 GMT Subject: problem compiling Python 2.0 on Sun Solaris Message-ID: <3a539455.17521624@news.wanadoo.fr> Hi, I just downloaded the sources for Python 2.0 from http://www.python.org/ftp/python/2.0/BeOpen-Python-2.0.tar.gz ALL the text files are unrecognizable to my system because each line is ended with 0x0D 0x0A, common for Windows NT systems, but not for Unix systems. Does anybody have a suggestion ? Following is the version info for my machine: Machine hardware: sun4u OS version: 5.6 Processor type: sparc Hardware: SUNW,Ultra-4 greetings Jef From glandrum at my-deja.com Wed Jan 17 09:51:09 2001 From: glandrum at my-deja.com (Greg Landrum) Date: Wed, 17 Jan 2001 14:51:09 GMT Subject: Are there Tkinter examples somewhere? References: <20010117000807.198D9E951@mail.python.org> Message-ID: <944bgq$ttg$1@nnrp1.deja.com> In article , Terry Hancock wrote: > Hi, > I'm trying to learn how to use the Tkinter toolkit > to build an applications in Python, and I'm > having trouble fathoming how to use all the widgets. > John Grayson has already pointed towards the sample code from his book, but I guess he was too modest to recommend the book itself. So I'll do it. John's book "Python and Tkinter Programming" (from Manning publications) is a good overview of Tkinter and includes a hefty amount of sample code. There's also a reference section at the back which can be quite useful. It's well worth picking up a copy if you are planning on using Tkinter. -greg Sent via Deja.com http://www.deja.com/ From p at mjs400.co.uk Fri Jan 19 00:07:37 2001 From: p at mjs400.co.uk (Pete) Date: Fri, 19 Jan 2001 06:07:37 +0100 Subject: I will kill my Python References: <947r18$rdt$1@news.online.de> <948f09$i96$1@nnrp1.deja.com> Message-ID: <3A67CB98.EAC73B8@mjs400.co.uk> thelazydogsback at my-deja.com wrote: > On a related topic, I've seen some Microsoft bashing here as well (not > just this post.) There's certainly nothing wrong with that (It's a > profession for some) but I must say that in some cases it reduces > Python's credibility. I want to see people using it because it works I want to see bash. Bash Bash Bash Bash. :) From rcameszREMOVETHIS at dds.removethistoo.nl Wed Jan 17 11:07:54 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Wed, 17 Jan 2001 16:07:54 GMT Subject: python compiled to native in less than a year? References: <941koq077o@news1.newsguy.com> Message-ID: <902CA0BF8rcamesz@127.0.0.1> Steve Holden wrote: >I suspect that disclosure through the standardization process would >cause patent applications to fail onthe grounds of "prior art". >Apparently Arthur C. Clark described the geosynchronous satellite in >concept in the British magazine "Wireless World", and this was >enough to ensure that he was refused a patent on it later. That's not entirely true: A.C. Clarke never applied for a patent at least according to him. In a book of his (I can't recall which one) he described a conversation he had with a patent lawyer (during a social event, IIRC). The lawyer told him that he should have applied for a patent *before* making his idea public. However, in this case that wouldn't have made any difference, because Clarke had the idea roughly a quarter of a century before the first geosynchronous satellite was launched, so the patent would have expired anyway. So be warned: don't get too far ahead of your time. It'll cost you. Robert Amesz From tim.one at home.com Fri Jan 26 15:17:10 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 26 Jan 2001 15:17:10 -0500 Subject: marshal doesn't work with "file-like" objects In-Reply-To: <5.0.2.1.0.20010126135016.029c4d90@mail.mindspring.com> Message-ID: [Chuck Esterbrook] > >>> from StringIO import StringIO > >>> f = StringIO() > >>> f.write('hi') > >>> import marshal > >>> marshal.dump(1, f) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: marshal.dump() 2nd arg must be file > > So is that a bug, a flaw or a feature? It's functioning as documented (read the docs), and is also functioning as designed (read next sentence), so it's not a bug. As the docs say, marshal is primarily intended for Python's own use in reading and writing .pyc and .pyo files, and, as the docs don't say, to make it as fast as possible for those purposes it doesn't support any luxuries. So it's a feature from Python's POV, but a flaw from yours. Python wins <0.9 wink>. You could do this instead: filelikeobject.write(marshal.dumps(object)) Reading a sequence of marshaled values back from a file-like object is more of a puzzle! From claird at starbase.neosoft.com Wed Jan 24 11:13:28 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 24 Jan 2001 10:13:28 -0600 Subject: what GUI, please advise References: <3A6F0B27.A88D11C9@crepido.com> Message-ID: <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7@lp.airnews.net> In article <3A6F0B27.A88D11C9 at crepido.com>, Marco =?iso-8859-1?Q?Seiri=F6?= wrote: > >There seems to be several good options to choose from when >it comes to GUI developent with Python. > >Can someone say somthing, without killing each other with flames, what >GUI one should choose? > >Stupid and impossible question by the way as everything depends as >usual... but anyway.. > >/M > No. Unless you tell us more about yourself. Do you care about portability to MacOS? Does the GNOME widget collection infatuate you? Do you prefer or disdain a GUI builder? In the meantime, -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tim.one at home.com Mon Jan 8 01:29:15 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 8 Jan 2001 01:29:15 -0500 Subject: Speed of Python vs. Perl In-Reply-To: Message-ID: [David Allen] > From what I've seen and heard, if you must have an answer, it's > probably that perl may have a slight edge. It depends very much on what you're doing (and how you're doing it ). > But realistically, the question is loaded, since python and > perl don't often do things in the same way. That's for sure. Over the past week, several wrestled (behind the scenes) with the relatively poor speed of f.readline() in Python (as compared to "" in scalar context in Perl). Turns out that the single biggest contributor to the difference is that Python reads in a threadsafe way while Perl doesn't: Python spends over half its time in system stream locking/unlocking routines called by threadsafe system getc() (and friends). Now that we know that, we were able to make large improvements (which will be in Python 2.1) -- but it will never be as fast as thread-unsafe input. it's-more-fun-to-use-python-than-to-implement-it-ly y'rs - tim From dalke at acm.org Thu Jan 11 02:05:27 2001 From: dalke at acm.org (Andrew Dalke) Date: Thu, 11 Jan 2001 00:05:27 -0700 Subject: boolean xor References: <93ace8$nmo$1@panix3.panix.com> <93i7ne$5dk$1@nnrp1.deja.com> <93i9ff$q4l$1@slb0.atl.mindspring.net> <93iuj9$jta$1@slb3.atl.mindspring.net> Message-ID: <93jls9$v12$1@slb3.atl.mindspring.net> Rainer Deyke wrote: >If you want to play that way, the previous version is also flawed: > >not ( (a and b) or (not (a or b)) ) > >In any case except where both 'a' and 'b' are true, the truth >value of 'a' is calculated twice. True, but I didn't really say that. Here's a recapitulation of the thread. Aahz said he was using: def xor(a,b): return not ( (a and b) or (not (a or b)) ) Nicolas (ndev22 at yahoo.com) suggested instead using: def xor(a,b): return not(a==b) I pointed out that Aahz's expression compares the truth value of the object and doesn't compare things them directly, so the proper form of Nicolas' code must use operator.truth. You applied DeMorgan's law to my quote of Aahz's original statement, to get: def xor(a, b): return (a or b) and not (a and b) This was a backtrack on the thread and I was actually pointing out the difference between your modified form of Aahz's code and my corrected form of Nicolas's interpretation of Aahz's. Got it? :) Andrew dalke at acm.org From rcameszREMOVETHIS at dds.removethistoo.nl Thu Jan 11 19:33:59 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Fri, 12 Jan 2001 00:33:59 GMT Subject: Speed of Python vs. Perl References: Message-ID: <902756D7rcamesz@127.0.0.1> Tim Peters wrote: >The reasons for Python's relative startup sloth have been discussed >here often; a big one is that Python runs around looking for Python >files (like site.py and sitecustomize.py) at startup, and typically >does a big pile of failing fstats while failing to find those files >along the PYTHONPATH. If that's the case, couldn't at least some of that information be cached somewhere? (Somewhat like how *.py files are bytecompiled to *.pyc files, and rebuilt as needed). Admittedly, it might not be trivial to determine when that cache file needs to be re-built. When installing something with distutils, that file could simply be deleted, of course, but there may be other issues. Robert Amesz From dan.rolander at marriott.com Sat Jan 20 13:48:58 2001 From: dan.rolander at marriott.com (Dan Rolander) Date: Sat, 20 Jan 2001 13:48:58 -0500 Subject: Using Installer with PyXML Message-ID: <02c401c08311$a66e8f00$11260340@yin> Hi Martin, Thanks for responding. Here are the specifics-- When I use a script with the statements: from xml.sax import saxexts, saxlib, saxutils and parser = saxexts.make_parser("xml.sax.drivers.drv_pyexpat") the packager (Gordon McMillan's Installer) is able to find xml.sax.saxutils, but is not able to find xml.sax.saxexts or xml.sax.saxlib which actually reside in _xmlplus.sax. I can force builder.py to include the entire _xmlplus tree by adding a packages=_xmlplus line to the [APPZLIB] section of the .cfg file, but the exe still fails because it is looking for xml.sax.*: ImportError: cannot import name xml.sax.saxexts When I rename _xmlplus to xml and then run builder again without specifying any additional packages, the EXE fails because it can't find an available parser: File "c:\program files\python20\_xmlplus\sax\saxexts.py", line 77, in make_parser xml.sax._exceptions.SAXReaderNotAvailable: No parsers found If I manually import the entire PyXML tree (now named 'xml') by adding a packages=xml line to the .cfg file, I get a little farther but now the exe isn't able to find pyexpat. ImportError: cannot import name xml.parsers.pyexpat I then try to manually import pyexpat by adding xml.parsers.pyexpat to the misc line in the [MYCOLLECT] section, but finder.py is not able to find it: File "D:\DOCUME~1\Dan\Software\Python\INSTAL~1\MEInc\Dist\finder.py", line 121, in identify ValueError: xml.parsers.pyexpat.pyd not found If I changed the .cfg line in [MYCOLLECT] to misc=pyexpat.pyd then the core \DLLs version of pyexpat.pyd is found and put into the dist directory. Now when the exe is run I get a Windows error stating that the xmlparse.dll couldn't be located. I add xmlparse.dll to the misc= line and then I get an error stating that the xmltok.dll couldn't be found. I add xmltok.dll to the misc= line and voila! it works! I then start to wonder why the exe couldn't find xml.parsers.pyexpat.pyd if I imported the entire xml tree. I study the builder.log some more and realize that it only imported .py files and not .pyd files! I tried using directories= instead of packages= and got the same results. I re-read Gordon's documentation several times and tried different combinations of .cfg statements but nothing I tried resulted in a good import of xml.parsers.pyexpat. I then replaced the core version of pyexpat.pyd in \DLLs with the PyXML version and found that I could build a good exe without having to manually include the xmlparse.dll and xmltok.dll. So my final .cfg file looks like this: [MYCOLLECT] type= COLLECT name= dist_testsax bindepends= testsax.py misc= MYSTANDALONE, pyexpat.pyd debug = 0 excludes = PyWinTypes20.dll, win32api [MYSTANDALONE] type= STANDALONE name= testsax.exe script= testsax.py zlib = APPZLIB userunw = 0 support = 0 debug = 0 [APPZLIB] name= testsax.pyz dependencies= testsax.py excludes= dospath, posixpath, macpath directories=xml Now, for another example... Another test script has the statement: from xml.parsers import pyexpat and parser = pyexpat.ParserCreate() I start with the _xmlplus directory renamed to xml, because I know that's necessary, and I build a new standalone installation. This time the pyexpat file is imported to the dist directory as xml.parsers.pyexpat.pyd but the exe won't import it: ImportError: cannot import name xml.parsers.pyexpat Renaming the file to pyexpat.pyd does not help. I add packages=xml to the .cfg file and I still have the same problem. The only fix I can figure out is to change the import statement to: import pyexpat and that works. So in summary, my tests lead me to conclude the following... To use Gordon McMillan's Installer to create standalone executables of scripts that import modules from the PyXML package, the following must be done (depending on what modules are actually being used): 1. Replace the core xml directory with the _xmlplus directory, by renaming _xmlplus to xml. 2. Copy the PyXML pyexpat.pyd file from the xml.parsers directory to the \DLLs directory. 3. If pyexpat is needed, either explicitly import it in your script, or manually include it in the standalone installation by adding an entry to the misc line in the COLLECT section of the builder .cfg file. 4. If importing from xml.sax, manually import the entire PyXML tree (source files only) by specifying either packages=xml or directories=xml in the PYZ section of the builder .cfg file. (I have not even tried using DOM yet, so I'm sure there are more issues there to be found.) I am by no means an expert on this, so if anybody understands this better and can provide simpler workarounds I would appreciate hearing it. Thanks, and I hope this helps someone! Dan ----- Original Message ----- From: "Martin v. Loewis" To: Cc: ; ; Sent: Saturday, January 20, 2001 4:55 AM Subject: Re: [XML-SIG] Using Installer with PyXML > > "The problem here has to be the way that the xml library tree is replacing > > itself with the _xmlplus tree from the later PyXML distribution. While > > runtime re-assigns xml to _xmlplus in the __init__ for xml, the import > > system used by the installation package can't track that, so it still looks > > for the actual module tree it loaded from the Python distribution beneath > > the name xml." > > I'm not sure I understand the problem. Will the packager refuse (or > forget) to package the xml package, or will it, at runtime, fail to > load it? > > If it manages to package both xml and _xmlplus: when loading xml, will > it execute xml/__init__.py? In there, there is an import of _xmlplus. > Will that succeed? If so, what happens to the lines > > import sys > sys.modules[__name__] = _xmlplus > > Will __name__ have a value of "xml"? Will the assignment succeed? > > Now, suppose we do > > from xml.sax import sax2exts > > In normal Python, this will look for sys.modules["xml"] and start from > there. Are you saying the installer does not work that way, or that > even if it starts from there, it still can't figure out to load > _xmlplus.sax? > > > So the question is, will this adversely impact normal Python operation, and > > is there a better way? > > No, replacing the Python xml package completely with _xmlplus will > work just fine - except perhaps for the pyexpat difference. > > > The other question I have is... Why are there two different pyexpat.pyd > > files, one as part of the core 2.0 distribution (at only 25 kb) and the > > other as part of the PyXML distribution in _xmlplus.parsers (at 124 kb). I > > haven't been able to get the large one to work using Installer, but the > > small core file works fine. What is the difference? > > There are two differences: the one from PyXML contains a number of bug > fixes which are not in Python 2. In addition, it contains a literal > copy of the expat libraries, so that the expat DLLs in the Python core > should not be needed anymore. > > When you say "get the large one to work", what exactly have you tried, > and how exactly did it fail? > > Regards, > Martin > From ssthapa at harper.uchicago.edu Sun Jan 21 11:29:24 2001 From: ssthapa at harper.uchicago.edu (ssthapa at harper.uchicago.edu) Date: Sun, 21 Jan 2001 16:29:24 GMT Subject: Python and Industry, IBM I'm afraid References: <20010111172342.10148.00000934@ng-ca1.aol.com> <3A63D9E8.F9B74ACE@mjs400.co.uk> Message-ID: Martin von Loewis wrote: >grante at visi.com (Grant Edwards) writes: > >> How many Universities teach Python? > >I don't have a number, but I know that I do. I know at least some of the classes at the University of Chicago encourage or use python (e.g. Network Programming) but I think that's because David Beazley was teaching it. -- ---------------------------------------------------------------------------- | Suchandra Thapa | "There are only two kinds of math . s-thapa-11 at NOSPAMalumni.uchicago.edu | books. Those you cannot read beyond | the first sentence, and those you | can not read beyond the first page." | -C.N. Yang ---------------------------------------------------------------------------- From donn at oz.net Wed Jan 17 02:10:41 2001 From: donn at oz.net (Donn Cave) Date: 17 Jan 2001 07:10:41 GMT Subject: Interacting with a spawned ssh session? References: <3A63781F.D8CDB6DC@sas.upenn.edu> Message-ID: <943ghh$e7g$0@216.39.151.169> Quoth "Steven M. Castellotti" : | I'm having two problems with one function. | | I want to be able to spawn an ssh session to another computer, and then | interact with that session through python commands. (this is on a linux | system) | | The first problem is feeding the password to ssh; I believe that it | wants it's own tty. | | The second problem, and currently the more pressing one, is how to best | send commands to that ssh session, and read back/parse the results. | | I've looked at the pty module, but must not be understanding its | functionality, as I can't get a pty.fork()'d file descriptor to allow me | to perform commands. I'd like to keep away from popen (for security | reasons, though I'm not certain any other method could be considered | secure either), but am still having trouble interacting with the spawned | process (in this case a telnet session; for simplicity). | | Can anyone provide me with, or point me to, any examples of how to use | python to do roughly what I'm describing? I don't have anything at hand, but think it might help to mention that there's old pty functionality in Python 1.5, and newer stuff in 2.0. If you haven't upgraded to 2.0, this would be a good time to think about it. As for pty.fork(), I guess I wouldn't expect it to allow you to perform commands, so to speak, because it doesn't exec any command interpreter. spawn() might be more useful. And of course for the obligatory anti-password message, instead of RSA keys I like Kerberos authentication, and that will work with ssh, telnet etc. if your site is enlightened enough to support Kerberos 5. Donn Cave, donn at u.washington.edu From mmiller3 at iupui.edu Fri Jan 5 18:43:04 2001 From: mmiller3 at iupui.edu (Michael A. Miller) Date: 05 Jan 2001 18:43:04 -0500 Subject: examples of PIL and paletts? References: <87k8898v0p.fsf@lumen.med.iupui.edu> Message-ID: <87d7e18t13.fsf@lumen.med.iupui.edu> >>>>> "Michael" == Michael A Miller writes: > Can anyone point me to an example of using paletts and > image mode 'P' with PIL? To be more specific, I have grey scale images for which I've calculated an equalized lut. I'd like to view the image using that lut, so I try this: >>> import Image, ImagePalette, Numeric >>> im = Image.open('lena.jpg') >>> im.show() >>> im2 = im.convert('P') >>> lut = equalize(im2) >>> p = ImagePalette.new('RGB',lut) Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/site-packages/PIL/ImagePalette.py", line 57, in new Image.core.new_palette(mode, data) AttributeError: new_palette What I'm looking for is an example of how to apply a new lut to an existing image. Any hints? Mike From erno-news at erno.iki.fi Tue Jan 9 12:28:05 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 09 Jan 2001 19:28:05 +0200 Subject: Web devel with python. Whats the best route? References: <93dfqm07la@news1.newsguy.com> Message-ID: In article , Moshe Zadka writes: | [Alex Martelli] || I know I'm confused, but, isn't mod_apache some other Apache || module (that, I think, has something to do with configuring the || webserver itself)? How does it supersede PyApache? Tx for || clarifications on this...! | mod_* in Apache can be compiled both statically into Apache and dynamically. i think the confusion stems from the original poster having said mod_apache when he meant mod_python. indeed mod_apache has nothing to do with anything :) -- erno From wsryu at is05.fas.harvard.edu Tue Jan 23 19:26:32 2001 From: wsryu at is05.fas.harvard.edu (William Ryu) Date: 24 Jan 2001 00:26:32 GMT Subject: Tkinter spreadsheet or textgrid widget? Message-ID: <94l7fo$k6k$1@news.fas.harvard.edu> Tried a Google search but didn't come up with anything. Can someone point me to a Tkinter textgrid (i.e. spreadsheet type text/number entry) widget? Thanks, -willryu From thomas at xs4all.net Sat Jan 27 10:56:06 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 27 Jan 2001 16:56:06 +0100 Subject: . Python 2.1 function attributes In-Reply-To: ; from katz@Glue.umd.edu on Sat, Jan 27, 2001 at 09:42:17AM -0500 References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> Message-ID: <20010127165606.O962@xs4all.nl> On Sat, Jan 27, 2001 at 09:42:17AM -0500, Roy Katz wrote: > Didn't you feel it already? > The language was going to hell even before print>> was added. Change always ruins everything. Keyword arguments ?!? Who needs those. Lets go back to Python 1.3. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From moshez at zadka.site.co.il Tue Jan 30 13:30:10 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 30 Jan 2001 20:30:10 +0200 (IST) Subject: . Python 2.1 function attributes In-Reply-To: <955umt0923@news2.newsguy.com> References: <955umt0923@news2.newsguy.com>, <95432j014on@news2.newsguy.com>, Message-ID: <20010130183010.3E0A6A840@darjeeling.zadka.site.co.il> Haha! You had a *really* weak argument! On Tue, 30 Jan 2001 09:41:02 +0100, "Alex Martelli" wrote: > Take Stackless, for example. Have you ever heard arguments against > it from anybody WITH experience using it? So, IF "arguments from > experience" were indeed decisive, *WHY* isn't it in the core? Because Gordon McMillan seems to have been too busy with other things to finish up the PEP. That's an easy one. In other words, there is no one for whom having stackless is so important that he took the time to try to take the PEP from Gordon, and champion it to conclusion. This is in contrast to the print>> PEP, where it was important enough to Barry to do all the work, the arguing and the shameless bribery . For the record, I want stackless in the PEP too -- but it is not that important to me that I want to pony up the time either. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From s2mdalle at titan.vcu.edu Sat Jan 20 01:30:13 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Sat, 20 Jan 2001 06:30:13 GMT Subject: Questions on Python References: Message-ID: In article , "Sam" wrote: > Hi everyone, > I have never really programmed before but I'm very interested in it. My > main goal is to be able to eventually program simple games to fool around > with. I have read that Python is a good language to learn on because it > makes learning other languages easier. I want to ask how should i go about > learning this language? Should I read tutorials online (any good ones i > should check out?) or buy some books (which ones?)? Is this language good > for any programming goal or is it mainly for a certain area? What ways can i > make learning this the easy? Thank you for replies =) I'd say python is good for general purpose programming. Certainly what you're interested in doing python can do quite well. Check out "Learning Python" for a book to read. It will introduce you to programming in python. As for making learning easy, it isn't particularly. Program a lot, and you'll improve. -- David Allen http://opop.nols.com/ ---------------------------------------- Dejamoo - the feeling that you've heard this bull before. From mwh21 at cam.ac.uk Fri Jan 26 09:52:49 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 26 Jan 2001 14:52:49 +0000 Subject: python-2.1 function attributes References: <94s0r0$elb5e$1@ID-11957.news.dfncis.de> Message-ID: "Emile van Sebille" writes: > I also like it without the dot, as it opens the door to > allowing *args and **kwargs style parameter passing > interpretation. What would that mean? def f(*a=1): print 1 is a syntax error today... Cheers, M. -- ROOSTA: Ever since you arrived on this planet last night you've been going round telling people that you're Zaphod Beeblebrox, but that they're not to tell anyone else. -- The Hitch-Hikers Guide to the Galaxy, Episode 7 From sholden at holdenweb.com Wed Jan 3 01:33:06 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 3 Jan 2001 01:33:06 -0500 Subject: ~Python ? References: <3a4833f8.346848@news.t-online.de> <3A484B39.A16C0B99@python.net> Message-ID: Thomas A. Bryan wrote in message news:3A484B39.A16C0B99 at python.net... > Gerson Kurz wrote: > > [snip] > Wouldn't os.environ['HOME'] be an acceptable way of handling this problem? > I'm not sure whether such a variable is available under other OSs, such as > Windows, but at least environment variables are available under Windows. > I think that '~' is a foreign concept to non-UNIX users. (ActivePython is > a Windows distribution of Python, right?) > ActivePython is actually available for Linux, Solaris and Windoze (although of course there's little point expecting Win32 support in the former two platforms, unless Wine and WABI have come a lot further than I thought :-) regards Steve From sheila at spamcop.net Thu Jan 25 01:35:43 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 25 Jan 2001 06:35:43 GMT Subject: beep again References: <5251-3A6E5B71-16@storefull-163.iap.bryant.webtv.net> <94n5td$gu1$1@nnrp1.deja.com> <3A6F7BE3.98CFC640@uol.com.br> Message-ID: On Wed, 24 Jan 2001 23:05:39 -0200, Cesar Rabak wrote in comp.lang.python in article <3A6F7BE3.98CFC640 at uol.com.br>: :Mark Hammond wrote: :> :> In article <5251-3A6E5B71-16 at storefull-163.iap.bryant.webtv.net>, :> clickron at webtv.net wrote: :> > Thanks for answering my last question. I get the beep now, but no :> matter :> > what numbers I put in for the frequency and duration it doesn't :> change. :> :> The Python test suite has the following: :> :> import winsound :> for i in range(100, 2000, 100): :> winsound.Beep(i, 75) :> print "Hopefully you heard some sounds increasing in frequency!" :> :> This does the "right thing" on both Python 2.0 and 2.1a1 :> : :Well, in ActivePython 2.0, build 202, it only runs a ding.wav from :windows. (Win98 SE). Yes, that is what I'm hearing, as well. Moreover, this loop didn't even loop for me. It gave a single ding.wav and quit. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From LangaK at discoveryhealth.co.za Wed Jan 17 04:29:02 2001 From: LangaK at discoveryhealth.co.za (Langa Kentane) Date: Wed, 17 Jan 2001 11:29:02 +0200 Subject: parsing a file [newbie] Message-ID: ONe thing I don't understand. When I run os.popen('df -h'), this returns a pointer to an already open file if I am not mistaken. Now, to apply what you gave me to this scenario, how would I go about it. I am confusing myself silly here. Please help. -----Original Message----- From: Nils Hensel [mailto:nils at hhk.de] Sent: 17 January 2001 11:03 To: python-list at python.org Subject: Re: parsing a file [newbie] import os my_command = "/whatever/you/like" open ("output", "w").write (os.popen (my_command).read()) y = open ("output").read().split() [2] Hope this works, I haven't tried it. This is quick and dirty though, better implement some error checking. Nils "Langa Kentane" schrieb im Newsbeitrag news:mailman.979720698.24494.python-list at python.org... > How do I read a file. > This is what I want to do. > Run a command using os.popen and store the file info that it returns to x > Open file x and read the contents.[ contents of x will be a mount output.] > Go to the third column of the mount output and and store in y > > How would I go about doing this. > > __________________________________________________________ > Langa Kentane | TEL: (011) 290 3218 > Security Administrator | Cell: 082 606 1515 > DISCOVERY HEALTH | http://www.discoveryhealth.co.za > __________________________________________________________________ > > -- http://mail.python.org/mailman/listinfo/python-list From thomas at xs4all.net Thu Jan 4 14:32:32 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 4 Jan 2001 20:32:32 +0100 Subject: 2001 Enchancement Wishlist In-Reply-To: <008601c07675$0adf2020$102b2bc1@cadlab.it>; from aleaxit@yahoo.com on Thu, Jan 04, 2001 at 06:37:41PM +0100 References: <3A4CEACB.220998A0@javanet.com> <92j83r13gh@news1.newsguy.com> <20001231175940.A5435@xs4all.nl> <008301c07501$c036ae40$43931497@martelli> <20010104165116.F2467@xs4all.nl> <008601c07675$0adf2020$102b2bc1@cadlab.it> Message-ID: <20010104203232.P402@xs4all.nl> On Thu, Jan 04, 2001 at 06:37:41PM +0100, Alex Martelli wrote: > "Thomas Wouters" writes: > A module object, in contrast, has no such flexibility. It can of > course have *attributes*, which, as they can be anything (in particular, > they can be class-instances), are as flexible as can be -- but it > cannot present any 'face' to client-code, except its own. Nor is it intended to. Nor should you ever *want* to. *That* is why I don't understand your problem with me saying that it's perfectly possible to use a module namespace to provide singletons. I don't give a gerbil's tush about semantics myself. I was merely making clear what /F suggested: use a module namespace to expose singletons -- and I still don't understand what your problem is with that. The rest of the disagreement is based solely on a different view of Python and all its aspects. I won't dispute it, mostly because I don't feel like trying to understand it right now, sorry :) My view of Python is very simple, it works for me, and I have wish nor time to broaden it now for sake of aesthetic semantics :) Simplicity-is-Python's-main-attraction-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tim.one at home.com Mon Jan 29 21:47:42 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 29 Jan 2001 21:47:42 -0500 Subject: marshal doesn't work with "file-like" objects In-Reply-To: Message-ID: [/F] > Note the second part ("more of a puzzle" is a polite way to say > "impossible, if you care about performance"). [Tim] > That wasn't my intent ... [/F] > how about "impossible, if you care about performance, and > don't want to invent yet another file format". s/file format/filelike format/ and we're golden . From erno-news at erno.iki.fi Wed Jan 10 20:14:48 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 11 Jan 2001 03:14:48 +0200 Subject: zodb & multiple processes Message-ID: hello, from the looks of things, zodb is thread-safe in that you can use connections to the same storage from many threads at once and have it not break. how about multiple processes? will it just work, just not work, or require special incantations? -- erno From dnew at san.rr.com Wed Jan 17 12:38:37 2001 From: dnew at san.rr.com (Darren New) Date: Wed, 17 Jan 2001 17:38:37 GMT Subject: help with code for combinations/permutations References: <944adl$2bf@dispatch.concentric.net> Message-ID: <3A65D89D.E8366B3D@san.rr.com> Another way of doing this is to recognise that if you have all the permutations of (1,2,3), you can get all the permutations of (1,2,3,4) by inserting a "4" in each possible point in the permutations you already have. In other words, it's almost trivial to reduce recursively. Oh, and it's a 1-liner in APL. ;-) Bryan Webb wrote: > I need to come up with all possible combinations of the numbers in the above > list ie. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. "It says this wine has syphilis." "I think that's pronounced `sulphates'." From hunter at userfriendly.net Mon Jan 15 06:45:22 2001 From: hunter at userfriendly.net (hunter) Date: Mon, 15 Jan 2001 06:45:22 -0500 Subject: Netscape Enterprise Server 4.1 References: <3A62DC37.5A5A5294@eurodyn.com> Message-ID: <3A62E2D2.7DFA89EC@userfriendly.net> I certainly hope so, and i am hoping that it works in the reverse as well. I have 200 web servers running netscape enterprise server v4.1sp2 that i NEED to convert to apache with python (most likely mod_python) in order to save on the cost of the licenses for NES. They are around $1295 per cpu per server which is extremely cost-prohibitive. However i am struggling trying to get our main application driver (py-driver) to act as a cgi as we have it configured for NES. Michael Weiner Systems Administrator/Partner The UserFriendly Network -- Vasilis Giannikopoulos wrote: > > Does anyone know if a Python script that is now running on Apache could > also run on Netscape Enterprise Server 4.1 without modifications or run > at all? > > Thank you. > > Aki -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2626 bytes Desc: S/MIME Cryptographic Signature URL: From sandj.williams at gte.net Tue Jan 2 16:21:49 2001 From: sandj.williams at gte.net (Steve Williams) Date: Tue, 02 Jan 2001 21:21:49 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> Message-ID: <3A5247A9.236E0700@gte.net> Grant Edwards wrote: > [slash] > > The problem is that when you decide to change the endpoint from > 25 to something else, you _may_ have to change the code in two > places: the test and the initialization. If you decide to > raise the endpoint from 25 to 50, you only have to change one > line. If you want to lower it you might have to change the > initialization also. > > Requiring edits to two possibly widely seperated places in the > source code to change a single algorithm value is (in my > experience) going to cause a bug some day. > [more slash] Ah, but variables are magic things: intFoo = 25 intBar = 75 While intFoo < intBar: intFoo . . . Wiring constants in the code (and maintaining them in multiple places) is for the laity. Do !do it. From lele at seldati.it Mon Jan 8 20:16:14 2001 From: lele at seldati.it (Lele Gaifax) Date: 09 Jan 2001 02:16:14 +0100 Subject: Web devel with python. Whats the best route? In-Reply-To: "Alex Martelli"'s message of "Mon, 8 Jan 2001 23:37:54 +0100" References: <93dfqm07la@news1.newsguy.com> Message-ID: >>>>> On Mon, 8 Jan 2001 23:37:54 +0100, "Alex Martelli" said: AM> "Moshe Zadka" wrote in message AM> news:mailman.978936788.24717.python-list at python.org... [snip] >> The only thing I'm pretty certain about is that PyApache has >> been AM> superseded >> by mod_apache. Other then that, all have strong points, so you >> should pick AM> I know I'm confused, but, isn't mod_apache some other Apache AM> module (that, I think, has something to do with configuring AM> the webserver itself)? How does it supersede PyApache? Tx AM> for clarifications on this...! It may be, in the sense that it's a superset of PyApache. Never checked nor used the other modules, so I may be wrong. The goal of PyApache was fast execution of standard CGIs, and that's it. For more esotheric capabilities, I preferred Zope. bye, lele. -- nickname: Lele Gaifax | Quando vivro' di quello che ho pensato ieri real: Emanuele Gaifas | comincero' ad aver paura di chi mi copia. email: lele at seldati.it | -- Fortunato Depero, 1929. From quinn at chunder.ugcs.caltech.edu Sat Jan 27 22:23:31 2001 From: quinn at chunder.ugcs.caltech.edu (Quinn Dunkan) Date: 28 Jan 2001 03:23:31 GMT Subject: c(++)python? References: Message-ID: On Sat, 27 Jan 2001 02:20:54 -0500, Tim Peters wrote: >Given the number of odd platforms Python is ported to, C++ would still be a >major gamble. If history repeats, around 2010 we'll insist that people >finally use a 1999-flavor ANSI C compiler (although there's some doubt that >vendors will actually implement all of C99). As someone who uses python on a platform with no C++ compiler, and which is unlikely to ever have a C++ compiler, I'm quite glad python is in plain old C. Consider that anyone who wants any level of backward compatibility for their OS is going to have to port or write a C compiler (and some minimal posix emulation). Writing a C compiler is not trivial, but it's presumably well understood by now, and a lot easier than writing one for a complex, higher-level-but-must-be-performant language. Writing a C++ compiler is a lot more work than most people working on new platforms are willing to go to for mere backward compatibility :) >still-if-you-reimplement-python-in-c++-please-post-the-patch- > to-sourceforge-ly y'rs - tim Not that I'm arguing against python/c++ interoperability, anything that can improve that is great. I don't currently and may never write in java, but I'm glad jpython exists, because someday I might have to and then I'll be glad to have python around :) From tepperly at llnl.gov Wed Jan 3 18:18:58 2001 From: tepperly at llnl.gov (Tom Epperly) Date: Wed, 3 Jan 2001 15:18:58 -0800 (PST) Subject: Registering C methods when writing a C extension type? Message-ID: I planning to write a C extension type (not module) to provide a Python binding for an object or interface defined in an IDL (interface definition language) for high performance scientific computing. In the example from Mark Lutz's Programming Python (the only documentation I've found that directly addresses writing extension types), it does something like the following to make the object methods visible (in myobject.c): static struct PyMethodDef myobject_methods[] = { {"method_one", (PyCFunction)method_one, 1}, {"method_two", (PyCFunction)method_two, 1}, {"method_three", (PyCFunction)method_three, 1}, {NULL, NULL} }; static PyObject * myobject_getattr(myobject *self, char *name) { /* other stuff deleted */ return Py_FindMethod(object_methods, self, name); } /* tp_getattr points to myobject_getattr */ I am wondering what the relative merits/penalties of doing something like the following in the constructor for the hypothetical myobject instead of the above. I would like feedback about issues of style (am I violating the designers intent or using functions intended for internal use only), forward/backward portability, and efficiency. static myobject * new_myobject() { myobject *self; const int len = sizeof(object_methods)/sizeof(PyMethodDef); int i; self = PyObject_NEW(myobject, &myobjecttype); if (self == NULL) return NULL; for(i = 0 ; i < len ; i++){ PyObject *func = PyCFunction_New(object_methods + i, self); if (func != NULL) { PyObject_SetAttrString(self, object_methods[i].ml_name, func); Py_DECREF(func); /* remove extra reference */ } } return self; } In this case, the getattr method does not call Py_FindMethod. Tom -- ------------------------------------------------------------------------ Tom Epperly Center for Applied Scientific Computing Phone: 925-424-3159 Lawrence Livermore National Laboratory Fax: 925-424-2477 L-661, P.O. Box 808, Livermore, CA 94551 Email: tepperly at llnl.gov ------------------------------------------------------------------------ From loewis at informatik.hu-berlin.de Sat Jan 20 18:40:23 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jan 2001 00:40:23 +0100 Subject: Distribution issues References: Message-ID: D-Man writes: > To distribute, you simply jar your files together and ship it. The > user still needs a JVM, but that isn't a big issue (to me). (Jar is > very similar to tar or zip) The more tricky issue about jar file is that the JVM has to find them. This is typically done by setting the CLASSPATH, but, in my experience *not* to the directory containing the jar file, but to the jar file itself. Of course, there are also standard locations - you just have to know what they are as an administrator. > Is there a similar thing for python? Not quite the same, but there is distutils. Do python setup.py install and distutils will put everything in place, without the administrator knowing a thing about python. Regards, Martin From fakeaddress at nospammail.com Wed Jan 31 17:54:55 2001 From: fakeaddress at nospammail.com (Ben Catanzariti) Date: Thu, 1 Feb 2001 09:54:55 +1100 Subject: Design for slices References: <959uue$k02$1@cubacola.tninet.se> Message-ID: I am fairly sure this came about due to the fact you are defining a position of a pointer, not an object ie. a letter in a string. So position x[0] means the pointer has not moved or has a null value and will occur directly before the first letter in a string.... Some one please correct me if i am wrong ... I am sure you will ;) "Gustaf Liljegren" wrote in message news:959uue$k02$1 at cubacola.tninet.se... > I'm learning Python and have a question about defining ranges/slices in > strings. I can't find any defence for what looks like a poor design, so I > have to ask. Why is the first character in the string x defined as x[0] and > not x[1]? This looks just like the typical geek thinking that I'm trying to > avoid with Python. > > Gustaf From jpet at eskimo.com Wed Jan 24 03:22:52 2001 From: jpet at eskimo.com (Jeff Petkau) Date: Wed, 24 Jan 2001 08:22:52 GMT Subject: How do I know all thrown exceptions of a function? References: <94imre$7dd$1@slb6.atl.mindspring.net> Message-ID: Andrew Dalke wrote in message news:94imre$7dd$1 at slb6.atl.mindspring.net... > def integrate(func, x_min, x_max): > ... > will compute func(x) for several values of x between [x_min, x_max] > ... > > What exceptions does "integrate" throw, given that "func" can > throw anything? As I understand the Java way, you must declare > all of the exceptions thrown by "func", which most people will > take to mean it only throws a math error (divide by zero, overflow, > etc.). Once the "func" exceptions are known, the "integrate" > ones are also known. >... > I actually don't know. As far as I can tell, the only way to > do it is let integrate raise a specific "CannotIntegrate" > exception, then implement a wrapper, like for MyCache, which > converts any non-numeric exception in the CannotIntegrate > exception, as in > > To me, this is ugly and error prone. (Is this really what > you need to do for Java - the Feb. Dr. Dobb's comparison > between Java and C# suggests so.) Thus, I would rather write > my code to be exception safe, in that it gracefully accepts > any exception, then to declare every exception type. Since all exceptions in Java are derived from java.lang.Throwable, you could just declare integrate() as throwing Throwable. So you're effectively declaring, "this function can throw any damn fool thing, you deal with it." I think it's a good solution, although parameterized types would be better. (So you could say "this function throws whatever func throws.") --Jeff From phd at phd.pp.ru Fri Jan 26 07:55:52 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 26 Jan 2001 15:55:52 +0300 (MSK) Subject: Database-like module in Python? In-Reply-To: <20010126091824.25080.qmail@nwcst289.netaddress.usa.net> Message-ID: On 26 Jan 2001, Def P wrote: > Is there something database-like written in Python that I can use? I looked at > dbm & friends, can they be used for this purpose? (I don't know much about > them; since I am not on Unix, only dumbdbm seems to work for me.) dbm family (dbm, gdbm, Berkeley DB) are exactly dictionaries; they just store info in files. (The last one, BSDDB, is more advanced). There is also Metakit - similar to dbm, but operates with tables. You can also use Gadfly - pure python SQL engine. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From scarblac at pino.selwerd.nl Thu Jan 18 18:35:47 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 18 Jan 2001 23:35:47 GMT Subject: This is my first program in Python References: <3a66a585.268350144@news.tcn.net> Message-ID: Steve Holden wrote in comp.lang.python: > The assignment has deliberately been designated a statement rather than an > expression, > The standard idiom for doing this with a while would be (untested): > > while 1: > line = file.readline() > if line == '': > break > first, second = line.split(':', 1) > print first > > Some people don't like this. It's not going to change :-) But in 2.1, there will be xreadlines(), readlines() without slurping the whole file into memory, which will at least make this idiom unnecessary in the common case of reading a file line by line :-). -- Remco Gerlich From aleaxit at yahoo.com Thu Jan 4 12:42:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 18:42:50 +0100 Subject: Unexpected result for list operator "+=" References: <3A542778.E1BC06E3@bogusaddress.com> <9320ei02tic@news2.newsguy.com> <20010104175855.I2467@xs4all.nl> Message-ID: <008d01c07675$c25c3d50$102b2bc1@cadlab.it> "Thomas Wouters" writes: [snip] > > http://www.python.org/doc/current/ref/sequence-types.html > > > > """ > > Finally, sequence types should implement addition (meaning concatenation) > > [snip] > > by defining the methods __add__(), __radd__(), __iadd__(), > > """ > > (it continues by saying the methods are 'described below', > > but, they aren't). [snip] > *That* is fixed in the newer docs. If you find a good place to add a list's > *=/+=, let me know. (Is the non-augmented * or + documented anywhere ?) Not that I can see -- the "described below" I mentioned also refers to the non-augmented versions. Maybe, if 3.3.6 is now complete, it might suffice to change 'described below' to 'described in ', as 3.3.4 already mentions "addition (meaning concatenation) and multiplication (meaning repetition)". Does the C API manual also now mention the augmented operations...? Alex From claird at starbase.neosoft.com Tue Jan 23 09:36:37 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Jan 2001 08:36:37 -0600 Subject: Complete list of Python IDEs References: Message-ID: <25708BF4E69C79D8.642051B7F9A3B6D4.27F3341E69B04670@lp.airnews.net> In article , Albert Hopkins wrote: > >I know there are a few open source and commercial Python-ware IDEs >available, but does there exist a list somwhere comparing features as well >as contact info? . . . I know of none. If you or another enthusiast chooses to write it, though, I'm sure we can find at least one outlet to publish it. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From baasad at qualitynet.net Mon Jan 29 19:41:29 2001 From: baasad at qualitynet.net (bashar A. Asad) Date: Tue, 30 Jan 2001 03:41:29 +0300 Subject: what GUI, please advise References: <3A6F0B27.A88D11C9@crepido.com> <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7@lp.airnews.net> Message-ID: <955na0$m4r2@news.qualitynet.net> try blackader by http://www.thekompany.com it supports Qt lib cheers ---------- In article <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7 at lp.airnews.net>, claird at starbase.neosoft.com (Cameron Laird) wrote: > In article <3A6F0B27.A88D11C9 at crepido.com>, > Marco =?iso-8859-1?Q?Seiri=F6?= wrote: >> >>There seems to be several good options to choose from when >>it comes to GUI developent with Python. >> >>Can someone say somthing, without killing each other with flames, what >>GUI one should choose? >> >>Stupid and impossible question by the way as everything depends as >>usual... but anyway.. >> >>/M >> > > No. > > Unless you tell us more about yourself. Do you care about > portability to MacOS? Does the GNOME widget collection > infatuate you? Do you prefer or disdain a GUI builder? > > In the meantime, > > -- > > Cameron Laird > Business: http://www.Phaseit.net > Personal: http://starbase.neosoft.com/~claird/home.html From ray_drew at yahoo.co.uk Mon Jan 29 05:24:30 2001 From: ray_drew at yahoo.co.uk (Ray Drew) Date: Mon, 29 Jan 2001 10:24:30 GMT Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> <3a685ef2.3403798@reading.news.pipex.net> <949rii0a76@news1.newsguy.com> <3a6eb2fa.2347467@reading.news.pipex.net> Message-ID: <3a7542d7.2738309@reading.news.pipex.net> On Wed, 24 Jan 2001 07:18:19 -0800, Neil Schemenauer wrote: >really necessary. Here is the Python line from my .vimrc: > > au BufEnter *.py set sw=4 sts=4 et ai cindent cino=(0 cinkeys=!^F,o,O tw=74 > >The cindent options make Vim indent similarly to python-mode in >Emacs. > > Neil > I'm now running with au BufEnter *.py set sw=4 sts=4 et ai cindent cino=(0 cinkeys=!^F,o,O tw=74 in my _vmrc file, but this is the behaviour I'm getting... def fun(x): (1) if x: (2) y (3) else (4) after line 1, cursor is in leftmost position, I have to tab to indent the if block. after line 2, cursor under the i of if, I have to tab again for the next line. after line 3 , cursor is under the y. I now need to backtab for the else but can't use the backspace key to do it, I either have to hit the 'home' key to get to the start of the line and then tab my way back or switch to command mode and hit the 'h' key 4 times (or hit the left arrow key 4 times in 'insert' mode). The behaviour I'd like is for the cursor to autoindent for lines 2 and 3 and for the backspace key to move me back a tab in line 4. Can I get gvim to work like this? I've tried using si instead of ci and I've tried setting cinw to the python keywords that require indenting on the following line. I've got syntax on. Thanks for any help, Ray From sav at ulmen.mv.ru Thu Jan 25 01:58:26 2001 From: sav at ulmen.mv.ru (Alexander Semenov) Date: Thu, 25 Jan 2001 09:58:26 +0300 Subject: urllib.urlretrieve("http://free.bsdshell.net/") References: Message-ID: <94oiss$1hm2$1@news1.simtel.ru> "Oleg Broytmann" wrote in message news:mailman.980354711.2588.python-list at python.org... > On 24 Jan 2001, Erno Kuusela wrote: > Then the site filters me out just because, without any reason :))) But > it rejects only urllib - any browser will do its job right! Try to run 'telnet yoursite', then blindly type 'GET /index.html' and press Enter twice. Then try to use sockets module instead urllib to connect to site. Check for proxy settings in browser and http_proxy environment variables on your system. Hope it helps. SY, Alexander Semenov . From garabik-news at spam.melkor.dnp.fmph.uniba.sk Wed Jan 17 07:34:46 2001 From: garabik-news at spam.melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: 17 Jan 2001 12:34:46 GMT Subject: Curses module for Python 2.0 for Windows NT References: Message-ID: <979734821.7106@cdwork.cvt.stuba.sk> jurgen.defurne at philips.com wrote: : Dear all, : I am busy automating tasks across some Windows NT workstations, where : I control another program (Continuus/CM, if any one knows that). : Unfortunately, that control is not that easy. Ihave built a GUI interface, : but I am not really satisfied with it, so I want to simplify it somewhat so that : it can run in a DOS box using curses. Is there a curses add-on available : for the Win32 binaries ? It sure isn't part of the distribution I am using, : which is still the BeOpen version of Python 2.0 why I have such a feeling I saw (and answerred) the very same question some months ago? :-) see http://www.mikroplan.com.pl/~mak/python/ -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ melkor.dnp.fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From moshez at zadka.site.co.il Wed Jan 31 15:36:34 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 31 Jan 2001 22:36:34 +0200 (IST) Subject: readline: custom keywords In-Reply-To: References: Message-ID: <20010131203634.DCC4FA83E@darjeeling.zadka.site.co.il> On Tue, 30 Jan 2001 12:10:26 +0100, Michal Bozon wrote: > Is `readline' library designed only for interactive python, > or is it also possible to use it in own programs with own keywords? It is certainly possible! See the rlcompleter module. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From db3l at fitlinxx.com Tue Jan 23 22:37:06 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Jan 2001 22:37:06 -0500 Subject: Can I decompile PYC files? References: <94j8j5$50e$1@nnrp1.deja.com> Message-ID: jon at bezek.dstc.monash.edu.au (Jonathan Giddy) writes: > You can try using decompyle, which can be found using any search engine. One minor item - if you're running under Windows, it looks like a small tweak to decompyle.py (line 108 in _load_module) is necessary to change the open to use binary mode ('rb'). Otherwise, seems to work nicely. -- -- 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 rcameszREMOVETHIS at dds.removethistoo.nl Wed Jan 10 08:10:46 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Wed, 10 Jan 2001 13:10:46 GMT Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com> <93dfft077p@news1.newsguy.com> <93f4q7$ji4$1@newshost.accu.uu.nl> Message-ID: <90259B539rcamesz@127.0.0.1> Martijn Faassen wrote: > [Snip] > >Dus, voorwaards met dat Nederlands! --------^- Well, one can but hope... Robert Amesz From phd at phd.pp.ru Mon Jan 15 06:25:36 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 15 Jan 2001 14:25:36 +0300 (MSK) Subject: ALARM on windows? In-Reply-To: <93ukvl$cdp$1@news0.skynet.be> Message-ID: On Mon, 15 Jan 2001, Kalista Christophe wrote: > I'd like to do the following : A python script listens to port 6664(for > example). When it gets a connection, it then sets an alarm handler and then > tries to read from the socket. If it does not get data within 10 seconds, it > then times out, at which point the alarm handler throws an axception and > aborts the socket read. Use timeoutsocket from http://www.timo-tasi.org/python/ Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From grante at visi.com Tue Jan 23 10:47:25 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 23 Jan 2001 15:47:25 GMT Subject: serial i/o under linux? References: <94igau$h6i$1@nnrp1.deja.com> Message-ID: In article <94igau$h6i$1 at nnrp1.deja.com>, henry_crun3583 at my-deja.com wrote: >Can anyone give an example of simple serial port ops under linux? I wrapped it up in the simplest way I could at ftp://ftp.visi.com/users/grante/python/PosixSerial.py There is no documentation other than example usage in a dumb little GTK based terminal emulator: ftp://ftp.visi.com/users/grante/python/lcom.py >ie I want to write a string, and readlines until done or timeout.... You can do the timout using select or by using the serial driver timout funcitonality (man termios). -- Grant Edwards grante Yow! Why don't you at ever enter and CONTESTS, visi.com Marvin?? Don't you know your own ZIPCODE? From peter at engcorp.com Sat Jan 27 03:20:39 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 27 Jan 2001 03:20:39 -0500 Subject: undefined variable References: Message-ID: <3A7284D7.FEDA433@engcorp.com> shaka wrote: > > hi, I am a beginner learning python, and I have notice that in python > variale are not declared or defined. But does it mean that your cannot use > the same variable twice and all your variable have to be of different name. > In java you can have a variable of the same name but of different type and > it makes programming much more flexible. It sounds like you are looking for the concept called "namespaces", or perhaps "scope". Java can have variables of the same name but different type defined *in different places*, such as in two separate methods. Python is no different in this respect. Or did I misunderstand your (unclear) question? From roger_callisto at hotmail.com Wed Jan 3 11:24:53 2001 From: roger_callisto at hotmail.com (Peter Yu) Date: Wed, 03 Jan 2001 16:24:53 GMT Subject: Embedded Python Question Message-ID: <92vjob$8rh$1@nnrp1.deja.com> Hello, I've decided to do an environment that allows for Python scripts to run in a specific directory with object-level file security. RExec appears to be my best option. So far, I've been able to change the "root" directory of all file operations to the desired directory... However, when I tried to add file access restrictions for specific objects, I'm stumped -- Normally, I'd have used the call stack to determine access privilages, but the call stack is unavailable inside the RExec environment... Does anyone have any suggestions on what else I could do? Thanks in advance, Peter Sent via Deja.com http://www.deja.com/ From johnvert at my-deja.com Sat Jan 20 13:38:56 2001 From: johnvert at my-deja.com (johnvert at my-deja.com) Date: Sat, 20 Jan 2001 18:38:56 GMT Subject: about DOM. Message-ID: <94cm00$t4m$1@nnrp1.deja.com> Hi, I just read up some intro documents about DOM. It seems like a really cool idea, but I haven't heard of anybody using it--doesn't seem to come up a lot. I was wondering what are people using it for nowdays, and how I can access it from Python code. Thanks, -- John Sent via Deja.com http://www.deja.com/ From sheila at thinkspot.net Sun Jan 21 00:30:03 2001 From: sheila at thinkspot.net (Sheila King) Date: Sun, 21 Jan 2001 05:30:03 GMT Subject: Translating a Perl script into Python References: <94d4hk$1sq$1@animus.fel.iae.nl> <94ddks$ff9$1@nnrp1.deja.com> Message-ID: <4tsk6t8ia6j55c1luv9l9tdqdfd6ljs8aj@4ax.com> On Sun, 21 Jan 2001 01:22:40 GMT, Hamish Lawson wrote in comp.lang.python in article <94ddks$ff9$1 at nnrp1.deja.com>: :It's more general and more powerful than that. The % operator takes a :string on the left and a single value, tuple, list or dictionary on the :right and produces a string by substituting the % placeholders in the :left-hand operand with values from the right-hand operand. Note that % :inside a string doesn't have any special meaning in itself; it's the % :operator that treats it as placeholder. Thus : : a = "His name is %s and his age is %d" : b = ['Bob', 42] : print a % b Thanks. I think it's starting to creep into my head, now. Your examples helped. I've saved them in my file of examples. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From benji_york at cal-na.com Mon Jan 22 13:22:39 2001 From: benji_york at cal-na.com (Benji York) Date: Mon, 22 Jan 2001 18:22:39 GMT Subject: Different deployment considerations (was: Python & GUI?) References: <3A674896.C7E52247@crepido.com> <3A698869.198D6263@crepido.com> <301DBDE62C14BD35.683C43A181247CB3.8398E5428BE1B406@lp.airnews.net> <94cm0r01b6j@news2.newsguy.com> Message-ID: <94htp3$v4t$1@nnrp1.deja.com> In article , "Tim Hochberg" wrote: > > "Alex Martelli" wrote in message > news:94cm0r01b6j at news2.newsguy.com... > > > I haven't checked, but, why wouldn't Installer (or other > > such solutions) work equivalently for, say, wxPython? > > It does. (There are a couple of tricks one needs to know, but those are > readily answered on the wxPython list). > > -tim I recently finished a spiffy little Windows wxPython app for our local country club and was trying to figure out how I was going to distribute it. I could have installed Python, wxWindows, and my code on their machine and been done with it, but I decided to learn how to do it "right." I figured out how to get Gordon McMillan's "Installer" (http://www.mcmillan-inc.com/) to package up all the files my app needed (including the wx files). I then downloaded Inno Setup (http://www.jrsoftware.org/isinfo.htm) and learned how to build a setup program. The results are a single executable setup program. Just double click and it launches a profesional looking setup program. Inno Setup let me put icons on the Start menu and desktop and automatically created an uninstaller that integrates with the standard Windows add/remove programs functionality. I was very impressed, you will be too. Benji York york at ficom dot net Sent via Deja.com http://www.deja.com/ From hancock at earthlink.net Wed Jan 17 23:16:53 2001 From: hancock at earthlink.net (Terry Hancock) Date: Wed, 17 Jan 2001 20:16:53 -0800 Subject: Literate programming in Python References: <20010117224801.6A67CEFDB@mail.python.org> Message-ID: <3A666E35.FC1A37C@earthlink.net> > Hello, > I'd like to know if there exist a "literate programming" language for Python (possibly > using the same structure/conventions of > WEB/CWEB, the first literate programming languages, developed by D.E.Knuth and Silvio Levy, > resp. for Pascal and C/C++). > > Thank you for your attention, > > -- > Giuseppe Bilotta I don't know of such a thing, but you should be aware of "Spider", which is a program for creating new literate programming tools for new languages (i.e. you could use spider to _make_ the tool you want). Spider is by Norman Ramsey, circa 1989, at Princeton University. You can probably get it from a number of places (CTAN archives?), but I know it's available as a Debian package (from http://www.debian.org). I think it allows for a higher level of generality than is the case with cweb. Best of luck! -- Terry Hancock hancock at earthlink.net From aahz at panix.com Wed Jan 10 19:30:03 2001 From: aahz at panix.com (Aahz Maruch) Date: 10 Jan 2001 16:30:03 -0800 Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> Message-ID: <93iuqb$rn9$1@panix3.panix.com> In article <20010110184830.13286.00000826 at ng-fg1.aol.com>, Crutoy wrote: > >Hi , i haven't used Python but i do have experience in other languages vb , >java , c++ . Is Python a fully object oriented ? Thanks Python is fully object oriented if you consider Java and C++ to be fully object oriented. If you don't consider those two fully object oriented, you may not consider Python to be fully object oriented. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Sometimes, you're not just out of left field, you're coming in all the way from outer space. --Aahz From jbranthoover at my-deja.com Fri Jan 12 08:47:30 2001 From: jbranthoover at my-deja.com (jbranthoover at my-deja.com) Date: Fri, 12 Jan 2001 13:47:30 GMT Subject: NewBie: How Can I Scan The Keyboard In Python? References: <93ku2c$gtr$1@nnrp1.deja.com> Message-ID: <93n1tg$a6v$1@nnrp1.deja.com> Hello Fredrik, Thank you for your response. I guess that neglected to mention that I am running Python 1.5.2 on a Lynx (not linux) box. I suppose that the msvcrt module makes use of windows API calls and must run on a windows based system? Anyway thanks for the information. If you have any other Ideas, please pass them along. Have a great day...! In article , "Fredrik Lundh" wrote: > jbranthoover at my-deja.com wrote: > > Is there a way to scan the keyboard to watch for a key > > closure? > > http://www.python.org/doc/FAQ.html#8.2 > "8.2. How to check for a keypress without blocking? > "Use the msvcrt module. This is a standard Windows-specific > extensions in Python 1.5 and beyond. It defines a function > kbhit() which checks whether a keyboard hit is present; also > getch() which gets one character without echo. Plus a few > other goodies." > > for more info, see the library reference. > > Cheers /F > > Sent via Deja.com http://www.deja.com/ From hancock at earthlink.net Sat Jan 20 01:22:57 2001 From: hancock at earthlink.net (Terry Hancock) Date: Fri, 19 Jan 2001 22:22:57 -0800 Subject: Questions on Python References: <20010120011201.72310F44E@mail.python.org> Message-ID: <3A692EC1.1C1F0A98@earthlink.net> > Hi everyone, > I have never really programmed before but I'm very interested in it. My > main goal is to be able to eventually program simple games to fool around > with. I have read that Python is a good language to learn on because it > makes learning other languages easier. I want to ask how should i go about > learning this language? Should I read tutorials online (any good ones i > should check out?) or buy some books (which ones?)? Is this language good > for any programming goal or is it mainly for a certain area? What ways can i > make learning this the easy? Thank you for replies =) Online tutorial for first-time programmers at: "Learning to Program" with Python: http://www.crosswinds.net/~agauld/ (Also available as a book -- see http://www.amk.ca/bookstore/python.html) As for books of the paper variety, I recommend "Learning Python" for getting started. I really don't think you can beat the reference materials available online (I consider them well above average for open-source documentation -- I hope this is a trend :) ), but you can purchase a printed version from the bookstore URL above. Hope this helps! I was originally persuaded to learn Python as an extension language for a non-existant (but planned) game engine. :) However, I have found lots of other applications. After some consideration of the amazingly short learning curve, I've decided Python is the language I would elect to teach first-time programmers. -- Terry Hancock hancock at earthlink.net From benc at rehame.com Tue Jan 9 23:47:39 2001 From: benc at rehame.com (Ben Catanzariti) Date: Wed, 10 Jan 2001 15:47:39 +1100 Subject: book recommendation? References: Message-ID: If you are using a Win environment i would recommend "Python Programming On Win 32" by Hammond & Robertson. This is a must have. or for a general OS information "Programming Python" another must have (you can never have too many) ... both published by O' Rielly and both are compliant with Version 2. Check out http://www.oreilly.com/catalog/pythonwin32/ http://www.oreilly.com/catalog/python2/ "Chris Watson" wrote in message news:mailman.979094414.3323.python-list at python.org... > On Wed, 10 Jan 2001 lsloan00 at my-deja.com wrote: > > > Okay, I'm being too picky. Since nobody's given any > > suggestions, maybe my request should be: > > Please recommend a good Python book. > > I was in the same spot a few days ago. Last friday actually. > I finally settled on Python Essential Reference as the book to learn from. > It pretty much is what *I* was looking for. A newbie book. But mainly for > reference. Such as "hrmm what was the options and syntax for open()?" > A quick look at the book is great for that sort of thing. It is almost a > clone of the online tutorial but has better examples scattered about its > pages. You should cruise to the local bookstore and check it out first and > see what you think of it. I think it was the best book I could of > purchased as a newbie. It doesn't cover 2.0 but I am not finding that a > problem so far. Happy hacking! > > -- > ============================================================================ = > -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek > Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas > Home: scanner at deceptively.shady.org | http://open-systems.net > ============================================================================ = > WINDOWS: "Where do you want to go today?" > LINUX: "Where do you want to go tomorrow?" > BSD: "Are you guys coming or what?" > ============================================================================ = > irc.openprojects.net #FreeBSD -Join the revolution! > ICQ: 20016186 > > From cerutti at together.net Thu Jan 25 14:41:19 2001 From: cerutti at together.net (Neil Cerutti) Date: 25 Jan 2001 19:41:19 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: Dethe Elza posted: >Purely anecdotal information: > >I was building a simple app in wxPython on Windows because I'd >heard Tkinter was 'too slow.' Things were relatively OK, but >when I tried to run it on Linux some functions were not yet >implemented and the program would coredump frequently. >wxPython/wxWindows is a swiftly moving target, so these problems >may well be fixed now. But I ported to Tkinter and it's been >fast enough for my limited needs, and with Tkinter 3000 I expect >it to be even faster (haven't had time to test that yet, perhaps >this weekend). > >Using Tkinter also has the advantage that it will work on my >antique Mac Duo which my 4-year old daughter uses for games. >This is pretty crucial for me, since what I'm writing is >basically a game for her. The current documentation for Tkinter is much better than what is available for wxPython. For comparison purposes, I'm writing my first GUI app, a simple wrapper for slrn, in Tkinter and wxPython. Tkinter's 'pack' layout manager is super easy to use, and with some practice and the excellent documentation, powerful. wxPython seems to have a couple of layout managers, but how they should be used is a mystery. I've been forced to place everything pixel by pixel so far. wxPython is supposed to be faster, but it isn't for the tiny app I've written, because it takes nearly 3 times as long to get started. Binding widgets to callbacks in Tkinter is much easier for me to understand than the wxPython EVT_ macros. Tkinter's events seem much easier to bind, since I don't have to worry about which widget generates what event -- they all seem to generate everything I've wanted to bind. In wxPython, I haven't figured out how to get my app to close if I hit ESC. Nothing I've tried EVT_CHARing has bothered to actually generate an event. The objects in wxPython are more full-featured (I guess--for some definition of full featured), but aren't as easily configurable as the Tkinter ones. For example, in Tkinter, I've bound right-clicking to a list box of news servers. A popup menu allows me to remove that new server from the list, or add another one. I can catch a EVT_RIGHT_BUTTON in wxPython, but I can't (so far) find out which list item the pointer was near when the event occurred. (For that matter, I can't make a popup menu either yet either, though I *know* it's possible. It says in the documentation that a Menu can be a popup.) The widgets and windows look exactly the same, so far. wxPython has access to more standard interface dialogs, though Tkinter has a fair number, too. The wxPython GUI code is going to be quite a bit shorter. It would probably lengthen if I started using a layout manager. My advice, although I've got limited experience, is to go with Tkinter, and read the following great document, by Python Labs' Fredrik Lundh: http://www.pythonware.com/library/tkinter/introduction/index.htm John Grayson has made a couple of chapters of _Python and Tkinter_ available for free. One of those free chapters covers the layout managers and I found it enlightening: http://www.manning.com/Grayson/Chapters.html wxPython's documentation seems to be in the state Tkinter's was back when all there was was the _Tkinter life preserver_. Better advice is probably to try them both for some small sample app, like I have, and make up your own mind. Perhaps wxPython makes perfect sense if you are a good C++ programmer. -- Neil Cerutti "If you're gonna score 125 points in a game, you've only got to play good enough defense to hold the other team to 124. How the hell hard is that?" -- Red Auerbach From trotts at llnl.gov Tue Jan 2 02:49:58 2001 From: trotts at llnl.gov (Issac Trotts) Date: Mon, 1 Jan 2001 23:49:58 -0800 Subject: OpenGL/GLUT in python In-Reply-To: ; from codebert9@users.sourceforge.net on Tue, Jan 02, 2001 at 06:55:52AM +0000 References: Message-ID: <20010101234958.A20921@llnl.gov> Have you checked out the GLUT demos included with PyOpenGL? If you look at these demos and the C GLUT demos included with Mesa and C GLUT then things might be clearer. The Python wrapper of GLUT is very similar to the C version. You might try a Google search for PyOpenGL. Issac On Tue, Jan 02, 2001 at 06:55:52AM +0000, Jeffrey Drake wrote: > Is there any sites that are specifically focused on this topic? I am looking > mainly for tutorial sites. > > Thanx in advanced, > Jeffrey Drake > > > -- > http://www.python.org/mailman/listinfo/python-list From dsh8290 at rit.edu Wed Jan 17 19:14:56 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 17 Jan 2001 19:14:56 -0500 Subject: How to import JavaClass from JPython? In-Reply-To: <3A638EE1.BDABAA65@free.fr>; from julien.reynier@free.fr on Tue, Jan 16, 2001 at 12:05:15AM +0000 References: <3A638EE1.BDABAA65@free.fr> Message-ID: <20010117191456.I23790@harmony.cs.rit.edu> First off, JPython is old. The current version is called Jython (jython.sourceforge.net). On Tue, Jan 16, 2001 at 12:05:15AM +0000, Julien Reynier wrote: | Hi, | | I know how to import core API classes from JPython using for example : | from java.lang import System | But I don't know how to import an specific class for example | MyClass.class that I had developped. | If I just do the same thing that with core API classes : from my.package | import MyClass, I obtain an error message. | What is your error message? "MyClass.class" must be in the class path otherwise the JVM can't find it. Jython is just a Java program, after all. You import your classes the same way as the system classes: from package import class (ie: from mypackage import MyClass if your Java looks like: package mypackge ; public class MyClass { } ) Or you can use the fully qualified name: import mypackage spam = mypackage.MyClass() | Is anybody knows if a classpath or other environment variables have to | be set to specific values ? | | thanks... | | Julien Reynier HTH, -D From robert at roebling.de Mon Jan 22 05:57:37 2001 From: robert at roebling.de (Robert Roebling) Date: Mon, 22 Jan 2001 11:57:37 +0100 Subject: ANN: wxDesigner 2.0 commercial RAD tool Message-ID: Hello, wxDesigner is a dialog editor and RAD tool for the wxWindows C++ library and its Python and Perl wrappers named wxPython and wxPerl. It allows its users to visually create dialogs using a simple point and click interface as well as add new classes, handlers and getters to these dialogs. wxDesigner is now available in English, German, Spanish and French. New is support for notebooks and for importing dialogs defined in XML, useful for converting existing projects from Windows to wxWindows in general and wxDesigner in particular. wxDesigner is available for Windows, Linux/Intel, Linux/PPC, Solaris/Sparc and FreeBSD/Intel. A singler-user licence costs $89, the student version $19, upgrading is free. More information is available from: http://www.roebling.de For more information about wxWindows, wxPython and wxPerl visit the respective sites at: http://www.wxwindows.org http://www.wxpython.org http://wxperl.sourceforge.net Regards, Robert Roebling -- Robert Roebling, MD From gmuller at worldonline.nl Sat Jan 20 14:33:17 2001 From: gmuller at worldonline.nl (Gerrit Muller) Date: Sat, 20 Jan 2001 20:33:17 +0100 Subject: I (don' ) will kill my Python References: Message-ID: <94cp5o$buj$1@nereid.worldonline.nl> Tim Peters heeft geschreven in bericht ... >[Bruno Schaefer] <...snip...> >> To improve the popularity of Python and to use it as first programming >> language this topic to create standalones is very important. > >I don't think so. See below. > <...snip...> >Python was never designed for standalone operation. That's life. What they >*should* say is: "This is my program! I have created it by myself! Look! >And it's only 507 bytes! Now you go to http://www.python.org/2.0/ and click >on 'Windows installer'. Then we can share tiny Python programs via email >forever after." > >I'm philosophically opposed to teaching kids that sharing fun programs >requires swapping multi-megabyte platform-specific binary executables over >high-speed internet connections. It's much better if their friends have >Python installed too. Then they can also jump into the program, change it, >improve it, do a bit of *programming* themselves. The nearly unbounded >artificial pain of producing platform-dependent binaries is someting Python >was deliberately designed to get away from. > <...snip...> Nevertheless I agree with Bruno that the route via a full-blown python installation is an additional hurdle for simple demonstration versions. From "naieve" user point of view a single-click or single copy installation is expected for simple demonstrators. What would the size of a platform-dependent (windows) binary for a simple Python/Tkinter based program, using static linked libraries? Looking at the tkinter dll's it will be in the low megabyte order of magnitude? Assuming bytecode programs in the order of 10..100 kbyte, for frequent sharing of programs a "normal" python installation is preferred, since this reduces the traffic some 2 orders of magnitude. > >the-freeze-utilities-are-exactly-as-good-as-volunteers-made-them-ly > y'rs - tim > regards Gerrit From peter at engcorp.com Thu Jan 4 00:29:35 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 04 Jan 2001 00:29:35 -0500 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> <3A52AD6A.62D043A2@engcorp.com> <3A534367.36B1FD18@uswest.net> Message-ID: <3A540A3F.DCF45469@engcorp.com> Bjorn Pettersen wrote: > > Peter Hansen wrote: > > [snip] > > You are a cowboy-hacker type of programmer, not one working as a serious > > software engineer in a group environment, right? Or, if the latter, your > > management just hasn't caught on yet. > > Ad hominem attacks are out of place on c.l.py I tried to pose it as more of a question than an attack. Anyway, you're directing your attack (I mean comment) at someone replying to an individual who has persistently attacked the intelligence of others replying calmly to his postings, so perhaps your comments are misdirected. (Oops, do you consider that an attack, too? Sorry, I guess I can't tell. Personally, I consider blanket statements about what is and is not appropriate on Usenet to be attacks, but that's another story.) > > Seriously, nobody who really programs for a living instead of as a hobby > > should (in my opinion) have the attitude you express above towards a > > maintenance issue such as this. In my opinion. Nothing personal. > > Personally, I find it more problematic to manage all the possible places in a while > 1 loop that an exit can take place. While an unfortunate variable initialization > isn't good by any means, I would expect a loop that wasn't entered to be caught by > the test harness, having a loop accidentally exit because you forgot to change one > of the exit conditions might be harder to catch -- which incidentally is why I don't I agree that there are a variety of ways in which maintenance can be an issue, and a loop with multiple exits is probably no better than a function with multiple exits. On the other hand, with break and continue statements, and a loop-exit flag appropriate to the situation, the while (1) loop is easily turned into a while (not done) loop and the maintenance problem is minimized. The "special value as initializer" situation is equally easy to remedy, as we've seen. The point is that in either case the code doesn't implement the desired solution well, or the solution is too complex for the problem. All we've been doing here is trying to point out the way(s) in which the initialization issue can be a Bad Thing, as multiple exits can be. > Since nobody is going to change their mind at this point, can we hope that this > thread will die? We can hope, but perhaps some of us are still finding interesting viewpoints worth considering. I'm happy you pointed out that downside of my off-hand remark about allowing multiple exit points from a "while (1)" loop, and perhaps others are learning something new. If people don't want to participate, no one's stopping them... Cheers! -Peter From sholden at holdenweb.com Fri Jan 5 10:47:33 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 5 Jan 2001 10:47:33 -0500 Subject: Returning the path of a file References: Message-ID: <02m56.4986$xT.159306@e420r-atl1.usenetserver.com> Daniel Klein wrote in message news:mjob5tgge328h1sj94elg4b8sldrtteeus at 4ax.com... > I've search the Beazley book as well as the Python reference materials > and can't find answers to these two basically simple questions: > > 1) How to return the path of a file previously opened in read-only > mode? > > myfile = open("foo") > > I know I can do something like > > os.getcwd() > > and this is where 'myfile' is, but if the file was opened by some > other method, I would like to be able to interrogate where it was > opened from. > File objects have a name attribute, which you can access to obtain the parameter given to open(), but you may then need to construct the full path using os.curdir() and os.path operations. >>> os.chdir("c:\\windows") >>> f = open("newfile.txt") >>> f.name 'newfile.txt' > > 2) Is there a builtin or method to delete a file or do I have to > execute an os process to do this? > remove() or unlink() will both take a path and delete the associated file. removedirs() and rmdir() operate on directories. > > experiencing-python-growing-pains-ly y'rs, > Daniel Klein > Portland, OR USA > > > From grante at visi.com Sat Jan 13 21:17:49 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 14 Jan 2001 02:17:49 GMT Subject: do python programmers avoid the mac? References: <3A607DCC.7EF7809C@mjs400.co.uk> Message-ID: In article <3A607DCC.7EF7809C at mjs400.co.uk>, Pete wrote: >Ordinary Bloke seeks stable python2.0 mac ide environment for possible >long term development antics. Don't tell me to buy a noisy steenkin >intel fat box. You don't have to buy a noisy steenkin intel fat box: Run Linux! -- Grant Edwards grante Yow! I had a lease on an at OEDIPUS COMPLEX back in visi.com '81... From mwh21 at cam.ac.uk Thu Jan 18 19:44:24 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Jan 2001 00:44:24 +0000 Subject: interesting bound-built-in-method technique References: <9476k6$d55$1@nnrp1.deja.com> Message-ID: "Steve Holden" writes: [snip] > >>> m = {'parrot': "alive"} > >>> f('parrot') > 'dead' > > It just removes the mutable object reference from the namespace, presumably > meaning you can't change it any more. Neat. But will the reference to its > method be enough to stop Python from garbage collecting it [I have to > believe the answer is 'yes']. Yes. Cheers, M. -- ... but I'd rather not reinvent the wheel if I don't have to. On the other hand, if the currently instantiated version of the wheel consists of a square rock covered with moss, I might as well just start fresh. -- Roy Smith, comp.lang.python From dale at out-think.NOSPAMco.uk Tue Jan 2 15:19:04 2001 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Tue, 02 Jan 2001 20:19:04 +0000 Subject: Printing with wxPython References: Message-ID: entropia wrote: >At www.vex.net/parnassus I found: >http://starship.python.net/crew/jjkunce/wxpython/ >1. Printable Text Controls for wxPython > >prntxtwx.py includes the class PrintableTextControl which adds OnDoPrint() and OnPrintSetup() >methods to its parent class, wxTextCtrl. Also provides control of print margins and line wrap. >(Margins may not be working quite right). > >Dale Strickland-Clark escribi?: > >> I'm trying to get to grips with wxPython and printing on Windows. >> >> Has anyone got a very simple sample that sets up a device context and prints some text or simple >> graphics? >> >> I can't find any printing examples. >> >> Thanks for any help. >> >> -- >> Dale Strickland-Clark >> Out-Think Ltd >> Business Technology Consultants >> -- >> http://www.python.org/mailman/listinfo/python-list > Thanks. I'll take a look. -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From quinn at cruzeiro.ugcs.caltech.edu Wed Jan 31 18:40:50 2001 From: quinn at cruzeiro.ugcs.caltech.edu (Quinn Dunkan) Date: 31 Jan 2001 23:40:50 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> Message-ID: On 31 Jan 2001 00:57:48 GMT, Remco Gerlich wrote: >Well, writing "string.split" is inconsistent, shouldn't it be string[split] >or string["split"]? > >It's like indexing the module. It is actually a dict lookup internally. >They're not the same thing really since an identifier suddenly becomes a >string and so on, but it's just a connection my mind made... You'd like lua, then. Everything is a table. Modules (which are not built into the langauge, naturally) are tables. Arrays are tables indexed with numbers. foo.bar is sugar for foo['bar']. It's theoretically appealing, but sometimes causes additional complexity, when, for example, you want to know how long an array is (the convention is to have an 'n' key with the length). And tables are created with {} but indexed with [] :) From quinn at groat.ugcs.caltech.edu Tue Jan 30 03:15:27 2001 From: quinn at groat.ugcs.caltech.edu (Quinn Dunkan) Date: 30 Jan 2001 08:15:27 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> Message-ID: On Mon, 29 Jan 2001 22:07:49 GMT, Rainer Deyke wrote: >"Quinn Dunkan" wrote in message >> So even in a language where functions are the major important element, >> efficiency dictates a data-oriented view. And python is pretty >data-oriented >> anyway, so a functional representation would be out of character. And >> mutation is important in python, while a functional representation gives >no >> opportunity for that. > >None of these is really a compelling reason for using '[]' instead of '()' >for access. There is no efficiency difference in Python because both are >implemented as (hidden) method calls, and languages like C++ allow 'f(5) = >5;'. Is there any good reason for function calls to use a different syntax >than mapping/sequence element access? Oh, so you mean "why not make the function-call *syntax* double for dictionary access"? Well, easy, because we have a dictionary access syntax already. In python, as in just about all OO languages, [] just a method call, like '*', '+', etc. A function/method call is *not* a method call, because you'd never get out of that little sinkhole. If you're going to use function syntax, you should use function semantics, and functions (AFAIK) are just about always immutable. Otherwise you are writing self-modifying code (and I'm sure in python it's possible to go mangle func_code.co_code, but you're not supposed to do that in polite company). I don't know any languages where self-modifying code is the norm, so I'm used to thinking of functions as things that you don't reach inside of and change at runtime. It's true, if you write a class that uses __call__, you can make it look like a function call. You can then mutate the class, and it looks like you're mutating a function. But you can make lots of weird looking syntax by abusing __getattr__, __getitem__, __call__, and the like :) I mean, I could also understand a function that holds a static pointer (oops, slipped into C-land) to some dict which is mutating, and thus gives you different values. But then it's the dict, not the function, doing the mapping, so making it *look* like the function is doing the mapping is a lie. Also, if you think of a dict as a function mapping keys to vals, *all* you can do is get a val from a key. The only way to check for the existence of a key is have the function return a tuple (error_flag, possible_val). There's no way to get all the keys, except remember them in another function (mapping integers or some known sequence to keys). If C++ allows 'f(x) = y;', then C++ is truly weird. What is *that* supposed to mean? 'f(x)' returns a value, and assigning to a value makes no sense. You assign to variables, not values. I could understand '*(f(x)) = y;', but the only way I can see to get 'f(x) = y;' to do what you want is to have 'f' return an lvalue. Icon does stuff like that, but it has an excuse: it's icon. Just out of curiosity, what is the type of the C++ 'f' function above (and don't say "cpp macro" :) ? It's likely C++'s idea of assignment is one I'm not familiar with. In any case, python has a SyntaxError for that: SyntaxError: can't assign to function call And it's the 'no traceback' flavor of SyntaxError, which means it's for real :) From bhellao at my-deja.com Fri Jan 19 17:00:10 2001 From: bhellao at my-deja.com (Opinderjit) Date: Fri, 19 Jan 2001 22:00:10 GMT Subject: libswigpy for NT Message-ID: <94add5$7o5$1@nnrp1.deja.com> Is there a libswigpy library for the NT environment? Thank you. Sent via Deja.com http://www.deja.com/ From tim.one at home.com Mon Jan 1 18:43:45 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 1 Jan 2001 18:43:45 -0500 Subject: Is 100,000 entries big for a dictionary? In-Reply-To: <92on4o$2ei$1@nnrp1.deja.com> Message-ID: [Tim] > On most machines hash values are 32 bits, and are always > computed as such, and are cached in the dict entry. > When it's time to grow, the table does double in size, > but hash values are not recomputed -- it simply uses one > more of the hash bits that's always been there. Note > that entries are reinserted when the table grows -- > that's probably not what you meant by "the usual > extensible hashing mechanism". .. [rturpin at my-deja.com] > Actually, that describes exactly what I meant. This is > now a pretty standard algorithm used in a variety of > DBMS and other applications. Only the entries whose > next bit is 1 need to be reinserted, though that can > cause other entries to move in the lower half if there > were previous collisions. Well, at this point you would have an easier time reading dictobject.c than I would have guessing exactly what you mean . Python's hash table structure is utterly vanilla, a contiguous vector of 2**N structs -- it's just that sometimes a brand new vector 2x bigger (or 2**M times smaller) may get allocated and everything moves to the new vector. All references to extensible (more often "extendible") hashing I've seen have a much fancier scheme in mind, with a directory (or index) table pointing to buckets that can split independently; the thrust of such schemes is to ensure that an item can be found with no more than two disk accesses (incl. one for the directory table, if it's paged out). I believe that's the std meaning, and it doesn't have anything in common with Python's scheme beyond hash functions and powers of 2; e.g., http://hissa.nist.gov/dads/HTML/extendibleHashing.html http://www.cs.byu.edu/courses/cs453/lecture18.html http://www.csm.astate.edu/~rossa/datastruc/Extend.html http://www.cs.purdue.edu/homes/sunil/syllabi/541/Lecture5/sld006.htm http://www.istis.unomaha.edu/isqa/haworth/isqa3300/fs009.htm The last link is especially cool because it contains an implementation in gloriously readable COBOL . SIGN-OFF-USING-LY-SIG-ly y'rs - tim From ccosse at psl.nmsu.edu Tue Jan 16 13:52:03 2001 From: ccosse at psl.nmsu.edu (charles cosse) Date: Tue, 16 Jan 2001 11:52:03 -0700 Subject: help finding python20_d.lib for download? Message-ID: <3A649853.5CFBC157@psl.nmsu.edu> Hi, i have to use python in windows for 1 small task and can't link my C module because i need python20_d.lib. Can anyone help me find the downloadable archive which contains it? Thanks a lot! Charles From SBrunning at trisystems.co.uk Thu Jan 4 04:25:19 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Thu, 4 Jan 2001 09:25:19 -0000 Subject: variable inirialization and loop forms (was Re: why no "do : until"?) Message-ID: <31575A892FF6D1118F5800600846864D5B168A@intrepid> > From: grey at despair.rpglink.com [SMTP:grey at despair.rpglink.com] > On Wed, 3 Jan 2001 13:40:38 +0100, Alex Martelli > wrote: > >Initializing variables *to correct values* is a great thing -- but using > >*arbitrary* values for the initialization isn't optimal style. > > I still stand that initting a variable is just that, setting it to a > known, arbitrary value. I've had just about enough of this. It strikes me that the root of this particular spat is that people are using two different definitions of the work 'arbitrary'. /F, Alex and others are using it to mean that one particular value (the 'arbitrary' value) has a special meaning. Steve is using it to mean any old value. Rather than get into an argument as to which of these is the *correct* use of the word (FWIW, my reading of the OED offers some support for *both* meanings), let's just stop using the word altogether in this thread, eh? Having a quick look at Steve McConnell's 'Code Complete (a Bible to me), he refers to what /F is objecting to as 'a variable with a hidden meaning', or 'hybrid coupling'. Hmm, don't like that second one much. Let's go with the first. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk It is not necessary to change. Survival is not mandatory. - Dr. W. Edwards Deming ----------------------------------------------------------------------- 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 fredrik at effbot.org Thu Jan 11 10:41:06 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 11 Jan 2001 15:41:06 GMT Subject: BUG Python 2.0 FreeBSD compile problem References: Message-ID: Robin Becker wrote: > When building Python 2.0 with FreeBSD xxx.com 2.2.7-STABLE FreeBSD 2.2.7-STABLE > I get undefined references to _TELL64 at load time unless I change line 61 of > Objects/fileobject.c from > > #elif defined(__NetBSD__) || defined(__OpenBSD__) > > to > > #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) http://sourceforge.net/bugs/?func=detailbug&bug_id=128119&group_id=5470 (still says "Resolution: None", but I'm pretty sure a fixed was checked into CVS a couple of days ago... if you can verify that the CVS version builds cleanly, let us know!) Cheers /F From nas at arctrix.com Fri Jan 5 18:37:20 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Fri, 5 Jan 2001 15:37:20 -0800 Subject: web application environments [was: Migrating to perl?] In-Reply-To: <20010106001359.DE54BA84F@darjeeling.zadka.site.co.il>; from moshez@zadka.site.co.il on Sat, Jan 06, 2001 at 02:13:59AM +0200 References: <14933.21680.440187.266261@beluga.mojam.com>, <3Fa56.4580$of7.216286@news1.atl> <14933.21680.440187.266261@beluga.mojam.com> <20010106001359.DE54BA84F@darjeeling.zadka.site.co.il> Message-ID: <20010105153719.B6016@glacier.fnational.com> On Sat, Jan 06, 2001 at 02:13:59AM +0200, Moshe Zadka wrote: > The big problem with Mason's approach (I use it all the time at work) is > that is a preprocessing tool, rather then a compiler. That means syntax > error crop up in the *compiled* Perl code, which has no relation to > the original Mason code where you made the error. I spent 30 minutes > yesterday finding out where I had an extra curly brace. This is how Quixote's template language, PTL, used to work. Debugging template code was a pain in the ass. Now that PTL modules are compiled and executed by the Python bytecode interpreter life is much nicer. Tracebacks are cool. I can't imagine doing a sophisticated web application the old way. Then again, I'm biased. :) Neil From tismer at tismer.com Sun Jan 7 17:37:55 2001 From: tismer at tismer.com (Christian Tismer) Date: Mon, 08 Jan 2001 00:37:55 +0200 Subject: ANN: Stackless Python 2.0 Message-ID: <3A58EFC3.5A722FF0@tismer.com> Dear community, I'm happy to announce that Stackless Python 2.0 is finally ready and available for download. Stackless Python for Python 1.5.2+ also got some minor enhancements. Both versions are available as Win32 installer files here: http://www.stackless.com/spc20-win32.exe http://www.stackless.com/spc15-win32.exe Speed: Stackless Python for Python 2.0 is again a bit faster than the original. This time even better: About 9-10 percent. I have to say that optimization was much harder this time. My speed patches are now done by a Python script, which will make maintenance and diff reading much easier in the future. There is now also a bit of example code available, like the uthread9.py Microthreads module from Will Ware, Just van Rossum, and Mike Fletcher. Source code and an update to the website will become available in the next days. enjoy - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From phlip_cpp at my-deja.com Sat Jan 20 14:18:09 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 20 Jan 2001 19:18:09 GMT Subject: Where's a built version of dcop.py? Message-ID: <94co9h$74k@freepress.concentric.net> Pythons: I seek a compiled or packaged form of dcop.py. This links KDE's DCOP object message broker to python, letting one script KDE apps. The only version I can find is in the KDE CVS repository, down here: kdebindings/dcoppython/lib/dcop.py When I compile this, following the README directions, I get absurd errors that I shan't disturb a Python group with. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- Founding member of NuGWa - Nudists for Global Warming -- From mwh21 at cam.ac.uk Tue Jan 30 13:28:37 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 Jan 2001 18:28:37 +0000 Subject: Sets in Python References: <956hcd$qef$1@tyfon.itea.ntnu.no> <956s6k013u0@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > "Magnus Lie Hetland" wrote in message > news:956hcd$qef$1 at tyfon.itea.ntnu.no... > > > > I quite often use dictionaries as sets in Python... But it doesn't really > > seem pretty enough to me... Some arbitrariness (as with > > "while 1: ... break" I still don't like that one...) about using what > > to me is a value as a key, and assigning it some value -- like 1, > > for instance... And then checking it with has_key, and removing > > it with del... > > > > Isn't there a better (more beautiful) way of doing this? > > Hi Magnus! It's been a while... > > In Python 2.1, you'll be able to use > if x in dict > as a synonym for > if dict.has_key(x) > [and *maybe* the for-loop equivalent, too -- I'm still unclear > about that one, and it doesn't seem to be in the first alpha]. Uh huh; maybe not. There have been second thoughts at high levels - expect a PEP and to maybe see these features in 2.2. Cheers, M. -- The PROPER way to handle HTML postings is to cancel the article, then hire a hitman to kill the poster, his wife and kids, and fuck his dog and smash his computer into little bits. Anything more is just extremism. -- attributed to Paul Tomblin on ASR From scarblac at pino.selwerd.nl Wed Jan 24 10:04:58 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 24 Jan 2001 15:04:58 GMT Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> Message-ID: Paul Foley mailed me his comments, I'm assuming he meant to post to the group. I'll paste in some of them, since he disagreed interestingly :-) (his quotes marked with |) I've left D-Man's comments in although I comment mainly on Paul's, but whatever :) D-Man wrote in comp.lang.python: > On Tue, Jan 23, 2001 at 06:48:45PM +0000, Remco Gerlich wrote: > | - All the exceptions your code explicitly throws should inherit > | some base exception defined in your module, so that that can > | be tested for. > > I agree with this. It makes handling all exceptions of a certain > classification easy. (Paul) | No. If your code gets, say, a bad value, it should raise ValueError, | not some new version of ValueError defined only in that module. Ah, of course. If there's an obvious builtin exception for exactly this problem, use that. That should cover many cases. My point is though, say you have some markup language parser that is looking for an end tag. Your string.index() call fails with a ValueError (end marker not found). Now it would be best to catch that and raise some sort of mymarkupparser.MissingEndTag exception, not to simply pass on the unhelpful ValueError that might change once you switch to regular expressions. (Paul) | It's often useful to define a bunch of new exceptions for your module, | but probably equally often, you want the built-in exceptions [or, | occasionally, exceptions defined in third-party modules you imported. | E.g., a module that defines some new kind of network socket might want | to raise socket.error...though this is a bad example; socket.error is | rather under-specific...] I don't like using exceptions from completely different modules you happen to use. That is where it becomes hard to find out for the user what exceptions your code might raise, and now they need to import that module to use its exceptions, and read its documentation, when the whole points is that they reach it through your module so they don't have to know about it. > | - Avoid throwing exceptions that have to do with your implementation > | to the outside world. If your module function gets an argument that > | is out of range, resulting in an IndexError, don't just pass that on > | to the caller but catch it and raise a custom exception yourself, > | that inherits from your module's standard exception. Hide your > | implementation. > > I agree with this as well. I did this when modifying a library to > actually throw exceptions :-). It had try{ ... } catch( Exception e ) { > return false ; } in it. (Java lib someone else copied from a C lib). > It made the errors much more useful. (Paul) | Au contraire; pass on that IndexError if it makes sense to do so | (i.e., if you can't handle it inside your code, and its not some | implementation detail that could go away with a different | implementation (unlikely, for IndexError)). But if it's caused by a bad input value, it should raise ValueError - so you catch it and raise the other exception. Otherwise you have to remember for each library function what the exception is that it throws when you give it wrong input (and there might be several possibilities). (Paul) | Catching it only to raise | some custom exception is conceptually horrible, as well as being | generally impossible (think higher-level functions, or callbacks. You | don't know what the user wants to do when exceptions happen in his own | code that's being called by yours, and if you alter his exceptions, | you'll break his handlers! Utterly evil!) Ok, functions you know nothing about that are passed in as an argument, those are an exception. If you know nothing about what it does, you shouldn't change it either... (Paul) | Perhaps the best advice is "know what you're doing, and write code | that behaves sensibly", rather than trying to enforce some overly | strict rules. Of course. But discussing what good rules of thumb would be makes it a lot easier to behave sensibly later :-). -- Remco Gerlich From martin.franklin at westerngeco.com Tue Jan 23 09:32:11 2001 From: martin.franklin at westerngeco.com (Martin Franklin) Date: Tue, 23 Jan 2001 14:32:11 +0000 Subject: Editor font in IDLE (Linux) References: <94k31p$geg$1@reader1.imaginet.fr> Message-ID: <3A6D95EB.6041A685@westerngeco.com> Take a look in EditorWindow.py it has this on line 142.... if sys.platform[:3] == 'win': text['font'] = ("lucida console", 8) # text['font'] = ("courier new", 10) change it to just ... text['font'] = ("Courier ", 14) or whatever font you like..... Martin Gilles Lenfant wrote: > > Thanks... > > But for deployment reasons, I need a solution that works with Python 1.5.2 > that does not run IDLE 0.6 (some Unicode constants and others). > > After a quick view, hacking IDLE 0.6 to make it work with Python 1.5.2 is > more difficult than it seemed at first. > > "Simon Brunning" a ?crit dans le message news: > mailman.980252066.30237.python-list at python.org... > > > From: Gilles Lenfant [SMTP:glt at e-pack.net] > > > There is no "config-unix.txt" file in any Python related directory. > > > Perhaps you are using another IDLE version than mine (0.5). > > > > The file that Bryan mentioned was introduced in IDLE version 0.6. Why not > > upgrade to that version? > > > > 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. > > > > -- > http://mail.python.org/mailman/listinfo/python-list From cfelling at iae.nl Wed Jan 24 16:06:35 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 24 Jan 2001 22:06:35 +0100 Subject: python-2.1 function attributes References: Message-ID: <94ng4r$gin$1@animus.fel.iae.nl> Michael Hudson wrote: > Mike Romberg writes: >> I've been messing around with python-2.1a1 and have discovered the >> new feature 'function attributes'. The project I'm currently working >> on can really use this feature. The feature itself would be much more >> useful if one could predefine a set of attributes with the function >> definition. This is one of the things mentioned in the 'future >> directions' sections of pep 232 >> >> http://python.sourceforge.net/peps/pep-0232.html >> >> So... I guess I'd like to put in one 'yes' vote for this extension :). > I suspect if you can come up with a decent syntax, it will go in. I > can't though. Any ideas? I'm always full of ideas, whether they make sence... in current Python (1.5, 2.0) you can do: >>> def f(): ... 'spam' ... print f.__doc__ ... f.__doc__ = f.__doc__ + ' and spam' ... >>> f() spam >>> f() spam and spam why not enhance this like in: >>> def f() ... with: ... f.__doc__ = 'spam' ... print f.__doc__ ... f.__doc__ = f.__doc__ + ' and spam' ... >>> f() spam >>> f() spam and spam and play some tricks to allow "with: suit" only here without it being a true keyword. -- groetjes, carel From aleaxit at yahoo.com Tue Jan 9 12:07:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 9 Jan 2001 18:07:11 +0100 Subject: embedding python in C++ References: <934r1a$pda$1@troll.powertech.no> <93a3lp01kpg@news1.newsguy.com> <93b02a$tr8$1@troll.powertech.no> <93cq6n0186t@news1.newsguy.com> Message-ID: <93fgim04oc@news1.newsguy.com> "Syver Enstad" wrote in message news:YmE66.99$k25.1060 at news1.oke.nextra.no... > > "Alex Martelli" wrote in message > news:93cq6n0186t at news1.newsguy.com... > > You could do it all in C++ without real pain -- whence, the 'somewhat' in > > my sentence above, rather than 'massively':-): instantiating the Python > > type C++ object (which need only implement a 'write' method, and let > > 'softspace' be set & gotten from Python) in C++, and using, again from > C++, > Mmm, that's what I did, didn't implement the softspace attribute though. > What's it for anyway? Python's print statement sets it when it sees a comma (requiring space-separation), reads it back to determine if it must output a space, etc. Basically it's used to avoid a useless trailing space in cases such as print goo, print I don't know what happens if you don't let softspace be set & read (i.e., whether print degrades gracefully or what) -- note that all Python instance objects ARE 'expando' (Javascript terminology) by defaults, so you don't normally have to do anything special to enable it, but, if you're using your own C-level type rather than a Python implemented instance... > > PyObject_SetAttrString to set it directly as the 'stdout' attribute of > > the sys module. > > I did that from python instead. Yep, but that's not significantly more difficult to do from C. > >on the basis of "do the simplest > > thing that can possibly work", it's probably best avoided anyway. > Yeah, shave it with Occam's razor! > > > Another principle (a corollary of the main one) being, of course, "as > little > > C++ as you can possibly get away with":-). > Yes, but sometimes it's fun struggle with C++ too, but it generally Sure. Running 10 miles every morning is very good exercise, too (and probably even better for your health), just not the easiest way to go from point A to point B (generally:-). > dispappears when I start trying to reuse things which is a real pain in C++, > not to mention runtime libraries, and the need to have a lib compiled in at > least 4 different versions dependening on which other libraries you link > with. Platform issues I guess... > >Personally, I currently use the Boost Python Library (BPL), at > > www.boost.org, for all C++/Python work that I don't do through COM (with > > the sole exception of what I need to do in C for general acceptance:-). > > Yes, boost looks interesting. I've downloaded it, but I don't think I'll use > it before I have a better grasp of the underlying API. It can spoil you by masking the API so gracefully, yes:-). > > Sorry, can't help you here, either. If I _was_ in a threading-is-crucial, > > Win32-only situation, I'd be *certain* to use ActiveScripting, which > > *ensures* I can instantiate just as many interpreters as I need (and they > > _shouldn't_ thread on each other toes -- though I have NOT had occasion > > to test this... as threading is another of those "the least I can possibly > > get away with" complications, in my worldview:-). > > Okay, do you have any examples on how to use that instead? Use what? ActiveScripting? Sure, it's pretty easy (via Microsoft ScriptControl). Instantiate in each relevant thread (after suitably CoInitializeEx'ing, of course) a "MSScriptControl.Control" object, set its "Language" property to the string "Python", add code to this instance with the method 'AddCode', and of course use its ExecuteStatement and Eval methods to do -- guess what (execute statements, and evaluate methods, respectively!-). You need to expose your own functionalities as Automation (COM) interfaces and add them with names to the ScriptControl via the ScriptControl's AddObject method, see e.g. Q185889 on MSDN (all examples I've ever found of ScriptControl are in/for VB, but then you do generally need to be able to read some VB code to make heads or tails out of most object models' documentations!-). A good general overview article (again VB-oriented) can be found at http://www.microsoft.com/mind/0799/script/script.htm My "Win32 API" tutorial (for C, and in Italian) does include an example of ScriptControl use (http://aleax.supereva.it/TutWin32/s39.htm), but the comments &c are in Italian and the example does NOT need to expose any functionality to the scripts (just uses the control to interpretively execute arbitrary expressions entered by the user, for the purpose of doing a function-plot -- it's really just a didactical exercise on doing some graphics at the API level!-). Alex From emile at fenx.com Sun Jan 21 10:18:23 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 21 Jan 2001 07:18:23 -0800 Subject: Markov.py References: <94eavq$5cl$1@nnrp1.deja.com> Message-ID: <94eulk$dduhj$1@ID-11957.news.dfncis.de> The documentation is included in the script itself, see the start of the test routine. On a system with a command line interface, this runs as the documentation indicates, however, I'm not sure how command line arguments are passed to the Mac. You can insert a line in the test routine: args = [r'd:\python20\test.txt'] to assign to args directly instead of reading it from the command line. At least then it does something. HTH, -- Emile van Sebille emile at fenx.com ------------------- wrote in message news:94eavq$5cl$1 at nnrp1.deja.com... > I found the following script in the mac standard distribution (see path > below). It seems to be Guido's, i am not sure however, i am at a loss > as to how to use this. I was unable to run it and there is not > documentation. In otherwords, i put on my detective hat but was still > unable to get the thing to run. Anyone use this and can explain to me > how? The script is a bit to big and complex for my level of python kno- > how, but how sweet would it be to be able to make a markov chain in > python without having to re-invent the wheel. Particularly since i > wouldn't be able to in this case! > > cheers, > kevin parks > seoul, korea > cpsoct at lycos.com > From matt_g_russell at my-deja.com Fri Jan 5 19:47:45 2001 From: matt_g_russell at my-deja.com (matt_g_russell at my-deja.com) Date: Sat, 06 Jan 2001 00:47:45 GMT Subject: Q: how to execute an outside program in the python ? References: Message-ID: <935pvf$io0$1@nnrp1.deja.com> In article , "Hwanjo Yu" wrote: > Thanks. > > Using the commands module , you can get the exit status of the shell. import commnads aSampleUNIXCommand = "ls -al /" (exitStatus, output) = commands.getstatusoutput(aSampleUNIXCommand) Sent via Deja.com http://www.deja.com/ From fuess at att.net Wed Jan 31 08:35:24 2001 From: fuess at att.net (David A. Fuess) Date: Wed, 31 Jan 2001 13:35:24 GMT Subject: BUG? Python 2.0 chokes on international characters in Unicode strings References: <958g0k$f97$1@wanadoo.fr> Message-ID: This may explain why I was having problems when I extracted data drom an international database. onr record contained o-accent, u-umlaut, and e-umlaut. Python crashed every time I tried to perform some string operation on a string containing these characters or if I tried to print those strings. I think the error was a Unicode coersion error or something like that. We may be loking at an previously unreported bug. Dave "Jurie Horneman" wrote: >I've checked the FAQ and the buglist, but I couldn't find anything on this. > >I was doing some COM programming with Python 2.0 on Windows 2000 yesterday. >I retrieved some Unicode strings containing international characters: e >accent grave, c accent circonflex, that kind of thing (I live in France). >Printing these strings raised a Unicode exception. Some investigation showed >that the exception was raised when trying to print the international >characters. Replacing them by some dummy character "solved" the problem: the >strings printed fine. > >It's odd: I've seen French COM error messages printed by Python. The >international characters were not printed correctly ('u/351'), but at least >it didn't crash... > >I haven't verified if the same thing happens with ASCII strings. > >Is this a known bug? (If so, AAARRGGHHH - could it really be that Python >basically doesn't work outside of the US? Hard to believe: these characters >are used in the Dutch language...) >Is there some workaround? Could I convert Unicode strings to ASCII? If so, >how? > >Thanks for any help on this. Please put my work address >jhorneman at kalisto.com in copy if you can, I'm writing this from home. From NoSpam at NoSpam.com Sun Jan 21 23:15:02 2001 From: NoSpam at NoSpam.com (Tom) Date: Mon, 22 Jan 2001 04:15:02 GMT Subject: wyPython References: Message-ID: My experience has been good on Win2K. Check out the wxPython Demo - it is very useful. Because it is a 'native' toolkit it is very fast. Tom. "Doug Farrell" wrote in message news:Mk9a6.3589$3T2.181641 at newsread1.prod.itd.earthlink.net... > Hi, > > I'd like to hear what people think of wyPython and any experience they've > had with it, in particular as to how it compares to useing other GUI tookits > like Tcl/Tk for instance. > > Thanks, > Doug > > From sholden at holdenweb.com Fri Jan 12 16:21:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 12 Jan 2001 16:21:47 -0500 Subject: How robust is Python ? References: <9358nn$3c5$1@nnrp1.deja.com>, <9354f9$vbi$1@nnrp1.deja.com>, <20010106103938.8FCAFA84F@darjeeling.zadka.site.co.il> <93nh5u$9nk$1@nntp6.u.washington.edu> Message-ID: "Donn Cave" wrote in message news:93nh5u$9nk$1 at nntp6.u.washington.edu... [exception handler query snipped] > > Why apart from that? > > I guess we've already covered the "try: continue" issue: "try: continue" > just isn't supported (though the more useful "try: ... except: continue" > does work.) Readable flow control inside a loop is very doable. It's > hard for me to see that try: continue would really improve on that - > on the contrary, continue is liable to detract from readability if it's > used in conjunction with too many other flow control options. I think > "goto" would be fun, too, but I can see why in some ways we're better > off without it. > Yes, but there doesn't seem to be any inherent reason *why it shouldn't* be supported in the future. It certainly isn't detected as a syntax error, which would be going a bit far. > But back to the subject, I would be interested in more concrete > examples of what exceptions we're liable to catch in a case like that. > I have used top level handlers, but only as basically an alternative to > the traceback, not to resume execution. I think the initial proposal > was to execute the program again from scratch after it exits, and it's > pretty obvious what that's about. But after catching some random > exception at the top of the program, I would be concerned that the > program might be in a compromised state and not really fit to go back > to work. And would that really catch the kind of lossage that could > break a correctly written Python program, or do those things usually > break the interpreter directly? > The reason *I* found for using this construct was, in pseudo-code: # # Handle billings by e-mail # for c in customer: try: read the database zip up relevant files formulate email with zip attached try: generate list of mail hosts except KeyboardInterrupt: raise except: continue for host in hosts: if known-bad-host: log error continue send mail ...etc AFAIR, Python complained because the continue was in the outer "try" even though it was in the "except" of an inner "try", although it's along time ago now so I could be wrong. Whatever the case, I don't see why "continue" shouldn't be acceptable in either suite, although I accept there may be some implementational convenience to things the way they are now. regards Steve From jan.dries at dcube-resource.be Fri Jan 12 00:17:17 2001 From: jan.dries at dcube-resource.be (Jan Dries) Date: Fri, 12 Jan 2001 06:17:17 +0100 Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> <3A5E5C21.3E036BFE@intelligenesis.net> Message-ID: <3A5E935D.CF641658@dcube-resource.be> Ben Hutchison wrote: > > Crutoy wrote: > > > Hi , i haven't used Python but i do have experience in other languages vb , > > java , c++ . Is Python a fully object oriented ? Thanks > > I have just been considering the same questions myself. I do have a few > concerns with Pythons OO credentials, relative to Java/C++. > > 1. Most significantly, Python requires the "self" or "this" reference to be > explicitly declared. This seems like a bit of a hassle if you do pure OO > development with python; lots of typing! This is a design choice (the "explicit is better than implicit", one of Python's favourite design choices), and as any design choice, a compromise. It makes things more explicit. Whether you consider that to be an advantage or a disadvantage depends on your point of view. Yes, it requires more typing, but it also protects you from the complexity of the many sometimes subtle disambiguation rules that C++ has to correctly deal with the implicit use of "self" or "this". In either way, it has nothing whatsoever to do with the concept of OO. It's a language implementation design choice, that, as it happens, makes both using and implementing Python more straightforeward. And FWIW, I have been a core C++ afficionado for more than 10 years, and I liked it so much for it's impliciteness and conciseness. About a year ago, I discovered Python and have since then written thousands of lines of Python code, yet have not once experienced the typing of "self." to be overhead, and further, although it's less important for myself as a programmer, I find that some of my not so experienced team members have much less trouble getting up to speed with the explicit Python approach than with the more implicit C++ approach. Besides, when it comes to typing, even with the explicit "self.", Python is still far less verbose than Java. > Suggests perhaps that OO features were > built onto initially procedural language. > eg: Python > class MyClass: > def __init__(self, name): > def doIt(self): > Python with implict self (as in C++, Java) > class MyClass: > def __init__(name): > def doIt(): > > 2. Access control is more informal in Python than C++/Java. I know in the case > of Java at least that security provisions depend in part on access control > being strictly enforced, and additonally there are a number of design > principles that assume 3 tiered (public, protected, private) access levels. > * Is Pythons leading underscore mechanism more of a convention? The underscore approach is more than a convention: Names prefixed with a single underscore are not imported by the "from module import *" statement, and hence must be explicitely imported. Names prefixed with double underscore are explicitely mangled so they can't be mistakenly accessed from outside their class for instance. > * It is strong enough to build security mechanisms on? Even the C++ support for public/protected/private access is not strong enough to enforce security. Quoting Stroustrup (in "The C++ Programming Language", 3rd ed. p. 226): "The protection of private data relies on restriction of the use of the class member names. It can therefore be circumvented by addressing manipulation and explicit type conversion. But this, of course, is cheating. C++ protects against accident rather than deliberate circumvention (fraud)." In that light the Python underscore approach does not differ from C++. You can circumvent it, but you must explicitely do so. Although in Python it is arguably easier to do so than in C++. > * Can a class declare a priviledged API availalbe only to subclasses? Here you refer to the notion of protected members. There is concensus in some circles that protected was a bad idea in the first place. Protected was invented for C++, and Java copied it. But Bjarne Stroustrup, inventor of C++, now says it was a mistake introducing protected, because it is a source of bugs and seriously complicates maintenance. Quoting him again (in "The design and evolution of C++", p.302): "Barbara Liskov's OOPSLA keynote [Liskov,1987] gives a detailed explanation of the theoretical and practical problems with access control based on the protected notion. [...] In fact, one of my concerns about protected is exactly that it makes it too easy to use a common base the way one might sloppily have used global data. [...] In retrospect, I think that protected is a case where 'good arguments' and fashion overcame my better judgement and my rules of thumb for accepting new features." The bottom line, IMO, is that Python has managed here (as with so many other aspects of the language) to provide a very simple approach that at least in practice is just as effective as the equivalent C++ or Java feature, but at a fraction of the overhead and complexity. It is, for example, extremely challenging to even try to understand all the subtleties of acces control or multiple inheritance for that matter in C++. In Python, all of this is simple to explain, just a handful of simple rules, and simple to use, but as features in practice just as effective as in C++. Regards, Jan From m.faassen at vet.uu.nl Sat Jan 6 22:34:33 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Jan 2001 03:34:33 GMT Subject: Should I learn Python or Java? References: Message-ID: <938o49$fj6$1@newshost.accu.uu.nl> Charlotte Williams wrote: [snip] > I notice that there is a lot of demand for Java programmers. The only > experience I have with an OO language is Smalltalk. My questions are: My background: I'm not intimately familiar with VB, but I know Basics and I know what it's about. I'm not intimately familiar with Java either, but I know C++ and I figure I know what Java's about too. :) > 1. Which language would be best to learn, Java or Python. From a VB > standpoint, which has the least learning curve? Python would definitely have the easier learning curve. Python's syntax is simpler and it allows for a more interactive style of programming than Java. It doesn't really matter what language you're coming from, in fact; even coming from C++ (which is much like Java in quite a few ways, especially syntax) Python is probably easier to pick up than Java. > 2. Is going from object-based to object-oriented programming that huge a > jump? I want to learn an OO language, however I plan on utilizing it in my > career. OO concepts such a polymorphism are pretty important, and I'm not entirely sure if VB supports it (though I heard it is fully OO now, so it should now, and there's COM of course). Anyway, OO concepts in the context of Python aren't that hard to pick up; it comes fairly natural. > 3. Which one is the most "fun" to program in? Python (you are asking in the Python newsgroup, right? :). Definitely Python, though. Python's more interactive, its syntax is more concise and still more readable, and it doesn't bother you with a lot of static type checking, which Java definitely does. > 4. Is Python multi-platform? How is it's performance compared to JAVA in > an internet situation? It's reliability? Python's very multi-platform, though it takes another approach than Java; the idea is to stick to the wide range of modules that are available cross platform if you want to make a cross platform Python program. There's absolutely no problem moving from Windows to Linux, for instance, if you do that. Performance depends on the task you're performing. In theory, Python is slower than Java. In practice, it's often faster. How can that be? Various reasons: * Python extension modules are in C, and therefore pretty fast, whereas Java has the tendency to do everything in Java, which tends to be slower than C. * Python code tends to be more high level than Java code, and it's easier for programmers to come up with smarter, faster, algorithms. * The startup time and overhead of the Python interpreter is smaller than that of most Java environments. I've used Python extensively for internet programming, in the context of Zope (http://www.zope.org), which is written in Python. I've experienced no reliability problems with Python to speak of. It doesn't seem to be an issue, generally. > 5. Do you for see Python as becoming a major player like Java servlets and > MTS? Can you see Python demand outstripping Java demand in 2 years time? It's possible. I wouldn't make predictions like this, but let's say that if people were smart this *would* happen. :) I do see Python's mindshare growing though; 2 years ago you'd see far fewer references to it than you can see today, for instance. There were also far fewer books on it. > Many of these questions are in response to a post I saw earlier where Python > was being touted as the next evolution of OO programming. It went something > like... > C --> C++ --> Java --> Python. I skipped Java myself. I've used Delphi, though, so perhaps my evolution is comparable to that. It's not as if Python is a revolutionary OO language; it doesn't introduce revolutionary new concepts (but neither does Java, even though people seem to think it does). Python is very nice in that it integrates OO without really forcing it on you, instead making it natural. It provides just enough syntactic sugar to make it easy on the mind, but not enough trickery to make it hard to remember it all. > I'm really interested in hearing from VB programmers that decided to jump > into one or both of the languages, has pretty good knowledge (enough to get > a Java or Python job) and the headaches and experiences they had learning > about them. Do you need a formal CS education to grasp them? I wouldn't think so, but in either case it'd help. An informal CS education and a curious mind are definitely enough, though. Good luck! Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aotto2 at my-deja.com Mon Jan 8 02:12:49 2001 From: aotto2 at my-deja.com (aotto2 at my-deja.com) Date: Mon, 08 Jan 2001 07:12:49 GMT Subject: CO-process References: <93a535$n76$1@nnrp1.deja.com> <_2666.240898$U46.7569402@news1.sttls1.wa.home.com> <4i666.240905$U46.7570799@news1.sttls1.wa.home.com> Message-ID: <93bp9f$v1h$1@nnrp1.deja.com> In article <4i666.240905$U46.7570799 at news1.sttls1.wa.home.com>, "Patrick Logan" wrote: > > wrote in message news:93a535$n76$1 at nnrp1.deja.com... > > > > after Mirosoft create .NET , it's time to answer > > > > have a look to: > > > > http://home.t-online.de/home/aotto/mqcon_E.html > > The CO-process does not seem to support multiple languages in the same OS > process operating on a shared object model/space. That seems to be a big > advantage of .net > > CO-process appears to be based on multiple processes for everything. Is > communication based on sockets or some other network mechanism so the > processes are host-independent? That'd be interesting and flexible, but too > heavyweight for many of the things you'd want to use .net for. Hi, 1) the solution for MqSeries has only 20 KB wich isn't heavyweight. 2) One CO-Process is used to manage one "task" ( DB, Communication GUI-Interface, Appl-Server, ...) there is no need to write one task in more than one language, the benefit is that you can choose the right language for the task, and the clear and easy interface between the tasks mfg aotto :) Sent via Deja.com http://www.deja.com/ From tim.one at home.com Thu Jan 4 23:04:08 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 4 Jan 2001 23:04:08 -0500 Subject: question about grouping in RE In-Reply-To: Message-ID: [Shen Wang] > Currently in RE (A)|(B)|(C) create 3 groups, I wonder if there is a > way to make it generate only 1 group. Sure: (A|B|C) It only creates groups where *you* put in parentheses! Since the precedence of "|" is very low, you usually don't need parentheses just to alter precedence between "|" branches. If you do need parentheses to alter precedence, but do not want to create a group, use the non-grouping parentheses construct (?:pattern). For example, ((?:A)|(?:B)|(?:C)) matches the same strings but creates only one group. > Which is more meaningful in my opinion. As above, you can have it either way, so we don't have to decide whose opinion is better . > But things are different for named group, in pattern like > (?P(sub1)(sub2))|(?P(pat1)), I did want (sub1) and > (pat1) refer to group 2, (sub2) refer to group 3, but I don't want > group 'name1' and 'name2' all refer to group 1, because then I > have no way to tell which part matchs. maybe we can change named > group's number to negative? > > That's all. I don't know if any guru can patch RE to add new flag > like "merge group name". Heh -- sorry, but I have no idea what you just said. If it turns out that nobody else does either, it might be helpful to post a specific, concrete, executable example, spelling out exactly what you're trying to accomplish. Note that there's an undocumented (because still experimental -- it may go away) feature in Python 2.0's new re implementation: >>> import re >>> m = re.search("(A)|(B)|(C)", "abcABC") >>> m.lastindex 1 >>> m = re.search("(A)|(B)|(C)", "abcCBA") >>> m.lastindex 3 >>> That is, a match object has a new attribute "lastindex" that gives the number of the "last group" that matched (but m.lastindex is None if no group matched). There's also a "lastgroup" attribute that gets created if the last group that matched was a named group. That may or may not be along the lines of what you're looking for. Fredrik is experimenting with this because, when writing a regexp-based scanner in Python, you need to which group matched (is the next token an integer? a string? an xyz?), and that's clumsy and slow without something like lastindex/lastgroup. There's also an undocumented Scanner class using this feature in 2.0's sre.py, if that interests you. simple-regexps-for-simple-tasks-makes-for-a-simple-life-ly y'rs - tim From boud at rempt.xs4all.nl Wed Jan 24 14:14:12 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 24 Jan 2001 19:14:12 GMT Subject: Blackadder - any opinions? References: <94c6cu$hl2$1@bob.news.rcn.net> <3a6ae6c7$0$37175$1a0eedbc@dreader2.news.xs4all.nl> Message-ID: <94n9i4$3dq$1@news1.xs4all.nl> Neil Hodgson wrote: > Boudewijn Rempt: >> Anyway, the core components of Blackadder are good - Qt, Qt >> Architect, PyQt, Scintilla. > ! How do you know its Scintilla? When the announcement appeared, I looked > at the site and the screenshot > http://www.thekompany.com/products/blackadder/_img/BAEditor.png > and while the main text part looks a lot like Scintilla, the fold marks > are moved to the right of their margin and hit the edge which looks bad. > Also there are unfixed damaged pixels to the left of the editor and at the > top of the margins. >From a discussion on the PyKDE mailing list. Of course, Scintilla is what most people grab when they are out to make a Python IDE - witness Wing IDE. As for the artefacts - the screenshot is from a pre-beta version, so I am confident they won't appear in the release version. -- Boudewijn Rempt | http://www.valdyas.org From katz at Glue.umd.edu Fri Jan 19 23:53:04 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Fri, 19 Jan 2001 23:53:04 -0500 Subject: A bug in commands.getstatus? Message-ID: Recently I noticed that commands.getstatus() does not accept any parameters I give it -- even when its sister functions getstatusoutput() and getoutput() are happy: 23:48:15 [foxglove at foxglove foxglove]$ py Python 2.0 (#1, Oct 16 2000, 18:10:03) [GCC 2.95.2 19991024 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import commands >>> commands.getstatus('ls') 'ls: ls: No such file or directory' >>> commands.getstatusoutput('ls .') (0, '') >>> commands.getoutput('ls .') '' what is going on here?? Roey From menno at phreaker.net Wed Jan 10 00:22:16 2001 From: menno at phreaker.net (DamageCase) Date: Wed, 10 Jan 2001 06:22:16 +0100 Subject: DTML/Zope AND Flash Message-ID: <93i5su$kfs$1@news1.xs4all.nl> Hello all, I have a question regarding the use of flash on a zope server ! I hope someone can help me out here ! I'm trying to load a simple .txt file into flash, which isn't the problem of course, the problem I have is that I want to make the .txt variable using dtml that get's is content from a MySQL database. Simply putting dtml-var's in the .txt file does not work ( how surprising =P ) but Flash does not want to read from other format's than txt, so a dtml-document does not work either. Does anybody have an solution for this problem ? friendly regards, Menno From jafo-pythonlist at tummy.com Sun Jan 21 01:30:34 2001 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Sat, 20 Jan 2001 23:30:34 -0700 Subject: Tweaking for New Co-lo In-Reply-To: ; from beno@TheWebsons.com on Sat, Jan 20, 2001 at 09:43:38AM -0800 References: Message-ID: <20010120233034.A20336@tummy.com> On Sat, Jan 20, 2001 at 09:43:38AM -0800, Ben Ocean wrote: >I just moved my server. What a joy. Now my python install (on RedHat 6.2) is >broken. Do I need to rebuild from scratch or is there an easy fix? There have been some problems with the Pythons on RedHat. I don't know if 6.2 was impacted, but I think so. If you aren't seeing the problem with "anydbm" as described on the http://www.tummy.com/radiuscontext/ errata page, then you'd better post more information. Otherwise, follow the instructions there and you should be set. Sean -- I think you are blind to the fact that the hand you hold is the hand that holds you down. -- Everclear Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From erno-news at erno.iki.fi Sun Jan 21 09:50:59 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 21 Jan 2001 16:50:59 +0200 Subject: python-mode & emacs settings (was: Re: Tabbing/Spaces & python-mode) References: Message-ID: In article , barry at digicool.com (Barry A. Warsaw) writes: | If you're in the indentation, just use M-m (ESC m) to get you to the | first non-whitespace character and C-a to get you to the beginning of | the line. thanks! i actually had found that eariler, but i forgot to start using it because M-m is a somewhat awkward key combination. but now i've rebound it. anyone want to share the python-related .emacs tweaks they are using? here are some from mine: (i have recycled my caps lock to work as a hyper key, change modifier to taste) -- erno (global-font-lock-mode 1) (global-set-key [?\H-l] 'goto-line) (global-set-key [\H-left] 'back-to-indentation) (global-set-key [\H-right] 'end-of-line) ;; this is in global keymap so that i can open C-x C-f ~/bin/quick-hack ;; and hit H-M-p (global-set-key [?\H-\M-p] 'py-template) (add-hook 'python-mode-hook (lambda () (define-key py-mode-map [?\H-d] 'py-module-doc))) ;; when you have something for reference in the other window (global-set-key [C-next] 'scroll-other-window) (global-set-key [C-prior] 'scroll-other-window-down) (defun py-template () "Insert a python program skeleton" (interactive) (insert "#!/usr/bin/env python\n" "# -*- mode: python; py-indent-offset: 4; indent-tabs-mode: f -*-\n" "import os, sys, string\n" "\n" "def main():\n" " pass\n" "\n" "if __name__ == '__main__':\n" " try:\n" " main()\n" " except KeyboardInterrupt:\n" " sys.exit('%s: break' % os.path.basename(sys.argv[0]))\n") (python-mode)) (defun py-module-doc (module-name) "Open a netscape window showing the documentation for the requested module" (interactive "smodule name: ") (shell-command (format "gnome-moz-remote " "'http://www.cwi.nl/www.python.org/doc/current/" "lib/module-%s.html'" module-name))) From wware at world.std.com Wed Jan 24 05:51:54 2001 From: wware at world.std.com (Will Ware) Date: Wed, 24 Jan 2001 10:51:54 GMT Subject: Random and whrandom References: <94bj03$59v$1@nnrp1.deja.com> <3a6a3540.1976549@news.xo.com> <94jkh0011gg@news1.newsguy.com> <94m9bf$nge$1@nnrp1.deja.com> Message-ID: cpsoct at my-deja.com wrote: > but to get back to my original question. I should import random and not > whrandom? Yup. Just import random. > But then i notice that seed is in whrandom? random import whrandom, so you don't have to. > Hmmm. so i need to import both? Nope, just import random. > And why are there 3 seed values? In C, there was just one. There are three separate C-style random number generators whose outputs are summed (fmod one) to produce the output. The result is a much better random number, in my experience. When using C's rand() function, I have often found patterns cropping up in what I was doing, where I had hoped that the use of a random number generator would prevent patterns from appearing. The whole idea is that it will behave the way real random numbers would behave. Python's random.random() comes much closer to this than C's rand(). If you just import random and use it normally, you'll never directly deal with the fact that there are three separate seeds. > and, what then is rand? id that depreciated? I don't remember about rand. I frequently use random.random() and random.choice(). There are also a bunch of interesting functions in random that pertain to random variables with various interesting probability distributions. I probably know enough probability theory to use these correctly, but an occasion to do so hasn't arisen yet. -- import string,time,os;print string.join((lambda x:x[:10]+x[8:])(map( lambda x:string.center("*"*(lambda x:((x<24) ### Seasons Greetings, Will Ware *(x-3))+3)(x),24),range(1,28, 2))),"\n") ################ wware at world.std.com From glenfant at equod.com.nospam Tue Jan 30 13:53:15 2001 From: glenfant at equod.com.nospam (Gilles Lenfant) Date: Tue, 30 Jan 2001 19:53:15 +0100 Subject: How do you lock your web app data? References: <956uqd$6st$1@newsreaderg1.core.theplanet.net> Message-ID: <957286$kde$1@reader1.imaginet.fr> If you play with lot of small files and few users you can use "lock files" with the same name as the file the user is supposed to modify. This is not "pythonic" but a general algorythm that can be done in python or whatever: start cgi if not exists "myfile.lock" touch "myfile.lock" # play with "myfile.txt" ... # end play with "myfile.txt" rm "myfile.lock" else reply "resource in use, come back later" to the user (or anything else relevant) endif end cgi Of course, this will not be appropriate to big traffic and if the cgi script crashes (beetween "# play..." and "# end play...") and leaves "myfile.lock"... nobody will be capable of using your application. In some months, your application complexity will perhaps grow such that staying with cgi technology will lead to headaches for you and your server. There are better "pythonic" solutions than cgi for playing with shared complex objects and lots of users in a "safer" way. see Zope at www.zope.org that offers an open source Python based applications server that's better suited to complex Web based applications. "Franz GEIGER" a ?crit dans le message news: 956uqd$6st$1 at newsreaderg1.core.theplanet.net... > > Hi all, > > I began to play around with cgi scripts and of course use Python for that. > And man, it is a pleasure to do that with Python! It really is a snap. After > about a day I had written an Issue Tracker, where People can add software > feature requests and bug reports. At this time I add functionality to edit > and delete the entries - until now they only could have been added. > > So an important issue enters the game: How do I lock others out, when one > edits/writes records? Please get me right: This will not be a heavy load app > nor will it be to handle requests and reports from hundreds of people. > Therefore and because I just settled out to explore cgi I decided to use > text files and pickle files for maintaining data and state, which is very > convenient. > > Of course I could take a database as backend but I wonder if there are other > possibilities to achieve that "serialization"? How do you do it? Do you > always use a database? Is it worth the effort doing it without a database? > > The server is an NT box running IIS4. Python is of version 2.0 (AvtiveState > distribution). > > Any hint is appreciated. > > Thanks in advance and best regards > Franz GEIGER > > > > From heiland at ncsa.uiuc.edu Fri Jan 5 10:02:18 2001 From: heiland at ncsa.uiuc.edu (Randy Heiland) Date: Fri, 05 Jan 2001 09:02:18 -0600 Subject: JPython install problem Message-ID: <3A55E1F9.60E033EF@ncsa.uiuc.edu> I've successfully installed and am using JPython-1.1 on my SGI/Unix box and was trying to install it on a Windows NT box. I'm running JDK 1.3 there. I do 'java JPython11' and step thru the installation GUI process, changing the default installation dir to be d:\JPython-1.1. However, after seeing 'Build JPython launch scripts', an Error panel pops up with "Installation failed". When I click on "OK", the GUI says "..installation complete. Extracted 389 files into 32 dirs...etc" Anyone else seen this? Is there some folder that might contain more info on the error that occured? thanks, --Randy From phlip_cpp at my-deja.com Mon Jan 22 19:33:43 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Mon, 22 Jan 2001 16:33:43 -0800 Subject: PyGTK wrapper for diacanvas? Message-ID: <2l4b6.132$wt4.93794@news.pacbell.net> Pythons: Diacanvas is the widget version of "dia", the Gnome Diagram Editor. I'm currently wrapping it in PyGTK-style Python, so we can drive it from a high level language here. If anyone has already done this, or wants to help do this, please tell me so we can synchronize efforts. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- Whoever dies with the most features wins -- From a0038417 at addcom.de Tue Jan 23 03:11:30 2001 From: a0038417 at addcom.de (Konrad Koller) Date: Tue, 23 Jan 2001 08:11:30 GMT Subject: Python 2.0 makes the current Megawidget PmwCounter (v.0.8.4) useless Message-ID: <3a6d3b73.3713875@news.addcom.de> Under Python 2.0 in all my programs the PmwCounter widget in its integer (!) form fails when the value is changed with the arrow buttons. Make a test with the demo Counter.py and you will realize how the value fails to be changed. Under 1.5. everything was ok. Who can cure the problem (perhaps G. McFarlane)? From claird at starbase.neosoft.com Wed Jan 17 09:45:52 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 17 Jan 2001 08:45:52 -0600 Subject: Command language definition References: <3A6542EC.99ED1149@intes.de> <20010117082100.A21854@yetix.sz-sb.de> Message-ID: <9AB314EB1750CDED.8E601D433980376B.010B6045AEFBB1BE@lp.airnews.net> In article , Rolf FISCHER wrote: >On Wed, 17 Jan 2001, Andreas Jung wrote: >> On Wed, Jan 17, 2001 at 07:59:56AM +0100, Rolf Fischer wrote: >> > Or is there a combination with another tool that you would recommend ? >> >> hm...please be a bit more detailed... >> >> Andreas > >Thanks for the reply > >if you want to build a grammar, the basic problem is a syntax definition and >the check of its validity >i.e > >command:= keyword [parameter = value] > >To setup a command with parameters and values requires a syntax analysis. >My first (and very raw) impression on python was, that the tool has excellent >capabilites in easy programming, but I didn't see anything the like to check a >syntax or to define one. This is why I asked for additional tools. . . . I think you're dealing with very important matters, but I'm a bit lost. Is this true: You're part of a team that has developed a GUIfied application. You have respon- sibility for testing the application. You're now saying that, if the application had a command language, that you could exploit that to automate testing. Do I have all that right? If so, my reaction is that, well, yes, that's one approach. The impression I get from your descrip- tion is that "retrofitting" a command language might be a larger task than you realize. While I rate my- self one of the world's most passionate advocates of testing instrumentation (in software), I'd want to have a *very* clear idea of what's involved before I'd recommend dismembering an existing appli- cation in order to rework it for a new command language. The ideal situation is that testability is designed into an application from the beginning. Are you at a stage in your development process where your team will afford you that luxury? The canonical question people ask is for a black-box GUI tester--something that deals purely with screen events. I've dismissed essentially all those for years as more trouble than they're worth. I've re- cently become quite enthusiastic, though, about Android . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tim.one at home.com Fri Jan 26 01:37:27 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 26 Jan 2001 01:37:27 -0500 Subject: random.py gives wrong results (+ a solution) In-Reply-To: Message-ID: [Ivan Frohne] > I'm convinced that Janne Sinkkonen is right: The beta distribution > generator in module random.py does not return Beta-distributed random > numbers. Janne's suggested fix should work just fine. Which is (for reference): def betavariate(alpha, beta): y = gammavariate(alpha,1) if y==0: return 0.0 else: return y/(y+gammavariate(beta,1)) > Here's my guess on how and why this bug bit -- it won't be of interest > to most but this subject is so obscure sometimes that there needs to > be a detailed analysis. > ... Which I'll skip, since it's immortalized already in c.l.py and the bug report: https://sourceforge.net/bugs/?func=detailbug&bug_id=130030&group_id=5470 > ... > The corrected equation for a beta random variable, using Watkins' > definition of the gamma density, is > > brv(A, B) = grv(A, 1) / ( grv(A, 1) + grv(1/B, 1) ), > > which translates to > > brv(A, B) = grv(A, 1) / (grv(A, 1) + grv(B, 1) > > using the more common gamma density definition (the one used in random. > py). Now that seems plain wrong, although I assume it's just typographical confusions: 1. You don't really mean to generate two independent instances of grv(A, 1), right? 2. The parens around the summand denominator have magically disappeared, changing something of the form X/(X+Y) to (X/X)+Y. > Many standard statistical references give this equation -- two are > "Non-Uniform random Variate Generation," by Luc Devroye, Springer-Verlag, > 1986, p. 432, and "Monte Carlo Concepts, Algorithms and Applications," > by George S. Fishman, Springer, 1996, p. 200. So does Knuth, Vol 3 Ed 3 (in the X/(X+Y) form), although he's not careful (as was Janne) to avoid division by 0. So I'll check in Janne's code as-is. Thank you for the analysis! It was an enlightening help. From aleaxit at yahoo.com Mon Jan 22 05:39:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 22 Jan 2001 11:39:50 +0100 Subject: Newbee!!BPL question! Printing to standard output References: <3A6B4D04.14B661E2@magnet.fsu.edu> <94fnkp$sdc$1@news.online.de> <3A6B8C21.ADEAB05E@magnet.fsu.edu> Message-ID: <94h2lm02hml@news1.newsguy.com> "Khaled Khairy" wrote in message news:3A6B8C21.ADEAB05E at magnet.fsu.edu... [snip] > I'm using the Boost Python Library to use Python as an interface for a C++ > library. Boost does an excellent job. > What I would like to be able to do is get a handle to the intepreter > terminal inside my C++ code, and directly print from > there, not through returning a string on an exported function. In the bare C API, you have several choices -- I'm not quite sure which ones are wrapped, and at what level, by Boost Python (I have not done 'printing' from inside a BPL-written extension). The simplest way, if the string you want to print is in your std::string variable named Foo and it contains no quotes &c: void printIt1(const std::string& Foo) { std::string temp = std::string("print \"") + Foo + "\""; PyRun_SimpleString(temp.c_str()); } More elaborate ways proceed by getting at the sys module, obtaining its attribute stdout, and calling method 'write' on said stdout (or slight variants on this). Nothing too terrible, mind you... for example, again with the C API: void printIt2(const std::string& Foo) { PyObject* pSys = PyImport_ImportModule("sys"); PyObject* pStdout = PyObject_GetAttrString(pSys, "stdout"); PyObject* pResult = PyObject_CallMethod(pStdout, "write", "%s", Foo.c_str()); Py_DECREF(pResult); Py_DECREF(pStdout); Py_DECREF(pSys); } You can no doubt remove the explicit reference-decrements here by making use of the smart pointers/references that BPL gives you, but that's just a minor (if useful) convenience. Also, obviously, you may want to do the import-module and get-attribute only once, rather than for each 'print', by saving pStdout (or the bound-method-reference pointer, if you prefer) somewhere in your state; however, while a little bit faster, that will give you problem adjusting your output if the Python side ever sets something different for a while as the value of sys.stdout -- your output would keep going to the 'OLD' stdout (the one that was set when you did the get-attribute initialization); I think that doing the three calls each time may be simplest for most uses (and the little overhead is probably not a biggie compared with the overhead of formatting and I/O, anyway). Lastly, it's also (almost) trivial to wrap this up as a C++ stream buffer if you want; but the added-value is small unless you need to output polymorphically to "the Python standard output" OR other C++ output streams. Alex From cpr at emsoftware.com Thu Jan 18 10:33:26 2001 From: cpr at emsoftware.com (Chris Ryland) Date: Thu, 18 Jan 2001 15:33:26 GMT Subject: Literate programming in Python References: Message-ID: <9472c7$8u9$1@nnrp1.deja.com> In article , "Giuseppe Bilotta" wrote: > I'd like to know if there exist a "literate programming" language for > Python (possibly using the same structure/conventions of > WEB/CWEB, the first literate programming languages, developed by > D.E.Knuth and Silvio Levy, resp. for Pascal and C/C++). See for a lot of information on the topic, including tools (most C/C++ oriented, but pointing to other languages). Also see for Leo, a literate editor with Python support. -- Chris Ryland * Em Software, Inc. * www.emsoftware.com Sent via Deja.com http://www.deja.com/ From root at rainerdeyke.com Wed Jan 10 23:36:24 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 11 Jan 2001 04:36:24 GMT Subject: boolean xor References: <93ace8$nmo$1@panix3.panix.com> <93i7ne$5dk$1@nnrp1.deja.com> <93i9ff$q4l$1@slb0.atl.mindspring.net> <93iuj9$jta$1@slb3.atl.mindspring.net> Message-ID: "Andrew Dalke" wrote in message news:93iuj9$jta$1 at slb3.atl.mindspring.net... > > Rainer Deyke wrote: > >You could, however, remove a redundant 'not' from the original: > > > >def xor(a, b): return (a or b) and not (a and b) > > That may find the truthness of a and b twice, which might > not give the expected behaviour. Eg, if __nonzero__ takes > time to compute (as with a proxy to a remote object) then > the overhead may be twice as long. If you want to play that way, the previous version is also flawed: not ( (a and b) or (not (a or b)) ) In any case except where both 'a' and 'b' are true, the truth value of 'a' is calculated twice. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aleaxit at yahoo.com Thu Jan 25 07:35:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 25 Jan 2001 13:35:18 +0100 Subject: Markov.py References: <94eavq$5cl$1@nnrp1.deja.com> <94eulk$dduhj$1@ID-11957.news.dfncis.de> <3A6B7716.68A62115@home.com> <94h5he$9kl$1@nnrp1.deja.com> <94ides$6t2$1@animus.fel.iae.nl> <94jrt701eg4@news1.newsguy.com> <94l59e$4kc$1@animus.fel.iae.nl> <94mbet01ruh@news2.newsguy.com> <94n920$e66$1@animus.fel.iae.nl> Message-ID: <94p6i40244j@news2.newsguy.com> "Carel Fellinger" wrote in message news:94n920$e66$1 at animus.fel.iae.nl... [snip] > > Yep, I remember the debates!-) The little fact that our > > approach *WORKED* (allowing a 20,000-word vocabulary real > > time recognizer to be first built in 1984), of course, > > Impressive! (I take it it did single words only, and I guess it needed > training to get a good profil of the speaker, but still impressive) Real-time speech but not continuous one (short-as-you-wish, but mandatory, pause between words -- we called it 'dictation' speech), and 15-minutes training needed per speaker; took a dedicated IBM mainframe with a few CPU's and 'vector features', or equivalent (3rd party vector-processing units for the same class of mainframe). It _was_ 1985 before 'we' (actually some brilliant HW guys in IBM Research) turned out special- purpose boards that you could stuff inside an IBM PC/AT to make it perform the same task (maybe even early '86 before the latter box was reliable enough to announce & demo) -- what we contributed to the miniaturization effort was a study of numeric sensitivity, to turn the computations into fixed-point ones at various minimal-sufficient precisions along the algorithms' paths. > But if I remember correctly, the use of frequency analysis to > recognize spoken words was not what was criticised at all. We (the You don't (remember correctly) -- being the target of such criticisms sharpens one's memories:-). I remember silencing a critic once in public debate about this -- he claimed it's not truly feasible to 'take dictation' without any understanding whatsoever, and I gave the counterexample of my father and his secretary... he, a specialist physician, all the time dictating extremely specialized and obscure texts -- she, an efficient dactilographist, not caring AT ALL about understanding of what she was writing down, as long as she knew exactly how to SPELL each of the totally-meaningless-to-her words and names. In fact, that's why, she explained, she could not do *stenography* for his reports -- THAT does require a modicum of understanding of WHAT is being written about, it seems -- rather, she typed right at the typewriter as he dictated (the way he DID dictate would have been perfectly suitable for our recognizer, save for occasional [and inadvertent] lack-of-pause between two adjacent words... which occasionally made HER go wrong, too!). > members of the Rosetta team) felt a bit awkward by the claim that > stochastic models were better suited to attach meaning to (written) > natural language and even to weed ambigueties. Grammars, on the other > hand, are soo crisp and clear, hence easy to understand:) Probably had Right -- and therefore insufficient to model what human beings actually DO with language:-). > to do with some defect in our minds; I for one never grogged Perl, yet > with Python it was love at first sight. Same here, though I did use Perl a lot before finally meeting Python (lack of perceived alternatives...). Alex From cfelling at iae.nl Mon Jan 22 21:13:38 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 23 Jan 2001 03:13:38 +0100 Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> Message-ID: <94ipci$afo$1@animus.fel.iae.nl> Steve Williams wrote: ... > Ah yes, but ftplib (and the example in the code and in Beazley) does the > following: ...example snipped My point was that instead of > from somelib import somefunc you should use import somelib then the following would work > try: > somelib.somefunc() > except somelib.myError: > 'do something about it' -- groetjes, carel From katz at Glue.umd.edu Fri Jan 26 23:36:43 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Fri, 26 Jan 2001 23:36:43 -0500 Subject: . Python 2.1 function attributes In-Reply-To: <94tbm0$12$1@news.udel.edu> References: <94tbm0$12$1@news.udel.edu> Message-ID: My question is this: what is the point of letting functions have attributes when the same role is fulfilled cleanly by classes which implement __call__()? My previous long post showed an example. Roey On Fri, 26 Jan 2001, Terry Reedy wrote: > Since functions are and always (for at least five years) have been > (Py)Objects and since they have always had attributes (like many other > types of PyObjects), it is still not clear what you are asking, and hence > the paucity of answers. > > The new thing in 2.1 is to allow users to directly set as well as read > user-defined function attributes. This eliminates the need for certain > kludgy workarounds that people have been resorting to. > > Terry J. Reedy > > > > From nospam at mega-nerd.com Fri Jan 26 22:39:24 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Sat, 27 Jan 2001 03:39:24 GMT Subject: Tkinter : button size References: <3A722DED.74B41DA1@mega-nerd.com> Message-ID: <3A723FD9.5AA0CDB@mega-nerd.com> dsavitsk wrote: > > > Is there any neat way I can force all the buttons to be the same > > size regardless of the number of characters in the label? > > self.cmdX = Button(frame, width=15, text='Text Here', borderwidth=3, > relief=GROOVE, command=self.cmdXPress) Perfect!!!! I also really like what "relief=GROOVE" does to those buttons. Cool!!! Thanks, Erik -- +----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) +----------------------------------------------------------+ Complex problems have simple easy to understand wrong answers. From alan.gauld at gssec.bt.co.uk Wed Jan 10 09:33:15 2001 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Wed, 10 Jan 2001 14:33:15 +0000 Subject: How robust is Python ? References: <9358nn$3c5$1@nnrp1.deja.com>, <9354f9$vbi$1@nnrp1.deja.com>, <9365p9$s2k$1@nnrp1.deja.com> Message-ID: <3A5C72AB.BD43E182@gssec.bt.co.uk> rturpin at my-deja.com wrote: > In article , > Moshe Zadka wrote: > > .. C/C++ core dumps at the drop of a pointer. .. > In theory, that's an application flaw, Mot in theory, in practice. Its just very easy to have these flaws in C++. But most modern telephone switches are written in C++ and they run with "seven 9's" reliability, ie. 99.99999% uptime. It's an industry standard for public switches. Better than any computer you can by off the shelf even so called high availability boxes. But the software takes an age to develop, needs good CASE tool support combined with formal methods. It's possible, just costly. Python provides an easier and cheaper path to similar levels of reliability but bad programming will still be buggy programming. Just don't blame the language. > software engineering produces C/C++ programs that > very rarely dereference bad pointers. It's harder > and more work than development with Python. exactly so. Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From sandj.williams at gte.net Thu Jan 11 12:33:24 2001 From: sandj.williams at gte.net (Steve Williams) Date: Thu, 11 Jan 2001 17:33:24 GMT Subject: ActivePython2.0 - Server Side objects for ASP problem References: <93j0qi$7cv$1@bob.news.rcn.net> <93k6k5$1g7$1@bob.news.rcn.net> <9li76.10661$X3.66765@e420r-atl1.usenetserver.com> <3A5DD081.F37275A@gte.net> Message-ID: <3A5DEFB2.D3E92632@gte.net> Steve Holden wrote: > "Steve Williams" wrote in message > news:3A5DD081.F37275A at gte.net... > > Steve Holden wrote: > > > > > "Satheesh Babu" wrote in message > > > news:93k6k5$1g7$1 at bob.news.rcn.net... > > > [snip] > > > [snip] > So I suspect that all your valid objections are objections to something I > wasn't suggesting, and are not required. I could be wrong, though. Maybe I > *was* suggesting that, or maybe that *is* required :-) No, no. You're right. I didn't read the thread carefully. As you might guess, I've been obsessed with DCOM problems lately. I'll be better once I take my meds. From jdries at mail.com Tue Jan 16 21:30:57 2001 From: jdries at mail.com (Jan Dries) Date: Wed, 17 Jan 2001 03:30:57 +0100 Subject: Relational Databases and Python References: Message-ID: <3A6503E1.2818971@mail.com> Chris Watson wrote: > > > My reading of the PostgreSQL web site leads me to believe you'll be > > "limited" to UNIX platforms, I can't remember far enough back in the thread > > to determine whether this matters or not. > > Limited in platforms? AFAIK Postgresql runs on more unix platforms > than any other DB out there. Does your statement in any way change the "limited to UNIX" claim in the original post? Jan From jasonic at nomadicsltd.com Wed Jan 17 12:34:44 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Wed, 17 Jan 2001 12:34:44 -0500 Subject: Best way to learn Python ? References: <943sn302g4p@news2.newsguy.com> Message-ID: Alex Martelli wrote in message news:943sn302g4p at news2.newsguy.com... > "J5" wrote in message > news:aa8a6t895h8l3k2q7nmhd25oh6m7haulj9 at 4ax.com... > > No schools teach it, so what books do you recommend ? > > O'Reilly's "Learning Python", by Lutz and Ascher, for a slow, > patient, very thorough introduction to the basics; or, if you > prefer faster pace and more breadth (but a bit less depth), > Manning's "Quick Python Book", by Harms and McDonald. Yes. I agree. Add to this list the bright new one: 'Core Python Programming' by Wesley Chun Paperback - 500 pages 1st edition (December 15, 2000) Prentice Hall; ISBN: 0130260363 http://www.amazon.com/exec/obidos/ASIN/0130260363/o/qid=979751098/sr=8-1/ref =aps_sr_b_1_1/107-8994515-3258904 Very well written. It is the clearest, friendliest book I have come across yet for explaining Python, and putting it in a wider context. It does not presume a large amount of other experience. It may be too slow for more advanced people, but it does goe into some important Python topics carefully and in depth. Unlike too many beginner books, it never condescends or tortures the reader with childish hide-and-seek prose games. The author helped to develop 'Yahoo!Mail' and 'Yahoo!People Search' using Python. Not too many in-depth realworld examples in the book [hopefully he will do a followup volume], it sticks to gaining a solid grasp of Python syntax and structure. But there is some good stuff on regulra espressions, network Sockets Plus+ if you are working on Win32, check out: 'Python Programming on Win32' by Mark hammond and Andy Robinson Paperback - 652 pages 1 Ed edition (January 2000) O'Reilly & Associates; ISBN: 1565926218 http://www.amazon.com/exec/obidos/ASIN/1565926218/qid%3D979752107/107-899451 5-3258904 Packed with useful practical stuff. Very well written. Good examples. Essential for any Python + COM work. One of the authors [Mark Hammond] wrote the PythonWin extensions, so he really knows what he is talking about. As a Python beginner's book it dives in deep very quickly, and althouth the intro to Python is good, it does assume prior programming experience. Lots of great stuff on how to connect Python with MSExcel and plenty of real-world operating sytem interfacing examples. good luck! - Jason From richard_chamberlainREMOVE at ntlworld.com Tue Jan 16 02:24:13 2001 From: richard_chamberlainREMOVE at ntlworld.com (Richard Chamberlain) Date: Tue, 16 Jan 2001 07:24:13 -0000 Subject: stackless python for palm Message-ID: Hi, I believe there was a project at one point for stackless for palm. Any news on progress? Thanks, Richard From tanzer at swing.co.at Tue Jan 23 03:45:01 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Tue, 23 Jan 2001 09:45:01 +0100 Subject: wxPython In-Reply-To: Your message of "Mon, 22 Jan 2001 11:32:56 EST." <3A6C60B8.72249CDB@mitre.org> Message-ID: Mike Brenner wrote : > The second thing that can be gotten to work, but you must develop on > windows and port to Linux (not the other way around) is the sizing of > the intermediate levels of objects. Like most GUIs, wxPython requires > many levels of objects (windows, frames, etc., etc.). If you develop the > GUI on Linux, the sizing/resizing/automatic sizing always works on Linux > but fails when moved to Windows. Windows requires a lot more sizing > calls at a lot more intermediate levels to make it work correctly, > otherwise everything gets jumbled up on top of each other. (snip) > We were not able to get TK-inter or GTK to convert so it worked on both > Linux and WIndows with the same source code in the same amount of time, > so we stopped working on them. I don't know any details about wxPython, but both TK and GTK provide geometry managers solving exactly the problem you are talking about. I use Linux for devleopment and apart from a few glitches, TK GUI's work exactly alike under Linux and Windows. There are very few platform dependencies in my GUI code. -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From boud at rempt.xs4all.nl Sat Jan 6 04:50:44 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 6 Jan 2001 09:50:44 GMT Subject: Question about IDLE References: <9364b7$qse$1@nnrp1.deja.com> <936db1$1f0$1@nnrp1.deja.com> Message-ID: <936ppk$og9$1@news1.xs4all.nl> one61803 at my-deja.com wrote: > Yes, I've tried setting idle.font, idle.fontFamily, idle.fontList, etc. Also, > I've looked through the source code for all occurences of the word "font" and > have not identified any sections that actually specify a font for idle (other > than the one for windows). For the Idle that comes with Python 2.0, there's a text file in the source directory, config-unix.txt that you can change. You can also edit a .idle file in your home directory (though why that shouldn't be called .idlerc like the rest of them I don't know). Look in IdleConf.py to see how it's done. -- Boudewijn Rempt | http://www.valdyas.org From tomega at earthlink.net Thu Jan 25 15:27:27 2001 From: tomega at earthlink.net (Simon Kesenci) Date: Thu, 25 Jan 2001 20:27:27 GMT Subject: Library paths References: <94pm5p$mhi$1@nnrp1.deja.com> Message-ID: Add the path into /etc/ld.so.conf, then run ldconfig as root. --S. sp00fD wrote: > I build Python2.0, and added in tk support. Now when I try to use > python, I get: > ld.so.1: python: fatal: libtk8.3.so: open failed: No such file or > directory > > I can set my LD_LIBRARY_PATH to point to the directory which holds the > tk library and everything is cool. The question is, is there any way > to build python so that I don't have to add a LD_LIBRARY_PATH entry to > all the users? > > > Sent via Deja.com > http://www.deja.com/ -- Coito ergo cum. From dalke at acm.org Wed Jan 10 19:28:04 2001 From: dalke at acm.org (Andrew Dalke) Date: Wed, 10 Jan 2001 17:28:04 -0700 Subject: boolean xor References: <93ace8$nmo$1@panix3.panix.com> <93i7ne$5dk$1@nnrp1.deja.com> <93i9ff$q4l$1@slb0.atl.mindspring.net> Message-ID: <93iuj9$jta$1@slb3.atl.mindspring.net> Rainer Deyke wrote: >You could, however, remove a redundant 'not' from the original: > >def xor(a, b): return (a or b) and not (a and b) That may find the truthness of a and b twice, which might not give the expected behaviour. Eg, if __nonzero__ takes time to compute (as with a proxy to a remote object) then the overhead may be twice as long. Andrew dalke at acm.org From NoSpam at NoSpam.com Fri Jan 19 12:16:28 2001 From: NoSpam at NoSpam.com (Tom) Date: Fri, 19 Jan 2001 17:16:28 GMT Subject: Jython-2.0 released References: <1nR96.8075$Mo6.76257@e420r-atl1.usenetserver.com> Message-ID: "Steve Holden" wrote in message news:1nR96.8075$Mo6.76257 at e420r-atl1.usenetserver.com... > [Jython announcement] > > "Tom" wrote in message > news:m8P96.185124$59.49360823 at news3.rdc1.on.home.com... > > I thought that what existed before was a python enterpreter written in > Java. > > But this sounds like a Python compiler. Is this something new? > > > > Tom. > > > No. JPython was similar to standard (C)Python in that it compiled to > intermediate byte codes and interpreted them. The smart part was compiling > to *Java* bytecodes instead of Python bytecodes. Jython programs can be run > by any Java Virtual Machine implementation, and therefore get pretty amazing > integration with Java classes. It is possible to have Python classes > subclassing Java classes, and vice versa. Looking at this from the point of reference of the Java platform, this was not, but is now a compiler. It sounds really good, but it also sounds like a lot of work was involved. Tom. > Jython 2.0 is an implementation of JPython which > > a) Avoids impinging on CNRI's rights to the name JPython, and > > b) Brings the Python language synatx into line with Python 2.0 > > although-2.1-is-just-around-the-corner-ly y'rs - steve > From Dan.Rolander at marriott.com Fri Jan 26 08:52:54 2001 From: Dan.Rolander at marriott.com (Rolander, Dan) Date: Fri, 26 Jan 2001 08:52:54 -0500 Subject: Why isn't crypt.py in Win32 Python distribution? Message-ID: <6176E3D8E36FD111B58900805FA7E0F80CCF6337@mcnc-mdm1-ex01> Thanks Michael. I had already found that and it is perfect! Dan -----Original Message----- From: Michael Hudson [mailto:mwh21 at cam.ac.uk] Sent: Friday, January 26, 2001 8:20 AM To: python-list at python.org Subject: Re: Why isn't crypt.py in Win32 Python distribution? "Rolander, Dan" writes: > Just curious. Why isn't crypt.py included in the standard python > distribution for Windows? I needed the crypt() function and finally found > fcrypt.py which was very helpful, but it seems it should be standard in > Windows just like in the Unix distribution. Try: http://www.vex.net/parnassus/apyllo.py?i=54474698 (I haven't, apart from checking the link works). Cheers, M. -- > Why are we talking about bricks and concrete in a lisp newsgroup? After long experiment it was found preferable to talking about why Lisp is slower than C++... -- Duane Rettig & Tim Bradshaw, comp.lang.lisp -- http://mail.python.org/mailman/listinfo/python-list From aleaxit at yahoo.com Thu Jan 4 06:07:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 12:07:39 +0100 Subject: A single, general looping construct? (was: why no "do : until"?) References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <92qc21$538$1@nnrp1.deja.com> <0O7zTzsxerl5-pn2-SISYKtwXTOmR@bill> Message-ID: <931lji02ik1@news2.newsguy.com> "William Sonna" wrote in message news:0O7zTzsxerl5-pn2-SISYKtwXTOmR at bill... [snip] > Object Rexx's implementation of the generalized do is the best I've > seen (in a real language, that is). Works like this: Snipping: 5 different forms that _still_ don't cover the Knuth-identified general case of "N-and-1/2-times" loops. We clearly have a very different idea of what the word "best" means. *Entities are not to be multiplied needlessly* -- Occam's razor. ONE general loop form, plus one form for the very important case of loops over a sequence, seems just right to me. > while count < 100: # zero or more iterations [snip] > until count <=100: # one or more iterations [snip] > Which are all (with the exception of the ones that are identical or > nearly identical) cleaner and even more Pythonic than Python. We clearly also disagree on the adjectives 'clean' and 'Pythonic'. Since when is it Pythonic to have many equivalent ways to express one concept? It's not Python that has both 'if' and 'unless', for example -- it's Perl. A language which has both while and until for loops, but doesn't have both if and unless for non-loop tests, is inconsistent; one which has one form in each case, and one which systematically adopts multiple forms whenever feasible, are each consistent, albeit with, clearly, VERY different underlying philosophy. "Do the simplest thing that can possibly work", "there should be exactly one way to perform a task" -- that is one philosophy. It is Python. The exactly-opposite philosophy, that of "the more ways, the merrier", of exhuberant, post-modern richness, is Perl's. How can you possibly call 'Pythonic' something which goes so drastically against the grain of its basic tenets? > Fortran had even simpler control structures than Python, and was a > royal pain to use as a result. Surely you're joking, Mr Sonna. Have you ever USED Fortran?! I must have written and maintained many tens of thousands of lines in it. How can you POSSIBLY assert that the set of its control structures is "simpler than Python's"?! Simple GOTO, assigned GOTO, computed GOTO, logical IF, arithmetic IF, the DO statement... it's *brimming* with complexity! (Let's not even get into Fortran 77, which added even more). Just the rules about what kinds of GOTO's are acceptable across which kind of DO-statement boundaries get longer to explain than the whole Python language!-) Anyway, simplicity is not enough -- it's the simplest thing *that can possibly work*. A language with a truly simple set of control, well, 'structures', was Snobol -- the single concept of 'success and failure' (with backtracking), and conditional jumps controlled by success and failure. The simplicity of conditional jumps as the only control-structure doesn't work well with the human mind's limitations in keeping track of disparate things -- so the need to wrap up those jumps into actual structures is well accepted today as a working need. (The success/failure concept, and backtracking to go with it, are far from being proven failures -- Icon took them from Snobol, wrapped them into actual structures, and was [is] a very interesting language as a result; unfortunately, the set of structures chosen emerged as far from simple -- just explaining the difference between 'while' and 'every' to an Icon beginner is a headache). The need for structure is not under discussion: rather, the basic guideline on how to pick the structures. Some languages bask in 'being very expressive' by making you choose among umpteen ways to express the same thing, a la Cobol's ADD CREAM TO ESPRESSO GIVING CAPPUCCINO vs LET CAPPUCCINO = CREAM + ESPRESSO I'm quite happy for people who like such "expressive richness" to pursue it in the many languages that follow this "the more the merrier" philosophy -- Cobol and Perl being just two reasonably consistent examples of such redundance. It would just be nice if, in turn, such people accepted the existence of languages based on a *diametrically opposite* underlying philosophy of *language simplicity* as a value -- and Python is a pretty good example of such a language (not _perfect_, of course -- it IS a human endeavour, and thus fallible, witness the 'print>>' construct... but, quite reasonably close). Having several different and perfectly equivalent ways of expressing the same thing, just because you believe that bleep() unless bloop(); is 'prettier' ('more directly expressive', whatever) than if not bloop(): bleep() is Perl's way. If you want Perl, you know where to find it. Just don't try to Perl-ize Python... ONE Perl is enough (some would say, far more than enough). > Although I enjoy using Python and am generally supportive of its > minimalist philosophy, I still believe that the "while 1: buried > break" is a step backwards. I have repeatedly agreed that it's not optimal syntax, but *adding* special-case syntax forms is exactly the wrong way to go. ONE general syntax form for general loops: loop : while : would probably be ideal (with the loop-over-sequence form, since it's *such* a common case, singled out). But it ain't gonna happen -- the gain is just too small for the disruption. > Many of the classic algorithms are best expressed with "do until" or > "repeat until" and translating them into Python requires the > introduction of a uniquely inelegant language idiom. I just don't think they're that many! Out of all loops one needs I think about 2/3 are best expressed as loop-over-sequence; of the remainder, about 2/3 are best expressed as single-test ones with the test at the start; of the remainder, about 2/3 need the general test-in-the-middle form for best expression. Just a few % are left in the special-case form where test-at-the-end would prove best. Of course, one general loop form would cover them all equally, so the exact numbers don't matter much (save for the enormous frequency of loop-on-sequence, which justifies singling it out). I *particularly* disagree that Python's syntax for the general loop is "uniquely inelegant", whatever you're trying to convey with that "uniquely". The spelling of the second clause in the general loop form as (indented) 'if not : break' is, at worst, slightly awkward -- the very popularity of 'break' as a keyword in other languages (and the extremely similar semantics of equivalent keywords in languages which have a slightly different syntax, such as Perl's "last") helps to mitigate the perception of this awkwardness. What WOULD be truly inelegant, in my view, would be to have a zillion ways to express special cases of one general form; at least we have the general form itself, albeit not with optimal syntax sugar to accompany it. Alex From moshez at zadka.site.co.il Tue Jan 23 10:31:24 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 23 Jan 2001 17:31:24 +0200 (IST) Subject: unpack sequence to tuple? In-Reply-To: <94j6j1$3na$1@nnrp1.deja.com> References: <94j6j1$3na$1@nnrp1.deja.com> Message-ID: <20010123153124.912A3A83E@darjeeling.zadka.site.co.il> On Tue, 23 Jan 2001 05:58:58 GMT, noahspurrier at my-deja.com wrote: > I want to easily read arguments in a sequence into separate variables. > Basically, I want to use a Per1 idiom and do this: > > (cmd, host, user, key) = tuple(sys.argv) No need for the tuple() or the () on the LHS: cmd, host, user, key = sys.argv Will work just ine. If you want padding, just roll your own class: class PaddedSeq: def __init__(self, s, n): self.s = s self.n = n def __len__(self): return self.n def __getitem__(self, i): if not (0<=i This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From dsavitsk at e-coli.net Fri Jan 26 22:26:45 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Fri, 26 Jan 2001 21:26:45 -0600 Subject: Tkinter : button size References: <3A722DED.74B41DA1@mega-nerd.com> Message-ID: > Is there any neat way I can force all the buttons to be the same > size regardless of the number of characters in the label? self.cmdX = Button(frame, width=15, text='Text Here', borderwidth=3, relief=GROOVE, command=self.cmdXPress) ds From n8gray at caltech.edu Sun Jan 28 17:01:11 2001 From: n8gray at caltech.edu (Nathaniel Gray) Date: Sun, 28 Jan 2001 14:01:11 -0800 Subject: "in" for dicts (was: Python 2.1 function attributes) References: Message-ID: <3A7496A7.253B7B67@caltech.edu> Tim Peters wrote: > > [Robin Becker] > > yes I figured it was a bit funny, but nastier things are proposed and > > aren't laughed off. > > By whom? They're *scowled* off by Guido, and that's all that counts in the > end. > > > -why don't we have $ and @ and \ operators-ly yrs- > > Because so far, Guido hates them. This is usually something you can count > on for life. But, e.g., in the past he disliked the idea of being able to > say > > if key in dict: > > instead of > > if dict.has_key(key): > > because in the first form it's not 100% clear whether you're asking if key > is in dict.keys() or dict.values() or dict.items(). In a once-per-decade > reversal, he changed his mind about that last week, and Thomas Wouters > graciously implemented it for 2.1. > > It's a nice addition. People will complain about it, and some bitterly, but > so it goes. > > when-people-disagree-not-everyone-gets-what-they-want-ly y'rs - tim Funny, I was going to bring this up in this thread as a bad idea that actually _is_ going into Python 2.1. Let me then be the first to complain about it (perhaps not bitterly). If I was to ask you, "Tim, is 'larch' in Webster's dictionary?" would you reply, "Yes, it's under 'L'", or would you reply, "No, there's no 'larch' section, just A,B,C,D,..."? (I know you'd _actually_ reply "Look it up yourself!" ;^) "in" just doesn't imply "has_key" for dictionaries. Note for those who don't read python-dev: It seems this "feature" is being added to facilitate the use of dictionaries as sets, so you can say: if something in my_set: something.foobar() and the like. Couldn't we just have a collections module for Python that gave us a set class (and all the other wonders that CS can produce) without mucking up dictionaries? -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From tim.one at home.com Sat Jan 27 18:12:12 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 27 Jan 2001 18:12:12 -0500 Subject: . Python 2.1 function attributes In-Reply-To: Message-ID: [Robin Becker] > yes I figured it was a bit funny, but nastier things are proposed and > aren't laughed off. By whom? They're *scowled* off by Guido, and that's all that counts in the end. > -why don't we have $ and @ and \ operators-ly yrs- Because so far, Guido hates them. This is usually something you can count on for life. But, e.g., in the past he disliked the idea of being able to say if key in dict: instead of if dict.has_key(key): because in the first form it's not 100% clear whether you're asking if key is in dict.keys() or dict.values() or dict.items(). In a once-per-decade reversal, he changed his mind about that last week, and Thomas Wouters graciously implemented it for 2.1. It's a nice addition. People will complain about it, and some bitterly, but so it goes. when-people-disagree-not-everyone-gets-what-they-want-ly y'rs - tim From jurgen.defurne at philips.com Tue Jan 23 03:05:36 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Tue, 23 Jan 2001 09:05:36 +0100 Subject: PSU uses emacs? Message-ID: <0056900015343304000002L042*@MHS> A few months ago I was very busy in CP/M (I am coding a Z80 emulator), and what I found about QDOS, was that Tim Paterson needed a 16-bit version of CP/M, and that he (annoyed by Digital Research) decided to write his own version. He started from CP/M, because he it was the only thong he knew and he needed it fast. Jurgen grante at visi.com@SMTP at python.org on 22/01/2001 17:15:12 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: PSU uses emacs? Classification: In article <94cktu$d9c$1 at news.wrc.xerox.com>, Mark Jackson wrote: >> This is speculation, based on the philosophical attitudes I have observed in >> the two groups concerned. 8^} Who designed DOS anyway, Gary Kildall wasn't >> it? > >That was CP/M, the 16-bit version of which was considered by IBM for >their PC but not chosen. MS-DOS was first licensed and then purchased >by Microsoft from Seattle Computer Products. It was written by Tim >Paterson; heavy CP/M influence is evident, but it was far from a >clone. See Paul Ceruzzi, /A History of Modern Computing/. Looked like a clone to me. Virtually identical FCB structure, BIOS entry point at 0x0005, same executable layout, etc. etc. -- Grant Edwards grante Yow! They don't hire at PERSONAL PINHEADS, visi.com Mr. Toad! -- http://mail.python.org/mailman/listinfo/python-list From aleaxit at yahoo.com Thu Jan 11 17:05:38 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 11 Jan 2001 23:05:38 +0100 Subject: using IE5 HTML DOM parser in python ? References: <93kpp4$51p$1@reader1.imaginet.fr> Message-ID: <93lb1h0227f@news1.newsguy.com> "Gilles Lenfant" wrote in message news:93kpp4$51p$1 at reader1.imaginet.fr... > Hi, > > Seems that it is not easy to parse ugly HTML (not "well formed" in XML > wording) with the htmllib. > I can do it easily with the IE5 included HTML DOM parser but it's in > javascript and the script is to be included in the HTML. > Did any of U succeed to use it from python and win32 extensions. Maybe I don't understand your problem correctly. The HTML DOM that comes with IE5 is COM/Automation (accessible from JScript, but definitely not just from there) -- easy to access from Python (with 'makepy' support, ideally). And I don't understand "the script is to be included in the HTML" together with your need to parse the HTML itself -- if you need to parse scripts in arbitrary scripting languages, that IS indeed difficult (and HTML DOM has no help for that)... but why would you need that? Alex From clickron at webtv.net Wed Jan 24 17:15:06 2001 From: clickron at webtv.net (clickron at webtv.net) Date: Wed, 24 Jan 2001 17:15:06 -0500 (EST) Subject: beep again References: <5251-3A6E5B71-16@storefull-163.iap.bryant.webtv.net> Message-ID: <29605-3A6F53EA-11@storefull-168.iap.bryant.webtv.net> I'm afraid all I get is the windows ding. No other changes. Ron From db3l at fitlinxx.com Mon Jan 29 15:06:33 2001 From: db3l at fitlinxx.com (David Bolen) Date: 29 Jan 2001 15:06:33 -0500 Subject: win32 DLL import problem References: Message-ID: "John J. Lee" writes: > I compiled multipack on NT with cygwin, with the -mno-cygwin switch, which > is supposed to link against the same C run-time library as the python 2.0 > distribution itself, msvcrt.dll (which is there on the win95 machine) > rather than the cygwin crtdll, so presumably that can't be the problem, > but since I don't know which file it can't find, it's hard to say! It > does import okay on NT. Since you've got cygwin, try using the cygcheck utility to check out the DLL dependencies to ensure it uses what you think. There's also a tool that comes with the NT resource kit (and perhaps independently if you search around) called "depends" that's a native Win32 dependency checker. Python just uses a Win32 LoadLibrary (or LoadLibraryEx, I forget) to load the module, and if an underlying DLL dependency can't be resolved, that level of detail isn't exported back through the API, so it's not really Python's fault for not displaying a more concrete error message. -- -- 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 sandj.williams at gte.net Tue Jan 9 13:35:54 2001 From: sandj.williams at gte.net (Steve Williams) Date: Tue, 09 Jan 2001 18:35:54 GMT Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: <3A5B5B55.198BC2C5@gte.net> Robin Becker wrote: > In message , Oleg > Broytmann writes > >On Tue, 9 Jan 2001, Robin Becker wrote: > >> > Anyone here has any doubts that at least mxDateTime simply MUST be in > >> >the Python core? :) > >> > > >> > >> I'm a minimalist; let 100 flowers bloom, but the core should really only > >> include the minimal required. Fancy dates are a bit too far for me. I > > > > mxDateTime is not for fancy dates. Many SQL modules use it for returning > >DATE/TIME fields from SQL. Think also about including it into Zope > >(replacing current simple DateTime)... > > > >Oleg. > ... > SQL modules are even less essential in the core. > -- > Robin Becker Some of us think SQL modules are as important as file modules. Maybe more important. From akuchlin at mems-exchange.org Tue Jan 23 16:30:46 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 23 Jan 2001 16:30:46 -0500 Subject: I mean *setup.py* ! ... (more questions) References: <3d3dea3vuh.fsf@ute.cnri.reston.va.us> <94knmm$2vi$1@murdoch.acc.Virginia.EDU> Message-ID: <3dzogi2by1.fsf@ute.cnri.reston.va.us> sdm7g at minsky.med.Virginia.EDU (Steven D. Majewski) writes: > If there are modules in this list, does setup.py detect that and not > try to build them shared also ? Yes, it does; Martin von Loewis pointed this out before the alpha1 release. I don't know what the case-insensitivity fix should be, though. Can you please report this on the SourceForge bug tracker so it doesn't get forgotten? --amk From aleaxit at yahoo.com Thu Jan 25 07:41:55 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 25 Jan 2001 13:41:55 +0100 Subject: The fundamentals... References: <20010124085846.A32572@glacier.fnational.com> Message-ID: <94p6uh024lf@news2.newsguy.com> "Neil Schemenauer" wrote in message news:mailman.980382102.30218.python-list at python.org... > On Wed, Jan 24, 2001 at 08:58:46AM -0800, Neil Schemenauer wrote: > > So you can do: > > > > boo = string.replace(". ", "\n") > > That should be: > > boo = string.replace(boo, ". ", "\n") Or boo = boo.replace('. ', '\n') [in Python 2, but surely we're all upgraded by now, aren't we?-)] Alex From gregj at pobox.com Sat Jan 27 23:03:06 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Sun, 28 Jan 2001 04:03:06 GMT Subject: Python vs Ruby References: <94mdkd$222e$1@news.adamastor.ac.za> <877l3h5a29.fsf@hoyogw.netlab.co.jp> <94voh3$5nm$1@snipp.uninett.no> Message-ID: <9505lo$v21$1@nnrp1.deja.com> In article <94voh3$5nm$1 at snipp.uninett.no>, "Magnus Lie Hetland" took Yukihiro Matsumoto to task for his comparison of Fibonacci functions in Python and Ruby: > > double? Fibonacci is mostly based on function calls > > Not necessarily... > > (By the way, your function wasn't altogether correct...) With all respect, yours is even worse. It doesn't generate a correct Fibonacci sequence (your function gives 1,1,3,4,5,7,9,12,16,...). A simpler (and correct) iterative Python function is: ---- def fib(n): a,b = 0,1 while n > 0: a,b = b,a+b n = n-1 return a ---- My version will correctly return 0 for fib(0); your function returns 1. And I avoid the range() call. I tested both versions with: for i in range(10): print fib(i) -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From cjensen at bioeng.ucsd.edu Wed Jan 3 16:12:21 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 03 Jan 2001 13:12:21 -0800 Subject: Name Error Message-ID: <3A5395B5.EBE77FA4@bioeng.ucsd.edu> Below is a bit from my Python interpreter. The "stored_data" variable is a global list. It should be seen from within the "send_data" function. However, I get a NameError here. I ran it with pdb; pdb is able to output the "stored_data" variable from within the "send_data" function. However, it still gives a NameError. "stored_data" works in all of my other functions except this one? Any ideas? >>> pdb.run( 'main()' ) > (0)?() (Pdb) b send_data Breakpoint 1 at cont_client.py:3078 (Pdb) r > (1)?() (Pdb) c CONTINUITY ver 5.00 Wed Jan 3 12:50:16 2001 CONTINUITY>> send > cont_client.py(3078)send_data() -> print stored_data[0] (Pdb) p stored_data [] (Pdb) n NameError: 'stored_data' > cont_client.py(3078)send_data() -> print stored_data[0] (Pdb) -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From jp at NOSPAMdemonseed.net Mon Jan 22 19:20:17 2001 From: jp at NOSPAMdemonseed.net (jason petrone) Date: Tue, 23 Jan 2001 00:20:17 +0000 Subject: IP Octet Patern Match References: <3A6CBDC4.C5F292C9@tampabay.rr.com> Message-ID: <1oii49.c4v.ln@demonseed.net> Kevin Fiscus wrote: > I am extremely new to Python. Can anyone help me to design a script > that will find the IP addresses from email headers and write the entire > line where they are found to another text file? I do something similar to this to process my ipfilter logs. ------------------------- import sys, re lines = sys.stdin.readlines() for line in lines: if re.search('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', line): print line[:len(line)-1] ------------------------- I'm using 'print line[:len(line)-1]' instead of 'print line' in order to strip off the trailing new line. You might need -2 if it is dos formatted text. Notice this doesn't handle IPV6 addresses. -jason From cpsoct at my-deja.com Sat Jan 20 03:56:40 2001 From: cpsoct at my-deja.com (cpsoct at my-deja.com) Date: Sat, 20 Jan 2001 08:56:40 GMT Subject: How to chop list n-elements at a time Message-ID: <94bjs8$5nn$1@nnrp1.deja.com> I've been at this a while and can't seem to get it to work. I am wondering if others know how, have tried, or already have written a func to package up list elements in sublists n at a time. I was able to get something that worked for bunches of 1, or 2, but i am wondering how to make the tool more general so that i could say: x=[1,2,3,4,5,6,7,8,9] bunch(x,1) --> [[1], [2], [3], [4], [5], [6], [7], [8], [9]] bunch(x, 2) --> [[1,2], [3,4], [5,6], [7,8], [9, None] bunch(x, 3) --> [[1,2,3], [4,5,6], [7,8,9]] bunch(x, 4) --> [1,2,3,4], [5,6,7,8] [9, None, None, None]] The algo. i was using for two at a time for example just tested for even and odd. but i am not sure how to do generalize to create the above. cheers, kevin parks cpsoct at lycos.com Sent via Deja.com http://www.deja.com/ From nospam at wanted.com Thu Jan 11 02:02:53 2001 From: nospam at wanted.com (huber) Date: Thu, 11 Jan 2001 08:02:53 +0100 Subject: tk3000 on linux Message-ID: can you tell me how to install tkinter3000 on a linux box? thanks udo From timr at probo.com Tue Jan 23 01:23:57 2001 From: timr at probo.com (Tim Roberts) Date: Mon, 22 Jan 2001 22:23:57 -0800 Subject: Random and whrandom References: <94bj03$59v$1@nnrp1.deja.com> <3a6a3540.1976549@news.xo.com> Message-ID: bogus at bogus.net wrote: >The whrandom algorithm may not generate very good random numbers. I >created a pair of dice objects and rolled them 10,000 times, there >seems to be a bias against rolling the same number on both dice. Umm, in the long term, there SHOULD be a 5-to-1 bias against rolling the same number on both die. whrandom is a linear congruential random number generator. The properties are well-understood; in the long term, each number in the sequence occurs once before any number is repeated. However, short sequences will not show the same uniformity. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dsh8290 at rit.edu Mon Jan 29 11:18:20 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 29 Jan 2001 11:18:20 -0500 Subject: Python vs Ruby In-Reply-To: <20010126045052.A4684@glacier.fnational.com>; from nas@arctrix.com on Fri, Jan 26, 2001 at 04:50:52AM -0800 References: <94mdkd$222e$1@news.adamastor.ac.za> <87puhbndn5.fsf@hoyogw.netlab.co.jp> <"from loewis"@informatik.hu-berlin.de> <20010126045052.A4684@glacier.fnational.com> Message-ID: <20010129111820.C15924@harmony.cs.rit.edu> On Fri, Jan 26, 2001 at 04:50:52AM -0800, Neil Schemenauer wrote: | [Martin von Loewis on the Ruby GC] | > So I shall find some time to study its weaknesses :-) | | The Python FAQ has some good information on why Python uses | reference counting. RC gives good finalization semantics, plays | nicely with other memory managers, and is very portable. | | RC also works quite well with data caches and VM managers. Using | the Boehm-Demers GC with Python and disabling reference counting | slows the interpreter down by a significant amount. Really? This is interesting. I had thought that it would be faster. At the very least, the simple assignment statment can be simple. With RC, both arguments' ref counts have to be checked first and then updated appropriately. Just out of curiosity, how do/did you disable the ref counting in the interpreter? All the tests I've seen of the Boehm collector used C programs originally designed for malloc/free, not using any ref counting schemes. Maybe this has an effect? I wonder if python was designed for the collector instead of ref counting if this would improve its performance . . . (not that it is exceptionally slow now anyways) | | Neil | always-learning-new-things-ly y'rs -D From kern at myrddin.caltech.edu Sun Jan 28 23:01:43 2001 From: kern at myrddin.caltech.edu (Robert Kern) Date: 29 Jan 2001 04:01:43 GMT Subject: ANN: clifford.py 0.6 Message-ID: <952pv7$4do@gap.cco.caltech.edu> Okay, I finally got off my lazy duff and put the fixed version on the Starship. clifford.py is an implementation of Clifford (geometric) algebras in Python using Numerical Python (http://numpy.sourceforge.net). I posted a previous (and embarassingly buggy) version to c.l.py, so now, I belatedly fix that mistake and put the new version on the Starship. Location: http://starship.python.net/crew/kernr/source/clifford.py New in version 0.6: * fix a few stupid bugs that don't show up in 3 Euclidean dimensions * introduce a new algorithm for join and meet that actually works, but isn't very numerically stable: but it's better than nothing * various fixes and clean-ups -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From fgeiger at datec.at Wed Jan 3 15:10:05 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Wed, 3 Jan 2001 21:10:05 +0100 Subject: 8.3 peculiarity if run w/i console References: <92g4dn$5ug$1@newsreaderm1.core.theplanet.net> <92ih6d$bt0$1@newsreaderm1.core.theplanet.net> <3a4cee96.4237881050@nntp.gov.bc.ca> Message-ID: <9300rf$uei$1@newsreaderm1.core.theplanet.net> That did the trick, thanks you! Best regards Franz "KellyK" wrote in message news:3a4cee96.4237881050 at nntp.gov.bc.ca... > On Fri, 29 Dec 2000 18:18:24 +0100, "Franz GEIGER" > wrote: > >Well, actually that's me, I call it "abbreviated". I know there are those > >two forms of file names, but I dont like the one containing "~1". How can I > >get rid of that? > > Check out this web page: > > http://ntfaq.com/Articles/Index.cfm?ArticleID=13721 > From MarkH at ActiveState.com Tue Jan 2 10:08:09 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 02 Jan 2001 15:08:09 GMT Subject: HELP! win32com, COM, Invoke problem References: <92rv3q$asi$1@nnrp1.deja.com> Message-ID: <3A51EDBF.3000808@ActiveState.com> TB wrote: > File "F:\tb\cbo\test1.py", line 13, in ? > form = sess.CreateFormContext() > File "f:\python20\win32com\client\dynamic.py", line 150, in __call__ > return self._get_good_object_(apply > (self._oleobj_.Invoke,allArgs),self._olerepr_.defaultDispatchName,None) > com_error: (-2147352573, 'Member not found.', None, None) > > I used to debugger to dig into the dynamic.py, at line #422 > try: > ret = > self._oleobj_.InvokeretEntry.dispid,0,pythoncom.DISPATCH_PROPERTYGET,1) > except pythoncom.com_error, details: > ..... > > it doesn't throw an exception even CreateFormContext is a method, and > the invoked is called with DISPATCH_PROPERTYGET. Is it supposed to > throw an exception when a method is called with PROPERTYGET? It is quite common for some COM objects to allow certain methods to be accessed as either a method or property. This is mainly for VB, where you can't (could not) use parens with a sub. So, that happens with sess.CreateFormContext() is that the "CreateFormContent" is making the method call when simply referenced as a property. This causes Python to try and execute the _result_ of the function - probably calling the default method on the FormContext object. Note that the traceback above has: > File "f:\python20\win32com\client\dynamic.py", line 150, in __call__ > return self._get_good_object_(apply This is what leads me to believe you can simply drop the parens. Note that if you run "makepy" over this TLB, it will work correctly. Mark. > > what OLEVIEW says about Session > [ > uuid(E8000132-8693-11D0-B8B1-080009B6AB17) > ] > dispinterface Session { > properties: > [id(0xfffffffc) > ] > IUnknown* _NewEnum; > [id(0x00000001), helpstring("SessionID") > ] > BSTR SessionId; > [id(0x00000002), helpstring("Set this property to True when > using JScript") > ] > VARIANT_BOOL JScript; > methods: > [id(0x00000003), helpstring("Log into Clarify system")] > void Login( > BSTR pLoginName, > BSTR pPassword, > [optional] VARIANT LoginType, > [optional] VARIANT AssocDefault); > [id(0x00000004), helpstring("Log out")] > void Logout(); > [id(0x00000005), helpstring("Creates a Clarify Form Context > object")] > FormContext* CreateFormContext(); > [id(0x00000006), helpstring("Builds a session cookie string")] > ....... > > > --TB > > > Sent via Deja.com > http://www.deja.com/ From jhg at galdon.com Fri Jan 26 04:32:42 2001 From: jhg at galdon.com (Juan Huertas) Date: Fri, 26 Jan 2001 10:32:42 +0100 Subject: How to spawn another program? References: <94qdjl$5hk$1@mail.pl.unisys.com> Message-ID: <94rfs9$n17$1@talia.mad.ttd.net> Try with the module os: os.exec*, os.startfile(file) ..... or with: os.spawnv (mode, path, args) From delza at antarcti.ca Tue Jan 2 17:53:48 2001 From: delza at antarcti.ca (Dethe Elza) Date: Tue, 02 Jan 2001 22:53:48 GMT Subject: HTTPServer, performance References: Message-ID: <0_s46.921678$8u4.18404294@news1.rdc1.bc.home.com> Sounds like garbage collection behavior, at least in Java-land. There are lots of lightweight web servers out there, in Java and in Python. Might want to check out the code in one (or more) of those... --Dethe "Bill Scherer" wrote in message news:mailman.977951836.8921.python-list at python.org... > Hello eveyone, hope you had a nice holiday... > > Question: Is the code below the proper way to create a multi-threaded > http server in Python, and what kind of performance should one expect > out of it? > > The code below works. It's an extremely stripped down verison of my > current project which really runs under J(p)ython. I was unsatisfied > with performance, so I stripped out all that wasn't web server and tried > it under CPython and JPython. > > With the code below, CPython does about 12 tps on a dual 733 Mhz machine > under RedHat 6.2. JPython is only slightly slower (when using a JVM that > uses native threads and therefore both processors). Apache on the same > box does over 70 tps with a greater number of simulated users (100 vs > 25). > > One thing I do see with both CPython and JPython running this code is > random stalling. ie. The server will be happily serving requests, then > for no apparent reason, it justs stops. CPU load drops during the > stall, although it never gets very high. Two, maybe three, seconds > later, it resumes serving. Pings during this time show no change to > network latency (0.4ms). > > Any and all help is appreciated. > > Thanks! > > -------------------------------------------------------------------------- ------ > > import SocketServer, BaseHTTPServer > > PORT = 9777 > > class HTTPServer(SocketServer.ThreadingMixIn, > BaseHTTPServer.HTTPServer): > pass > > class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): > def do_GET(self): > self.send_response(200) > self.send_header("Content-type", 'text/plain') > self.end_headers() > self.wfile.write('hello world') > return > > if __name__ == '__main__': > httpd = HTTPServer(('', PORT), RequestHandler) > print 'serving on port', PORT > httpd.serve_forever() > > > -- > William K. Scherer > Sr. Member of Applications Staff - Verizon Wireless > Bill.Scherer_at_VerizonWireless.com > From aleaxit at yahoo.com Wed Jan 10 06:06:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 10 Jan 2001 12:06:00 +0100 Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com> Message-ID: <93hfp1013sm@news2.newsguy.com> "Sam Penrose" wrote in message news:spenrose-E755EB.22423209012001 at news.dnai.com... [snip] > In contrast to Alex's comments, however, we do not place Python > statements within HTML. We stick with string substitution keys, That's nice, but in my very first application I needed to generate a variable number of repetitions of a table-row, depending on values computed from the Python side of things. Rather than reinvent loop-syntax &c, I found it simplest to embed a for statement in the HTML template, a la: +for i in range(len(results)): @i@ @results[i]@ - All the presentation logic goes into the template, all of the computation into the Python CGI script, and my little yaptu.py (yet another python template utility, of course) bridges the gap (with about 50 SLOC's, plus comments, docstrings, and test pushing it to a bit over 100 lines). [For the curious, it's just a 2K byte download from http://aleax.supereva.it/Python/Yaptu.zip -- but I have to apologize in advance for its quality, since it WAS my first playing with Python, and back in 1.5.2 times]. > The next time someone posts to comp.lang.python telling you you really > need an Apache module/Zope/whatever to handle that customer feedback > page, don't believe them. To be honest, I don't think anybody's really saying you NEED fancy approaches, just that they're more convenient than roll-your-own-on-top-of-CGI. This may well be true for big and complex sites, too -- my counterthesis is just that many sites are simple ones needing no more than CGI (and perhaps 50 SLOCs worth of a templating utility:-). Alex From lars at stea.nu Fri Jan 5 04:52:16 2001 From: lars at stea.nu (Lars Stea) Date: Fri, 05 Jan 2001 09:52:16 GMT Subject: cgi Message-ID: <3A549C1C.3EC97EB4@stea.nu> Hi, how can i deside wether a form field can be left blank or not? Thanks in advance. Lars From aleaxit at yahoo.com Thu Jan 18 15:28:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 21:28:15 +0100 Subject: Python and Industry, IBM I'm afraid References: <3A63D9E8.F9B74ACE@mjs400.co.uk> <941c14$dok$1@nnrp1.deja.com> <946evt02mr@news2.newsguy.com> <947ddt$g8a$1@nntp6.u.washington.edu> Message-ID: <947jop01i2g@news2.newsguy.com> "Donn Cave" wrote in message news:947ddt$g8a$1 at nntp6.u.washington.edu... > Quoth "Alex Martelli" : > [re AIX ] > | As I recall, its main > | "here's our horrible surprise of the day for you" feature > | was a malloc that would never return 0 even if you asked > | it for FAR more memory than you had around -- rather, the > | program died horribly later when it actually tried to USE > | the memory it THOUGHT it had allocated... > > Never ran into this, thanks maybe to more modest memory requirements. > But AIX's malloc is somewhat notorious for the converse: request > 0 bytes and get a null pointer. I guess the rationale for this is > something like "ask a silly question, get a silly answer", and it > still does that to this day. But *THIS* is compliant with the ISO C standard. I have no problem with that -- our code routinely ported between a dozen platforms at the time. > When things are not going well on an AIX port, another thing to think > about is a compiler flag, I believe it's -qchars=signed, that reverses > their unusual unsigned char default. Again, not the kind of porting problem you run into when you already work on a dozen disparate platforms...:-). Alex From jhorSPAMBGONneman at wanadoo.fr Sun Jan 28 02:53:56 2001 From: jhorSPAMBGONneman at wanadoo.fr (Jurie Horneman) Date: Sun, 28 Jan 2001 08:53:56 +0100 Subject: BUG? Python 2.0 chokes on international characters in Unicode strings Message-ID: <958g87$fqr$1@wanadoo.fr> "Jurie Horneman" wrote in message news:... <> Argh. I've just read some other postings in the newsgroup and found messages concerning my problem... guess I should've done it the other way around... The exception I got was "UnicodeError: ASCII encoding error: ordinal not in range(128)". A bug fix or FAQ entry on this would be nice. (Maybe there is one and I just haven't found it :) Does anyone know if this is in the bug database somewhere? -- Jurie Horneman Opinions expressed are my own jhorSPAMBGONneman at wanadoo.fr From robin at alldunn.com Thu Jan 18 14:40:18 2001 From: robin at alldunn.com (Robin Dunn) Date: Thu, 18 Jan 2001 11:40:18 -0800 Subject: Python & GUI? References: <3A674896.C7E52247@crepido.com> Message-ID: "Marco Seiri?" wrote in message news:3A674896.C7E52247 at crepido.com... > Are there any GUI components or ways to build a GUI in > Python that contains all the widgets that one would expect to > find in a VB or Java environment. Can you (easily) build things > like explorer like applications and such... > There's lots of options. Look here: http://starbase.neosoft.com/~claird/comp.lang.python/python_GUI.html -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From crutoy at aol.com Thu Jan 11 17:23:42 2001 From: crutoy at aol.com (Crutoy) Date: 11 Jan 2001 22:23:42 GMT Subject: Python and Industry Message-ID: <20010111172342.10148.00000934@ng-ca1.aol.com> Hi , does anyone know how widly in an instries does python being used ? I looked at the syntax of it and read some stuff on it,it's interested i just want to know if it's worth learning it. Thanks From jqcordova at my-deja.com Fri Jan 26 05:19:15 2001 From: jqcordova at my-deja.com (jqcordova at my-deja.com) Date: Fri, 26 Jan 2001 10:19:15 GMT Subject: New way to learn Python? Message-ID: <94riuv$bqr$1@nnrp1.deja.com> Spent last couple of years building well-known e-commerce sites using Open Source code. Used Perl, Python,Tcl/Tk, & Java and had to teach jr. programmers a lot about how to program in these languages. Found out most effective way was the so-called Socratic method of question/answer. So, put together a website www.codecity.com to explore this approach to teaching Open Source. Hope to get some feedback/participation from this group especially in contributing Python quizzes. Hope this is appropriate. Jeff C. www.codecity.com Sent via Deja.com http://www.deja.com/ From greg at cosc.canterbury.ac.nz Wed Jan 31 19:32:13 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 01 Feb 2001 13:32:13 +1300 Subject: function attributes are like function objects References: Message-ID: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Sean Reifschneider wrote: > > It didn't really > seem like they were missing so much as it seemed like they would act > more like everything else now... Everything? What about lists, dicts, tuples, file objects...? What's so special about functions that we need to be able to plonk arbitrary attributes on them, but not any other builtin types? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aahz at panix.com Sat Jan 6 18:42:17 2001 From: aahz at panix.com (Aahz Maruch) Date: 6 Jan 2001 15:42:17 -0800 Subject: What makes Python Python (was: OO in Python (was Re: Migrating to perl?)) References: <3Fa56.4580$of7.216286@news1.atl> <937q8r01q91@news1.newsguy.com> Message-ID: <938agp$c7a$1@panix6.panix.com> In article , Joel Ricker wrote: > >Well since I've been P*** bashing myself quite a bit since I started up this >thread a few days ago, I think I should rectify myself and mention that the >original P*** had promise and did what the creator set out to do -- Thats >why its called Practical *xtraction *eport *anguage but has somehow lost its >way. I believe even Larry refers to it as Pathologically Eclectic Rubbish Lister. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "This is Usenet. We're all masturbating in public places." -DH From LangaK at discoveryhealth.co.za Fri Jan 12 03:12:30 2001 From: LangaK at discoveryhealth.co.za (Langa Kentane) Date: Fri, 12 Jan 2001 10:12:30 +0200 Subject: running os commands [newbie] Message-ID: Greetings. I want to create a list call dfout[] In the list, I want to put the output of the df command. How do I go about doing this? I have been trying to find this in the docs, no luck so far. Thanks in advance __________________________________________________________ Langa Kentane | TEL: (011) 290 3218 Security Administrator | Cell: 082 606 1515 DISCOVERY HEALTH | http://www.discoveryhealth.co.za __________________________________________________________________ From matt at virtualspectator.com Sat Jan 20 15:15:46 2001 From: matt at virtualspectator.com (matt) Date: Sun, 21 Jan 2001 09:15:46 +1300 Subject: about DOM. In-Reply-To: <94cm00$t4m$1@nnrp1.deja.com> References: <94cm00$t4m$1@nnrp1.deja.com> Message-ID: <01012109311300.00900@localhost.localdomain> Check out xml-sig archives .... I use it heavily for building documents where many fragments are gathered from the filesystem or an IPC, and inserted at many different locations in the document. That really is its power, but I as I learn more about it there seem to be many more fun and interesting uses, for example, picking up whole branches and shifting them to somewhere else becomes very handy. Matt On Sun, 21 Jan 2001, johnvert at my-deja.com wrote: > Hi, > > I just read up some intro documents about DOM. It seems like a really > cool idea, but I haven't heard of anybody using it--doesn't seem to come > up a lot. > > I was wondering what are people using it for nowdays, and how I can > access it from Python code. > > Thanks, > -- John > > > Sent via Deja.com > http://www.deja.com/ > -- > http://mail.python.org/mailman/listinfo/python-list -- From amk at mira.erols.com Wed Jan 10 23:40:51 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 11 Jan 2001 04:40:51 GMT Subject: zodb & multiple processes References: Message-ID: On Thu, 11 Jan 2001 03:00:08 GMT, Kapil Thangavelu wrote: >currently the zodb assumes a process lock on a particular zodb storage. if >you want to run it with >multiple processes you can use ZEO, which is a bit heavyweight if you want >your app to run on >one machine as it communicates over tcp/ip. ZEO can also use a Unix-domain socket, which would provide both performance and security benefits. I suppose you could write a special Storage class that expected multiple openers, but don't know of any Storage that actually supports that at the moment. --amk From sandj.williams at gte.net Fri Jan 19 11:01:40 2001 From: sandj.williams at gte.net (Steve Williams) Date: Fri, 19 Jan 2001 16:01:40 GMT Subject: Python COM and DCOM. References: <3RV96.10957$wt2.125028@news1.oke.nextra.no> Message-ID: <3A686640.534195EE@gte.net> Syver Enstad wrote: > I am having a bit of a problem getting a python COM object to work over > DCOM. > > As far as I can see I've done exactly what is proposed in the Python on > Win32 book. But the object is started on the local machine, when using > win32com.client.Dispatch or the default instance creation methods in other > languages such as JScript with ASP and C++. It seems like DCOM works when > using the DispatchEx to explicitly choose the machine to run on but not > else. > > Help very much appreciated, thank you. Just a thought. Run dcomcnfg on your server, highlight Python server name, click on properties and look at the location tab. You may also want to look at the Identity tab, as well. From xyzmats at laplaza.org Fri Jan 19 10:27:19 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Fri, 19 Jan 2001 15:27:19 GMT Subject: book recommendation? References: Message-ID: <3a685c8d.7028987@news.laplaza.org> On Wed, 10 Jan 2001 15:47:39 +1100, "Ben Catanzariti" wrote: >If you are using a Win environment i would recommend "Python Programming On >Win 32" by Hammond & Robertson. This is a must have. or for a general OS >information "Programming Python" another must have (you can never have too >many) ... both published by O' Rielly and both are compliant with Version 2. I've just picked this book up (i.e., I've owned the book for a while, but not picked it up....) and I'm extremely impressed. Mark and Andy explain things beautifully: I'd suggest that this is valuable /even/ for non-windows programmers, for the quality of examples showing how to apply "thinking in Python" to a wide range of problems. It's not a language tutorial, though. Mark and Andy: thanks! I'm enjoying this one! Mats From danielk at aracnet.com Sat Jan 13 11:45:47 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sat, 13 Jan 2001 08:45:47 -0800 Subject: Python Design Patterns (was Re: Should I learn Python or Java?) References: <3cus5tk2n0qnhgfid5mnmauulc4gsjfnpb@4ax.com>, <978840685.459818@emperor.labs.agilent.com> <3A5DF377.791E3DE0@comm.mot.com> Message-ID: On Sat, 13 Jan 2001 17:46:32 +0200 (IST), Moshe Zadka wrote: >On Thu, 11 Jan 2001 19:30:22 -0800, Daniel Klein wrote: > >> Since you mention it, what is the pythonic way to implement a Singleton? You >> don't have to provide a complete answer, just a pointer as to where to start >> would be fine as I like to try to work these things out at first for myself. > >See the last Python-URL!: the first link points to Alex Martelli's discussion >of factory methods. Read the thread, it has very good pointers. Alex's message did not make it to my news server. Could you send it directly to me please? Thanks, Dan From jasonic at nomadicsltd.com Fri Jan 12 00:13:38 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Fri, 12 Jan 2001 00:13:38 -0500 Subject: Binaries for mySQL module ? References: <9%t76.1516$B6.336141@news1.rdc1.md.home.com> Message-ID: Check carefully at: http://mysql.he.net/downloads/mysql-3.23.html ..looks like the compiled Win32 is down the list there -- Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] Gerhard H?ring wrote in message news:slrn95t2k7.mh.gerhard.nospam at lilith.hqd-internal.de... > http://highqualdev.com > > On Fri, 12 Jan 2001 02:30:29 GMT, Eric Hagemann wrote: > >Are there binaries for mySQLmodule for win32 available ? A quick pointer > >would be appreciated > > -- > mail: gerhard bigfoot de > web: http://highqualdev.com From gregj at pobox.com Sun Jan 28 19:44:28 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Mon, 29 Jan 2001 00:44:28 GMT Subject: Iterate thru object member names References: <9526tr$iac@dispatch.concentric.net> Message-ID: <952edb$l0h$1@nnrp1.deja.com> In article <9526tr$iac at dispatch.concentric.net>, Phlip wrote: > Pythons: > > In Javascript you can iterate thru an object's members and print out all > their names. What's the equivalent in Python? ---- for a in dir(object): print a ---- dir() works on any Python object, including classes and functions. Depending on what you are doing, you may also want to look at the __dict__ attribute of your class: myclass.__dict__ The types module may also be of interest if you need to determine the type of an attribute (function, string, etc.). -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From grante at visi.com Sun Jan 28 12:10:45 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 28 Jan 2001 17:10:45 GMT Subject: PyArg_Parse vs. PyArg_ParseTuple? Message-ID: I was hacking on socketmodule.c, and noticed that in some places PyArg_Parse() is used to convert Python data to C data, and in other spots PyArg_ParseTuple() is used. In order to get one line to do what I wanted, I had to change from PyArg_Parse to PyArg_ParseTuple. It seems to work the way I expect. I found the documentation on PyArg_ParseTuple(), but I can't find any documentation on PyArg_Parse(). So I'm not 100% sure that what I did was "safe". What is the difference between PyArg_Parse and PyArg_ParseTuple? -- Grant Edwards grante Yow! Wait... is this a FUN at THING or the END of LIFE in visi.com Petticoat Junction?? From dhirja at vsnl.net Tue Jan 23 10:24:13 2001 From: dhirja at vsnl.net (Dhirja Gangopadhyay) Date: Tue, 23 Jan 2001 20:54:13 +0530 Subject: WhatamI doing wrong ? (re: About Content-Transfer-Encoding) Message-ID: <01db01c08550$998238a0$020000c3@node02> I did the following few things in this: I found on a Google Search - http://www.linuxsolutions.demon.co.uk/PythonPages2.html subwriter = w.nextpart() subwriter.addheader("Content-Transfer-Encoding", "base64") subwriter.addheader("Content-Disposition", 'attachment; filename="%s"' % _fileName) f = subwriter.startbody('application/octet-stream; name="%s"' % _fileName) subwriter.flushheaders() base64.encode(open('./%s' % _fileName, 'r'), f) w.lastpart() Where I learnt to change my: listLines = ['zxczxc','werwerwer'] subwriter = w.nextpart() f = subwriter.startbody('text/html') subwriter.flushheaders() f.writelines(listLines) w.lastpart() To: def mthEncoder(lstLines): import base64 tmpList = [] for lstLine in lstLines: tmpList.append(base64.stringencode(lstLine)) return tmpList listLines = ['zxczxc','werwerwer'] subwriter = w.nextpart() subwriter.addheader("Content-Transfer-Encoding", "base64") subwriter.addheader("Content-Disposition", 'inline') f = subwriter.startbody('text/html') subwriter.flushheaders() f.writelines(mthEncoder(listLines)) w.lastpart() Works fine on the server. The e-mail goes out. But when received on the Outlook Express 5.5 client, the strings are all mangled. I cant figure out why. What am I doing Wrong ? Thanks Sandipan PS. I am using Dhirja's account as my ISP's SMTP server is down ! ----- Original Message ----- From: "Dhirja Gangopadhyay" To: Sent: Tuesday, January 23, 2001 7:32 PM Subject: About Content-Transfer-Encoding > I use the MimeWriter module to build a MIME body that I then send over SMTP > using smtplib. > > How can I force content-transfer-encoding to base64 ? > Content-type is text/plain, text/html and text/xml. > > Thanks, > > Sandipan > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From seefeld at sympatico.ca Wed Jan 17 10:27:47 2001 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Wed, 17 Jan 2001 15:27:47 GMT Subject: XREF tool? References: <3A65A235.468D582E@uni-goettingen.de> Message-ID: <3A65C861.E58ADFD9@sympatico.ca> Ragnar Beer wrote: > Does anybody know if there's a cross reference tool available for Python? have a look at synopsis: http://Synopsis.sourceforge.net. The last release (about two weeks ago) contained an IDL and a C++ parser, but the actual code in cvs already contains a python parser as well. Regards, Stefan _______________________________________________________ Stefan Seefeld Departement de Physique Universite de Montreal email: seefelds at magellan.umontreal.ca _______________________________________________________ ...ich hab' noch einen Koffer in Berlin... From fredrik at effbot.org Wed Jan 10 12:25:48 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 10 Jan 2001 17:25:48 GMT Subject: escape sequences and string comparisons References: <93cboe$ctj$1@nnrp1.deja.com> <93elo7$aoh$1@nnrp1.deja.com> <93f1rd$iv7$1@nnrp1.deja.com> <2wG66.4330$AH6.750256@newsc.telia.net> <93haki$c0h$1@nnrp1.deja.com> Message-ID: jkndeja at my-deja.com wrote: > OK, perhaps I shouldn't have written 'RE' match above. What I was > hoping/expecting is that this: > > >>> import re > >>> s = r'[123]' > >>> r = re.escape(s) > >>> r > '\\[123\\]' > >>> r == s > 0 > >>> > > or something similar, would give 1, not zero try: for s in all_possible_string_values: r = s assert r == s assert eval(repr(s)) == s m = re.match(re.escape(s), s) assert m != None and m.span() == (0, len(s)) except AssertionError: print "this message will never be printed!" Cheers /F From mlh at idi.ntnu.no Tue Jan 30 08:56:49 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Tue, 30 Jan 2001 14:56:49 +0100 Subject: Sets in Python Message-ID: <956hcd$qef$1@tyfon.itea.ntnu.no> I quite often use dictionaries as sets in Python... But it doesn't really seem pretty enough to me... Some arbitrariness (as with "while 1: ... break" I still don't like that one...) about using what to me is a value as a key, and assigning it some value -- like 1, for instance... And then checking it with has_key, and removing it with del... Isn't there a better (more beautiful) way of doing this? And if one was to write a small wrapper of some kind -- is there any way to implement "x in s" without a linear search? Or does the "in" operator always loop from 0 and up? (It would certainly be nice to be able to override it...) -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From wagnernils at hotmail.com Sat Jan 6 14:42:27 2001 From: wagnernils at hotmail.com (Nils Wagner) Date: Sat, 06 Jan 2001 19:42:27 -0000 Subject: Fwd: Recompilation of Vpython Message-ID: >From: "Nils Wagner" >To: python-help at python.org >CC: wagnernils at hotmail.com >Subject: Recompilation of Vpython >Date: Sat, 06 Jan 2001 19:23:03 -0000 > >Hi, > >I tried to recompile Vpython > >http://cil.andrew.cmu.edu/projects/visual/index.html > >for Linux (Kernel 2.2.16). >Python version : Python 2.0 (#1, Oct 16 2000, 18:10:03) >[GCC 2.95.2 19991024 (release)] on linux2 > >A make in cvisual/ produces the following messages (Makefile.res). > >Who can help me ? > >Nils _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -------------- next part -------------- A non-text attachment was scrubbed... Name: makefile.res Type: application/octet-stream Size: 3335 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: xgl.cpp Type: application/octet-stream Size: 5431 bytes Desc: not available URL: From wedjlok at excite.com Mon Jan 8 15:48:32 2001 From: wedjlok at excite.com (Eric Anechiarico) Date: Mon, 08 Jan 2001 20:48:32 GMT Subject: Fibonacci numbers/program References: <936gsv$3r1$1@nnrp1.deja.com> <936r2h0ps5@news1.newsguy.com> Message-ID: <93d92t$7si$1@nnrp1.deja.com> > Writing to a file is very easy. You open the file for writing with > fileobj = open(filename,"w"), then you can use its fileobj.write(s) > method to write any string s to it -- just build the string s as you > wish, e.g., str(anumber)+'\n' to emit the stringform of anumber > followed by an end-of-line. > > As for a GUI, you have various choices, but Tkinter is probably the > simplest toolkit to use in your case (on a Mac). I have no Tkinter > on Mac experience (no Mac experience at all, actually) so I'll > refrain from any specifics, just in case there are specific issues > I'm unaware of... > > Alex Thanks for your response, Alex. I was wondering in what context I should use that within the program itself? I am fairly new to Python and have not found very many references in the books that I have read that would show the exact sequence on when/where I would put that string/command into effect with the code itself. Basically, I am defining the command to def FindFibBetween(A,B), having it go through the simple sequence of getting the numbers, and then they output them to a screen. I want to interven so that it will NOT print them to a screen, but dump them directly into a text file. So what I need to know is at what point to I call it in the program to open a file, write the numbers to it, and then close the file? Here is the complete code that I use so far: def FindFibBetween(A,B): x, y = 1L, 1L while x < B: if x >= A: print x x, y = y, x+y then I input FindFibBetween(1, 100) or whatever range for (1, n) Thank you for your time and assistance. Eric Sent via Deja.com http://www.deja.com/ From m.hadfield at niwa.cri.nz Tue Jan 30 17:09:29 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 31 Jan 2001 11:09:29 +1300 Subject: How to extend sys.path on Win9x permanently? References: <3a75ef9c.11194652@news.muenster.de> <980811891.858385@clam-ext> <3a7730ab.37058673@news.muenster.de> Message-ID: <980892569.896508@clam-ext> "Martin Bless" wrote in message news:3a7730ab.37058673 at news.muenster.de... > ... > To be exact, it's the > HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.0\PythonPath\win32 > key on my machine. It adds the extra path both in Python/DOS and > PythonWin. Well you can add any key you want under .../PythonPath, e.g. I have one called HTMLgen to add the (you guessed it) HTMLgen directory to the path. > But what I like much better is the solution to put MYLIBS.PTH into the > Python dir. I wasn't aware of this one. I'm not sure if I like it better or not (I've never been as reluctant to edit the registry as others seem to be) but I'll try it out. I'm glad you started this thread! --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/ National Institute for Water and Atmospheric Research PO Box 14-901, Wellington, New Zealand From grante at visi.com Tue Jan 2 16:06:33 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 02 Jan 2001 21:06:33 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> Message-ID: In article , Steve Lamb wrote: >On Sat, 30 Dec 2000 21:12:13 -0500, Peter Hansen wrote: >>I understand the point you are making; I'm just pointing out that the >>opposing views seem well-founded. Areas where I think you missed the >>point are in the importance of code maintainability, the increased >>complexity with your suggested approach, and the feelings of the "entire >>CS community" on this issue. > > I seriously doubt that initing a variable before use causes either code >maintainability problems or increased complexity. The problem is that when you decide to change the endpoint from 25 to something else, you _may_ have to change the code in two places: the test and the initialization. If you decide to raise the endpoint from 25 to 50, you only have to change one line. If you want to lower it you might have to change the initialization also. Requiring edits to two possibly widely seperated places in the source code to change a single algorithm value is (in my experience) going to cause a bug some day. -- Grant Edwards grante Yow! Yow! And then we at could sit on the hoods of visi.com cars at stop lights! From chrisw at nipltd.com Wed Jan 3 12:19:46 2001 From: chrisw at nipltd.com (Chris Withers) Date: Wed, 03 Jan 2001 17:19:46 +0000 Subject: [Zope-dev] case insensitive sorts References: <3A5350B5.79BE639F@kaivo.com> <006501c075a4$5b8c46a0$ae03a8c0@fork> <3A535764.1144FA95@nipltd.com> <00eb01c075a8$24f9a570$ae03a8c0@fork> Message-ID: <3A535F32.14E1BA3D@nipltd.com> Andy McKay wrote: > > Hmm im actually not so sure on that. Currently you can do a sort either way, > if you fix it so its only case sensitive we'll end up like Visual Basic :) Actually, I'd like to see it 'fixed' so it's only case insensitive: Alan betty Carl Wilbur > Fixing python is a question for the python list and I'd be scared to ask it > there... I'm sure I copied one of these messages to the python list for that very reason but it didn't get any response. Ah well, I'll copy this one there as well and see what happens ;-) cheers, Chris From grey at despair.rpglink.com Fri Jan 19 16:29:56 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 19 Jan 2001 21:29:56 -0000 Subject: Why no isexec, isread, iswrite, etc (was: I must be missing something obvious: os.path.isexecutable?) References: Message-ID: On Fri, 19 Jan 2001 19:50:34 GMT, Grant Edwards wrote: >[Same answer if you're going to try to write or exec a file.] It is? What if you want to check to ensure something is executable before actually symlinking as a sanity check? Yes, things can change between the stat call and when you do the link in that case but that isn't an excuse not to do the sanity check in the first place in some situations. For example, startup scripts which are symlinking different scripts to adapt the startup to the changing configuration of a laptop. Anyone want to guess what my current project is? :P -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From grante at visi.com Fri Jan 26 15:46:09 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 26 Jan 2001 20:46:09 GMT Subject: SourceForge problems References: Message-ID: In article , Tim Peters wrote: >> the power cable goes in the mains[1] before submitting mine... >> [1] This is too harsh. Oh well. > >Actually, it's too English. Nobody in America has any idea how >devasting you've been. Sure we do. We're not _all_ completely dim on this side of the pond. >don't-even-try-discussing-hot-steaming-faggots-ly y'rs - tim You're probably not talking about cigarettes or firewood, so I'm guessing it's some sort of sausage. But English food is best left undiscussed if not uneaten. ;) -- Grant Edwards grante Yow! PIZZA!! at visi.com From danielk at aracnet.com Sat Jan 13 11:20:16 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sat, 13 Jan 2001 08:20:16 -0800 Subject: Defining a new exception with multiple args References: Message-ID: <1qv06ts4e9orlhb6tg4bdh1jqqitaqbnqc@4ax.com> On Thu, 11 Jan 2001 20:01:39 GMT, "Randall Kern" wrote: >You could also override __str__: > >class RecordNotFoundException(Exception): > def __init__(self, filename, recordid): > self.filename = filename > self.recordid = recordid > > def __str__(self): > return '%s(%s)' % (self.filename, self.recordid) Yes, this is a good solution. Thanks, Dan From sill at localhost.kitenet.net Tue Jan 16 21:58:17 2001 From: sill at localhost.kitenet.net (Oldayz) Date: Wed, 17 Jan 2001 02:58:17 GMT Subject: Python equivalent of 'use strict' References: <3A6483CD.CB2424E0@raqia.com> <94232r$297$1@nnrp1.deja.com> Message-ID: On Tue, 16 Jan 2001 18:15:01 GMT, Hamish Lawson wrote: >David Lees wrote: > >> Is there an equivalent to the perl 'use strict'? [My perl/C++ guru >> friend] is concerned with accidentally initializing values of >> mistyped variables. I showed him how you get an error doing an >> operation with an uninitialized variable ... but he is looking for >> this 'use strict' stuff. > >Python effectively has "use strict" on all the time and all assignments >effectively use "my". This in Python > > x = 3 > z = 2 > x = z + 5 > z = y > >is equivalent to this in Perl: > > use strict; > my $x = 3; > my $z = 2; > my $x = $z + 5; > my $z = $y; > >Both will complain about the uninitialised y. > >But "use strict" couldn't stop you from saying > > my $foo = 2; > my $fooo = $foo + 1; > >where you meant to say > > my $foo = 2; > my $foo = $foo + 1; > >(though I concede that using 'my' on both assignments is not quite >idiomatic Perl). Similarly, Python won't stop you saying: > > foo = 2 > fooo = foo + 1 > >where you meant > > foo = 2 > foo = foo + 1 > >Hamish Lawson > > >Sent via Deja.com >http://www.deja.com/ Would it perhaps be useful to have to indicate specifically that you're declaring a new variable with a keyword? import strict new a new b = 5 a = b + 6 c = 3 # raises an error I'm not sure I'd like it - I only used perl in a few tiny scripts and never did use strict, so I don't know how it'd feel. -- Andrei From aleaxit at yahoo.com Thu Jan 11 04:39:06 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 11 Jan 2001 10:39:06 +0100 Subject: Reflection: Calling Methods Dynamically by Name References: <93jfur$9rj$1@nnrp1.deja.com> Message-ID: <93jv2r0g97@news1.newsguy.com> wrote in message news:93jfur$9rj$1 at nnrp1.deja.com... > Question for Guido or language experts: > > Does Python have the ability to call methods of a class by name? For Yes, as I've seen other answers have already showed you. (You actually seem to want to call the method on an _instance_ of the class, of course). > example, I have a string: "ProcessData" and the class MyClass has a > method called ProcessData. Is there a way I can do something like this: > > mc = MyClass() > str = "ProcessData" > args = ("Data", 1, 3) > CallMethodByName(mc, str, args) One way to let you use the exact syntax you desire: def CallMethodByName(instance, method_name, method_args): method_object = getattr(instance, method_name) return method_object(*method_args) The getattr will raise an attribute-error exception if the instance does NOT have some attribute named with the string method_name refers to; if the attribute IS there, but is not callable, you'll get a type-error from the following line instead. If these are not the exact exceptions you desire to receive for such usage errors, you will add try/except blocks to translate them to whatever different exceptions you require (but, DO use exceptions to signify such errors -- it's by far most often the best approach). The '*method_args' syntax takes a tuple, referred to by method_args, and applies it as arguments to the call being performed (new in Python 2.0: the apply built-in function, which I see has been also suggested, is how you would do that in older Python versions -- it also keeps working in 2.0, of course). Alex From katz at Glue.umd.edu Mon Jan 15 10:40:49 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Mon, 15 Jan 2001 10:40:49 -0500 Subject: Parameterized Types Message-ID: Hello, I came across http://www.python.org/~guido/static-typing/ the other day. Some things that struck me as odd: - parameterized types: class foo: pass def func: pass Why is this necessary? I think the point of parameterized types is to tell the Python compiler that we are only going to use TYPE and TYPE. Is this correct? Which begs the question: is it possible to write an analyzing tracer which traces the types of objects and generates efficient code? for example -- the gcd() function: def gcd(a,b): if a>b: return a return b Now, if in my program all I pass to gcd() are int's, the tracer would recognize this. So I don't need any decl statement; the compiler "knows" that I will only pass in int's. Presumably, no optimizations would be made if my script passes in a lone string or makes a decision between passing a string or passing an int, etc. - Syntax for static typing The suggestion decl f(x: int) -> int or decl f(x: int) -> [int] looks to me like a mathematical mapping. Is there any cleaner way to specify this? instead of ->, can't we overload an existing keyword ('return')? Similarly, [int] looks like 'list of integers of size 1'. The slides expressed inlining and explicit forms of declarations; is it possible to come to a concensus before TMTOWTDI? For that matter, is -> or return even needed? def f(x: int) int: pass I use Python for scripting and larger programs (RPGs, etc.). What I need in static typing is this: + Clean and unambiguous + No new keywords ('->' vs. 'return') + There's only *one* (right) way to do it. I pondered whether it is important to be able to write class/func prototypes separately from implementations -- but then that we get the following: decl func( x: int ) -> int def func(x) pass or decl func( x: int ) -> int def func(x: int ) -> int: pass I like the second approach better because it is more consistent (imho) between declaration & implementation. Then again.. with the first approach, if you take out the decl statement, then func becomes fully generic. In the second implementation, func stays statically typed even when we remove the decl statement. An additional concern is that Python will become like Pascal in the sense that it is very readable, but it just takes too long to write out (relative to C/perl/etc.) Roey Katz president, Federation of Ignorant Scripters. From tim.one at home.com Fri Jan 5 13:36:07 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 5 Jan 2001 13:36:07 -0500 Subject: embedded python - cancel "while 1: pass" In-Reply-To: Message-ID: [Warren Postma] > ... > I have decided to patch Python 1.5.2 to have thread-based > signals. > > I noticed a comment in ceval.c, that said someone else has the > same thought as me, was it Guido? The comment is Guido's, but his goal was not the same. > [Guido's comment, from ceval.c] > There are two possible race conditions: > (1) nested asynchronous registry calls; > (2) registry calls made while pending calls are being > processed. > While (1) is very unlikely, (2) is a real possibility. > The current code is safe against (2), but not against (1). > The safety against (2) is derived from the fact that only > one thread (the main thread) ever takes things out of the queue. > > XXX Darn! With the advent of thread state, we should have an array > of pending calls per thread in the thread state! Later... > > -- (end snippet) -- > > Since Pharlap has no "registry", I don't know what equivalent trouble > "nested asynchronous registry calls" might get me in on PharLap, Guido was writing in Dutch there: his use of "registry" has nothing to do with Windows. What he means by "registry call" is "a call to Py_AddPendingCall", the function which "registers" (in Dutch -- or, for that matter, also in English ) the callback function to be invoked later. Note the comment at the start of Py_AddPendingCall: /* XXX Begin critical section */ /* XXX If you want this to be safe against nested XXX asynchronous calls, you'll have to work harder! */ It's getting at the same thing. Py_AddPendingCall does not have proper mutual exclusion (the comment *says* "critical section" but the code doesn't implement one!), and it *is* subject to race condition #1, as explained in the previous comment. "Nested" isn't quite the right word, though: if two threads each call Py_AddPendingCall close in time, it's possible for both of them to see busy==0 upon entry to Py_AddPendingCall, and so for both of them to enter the body simultaneously. Madness will ensue. Python itself never makes calls like that now, but if you're using the mechanism for more, you may. *If* it had per-thread queues of pending calls (as suggested in the first comment), that problem would go away. As I mentioned in a previous msg, this (a per-thread queue) would be one of the things easier to implement if we first had a portable thread-local storage mechanism to build on. > but so far, so good. I have removed the checks to see if thread id > == main_thread. Then you've also taken away the current code's protection against Guido's race condition #2. As you quoted him above: The safety against (2) is derived from the fact that only one thread (the main thread) ever takes things out of the queue. It's in the nature of race conditions that they're erratic, so there's no assurance in "so far, so good". The comments are telling you what *is* going to go wrong, sooner or later -- it's just a matter of time (and system load, and OS scheduling, and phase of the moon, and ...). From iqrogr at email.com Fri Jan 19 13:28:42 2001 From: iqrogr at email.com (iqrogr at email.com) Date: 20 Jan 2001 02:28:42 +0800 Subject: Powerful Technique 4779 Message-ID: <3a68875a.0@news2.tm.net.my> Learn all the secret of HOW TO MAKE OTHER PEOPLE TO WORK FOR YOU for free, get hundred or thousand of people reach you without you even contacting them. Visit us today at : www.sixfigureincome.com/affiliate/register.html?871371 now. Here you will learn 12 reason why you should do it. grwuqtcwjyrtbepwjdb From mhammond at my-deja.com Fri Jan 12 20:44:29 2001 From: mhammond at my-deja.com (Mark Hammond) Date: Sat, 13 Jan 2001 01:44:29 GMT Subject: Can we in python code, catch exception generated by C++ pythonized function? References: <3A5A4545.661385AD@aristotech.com> <93gd8d$las$1@nnrp1.deja.com> <3A5FAA6E.ABA298AB@aristotech.com> Message-ID: <93obtt$h9u$1@nnrp1.deja.com> In article <3A5FAA6E.ABA298AB at aristotech.com>, Siu-Tong Hui wrote: > Thanks for all the responses. > > We use SWIG to link from python to C++. Our highest level code is in > python. ... > level command shell, we would have to put in exception control > codes in all pythonized C++ functions in order to have > bullet-proof exception protection. If I can catch exception in > python, then I only need to do it once in my highest level command > shell in python. You can't catch C++ exceptions directly in Python. But check out the SWIG %except typedef. You should be able to say something like: %typemap(python,except) MYBOOL { try { $function } catch (e) { PyErr_SetString(MyError, e->description_or_whatever); return NULL; } } This is the technique I use to ensure that most SWIG wrapped functions in the Win32 extensions correctly convert Win32 error codes to Python exceptions - see pywintypes.i in the Python for win32 sources. Mark. Sent via Deja.com http://www.deja.com/ From ckalista at realproject.be Fri Jan 19 06:11:22 2001 From: ckalista at realproject.be (Kalista Christophe) Date: Fri, 19 Jan 2001 12:11:22 +0100 Subject: Synchronize a socket close? Message-ID: <9497f1$k4v$1@news1.skynet.be> A socket close doesn't apply immediately. Is it possible to force it? Thanks, -- Kalis -- From erno-news at erno.iki.fi Tue Jan 9 02:22:14 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 09 Jan 2001 09:22:14 +0200 Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com> Message-ID: In article , Moshe Zadka writes: | Perhaps even CGI+HTMLgen is an answer, though this might depend on | personal taste. there's also HyperText at . i liked it more than HTMLgen. | Of course, the simplest thing that can possible work | interface-to-the-browser part is of course not even going with CGI, | but with inheriting from BaseHTTPRequestHandler. very true, the http server stuff in the standard library is very much under-appreciated. i mostly use cgi for low-usage stuff because there's the issue of keeping the python webserver process running. it takes extra resources from the computer and extra effort from the human (for the automation). | [...] with ZODB and | a dash of cookies, state management becomes so easy you'll wonder | how you did without it. very true, the http server stuff in the standard library is very much under-appreciated. how does one take care of locking/concurrency control with zodb? can you just open the same database from multiple processes or threads simulateneously and have it work? -- erno From bobhicks at adelphia.net Sat Jan 13 15:49:31 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Sat, 13 Jan 2001 20:49:31 GMT Subject: do python programmers avoid the mac? References: <3A607DCC.7EF7809C@mjs400.co.uk> Message-ID: I am new to Python and cutting my teeth on MacOS 9. It is proving interesting to say the least. I am looking forward to OSX since it will be a paradigm (BSD) more people deal with. > From: Pete

> Organization: MJS400 > Reply-To: p at mjs400.co.uk > Newsgroups: comp.lang.python > Date: Sat, 13 Jan 2001 17:09:48 +0100 > Subject: do python programmers avoid the mac? > > Ordinary Bloke seeks stable python2.0 mac ide environment for possible > long term development antics. Don't tell me to buy a noisy steenkin > intel fat box. From warrickb at my-deja.com Tue Jan 30 05:42:12 2001 From: warrickb at my-deja.com (warrickb at my-deja.com) Date: Tue, 30 Jan 2001 10:42:12 GMT Subject: Wrapping up a C++ class References: <954496$ues$1@nnrp1.deja.com> <9546rv01ahd@news2.newsguy.com> Message-ID: <9565q3$nnh$1@nnrp1.deja.com> Thankyou all I shall take a look and see if I can make sense of it! It does strike me as odd that there isn't a simple one source file example of how to do it in the docs though... Sent via Deja.com http://www.deja.com/ From olczyk at interaccess.com Sat Jan 6 23:04:25 2001 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Sun, 07 Jan 2001 04:04:25 GMT Subject: LoadLibrary/dllopen in python. Message-ID: <3a57ea9f.348172625@nntp.interaccess.com> Is there a way to call LoadLibrary (Win32 ) or dllopen (Linux ) in Python? TIA From boud at rempt.xs4all.nl Thu Jan 25 01:21:10 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 25 Jan 2001 06:21:10 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: <94ogkm$ggb$2@news1.xs4all.nl> Rick Lee wrote: > It has to be cross platform between Linux and Windows, so it seems that > my choices are Tkinter and wxPython. PyQt is also crossplatform between Linux and Windows. > Your experience, thoughts, opinion, on the relative merits and pitfalls > of each? > My particular case: A GUI that has 5 windows max., will incorporate a > xmlrpc client, will have a python object browser, being able to build > data entry screens on the fly from a description of an object's > attributes, programmer not familiar with either toolkit. The dynamic building of a data-entry form based on a description has already been done before - with PyQt. See the kuragui part of kura: http://www.xs4all.nl/~bsarempt/linguistics. -- Boudewijn Rempt | http://www.valdyas.org -- Boudewijn Rempt | http://www.valdyas.org From aleaxit at yahoo.com Wed Jan 10 05:28:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 10 Jan 2001 11:28:27 +0100 Subject: Problems with zipfile module... References: <93ha6j$ca6$1@reader1.imaginet.fr> Message-ID: <93hdis0128r@news2.newsguy.com> "Christophe Prevost" wrote in message news:93ha6j$ca6$1 at reader1.imaginet.fr... [snip] > backup = zipfile.ZipFile(zip, "w", "ZIP_DEFLATED") Change to: backup = zipfile.ZipFile(zip, "w", zipfile.ZIP_DEFLATED) i.e., the option is NOT to be passed as a string, but rather as a numeric 'constant' which is defined in module zipfile. Alex From benpark at my-deja.com Tue Jan 23 12:19:48 2001 From: benpark at my-deja.com (Ben Park) Date: Tue, 23 Jan 2001 17:19:48 GMT Subject: password input in rsync Message-ID: <94kef8$4j6$1@nnrp1.deja.com> Hi, I am trying to automate the process of getting files using rsync. Here is what I do: myPass = '1234' temp1 = "rsync -avz -e 'ssh -l benpark' guppy:temp1 ." out1,in1,err1 = popen2.popen3(temp1) in1.write(myPass) But it does not work. rsync does not take password input from the standard in. Any suggestion? Thanks in advance. Sent via Deja.com http://www.deja.com/ From trentm at ActiveState.com Tue Jan 2 19:25:15 2001 From: trentm at ActiveState.com (Trent Mick) Date: Tue, 2 Jan 2001 16:25:15 -0800 Subject: Komodo In-Reply-To: ; from db3l@fitlinxx.com on Tue, Jan 02, 2001 at 12:23:30PM -0500 References: <3A4D6D0B.20000@ActiveState.com> Message-ID: <20010102162515.B25147@ActiveState.com> On Tue, Jan 02, 2001 at 12:23:30PM -0500, David Bolen wrote: > Mark Hammond writes: > > > I can't speak for Perl. But for Python, you certainly should be able to > > craft your own working Python version. There is nothing special in the > > ActivePython binaries, other than everything Komodo needs in one > > package. > > When I tried to install Komodo, it complained that ActivePython wasn't > installed (I have a standard Python installation), at which point I > gave up. Do you know if this is just a check for certain Python > modules? I had assumed it was looking for something truly specific to > ActivePython, and I wasn't prepared to install that just for Komodo. It was probably complaining about the lack of the PyWin32 extensions. Do you have those installed? They are installed by default with ActivePython but not with BeOpen's Python. You can get it here: http://www.activestate.com/Products/ActivePython/win32all.html And I have heard reports that Komodo then works fine. Cheers, Trent -- Trent Mick TrentM at ActiveState.com From amk at mira.erols.com Tue Jan 9 22:26:24 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 10 Jan 2001 03:26:24 GMT Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: On Tue, 09 Jan 2001 16:16:36 -0800, Paul Prescod wrote: >I haven't tried this recently but if I remember correctly, the problem >is: How would I do a regexp match on "Py..n" on a 1-gigabyte file with a >fixed amount of "lookahead"? Do I have to load in chunks at a time and >then do the pattern matching across "chunk boundaries" myself? If With the mmapfile module, you should be able to mmap the entire gigabyte file, and then do an re.search() on the whole thing. Performance is then up to _sre and your OS's virtual memory algorithms. --amk From moshez at zadka.site.co.il Sat Jan 27 13:46:22 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 27 Jan 2001 20:46:22 +0200 (IST) Subject: . Python 2.1 function attributes In-Reply-To: References: , , <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> <14962.62953.304511.523826@anthem.wooz.org> Message-ID: <20010127184622.4DD3CA840@darjeeling.zadka.site.co.il> [I wrote] > try: > print foo, bar > finally: > sys.stdout = sys.__stdout__ [Roy Katz] > what is wrong with redirection? must we wrap the output in a try: > anymore than wrap a standard print in a try:? Because if the print raises an exception, I want the stdout to be the old one. [Moshe Zadka] > print >>sys.stderr foo, bar > > Is obvious, simple and easy to understand. [Roy Katz] > Perhaps simple, but to me it looks like it has the potential to be > ambiguating. Huh? What else *could* it mean? > If we have print>>file, why not print>>obj (if not already > so); print >>obj, something Prints ``something'' to obj. Any file-like object would do. Just the same as almost anywhere in Python. > if we already have print>>obj, why not extend it to > statement>>obj Which would do? Besides, it would be ambigous, since expressions are statements in Python. > Why stop there? if not statement>>obj, why not > func>>obj? since obj's can implement __call__(self), why > not obj>>obj? What has any of it got to do with telling "print" to print to some other file-like object rather then sys.stdout? Your reductio ad absordum has no logical basis. > I'm only interested in why it happened at all, and how to prevent it from > screwing up our language further :) But Guido has been wanting all this to happen sooner -- he just did not have the man power. > Let's see it! petition! vote! who wants and who doesn't? No more of this > of this 'Benevolent Dictator' or 'Hey I've got a patch' garbage. *vote* > and make Python not the patcher's language, not my language, and not > yours, but *our* language. Why would anyone care about votes? If you have a rational argument, let's hear it. And if you think the Python development doesn't listen to your logical arguments, then you're welcome to take Python and develop it in a direction that suits you -- the license is quite liberal. > Let's add bless(). I want to change the class of an object at > runtime. You can already do this, and have been able to a long time. foo.__class__ = new_class Why would anyone want a new builtin for that? > all this when real issues like typing and making int's first-class objects > falls to the wayside. You're welcome to contribute patches. http://sourceforge.net/projects/python/ -> Patches -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From loewis at informatik.hu-berlin.de Mon Jan 15 18:34:42 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jan 2001 00:34:42 +0100 Subject: Determining names of instances References: Message-ID: "Daniel Klein" writes: > A question I hope has a simple answer. Take the following simple class and > instance > > class foobar: > pass > > foo = foobar() > > The question is, is there a way for the object 'foo' to know that its name > is 'foo'? No. Objects have no names. Consider foo = foobar() bar = foo What is that object's name? foo or bar? If you still think it is foo, consider this: foo = foobar() bar = foo foo = foobar() Now, the object referenced in bar(), should it's "name" still be foo? Even though the name foo refers to some other object? Of course, you can invoke globals() and check whether the object is listed there. Regards, Martin From sragsdale at my-deja.com Thu Jan 18 15:26:26 2001 From: sragsdale at my-deja.com (sragsdale at my-deja.com) Date: Thu, 18 Jan 2001 20:26:26 GMT Subject: who imported me? Message-ID: <947jh5$puv$1@nnrp1.deja.com> (Hopefully) easy question: I'm writing a module that uses values in variables from the script that imported it. How can I tell which script is importing me? Is there some easier way to get the parent module's variable values? Sent via Deja.com http://www.deja.com/ From jkraska1 at san.rr.com Mon Jan 15 00:14:22 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 15 Jan 2001 05:14:22 GMT Subject: P*rl in Latin, whither Python? References: <3A0C8258.4217A1C@alcyone.com> <3A0D7321.29BE1264@engcorp.com> <874s1ei02a.fsf@fangorn.stofanet.dk> <3A0DEA72.7F8A2868@alcyone.com> <3A0E0E00.50B7A1E1@engcorp.com> <871ywhmiis.fsf@fangorn.stofanet.dk> <974070178.345720@clam-ext> <979516309.507737@clam-ext> Message-ID: <01256tkvn7pb97fsbqad8ef3g91acr1hpm@4ax.com> On Mon, 15 Jan 2001 12:51:49 +1300, "Mark Hadfield" wrote: >"J?rgen A. Erhard" wrote in message >news:mailman.979323254.7670.python-list at python.org... >> >> Mark> People in glace houses shouldn't throw stones. >> >> Just an illustration of the truism that every spelling flame contains >> at least on [sic] spelling error itself. ;-) My most frequently encountered error of this type is the one where someone criticizes someone else's "spelling and grammer (sic)". Most amusing, C// From vesemir at pro1.promail.pl Sun Jan 7 17:32:34 2001 From: vesemir at pro1.promail.pl (Vesemir) Date: Sun, 7 Jan 2001 23:32:34 +0100 Subject: shtml in python References: <93adro$k9n$1@sunsite.icm.edu.pl> <9z366.240411$_5.53698286@news4.rdc1.on.home.com> <93algg$pdj$1@sunsite.icm.edu.pl> Message-ID: <93aqke$md6$1@sunsite.icm.edu.pl> Hello! > Configure your web server to allow the execution of CGI scripts. > And then include the corresponding URL of the CGI scripts > inside the SSI statement. Could you give me an example? Yours QdlatY From jkndeja at my-deja.com Tue Jan 9 04:30:46 2001 From: jkndeja at my-deja.com (jkndeja at my-deja.com) Date: Tue, 09 Jan 2001 09:30:46 GMT Subject: escape sequences and string comparisons References: <93cboe$ctj$1@nnrp1.deja.com> Message-ID: <93elo7$aoh$1@nnrp1.deja.com> OK, my question is being purified ;-) into the following: When, in a string, an escape character '\' is followed by a character which is not in the list of 'characters forming escape sequences', the behaviour of Python is that both the backslash and the following character are kept in the string. My copy of K & R C (2nd Ed, Sec A2.5.2) says 'if the character following the \ is not one of those specified, the behaviour is undefined' My copy of 'The C Reference Manual' (Harbison and Steele), says (paraphrased) '... the behaviour is undefined, though traditionally the effect is simply that the backslash is ignored'. My question - is there a good reason that Python has moved from this 'traditional' effect, which seems to me to be a useful one, for instance in the context of my original question? Would this behaviour have broken something else? Shall I raise a PEP? ;-) Regards Jon N Sent via Deja.com http://www.deja.com/ From tim.one at home.com Sat Jan 27 01:29:01 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 27 Jan 2001 01:29:01 -0500 Subject: Precision of float --- double? In-Reply-To: <87hf2lk0xz.fsf@tea.thpoon.com> Message-ID: ]Arcady Genkin] > Could someone point me to a place in the documentation where the float > type is defined? Probably. But if you have grep or findstr, you can find it faster than I can type it in. > s it equivallent of C's double? Yes, and on all platforms. It *is* a native C double. Similarly, a Python int is a native C signed long (while a Python long is unbounded -- a "bigint"). From chris.gonnerman at usa.net Sat Jan 27 11:34:29 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 27 Jan 2001 10:34:29 -0600 Subject: Strange Python 2.1 return style (was Re: . Python 2.1 function attributes) References: <3A72E786.BCBD13C7@engcorp.com> Message-ID: <000701c0887f$07164ce0$a100000a@local> ----- Original Message ----- From: "Peter Hansen" > Tim Peters wrote: > > Barry also added code to Python 2.1 to let you write, e.g., > > > > def f() >> x: > > x = 1 > > y = 2 > > > > Is there a smiley missing from the above? Sounds like a > bad April Fool's joke, to me. Motion seconded! The 'print >>' statement seems natural to an old shell scripter but the 'def f() >> x:' form is plain confusing. If I saw it in some module source somewhere I would say "what the hork is that?" and waste an hour or two online (more or less) trying to figure it out. > I think some people are starting to get nervous > about '>>' and other such non-intuitive, C++-like > cryptic sugary syntax. I'll second that motion too! > Whatever happened to 'one way of doing things', > and 'simpler is better than completely twisted'? When I learned Python it was like this: PERL: Boring name, twisted syntax Python: Twisted name, boring syntax and I LIKED it that way. Unsurprising syntax and semantics in a language which 'just works' is vastly my preference! I'm not against change. I just want everything plain, logical, and consistent. I've spent too many hours armwrestling with code written by others who prefer a different subset of whatever language... in Python (up to now) I haven't had to expand my knowledge of the language (much) just to read another person's code. From benh at intelligenesis.net Thu Jan 11 20:21:37 2001 From: benh at intelligenesis.net (Ben Hutchison) Date: Fri, 12 Jan 2001 12:21:37 +1100 Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> Message-ID: <3A5E5C21.3E036BFE@intelligenesis.net> Crutoy wrote: > Hi , i haven't used Python but i do have experience in other languages vb , > java , c++ . Is Python a fully object oriented ? Thanks I have just been considering the same questions myself. I do have a few concerns with Pythons OO credentials, relative to Java/C++. 1. Most significantly, Python requires the "self" or "this" reference to be explicitly declared. This seems like a bit of a hassle if you do pure OO development with python; lots of typing! Suggests perhaps that OO features were built onto initially procedural language. eg: Python class MyClass: def __init__(self, name): def doIt(self): Python with implict self (as in C++, Java) class MyClass: def __init__(name): def doIt(): 2. Access control is more informal in Python than C++/Java. I know in the case of Java at least that security provisions depend in part on access control being strictly enforced, and additonally there are a number of design principles that assume 3 tiered (public, protected, private) access levels. * Is Pythons leading underscore mechanism more of a convention? * It is strong enough to build security mechanisms on? * Can a class declare a priviledged API availalbe only to subclasses? -- Ben Hutchison Software Engineer-Market Predictor Webmind Australia http://www.webmind.com/productspredictor.html From bobhicks at adelphia.net Thu Jan 25 21:26:59 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Fri, 26 Jan 2001 02:26:59 GMT Subject: Tkinter 3000 (was Re: Tkinter vs wxPython: your opinions?) References: <3A6F899F.E164F628@home.com> Message-ID: Will Tk3k be rolled into Python at some point? > From: "Fredrik Lundh" > Organization: Telia Internet > Newsgroups: comp.lang.python > Date: Thu, 25 Jan 2001 20:27:11 GMT > Subject: Re: Tkinter vs wxPython: your opinions? > > Neil Cerutti wrote: > >> Sorry. > > no problem! > >> I'm still proud that I spelled your name correctly. > > that's appreciated (but I don't really mind, as long > as you don't call me Fred ;-) > > (btw, if you skip over to amazon, you'll find a book by > authors Frederick Lundh and Frederik Lundh...) > > Cheers /F > > PS. The first Tkinter 3000 WCK alpha will be out next > week. Stay tuned. > > From maxm at normik.dk Thu Jan 4 05:05:01 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Thu, 4 Jan 2001 11:05:01 +0100 Subject: Configuring PWS for Python ASP Scripting Message-ID: <7BD10B680501D411B9DF009027E06F32197B79@exchange> If you install Mark Hammonds Win32all it should work nicely. You can get it at: http://www.activestate.com/Products/ActivePython/Extensions.html Max M -----Original Message----- From: Herb Lainchbury [mailto:herb at dynamic-solutions.nospam.com] Sent: Thursday, January 04, 2001 10:17 AM To: python-list at python.org Subject: Configuring PWS for Python ASP Scripting Could someone direct me to the steps required to configure PWS so I can use python scripts in my ASP pages? I want to be able to write .asp files of the form: <%@ Language=Python %> <% print 'Hello from Python' %> but when I do this I get the error message: Active Server Pages error 'ASP 0129' Unknown scripting language /index.asp, line 5 The scripting language 'Python' is not found on the server. Thanks. -- http://www.python.org/mailman/listinfo/python-list From spamfranke at bigfoot.de Wed Jan 31 10:38:27 2001 From: spamfranke at bigfoot.de (Stefan Franke) Date: Wed, 31 Jan 2001 15:38:27 GMT Subject: invalid-token syntax hook (was Re: Hack request: rational numbers) References: Message-ID: <3a782e12.10122330@news.btx.dtag.de> >We *might* get somewhere being even less ambitious. Perhaps by extending >Python's grammar in a *fixed* way, so that every tool can learn to deal with >it via "cheap tricks", and no compile-time hooks are needed to decide >whether a piece of text *is* Python code. The simplest thing I can think of >would be to allow any letter as a prefix to a string (instead of just the >[uUrR] allowed today), and ditto for a suffix on "a number" (instead of just >[lL] today). IHMO this is a very good idea, since I also had it before . Seriously, as the extension language Python was designed to be, I think the lack of user definable literals is a gaping hole, especially compared to, say, Tcl. At least it stopped me more than one time from writing an extension to interface an existing library supporting various musical datatypes, whose notation is one of its most important adventages. Being forced to include musical literals into run-time evaluated strings invalidates one of its strongest points. Stefan From bobhicks at adelphia.net Sun Jan 21 21:09:46 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Mon, 22 Jan 2001 02:09:46 GMT Subject: Why is "as" not a keyword? References: <3A679717.1328@loop.com> Message-ID: Last I looked...which was 5 seconds ago..."as" is not in the keyword list. I am sure if it is ever added then IDLE will be updated to reflect that. > From: grey at despair.rpglink.com (Steve Lamb) > Organization: We're organized?! > Reply-To: morpheus at here.not.there > Newsgroups: comp.lang.python > Date: Fri, 19 Jan 2001 02:07:03 -0000 > Subject: Re: Why is "as" not a keyword? > > On Thu, 18 Jan 2001 17:23:35 -0800, Jesse W wrote: >> Most people know about the functionality of the import statement that >> in IDLE, and import lights up as a keyword, but "as", which has to be >> there and is clearly part of the syntax, does not. If this question has >> been answered already, pardon me; I have not seen the answer anywhere. > > What are you asking? Just because an IDE (or editor) does not highlight a > word doesn't mean it isn't a keyword in the language. In this case it sounds > like something to take up with IDLE's mantainer. > > -- > Steve C. Lamb | I'm your priest, I'm your shrink, I'm your > ICQ: 5107343 | main connection to the switchboard of souls. > -------------------------------+--------------------------------------------- From katz at Glue.umd.edu Sat Jan 27 11:58:06 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Sat, 27 Jan 2001 11:58:06 -0500 Subject: . Python 2.1 function attributes In-Reply-To: References: Message-ID: On Sat, 27 Jan 2001, Rainer Deyke wrote: > Syntax sugar for singletons could chop another line from the class-based > idiom: > > > singleton g: > attr = 0 > def __call__(): pass I thought of that, so I wrote the other post (about an Entity type). I noticed that your __call__() doesn't pass self. Was this intentional, given that you specified a singleton? Roey From donn at u.washington.edu Wed Jan 3 14:15:41 2001 From: donn at u.washington.edu (Donn Cave) Date: 3 Jan 2001 19:15:41 GMT Subject: Threads References: Message-ID: <92vtot$h84$1@nntp6.u.washington.edu> Quoth Terry Hancock : | I'm writing a scheduler for running "behaviors" under a | system modelled roughly on "subsumption architectures" | (Dr. Rodney Brooks and others, check MIT's AI and Robotics | publications for references to "sumbsumption" and | "behavior programming"). | | Basically, it seems very reasonable to run these as | lightweight processes or "threads," so I'm considering | using the Python "pthreads" module for posix threading | in order to do this, but I've never done this before | and I have some concerns about it: | | 1) How broad is "pthreads" support? -- we have a goal | of this program running on at least Linux, Windows, and | Mac computers. Will the code remain portable? What | platforms don't support pthreads? Ultimately I'd | like to run this on embedded systems as well. | | 2) Do any of these architectures impose high per-thread | costs or limits on the number of processes that can be | running (or rather what are the limits I can expect for | any architecture?). I ask this because this programming | model calls for large numbers (100s or 1000s) of very | light processes (e.g. 10 - 100 lines of Python code). | | The alternative is to simply run the behaviors | sequentially, without spawning a bunch of separate | threads, but this is contrary to the design philosophy | of subsumption architectures, and loses some of their | advantages (e.g. "fail-soft" resistance to buggy | behavior code). The idea is that programs consist | of large numbers of quasi-independent components which | can fail without wrecking the rest of the system. | Processes that "hang up" can just be killed by | the scheduler when they miss their deadlines. | | Also, I'd just like to be aware of any caveats or | advice you might have about this kind of application. | | Thanks a lot! | | The project, BTW is http://light-princess.sourceforge.net/ | this is for the "character agents". Just to be fair and not single out any particular architecture you mentioned, I tried a simple program on one you didn't, and under BeOS, 100s of threads isn't a problem but 1000s seems to be stretching it (I tried 10000, and it didn't execute correctly.) I don't know of a pthreads module, on any platform. BeOS doesn't support pthreads, but the "threads" module works, and the "threading" module. >From what I have heard of the stackless microthread system, you won't get the `processes that "hang up" can just be killed' part of what you want there, at least not for all causes of hanging up. Honestly, I guess you won't get it from Python threads either, because there is no provision in the API for killing a thread, but at least the process will continue, because these threads go down to the operating system level where the usual hanging up happens. Donn Cave, donn at u.washington.edu From dsh8290 at rit.edu Tue Jan 2 17:14:11 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 2 Jan 2001 17:14:11 -0500 Subject: Q: JPython, NumPy, and PIL? In-Reply-To: ; from scott@csihq.com on Tue, Jan 02, 2001 at 04:23:10PM -0500 References: Message-ID: <20010102171411.A2096@westsidecnc.rh.rit.edu> Sure, it's a python module. But you will need to have the C parts of it compiled and reachable on the system you will run it on. It may be more complicated having the Java + Python + C interaction, so you might run into other problems and decide it's not worth it to try. HTH, -D On Tue, Jan 02, 2001 at 04:23:10PM -0500, Scott Bortman wrote: > Hello, > > Can I use the NumPy or PIL libraries from JPython? > > Thanks in advance, > scottie From andymac at bullseye.apana.org.au Mon Jan 15 16:10:29 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Tue, 16 Jan 2001 08:10:29 +1100 (EDT) Subject: storing passwords In-Reply-To: <20010115003607.B3666@glacier.fnational.com> Message-ID: On Mon, 15 Jan 2001, Neil Schemenauer wrote: > On Mon, Jan 15, 2001 at 10:08:52PM +0200, Moshe Zadka wrote: > > On Mon, 15 Jan 2001 Andrew MacIntyre wrote: > > > > > I wrote a simple module that stores the account,password pair as an XOR > > > "masked" string in a dbm file with the hostname as the key. The module is > > > only published (put in the PYTHONPATH) as a .pyc/.pyo, so the full source > > > is not generally readable. > > > > > > This is only obscurity however, not real security. > > > > And not even good obscurity! .pyc files are actually quite readable > > if you use the dis module, and I think Mr. Aycock wrote a decompyler. > > Don't use security through obscurity, please! > > There's no excuse either: > > import sha > def hash_password(password): > """Apply a one way hash function to the users password and > return the result""" > return sha.new(password).hexdigest() > > def valid_password(self, password, hash): > "Return true if the provided password is correct" > return (hash == hash_password(password)) > > Its easy to add some "salt" to the hash too if your worried about > dictionary based attacks. In the application I had, I needed the password in raw form (it was for an account on a different system) so a hash was no good. Everything that has been said about security vs obsurity I agree with, but sometimes circumstances force you to take an approach you'd rather not. In the particular circumstances at the time, the risk assessment was that the solution I used was tolerable in view of there being no alternative solution (organisational politics were the difficulty, not technicalities). -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From joejava at dragonat.net Tue Jan 9 18:23:21 2001 From: joejava at dragonat.net (Joel Ricker) Date: Tue, 9 Jan 2001 18:23:21 -0500 Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: Jason Cunliffe wrote in message ... >Oleg Broytmann wrote: >> Anyone here has any doubts that at least mxDateTime simply MUST be in >> the Python core? :) > >YES!! >PLEASE PLEASE PLEASE let's end this 1970.epoch.ticks.DateTime-oriented >mAdNeSs now = include mxDateTime in Python core for perpetuity.. NO!! I just figured those routines out. Don't change them on me yet! ;) Joel -- I have been Perl-Free for 4 Days, 20 Hours, 33 Minutes, and 40 Seconds. ----------------------------------------------------------------------- Joel Ricker joejava at dragoncat.net Just Another Python Hacker From tjreedy at udel.edu Fri Jan 26 21:24:10 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 26 Jan 2001 21:24:10 -0500 Subject: . Python 2.1 function attributes References: Message-ID: <94tbm0$12$1@news.udel.edu> "Roy Katz" wrote in message news:Pine.GSO.4.21.0101260824430.1922-100000 at y.glue.umd.edu... > Hello.. > > I posted before a much longer version of this question but I got only one > response. What do function attributes give that cannot be accomplished > with function objects? Since functions are and always (for at least five years) have been (Py)Objects and since they have always had attributes (like many other types of PyObjects), it is still not clear what you are asking, and hence the paucity of answers. The new thing in 2.1 is to allow users to directly set as well as read user-defined function attributes. This eliminates the need for certain kludgy workarounds that people have been resorting to. Terry J. Reedy From keichwa at gmx.net Sun Jan 28 04:04:17 2001 From: keichwa at gmx.net (Karl Eichwalder) Date: 28 Jan 2001 10:04:17 +0100 Subject: Can't configure gnome-python, imlib fails with 'no --libs' References: <94ujvo$7pp$00$1@news.t-online.com> Message-ID: Browne at t-online.de (Edward D. Browne) writes: > I can't compile gnome-python-1.0.53 on either my SuSE7.0 > or Redhat7.0 systems, both failing with the same error, namely: All these packages are coming with SuSE Linux 7.0 (some of them have strange names, though). Please, install the so called Source RPMs (installable via YaST) and check out the spec files; than call ./configure as shown in the spec file. -- work : ke at suse.de | ,__o : http://www.suse.de/~ke/ | _-\_<, home : keichwa at gmx.net | (*)/'(*) From zippy1984 at my-deja.com Wed Jan 24 07:59:22 2001 From: zippy1984 at my-deja.com (zippy1984 at my-deja.com) Date: Wed, 24 Jan 2001 12:59:22 GMT Subject: win32com.client - need some help Message-ID: <94mjj8$v3g$1@nnrp1.deja.com> I am trying to port some VB code to Python, but I have a problem with code that passes Objects by reference.... VB: Dim ob as someObject Dim dic as IDictionary Dim i as Long ob = CreateObject("some.object.1") ob.getDictionary dic ' set "dic" to point to the "ob" dictionary i = dic.getValue("xyzzy") Python: import win32com.client ob = win32com.client.Dispatch("some.object.1") # ok # I can now use "ob" to call methods that returns infomation # by the return value. #... then how do I get the dictionary? regards, tom Sent via Deja.com http://www.deja.com/ From vasvir at iit.demokritos.gr Wed Jan 3 17:23:24 2001 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Thu, 04 Jan 2001 00:23:24 +0200 Subject: SMB Module References: <92n1lh02evv@drn.newsguy.com> <92pkod011eh@drn.newsguy.com> <3A508B35.1D328941@iit.demokritos.gr> <92s8b30ddt@drn.newsguy.com> Message-ID: <3A53A65C.5047B2C@iit.demokritos.gr> Armin Steinhoff wrote: [snip] > > > >I think we have a slight misunderstanding here. Please let us remind you > >that unless you are using linux you cannot mount SMB shares since you > >lack the smbfs module which is a smb client actually. > > Well ... I was talking about utilities for mounting of SMB volumes. > There are a lot of other 'smbfs' like modules for other UNIXes. > (For QNX RTP ... it's called fs-cifs) OK > > > The SMB client library is very useful > > Huh ... what is a 'SMB client library' ?? > > >in that respect, thus effectively allows other operating systems to access MS > >>servers. > > It allows access to SMB servers ... not only M$ servers. That's true, although one can argue that the native file sharing protocol for UNIX <-> UNIX file sharing is NFS. SMB is useful only when you have MS servers involved. > > > Since python offers bindings for > >every other library in this planet I don't really see why such an > >addition would be useless or inconsistent. > > What the heck should offer a 'SMB client library' to that planet since we are > able to mount SMB volumes?? > > Armin I seem to recall the need of several people to access SMB servers which didn't have kernel support for SMB like filesystems in their system. If this is not the case [anymore] I apologize. .Bill From chris at voodooland.net Fri Jan 26 13:10:09 2001 From: chris at voodooland.net (Chris Watson) Date: Fri, 26 Jan 2001 12:10:09 -0600 (CST) Subject: How to spawn another program? In-Reply-To: <94qdjl$5hk$1@mail.pl.unisys.com> Message-ID: > Is there a way in python to launch another program, > like a batch file or other executable? Hi ed! Try looking at os.spawnv() [1]. I think thats what your looking for. [1] Shouldnt this be in a FAQ somewhere :-) Chris From mfletch at tpresence.com Tue Jan 30 00:35:12 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 30 Jan 2001 00:35:12 -0500 Subject: need Numeric module Message-ID: http://numpy.sourceforge.net/ HTH, Mike -----Original Message----- From: Issac Trotts [mailto:trotts at mit.edu] Sent: Monday, January 29, 2001 2:56 PM To: ABDENOUR HADID; python-list at python.org Subject: Re: need Numeric module Why not try a Google search for Numeric Python. Issac ABDENOUR HADID (hadidab at yahoo.fr) wrote: > hello.. > > I want to excute a scrit wich import a Numeric module, > where can I find this module? > > thanks > > > > ___________________________________________________________ > Do You Yahoo!? -- Pour dialoguer en direct avec vos amis, > Yahoo! Messenger : http://fr.messenger.yahoo.com > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list From db3l at fitlinxx.com Thu Jan 25 17:12:42 2001 From: db3l at fitlinxx.com (David Bolen) Date: 25 Jan 2001 17:12:42 -0500 Subject: ANN: timeoutsocket.py --> v1.12 works with Python 2.0 References: <980352751.234548674@news.flashcom.net> <3A6F9224.FBCE2EF1@home.com> Message-ID: Rick Lee writes: > I don't know how expensive threads are. If I have to implement a > server, it seems to me that I have to do recv() on every connection I > accept on a separate thread. Is that the way to go? Is there a more > efficient way? Typically an application like this uses select() to wait for any of its connections to have something to process, and then it processes those that it needs to. Some later Unix platforms also have a poll() call that can be more efficient. So you end up with a main loop (which may be a distinct thread if you have a GUI front-end) blocking in select() except when something needs to be done. > Asyncore? (In my application, all TCP connections are > very long lived, there can be up to 1000 simultaneous connections.) The asyncore module effectively packages up the loop around the select (or poll if available), and dispatches I/O to the appropriate socket connections as necessary. It'll also queue up output and send it out as it can from any of your socket writes. It's a little different coding model when you write your top level code using the library (since effectively you are writing small hooks to either keep the library fed with more data to send, or to drain data as it is received), but it can be very effective. As to whether you can support 1000 simultaneous connections (particularly dependent on how much data is flowing simultaneously) will depend on a lot of things (including your OS/kernel, memory, network stack and so on), but I do think it's technically feasible. You may also want to look at the open/free medusa framework (http://www.nightmare.com/medusa) which is layered on top of asyncore to provide services such as an HTTP server. If not useful directly, at least it will provide some examples of coding to asyncore. -- -- 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 nas at arctrix.com Fri Jan 5 19:04:50 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Fri, 5 Jan 2001 16:04:50 -0800 Subject: failed fork with latest 2.4 linux kernel? In-Reply-To: <3A56B959.F1647198@SPAM.sgi.com>; from sandeen.NO@SPAM.sgi.com on Sat, Jan 06, 2001 at 12:21:13AM -0600 References: <3A56B959.F1647198@SPAM.sgi.com> Message-ID: <20010105160449.C6016@glacier.fnational.com> On Sat, Jan 06, 2001 at 12:21:13AM -0600, Eric Sandeen wrote: > Everything worked at -test11, but with -prerelease and 2.4.0, we get > this dump (the execWithCapture function is at the end of this message). > This will fail for any arv. The kernel version seems to be the only > variable here... any ideas? You might want to try running the Python test suite. It should be installed in the Python lib directory under test. You want to run the script regrtest.py. Also, it would be helpful to know what version of Python you are using. I am running Linux 2.4.0 and have no problems with 1.5.2 and the CVS version of Python. Neil From bkc at Murkworks.com Tue Jan 16 10:34:39 2001 From: bkc at Murkworks.com (Brad Clements) Date: Tue, 16 Jan 2001 10:34:39 -0500 Subject: Python and Industry, IBM I'm afraid References: <3A63D9E8.F9B74ACE@mjs400.co.uk> <941c14$dok$1@nnrp1.deja.com> <3A642C9F.58E02F23@mjs400.co.uk> Message-ID: <0PZ86.124$Lm2.8536@news.clarkson.edu> 6 months ago I rattled several doors at IBM to see if they'd sponsor a port of Python to AS/400 (that is, spare me a few bucks and a machine to do the port). I never was able to make the necessary connections and gave up. Meanwhile, I did finish the port of Python 1.5.2 and Zope to NetWare, but Novell isn't interested in sponsoring that either so I'm stuck trying to figure out how to recoup the cost. Don't get mad at me, but I'm a poor programmer with a family to feed and just can't spare much time on non billable stuff even though I absolutely love Python :-( -- Brad Clements, bkc at murkworks.com "Pete"

wrote in message news:3A642C9F.58E02F23 at mjs400.co.uk... > Honestly Simon! I do have an old, working version of JPython on my > account on virtual400.com :) THAT was easy. > More importantly though, if I can put to one side the 11 years spent > coding for Business (the horror...the horror...), and get further into > debt, and stay fatherly, and get hold of a C compiler, perhaps it will > be a good challenge to make the first EBCDICy Python Port, but I think > brighter, fitter, younger guys can do it before the end of the century. > > Given Industry/IBM is a fact that hasn't changed, and won't change in a > hurry: what's next? > > --Pete From fredrik at effbot.org Wed Jan 3 17:03:53 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 03 Jan 2001 22:03:53 GMT Subject: Iterating over multiple lists (a newbie question) References: <3a539f3a.445366109@localhost> Message-ID: Victor Muslin wrote: > I would like something like this (which obviously does not work): > > for one,two in list1, list2: > print one,two in 2.0, use "zip": for one, two in zip(list1, list2): ... in earlier versions, you can use range or map(None): for i in range(len(list1)): one, two = list1[i], list2[i] for one, two in map(None, list1, list2): ... hope this helps! cheers /F From sill at localhost.kitenet.net Tue Jan 16 20:51:43 2001 From: sill at localhost.kitenet.net (Oldayz) Date: Wed, 17 Jan 2001 01:51:43 GMT Subject: Best way to learn Python ? References: Message-ID: On Tue, 16 Jan 2001 20:38:10 -0800, J5 wrote: >No schools teach it, so what books do you recommend ? > >Also, what are some cool programming projects I could do ? > >What do you guys write with python ? > >J5 I personally read the tutorial on python.org, got the ORA programming python book (although I don't like it for some reason) and write small programs I need.. for instance, I needed to read some e-books but text files with really long lines are hard to read in vim so I wrote a small python script that splits them up into 80 char ones.. then I wrote a small script that autostarts screen- saver every 10 minutes unless 'no screensaver' flag is set (to give my eyes some rest :-), then I wrote a small script that is a frontend to cdrecord, cdrdao, mkisofs, to burn cds.. then I made a little script that changes back- ground in WM randomly and is run every day from crontab.. and then the biggest one i wrote (at ~200 lines) is a program that keeps track of how much time I spend on a project - so that I can look at the logfile and say 'damn.. I only worked on this 15 hours this week, I better stop being so lazy'. I'm also planning two more things: irc client (i'm looking through pyirc to see how things are done..) and a frontend to mpg123 that would allow me to rate songs and play them randomly with higher rated songs having more of a chance of being played.. So, in other words, the best way to learn is to do things that you need to be done.. I also try to follow the newsgroup, look at the questions and answers and learn from that. Hope this helps. -- Andrei From moshez at zadka.site.co.il Sat Jan 20 14:57:59 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 20 Jan 2001 21:57:59 +0200 (IST) Subject: [OT] Shared Libraries (was Re: Deployment woes (was: I will kill my Python)) In-Reply-To: References: , , <947r18$rdt$1@news.online.de> <4DE7F9DB9399A3C1.D96FC6EFB3F2391E.88AD1775E4555FCA@lp.airnews.net> Message-ID: <20010120195759.CF74AA83E@darjeeling.zadka.site.co.il> [Moshe Zadka] > Basically, the problem is thorny, the solution is hairy, and the only > saving grace of Linux is that the packages have concepts of dependancies. [Quinn Dunkan] > How about static linking? It solves a different problem (code reuse) -- but not the problems shared libraries were meant to solve (less space on disk, less space in memory, transparent upgradeability). Since the solution is sometimes worse then the problem, sometimes it's better to do static linking. On Windows too . life-is-complex-ly y'rs, Z. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From emile at fenx.com Fri Jan 12 12:30:29 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 12 Jan 2001 09:30:29 -0800 Subject: A small suggestion for Python References: <3A5F27F7.30268D9A@erols.com> Message-ID: <93nf0g$amfvv$1@ID-11957.news.dfncis.de> This follows the explicit is better than implicit concept, so outside of adding a keyword and breaking backward compatibility (bad things), this is probably a good thing ;-). If such a thing were to be added, might it also be good to raise an exception when not assigning the return value? If so, perhaps a nothing would not object to being a sink hole (ala /dev/null). --- class test: def mysort(self): "method w/o return" def retval(self): return "retval" def retval(): return "retval" def mysort(): "function w/o return" --- y = test() y.mysort() # ok ??? = y.mysort() # fails ??? = y.retval() # ok mysort() # ok ??? = mysort() # fails ??? = retval() # ok not-holding-my-breathe-le y'rs -- Emile van Sebille emile at fenx.com ------------------- "Edward C. Jones" wrote in message news:3A5F27F7.30268D9A at erols.com... > I have been programming in Python for several years. I still > occasionally make mistakes with functions (such as sort) that > return only "None". I suggest that functions like sort should > return either "Nothing" or nothing. "Nothing" would be exactly > like "None" except it can't be assigned. Whether "Nothing" or > nothing is used, the statement "x= y.sort()" would raise a > run-time Exception. > > Thanks, > Ed Jones > > From fredrik at effbot.org Wed Jan 31 09:01:43 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 31 Jan 2001 14:01:43 GMT Subject: BUG? Python 2.0 chokes on international characters in Unicode strings References: <958g0k$f97$1@wanadoo.fr> Message-ID: Jurie Horneman wrote: > Is this a known bug? (If so, AAARRGGHHH - could it really be that Python > basically doesn't work outside of the US? Hard to believe: these characters > are used in the Dutch language...) it's not a bug -- it's just that there are only 127 ASCII code points, and 40,000+ unicode characters... > Is there some workaround? Could I convert Unicode strings to ASCII? If so, > how? use the encode method: u = any unicode string s = str(u) # will fail for non-ascii characters s = u.encode("utf-8") # will always work s = u.encode("iso-8859-1") # may fail for non-latin-1 characters s = u.encode("ascii", "ignore") # won't fail, but may lose chars s = u.encode("ascii", "replace") # won't fail, will replace non-ascii chars import locale # get the most likely output encoding (works on most unix, # windows, and macintosh installations) loc, enc = locale.getdefaultlocale() print u.encode(enc, "replace") see http://www.python.org/doc/current/lib/string-methods.html for more info on the encode method, http://www.python.org/doc/current/lib/module-codecs.html for more info on codecs (including stream codecs) Cheers /F From s713221 at student.gu.edu.au Thu Jan 4 02:57:58 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Thu, 04 Jan 2001 17:57:58 +1000 Subject: Calling an application from inside a python script Take 1 References: Message-ID: <3A542D06.9766A9CD@student.gu.edu.au> > > My long winded question is > how do I get python to call an external application? > > If someone could point me in the right direction I would really > appreciate it. Thanks for your time! > > Chris >>> import os >>> os.system('echo "hello"') hello 0 >>> Hope that helps. Joal Heagney/AncientHart From jasonic at nomadicsltd.com Thu Jan 25 17:35:15 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Thu, 25 Jan 2001 17:35:15 -0500 Subject: ZOPE : Zcatalog References: <94pib3$1e2t$1@news5.isdnet.net> Message-ID: Fabien Germain wrote in message news:94pib3$1e2t$1 at news5.isdnet.net... > Hello, > > First, is there a NG only for Zope ? Alas no. But there are very active mailing lists. [high signal to noise] Since Digital Creation have a very feeble sense of web site usability/design, this essential liink is buried 3 levels down at: http://www.zope.org/Resources/MailingLists --Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] From sbrunning at bigfoot.com Tue Jan 16 06:41:25 2001 From: sbrunning at bigfoot.com (Simon B.) Date: Tue, 16 Jan 2001 11:41:25 GMT Subject: Python and Industry, IBM I'm afraid References: <3A63D9E8.F9B74ACE@mjs400.co.uk> Message-ID: <941c14$dok$1@nnrp1.deja.com> In article , "Tim Peters" wrote: > [Pete] > > Has anyone ported Python to IBM iSeries 400?...Or is this > > considered too much hassle, because they are big fat trucks > > of servers - and come bundled with no GUI support (they have > > had posix for many years)?...Or are people waiting for Linux > > support in a logical OS partition?...Or does no one care? > > A Python port to platform X, regardless of X, is almost always done by some > user of X who wants to run Python on X, and usually working alone. That's > how things work in any project without revenue to pay for a port (don't know > whether you've used Python, but if you have and someone charged you for it, > you were suckered bigtime). > > I don't know whether there are any Python ports to IBM iSeries 400, but, if > there aren't, that would be because no IBM iSeries 400 user bothered to port > it. In which case, you'll have to ask them what their hangup is -- or ask > IBM why they don't think it's worth their time to make a port available. > Note that Intel and Microsoft cared enough to pay ActiveState for a Win64 > Python port. So there's more than one way to get a port done, but the only > way that's free requires a volunteer. The subject of porting Python to the iSeries 400 (better known as the AS/400) has come up before - do a deja search on 'AS/400' in c.l.py, and you'll find quite a few hits. Its not a case of not being bothered - I'd *love* to get Python going on the '400. The main issue is that the AS/400 doesn't come with a C compiler. There is a C compiler available, but it's expensive, and almost no one has it. I've been working on the '400 for over ten years, on dozens of sites, and I've *never* come across one with the C compiler installed. The '400 world is dominated by various flavours of RPG, with a scattering of COBOL. Very exciting. Now, a Jython port is a bit more likely - the '400 comes with what I'm told is a very good JVM. I've not had any sucess getting it to work just yet, but I keep trying. If I ever do get it going, c.l.py will be the first to know... -- Simon Brunning A rock pile ceases to be a rock pile the moment a single man contemplates it, bearing within him the image of a cathedral. - Antoine de Saint-Exupery Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Fri Jan 26 12:01:26 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 26 Jan 2001 17:01:26 GMT Subject: informal representation of long integers References: Message-ID: Randall Kern wrote: > Using Python 1.5.2: > > >>> str(10L) > '10L' > >>> repr(10L) > '10L' > > Just curious why the 'informal' representation of 10L > is '10L', rather than '10'. which one is the "informal" representation? if you mean "str", python 1.6 and later does what you want: >>> str(10L) '10' >>> repr(10L) '10L' Cheers /F From moshez at zadka.site.co.il Mon Jan 15 08:37:12 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: 15 Jan 2001 07:37:12 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jan 15) Message-ID: <2202C3D583A4D789.DB5E306A785ABF5E.5CE0FA4DEBA805D0@lp.airnews.net> A lot of Python software is announced this week: Phil Thompson announces BlackAdder, an IDE http://deja.com/threadmsg_ct.xp?AN=714236647 Steve Pike announces PikiePikie, yet another WikiWiki clone http://deja.com/=dnc/getdoc.xp?AN=714600578 Mark Hammond announces PyXPCOM http://deja.com/=dnc/getdoc.xp?AN=714704292 Pete Shinners announces pygame http://deja.com/=dnc/getdoc.xp?AN=715685318 David Allen announces a gopher client http://deja.com/=dnc/getdoc.xp?AN=714680975 Tom Hazel announces some C++ modules for event-based programming http://deja.com/=dnc/getdoc.xp?AN=714155765 Mark Hammond explains how to turn C++ exceptions into Python exceptions http://deja.com/=dnc/getdoc.xp?AN=715158611 and clarifies win32 licensing issues http://deja.com/threadmsg_ct.xp?AN=714080019 Andrew Kuchling asks about modules to read tar files http://deja.com/=dnc/getdoc.xp?AN=714509949 and summarizes the answers http://deja.com/=dnc/getdoc.xp?AN=714633221 Neil Schemenauer shamelessly promotes Quixote http://deja.com/=dnc/getdoc.xp?AN=715491037 Amy Katherine sends an update about IPC9 http://deja.com/=dnc/getdoc.xp?AN=714636560 Fredrik Lundh explains why list.sort() returns None http://deja.com/=dnc/getdoc.xp?AN=715271948 how to find URLs in text http://deja.com/=dnc/getdoc.xp?AN=714986303 reading line-by-line in (future) Python 2.1 http://deja.com/=dnc/getdoc.xp?AN=715622713 and parsing broken HTML http://deja.com/=dnc/getdoc.xp?AN=714626763 Alex Martelli describes an alternative way to parse broken HTML http://deja.com/=dnc/getdoc.xp?AN=714811428 and explains how to call methods by name http://deja.com/=dnc/getdoc.xp?AN=714467730 Erno Kussela asks how to open a ZODB database from multiple processes http://deja.com/=dnc/getdoc.xp?AN=714350424 Remco Gerlich gives the easy way to find out if a string is numeric http://deja.com/threadmsg_ct.xp?AN=714836987 Tim Peters answers question about pattern matching in Python http://deja.com/=dnc/getdoc.xp?AN=714844866 Life is not all serious at Pythonland. Martijn Faassen announces future PSU plans: http://deja.com/=dnc/getdoc.xp?AN=714114496 Steve Holden stirs dormant conspiracy theory http://deja.com/threadmsg_ct.xp?AN=714907501 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://deja.com/group/comp.lang.python.announce Andrew Kuchling writes marvelous summaries twice a month of the action on the python-dev mailing list, where the future of Python is truly determined http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sholden at holdenweb.com Fri Jan 12 13:50:24 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 12 Jan 2001 13:50:24 -0500 Subject: How robust is Python ? References: <002301c07cba$ddef9080$020000c3@node02> <005e01c07cbe$418f1360$0201a8c0@holdenweb.com> <008101c07cc5$41740d20$020000c3@node02> Message-ID: <008d01c07cc8$86782ca0$0201a8c0@holdenweb.com> In the example you give, the "print" statement is a part of the class definition suite. It will therefore be executed when the class definition is processed: >>> class newclass: ... print "Something" ... Something This feature can be used to assign class variables (shared across all instances), because the class namespace is local at time the definition suite is processed. If you wanted to print something when the exception was raised, you could put the print statement in the __init__ method of the class: when an exception is rasied, an instance is created: >>> class WeirdException: ... def __init__(self): ... print "Weird stuff, man" ... >>> raise WeirdException Weird stuff, man Traceback (innermost last): File "", line 1, in ? WeirdException: <__main__.WeirdException instance at 016EC35C> You can, of course, use *instances* of your exception class rather than the class itself to raise exceptions. You can either do this by simply using an instance call directly, or you can add a single argument or a tuple (which will become the argument list) to the "raise" statement: >>> class ParamException: ... def __init__(self, file="Unknown", line="not given"): ... self.file = file ... self.line = line ... This allows you to pick up the exception and handle it using its methods and attributes. This example doesn't use any methods, just attributes, but it should give you the idea. >>> try: ... raise ParamException("BigFile.txt", 23) ... except ParamException, p: ... print "Except: error in file", p.file, "at line", p.line ... Except: error in file BigFile.txt at line 23 Sorry about the tabbing in this mail. regards Steve ----- Original Message ----- From: "Sandipan Gangopadhyay" To: "Steve Holden" Sent: Friday, January 12, 2001 1:27 PM Subject: Re: How robust is Python ? > Absolutely. Its superfluous to catch AnyOldNameILike separately if I intend > to do nothing different about it ! > > I would however, prefer your suggestion of creating a special exception than > to (ab)use an existing one. Just doesnt seem right. > > I am curious about something, though. What would happen if I replaced pass > in - > > class AnyOldNameILike: > print "Hi there" > > Ie, if/when is this print executed ? > > My thanks and regards, > > Sandipan > From bowman at montana.com Mon Jan 29 09:41:12 2001 From: bowman at montana.com (bowman) Date: Mon, 29 Jan 2001 07:41:12 -0700 Subject: Books References: <3a757ac1$1@netnews.web.de> Message-ID: Volker Jahns wrote in message news:3a757ac1$1 at netnews.web.de... > > Second: I searchin links about PHYTON and fpound not very much. The german web- > addr is dead and behind the .org have nothing to do (I think) with the language... search for PYTHON and you will have greater success. From teep at inet.co.th Thu Jan 18 04:21:43 2001 From: teep at inet.co.th (Prateep Siamwalla) Date: Thu, 18 Jan 2001 16:21:43 +0700 Subject: This is my first program in Python References: <3a66a585.268350144@news.tcn.net> Message-ID: <946cej$vuu$1@news.inet.co.th> I tried your program on my PythonWin editor, and it worked for me. What error message did you get? contents of file c:\blank\globs.txt: one:alpha two:beta three:gamma >>> def trythisout(): ... f = open(r'c:\blank\globs.txt','r') ... for line in f.readlines(): ... (first,second) = string.split(line,":",1) ... print first ... f.close() ... >>> trythisout() one two three did you get a "ValueError: unpack list of wrong size" error? If you did, then one of your input lines probably is missing a ":" hope this helps. teep Richard Zilavec wrote in message news:3a66a585.268350144 at news.tcn.net... > > I've spent the last few weeks trying to find a good book on Python. > Seems that most stores don't carry a large selection, however I found > The Quick Python Book.. The material seems to flow in the right > direction and the fonts are easy on the eyes. > > Anyways, I wrote my first program but was stumped on readline(). I > could get the first line, but not the rest of the file. I tried > searching python.org and could not find an example.... well here it > is: > > import string > file = open("/tmp/globs", 'r') > for line in file.readlines(): > (first,second) = string.split(line,':',1) > print first > file.close() > > This was my first attempt, which looks like it should work but failed: > invalid syntax. Is this not possible? > while line = file.readlines(): > > Am I using string.split properly? > > I was quite happy with how easy this was to put together, I'm just not > sure if its totally correct. > > -- > Richard Zilavec > rzilavec at tcn.net From bencr at bigpond.com Sun Jan 21 04:56:30 2001 From: bencr at bigpond.com (Ben) Date: Sun, 21 Jan 2001 20:56:30 +1100 Subject: Traversing A Directory For Files Message-ID: Hi, I am looking for examples of a recusive Python algorithm to traverse a directory and all subdirectories for files and return them to a list for further processing. I have something written already ... but it doesn't appear to be that eloquant Thanks In Advance From csrabak at uol.com.br Wed Jan 24 20:05:39 2001 From: csrabak at uol.com.br (Cesar Rabak) Date: Wed, 24 Jan 2001 23:05:39 -0200 Subject: beep again References: <5251-3A6E5B71-16@storefull-163.iap.bryant.webtv.net> <94n5td$gu1$1@nnrp1.deja.com> Message-ID: <3A6F7BE3.98CFC640@uol.com.br> Mark Hammond wrote: > > In article <5251-3A6E5B71-16 at storefull-163.iap.bryant.webtv.net>, > clickron at webtv.net wrote: > > Thanks for answering my last question. I get the beep now, but no > matter > > what numbers I put in for the frequency and duration it doesn't > change. > > The Python test suite has the following: > > import winsound > for i in range(100, 2000, 100): > winsound.Beep(i, 75) > print "Hopefully you heard some sounds increasing in frequency!" > > This does the "right thing" on both Python 2.0 and 2.1a1 > Well, in ActivePython 2.0, build 202, it only runs a ding.wav from windows. (Win98 SE). From chris at chrullrich.de Sun Jan 14 16:50:35 2001 From: chris at chrullrich.de (Christian Ullrich) Date: 14 Jan 2001 22:50:35 +0100 Subject: Threaded server doesn't run its threads Message-ID: Hello all! I am writing a small server to remotely control (run and monitor) an application. Because this is my first encounter with networks, I decided to use Python, as it appears to be rather easy to use. Now I am facing a problem in the implementation. My server is supposed to run the app and monitor its output, and at the same time respond to status queries, so I think I can't let the MyRequestHandler block. I read a bit about select, but i did not understand it, and I want to get some working code in the _near_ future. So I chose the ThreadingTCPServer. But it doesn't work. The server script starts and runs. When I telnet to the port, I get a connection, but no response from the server (MyRequestHandler.handle() seems not to be called). If I now Ctrl-C the server script, handle() is called, but if I enter a command via telnet, the script simply terminates, rather than handling the command, as it's supposed to do. The same code, just using TCPServer instead of ThreadingTCPServer, does not show this behavior, the forking server works fine as well. I am using Python 2.0 on Linux, but it fails similarly on NT. Might there be a problem with the underlying OS support? Because this post is already quite long, I am not including example source. If you need it, please tell me. -- Christian Ullrich Registrierter Linux-User #125183 "Sie k?nnen nach R'ed'mond fliegen -- aber Sie werden sterben" From DanielK at jBASE.com Mon Jan 15 17:42:52 2001 From: DanielK at jBASE.com (Daniel Klein) Date: Mon, 15 Jan 2001 14:42:52 -0800 Subject: Determining names of instances Message-ID: A question I hope has a simple answer. Take the following simple class and instance class foobar: pass foo = foobar() The question is, is there a way for the object 'foo' to know that its name is 'foo'? Daniel Klein From jianchen at my-deja.com Mon Jan 8 09:15:40 2001 From: jianchen at my-deja.com (jianchen at my-deja.com) Date: Mon, 08 Jan 2001 14:15:40 GMT Subject: zombie question References: <93c19g$5k7$1@nnrp1.deja.com> Message-ID: <93ci26$hog$1@nnrp1.deja.com> sure! the parent process looks like this?? ------------------------------------------------------------ serv=socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: serv.bind((HOST,PORT)) except: print "Can't bind to local port %s" % PORT sys.exit(-1) serv.listen(5) signal.signal(signal.SIGCHLD,handler) while 1: conn,addr=serv.accept() pid=os.fork() if pid<0: myerr('Can\'t fork new process') if pid==0: # the child process serv.close(?? proxy(conn,addr) # the real proxy sys.exit(0) conn.close() ------------------------------------------------------------ The handler is : def handler(signum,frame): pid,excode=os.waitpid(-1,os.WNOHANG) return ------------------------------------------------------------ the most strange thing is that the handler is never called! any advice. thanks! Sent via Deja.com http://www.deja.com/ From syver at NOSPAMcyberwatcher.com Thu Jan 18 15:18:54 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Thu, 18 Jan 2001 21:18:54 +0100 Subject: Python ActiveX Scripting Engine raising Unicode errors References: Message-ID: <947j84$503$1@troll.powertech.no> > > > This is too weird: I just renamed pySQL.py, checked that there is no pySQL.* > file *anywhere* on my disks, and the ASP page still claims to be seeing an > error in it! In my experience imported modules stay in memory until you unload the IIS application or restart the w3svc service. You can also make an asp page with reload statements for the relevant modules as long as this asp page is situated in the same application. > Clearly some weird cacheing going on here. Yes! Regarding the unicode error, you probably try to process characters outside the 128 ascii characters, is it possible that some international characters have been entered into the text field? From joejava at dragonat.net Fri Jan 5 09:06:21 2001 From: joejava at dragonat.net (Joel Ricker) Date: Fri, 5 Jan 2001 09:06:21 -0500 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <933fa1$j2i$1@newshost.accu.uu.nl> Message-ID: Steve Lamb wrote in message ... >On Fri, 5 Jan 2001 00:47:32 -0500, Joel Ricker wrote: > No braces for blocks and intention matters. For example... [*snip* Program example*] > ...do two different things. The former will print foo and bar on two >separate lines only if something is true. The latter will pring foo only if >something is true but will always print bar. After seeing examples of this, I'm don't think I'll mind that. I took a FORTRAN class once and which used quite a bit of white space for its control structs but I think it won't be so bad with Python. Especially no more counting curley braces to find where the logic error is. Joel From moshez at zadka.site.co.il Fri Jan 5 22:17:48 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 6 Jan 2001 05:17:48 +0200 (IST) Subject: How robust is Python ? In-Reply-To: <9354f9$vbi$1@nnrp1.deja.com> References: <9354f9$vbi$1@nnrp1.deja.com>, Message-ID: <20010106031748.BF2CDA84F@darjeeling.zadka.site.co.il> On Fri, 05 Jan 2001 18:40:41 GMT, rturpin at my-deja.com wrote: > That's an interesting comment. We're planning an "always > up" application, that launches at boot, runs until next > restart or shutdown, and does a lot of work in between. > I'd like to use Python. I've been working under the > assumption that it is adequately robust for this purpose. > > Does anyone want to caution me on this? You might have misunderstood my English. X is just as T as Y means T(x) >= T(y). Python is vey robust. However, personally I wouldn't trust *any* language for that. Have a every-minute cron which resurrects it if it isn't up? That means you're as stable as either Python or the OS infrastructure, whichever is better. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From fredrik at effbot.org Mon Jan 15 01:31:04 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 15 Jan 2001 06:31:04 GMT Subject: manipulating data References: <93ttmd$j04$1@nnrp1.deja.com> Message-ID: ibrewale_2000 at yahoo.com wrote: > I have a Pmw/Tkinter program I am trying to write (just learning), in a > text entry box I can retrieve numbers entered into it and print it like > this... > > print self.amount.get() > > But I want to assign the number I retrieve with get, into a variable, > like: > > b = self.amount.get() > > but this doesnt work. "doesn't work" as in "TypeError: can't multiply sequence with non-int"? If so, Python's trying to say that you're mixing data types. > How do I put it into the variable?? assuming "self.amount" is an Entry widget (or something compatible), try: b = float(self.amount.get()) b = b * 0.0875 ... Cheers /F From jafo-pythonlist at tummy.com Sun Jan 21 01:57:01 2001 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Sat, 20 Jan 2001 23:57:01 -0700 Subject: peer-to-peer in python In-Reply-To: <945ngf$731$1@nnrp1.deja.com>; from peter@peermetrics.com on Thu, Jan 18, 2001 at 03:21:56AM +0000 References: <945ngf$731$1@nnrp1.deja.com> Message-ID: <20010120235701.E20336@tummy.com> On Thu, Jan 18, 2001 at 03:21:56AM +0000, peter at peermetrics.com wrote: >I am looking for good Python developers to help me out with a peer-to- >peer system (written entirely in Python.) We have a working demo / You'll probably get a better response if you say how much you're paying for people who accept this job. Hmm... On the other hand, maybe you won't. ;-) Sean -- This mountain is PURE SNOW! Do you know what the street value of this mountain is!?! -- Better Off Dead Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From aleaxit at yahoo.com Wed Jan 10 12:09:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 10 Jan 2001 18:09:39 +0100 Subject: embedding python in C++ References: <934r1a$pda$1@troll.powertech.no> <93a3lp01kpg@news1.newsguy.com> <93b02a$tr8$1@troll.powertech.no> <93cq6n0186t@news1.newsguy.com> <93fgim04oc@news1.newsguy.com> <93g8sp$pcj$1@troll.powertech.no> <93hgeq014d3@news2.newsguy.com> Message-ID: <93i52v01qim@news2.newsguy.com> "Syver Enstad" wrote in message news:mMZ66.1325$k25.19052 at news1.oke.nextra.no... > > "Alex Martelli" wrote in message > news:93hgeq014d3 at news2.newsguy.com... > > Just reiterating an important point: this is true for *instances*, > > where such after-the-fact tagging is implemented; it may not be for > > a typical C-coded type, unless care is taken to let the caller set > > (and re-read) arbitrary attributes. > > This is done by implementing setattr so that it assigns values to python > dictionary that is a member of the C type, right? Yes, and getattr accordingly; or you can just watch for the 'softspace' name and keep one bit to record that, if all you need is fileobject emulation for print-statement purposes. Alex From romberg at smaug.fsl.noaa.gov Wed Jan 24 12:35:21 2001 From: romberg at smaug.fsl.noaa.gov (Mike Romberg) Date: 24 Jan 2001 10:35:21 -0700 Subject: python-2.1 function attributes Message-ID: I've been messing around with python-2.1a1 and have discovered the new feature 'function attributes'. The project I'm currently working on can really use this feature. The feature itself would be much more useful if one could predefine a set of attributes with the function definition. This is one of the things mentioned in the 'future directions' sections of pep 232 http://python.sourceforge.net/peps/pep-0232.html So... I guess I'd like to put in one 'yes' vote for this extension :). Mike Romberg (romberg at fsl.noaa.gov) From dalke at acm.org Mon Jan 22 20:33:03 2001 From: dalke at acm.org (Andrew Dalke) Date: Mon, 22 Jan 2001 18:33:03 -0700 Subject: How do I know all thrown exceptions of a function? References: Message-ID: <94imre$7dd$1@slb6.atl.mindspring.net> Delaney, Timothy wrote: >Personally, I think Java's view of exceptions (almost) makes >sense. Actually, I disagree. Consider a function which numerically integrates another function over a given range: def integrate(func, x_min, x_max): ... will compute func(x) for several values of x between [x_min, x_max] ... What exceptions does "integrate" throw, given that "func" can throw anything? As I understand the Java way, you must declare all of the exceptions thrown by "func", which most people will take to mean it only throws a math error (divide by zero, overflow, etc.). Once the "func" exceptions are known, the "integrate" ones are also known. However, suppose func is very involved and I decide to use a cache: class MyCache: def __init__(self, func, cache_file = "func.cache"): # open the file as a dbm; don't know the args but this is self.cache = gdbm.open(cache_file, "rw") # close enough self.func = func def __call__(self, x): y = self.cache.get(x) if y is not None: return y y = self.func(x) self.cache[x] = y return y Suppose also that the file system breaks, or gets full, so the dbm interface no longer works. This throws a dbm error. What is the best way to handle this unexpected exception in the Java way? I actually don't know. As far as I can tell, the only way to do it is let integrate raise a specific "CannotIntegrate" exception, then implement a wrapper, like for MyCache, which converts any non-numeric exception in the CannotIntegrate exception, as in try: y = self.func(x) except (DivideByZeroException, other expected math errors ...): raise except (SystemExit, KeyboardInterrupt): # allow forced breaks raise except: .. convert to a CannotIntegrate exception .. return y To me, this is ugly and error prone. (Is this really what you need to do for Java - the Feb. Dr. Dobb's comparison between Java and C# suggests so.) Thus, I would rather write my code to be exception safe, in that it gracefully accepts any exception, then to declare every exception type. Andrew dalke at acm.org From erno-news at erno.iki.fi Mon Jan 22 19:12:31 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 23 Jan 2001 02:12:31 +0200 Subject: Replacing control characters. References: <94ifec$ggt$1@nnrp1.deja.com> Message-ID: In article <94ifec$ggt$1 at nnrp1.deja.com>, johnvert at my-deja.com writes: | I want to remove all of these characters, but since | it's not an actual caret (^) and a letter M, but the *Ctrl* character | C-M I don't know how to refer to them in a regexp. How can I? C-M would be '\x0d'. you can look at the ascii(7) manual page for the codes, or type something like print hex(ord('^M')) at the prompt. the way to insert a literal ^M there is to first type ^V to prevent readline or the tty driver from meddling with it. | Also, what would be the most efficient way to do this in Python | (e.g. use regexp functions to maybe module string will do?) string.translate()/string.maketrans() probably. -- erno From tim at degree.ath.cx Fri Jan 26 20:54:07 2001 From: tim at degree.ath.cx (Tim Hammerquist) Date: Sat, 27 Jan 2001 01:54:07 GMT Subject: .cgi or .cgp or .py or ? References: <94reu2$8uh$1@nnrp1.deja.com> Message-ID: Hamish Lawson wrote: > Tim Hammerquist wrote: > > > You can at least take comfort in the fact that the > > mass majority of P*** CGI scripts have either no extension or .cgi and > > therefore do not "promote" their mother-language in the way you > > described. > > However, if you have scripts in various languages at your site, using > the extension of .py may make it easier at some future date to migrate > your Python scripts to being handled by something other than the > universal CGI handler - for example, the Apache mod_python handler. If I and my equals can't do a `head -3 scriptname` to find out what language it is, we have many more problems than I thought. =) Besides, not having an extension at all allows a security feature via obfuscation. Remember Apaches trick of: http://domainname.com/subdirectory/a-name/someword.html ...where a-name is actually the script? If visitors think it's an html file as it appears to be, they will be much less likely to try to hack it. Is this as feasible as a security measure thus?: http://domain.com/stuff/a-name.py/someword.html Just some considerations. As I said in another post, use whichever extension works best in any given situation. HTH -- -Tim Hammerquist Legend -- a lie that has attained the dignity of age. -- H. L. Mencken From embed at NO_SPAM_PLEASE.geocities.com Tue Jan 9 14:58:59 2001 From: embed at NO_SPAM_PLEASE.geocities.com (Warren Postma) Date: Tue, 9 Jan 2001 14:58:59 -0500 Subject: Should I join the PSA if it's "no longer relevant"? Message-ID: I have a Python port (for ETS) that I'd like to place on the web somewhere, preferably on Starship.python.net. I have nothing against joining the PSA, but on the PSA web page I read: > The PSA no longer serves a real purpose, now that the Python development > team no longer works for CNRI. The information about memership below is > no longer relevant, but lack of time prevents us from rewriting this webpage > to fully reflect reality. So, here's the question, do I join PSA still, to get a page on Starship, or can I get a page on Starship, without joining the PSA? How do we contribute to Python development? What do I do?! Warren Postma Python-ETS developer From c.ullrich at vulkantechnic.de Mon Jan 15 05:12:49 2001 From: c.ullrich at vulkantechnic.de (c.ullrich at vulkantechnic.de) Date: Mon, 15 Jan 2001 10:12:49 GMT Subject: Threaded server doesn't run its threads References: Message-ID: <93uieu$2ll$1@nnrp1.deja.com> * Christian Ullrich wrote: > But it doesn't work. The server script starts and runs. When I telnet > to the port, I get a connection, but no response from the server > (MyRequestHandler.handle() seems not to be called). If I now Ctrl-C > the server script, handle() is called, but if I enter a command via > telnet, the script simply terminates, rather than handling the > command, as it's supposed to do. I tried it on two more machines, one Linux, one NT, there it all works just fine. I'm confused now. > Might there be a problem with the underlying OS support? Now I think this is the probable cause. Could someone please list the required software to get thread support working? Thank you. Sent via Deja.com http://www.deja.com/ From warrickb at my-deja.com Wed Jan 31 06:30:37 2001 From: warrickb at my-deja.com (warrickb at my-deja.com) Date: Wed, 31 Jan 2001 11:30:37 GMT Subject: Wrapping up a C++ class References: <954496$ues$1@nnrp1.deja.com> <9546rv01ahd@news2.newsguy.com> <9565q3$nnh$1@nnrp1.deja.com> <956shd0149r@news2.newsguy.com> Message-ID: <958t0t$2vc$1@nnrp1.deja.com> But be careful not to confuse them with people who understand C++ and _C++_ but are quite rightly content to code inbetween. Sent via Deja.com http://www.deja.com/ From xyzmats at laplaza.org Wed Jan 17 09:13:23 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 17 Jan 2001 14:13:23 GMT Subject: Curses module for Python 2.0 for Windows NT References: Message-ID: <3a65a767.3665680@news.laplaza.org> On Wed, 17 Jan 2001 09:23:42 +0100, jurgen.defurne at philips.com wrote: >Dear all, > >I am busy automating tasks across some Windows NT workstations, where >I control another program (Continuus/CM, if any one knows that). >Unfortunately, that control is not that easy. Ihave built a GUI interface, >but I am not really satisfied with it, so I want to simplify it somewhat so that >it can run in a DOS box using curses. Is there a curses add-on available >for the Win32 binaries ? It sure isn't part of the distribution I am using, >which is still the BeOpen version of Python 2.0 Problem is not with Python, but with missing the piece that the curses module depends on: curses itself. I haven't seen anything recently that indicates curses-on-Windows available cleanly. There was a console application noted here not too long ago that might be usable; the GNU project page for curses indicates that a solid Windows port is still a whishlist item. Nonetheless, vim works very well on Windows so someone out there has presumably done the necessary work. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From rwklee at home.com Wed Jan 24 21:04:17 2001 From: rwklee at home.com (Rick Lee) Date: Thu, 25 Jan 2001 02:04:17 GMT Subject: Tkinter vs wxPython: your opinions? Message-ID: <3A6F899F.E164F628@home.com> It has to be cross platform between Linux and Windows, so it seems that my choices are Tkinter and wxPython. Your experience, thoughts, opinion, on the relative merits and pitfalls of each? My particular case: A GUI that has 5 windows max., will incorporate a xmlrpc client, will have a python object browser, being able to build data entry screens on the fly from a description of an object's attributes, programmer not familiar with either toolkit. Thanks in advance. - Rick Lee From dsh8290 at rit.edu Thu Jan 25 14:18:30 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 25 Jan 2001 14:18:30 -0500 Subject: python-2.1 function attributes In-Reply-To: <004001c086dd$f2d40710$f05aa8c0@lslp7o.int.lsl.co.uk>; from tony@lsl.co.uk on Thu, Jan 25, 2001 at 02:48:58PM +0000 References: <94ng4r$gin$1@animus.fel.iae.nl> <004001c086dd$f2d40710$f05aa8c0@lslp7o.int.lsl.co.uk> Message-ID: <20010125141830.B2678@harmony.cs.rit.edu> On Thu, Jan 25, 2001 at 02:48:58PM +0000, Tony J Ibbs (Tibs) wrote: | Decent syntax for this is obviously hard (else the Pythonlabs people and | their cohorts would already have gotten one). But... | Has anyone suggested a javadoc-like syntax before? ex: >>>def f() : """f() -> return value Other comments here @newattribute value_for_new_atribute """ >>>print f.__doc__ f() -> return value Other comments here >>>print f.__attributes__["newattribute"] value_for_new_attribute >>> As I tried to show above, the extra stuff would be removed from the __doc__ attribute, and instead placed into it's own proper attribute. I don't recall the new attributes' names and the exact way of accessing them off the top of my head right now, so I apologize since I probably got it wrong. Just a thought... -D From skip at mojam.com Sat Jan 6 15:47:23 2001 From: skip at mojam.com (Skip Montanaro) Date: Sat, 6 Jan 2001 14:47:23 -0600 (CST) Subject: Migrating to perl? In-Reply-To: <937qj001qms@news1.newsguy.com> References: <3Fa56.4580$of7.216286@news1.atl> <6Nk56.822$4Z.64804@news2.atl> <934nse02oal@news2.newsguy.com> <3A571F1E.2D25E978@python.net> <937qj001qms@news1.newsguy.com> Message-ID: <14935.33883.932341.423251@beluga.mojam.com> "Thomas A. Bryan" wrote: >> That's funny. Although there *is* more than one way to do this in >> Python, Python users don't seem to care for exercises in finding and >> displaying "neat tricks" in Python. Yeah we do. We generally disguise it as an exercise in speeding up someone else's code that runs too slow... ;-) -- Skip Montanaro (skip at mojam.com) Support the Mojam.com Affiliates Program: http://www.mojam.com/affl/ (847)971-7098 From andreas.voegele at gmx.de Wed Jan 24 18:08:32 2001 From: andreas.voegele at gmx.de (Andreas Voegele) Date: 25 Jan 2001 00:08:32 +0100 Subject: windows, python, gtk References: <94nd0r$o0v$1@nnrp1.deja.com> Message-ID: <87bsswtuof.fsf@columbus.voegele.local> > I'm looking for the gtk toolkit for windows to use with python 2.0 for > windows, and am having trouble finding it. Any ideas? Look at http://www.hans.breuer.org/ports/ and subscribe to the pygtk mailing list at http://www.daa.com.au/mailman/listinfo/pygtk. From jpl at global.co.za Tue Jan 23 18:33:38 2001 From: jpl at global.co.za (James Lockley) Date: Wed, 24 Jan 2001 01:33:38 +0200 Subject: Using python to call .bat files Message-ID: <94l44i$10km$1@news.adamastor.ac.za> > "James" schrieb im Newsbeitrag > > am hoping to use a python script to control a process that at the moment > > is run by a set of 10 windows batch files. > import os > return_code = os.system ('c:\\your\\batch\\file.bat') > > If you need to get the output of any of these programs take a look at > os.popen (filename) i've been trying os.popen, but it doesn't wait for the set of processes controlled by the batch file to finish before starting the next each batch relies on the results from the previous one, so i need the one to complete before the next starts... thanks in advance james (using python2.0 on winnt4) this is my best attempt so far... # calls batch files # each bat echoes 'JOB COMPLETE' on finishing; trying to use this as cue # to start next import os,string,sys extcalls=['pyform1.bat','pyreaction.bat'] workpath='D:\\work\\new\\' for call in extcalls: path=os.path.join(workpath,call) list=os.popen(path).readlines() for line in list: if string.find(line,'COMPLETE')>-1: print line continue print path From torkil at fast.no Mon Jan 8 08:39:37 2001 From: torkil at fast.no (Torkil Grindstein) Date: Mon, 08 Jan 2001 14:39:37 +0100 Subject: How to set up an XML-RPC server (newbie) References: <3A59B00B.4CB407D3@fast.no> Message-ID: <3A59C319.E878838C@fast.no> > for simplicity you should try F Lundh/Pythonware's > http://www.pythonware.com/downloads/xmlrpc-0.9.8-990621.zip Thank you for the quick answer. But still I wonder... The zip-package contains three .py-files. I've been trying to run them in different orders, but I get a series of error messages anyways. (And yes, I've outcommented the betty-server line, and uncommented the localhost-server line.) Here is an example. First, I run xmlrpcserver.py, then xmlrpclib.py: This yields : import: Unable to grab the mouse. import: Unable to read X window image (). import: Missing an image file name. import: Unable to grab the mouse. import: Unable to read X window image (). import: Missing an image file name. import: Unable to grab the mouse. import: Unable to read X window image (). import: Missing an image file name. import: Unable to grab the mouse. import: Unable to read X window image (). import: Missing an image file name. import: Unable to grab the mouse. import: Unable to read X window image (). import: Missing an image file name. ./xmlrpc_handler.py: class: command not found ./xmlrpc_handler.py: line 16: syntax error near unexpected token `(s' ./xmlrpc_handler.py: line 16: ` def match (self, request):' Am I stupid? -- Torkil Grindstein Mail: Torkil.Grindstein at fast.no System Architect Web: http://www.fast.no Fast Search & Transfer ASA Phone: +47 21 60 11 90 Gr?nnegata 80, Pb 571 Fax: +47 77 69 66 89 NO-9261 Troms?, NORWAY Mob: +47 98 06 61 38 Try FAST Search: http://www.alltheweb.com From dsh8290 at rit.edu Thu Jan 11 00:25:50 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 11 Jan 2001 00:25:50 -0500 Subject: HTML embeded with python In-Reply-To: ; from derek@realware.com.au on Thu, Jan 11, 2001 at 12:53:22PM +1000 References: Message-ID: <20010111002550.D15770@dman.rh.rit.edu> This is a very popular subject lately, check the archives to see how many threads there have been over the last couple of days. Try Poor Man's Zope (http://pmz.sourceforge.net) or PyHTML (check the announce list archives, posted by Jeff Epler). Another choice is PSP [Python Server Pages] which is on sourceforge (maybe http://psp.sourceforge.net). PSP has the limitation that the "psp" pages must reside in the Document Root (ie /var/www , not ~*/public_html). I like the PyHTML syntax the best, it's the most Pythonic too. I will install it sometime. -D On Thu, Jan 11, 2001 at 12:53:22PM +1000, Derek Lavine wrote: | Hi all, | | I am very new to python, in fact I have only just picked up my first | book. I am thinking of using python for web apps and was just wondering | if there are any modules out there that make it possible to embed python | in the HTML pages so that one can easily build web pages based on the | result of database queries and things like that. | | I have used coldFusion quite a bit and it of course makes this sort of | thing very easy. I know there are solutions of this type in perl but | since I am keen to use python in this context (initially as a means to | get acquainted with the language) I thought I would ask them that are in | the know. | | Thanks for any pointers or suggestions | | Derek | -- | http://www.python.org/mailman/listinfo/python-list From malik.thomas at lbbw.de Fri Jan 19 09:34:40 2001 From: malik.thomas at lbbw.de (Thomas Malik) Date: Fri, 19 Jan 2001 15:34:40 +0100 Subject: who imported me? References: <947jh5$puv$1@nnrp1.deja.com> Message-ID: <3A685080.AE881AC6@lbbw.de> sragsdale at my-deja.com wrote: > > (Hopefully) easy question: I'm writing a module that uses values in > variables from the script that imported it. > > How can I tell which script is importing me? > you can't, since the code in module's global level is executed only once ( during the initial import) and nothing is passed into an imported module by default. > Is there some easier way to get the parent module's variable values? > use execfile instead, here you can pass any dictionary ( including globals() ) as global scope for the execution of the code inside the file (by saying 'scope' i mean the set of variable bindings, don't know a better word for that). So you may, inside the file, access variables from the current (calling) module. If you need some module to come out of the whole process, you can import an empty dummy module, copy all global variables from the current module into the dummy module, and pass dummy.__dict__ as global scope to execfile, like this: testmod.py: # 'almost-module' to be 'imported' as dummy, needs to know importing module's scope print 'testmod: i was called by', __name__ print 'testmod: just_for_fun =', just_for_fun print 'testmod: calling test():\n', test() # set some variable new_var = 1 dummy.py: # everything inside testmod.py shall show up inside this module, as if the code in testmod.py # had been defined here. just_for_fun = 0 print 'dummy: __name__ =', __name__ main.py: import dummy # function to be visible inside 'testmod' def test(): print 'test(), __name__ =', __name__ print 'test: dummy.just_for_fun =', dummy.just_for_fun return 'test result' # copy main.py's scope into dummy's scope dummy.__dict__.update(globals()) # exec testmod.py and put all assignments/defs into dummy's scope execfile("testmod.py", dummy.__dict__) # actually set in testmod print 'dummy.new_var =', dummy.new_var print 'dummy.__name__ =', dummy.__name__ # Note that __name__ will be wrongly set in dummy from main.py's __name__ # (you may decide to reset it after the execfile) dummy.__name__ = 'dummy' print dummy.test() # is main.py's test, actually, __name__ will still print as '__main__' in test() call # has gone into dummy, not here: NameError print 'just_for_fun =', just_for_fun Thomas From b012414 at mail.dvz.fh-koeln.de Thu Jan 18 06:47:58 2001 From: b012414 at mail.dvz.fh-koeln.de (Stephan Effelsberg) Date: Thu, 18 Jan 2001 12:47:58 +0100 Subject: mod_python/'import site' failed References: <944pf1$8d3$1@news.gu.se> Message-ID: <3A66D7EE.795D5F45@mail.dvz.fh-koeln.de> Martin Sandin schrieb: > Hello! > > I'm trying to get mod_python up running and have run into the same problem > on both Win98 systems I've attempted this feat on. This after following the > instruction provided to the best of my abilities. Apache starts giving the > following message: > > 'import site' failed; use -v for traceback > Apache/1.3.12 (Win32) mod_python/2.6.3 Python/2.0 running... > 'import site' failed; use -v for traceback > > and then returning "internal server error" on the URLs pointing to Python > files. Now, I'd be asking this on the mod_python mailing list if it wasn't > for the fact that I've tracked dow that error message as something that > Python emitts. Thus given I'll ask this: > > What does that error message mean? What has gone wrong? How can I fix it in > general? And if anyone knows, how can it be fixed in this particular case? > Apart from 'ordinary' modules, site.py is a very special module for handling OS-specific imports of 3rd party modules (e.g. look if you have *.pth files in your Python directory, they are read by this module) and adjusting sys.path, it is imported automatically during startup. A failed import of this module also causes this special error message, not the usual ImportError. It seems that you either don't have the file site.py (or site.pyc) or Python is not able to locate it. A failed import of 'site' is no reason for Python to quit, you're simply not able to locate some specific modules. That's the reason why Apache tells you that Python is running, because it is really doing so. Conclusion: either Python is not installed correctly or Apache is able to modify the way Python works (but don't ask me how in particular, I'm not an Apache expert). From shredwheat at mediaone.net Wed Jan 24 12:24:48 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Wed, 24 Jan 2001 17:24:48 GMT Subject: Python vs Ruby References: <94mdkd$222e$1@news.adamastor.ac.za> Message-ID: "James Lockley" wrote > Just been reading a "Ruby centric" comparison of Ruby vs Python on: > http://helium.ruby-lang.org/en/compar.html > > would be interested to hear the Pythonista view.... what's interesting after looking over the 'bullet points' is that most of them are the same points i would make to say why i prefer python over ruby. heh really, i don't know too much about ruby. i was looking at both languages at the same time, and after a little fence strattling, jumped over into the python yard. been happy enough to not peek back over the fence either. From coral945 at aol.com Sat Jan 6 16:50:01 2001 From: coral945 at aol.com (coral945 at aol.com) Date: Sat, 06 Jan 2001 21:50:01 GMT Subject: GET PAID $$$ FOR BEING ONLINE! 9662 Message-ID: GO TO http://buzyperson01.homestead.com/main.html FOR ALL THE INFO!!!!!!!!!!!!!!! kuwnfxebxfidlverxbryvlpctudzbfqobcgbhbxnehmdswiwtxtgccjrhhuqevqnjtrjdzkclnnuifd From fredrik at effbot.org Thu Jan 4 06:07:21 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 04 Jan 2001 11:07:21 GMT Subject: regular expressions: grabbing variables from multiple matches References: Message-ID: Heather Lynn White wrote: > Suppose I have a regular expression to grab all variations on a meta tag, > and I will want to extract from any matches the name and content values > for this tag. > > I use the following re alex has already explained how to use the optional "pos" argument to search forward from the last match. but supposing you really are out to extract meta tags from an HTML document, it might be a better idea to use the HTML/SGML parser in sgmllib: # extract meta tags from a HTML document # (based on sgmllib-example-1 in the effbot guide) import sgmllib class ExtractMeta(sgmllib.SGMLParser): def __init__(self, verbose=0): sgmllib.SGMLParser.__init__(self, verbose) self.meta = [] def do_meta(self, attrs): name = content = None for k, v in attrs: if k == "name": name = v if k == "content": content = v if name and content: self.meta.append((name, content)) def end_title(self): # ignore meta tags after . you # can comment away this method if you # want to parse the entire file raise EOFError def getmeta(file): # extract meta tags from an HTML/SGML stream p = ExtractMeta() try: p.feed(file.read()) p.close() except EOFError: pass return p.meta # # try it out import urllib print getmeta(urllib.urlopen("http://www.python.org")) Hope this helps! Cheers /F From ngps at madcap.dyndns.org Sat Jan 13 10:27:20 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 13 Jan 2001 15:27:20 GMT Subject: Using Python SSL References: <93nt06$4eu$1@nnrp1.deja.com> <3A5F8255.55F71A1D@stroeder.com> <93o4v4$bic$1@nnrp1.deja.com> Message-ID: <93ps4o$dbt$1@violet.singnet.com.sg> According to Gavin Cooper : > This leads me to think that there might not be a way to use Python's SSL > like this to code an SSL _server_. I'll have to browse the socket module The last time I looked Python 2.0's built-in SSL doesn't do servers. Somebody posted patches to c.l.py to do that, but I can't seem to find a copy nor a pointer on my disk. M2Crypto does SSL clients and servers and works with both Python 1.5.2 and Python 2.0. For server examples, the package comes with the canonical "echo" server done the following ways: - iterative - forking - threading, 2 flavours - asynchronous socket i/o Get it here: http://www.post1.com/home/ngps/m2 Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From paulp at ActiveState.com Fri Jan 19 20:21:52 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 19 Jan 2001 17:21:52 -0800 Subject: Evaluting a python code in a string References: Message-ID: <3A68E830.8E1CB605@ActiveState.com> Steve Tuckner wrote: > > In Perl you can evaluation perl code that is embedded in a string by using > the Eval function. For example the following code: > > $i = "hello" > eval "print $i"; > > will print "hello" to the terminal. > > How can a person do a similar function in Python? Others have described how to do this but I want to make the point that it is often a feature that people use when they should not. It is inefficient and also a potential security hole. Often people use it to just convert types or delay executiion of some code. I don't know anything about you so you may be an expert and know exactly what you are doing but just in case not, I thought I'd give a warning. Paul Prescod From huwdotlynes at ic.ac.uk Fri Jan 26 10:51:03 2001 From: huwdotlynes at ic.ac.uk (Huw Lynes) Date: 26 Jan 2001 15:51:03 GMT Subject: Python and postgreSQL ?? References: Message-ID: Has anyone mentioned PyGresql? That's the interface I usually use and it seems fairly straightforward. Bit of a sod to compile though. To reply you know what "dot" should really be. From aleaxit at yahoo.com Wed Jan 31 03:00:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 31 Jan 2001 09:00:46 +0100 Subject: Python 2.1 and Unicode References: Message-ID: <958gnc0ksj@news2.newsguy.com> "Dale Strickland-Clark" wrote in message news:hpse7tc1h31hosvt4ojeu419c531mm76ij at 4ax.com... [snip] > We need two important features: > > 1. A print command that defaults to ignoring Unicode conversion errors - or at least > has the option to do so. Having print be a _little_ bit flexible in how it stringifies its arguments would be a big plus for us addicts of q&d-print-based debugging, no argument about that. Other 'stringifications', such as the one performed by %-formatting (with a %s format code) etc, may have similar issues. > 2. A function, such as str() that converts *anything* to an ASCII string - > ignoring Unicode errors. You may put something like this in your site-configuration script[s]: import __builtin__ def astr(x,str=__builtin__.str): try: return str(x) except UnicodeError: return x.encode('latin1','ignore') __builtin__.str = astr to replace the built-in str with a "more forgiving" one to your taste. This won't help with other implicit stringifications, though -- for those, setting the default encoding (again in your site configuration) may be best, but I don't think that, this way, you can specify 'ignore' rather than 'strict' as the default. Alex From peter at engcorp.com Sun Jan 14 23:59:31 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 14 Jan 2001 23:59:31 -0500 Subject: PHP vs Python References: Message-ID: <3A6283B3.76D07875@engcorp.com> TC wrote: > > Hi Hi! > I did a quick search for deja python +php +review > not even 1 relevent hit ...so > any takers points of interest > > 0- how long is a peice of string ? ;) Seven. > 1-which one is going to be around longer, why ?? The piece of string? No, wait, I see. The answer is Python. No argument is possible. (Two possible reasons, one being that Python was here first...) > 2-who has more users Don't know. Suspect it's Python, that one being rather broader in scope ("rather" means "massively" in my world). > 3-who hits the wall in scaling up and or handing complexity PHP. > 4-general performance Python is better for "general" performance, given that PHP is not designed for "general" use. > 5-where would I be better off using PHP over Python An environment already using PHP. Or an environment where Python is not available. Or if you know only PHP. Only sure about the first two... > 6-DB interfaces consistent > -seems python has a standad API PHP appears > all over the map depending on DB Probably true. Since you don't specify even in the slightest your intended use for either of these languages, it must be inferred. Unfortunately, there are conflicting hints. The mere fact you are looking at PHP suggests you are focused on web development. On the other hand, you do mention "general performance", implying perhaps that you have more than a narrow application area in mind. Give us more info and the answers might be useful. I doubt mine is. :) There is a chance, if you have a very narrow focus on server-side web scripting in mind, that PHP might be more suitable for you. If that is not your sole focus, don't waste your time. From derek at realware.com.au Wed Jan 10 21:53:22 2001 From: derek at realware.com.au (Derek Lavine) Date: Thu, 11 Jan 2001 12:53:22 +1000 Subject: HTML embeded with python Message-ID: Hi all, I am very new to python, in fact I have only just picked up my first book. I am thinking of using python for web apps and was just wondering if there are any modules out there that make it possible to embed python in the HTML pages so that one can easily build web pages based on the result of database queries and things like that. I have used coldFusion quite a bit and it of course makes this sort of thing very easy. I know there are solutions of this type in perl but since I am keen to use python in this context (initially as a means to get acquainted with the language) I thought I would ask them that are in the know. Thanks for any pointers or suggestions Derek From embed at geocities.com Wed Jan 24 09:02:25 2001 From: embed at geocities.com (Warren Postma) Date: Wed, 24 Jan 2001 09:02:25 -0500 Subject: Python as a Beverage References: <94mdkd$222e$1@news.adamastor.ac.za> Message-ID: "James Lockley" wrote: > Just been reading a "Ruby centric" comparison of Ruby >vs Python on: http://helium.ruby-lang.org/en/compar.html My 2 cents: This has been done to death, and since it is categorically impossible to put objectively, I think poetic license is called for. I felt that in Ruby there was too much of the "Perl" way of doing things: Odd punctuation, odd little operators and naming, and what felt to me like unintuitive syntax and conventions. The core Python syntax and coding patterns were "compact" and I absorbed them very easily. [ Except for the much-over-discussed existence of both Tuples and Lists, which later made sense, and the meanings of "lambda" and "map", which now seem to fit, but which originally I did not understand. ] Nevertheless, I could write anything I wanted pretty much right away in Python, without the "Borrowed from functional languages" stuff. With that in mind, I would put it this way: Python = Jolt Cola (All the Sugar, and Twice the Caffeine. Watch out for the side effects.) Ruby = Pepsi Cola (Much Better than New Coke, but not a replacement for Old Coke or Jolt, for me) Perl = Liquid Invert Sugar and Caffeine in an intravenous drip bag (Let's not beat around the bush anymore, let's just go and do some damage.) C = Classic Coke (Still can't live without it. Python, for instance, is written in C.) C++ and Java = New Coke (Can definitely live without it, but other people swear by it) Smalltalk = Tonic Water with a slice of Lemon (I'm not quite ascetic enough to appreciate it, but I appreciate people who appreciate it.) Lisp or Functional Languages = Hot Water (Some people can drink hot water with nothing in it. I don't understand it. Neither do I understand Lisp or Functional programmers.) Analogys-R-Us-ly-y'rs- Warren From rturpin at my-deja.com Fri Jan 5 14:53:32 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Fri, 05 Jan 2001 19:53:32 GMT Subject: How robust is Python ? References: <9354f9$vbi$1@nnrp1.deja.com>, Message-ID: <9358nn$3c5$1@nnrp1.deja.com> In article , Moshe Zadka wrote: > You might have misunderstood my English. X is just as T > as Y means T(x) >= T(y). .. Your English is just fine. Since I don't know T(y), that tells me little about T(x)! > .. However, personally I wouldn't trust *any* language > for that. Have a every-minute cron which resurrects > it if it isn't up? .. Unfortunately, cron is not cross-platform. We'll have some sort of mechanism to do this. The problem is not just the language and operating system, but everything that can kill a process. Still .. you want such mechanism as backup, not as a solution to regular crashes. Russell Sent via Deja.com http://www.deja.com/ From bbhaydon at my-deja.com Fri Jan 19 02:49:54 2001 From: bbhaydon at my-deja.com (bbhaydon at my-deja.com) Date: Fri, 19 Jan 2001 07:49:54 GMT Subject: Beginning with threads Message-ID: <948rj1$rhu$1@nnrp1.deja.com> I am just starting with threads and am trying to grasp what should and shouldn't be done... I have a class that uses threads in one of its functions. Should I make it inherit from threading?? for instance my code goes like: import threading class someclass: def somefunc(self): t = threading.Thread(target="self.someotherfunc", args = "args") t.start() def someotherfunc(self,args): do stuff It's legal but.. regards, Brett Sent via Deja.com http://www.deja.com/ From grante at visi.com Mon Jan 22 10:56:43 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 22 Jan 2001 15:56:43 GMT Subject: PSU uses emacs? References: <94cktu$d9c$1@news.wrc.xerox.com> Message-ID: <%KYa6.1423$eI2.487638@ruti.visi.com> In article <94cktu$d9c$1 at news.wrc.xerox.com>, Mark Jackson wrote: >> This is speculation, based on the philosophical attitudes I have observed in >> the two groups concerned. 8^} Who designed DOS anyway, Gary Kildall wasn't >> it? > >That was CP/M, the 16-bit version of which was considered by IBM for >their PC but not chosen. MS-DOS was first licensed and then purchased >by Microsoft from Seattle Computer Products. It was written by Tim >Paterson; heavy CP/M influence is evident, but it was far from a >clone. See Paul Ceruzzi, /A History of Modern Computing/. Looked like a clone to me. Virtually identical FCB structure, BIOS entry point at 0x0005, same executable layout, etc. etc. -- Grant Edwards grante Yow! They don't hire at PERSONAL PINHEADS, visi.com Mr. Toad! From danielhill at brightok.net Mon Jan 22 04:44:25 2001 From: danielhill at brightok.net (Dead Dan) Date: Mon, 22 Jan 2001 03:44:25 -0600 Subject: What does Python do References: <94gmeu$4fc$1@sooner.brightok.net> Message-ID: <94gvv5$7mo$1@sooner.brightok.net> Dag, Thanks, Im just begining in programming and I have had a few suggestiond for Python. What do you think of it as a first lang, well other HTML. I guess that dont count Dan From fredrik at effbot.org Wed Jan 31 05:57:30 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 31 Jan 2001 10:57:30 GMT Subject: fork, exec and wait on WINDOWS? References: <3A774C91.40835F30@lbl.gov> Message-ID: Nigel W. Moriarty wrote: > I have an app that needs to run on UNIX and Windows. > I have the UNIX fork() and exec() setup but how doe > one do a similar thing in Windows? os.spawnv/spawnve. for more info, see "process management" in the library reference: http://www.python.org/doc/current/lib/os-process.html Cheers /F From jdries at mail.com Wed Jan 31 11:56:21 2001 From: jdries at mail.com (Jan Dries) Date: Wed, 31 Jan 2001 17:56:21 +0100 Subject: Dynamically Defined Functions in Classes? References: <3A7828AD.279C88AC@wildbrain.com> Message-ID: <3A7843B5.1C43811C@mail.com> Jim Meyer wrote: > I have an application in which I wish to treat the members of a > dictionary as attributes; that is, I want to use set-and-get functions > to access them. The {weird|clever|tricky|stupid} thing I want to do is > to dynamically define the access functions at the time that an instance > of the class is initialized. Here's a brief example > > defaultFoo = {'joe' : 'cool', 'frank' : 'lee', 'ron' : 'dell'} > > class Bar : > def __init__(self) : > self.Foo = defaultFoo > for key in self.Foo : > # Define function member key(self,value) which is equivalent > # to calling self.setOrGet(key,value), e.g def joe(value) : ... > > def setOrGet(self, attrName, value = None) : > if value == None : > return self.Foo[attrName] > else : > self.Foo[attrName] = value > return self.Foo[attrName] > > Any elegant way to go about this? Or smarter ways to deal with > attributes? Try this: defaultFoo = {'joe' : 'cool', 'frank' : 'lee', 'ron' : 'dell'} class Bar: def __init__(self): self.__foo = defaultFoo def __getattr__(self,name): try: return self.__foo[name] except: raise AttributeError def __setattr__(self,name,value): if name == "_Bar__foo": self.__dict__[name] = value else: try: self.__foo[name] = value except: raise AttributeError You can then write: x = Bar() print x.joe x.frank = "something" etc. Regards, Jan From bill at janssen.org Wed Jan 31 23:24:48 2001 From: bill at janssen.org (Bill Janssen) Date: Wed, 31 Jan 2001 20:24:48 PST Subject: Palm extensions for PIL available Message-ID: <01Jan31.202456pst."3448"@watson.parc.xerox.com> Fredrik, I've completed some work on extending PIL 1.1.1 to support raw Palm image quantization and output. You can find a gzipped tar file containing a patch and a new ImagePlugin at ftp://ftp.parc.xerox.com/transient/janssen/PILpalm.tgz. The README in that file explains how to apply the support to a vanilla PIL 1.1.1 source distribution. The most interesting thing to you, I think, is the extension of the quantize method, via a new keyword, to support quantizing the colors of an image to a specified palette. That palette is specified by passing an image containing the desired palette. There were a number of ways to add this functionality; this seemed to be the approach that involved the minimal change to PIL. If you'd like to discuss any philosophical or technical issues about how I've done this, I'd be happy to do so. I'd appreciate it if this got into the next release of PIL; of course your release schedule is your own. Regards, Bill From nospam at nospam.com Tue Jan 9 14:31:38 2001 From: nospam at nospam.com (Tom) Date: Tue, 09 Jan 2001 19:31:38 GMT Subject: How to run more than one instance of the Python interpreter in one process? References: Message-ID: I used that API with VC6 on Win2K and Python v1.6. It worked fine. I only created one 'sub-interpreter'. Tom. "Tim Peters" wrote in message news:mailman.978862627.7187.python-list at python.org... > [Syver Enstad] > > I am fiddling around with embedding Python in C/C++ and am trying > > to run one interpreter per thread. I've tried using the > > Py_NewInterpreter and Py_EndInterpreter for each thread but it > > doesn't seem to be enough because I trigger access violations in > > the interpreter so I am obviously missing a couple of things. Are > > there any examples on how to do these kinds of things other than > > the very sparse code in the demo folder of the source distribution. > > None that I've ever seen, or heard of. Py_{New,End}Interpreter appeared to > have been added during a brief bout of Tcl Envy, and neglected thereafter. > The natural place to talk about this is the Python Thread-SIG: > > http://www.python.org/sigs/thread-sig/ > > But, in the past, I was unable to get anyone there to admit they used this > API either. You should bring it up there, though; at least Guido may be > interested. Be sure to say which version of Python you're using and which > platform you're running on. > > there-are-no-access-violations-under-windows-ly y'rs - tim > > From sholden at holdenweb.com Fri Jan 5 08:20:24 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 5 Jan 2001 08:20:24 -0500 Subject: embedded python - cancel "while 1: pass" References: Message-ID: <1Uj56.3855$xT.141687@e420r-atl1.usenetserver.com> Tim Peters wrote in message news:mailman.978679506.4982.python-list at python.org... > [Warren Postma] > > Okay, I have a worse case than WHILE 1: PASS [...] > > ... > > In that case, I think I'm still stuck with the Three Finger > > Salute method (reboot). > > Since that's a Windowsism, I hope you know you can kill Python from the Task > Manager, instead of rebooting. Windows was carefully designed to let you > recover from anything . > Even itself! From pearu at cens.ioc.ee Sat Jan 13 03:06:19 2001 From: pearu at cens.ioc.ee (Pearu Peterson) Date: Sat, 13 Jan 2001 10:06:19 +0200 Subject: making a string copy of a list In-Reply-To: <3a5ff99b.3312857@news.earthlink.net> References: <3a5ff99b.3312857@news.earthlink.net> Message-ID: On Sat, 13 Jan 2001, Tyler Eaves wrote: > yourstring='' > for x in yourlist: > yourstring=yourstring+str(x)+',' > #Remove that last comma > yourstring=yourstring[:-1] `yourlist` should do the job: >>> `[2,3]` '[2, 3]' or (almost) equivalent to Tyler's suggestion: >>> `[2,3]`[1:-1] '2, 3' Pearu From tim.hochberg at ieee.org Thu Jan 11 21:06:54 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Fri, 12 Jan 2001 02:06:54 GMT Subject: boolean xor References: <93ace8$nmo$1@panix3.panix.com> <93i7ne$5dk$1@nnrp1.deja.com> <93i9ff$q4l$1@slb0.atl.mindspring.net> <93iuj9$jta$1@slb3.atl.mindspring.net> <93jls9$v12$1@slb3.atl.mindspring.net> <93kofr01bg2@news1.newsguy.com> <61t76.2471$6i.33339@e420r-atl2.usenetserver.com> Message-ID: <2Ft76.135896$15.28612550@news1.rdc1.az.home.com> "Steve Holden" wrote in message > "Alex Martelli" wrote in message > news:93kofr01bg2 at news1.newsguy.com... [SNIP] > > Bingo -- I *was* starting to think I should post about that. For least- > > astonishment purposes, I'd thus like the xor function to behave similarly: > > return either A or B if at all possible (it may not be, of course, if > > both A and B are true). E.g., > > > > def xor(A,B): > > if not A: return B > > if not B: return A > > > Bzzzt. You need a "return 1" at the end of that. Look: > > >>> def tf(x): > ... if x: return 1 > ... else: return 0 [SNIP] > Better check my fix works: not often I get a chance to correct the > martellibot! I suspect that head thwacking will soon commence > >>> def xor(A, B): > ... if A: return B > ... if B: return A > ... return 1 > ... > >>> for A, B in (["", ""], ["", 't'], ['t', ''], ['t', 't']): > ... print tf(A), tf(B), tf(xor(A, B)) > ... > 0 0 1 > 0 1 0 > 1 0 0 > 1 1 1 > > Yup, that appears to do it. Still, returning that "1" doesn't seem very > Pythonic. Can;t think of anything else to do, however, since not (either > argument) will give 1 anyway in that case. Uhm, unless I slipped into an alternate universe at some point since they were cramming this stuff into my brain, the truth table for xor is: A B A^B 0 0 0 0 1 1 1 0 1 1 1 0 The rest I leave as an excercise for the reader. -tim From fredrik at effbot.org Mon Jan 15 13:06:06 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 15 Jan 2001 18:06:06 GMT Subject: is this a known re 'bug/feature'? References: <4jG86.6277$Qb7.923474@newsb.telia.net> Message-ID: > (In the meantime, feel free to post this bug report to the > SF bug tracker). I posted it myself: http://sourceforge.net/bugs/?func=detailbug&bug_id=128899&group_id=5470 Cheers /F From dubal at my-deja.com Thu Jan 18 10:44:49 2001 From: dubal at my-deja.com (dubal at my-deja.com) Date: Thu, 18 Jan 2001 15:44:49 GMT Subject: curses, python20/152, RH70/62, postgresql problems Message-ID: <94731d$9j4$1@nnrp1.deja.com> Hello! We are trying to develop a business application for dumb terminals using python, curses and postgresql. First we tried to install the Beopen Py20 rpm on RedHat 7.0. It looks for some old libs and doesn't install. We then tried to compile Py20 source on RH7. It gives some LONG_BIT error and stops. We then renamed /usr/bin/gcc to gcc.nogo and renamed kgcc to gcc and tried to compile py20. Got same error. Has anyone found out a way to get py20 to work on rh7? We then read curses howto from python website and started developing using the RH7's stock python152. We found following problems: 1. Color cannot be used because the required vars are not available. 2. pads cannot be used as mentioned in howto. 3. getstr(x,y,len) does not allow the 3rd argument (length) Can anyone plese suggest any solutions to these? We then abandon rh7 and go to rh62 with beopen py20 rpm installed. getstr works fine. Color vars are available but we could not get the color to work. Latest (7.0.3) postgresql rpms are also installed on this machine. This includes postgresql-python rpm supplied by postgres site. When we try to connect to postgres from python, it produces following warning: Python C API version mismatch for module _pg: This python has API version 1009, modules _pg has version 1007 How to fix this? It seems to work after this warning. We checked the pygresql site. It says their next version will have py20 compatibility. Do you think it is ok to use _pg with the version mismatch? I read somewhare that curses do not have colors, ncurses do. I see that ncurses is preinstalled on rh. Does python have its own builtin curses or does it use the one from separately installed rpm? How to get the color to work? Thanks for reading and TIA for any replies. Dubal Sent via Deja.com http://www.deja.com/ From grante at visi.com Fri Jan 19 14:52:22 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 19 Jan 2001 19:52:22 GMT Subject: I will kill my Python References: <947r18$rdt$1@news.online.de> Message-ID: In article <947r18$rdt$1 at news.online.de>, Nils Hensel wrote: >If an exe is your single concern then perhaps you should better stick with >VB. As if running an exe file generated by VB doesn't require that a whole slew of DLLs and other cruft be installed. It's no different than Python. -- Grant Edwards grante Yow! It was a JOKE!! Get at it?? I was receiving visi.com messages from DAVID LETTERMAN!! YOW!! From erno-news at erno.iki.fi Wed Jan 24 20:31:59 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 25 Jan 2001 03:31:59 +0200 Subject: Python and postgreSQL ?? References: Message-ID: In article , isard at localhost.localdomain (Carles Sadurn? Anguita) writes: | I've search unsuccessfully a tutorial about "attack" postgreSQL with Python. | Can anybody help me? pygresql comes with a tutorial. it's in the "tutorial" directory. -- erno From sifu at isohypse.org Thu Jan 18 09:23:40 2001 From: sifu at isohypse.org (Siegmund Fuhringer) Date: Thu, 18 Jan 2001 15:23:40 +0100 Subject: emacs / autocompletion Message-ID: <20010118152340.A31004@isohypse.org> hi.. is there anywhere an emacs autocompletion mode available? i'm unable to find something like that. bye siegmund From sharmad at goatelecom.com Sat Jan 27 03:43:05 2001 From: sharmad at goatelecom.com (Sharmad Naik) Date: Sat, 27 Jan 2001 14:13:05 +0530 Subject: crypt and decrypt Message-ID: <005e01c0883d$2e354700$85a1d4d2@SharmadNaik> Can anyone tell me whether there is a crypting (security) function in python 1.52 . -------------- next part -------------- An HTML attachment was scrubbed... URL: From jbauer at rubic.com Wed Jan 24 11:29:18 2001 From: jbauer at rubic.com (Jeff Bauer) Date: Wed, 24 Jan 2001 10:29:18 -0600 Subject: ANN: timeoutsocket.py --> v1.12 works with Python 2.0 References: <980352751.234548674@news.flashcom.net> Message-ID: <3A6F02DE.B0C4A@rubic.com> The timeoutsocket.py module is very useful. Any chance it could be rolled into the standard python library? Jeff Bauer Rubicon Research From stepheb at comm.mot.com Fri Jan 26 16:26:52 2001 From: stepheb at comm.mot.com (Stephen Boulet) Date: Fri, 26 Jan 2001 15:26:52 -0600 Subject: c(++)python? Message-ID: <3A71EB9C.D258C1C0@comm.mot.com> This is just something I've wondered about, and not intended to be a troll. Why is the most popular implementation of python in C? A novice programmer (like myself) might think: "python is itself an object-oriented language, so it would make sense to implement it in another object-oriented language." Is this in fact the case, or was c++ not standardized/mature enough when python first came out? -- Stephen From lars at marowsky-bree.de Wed Jan 17 11:13:11 2001 From: lars at marowsky-bree.de (Lars Marowsky-Bree) Date: 17 Jan 2001 17:13:11 +0100 Subject: Relational Databases and Python References: <3A63D5DB.50B7DD0E@python.net> Message-ID: On Wed, 17 Jan 2001 09:01:22 +0100, Robert Sauer wrote: > Another opetion would be to go with SAP DB. It's freshly published as Open > SOurce. > > Have a look at http://www.sap.com/solutions/technology/sapdb/ Do you have any experience so far how well it works with Python and in general? From sholden at holdenweb.com Thu Jan 18 08:21:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 18 Jan 2001 08:21:47 -0500 Subject: This is my first program in Python References: <3a66a585.268350144@news.tcn.net> Message-ID: "Richard Zilavec" wrote in message news:3a66a585.268350144 at news.tcn.net... > > I've spent the last few weeks trying to find a good book on Python. > Seems that most stores don't carry a large selection, however I found > The Quick Python Book.. The material seems to flow in the right > direction and the fonts are easy on the eyes. > > Anyways, I wrote my first program but was stumped on readline(). I > could get the first line, but not the rest of the file. I tried > searching python.org and could not find an example.... well here it > is: > > import string > file = open("/tmp/globs", 'r') > for line in file.readlines(): > (first,second) = string.split(line,':',1) > print first > file.close() > Very Pythonic! The parentheses are unnecessaary in the assignment, but that's a nit. Also, in Python 2 you could replace string.split(line, ":", 1) with line.split(':', 1), and avoid the need to import the string module. But that's another nit. This is a good program. > This was my first attempt, which looks like it should work but failed: > invalid syntax. Is this not possible? > while line = file.readlines(): > The assignment has deliberately been designated a statement rather than an expression, The standard idiom for doing this with a while would be (untested): while 1: line = file.readline() if line == '': break first, second = line.split(':', 1) print first Some people don't like this. It's not going to change :-) > Am I using string.split properly? > Yes, but strings now have a split() method, so the first argument is implicit as I mentioned above. > I was quite happy with how easy this was to put together, I'm just not > sure if its totally correct. > > -- > Richard Zilavec > rzilavec at tcn.net > Totally. Well done! regards Steve From piet at cs.uu.nl Mon Jan 8 10:25:19 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 08 Jan 2001 16:25:19 +0100 Subject: Interbase/Python 2.0 (was Re: MySQL with Windows) References: <9349uh$h3i$1@news1.xs4all.nl> Message-ID: >>>>> boud at rempt.xs4all.nl (Boudewijn Rempt) (BR) writes: BR> Well, Andy links to http://home.t-online.de/home/err666/ from his This page also contains a link to a precompiled Interbase module for Python 2.0 on Windows. Unfortunately the link is no longer valid. Does anyone have/know a precompiled one for the above? -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From mikael at isy.liu.se Sat Jan 13 10:38:36 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Sat, 13 Jan 2001 16:38:36 +0100 (MET) Subject: newbie... In-Reply-To: Message-ID: On 13-Jan-01 Matt Frey wrote: > Where is a good place to learn python? I'll try to give you a more serious answer than the ones you've gotten so far. First, visit the Python home at www.python.org. Especially, take a look at the Python documentation that you can find there. And of course, the tutorial. Then, when you stumble over something you do not understand, return here. Good luck! /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 13-Jan-01 Time: 16:34:14 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From aleaxit at yahoo.com Thu Jan 4 17:24:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 23:24:13 +0100 Subject: How-to create a Pascal Record using Python References: <3a54c7cf.15612195@news.skynet.be> <3a54e0c0.21998314@news.skynet.be> Message-ID: <932t9t012hv@news1.newsguy.com> "Daniel" wrote in message news:3a54e0c0.21998314 at news.skynet.be... [snip] > Suppose I have something like > > TMyRecord = record > aName : string; > adate : TDateTime; > aZIP : integer; > end; //record > > var MyRecs : array [1..100] of TMyRecord; > f : file of TMyRecord; > > How is this handled in Python? Sorry for these questions, but I > really would like to learn about all of this. Such fixed-structures are rarely used in Python. When there is a need, the struct module may be employed. The 'p' format of struct is exactly the one used to encode a Pascal string (1-byte length, then up to 255 characters -- or, a different length if explicitly specified). 'integer', depending on whether you mean 2 or 4 bytes, is either format 'h' (for 'half') or 'i'. A 'TDateTime' is not an elementary type and thus has no direct struct format character. As you can see, these are rather low-level constructs from Python's viewpoint! They will be needed if one has to handle a file produced by some other program. Else, one would normally define a class to hold the data attributes, and use the pickle (or cPickle) module to save to disk and reload any number of such objects. Alex From loewis at informatik.hu-berlin.de Sat Jan 20 17:53:00 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Jan 2001 23:53:00 +0100 Subject: pyXML support for XSL tranformations?? References: Message-ID: "Scott Hathaway" writes: > Using the Microsoft tools, you can load an XML document, then load and XSL > or XSLT document into memory and then call nodeTransform to blend the two > together and then spit it back out. > > Is there a way to do this with pyXML or any other python xml library? Try 4Suite. It is a PyXML superset, that uses the PyXML parsers and implements the transformations on top of it. Regards, Martin From daniel at dittmar.net Sun Jan 28 08:20:32 2001 From: daniel at dittmar.net (Daniel Dittmar) Date: Sun, 28 Jan 2001 14:20:32 +0100 Subject: Pyditor, Text editor fully extendible in python a la' Emacs References: Message-ID: <3A741CA0.80EA83FA@dittmar.net> > ... lots of features requests for a python programmable programming editor ... I think vim (http:/www.vim.org/) has most of these. If only someone would write emacs like keybindings for vim. Daniel From aahz at panix.com Sat Jan 20 11:44:12 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Jan 2001 08:44:12 -0800 Subject: Tabbing/Spaces References: Message-ID: <94cf8s$dga$1@panix6.panix.com> In article , Quinn Dunkan wrote: >On 19 Jan 2001 16:17:13 -0800, Johann Hibschman >wrote: >> >>Shrug. Whatever suits you best, I guess. I just hate getting all-tab >>code, since then I have to re-indent it for it to be readable. >>All-space code, on the other hand, always looks fine. > >Unless you use proportional fonts. To expand on Alex's comment, proportional fonts are fine unless you've also got a setup that tries to do justification -- but that would be a problem with monospaced fonts, too. The width of a space in a non-justified proportional font is fixed. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I guess I mostly see Life [tm] as a process of closing doors that you might want to go through. --Aahz From jbauer at rubic.com Wed Jan 3 11:51:38 2001 From: jbauer at rubic.com (Jeff Bauer) Date: Wed, 03 Jan 2001 10:51:38 -0600 Subject: Sample script using MySQLdb ? References: <92vjfd$p63$1@reader1.imaginet.fr> Message-ID: <3A53589A.D27D9A89@rubic.com> Christophe Prevost wrote: > Somebody have a quite complete script using this module? Here's a cheezy little script I use for mysql dba stuff. You might find it useful to get you started. If the code isn't formatted correctly I can email it to you as an attachment. Hope that helps. Jeff Bauer Rubicon Research #!/usr/bin/env python # mysqldba.py """ MySQL database administration routines jbauer at rubic.com """ import os, sys, string from string import join from UserDict import UserDict import getopt from getpass import getpass import MySQLdb class DbTable(UserDict): """ DbTable is a dictionary of 'db' table rows. key = (Db, Host, User) tuple value = dictionary of row values """ def __init__(self, connection): self.connection = connection apply(UserDict.__init__, (self,)) self.name = 'db' self.fields = [ 'Db', 'Host', 'User', 'Select_priv', 'Insert_priv', 'Update_priv', 'Delete_priv', 'Index_priv', 'Alter_priv', 'Create_priv', 'Drop_priv', 'Grant_priv', ] self.populate() def create_database(self, db_name, **kw): assert(db_name != 'mysql') assert(db_name not in self.database_list) c = self.connection.cursor() qs = "CREATE DATABASE %s" % db_name c.execute(qs) values = [ \ db_name, kw.get('Host', '%'), kw.get('User', ''), kw.get('Select_priv', 'Y'), kw.get('Insert_priv', 'Y'), kw.get('Update_priv', 'Y'), kw.get('Delete_priv', 'Y'), kw.get('Index_priv', 'Y'), kw.get('Alter_priv', 'Y'), kw.get('Create_priv', 'Y'), kw.get('Drop_priv', 'N'), kw.get('Grant_priv', 'Y'), ] self.reload() qs = "INSERT INTO %s (%s) VALUES (%s)" % \ (self.name, join(self.fields, ', '), join(map(lambda x: "'%s'" % x, values), ', ')) c.execute(qs) self.reload() def databases(self): """ Return a sorted list of databases """ databases = {} for db, host, user in self.keys(): if db: databases[db] = None keys = databases.keys() keys.sort() return keys def drop_database(self, db_name): assert(db_name != 'mysql') c = self.connection.cursor() qs = "DROP DATABASE %s" % db_name c.execute(qs) qs = "DELETE FROM %s WHERE Db='%s'" % (self.name, db_name) c.execute(qs) self.reload() def populate(self): c = self.connection.cursor() qs = "SELECT %s FROM %s" % \ (join(self.fields, ', '), self.name) c.execute(qs) _db = {} for r in c.fetchall(): d = {} i = 0 for f in self.fields: d[f] = r[i] i = i + 1 self[(d['Db'], d['Host'], d['User'])] = d _db[d['Db']] = None self.database_list = _db.keys() self.database_list.sort() def reload(self): c = self.connection.cursor() c.execute("FLUSH PRIVILEGES") self.clear() self.populate() class UserTable(UserDict): """ UserTable is a dictionary of 'user' table rows. key = (Host, User) tuple value = dictionary of row values """ def __init__(self, connection): self.connection = connection apply(UserDict.__init__, (self,)) self.name = 'user' self.fields = [ 'Host', 'User', 'Password', 'Select_priv', 'Insert_priv', 'Update_priv', 'Delete_priv', 'Index_priv', 'Alter_priv', 'Create_priv', 'Drop_priv', 'Grant_priv', 'References_priv', 'Reload_priv', 'Shutdown_priv', 'Process_priv', 'File_priv', ] self.populate() def add_user(self, user, **kw): assert(user != 'root') if kw.has_key('Password'): password = "PASSWORD('%s')" % password else: password = "''" values = [ \ "'%s'" % kw.get('Host', '%'), "'%s'" % user, password, "'%s'" % kw.get('Select_priv', 'Y'), "'%s'" % kw.get('Insert_priv', 'Y'), "'%s'" % kw.get('Update_priv', 'Y'), "'%s'" % kw.get('Delete_priv', 'Y'), "'%s'" % kw.get('Index_priv', 'Y'), "'%s'" % kw.get('Alter_priv', 'N'), "'%s'" % kw.get('Create_priv', 'Y'), "'%s'" % kw.get('Drop_priv', 'Y'), "'%s'" % kw.get('Grant_priv', 'N'), "'%s'" % kw.get('References_priv', 'Y'), "'%s'" % kw.get('Reload_priv', 'Y'), "'%s'" % kw.get('Shutdown_priv', 'N'), "'%s'" % kw.get('Process_priv', 'N'), "'%s'" % kw.get('File_priv', 'N'), ] qs = "INSERT INTO %s (%s) VALUES (%s)" % \ (self.name, join(self.fields, ', '), join(values, ', ')) c = self.connection.cursor() c.execute(qs) self.reload() def del_user(self, user, host=''): if host: wc = "User='%s' AND Host='%s'" % (user, host) else: wc = "User='%s'" % user qs = "DELETE FROM %s WHERE %s" % (self.name, wc) c = self.connection.cursor() c.execute(qs) self.reload() def mod_password(self, user, password): c = self.connection.cursor() qs = "UPDATE %s SET Password=PASSWORD('%s') WHERE user='%s'" % \ (self.name, password, user) c.execute(qs) c.execute("FLUSH PRIVILEGES") def mod_user(self, user, **kw): f = [] v = [] if kw.has_key('Host'): host = kw['Host'] else: host = '' values = [] for k in kw.keys(): if k in self.fields: if k == 'User': assert(kw[k] == user) values.append("%s='%s'" % (k, kw[k])) if host: wc = "User='%s' AND Host='%s'" % (user, host) else: wc = "User='%s'" % user qs = "UPDATE %s SET %s WHERE %s" % \ (self.name, join(values, ', '), wc) c = self.connection.cursor() c.execute(qs) self.reload() def populate(self): c = self.connection.cursor() qs = "SELECT %s FROM %s" % \ (join(self.fields, ', '), self.name) c.execute(qs) _user = {} for r in c.fetchall(): d = {} i = 0 for f in self.fields: d[f] = r[i] i = i + 1 self[(d['Host'], d['User'])] = d if d['User']: _user[d['User']] = None self.user_list = _user.keys() self.user_list.sort() def reload(self): c = self.connection.cursor() c.execute("FLUSH PRIVILEGES") self.clear() self.populate() class HostTable(UserDict): """ HostTable is a dictionary of 'host' table rows. key = (Host, Db) tuple value = dictionary of row values """ def __init__(self, connection): self.connection = connection apply(UserDict.__init__, (self,)) self.name = 'host' self.fields = [ 'Host', 'Db', 'Select_priv', 'Insert_priv', 'Update_priv', 'Delete_priv', 'Index_priv', 'Alter_priv', 'Create_priv', 'Drop_priv', 'Grant_priv', ] self.populate() def add_host(self, host, **kw): values = [ \ host, kw.get('Db', ''), kw.get('Select_priv', 'Y'), kw.get('Insert_priv', 'Y'), kw.get('Update_priv', 'Y'), kw.get('Delete_priv', 'Y'), kw.get('Index_priv', 'Y'), kw.get('Alter_priv', 'Y'), kw.get('Create_priv', 'Y'), kw.get('Drop_priv', 'N'), kw.get('Grant_priv', 'N'), kw.get('References_priv', 'Y'), kw.get('Reload_priv', 'Y'), kw.get('Shutdown_priv', 'N'), kw.get('Process_priv', 'N'), kw.get('File_priv', 'N'), ] qs = "INSERT INTO %s (%s) VALUES (%s)" % \ (self.name, join(self.fields, ', '), join(map(lambda x: "'%s'" % x, values), ', ')) c = self.connection.cursor() c.execute(qs) self.reload() def del_host(self, host, db=''): assert(host != 'localhost') pass #XXX self.reload() def mod_host(self, host, **kw): pass #XXX self.reload() def mod_password(self, user, password): self.userTable.mod_password(user, password) def populate(self): c = self.connection.cursor() qs = "SELECT %s FROM %s" % \ (join(self.fields, ', '), self.name) c.execute(qs) _host = {} for r in c.fetchall(): d = {} i = 0 for f in self.fields: d[f] = r[i] i = i + 1 self[(d['Host'], d['Db'])] = d _host[d['Host']] = None self.host_list = _host.keys() self.host_list.sort() def reload(self): c = self.connection.cursor() c.execute("FLUSH PRIVILEGES") self.clear() self.populate() class Server: def __init__(self, **kw): self.connection = apply(MySQLdb.connect, (), kw) self.dbTable = DbTable(self.connection) self.hostTable = HostTable(self.connection) self.userTable = UserTable(self.connection) def add_host(self, host, **kw): apply(self.hostTable.add_host, (host,), kw) def add_user(self, user, **kw): apply(self.userTable.add_user, (user,), kw) def create_database(self, db_name, **kw): apply(self.dbTable.create_database, (db_name,), kw) def del_host(self, host, db=''): self.hostTable.del_host(host, db) def del_user(self, user, host=''): self.userTable.del_user(user, host) def drop_database(self, db_name): self.dbTable.drop_database(db_name) def __get_password(self, user): passwd1 = getpass("Enter MySQL user '%s' password: " % user) passwd2 = getpass("Re-enter password: ") if passwd1 == passwd2: return passwd1 else: return None def mod_host(self, host, **kw): apply(self.userTable.mod_host, (host,), kw) def mod_user(self, user, **kw): apply(self.userTable.mod_user, (user,), kw) def process(self, operation, args=[]): c = self.connection.cursor() if len(args) < 1 and \ operation not in ('dblist', 'hostlist', 'userlist'): print "error: argument[s] required for %s operation" % operation return if operation == 'addhost': print "operation: '%s' not yet implemented" % operation #XXX elif operation == 'adduser': self.add_user(args[0]) elif operation == 'dbcreate': self.create_database(args[0]) elif operation == 'dbdrop': assert(args[0] != 'mysql') self.drop_database(args[0]) elif operation == 'dblist': c.execute("SHOW DATABASES") db_list = map(lambda x: x[0], c.fetchall()) db_list.sort() for db_name in db_list: print db_name elif operation == 'hostlist': for host in self.hostTable.host_list: print host elif operation == 'moduser': print "operation: '%s' not yet implemented" % operation #XXX elif operation == 'passwd': if len(args) < 2: while 1: passwd = self.__get_password(args[0]) if passwd: break else: passwd = args[1] self.userTable.mod_password(args[0], passwd) elif operation == 'rmhost': print "operation: '%s' not yet implemented" % operation #XXX elif operation == 'rmuser': assert(args[0] != 'root') self.del_user(args[0]) elif operation == 'tblist': c.execute("SHOW TABLES FROM %s" % args[0]) table_list = map(lambda x: x[0], c.fetchall()) table_list.sort() for tb_name in table_list: print tb_name elif operation == 'userlist': for user in self.userTable.user_list: print user else: print "error: invalid operation: %s" % operation if __name__ == '__main__': user = 'root' host = 'localhost' passwd = '' usage = """ usage: %s [options] operation options: -u user default='%s' -h host name or IP address, default='%s' -p password operation: addhost [hostname] adduser [username] add user dbcreate [dbname] create a database with default privileges dbdrop [dbname] drop a database (BE VERY CAREFUL) dblist list databases hostlist list hosts moduser [username userpriv=X] modify user privileges (e.g. Grant_priv=Y) passwd [username [password]] change user password rmhost [hostname] remove host rmuser [username] remove user tblist [dbname] list database tables userlist list users """ % (os.path.basename(sys.argv[0]), user, host) optlist, args = getopt.getopt(sys.argv[1:], 'h:p:u:') if len(sys.argv) < 2: print usage; sys.exit(1) argv = [] for _arg in sys.argv[1:]: argv.append(_arg) for (opt, optarg) in optlist: if opt == '-u': user = optarg elif opt == '-h': host = optarg elif opt == '-p': passwd = optarg else: print "error: invalid option: %s" % opt print usage; sys.exit(1) argv.remove(opt) argv.remove(optarg) if len(argv) < 1: print usage sys.exit(1) if not passwd: passwd = getpass("Enter MySQL user '%s' password: " % user) server = Server(host=host, db='mysql', user=user, passwd=passwd) server.process(argv[0], argv[1:]) From strombrg at seki.acs.uci.edu Thu Jan 18 17:34:02 2001 From: strombrg at seki.acs.uci.edu (Dan Stromberg) Date: 18 Jan 2001 22:34:02 GMT Subject: 3d array? Message-ID: <947r0q$f6k$1@news.service.uci.edu> I love python, but is there really no good way of doing a 3d array of a scalar type? How about of an aggregate type? -- Dan Stromberg UCI/NACS/DCS From bwilk_97 at yahoo.com Thu Jan 25 07:30:27 2001 From: bwilk_97 at yahoo.com (Bill Wilkinson) Date: Thu, 25 Jan 2001 12:30:27 GMT Subject: beep again References: Message-ID: | [Mark Hammond, on the great non-beeping beep mystery] | > We learn something new every day :-) | > I just had a look at the MS documentation for this function [Win32 | > Beep()], and it states at the bottom: | > """ | > Remarks | > Windows 95: The Beep function ignores the dwFreq and dwDuration | > parameters. On computers with a sound card, the function plays the | > default sound event. On computers without a sound card, the function | > plays the standard system beep. | > """ | > | > Not much we can do about it that I can see, except possibly add a note | > to the docstring. On my Win2k box (With a sound card) I get the system beeps and not the wave files. From lele at seldati.it Tue Jan 9 06:46:39 2001 From: lele at seldati.it (Lele Gaifax) Date: 09 Jan 2001 12:46:39 +0100 Subject: Web devel with python. Whats the best route? In-Reply-To: Erno Kuusela's message of "09 Jan 2001 09:14:49 +0200" References: <93cqvi0191h@news1.newsguy.com> Message-ID: >>>>> On 09 Jan 2001 09:14:49 +0200, Erno Kuusela said: EK> In article <93cqvi0191h at news1.newsguy.com>, "Alex Martelli" EK> writes: EK> | "Session continuity" will have to be provided via cookies, EK> but that's | not really all that hard EK> note that mod_python and mod_snake are in the same boat EK> (modulo libraries they may or may not provide?) because they EK> also run with multiple processes. Yes, there is no way out: the Apache server itself is actually composed by N child daemons. But while Apache alone consumes one process for every request, with mod_* you have N "long running" interpreters that handle them. EK> lately i've come to the conclusion that the best way to do EK> session tracking (certainly better than cookies) is to EK> generate a unique id and put it in the url as a path EK> component. something like EK> http://my.site/my-program/0dj2/operation or whatever. you can EK> use map the unique to (sequence of?) words from EK> id/usr/dict/words if you want to make the url EK> human-rememberable :) As said, I think most mod_* out there do help here: while with standard CGI you have to "open" a connection with whatever contains the session database (in your example, the data associated with session "0dj2") *at every request*, generally with the extmods you can have *only one* per daemon. The same is true for module import. So, to answer the original question: there isn't necessarily just /one/ "best" route, as usual... it depends on what you are doing. They all provide facilities not available in standard C. If you already have CGIs written in Python, then maybe PyApache can help on the speed front; if you are starting from scratch, maybe the "higher" POV provided by mod_[python,snake] would fit better. bye, lele. -- nickname: Lele Gaifax | Quando vivro' di quello che ho pensato ieri real: Emanuele Gaifas | comincero' ad aver paura di chi mi copia. email: lele at seldati.it | -- Fortunato Depero, 1929. From bowman at montana.com Tue Jan 23 09:17:24 2001 From: bowman at montana.com (bowman) Date: Tue, 23 Jan 2001 07:17:24 -0700 Subject: beep References: <11941-3A6D0F37-61@storefull-166.iap.bryant.webtv.net> Message-ID: Pete Shinners wrote in message news:gi9b6.91087$y9.17567648 at typhoon.we.rr.com... > > does a pretty good job on windows and unix. > although on windows this plays the system default beep wav, > it does not send noise to the speaker/buzzer This was a recent thread on comp.lang.forth. On Windows, a sound card, if installed and selected as the sound output device, will supercede the speaker. From warlock at eskimo.com Sat Jan 13 01:53:04 2001 From: warlock at eskimo.com (Jim Richardson) Date: Fri, 12 Jan 2001 22:53:04 -0800 Subject: making a string copy of a list Message-ID: OK, I swear I've looked for this, but how do I make a copy of a list, into a string, complete with commas seperating the entries in the list? -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From robin at jessikat.fsnet.co.uk Tue Jan 9 10:59:07 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 9 Jan 2001 15:59:07 +0000 Subject: mxTools (was Re: why no "do : until"?) References: <937rqs01sal@news1.newsguy.com> Message-ID: In article , Oleg Broytmann writes >On Sat, 6 Jan 2001, Alex Martelli wrote: >> ...which reminds me: why no PEPs about adding to Python's core some >> of the nicest ideas in Lemburg's neat mxTools...? I assume there must >> be a reason (e.g., Guido must already have seen them all and decided >> they don't belong in the core, or something), but I'd like to know... > > Anyone here has any doubts that at least mxDateTime simply MUST be in >the Python core? :) > I'm a minimalist; let 100 flowers bloom, but the core should really only include the minimal required. Fancy dates are a bit too far for me. I like them, but would prefer such exotica to stay outside the main distribution. Same goes for a lot of other stuff eg idle tkinter etc etc. I reckon a lot of the desire for core growth would reduce if there were a CPAN like scheme for Python. -- Robin Becker From charlottwilliams at mediaone.net Sat Jan 6 19:21:59 2001 From: charlottwilliams at mediaone.net (Charlotte Williams) Date: Sun, 07 Jan 2001 00:21:59 GMT Subject: Should I learn Python or Java? Message-ID: Hello, I am a Visual Basic programmer who wants to increase his knowledge of programming languages. Now that the curses, boos, and barrage of rotten fruit are out of the way, I would like to ask this group a few questions :-) ... I notice that there is a lot of demand for Java programmers. The only experience I have with an OO language is Smalltalk. My questions are: 1. Which language would be best to learn, Java or Python. From a VB standpoint, which has the least learning curve? 2. Is going from object-based to object-oriented programming that huge a jump? I want to learn an OO language, however I plan on utilizing it in my career. 3. Which one is the most "fun" to program in? 4. Is Python multi-platform? How is it's performance compared to JAVA in an internet situation? It's reliability? 5. Do you for see Python as becoming a major player like Java servlets and MTS? Can you see Python demand outstripping Java demand in 2 years time? Many of these questions are in response to a post I saw earlier where Python was being touted as the next evolution of OO programming. It went something like... C --> C++ --> Java --> Python. I'm really interested in hearing from VB programmers that decided to jump into one or both of the languages, has pretty good knowledge (enough to get a Java or Python job) and the headaches and experiences they had learning about them. Do you need a formal CS education to grasp them? I tried finding information on these two, but the experiences I always found were C or C++ programmers that tried to tackle them. Some sites actually belittled me as a VB programmer. Since I have heard such good things about this groups hospitality, I thought I would ask here first. Thanks. David Williams From john at coastalgeology.org Mon Jan 22 20:54:36 2001 From: john at coastalgeology.org (Jonathan Pennington) Date: Mon, 22 Jan 2001 20:54:36 -0500 Subject: XML doc generation Message-ID: <20010122205436.A29328@coastalgeology.org> I need some XML help. Here's a snippet from the XML How-To: You can also construct a DOM tree yourself, and convert it to XML; this is often a more flexible way of producing XML output than simply writing ... to a file. Unfortunately, I can't find an example of this. Does anyone have some code(script?) I can read that does this so I can learn? Much of what I see in docs/archives is parsing of an XML document. I, however, have long strings of coordinate data and info that I currently parse into a large nested dictionary. I'd like to be able to convert this into an XML format instead of or in addition to a dictionary. Thanks, -J ---- problem example for the more curious ---- I have a string returned as this just to ease splitting of multiple data types (ie. some have more or less info than this): "name:V:WAYPNT:R:comment:V:Test Waypoint data:R:latitude:V:-345689284304 \ :R:longitude:V:948502987435:R:proximity:V:83:R:symbol:V:8345:R:display:V:0" I don't have a DTD finished yet, but would like something like this, I just don't want to manually add the tags all the time (ie. I'll generate them based on the dictionary's "has key" membership): .... Also mineral, lithologic, etc. Also route, track, group, etc. Unique identifier for each WAYPNT Test Waypoint Data -0893274924,0928093840 83 8345 0 -- Jonathan Pennington | http://coastalgeology.org Site Manager | Protection and stewardship CoastalGeology.Org (CGO) | through public education. john at coastalgeology.org | Join CGO, make a difference. From moshez at zadka.site.co.il Mon Jan 22 15:57:34 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: 22 Jan 2001 14:57:34 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jan 22) Message-ID: <7D67E5DAC2099D1E.21F58565B42EB06D.325C52AE90704C1A@lp.airnews.net> Finn Bock announces Jython 2.0 http://x52.deja.com/getdoc.xp?AN=717592194 Sean True announces a tool to migrate from ADO to MySQL http://x58.deja.com/getdoc.xp?AN=718389620 Looking for Tkinter examples and documentation? Will Ware gives pointers http://x76.deja.com/getdoc.xp?AN=716724181 John Grayson points to his website http://x76.deja.com/getdoc.xp?AN=716828996 Greg Landrum points to John's book http://x58.deja.com/threadmsg_ct.xp?AN=716831469.1 Tony J Ibbs gives an overview of Python documentation tools http://x51.deja.com/getdoc.xp?AN=717805913 Fredrik Lundh reminds comp.lang.python about the Pythonware distribution http://x75.deja.com/threadmsg_ct.xp?AN=718127303.1 overviews ways to implement application scripting in Python http://x70.deja.com/getdoc.xp?AN=716862726 announces fifth preview of Tkinter 3k http://x57.deja.com/getdoc.xp?AN=717037092 Alex Martelli suggests a way to implement a visual OCX control http://x56.deja.com/getdoc.xp?AN=716590141 gives an overview of function introspection http://x72.deja.com/getdoc.xp?AN=717864576 shows how to search google with Python http://x60.deja.com/getdoc.xp?AN=716428657 David Beazly publishes a CFP for O'Reilly Open Source Conference http://x51.deja.com/getdoc.xp?AN=717807742 Tim Peters explains why freezing is not always the right thing http://x67.deja.com/getdoc.xp?AN=718124783 Thomas Heller announces py2exe http://x64.deja.com/getdoc.xp?AN=717858751 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://deja.com/group/comp.lang.python.announce Andrew Kuchling writes marvelous summaries twice a month of the action on the python-dev mailing list, where the future of Python is truly determined http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From danielk at aracnet.com Thu Jan 11 10:14:25 2001 From: danielk at aracnet.com (Daniel Klein) Date: Thu, 11 Jan 2001 07:14:25 -0800 Subject: Defining a new exception with multiple args Message-ID: Using the Beazley book as a guide, I have defined a new exception as: class RecordNotFoundException(Exception): def __init__(self, filename, recordid): self.filename = filename self.recordid = recordid However, this is what happens when I raise this exception: >>> raise RecordNotFoundException("myfile", "myid") Traceback (innermost last): File "", line 1, in ? raise RecordNotFoundException("myfile", "myid") RecordNotFoundException: >>> raise RecordNotFoundException, ("myfile", "myid") produces the same result. I also tried defining the exception with import exception class RecordNotFoundException(exception.Exception): Why is it showing '' instead of the arguments I passed? Thanks for any assistence, Daniel Klein From cpsoct at my-deja.com Wed Jan 24 05:04:34 2001 From: cpsoct at my-deja.com (cpsoct at my-deja.com) Date: Wed, 24 Jan 2001 10:04:34 GMT Subject: Random and whrandom References: <94bj03$59v$1@nnrp1.deja.com> <3a6a3540.1976549@news.xo.com> <94jkh0011gg@news1.newsguy.com> Message-ID: <94m9bf$nge$1@nnrp1.deja.com> but to get back to my original question. I should import random and not whrandom? But then i notice that seed is in whrandom? Hmmm. so i need to import both? And why are there 3 seed values? In C, there was just one. and, what then is rand? id that depreciated? i want to get random numbers, but seeded ones (so i can duplicate my run). Frankly i don't understand why python has two random modules in its standard library and how these namespaces might overlap. It would be great if the random whrandom poop could be cleaned up in future versions of python. One clear module. I am so confused kevin parks seoul, korea cpsoct at lycos.com Sent via Deja.com http://www.deja.com/ From steNOSvebPAM at katamail.com Sat Jan 27 05:09:27 2001 From: steNOSvebPAM at katamail.com (accattatevillo(at home)) Date: Sat, 27 Jan 2001 11:09:27 +0100 Subject: Python and Industry, IBM I'm afraid References: <20010111172342.10148.00000934@ng-ca1.aol.com> <3A63D9E8.F9B74ACE@mjs400.co.uk> Message-ID: <3A729E57.6CE19B86@katamail.com> Per Gummedal ha scritto: > > > I'm currently trying to do a port to AS/400. > I have it up running with a limited set of modules, but it's not > ready yet. > It's very interesting!! Version # ? TIA Stefano (happy AS/400 administrator :-) ) P.S. Are You an IBM's internal? From justinhj at hotmail.com Thu Jan 18 19:37:00 2001 From: justinhj at hotmail.com (JustinHJ) Date: Thu, 18 Jan 2001 16:37:00 -0800 Subject: How to run script from interpreter? References: Message-ID: say you have a script in a file called test.py just type import test (you don't need the .py) As for doing stuff in the script it will execute any commands it encounters. It's neat to have all your stuff in functions and then have commands at the bottom to call the functions as needed. This is like a simulated main() from C. if __name__ == '__main__': # only run if main program DoStuff( ) Rolander, Dan wrote in message news:mailman.979855413.16209.python-list at python.org... > What is the best way to run a python script from within the interpreter? > What command should I use? > > Thanks, > Dan > From rwklee at home.com Thu Jan 25 20:07:30 2001 From: rwklee at home.com (Rick Lee) Date: Fri, 26 Jan 2001 01:07:30 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: <3A70CDD3.3EE32FDA@home.com> Thank you all for your thoughtful posts. On reflection, I would say my greatest need would be: - being able to build data entry screens on the fly from a description of an object's attributes I am still very naive about this; but I would have thought the need for this feature would crop up frequently. I wonder why it doesn't seem to be featured in the popular toolkits. Maybe it is extremely easy for anyone to build, in which case would someone care to post a working example. Thanks. - Rick Rick Lee wrote: > It has to be cross platform between Linux and Windows, so it seems that > my choices are Tkinter and wxPython. > > Your experience, thoughts, opinion, on the relative merits and pitfalls > of each? > > My particular case: A GUI that has 5 windows max., will incorporate a > xmlrpc client, will have a python object browser, being able to build > data entry screens on the fly from a description of an object's > attributes, programmer not familiar with either toolkit. > > Thanks in advance. > > - Rick Lee From lvanderfeltz at knowledgetrax.com Sat Jan 13 15:31:31 2001 From: lvanderfeltz at knowledgetrax.com (Lennard van der Feltz) Date: Sat, 13 Jan 2001 20:31:31 GMT Subject: ZODB and Python 2.0 References: Message-ID: Isn't the bigger issue that ExtensionClasses are not yet available for Python 2.0? I had no problem compiling amk's ZODB distribution as is with Python 1.5.2 under Windows. A simple "python setup.py build" followed by "python setup.py. install" did the trick. I did try to run "python setup.py bdist_wininst", and while it ran, it didn't create anything useful. I noticed that it tries to invoke "zip" to create the distribution files but I don't have that for Windows. Further, I am not yet familiar enough with distutils to take it any further. Lennard "A.M. Kuchling" wrote in message news:slrn95vje6.gm.amk at 207-172-113-55.s55.tnt5.ann.va.dialup.rcn.com... > On Fri, 12 Jan 2001 17:02:36 -0500, Tim Peters wrote: > >[Steve Menard] > >> ... > >> So finally, my question is this : Why isn;t ZODB available as a separate > >> package using the distutils? > > > >http://sourceforge.net/projects/zodb/ > > That's not really going to help if he's on Windows without a compiler. > Someone needs to download the code and run "python setup.py > bdist_wininst"; I have no idea if it'll work, but it's worth a try. > > Paul Prescod also recently reported compiling ZODB for Windows and > offered to mmake binaries available. Paul, if you want to provide a > pointer to them, I'll add a copy to the SourceForge site. > > --amk From grante at visi.com Tue Jan 30 08:40:02 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 30 Jan 2001 13:40:02 GMT Subject: Books References: Message-ID: In article , Mikael Olofsson wrote: > >On 29-Jan-01 Me, myself, and I wrote: > > seems to be two different places. Compyters are nit-pickers when it > > comes to spelling. > >That should be computers. > >Note to self: Proofread one more time when posting to usenet. It won't work. Any posting pointing out a spelling error will itself contain a spelling error. It's one of the fundamental laws of Usenet -- no amount of proofreading will help. -- Grant Edwards grante Yow! .. I don't understand at the HUMOR of the THREE visi.com STOOGES!! From root at rainerdeyke.com Mon Jan 15 16:24:03 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 15 Jan 2001 21:24:03 GMT Subject: Beginner's question - class definition References: <3a6366a8.4537644@news.ruralnet.net.au> Message-ID: wrote in message news:3a6366a8.4537644 at news.ruralnet.net.au... > Can anyone explain please why the following definition ( from the > Python documentation) > > class Complex: > def _init_(self, realpart, imagpart): Should be __init__ (i.e. two underscores to the left and two underscores to the right). -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From derek at realware.com.au Wed Jan 17 21:50:27 2001 From: derek at realware.com.au (Realware Systems) Date: Thu, 18 Jan 2001 12:50:27 +1000 Subject: Python FTP module Message-ID: I am sure there is a python FTP module but I don't know where it is or what it is called. Any ideas? TIA Derek From phd at phd.pp.ru Tue Jan 9 05:55:16 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 9 Jan 2001 13:55:16 +0300 (MSK) Subject: mxTools (was Re: why no "do : until"?) In-Reply-To: <7BD10B680501D411B9DF009027E06F32197B86@exchange> Message-ID: On Tue, 9 Jan 2001, [iso-8859-1] Max M?ller Rasmussen wrote: > From: Oleg Broytmann [mailto:phd at phd.pp.ru] > > > Anyone here has any doubts that at least mxDateTime simply MUST be in > >the Python core? :) > > No that would be a great idea, but doesn't the license prevent that? I heared that Marc-Andre may work with GvR to resolve the issue. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jaapspies at home.nl Wed Jan 24 14:59:30 2001 From: jaapspies at home.nl (Jaap Spies) Date: Wed, 24 Jan 2001 19:59:30 GMT Subject: observer design pattern References: <94i340$4er$1@nnrp1.deja.com> <3A6CA19C.89A6DFB2@attglobal.net> <3A6D0992.C86D92CD@home.com> <3A6D5BAB.2AB22E36@mail.dvz.fh-koeln.de> <3A6D8E5A.476DE8E7@attglobal.net> Message-ID: <3A6F340D.7000606@home.nl> A.M. Kuchling wrote: > On Tue, 23 Jan 2001 08:59:54 -0500, > Roland Schlenker wrote: > >> Correct, when I read the Gof book, I rewrote many of the examples in the >> Python >> to better understand them. > > > If you still have the code, I'd encourage you to put it on a Web page > somewhere, or turn it into a HOWTO, since the question seems to come > up regularly (though not too frequently). > > --amk Yes! Please do! Jaap Spies From bww00 at amdahl.com Sun Jan 7 16:56:29 2001 From: bww00 at amdahl.com (Bryan Webb) Date: 07 Jan 2001 21:56:29 GMT Subject: help / examples reading floats / doubles, user definded objs Message-ID: <93aomd$7nd@dispatch.concentric.net> Hi, I'm loolking for examples of reading floats, doubles and user defined objects . Thanks Bryan Webb From djmoore at uh.edu Sun Jan 28 21:52:50 2001 From: djmoore at uh.edu (DaveMoore) Date: Sun, 28 Jan 2001 20:52:50 -0600 Subject: win32net NetServerEnum BufferSize, Resume References: Message-ID: <6nl97ts5i3kgcjs8uijdm56juqc2a0jl2g@4ax.com> On Fri, 26 Jan 2001 21:20:39 -0600, DaveMoore (that would be me) asked four questions. I kept looking, and came up with three answers: [snip Win32 API NetServerEnum under ActivePython 2.02 background info.] > >The parameter prefLen, used by most of the enumeration functions, >specifies the size of the returned data buffer, which is copied to >a list of dictionaries. The suggested size is 4096. [snip] >LMCons.h defines MAX_PREFERRED_LENGTH as ((DWORD) -1), which I take to >mean one less than the maximum possible value (I am not a C coder). Got this one; this means, of course, that MAX_PREFERRED_LENGTH is set to a value of -1, but cast as a DWORD. [snip] >On the gripping hand, prefLen=-1 yields the entire list. [snip] >Does preflen=-1 result in a buffer of exactly the right size, or the >largest buffer that can be allocated? "Exactly the right size," correct? So why is 4096 the default? > >NetServerEnum also returns resumeHandle, which supposedly allows you >to recall the function if there is more information. I'd think an >undersized buffer would be exactly what resumeHandle would cover, but >all my calls return zero. When, exactly, does the resume mechanism >kick in? >From : "For some strange reason the code was setting the resume handle to zero!" So it looks like this is an error which will go away in the next release, I hope. >The code fragment below is based on John Nielson's NetWkstaUserEnum >example in the Win32 Extensions Network Overview. I've deleted >Nielson's initial call to Net...Enum, and just set resumeHandle >nonzero so as to go through the While loop at least once. Would this >be a problem if I did indeed need to resume? I still don't get this one. Why two calls, one outside the loop and one in? [snip code] -- Dave Moore == djmoore at uh.edu == I speak for me. From not.this at seebelow.org Mon Jan 29 09:35:42 2001 From: not.this at seebelow.org (Grant Griffin) Date: Mon, 29 Jan 2001 08:35:42 -0600 Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> Message-ID: <3A757FBE.E54C5ECD@seebelow.org> C.Laurence Gonsalves wrote: > ... > I'm not sure why you need to be reminded whether something is a sequence > or a dictionary. I guess it's because sequences and dictionaries are conceptually very different. (You can tell, because we have a special word just to characterize "sequences". ) Both conceptually and in terms of how they are manipulated, lists, tuples, and strings are all much more similar to each other than dictionaries are to any of them. It helps me when reading code (even my own) to be reminded of the difference. (I am the proud owner of a skull of strictly limited size.) or-maybe-it's-just-because-I-learned-perl-first--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From syver at NOSPAMcyberwatcher.com Fri Jan 19 06:48:49 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 19 Jan 2001 12:48:49 +0100 Subject: Python COM and DCOM. Message-ID: <3RV96.10957$wt2.125028@news1.oke.nextra.no> I am having a bit of a problem getting a python COM object to work over DCOM. As far as I can see I've done exactly what is proposed in the Python on Win32 book. But the object is started on the local machine, when using win32com.client.Dispatch or the default instance creation methods in other languages such as JScript with ASP and C++. It seems like DCOM works when using the DispatchEx to explicitly choose the machine to run on but not else. Help very much appreciated, thank you. From scarblac at pino.selwerd.nl Sat Jan 6 20:37:57 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 7 Jan 2001 01:37:57 GMT Subject: Returning the path of a file References: Message-ID: Daniel Klein wrote in comp.lang.python: > I've search the Beazley book as well as the Python reference materials > and can't find answers to these two basically simple questions: > > 1) How to return the path of a file previously opened in read-only > mode? > > myfile = open("foo") As others said, myfile.name is now "foo" and maybe you can reconstruct something with that. What I want to add - in general it's simply not possible to do better than that. For instance, on Unix a file can have multiple filenames because of linking. Or maybe someone is changing the directory structure while you have the file open. Maybe the file is not actually a file on the harddisk, but some device. So maybe you should always open your files with the full path, if you need this sort of thing often. -- Remco Gerlich From mfletch at tpresence.com Thu Jan 11 11:53:27 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Thu, 11 Jan 2001 11:53:27 -0500 Subject: Reflection: Calling Methods Dynamically by Name Message-ID: Short answer: Yes. Long answer: Yes :o) . exec is an extremely heavyweight call, you're effectively creating a new interpreter context and asking it to parse your arbitrary code. The getattr and apply calls are trivial in comparison, a few name lookups. And that's before you get into the "never use exec because it is the spawn of the devil" philosophy that I'm sure someone will spout at you... Mike -----Original Message----- From: D-Man To: python-list at python.org Sent: 1/11/2001 7:51 AM Subject: Re: Reflection: Calling Methods Dynamically by Name On Thu, Jan 11, 2001 at 01:41:34PM +0700, Prateep Siamwalla wrote: | Chad, | | You will want to use getattr() and apply() | Is it better to use getattr() and apply() than to use exec? For example, mc = MyClass() funcname = "ProcessData" args = ("Data", 1, 3) exec( "mc." + funcname + "('Data' , 1 , 3 ) " ) -D -- http://www.python.org/mailman/listinfo/python-list From db3l at fitlinxx.com Fri Jan 26 14:53:47 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Jan 2001 14:53:47 -0500 Subject: win32all's win32net module and Win98 Message-ID: While trying to run a script on a Win98 machine (Python 1.5.2 and win32all-132), I found that using the win32net module - which works fine on my NT4sp4 machine - failed to import. The problem appears to be that the NETAPI32 DLL on the Win98 system didn't have any of the entry points it expected. The DLL on the Win98 system is dated from 99 (don't have the version handy), but the DLL on my NT system is dated from 98. Does anyone know if there's a problem using this module under Win98 (my SDK docs seem to indicate the functions it exports were available as of Win95), and/or do I need to install or update something on the Win98 box? Thanks. -- -- 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 nicrayner at hotmail.com Mon Jan 8 07:51:25 2001 From: nicrayner at hotmail.com (Nick Rayner) Date: Mon, 08 Jan 2001 12:51:25 -0000 Subject: ok Message-ID: confirm 438765 _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From Achim.Gaedke at zpr.uni-koeln.de Mon Jan 8 08:00:42 2001 From: Achim.Gaedke at zpr.uni-koeln.de (Achim Gaedke) Date: Mon, 08 Jan 2001 14:00:42 +0100 Subject: GNU Scientific Library Interface Message-ID: <3A59B9F9.868F3428@zpr.uni-koeln.de> My attempt to access several mathematical functions has grown to a interface for gsl (GNU Scientific Library: http://sources.redhat.com/gsl/ ). You may obtain it here: http://www.zaik.uni-koeln.de/~achim/gsl/ It gives access to 200 special functions, 31 probability-density-functions, about 20 random number generators. These functions come with the gsl library, just look at: http://sources.redhat.com/gsl/ref/gsl-ref_toc.html The actual status of gsl is 0.7 (alpha-version). In my opinion, the major part of this library is quite stable. First you will have to install gsl, then get the gsl-interface and unpack it. Python-2.0 is necessary for easy installation. Installation can be done as usual: python ./setup.py install I'd like to extend this interface together with other people. So far all wrapper functions are written in plain C, in order to avoid trouble while porting. Just contact me, if you would like to help: Achim.Gaedke --at-- zpr.uni-koeln.de. Here is a short example: # import special functions import gsl.sf # returns a tuple (result, error of result) print gsl.sf.gamma(1.0) #the full list of implemented functions, just refer to gsl-ref for details print dir(gsl.sf) #import random number generator and probability densities import gsl.rng #gives you the initialised mt19937 random number generator r=gsl.rng.gsl_rng_mt19937() #returns the next long int random value print r.get() # returns a float value with gaussian probability (sigma=2,mu=0) print r.gaussian(2) # displays all implemented rngs print filter(lambda e:e[:7]=='gsl_rng',dir(gsl.rng)) # displays all implemented densities: print filter(lambda e:e[-3:]=='pdf',dir(gsl.rng)) -- Achim Gaedke, ZPR Weyertal 80, 50931 K?ln Tel: +49 221 470 6021 From wlsonna at attglobal.net Sat Jan 20 09:10:35 2001 From: wlsonna at attglobal.net (William Sonna) Date: 20 Jan 2001 14:10:35 GMT Subject: I will kill my Python References: <947r18$rdt$1@news.online.de> <948f09$i96$1@nnrp1.deja.com> Message-ID: <0O7zTzsxerl5-pn2-3VUTduFoLZlv@bill> On Fri, 19 Jan 2001 04:15:10, thelazydogsback at my-deja.com wrote: [snip] > > On a related topic, I've seen some Microsoft bashing here as well (not > just this post.) There's certainly nothing wrong with that (It's a > profession for some) but I must say that in some cases it reduces > Python's credibility. I want to see people using it because it works > for them, not just because they hate the evil Micro$oft and would > rather code with toggle-switches than use anything built even 500 miles > from Redmond. Just some thoughts... > Your wrong, pal. PERL bashing, not Microshaft bashing, is the chief "professional" activity around here:-) From aleaxit at yahoo.com Thu Jan 4 07:31:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 13:31:43 +0100 Subject: Registering C methods when writing a C extension type? References: Message-ID: <931qh802n2n@news2.newsguy.com> "Tom Epperly" wrote in message news:mailman.978564004.19861.python-list at python.org... > I planning to write a C extension type (not module) to provide a Python > binding for an object or interface defined in an IDL (interface definition > language) for high performance scientific computing. In the example from So far, so good. > following to make the object methods visible (in myobject.c): > > static struct PyMethodDef myobject_methods[] = { > {"method_one", (PyCFunction)method_one, 1}, [snip] > return Py_FindMethod(object_methods, self, name); > } > > /* tp_getattr points to myobject_getattr */ Yes, this is the 'canonic' way. > I am wondering what the relative merits/penalties of doing something like > the following in the constructor for the hypothetical myobject instead of > the above. I would like feedback about issues of style (am I violating the > designers intent or using functions intended for internal use only), > forward/backward portability, and efficiency. I fail to see any advantage of the following approach. OTOH, the disadvantages are pretty obvious: > static myobject * > new_myobject() > { > myobject *self; > const int len = sizeof(object_methods)/sizeof(PyMethodDef); > int i; > self = PyObject_NEW(myobject, &myobjecttype); > if (self == NULL) return NULL; > for(i = 0 ; i < len ; i++){ > PyObject *func = PyCFunction_New(object_methods + i, self); > if (func != NULL) { > PyObject_SetAttrString(self, object_methods[i].ml_name, func); > Py_DECREF(func); /* remove extra reference */ > } > } > return self; > } ...each new-object instancing pays a time price to initialize the table of its methods, and, perhaps more important, the *space* to hold a table that's just a copy of the object_methods one to all intents and purposes. What's the point...? Alex From aleaxit at yahoo.com Wed Jan 31 17:40:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 31 Jan 2001 23:40:40 +0100 Subject: Python 2.1 and Unicode References: <958gnc0ksj@news2.newsguy.com> Message-ID: <95a49s01uao@news1.newsguy.com> "Dale Strickland-Clark" wrote in message news:ivig7t0dvpblnqlqa348jop70dbtmd2hjo at 4ax.com... [snip] > Thanks, again, Alex. You're welcome! > I'm not familiar with the site configuration stuff. Could I also use this > for identifying our own module library? > > Where's it documented? http://www.python.org/doc/current/lib/module-site.html and environs. Basically, strategically placing .pth files will help you "identify your module libraries" etc. Then, sitecustomize.py, if it exists, lets you do any last-minute site-specific tweaks -- it's imported first. Alex From nikolai.kirsebom at siemens.no Thu Jan 4 05:24:25 2001 From: nikolai.kirsebom at siemens.no (Nikolai Kirsebom) Date: Thu, 04 Jan 2001 10:24:25 GMT Subject: Importing into 'containers' namespace Message-ID: <3a544e22.1199160471@news.mch.sni.de> There is probably an easy solution to this, but I can't seem to find out. I would like to make an object (instance) created in the 'importing' namespace available in the imported module. Example below: # ----------------------------------------------------------- # File: B.py (the imported module) # when loaded, the object 'FrameWork' is in the scope class B: def __init__(self): self.b = FrameWork.a # ----------------------------------------------------------- # File: A.py (the importer) class A: def __init__(self): self.a = 1 # Create framework instanse FrameWork = A() # SOME IMPORT STATEMENT for module B ?? Sub = B.B() print Sub.b # Produces '1' as output # ---------------------------------------------------------- Thanks for any help. Nikolai From loewis at informatik.hu-berlin.de Thu Jan 25 13:34:44 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Jan 2001 19:34:44 +0100 Subject: Python vs Ruby References: <94mdkd$222e$1@news.adamastor.ac.za> Message-ID: "James Lockley" writes: > Just been reading a "Ruby centric" comparison of Ruby vs Python on: > http://helium.ruby-lang.org/en/compar.html > > would be interested to hear the Pythonista view.... As far as I can tell, all of them are facts, not opinions, which is a good thing. Most of them are correct, which is also a good think. Incorrect is the claim Ruby has "real" garbage collector, not ref-counting. While this is correct also, it implies that Python has ref-counting and no "real" garbage collector, which is not true for Python 2.0. The implication of the conclusion # Not subject to memory leaks like ref-counting is. is likewise incorrect - in Python 2.0, the memory leaks of reference counting disappear also. The implication from the other conclusion # No INCREF, DECREF are required for extensions. is still correct - INCREF, DECREF are required for extensions. I don't know how exactly GC works in Ruby - it is likely that it suffers from things that people would consider as drawbacks, though. # Ruby is often faster than Python. That I would not believe without proof. Regards, Martin From mspiggie at my-deja.com Fri Jan 26 11:54:38 2001 From: mspiggie at my-deja.com (mspiggie at my-deja.com) Date: Fri, 26 Jan 2001 16:54:38 GMT Subject: The fundamentals... References: Message-ID: <94sa4a$vo8$1@nnrp1.deja.com> In article , Neil Schemenauer wrote: > Its probably clearer use string.replace. Using ?!ng's excellent > pydoc command: > > $ pydoc string.replace > > Python Library Documentation: function replace in string > > replace(s, old, new, maxsplit=-1) > replace (str, old, new[, maxsplit]) -> string > > Return a copy of string str with all occurrences of substring > old replaced by new. If the optional argument maxsplit is > given, only the first maxsplit occurrences are replaced. > > So you can do: > > boo = string.replace(". ", "\n") > > In Python 2.0 or later you can use string methods: > > boo = boo.replace(". ", "\n") > > Cheers, > > Neil > > I have been trying to find a way to use replace() to perform more than one replacement within a given file. For instance, suppose I needed to replace ". " with "\n", but also need to replace "!" with "exclamation" and "?" with "question". I have tried several approaches to this, but none of my neophyte ideas have produced satisfying results. Rob Sent via Deja.com http://www.deja.com/ From katz at Glue.umd.edu Sat Jan 27 12:12:07 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Sat, 27 Jan 2001 12:12:07 -0500 Subject: . Python 2.1 function attributes In-Reply-To: References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> <14962.62953.304511.523826@anthem.wooz.org> Message-ID: On Sat, 27 Jan 2001, Robin Becker wrote: > >>>> def f(x * [x-1 for x > 1]) << x: pass ohmigod, that's like a bad dream.. > >... > >>>> print f.x = 5 > >120 weird! wouldn't it be clearer with a functor? wink, wink! > aaarrggghhhh the Inquisition auto da fe with << and >> it's what you oughtn't to do but you do anyway :) IMHO, the above History of the World quote applies to our topic precisely :) Yeah, I was griping about the language going to hell and I meant it. I don't mean to return to Python 1.3 days, but some things (notably print>>) contribute a fair share towards Perlization. Given Python's current "there's a right way to do it" motto, and its recent TMTOWTDIfication, perhaps a more fitting one would be "yeah, but so-and-so came up with a patch, and we couldn't resist, so we included it. So deal." History of the World. Now there is print>> and write(). I call for boycotting print>>. I expect one person, maybe less, to support me on that. I fully expect to see blocking delimiters in the next Python incarnation. Onward {Christian,Jewish,..} Soldiers! to Perl! (perlwards!) To be more optmistic: I would like to see more of a unification between functions and classes. See my other post. Perhaps a type which is both a class and a function simultaneously (a 'type')? type myClassAndFunc(self, x) extends ParentClassAndFunc: data = x # static data print data # when called as myClassAndFunc( type meth1(self): pass # method type meth2(self): pass # method Just brainstorming :) Roey Got Patches? From f8dy at my-deja.com Mon Jan 29 15:48:49 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Mon, 29 Jan 2001 20:48:49 GMT Subject: Books References: <3a757ac1$1@netnews.web.de> Message-ID: <954kvc$f6n$1@nnrp1.deja.com> In article <3a757ac1$1 at netnews.web.de>, "Volker Jahns" wrote: > First:I am want to read something about PHYTON. Which books are good for a > programmer with good knowledge in differnt languages PHP, SQL and so one? I am writing a free book on Python, targeted at people just like you, with experience in other scripting languages. So far, I've published 2.5 chapters of it on http://diveintopython.org/. It won't teach you everything, but it's a good place to start. -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From godcha at my-deja.com Thu Jan 18 04:30:09 2001 From: godcha at my-deja.com (godcha at my-deja.com) Date: Thu, 18 Jan 2001 09:30:09 GMT Subject: This is my first program in Python References: <3a66a585.268350144@news.tcn.net> Message-ID: <946d31$nh9$1@nnrp1.deja.com> In article <3a66a585.268350144 at news.tcn.net>, rzilavec at tcn.net wrote: > > I've spent the last few weeks trying to find a good book on Python. > Seems that most stores don't carry a large selection, however I found > The Quick Python Book.. The material seems to flow in the right > direction and the fonts are easy on the eyes. > > Anyways, I wrote my first program but was stumped on readline(). I > could get the first line, but not the rest of the file. I tried > searching python.org and could not find an example.... well here it > is: > > import string > file = open("/tmp/globs", 'r') > for line in file.readlines(): > (first,second) = string.split(line,':',1) > print first > file.close() > Your question is not clear... But I read and tried your code above, it is correct and working perfectly : it prints the first characters until the first colon (:) of each line of the /tmp/globs file. > This was my first attempt, which looks like it should work but failed: > invalid syntax. Is this not possible? > while line = file.readlines(): > > Am I using string.split properly? > > I was quite happy with how easy this was to put together, I'm just not > sure if its totally correct. > > -- > Richard Zilavec > rzilavec at tcn.net Godefroid Chapelle BubbleNet sprl Louvain-la-Neuve Belgium Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Wed Jan 3 18:37:42 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 03 Jan 2001 23:37:42 GMT Subject: Registering C methods when writing a C extension type? References: Message-ID: Tom Epperly wrote: > In this case, the getattr method does not call Py_FindMethod. what does it (tp_getattr) do instead? confused /F From pete at visionart.com Mon Jan 8 15:40:59 2001 From: pete at visionart.com (Pete Shinners) Date: Mon, 8 Jan 2001 12:40:59 -0800 Subject: HELP: traceback from signal handler Message-ID: <93d8go$9u1$1@la-mail4.digilink.net> i have a C signal handler that is catching my segfaults. i'd like to print a traceback before the program quits. i'm having a tricky time figuring this out. it appears first off that my signal handler doesn't have the global interp lock, so i can't get ahold of the current thread_state. (i assume i need the thread_state to create a traceback object). do i need to get the thread_state? is it safe for me to get it from inside a signal handler? am i even on the right track? thanks From db3l at fitlinxx.com Mon Jan 22 16:12:37 2001 From: db3l at fitlinxx.com (David Bolen) Date: 22 Jan 2001 16:12:37 -0500 Subject: Different deployment considerations (was: Python & GUI?) References: Message-ID: Mike Fletcher writes: > I do wxPython-based distributions using installer quite often, they are not > "single file" installations, as you get the PythonXX.dll, wxc.pyd, > wxXXX.dll, zlib.pyd, etceteras all as separate files. I think you get the > same for the Tkinter apps, so not really sure what's meant by "single file" > here. You can get "single file" by using a Windows installation package (like InstallShield, Wise, or the free InnoSetup). > There's nothing special to do for wxPython, I just run "standalone" or > "simple" and the app is generated with the DLLs collected. Once I rename > msvcirt.dll to msvcrt.dll I've got a working application. You've got to be careful with that - the MSVC*RT.DLL files are the C run time, and are sometimes system specific - not to mention not being identical. I'm drawing a blank on precisely the differences, but I seem to recall that MSVCRT40 delegates various functionality to MSVCIRT.DLL. I know know that I messed stuff up during testing by letting my (NT) MSVCIRT.DLL file get installed on a Win98 system. In the end, I've taken to wimping out and assuming that my clients need those present and I won't supply them. They come with many MS applications, and I think can be downloaded as a runtime independently if necessary, but I haven't run into any problems yet. Note that this issue is independent of Python or wxPython - it's a general problem with deciding how to update some of the system DLLs. -- -- 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 dnew at san.rr.com Fri Jan 19 12:58:56 2001 From: dnew at san.rr.com (Darren New) Date: Fri, 19 Jan 2001 17:58:56 GMT Subject: Why no isexec, isread, iswrite, etc (was: I must be missing something obvious: os.path.isexecutable?) References: Message-ID: <3A688062.A6B0E7F5@san.rr.com> > > One possibility is that there's more than one answer to the question > > of "isexec" - it's not a single bit, but one that can exist for all of > > owner, group and world. UNIX has ACLs now almost as sophisticated as NT does, too. > Another possibility is that "isexec" isn't a portable concept... > How would you implement it on Windows, for example? Anything you have execute permission for? What if the machine is down and it's on a network-mounted mount point? What if the path after the #! doesn't exist, or isn't executable. Try executing the file and see if you get what you want. That's "isexec". :-) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. "It says this wine has syphilis." "I think that's pronounced `sulphates'." From aleaxit at yahoo.com Fri Jan 19 11:55:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 19 Jan 2001 17:55:45 +0100 Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> <3a685ef2.3403798@reading.news.pipex.net> Message-ID: <949rii0a76@news1.newsguy.com> "Ray Drew" wrote in message news:3a685ef2.3403798 at reading.news.pipex.net... [snip] > (on Win98) > I've been using Idle but I'd like to try gvim. A few questions spring > to mind... > > Do you use a command window for interactive sessions, or can you run > an interpreter within gvim (as with emacs)? If you use a command > window, how do you manage repeating previous code snippets? I normally use a command window (occasionally PyWin or IDLE, while still doing 'real' editing from gvim). I repeat previous code snippets with up-arrow (on NT); Win98 is really brain-damaged (up-arrow doesn't work at Python prompt, while in NT it does) so I'd use an alternate command processor there, which does give me this minimal utility (there's one written in Python that I use on win98 machines sometime, but I don't have an URL for it handy; or else, bash or some of its workalikes). > How do you debug... in the command window with pdb? To be honest, more often I stick print statements in for debugging purposes, but that's not a particularly clever idea, just the normal reflex of a programming dinosaur (I do lots of OutputDebugString and watch them with a separate utility too - I find that VERY handy since so often I'm debugging joint Python and C/C++ code operation, and my approach to debugging does tend to be 'check what this is worth right here' which tracing facilities such as print and OutputDebugString work well with). pdb seems quite adequate too (when I'm debugging only Python, not C/C++ written modules at the same time). > Do you use the ole version to make it Python-programmable? Can you > give a simple example of how this might be used? Yes, and no, to the two questions. I find the idea of a programmable editor very cool, but (again being a dinosaur) I don't really make much true use of it!-) > Any other tips for using gvim with Python? Use blank lines cleverly to delimit logical blocks, so { and } are useful movement-commands -- also increases readability. Would be nice to have movement commands based on indent-levels, but, to be quite honest with you, I've never bothered programming them... (shame's about to engulf me...). I like :set expandtab always on -- no tab/space confusion; I also like :set ff unix, so that my scripts can be shared between Win and Unix machines (and why waste one byte per line to tell a 'carriage' that is not there to 'return' [to where?]...?!-). Oh, and the key tip for gvim under Win98 - the quoting character is NOT control-V (they used that for 'paste' to follow Win conventions) -- it's control-Q instead. So to remove those silly control-M (carriage-return) that using some other editor may have inserted, :%s/^Q^M// is what one types (with ^ to mean keeping the Ctrl key down:-). Alex From kwoeltje at earthlink.net Mon Jan 29 21:26:15 2001 From: kwoeltje at earthlink.net (Keith Woeltje) Date: Tue, 30 Jan 2001 02:26:15 GMT Subject: Books References: <3a757ac1$1@netnews.web.de> Message-ID: <3A76264A.D0E2557@earthlink.net> Volker, You'll probably want to try the Python tutorial first (online at http://www.python.org/doc/current/tut/tut.html ). For printed books, check out "Learning Python" by Lutz (there is even a German translation) or "The Quick Python Book" by Harms and McDonald. "Python Essential Reference" is a very handy book. It has a 10 page tutorial that may be enough to get you going especially if you've worked through the "official" tutorial. The rest of the book pretty much lives up to its billing. "Core Python" by Chun has gotten some good reviews, but I haven't seen it yet. The second edition of "Programming Python" by Lutz is due out in March from O'Reilly, and I anticipate that it will be something you'll want to evaluate once it comes out. There are a couple of other "Buecher auf Deutsch" that I haven't seen an English equivalent of, so I can't judge them. Look at http://www.amk.ca/bookstore/non-english.html . Hope that helps. Have fun. >KFW From tismer at tismer.com Mon Jan 8 11:15:55 2001 From: tismer at tismer.com (Christian Tismer) Date: Mon, 08 Jan 2001 18:15:55 +0200 Subject: ANN: Stackless Python 2.0 References: <3A58EFC3.5A722FF0@tismer.com> <20010108180616.A18993@yetix.sz-sb.de> Message-ID: <3A59E7BB.6908B7E2@tismer.com> Andreas Jung wrote: > > On Mon, Jan 08, 2001 at 12:37:55AM +0200, Christian Tismer wrote: > > Dear community, > > > > I'm happy to announce that > > > > Stackless Python 2.0 > > > > is finally ready and available for download. > > > > Stackless Python for Python 1.5.2+ also got some minor > > enhancements. Both versions are available as Win32 > > installer files here: > > Are there patches available against the standard Python 2.0 > source code tree ? I had no time yet to put the source trees on the web. Should happen in one or two days. The I will probably not provide patches, hoping that some other Unix people will catch up and provide that part. This worked the same for the 1.5.2 version. The 2.0 port consists of 10 or so files, which can be used as direct replacements for the same files in the 2.0 distro. I think on Unix this is the right way to go. For me it is simpler to have my own litle tree, since I'm working with Windows, and I just have to modify my VC++ project file. ciao - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From aleaxit at yahoo.com Mon Jan 29 09:25:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 29 Jan 2001 15:25:19 +0100 Subject: How to call a class method from a string representing a class name References: <3A745F5E.5F035F1D@axionet.com> <951p2j0e8@news2.newsguy.com> <3A74E327.C02A86FC@axionet.com> Message-ID: <953uge0vkg@news2.newsguy.com> "Andre Fortin" wrote in message news:3A74E327.C02A86FC at axionet.com... [snip] > > try: > > callable = test.myFunc > > except (NameError,AttributeError): > > pass > > else: > > callable('Some Text') > > Using "test.myFunc" returns a "AttributeError: myFunc", since > "test" is a string. The quotes are confusing, but I assume you mean that 'test' is not ITSELF the name of the object, but rather _refers to_ a string which is the name of the object. If so, then callable = eval(test+'.myFunc') may be the simplest way to apply this "indirectness". > import sys > import test > > className = 'test' Why call 'className' what is actually the name of a MODULE, *NOT* of a class? Seems confusing. Or, may the name be of _something else_ than a module...? > try: > sys.modules[className].myFunc('Some text') > except KeyError: > pass This will propagate an AttributeError if a module named 'test' exists but does NOT contain an entry called 'myFunc' (as well as a TypeError if that entry exists but is not callable with one argument, as before). > Very clean. It avoids both the globals() and vars() calls. > > > (a KeyError raised inside 'callable' in your case > > is silently caught and hidden -- IS that what you want?) > > In my case, yes. In this snippet context, what counts is the existence > of the "test" module. If you KNOW it's a module (not "just any object whatsoever") then I guess indexing into sys.modules is OK. But, IS this part of the specs? I saw you originally specify that you were naming *an object in the current global namespace*, and sys.modules does not check that -- if any OTHER module has ever imported one named 'test', then the entry WILL be in sys.modules, even if 'THIS module here' has never heard about it. So, you're implementing pretty different specs -- "modules only" as opposed to any object, "ever imported anywhere" as opposed to "in the current global namespace". Alex From ckrill at qvlinc.com Sat Jan 20 22:17:12 2001 From: ckrill at qvlinc.com (Coy Krill) Date: Sat, 20 Jan 2001 19:17:12 -0800 Subject: Blackadder - any opinions? References: <94c6cu$hl2$1@bob.news.rcn.net> Message-ID: <3A6A54B7.53ACE70C@qvlinc.com> Satheesh Babu wrote: > Hi, > > I saw this Python IDE at > http://www.thekompany.com/products/blackadder/ > > Personal edition is $49. Just wondering anybody had any > experience with that before I think of buying it. > > Screenshots look good though the site is damn too slow! > > Babu > > -- > v.s.babu > vsbabu at erols.com > http://vsbabu.csoft.net It hasn't actually been released yet. I ordered it the day they announced it and then found out it wouldn't be shipping for several weeks. A small bummer, but I can live with it. I've used PyQt for several months now and enjoy using it very much. I'd recommend it just on the benefits that it will provide (i.e. availability to create PyQt Windows programs and what appears to be a pretty nice IDE) and also to help pay for the continuing development of PyQt and it's availability on free platforms like Linux. Coy From isard at localhost.localdomain Wed Jan 24 16:14:02 2001 From: isard at localhost.localdomain (Carles =?iso-8859-1?Q?Sadurn=ED?= Anguita) Date: Wed, 24 Jan 2001 22:14:02 +0100 Subject: Python and postgreSQL ?? Message-ID: I've search unsuccessfully a tutorial about "attack" postgreSQL with Python. Can anybody help me? I would like to write a little program (python/tkinter) for a friend of mine who wants to mantain data about his costumers and who has no time to learn too much about computers. Thanks in advance -- ------------------------------------------------------------------------ Carles Sadurn? Anguita | no hab?a que cumplir promesas, | el cansancio era de placer, Quita _mira_la_firma para | las l?grimas eran de risas... responder. | y parece que a?n fue ayer. | Los Suaves ------------------------------------------------------------------------ From gerhard.nospam at bigfoot.de Fri Jan 5 00:40:04 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 05 Jan 2001 06:40:04 +0100 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> Message-ID: <3A555E34.3E01E4D0@bigfoot.de> Joel Ricker wrote: > So basically what I'd like to know is, how do the two compare? Is there an > easier learning curve with Python? I can only speak for myself. I have programmed (chronologically) in Basic, Pascal, C, x86 Assembler, Modula-2, C++, Java, Ada 95, Python, and some that I have already forgotten. The one or two times I wanted to learn Pearl I came to it from an object-oriented background and tried to start with Perl OOP. I failed, miserably. For me, Perl is very difficult to learn, perhaps it just does not correspond to my way of thinking. I wrote Python scripts that helped me do something useful from day one, so Python was really easy for me to learn. I guess it really depends on the backround you have. If you are a Unix guru and speak awk and sed as a native language, then perhaps Perl is what you will love. If you have a background from structured programming (Pascal!) or object-oriented programming (Ada 95, Java, C++), then Python might be just the scripting language you ever dreamed of. As far as CGI is concerned, I have successfully implemented an e-commerce web-application with dynamic generation of HTML in Python (CGI) + MySQL. The Python DB-API helped me to make the web-application database-agnostic. The Python MySQL-module is IMO very mature, I have never had any problems with it. There exist Python modules for a lot of other databases, most of them conform to the Python DB-API, so they can be easily interchanged. Should be just like Perl DBI. I haven't done very much with Graphics and Python, apart from generating buttons for web-pages (I used wxPython for this, an excellent cross-platform GUI toolkit). There exist several other Python libraries for graphics, the most prominent would be PIL (Python Imaging Library), but I haven't tried these. All in all, I can really recommend Python for CGI scripting. Gerhard H?ring PS: If you need some links, here they are: The Python tutorial: http://www.python.org/doc/current/tut/tut.html Python and databases: http://www.python.org/topics/database/ Yes, Python 2.0 comes with a CGI and a Cookie module, just download Python 2.0 and look in the docs. > Are the modules and add-ons as good as > perl (ie, Database -- I'm primarily interested in MySQL, CGI, Graphics). I'd say yes. > What about OOP? Is it it a full OO language? Of course, would you go with anything less? ;-) > Is it easier than to use than perl? For me: yes. > Perl OO just feels like it has been cludged together. Really? ;-) Or am I just too stupid to get it? > And lastly, what about the Python community? Is it friendlier than the perl > community? Too many times I've asked questions and all I'll get is pointers > to documentation, which I've already read and so thats why I'm asking for > information in the first place. I understand simple questions for basic or > novice information will warrant answers like that but not the things I've > asked. -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From donn at u.washington.edu Thu Jan 18 13:42:05 2001 From: donn at u.washington.edu (Donn Cave) Date: 18 Jan 2001 18:42:05 GMT Subject: Python and Industry, IBM I'm afraid References: <3A63D9E8.F9B74ACE@mjs400.co.uk> <941c14$dok$1@nnrp1.deja.com> <946evt02mr@news2.newsguy.com> Message-ID: <947ddt$g8a$1@nntp6.u.washington.edu> Quoth "Alex Martelli" : [re AIX ] | As I recall, its main | "here's our horrible surprise of the day for you" feature | was a malloc that would never return 0 even if you asked | it for FAR more memory than you had around -- rather, the | program died horribly later when it actually tried to USE | the memory it THOUGHT it had allocated... Never ran into this, thanks maybe to more modest memory requirements. But AIX's malloc is somewhat notorious for the converse: request 0 bytes and get a null pointer. I guess the rationale for this is something like "ask a silly question, get a silly answer", and it still does that to this day. When things are not going well on an AIX port, another thing to think about is a compiler flag, I believe it's -qchars=signed, that reverses their unusual unsigned char default. Donn Cave, donn at u.washington.edu From mfletch at tpresence.com Thu Jan 11 01:03:54 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Thu, 11 Jan 2001 01:03:54 -0500 Subject: Reflection: Calling Methods Dynamically by Name Message-ID: method = getattr( objectInstance, someString ) method( "Data", 1, 3) or apply( method, arguments ) Note that str is a builtin function for converting objects to strings, so it's not generally used as a variable in Python. HTH, Mike -----Original Message----- From: harrc at my-deja.com To: python-list at python.org Sent: 1/11/2001 12:22 AM Subject: Reflection: Calling Methods Dynamically by Name Question for Guido or language experts: Does Python have the ability to call methods of a class by name? For example, I have a string: "ProcessData" and the class MyClass has a method called ProcessData. Is there a way I can do something like this: mc = MyClass() str = "ProcessData" args = ("Data", 1, 3) CallMethodByName(mc, str, args) or perhaps: mc = MyClass() str = "ProcessData" args = ("Data", 1, 3) mc.CallMethodByName(str, args) This reflection-esque behavior would be very useful. Any ideas? Thanks, Chad Harrington Sent via Deja.com http://www.deja.com/ -- http://www.python.org/mailman/listinfo/python-list From john at coastalgeology.org Mon Jan 22 22:31:31 2001 From: john at coastalgeology.org (Jonathan Pennington) Date: Mon, 22 Jan 2001 22:31:31 -0500 Subject: XML doc generation Message-ID: <20010122223131.A31348@coastalgeology.org> >If you understand how to put raw text tags then I would suggest you >just do that as the simplest thing. I've been processing XML for a >long, long time and I hardly ever find it easier to build a tree and >then serialize it. It is more often best to do the simplest thing... Well, I trust your judgement there. As a reformed perl and PHP programmer, I can write text into a file in my sleep :-) However, one last question. If I wanted to download this coordinate info, then manipulate it as a DOM, would that still be easier. In other words, as stated above, I would download data from the receiver directly into an XML file, then parse the XML file into memory, display/manipulate it, then rewrite it to the file when saved. Do I understand correctly. It does sound easy enough, I just want to make sure that I'm not missing something or making things difficult with all that file I/O. Thanks. -J -- Jonathan Pennington | http://coastalgeology.org Site Manager | Protection and stewardship CoastalGeology.Org (CGO) | through public education. john at coastalgeology.org | Join CGO, make a difference. From mwh21 at cam.ac.uk Thu Jan 25 15:47:32 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Jan 2001 20:47:32 +0000 Subject: python-2.1 function attributes References: Message-ID: barry at digicool.com (Barry A. Warsaw) writes: > >>>>> "MH" == Michael Hudson writes: > > MH> I suspect if you can come up with a decent syntax, it will go > MH> in. I can't though. Any ideas? > > That's definitely been the problem so far. Function attribute tend to > be very useful even without the syntax, but I think many people agree > that an inline syntax a la docstrings would make the feature even more > useful. So far, no one's come up with an acceptable syntax. My > inclination would be to open a new PEP for just the syntax proposal, > referencing PEP 232 for the underlying implementation and access > rules. Ooh, I've come up with a strawman! One concrete idea: lose the dict analogy. It's only an implementation detail, and being able to have attributes whose names aren't strings is bonkers. The nearest equivalent in contemporary Python is the class statement, let's ape that. Now some ideas: def f(a, b, c) .publish = 1 .secure = 0: print "bobbins" Don't really like having the colon-free indent. def f(a, b, c) with: publish = 1 secure = 0: print "bobbins" I think this is my favourite that I've seen yet. Should be done with an "as"-like hack to avoid making is a keyword. The double indent is a bit naff, but I can't see a way of clearly distinguishing attributes from code without something like that. Maybe a variant: def f(a, b, c) with publish = 1; secure = 0: print "bobbins" Then you use backslashes when the attribute or argument list get long. def f(long_name, even_longer_name, still_longer_name) \ with publish = 1; secure = 0 grammar = f_grammar: print "bobbins" Thoughts? Cheers, M. -- This is an off-the-top-of-the-head-and-not-quite-sober suggestion, so is probably technically laughable. I'll see how embarassed I feel tomorrow morning. -- Patrick Gosling, ucam.comp.misc From thomas at xs4all.net Tue Jan 30 03:59:28 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 30 Jan 2001 09:59:28 +0100 Subject: "in" for dicts (was: Python 2.1 function attributes) In-Reply-To: ; from tim.one@home.com on Mon, Jan 29, 2001 at 06:23:59PM -0500 References: <954f49$b3k$1@news.udel.edu> Message-ID: <20010130095928.A962@xs4all.nl> On Mon, Jan 29, 2001 at 06:23:59PM -0500, Tim Peters wrote: > we also haven't pulled the platform-dependent tricks Perl does to optimize > char-at-a-time reading the way vendors *should* optimize fgets() but almost > never do (Tru64 Unix appears to be the sole probable exception to date). FreeBSD, actually, had insane performance in that area as well. (getc() being just as fast as getc_unlocked(), in processes with only a single thread active.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aleaxit at yahoo.com Tue Jan 2 16:49:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 2 Jan 2001 22:49:22 +0100 Subject: HTML Parsing References: Message-ID: <92tk07074s@news1.newsguy.com> "Denis Voitenko" wrote in message news:Vvq46.6762$ca.70091 at typhoon.jacksonville.mediaone.net... > I am trying to do some HTML parsing with htmllib but not getting anywhere. > Can someone give a couple of basic examples? Classic basic example #1: list links from an HTML page that you have in a diskfile: import htmllib import formatter parser=htmllib.HTMLParser(formatter.NullFormatter()) parser.feed(open('thepage.html').read()) parser.close() print parser.anchorlist Particularly easy, because links are specially processed by the supplied HTML parser class, so you need no inheriting and overriding for customization purposes. But, when you do, things aren't that much harder. E.g., say that what you need are the SRC urls of all IMG tags on the page...: import htmllib import formatter class MyParser(htmllib.HTMLParser): def __init__(self, formatterObject): htmllib.HTMLParser.__init__(self, formatterObject) self.image_sources = [] def do_img(self, attributes): for name,value in attributes: if name=='src': self.image_sources.append(value) parser=MyParser(formatter.NullFormatter()) parser.feed(open('thepage.html').read()) parser.close() print parser.image_sources Since the tag does not require a closing tag, it is handled by a method called do_img (not start_img and end_img, for opening and closing tags, as others would require). The attributes argument is a list of name/value pairs (2-element tuples), so we just loop on it in our subclass's overriding do_img method to identify the SRC attribute[s] and record their values. Alex From aahz at panix.com Fri Jan 26 10:56:00 2001 From: aahz at panix.com (Aahz Maruch) Date: 26 Jan 2001 07:56:00 -0800 Subject: xor operator? References: <20010126125141.18593.qmail@nw128.netaddress.usa.net> Message-ID: <94s6mg$ju8$1@panix6.panix.com> In article , Thomas Wouters wrote: > >What construction do you need the boolean xor operation for ? Isn't it more >obvious to use an if/elif/else contstruction ? In my case, it was to ensure that one-and-only-one variable was set in a Token class. Okay, so it was a little cutesy and not particularly generalizable, but it was the most compact way of representing the actual control flow at that point. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 'I'm not in the mood to say "yes" today.' --SJM From gerhard.nospam at bigfoot.de Wed Jan 31 15:47:56 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 31 Jan 2001 21:47:56 +0100 Subject: Perl-to-Python converter/translator? References: <959jsd$njn$1@nnrp1.deja.com> Message-ID: <3A7879FC.EA879C9B@bigfoot.de> Lance Sloan wrote: > > I'm an experienced Perl programmer who has just been assigned > a project that must be done in Python. I'm looking for a > Perl-to-Python translator to help me out. I don't expect to > write the whole project in Perl and translate it, though. I'm > just looking for some automation to help me see how my old work > could be done in Python. > > I didn't find anything useful via Google or Vaults of Parnassus > searches. So, I would appreciate any pointers! Maybe the Perl/Python phrasebook at http://starship.python.net/~da/jak/cookbook.html is helpful to you. Intra-document links don't work. Does anybody know a better version of this document? Gerhard -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From mfletch at tpresence.com Mon Jan 15 12:15:34 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Mon, 15 Jan 2001 12:15:34 -0500 Subject: pattern matching in python Message-ID: Ah, but if I were to be resurrected by the power of the Tim, would not the people wonder if I had been corrupted by that power? After all, my animated corpse would probably start wandering around and eating whitespace and such horrors. No, I'll stay here in my quaint little cell. Growing up in Canada has made me appreciate the wonders of hot places, and my new keeper (the pointy-horned one) says I can still post to c.l.py if I promise to make it content-free. And you can drop the pretence now. We all know "Tim" is just a bot whose power supply is held closely in the dictator's right hand. You're not to blame, I suppose. Bots are notoriously given to self-preservation. Still, you might come up with a more "sticky" adjective than "perfidious bones". In example: Dang his too-sweet-to-eat strope-waffling second-hand pronouncements on critical language features! ;-) Darn his diamond-clear-language! Where are the braces? :o) Drat him! When will we be freed from this infinite white space? Where is the spirit of the whitespace-eating nanovirus to free us? You'll have to clean up the hyphenation yourself, that's bot work ;o) . *poof* -----Original Message----- From: Tim Peters [mailto:tim.one at home.com] Sent: Friday, January 12, 2001 5:11 PM To: python-list at python.org Subject: RE: pattern matching in python [Tim] ... Curse me?! I'm not Guido. I curse him too, damn his perfidious Dutch bones. ... feel-free-to-resurrect-if-it's-not-too-late-ly y'rs - tim ... From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Sat Jan 20 18:12:41 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Sat, 20 Jan 2001 23:12:41 GMT Subject: Calling Java Code from CPython (1.5.2 or 2.0) References: <93mdfs$g7q$1@nyheter.chalmers.se> <9471cn$smc$1@violet.singnet.com.sg> Message-ID: In article <9471cn$smc$1 at violet.singnet.com.sg>, ngps at post1.com (Ng Pheng Siong) wrote: > According to Keith Ray : > > I could also imagine a CPython module using JNI functions and Java > > reflection to do a more general-purpose bridge for python. Create > > python > > objects that are bridges to java objects. Forwarding python method > > calls > > to the java objects, converting basic CPython types into Java > > equivalents for argument passing... > > Take a look at Inter-Language Unification (ILU): > > ftp://ftp.parc.xerox.com/pub/ilu/ilu.html Yes, I've looked at that in the past. I was thinking of a light-weight bridge like the Objective-C <-> Java bridge that Apple implement in the open-source Darwin code, WebObjects, and MacOS X. see and -- From fredrik at effbot.org Fri Jan 5 05:42:33 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 05 Jan 2001 10:42:33 GMT Subject: Tkinter and option database References: <9347jc$6iu$1@nnrp1.deja.com> Message-ID: bakaikoa at my-deja.com wrote: > Any hint, do you know of a way of assigning a Tk name > to a widget? http://www.pythonware.com/library/tkinter/introduction/x147-more-on-widget-names.htm "If you really need to specify the name of a widget, you can use the name option when you create the widget. In the following example, the resulting widget is named ".dialog.ok" (or, if you forgot to name the dialog, some- thing like ".1428748.ok"): ok = Button(dialog, name="ok") (follow the link for more info) Hope this helps! Cheers /F From fredrik at effbot.org Tue Jan 9 10:55:42 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 09 Jan 2001 15:55:42 GMT Subject: escape sequences and string comparisons References: <93cboe$ctj$1@nnrp1.deja.com> <93elo7$aoh$1@nnrp1.deja.com> <93f1rd$iv7$1@nnrp1.deja.com> Message-ID: <2wG66.4330$AH6.750256@newsc.telia.net> jkndeja at my-deja.com talks to himself again: > - I still think this makes re.escape() less useful than it > might be. How about a function which turns a string into an 'escaped' > form such that it would be an 'exact' RE match with itself? That's *exactly* what re.escape() does, of course. Cheers /F From jh at web.de Tue Jan 23 18:04:58 2001 From: jh at web.de (Jürgen Hermann) Date: Wed, 24 Jan 2001 00:04:58 +0100 Subject: [ANN] MoinMoin 0.8 Message-ID: <94l379$186$05$1@news.t-online.com> A WikiWikiWeb is a collaborative hypertext environment, with an emphasis on easy access to and modification of information. MoinMoin is a Python WikiClone that allows you to easily set up your own wiki, only requiring a Web server and a Python installation (1.5.2, 1.6 or 2.0). This release adds page templates, an include macro, pluggable actions including a very nice spell checker and "LikePages" navigation. The keywords found via the fulltext search are now highlighted. Finally, "RecentChanges" now shows diffs against the version you last viewed (possibly spanning several changes), which makes it much easier to keep yourself up to date with a wiki's evolution. Homepage: http://moin.sourceforge.net/ Download: http://download.sourceforge.net/moin/ Mailing lists: http://lists.dragon-ware.com/mailman/listinfo/moin-users http://lists.dragon-ware.com/mailman/listinfo/moin-dev New features: * Page templates (create a new page using a template page, by Richard) * Pluggable actions (by Richard) * Added "diff since bookmark" * Only "normal" URLs (outside of brackets) are converted to inline imgs * Show number of backups in SystemInfo macro * Show info on installed extension macros and actions * New macro: [[BR]] for line breaks * New action "LikePages" (again, Richard) * Highlighting of search results, and of bad words when spellchecking * Support for "file:" URLS * "SpellCheck" action (Richard, me, and Christian) * [[Include]] macro (you guessed it, Richard) Bugfixes: * Update bookmark with load time, not click time * Changed CSS styles to better suit Netscape's broken handling of CSS From gry at ll.mit.edu Thu Jan 25 15:49:06 2001 From: gry at ll.mit.edu (George Young) Date: Thu, 25 Jan 2001 15:49:06 -0500 Subject: Python and postgreSQL ?? References: <94pdkp$b9n$1@saltmine.radix.net> Message-ID: <3A709142.29B4FA9A@ll.mit.edu> Cary O'Brien wrote: > wrote: > >I've search unsuccessfully a tutorial about "attack" postgreSQL with Python. > >Can anybody help me? ... > You may want to check out Zope (http://www.zope.org). Zope is a web > application framework that has pretty good support for PostgreSQL (you ... You may also wish to consider the other postgresql/python interface package, PoPy: http://popy.sourceforge.net I find it quite useful. -- Your mouse has moved. Windows NT must be restarted for the change to take effect. Reboot now? [OK] From s2mdalle at titan.vcu.edu Sat Jan 27 13:50:00 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Sat, 27 Jan 2001 18:50:00 GMT Subject: Creating files. References: <3A72FDD0.2C1206CF@hotmail.com> Message-ID: In article <3A72FDD0.2C1206CF at hotmail.com>, "joonas" wrote: > Is there any functions in Python for creating files? > > Joonas. Open it for writing, and that's about it. fp = open("somefile", "w") fp.flush() fp.close() Congrats, "somefile" now exists with a 0 size. Alternately, you could through the shell "touch" the file if you're on a unix system. -- David Allen http://opop.nols.com/ ---------------------------------------- "As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs." - Maurice Wilkes discovers debugging, 1949 From pekko at iki.fi Tue Jan 23 08:43:04 2001 From: pekko at iki.fi (Pekko Piirola) Date: 23 Jan 2001 13:43:04 GMT Subject: Compiling Python 2.0 in DEC Alpha? Message-ID: I'm trying to compile python-2.0 in DEC Alpha, which is running Digital UNIX V4.0F (Rev. 1229). After reading the README and the man page of cc I figured out the commands I need to build the interpreter: (I have already edited the Modules/Setup) CC=cc OPT='-std -arch host -fast -D_REENTRANT -pthread' \ LDFLAGS='-pthread -lpthread -lmach -lexc -lc' \ ./configure --prefix=/usr/local/contrib --with-dec-threads make CC=cc OPT='-std -arch host -fast -D_REENTRANT -pthread' \ LDFLAGS='-pthread -lpthread -lmach -lexc -lc' 2>&1 | tee make.output-1 ./configure runs nicely but make stops with the following error message: --------------------- clip clip clip ---------------------- ( .... some stuff deleted ... ) make[1]: Entering directory `/scratch/ppiirola/Python-2.0/Modules' rm -f hassignal for i in threadmodule.o gcmodule.o bsddbmodule.o regexmodule.o regexpr.o \ pcremodule.o pypcre.o posixmodule.o signalmodule.o _sre.o \ arraymodule.o cmathmodule.o mathmodule.o stropmodule.o structmodule.o \ timemodule.o operator.o _codecsmodule.o unicodedata.o unicodedatabase.o \ ucnhash.o _localemodule.o fcntlmodule.o pwdmodule.o grpmodule.o \ errnomodule.o selectmodule.o socketmodule.o mmapmodule.o md5module.o \ md5c.o shamodule.o rotormodule.o newmodule.o binascii.o parsermodule.o \ cStringIO.o cPickle.o config.o getpath.o main.o getbuildinfo.o; do \ if test "$i" = "signalmodule.o"; then \ echo yes >hassignal; break; \ fi; \ done make[1]: Leaving directory `/scratch/ppiirola/Python-2.0/Modules' cd Parser ; make OPT="-std -arch host -fast -D_REENTRANT -pthread" \ VERSION="2.0" prefix="/usr/local/contrib" exec_prefix="/usr/local/contrib" \ all make[1]: Entering directory `/scratch/ppiirola/Python-2.0/Parser' cc -std -arch host -fast -D_REENTRANT -pthread -I./../Include -I.. \ -DHAVE_CONFIG_H -c -o pgenmain.o pgenmain.c cc: Error: ./../Include/pyport.h, line 390: #error \ "LONG_BIT definition appears wrong for platform (bad gcc config?)." \ (errormessage) #error "LONG_BIT definition appears wrong for platform (bad gcc config?)." -^ make[1]: *** [pgenmain.o] Error 1 make[1]: Leaving directory `/scratch/ppiirola/Python-2.0/Parser' make: *** [Parser] Error 2 --------------------------- clip clip clip ---------------------- Does anyone have an idea what's going wrong or, better yet, how to compile Python succesfully? Is there a bug in the source or in my setup? The compiler I'm using is DEC C V5.9-008 on Digital UNIX V4.0 (Rev. 1229), the make is GNU make 3.79.1 and the source is downloaded straight from Python's server. -- Pekko From zeitlin at seth.lpthe.jussieu.fr Mon Jan 29 10:01:17 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 29 Jan 2001 15:01:17 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> <952lo9$qme$1@nnrp1.deja.com> Message-ID: On 29 Jan 2001 15:02:01 +1100, Timothy Docker wrote: >Neither tkinter or wxWindows are thread-safe in the sense that >multiple threads can make arbitrary GUI calls simultaneously (I'm not >aware of any GUI toolkits that are thread-safe in this sense). This is not completely true: wxWindows does support multiple GUI threads but they are still multiplexed internally using a mutex. So, in principle, you can have multiple GUI threads running simultaneously as the thread sample in wxWindows distribution shows (it is in C++ though). However, having only one GUI thread and several worker threads is by far the preferred approach. Regards, VZ -- GCS/GM d? H+ s++:-- p2 au--- a- w+ v C+++ UBLS+++ P- L++ N++ E--- W++++ M? V-- -po+ R++ G`` !tv b+++ D--- e++++ u++ h--- f+ r++ n- y? From scarblac at pino.selwerd.nl Mon Jan 8 08:20:05 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 8 Jan 2001 13:20:05 GMT Subject: escape sequences and string comparisons References: <93cboe$ctj$1@nnrp1.deja.com> Message-ID: jkndeja at my-deja.com wrote in comp.lang.python: > Since re.escape() simply uses the criterion of 'non-alphanumeric > character' to determine whether to escape a character, is there an > alternative function to 'escape only characters used in string literal > escapes', am I on my own, or am I missing something? Simply using repr (or `` backquotes) gives the string as a string literal, with the necessary things escaped. The only thing is that if there are ' quotes in the string, they aren't escaped, but instead "" quotes are used to surround the string (and vice versa). >>> x = '\\' >>> len(x) 1 >>> print repr(x) '\\' >>> x = "'" >>> print repr(x) "'" So maybe you can use this, maybe you can't. -- Remco Gerlich From jan.dries at dcube-resource.be Sat Jan 13 10:10:06 2001 From: jan.dries at dcube-resource.be (Jan Dries) Date: Sat, 13 Jan 2001 16:10:06 +0100 Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> <3A5E5C21.3E036BFE@intelligenesis.net> <3A5E935D.CF641658@dcube-resource.be> <93mhr60e7e@news1.newsguy.com> Message-ID: <3A606FCE.642F495@dcube-resource.be> Alex Martelli wrote: > I forget the origin of the quote, but -- "there are two approaches > to [coding]: make it so complex there are no obvious flaws, or, > make it so simple there are obviously no flaws". The original quote is this: "There are two ways of constructing a software design; one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C. A. R. Hoare Jan From buster2642 at my-deja.com Thu Jan 4 21:00:49 2001 From: buster2642 at my-deja.com (buster2642 at my-deja.com) Date: Fri, 05 Jan 2001 02:00:49 GMT Subject: newbie : edit sys.path on WinNT Message-ID: <9339sf$fit$1@nnrp1.deja.com> I just installed NumPy16_152 into my 'D:\Program Files\Python' folder. How do I "permanently" add this to sys.path so 'import Numeric' succeeds? I may or may not have admin access to the NT box to do this.. (http://sourceforge.net/projects/numpy has NumPy zip archives for Python 1.52/1.6/2.0 on Win32) Thanks Chuck Sent via Deja.com http://www.deja.com/ From dsh8290 at rit.edu Wed Jan 3 20:13:28 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 3 Jan 2001 20:13:28 -0500 Subject: Registering C methods when writing a C extension type? In-Reply-To: ; from tepperly@llnl.gov on Wed, Jan 03, 2001 at 03:18:58PM -0800 References: Message-ID: <20010103201328.A7834@westsidecnc.rh.rit.edu> Since you have an IDL, doesn't the object already exist? If so, you might want to use one of the python bindings for CORBA instead. For example on sourceforge there is Orbit-Python. Sorry but I don't know anything about extending python in C. -D On Wed, Jan 03, 2001 at 03:18:58PM -0800, Tom Epperly wrote: > I planning to write a C extension type (not module) to provide a Python > binding for an object or interface defined in an IDL (interface definition > language) for high performance scientific computing. From alan.gauld at gssec.bt.co.uk Wed Jan 10 10:00:21 2001 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Wed, 10 Jan 2001 15:00:21 +0000 Subject: Should I learn Python or Java? References: Message-ID: <3A5C7905.A14D24F0@gssec.bt.co.uk> Charlotte Williams wrote: > I am a Visual Basic programmer who wants to increase his knowledge of > programming languages. > I notice that there is a lot of demand for Java programmers. The only > experience I have with an OO language is Smalltalk. My questions are: > 1. Which language would be best to learn, Java or Python. From a VB > standpoint, which has the least learning curve? Given the above the answer must be Python. Python allows you something like the smalltalk workspace for trying out object methods etc on the fly(the interactive prompt/IDLE) and doesn't have the rigid typechecking etc that Java has. Strict typing of variabvles is the biggest shock you are likely to find using Java, not the OO aspects! Python is also more efficient in terms of the number of lines of code to do a given task(around half as many IME) compared to Java (and even less than VB for non GUI work). [ On the other hand there are several good Java IDEs which are more like VB for GUI programming.] But overall, and especially from the language perspective Python is a much better bet. but if you look at it from an employment view I'd have to say Java... > 2. Is going from object-based to object-oriented programming that huge a > jump? Yes. The whjole thinking about OO projects changes when you have real polymorphism and ingheritance available. This changes the way you ddesign and build applications considerably. Don't underestimate the jump but OTOH its certainly not impossible and if you have done much smalltalk then you may already be using VB in an OO way as far as is possible. > 3. Which one is the most "fun" to program in? Python - its just so much faster to get something working and then evolve it as far as you need to go. > 4. Is Python multi-platform? Yes, more so than Java I suspect. > How is it's performance compared to JAVA in an internet situation? Not quite sure what you mean by the last bit but its at least as fast as the Microsoft JVM. I believe the new JIT compilers (hotspot etc ) might give Java a lead here. > It's reliability? If you write good programs they are as good as each other (see another current thread!) > 5. Do you for see Python as becoming a major player like > Java servlets and MTS? Can you see Python demand > outstripping Java demand in 2 years time? Unfortunately not. Python is growing and there are certainly jobs around but Java is HUGE just now. > I'm really interested in hearing from VB programmers that decided to jump > into one or both of the languages, I came to Python from C++/Delphi/Smalltalk and Java with a smattering of VB5(CCE). Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From sharmad at im.eth.net Sat Jan 27 00:12:44 2001 From: sharmad at im.eth.net (Sharmad Naik) Date: Sat, 27 Jan 2001 10:42:44 +0530 Subject: compiling Python with PostgrSQL Message-ID: <00eb01c08820$3d02d260$25090b3d@SharmadNaik> I want to compile python with postgres so initially while compiling postgres i did ./configure --with-python later i went to /postgres7-.0.2/src/interfaces/python copied pymodule.c where Setup file is and added a line as instructed in the README file but the moment i issue the first command i get an error given in the attachment Please if possible have a look at it i donot know what to do.please help me TIA Sharmad -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Fault.dat Type: application/octet-stream Size: 456 bytes Desc: not available URL: From grante at visi.com Wed Jan 10 14:56:14 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 10 Jan 2001 19:56:14 GMT Subject: Silly question from a newbie References: <93hk9p$g5m$1@newshost.accu.uu.nl> Message-ID: In article <93hk9p$g5m$1 at newshost.accu.uu.nl>, Martijn Faassen wrote: >> I downloaded the 'Grail' browser made with Python.... but, >> being someone who only just heard of Python 2 days ago, I don't >> know how to start the Grail browser. [...] >Hm, I'm not quite sure what the status of Grail is, but it >hasn't been worked on for some years, as far as I know. So I'm >not entirely sure if it's in running condition. I tried it a few months ago and couldn't get it to work (I didn't spend much time on it). If you're looking for example Python apps, I'd probably recommend something else. If you want to see a full-up Tk app, sketch is pretty cool: http://sketch.sourceforge.net/ If you want to look at something trivial (but still cool, IMO), I've done a demo of the 8-queens puzzle at: ftp://ftp.visi.com/users/grante/python/queens.py -- Grant Edwards grante Yow! Hey, LOOK!! A pair of at SIZE 9 CAPRI PANTS!! They visi.com probably belong to SAMMY DAVIS, JR.!! From dsh8290 at rit.edu Wed Jan 24 16:36:06 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 24 Jan 2001 16:36:06 -0500 Subject: PSU uses emacs? In-Reply-To: <3a6eb2fa.2347467@reading.news.pipex.net>; from ray_drew@yahoo.co.uk on Wed, Jan 24, 2001 at 10:56:42AM +0000 References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> <3a685ef2.3403798@reading.news.pipex.net> <949rii0a76@news1.newsguy.com> <3a6eb2fa.2347467@reading.news.pipex.net> Message-ID: <20010124163605.A26798@harmony.cs.rit.edu> On Wed, Jan 24, 2001 at 10:56:42AM +0000, Ray Drew wrote: | [snip] | | I'm having problems getting the indentation right with gvim. I've got | the following in my .vimrc file: | | au FileType py set ts=4 | au FileType py set sw=4 | au FileType py set expandtab on | au FileType py set ff=unix | | as far as I can make out from the docs, this should set those options | for all .py files. Tabs appear as 4 chars in gvim but when viewed in | an IDLE edtor window, tabs appear as 8 and throw a syntax error when | imported (files originally created in IDLE with tab space of 4). Do I | need to do anything else to get this to work? This results from the interpreter counting a character as equal to 8 spaces, but you are looking at it like it is 4. This causes problems if you mix tabs and spaces. IMO, you shouldn't set ts at all. Leave it at 8. Instead, set sw=4 (as you did) and sts=4 . sts is softtabstop. It affects the way vim acts when you do indentation operations like >> << and press the button on the keyboard. I leave tabstop=8 and set shiftwidth and softtabstop to the indentation level I want. Also, setting expandtab (as you tried to do) is good for replacing tab chars with space chars (based on the sts variable) when inserting. If you only use space characters in files you will have no trouble when switching editors. HTH, -D | | Ray Drew | CIA UK | From clarence at netlojix.com Sun Jan 28 00:21:03 2001 From: clarence at netlojix.com (Clarence Gardner) Date: Sat, 27 Jan 2001 21:21:03 -0800 Subject: . Python 2.1 function attributes References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> <14962.62953.304511.523826@anthem.wooz.org> Message-ID: <980659490.312565807@news.silcom.com> On Sat, 27 Jan 2001, Roy Katz wrote: >Given Python's current "there's a right way to do it" motto, and >its recent TMTOWTDIfication, perhaps a more fitting one would be >"yeah, but so-and-so came up with a patch, and we couldn't resist, so we >included it. So deal." History of the World. Now there is print>> and >write(). I call for boycotting print>>. I expect one person, maybe less, >to support me on that. I was somewhat amazed at the addition of print>>, and I assure you that I will never use it. But since I consider Guido, et al, as nearly godlike, and given that the last four years of my programming career have been much more joyful than they would have been without Python, I have magnanimously given him a pass on this issue :) -- Clarence Gardner Software Engineer NetLojix Communications clarence at netlojix.com From teep at inet.co.th Sat Jan 6 22:48:15 2001 From: teep at inet.co.th (Prateep Siamwalla) Date: Sun, 7 Jan 2001 10:48:15 +0700 Subject: Should I learn Python or Java? References: <938h6r$26j$1@troll.powertech.no> Message-ID: <938ops$b51$1@news.inet.co.th> I second that recommendation. Awesome book. Programming python using Mark Hammond's excellent contributions on Win32 + COM stuff, you'd also find yourself in a better position to interface with the usual Microsoft suspects (Word/Excel/PPT) than you would, should you be working in Java. (Anyone out there, correct me if I am mistaken about this) -teep Syver Enstad wrote in message news:938h6r$26j$1 at troll.powertech.no... > "Charlotte Williams" wrote in message > news:HEO56.5504$y9.2881293 at typhoon.we.rr.com... > > Hi Charlotte, I don't know what languages you should learn (probably best to > learn them all), but for windows programming with Python and considering > your VB background you really should buy/borrow/steal a copy of Python > programming on win32 from O'Reilly. I started with Python a couple of months > ago with that book and can recommend it warmly. > > From fredrik at effbot.org Thu Jan 11 14:00:26 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 11 Jan 2001 19:00:26 GMT Subject: NewBie: How Can I Scan The Keyboard In Python? References: <93ku2c$gtr$1@nnrp1.deja.com> Message-ID: jbranthoover at my-deja.com wrote: > Is there a way to scan the keyboard to watch for a key > closure? http://www.python.org/doc/FAQ.html#8.2 "8.2. How to check for a keypress without blocking? "Use the msvcrt module. This is a standard Windows-specific extensions in Python 1.5 and beyond. It defines a function kbhit() which checks whether a keyboard hit is present; also getch() which gets one character without echo. Plus a few other goodies." for more info, see the library reference. Cheers /F From quinn at groat.ugcs.caltech.edu Mon Jan 29 22:08:27 2001 From: quinn at groat.ugcs.caltech.edu (Quinn Dunkan) Date: 30 Jan 2001 03:08:27 GMT Subject: Pyditor, Text editor fully extendible in python a la' Emacs References: Message-ID: >> There is already a project like this? (btw, i dont like wily :) Oops, I responeded saying acme / wily do almost all of these already before getting here :) Except they do the 'everything reachable with menus' one better by having everything reachable in plain sight. And instead of 'all modules configurable from one interface' it's 'only one interface period, and no module configuration required' :) I guess the point is that if you want something just like everything else out there, but with python, there are a million editors already like that, and making yet another "new" one only-with-python, or retrofitting python to an old one is not going to let you do anything you couldn't before. That's just my personal experience, having used a number of editors scriptable with python, and finding out that python added very little (except a lot of extra code and startup time to the editor). Maybe just me, though. wily could certainly be improved (mostly by becoming more like acme :) i.e. plumbing instead of hard coded search patterns, better script interface, etc.) but it seems like a good place to start, unless one disagrees with its There's A Right Way To Do It principle (if so, why all the interest in python support? ). From wolfson at midway.uchicago.edu Sun Jan 14 23:09:44 2001 From: wolfson at midway.uchicago.edu (Ben Wolfson) Date: Mon, 15 Jan 2001 04:09:44 GMT Subject: P*rl in Latin, whither Python? References: <3A0B62B7.59A43E13@gte.net> <974070178.345720@clam-ext> <979516309.507737@clam-ext> Message-ID: In article <979516309.507737 at clam-ext>, Mark Hadfield wrote: >"J?rgen A. Erhard" wrote in message >news:mailman.979323254.7670.python-list at python.org... >> >> Mark> People in glace houses shouldn't throw stones. >> >> Just an illustration of the truism that every spelling flame contains >> at least on [sic] spelling error itself. ;-) >> >> PS: Was that "glace" mistake intended? ;-) ;-) > >What mistake? > >P.S. I've completely forgotten what this thread is about. This! Eventually python will look like this! ''' import rearrangeabuse (Begin, (Import, 'sys'), (Print, (Getattr, 'sys', 'argv'))) ''' Which runs fine for me: C:\Python20>python test1.py ['rearrangeabuse.py', 'test1.py', '2'] -- Barnabas T. Rumjuggler My wine of life is poison mixed with gall. -- James Thompson, "The City of Dreadful Night" From nickm at mit.edu Mon Jan 15 23:39:47 2001 From: nickm at mit.edu (Nick Mathewson) Date: Tue, 16 Jan 2001 04:39:47 GMT Subject: Determining names of instances References: Message-ID: On Mon, 15 Jan 2001 14:42:52 -0800, Daniel Klein wrote: >A question I hope has a simple answer. Take the following simple class and >instance > > class foobar: > pass > > foo = foobar() > >The question is, is there a way for the object 'foo' to know that its name >is 'foo'? > >Daniel Klein The short answer has been provided by others: not really. The long answer is: yes, but you wouldn't want to. # varname.py from types import * import sys # We need python 2 assert sys.version_info[0] >= 2 def varname(object,depth): try: raise "" except: frame = sys.exc_traceback.tb_frame.f_back seen={} refs = [lr[1:] for lr in _searchInDict(object, frame.f_locals, depth, seen, 1) ] if frame.f_globals is not frame.f_locals: refs += [gr[1:] for gr in _searchInDict(object, frame.f_globals, depth, seen, 1) ] return refs def _search(obj, target, depth=1, seen=None): if seen is None: seen = {} #if seen.get(id(target)): # return () #seen[id(target)] = 1 if obj is target: return [""] if depth <= 0: return [] t = type(target) if t is ClassType: return _searchInDict(obj, target.__dict__, depth, seen, 1) elif t is DictType: return _searchInDict(obj, target, depth, seen, 0) elif t is InstanceType: x = _searchInDict(obj, target.__dict__, depth, seen, 1) return x+_searchInDict(obj,target.__class__.__dict__,depth,seen,1) elif t in (ListType, TupleType): return _searchInSeq(obj, target, depth, seen) elif t is ModuleType: return _searchInDict(obj, target.__dict__, depth, seen, 1) return [] def _searchInDict(obj,dict,depth,seen,isAttr): lst = [] for k,v in dict.items(): if v is obj: lst.append( (isAttr and "."+k) or "[%s]"%`k` ) else: for x in _search(obj,v,depth-1,seen): lst.append( (isAttr and ".%s%s" %(k,x)) or "[%s]%s" %(`k`,x) ) return lst def _searchInSeq(obj,seq,depth,seen): lst = [] for i in range(len(seq)): if seq[i] is obj: lst.append( "["+i+"]") elif depth: for x in _search(obj,seq[i],depth-1,seen): lst.append("["+i+"]"+x) return lst ###### Use: >>> from varname import varname >>> x = "Hello world" >>> varname(x, 1) ['x'] # Ok, that worked... >>> p=y=t=h=o=n = x >>> varname(x, 1) ['y', 't', 'p', 'n', 'o', 'h', 'x'] #... but what is the true name of 'x'? >>> x = "Goodbye simplicity" >>> varname(x, 6) ["sys.modules['__main__'].x", "sys.modules['sys'].modules['__main__'].x", 'x'] # ... and which of these is the name of 'x' now? ###### The moral is a corolary to Fredrik Lundh's cat analogy: Although your neighbors (namespaces) can tell you the names they call the cat (object), and although they can tell you what names that their friends call the cat -- if you really want the cat (object) to have a name of its own, you'll need to put a tag around its neck (set an attribute). Too-much-time-on-my-hands-too-look-in-the-archive-ly y'rs, -- Nick Mathewson without the zees. From rickamores at hotmail.com Tue Jan 23 17:04:51 2001 From: rickamores at hotmail.com (Rick Amores) Date: Tue, 23 Jan 2001 17:04:51 -0500 Subject: If I was recruiting Python people were is the best place to go Message-ID: <94kvqa0g4t@enews2.newsguy.com> Be nice From m.faassen at vet.uu.nl Sat Jan 6 00:29:31 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 6 Jan 2001 05:29:31 GMT Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <933fa1$j2i$1@newshost.accu.uu.nl> Message-ID: <936afr$g8k$1@newshost.accu.uu.nl> Joel Ricker wrote: > Martijn Faassen wrote in message <933fa1$j2i$1 at newshost.accu.uu.nl>... [snip] > From your examples, Pythons class model is much cleaner. It definitely looks and feels cleaner to me! > Also if I understand your example, variables internal to the object are kept > internal -- they can't be accessed without a proper method. With perl > anything goes. There are some techniques to prevent this but it isn't > definite. Its actually this very topic that made me throw my new OO book > across the room and subscribed to this newsgroup :) Actually, no; with Python anything goes as well, it's just that we know to restrain ourselves and generally we don't access attributes directly. There's an idiomatic way to indicate 'this is private', which has no practical effect whatsoever, which is to prepend an underscore in front of the attribute or method you want to be private (or protected, for that matter): class Foo: def __init__(self): self._private = 1 def _privateMethod(self): pass There is also another way that *does* have an effect on the language, though it doesn't go very deep (it does some name mangling), which is to prepend two underscores in front of the thing you want to be private. Note that this also disallows easy use from subclasses and such, so I generally don't bother to use that and use the single underscore convention. [snip] > I've mentioned before that I'm real new to OO. How should I approach it in > Python? Python is a nice language to do OO in, I think, because it doesn't burden you with too much baggage; static type checking in particular adds a lot of programmer overhead that Python luckily doesn't have. That said, it may be possible that static type checking makes OO more clear for some people -- since Python is very liberal in what it allows you to do, you do have to know how to restrain yourself. > Has anyone learned OO just from Python? Or should I study OO > theory else where and then apply it to Python? I already knew OO before I came to Python, so I don't really know. However, I'd consider Python a good language to learn OO in, even though it calls for a little more programmer self-restraint, it isn't very difficult to do this, and it's not as if C++ or Java don't call for plenty of programmer discipline all over the place either -- more so than Python. > I know this is bordering on > the question of how do I do OO but I really know very little about it... > enough to know that I can benefit from it and basic ideas. I understand the > idea of a class and building objects from it but anything beyond that is > still really new to me. Any suggestions? What's nice about OO is that it allows you to decouple the interface from the implementation, and thereby it allows easy forms of polymorphism. That sounds complicated perhaps, but imagine you have a game which contains a bunch of objects; monsters of various kinds for instance. Now imagine we have a list filled with a number of different monsters, and each type of monster can be activated. When activated the monster will do something, dependent on what type of monster it is, and perhaps various other factors. If you don't use OO in your Python program (just using classes as a form of record), code to do that may look somewhat like this: # just an empty record we'll fill later; an empty dictionary is virtually # the same in Python, in fact. class MonsterRecord: pass # create a record for a monster and fill it with data green_monster = MonsterRecord() green_monster.type = "GREEN_MONSTER" green_monster.strength = 15 # create purple monster purple_monster = MonsterRecord() purple_monster.type = "PURPLE_MONSTER" purple_monster.strength = 10 # create orange monster orange_monster = MonsterRecord() orange_monster.type = "ORANGE_MONSTER" orange_monster.strength = 20 # another one, but weaker orange_monster2 = MonsterRecord() orange_monster2.type = "ORANGE_MONSTER" orange_monster2.strength = 10 # put them in a list monsters = [green_monster, purple_monster, orange_monster, orange_monster2] # a function that given a list of monster, performs action for each of them def perform_actions(monsters): for monster in monsters: if monster.type == "GREEN_MONSTER": print "The monster says: Booh!" elif monster.type = "PURPLE_MONSTER": print "The monster sings: We are a happy family!" elif monster.type = "ORANGE_MONSTER": print "The monster says: monster wants orange!" if monster.strength > 15: print "The monster grabs your orange and eats it!" # and call the function perform_actions(monsters) ######################## Now we'll do the same, OO style: class Monster: def __init__(self, strength): self.strength = strength class GreenMonster(Monster): def action(self): print "The monster says: Booh!" class PurpleMonster(Monster): def action(self): print "The monster sings: We are a happy family!" class OrangeMonster(Monster): def action(self): print "The monster says: monster wants orange!" if self.strength > 15: print "The monster grabs your orange and eats it!" # create some monsters and put them in a list monsters = [GreenMonster(15), PurpleMonster(10), OrangeMonster(20), OrangeMonster(10)] # and the function to perform all actions def perform_actions(monsters): for monster in monsters: monster.action() # let's call it perform_actions(monsters) In the OO example I've exploited a number of features generally associated with OO programming (though good non-OO and OO programming styles aren't far away): * interface/implementation separation leading to polymorphism The most important; it's easy to add new monsters with different behavior, without having to change anything in perform_actions(). In the non-OO example, we'd have to extend perform_actions() each time we have a new monster. For a single type of action (method) this is okay, but in real programs this generally isn't the case; and then you'd need to go through your program and add actions all over the place. You can do the same with a dictionary (hash table) indexed by monster type and returning some function to call, but why do it the hard way when there's an easy way (use classes and method). * inheritance Neat, but less essential to OO than is often thought. Since all monsters in my example have a 'strength' attribute, I've made all monsters inherit from the 'Monster' superclass, which has.. * a constructor A constructor that sets the strength attribute. Constructor functions returning a record are of course not hard to do in a non OO way. I've been talking about monsters in my example, but it could apply to GUI widgets, or different type of objects that can all be treated as files (on disk file, in memory file, even network transparent file if you wanted to), and so on. A good book to learn more about common structures you can find in OO programs is "Design Patterns". >>The Python community's reputation is that it's friendlier than the Perl >>community, the flame war about variable initialization in the do..until >>thread notwithstanding. :) > I heard something about curley braces as well. No {} for blocks? Thats > going to take some getting used to :) It's easier to get used to than most people think. I was used to it within a few days at most; I was definitely used to { and } before that. Using an editor that supports Python's indentation helps -- I myself am happy with Python mode for emacs, which you can find on the Python website. >>I've seen people beinn pleasantly surprised by the quality of answers >> they've received in this newsgroup, so you may like it. > I know I have been. Nothing like a friendly newsgroup to convince me to > switch -- at least take a break from perl for awhile to see how the other > side lives. Great! I'm probably repeating answers others have already given -- I saw the thread has grown. I'll go read it now myself. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From andreas at andreas-jung.com Sat Jan 27 12:28:02 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Sat, 27 Jan 2001 18:28:02 +0100 Subject: Python 2.1 slower than 2.0 Message-ID: <20010127182802.A21904@yetix.sz-sb.de> pystone.py with Python 2.0: ~3600 Pystones/sec Python 2.1: ~3000 Pystones/sec Env. Linux i386, AMD-K2 300 MHz Is there a reason why 2.1 runs significantly slower ? Both Python versions were compiled with -g -O2 only. Andreas From andreas at andreas-jung.com Wed Jan 17 13:36:31 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Wed, 17 Jan 2001 19:36:31 +0100 Subject: help with code for combinations/permutations In-Reply-To: <3A65D89D.E8366B3D@san.rr.com>; from dnew@san.rr.com on Wed, Jan 17, 2001 at 05:38:37PM +0000 References: <944adl$2bf@dispatch.concentric.net> <3A65D89D.E8366B3D@san.rr.com> Message-ID: <20010117193631.A32265@yetix.sz-sb.de> On Wed, Jan 17, 2001 at 05:38:37PM +0000, Darren New wrote: > Oh, and it's a 1-liner in APL. ;-) I am sure it will also fit with some lambda magic into one line of Python :) Andreas From bxt at nospam.nospam Tue Jan 9 11:02:23 2001 From: bxt at nospam.nospam (BxT) Date: Tue, 9 Jan 2001 17:02:23 +0100 Subject: string escaping problems with MySQLdb References: <93f2cr$ofq$1@news2.dtag.de> <7ZF66.128944$15.27235477@news1.rdc1.az.home.com> Message-ID: <93fbsp$8d$1@news2.dtag.de> Ok, this seems to solve my problem. Note that i was not clear before: when i said that i was getting \\337 is because the string i was getting from the database was of the kind myString="blah\337" and i used print `myString` so i "discovered" the double backslash. I will dive more deeply in the manuals, but for now, thanks! BxT "Tim Hochberg" ha scritto nel messaggio news:7ZF66.128944$15.27235477 at news1.rdc1.az.home.com... > > The mysterious BxT spake thusly: > > > Hi, i know this is a new-bie question, > > i'm using MySQLdb and, as i'm extracting records, i get string escaped as > > follows: > > for example, instead of ? i'm getting \\337 (yes, with doppel \). When i'm > > printing the string i'm getting blah\337 (internally is blah\\337). > > The string you are getting only has a single '\', it is displayed with two > because a "\337" is the escape code for the beta symbol. Hmmm, that's not > very clear, I suggest you peruse the manual and or play around till this > becomes clear. However, the difference you are seeing the string displayed > in the interpreter and the string printed is that printing formats stuff > using the str function, while in the interpreter repr is used. > > >I tried > > to use string.replace but it's giving me the same string. Is there a way > to > > print blah?? > > I'm sure there's a better way, but: > > import re > print re.sub(r"\\(\d\d\d)", lambda x : chr(int(x.group(1),8)), myString) > > or more clearly: > > escapedOctal = re.compile(r"\\(\d\d\d)") > def matchToChr(match): > n = int(match.group(1), 8) > return chr(n) > > print re.sub(escapedOctal, matchToChr, myString) > > > I'll let you figure out how that actually works.... > > -tim > > > > From dsh8290 at rit.edu Thu Jan 11 20:05:05 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 11 Jan 2001 20:05:05 -0500 Subject: Python Design Patterns (was Re: Should I learn Python or Java?) In-Reply-To: <3A5DF377.791E3DE0@comm.mot.com>; from stepheb@comm.mot.com on Thu, Jan 11, 2001 at 11:55:04AM -0600 References: <978840685.459818@emperor.labs.agilent.com> <3A5DF377.791E3DE0@comm.mot.com> Message-ID: <20010111200505.D20125@dman.rh.rit.edu> On Thu, Jan 11, 2001 at 11:55:04AM -0600, Stephen Boulet wrote: | Brian Zhou wrote: [snip] | | Can anyone recommend some literature about design patterns that would be | helpful to someone learning to program python? | There's always the Gang of Four book "Design Patterns". For the examples they use mostly C++ with some Smalltalk. Some things would be implemented quite different in python (such as Singleton) due to python's nice dynamic nature. I'm interested to know if there is any literature re Python specific design patterns (or the Pythonic way of implementing the Gang of Four's patterns). -D From m.wilson at bibliocraft.com Thu Jan 25 18:22:42 2001 From: m.wilson at bibliocraft.com (Mark Wilson) Date: Thu, 25 Jan 2001 23:22:42 -0000 Subject: removing duplicates from .csv files Message-ID: <016001c08725$de361580$2a824ac3@mwdell1> Rob Andrews: >I have been given several comma-delimited (.csv) files, > each containing as many as several thousand lines of >entries. Among the tasks I've been charged with is to >remove duplicate entries. The files each contain fields for >Contact Name, Company Name, Phone Number, and Address, >among other fields, which vary from file to file. [ ... ] >Has anyone already worked out a good approach? Can't say that we've "worked out" something, but I do have experience de-duping a similar kind of data set. Maybe this seems like overkill, but I'd suggest stuffing all your data into a database (one with an interface to Python of course - eg MySQL) and then use database queries to locate records with duplicate entries. One benefit of this approach is that you can use "Like" (with wildcards) to locate a series of records. This will allow you to identify that "Mr X. Y. Smokealot" is the same guy as "Xavier smokealot" (using a select where name like "%x%smokealot%" ). MySQL also supports regular expressions in its where statements, which may be useful. Obviously, you'll need to write code to scan through what's there (eg get the list of all names), abstract it a bit (get just surname and initial ) generate suitable queries therefrom, and examine the results ( eg check that X. Y. Smokealot works at the same place as Xavier smokealot ). Given the nature of the inconsistencies you're likely to find in a data set prepared by a human being, you could spend a long time writing such code to catch all possibilities, so I'd also suggest that a framework in which you can perform manual searches, and edit records (including copy/paste of text) is going to be essential to get the data perfect. Its pretty easy to get MySql up and running, and hooked into Python, and getting your data into MySQL is trivial (OK your files contain different fields, but you could account for that using Python to import data, or use Excel to create a set of csv files with common fields and import directly into the database). You could then spend time writing Python code to focus on the more esoteric de-duping issues, rather than re-inventing functionality that is already present in a database engine. Some of the UI bits that come with MySQL could be handy too for those final tweaks. Others may have other ideas, but I hope that helps. Mark From kno at jtan.com Sat Jan 13 17:44:38 2001 From: kno at jtan.com (Matt Dunford) Date: Sat, 13 Jan 2001 22:44:38 GMT Subject: A small suggestion for Python References: <3A5F27F7.30268D9A@erols.com> Message-ID: "Edward C. Jones" writes: >I have been programming in Python for several years. I still >occasionally make mistakes with functions (such as sort) that >return only "None". I suggest that functions like sort should >return either "Nothing" or nothing. "Nothing" would be exactly >like "None" except it can't be assigned. Whether "Nothing" or >nothing is used, the statement "x= y.sort()" would raise a >run-time Exception. >Thanks, >Ed Jones I'm not too fond of this idea. If you misuse a method, whose fault is it? Python's or your own? I think we should keep sort the way it is. Although, I wouldn't mind having a builtin method that returns a sorted array. Then we could do something like this: dict = { 'this' : 1, 'that' : 2 } for key in dict.keys().sort(): print key -- From weiming at cnri.reston.va.us Sat Jan 20 20:54:36 2001 From: weiming at cnri.reston.va.us (Weiming He) Date: Sat, 20 Jan 2001 20:54:36 -0500 Subject: Help for DCOracle examples References: Message-ID: <3A6A415B.D83D6173@cnri.reston.va.us> Oleg: I am so pleased that you give me examples regarding DCOracle. But I might missed something here. Look at my two sessions: 1. >>> import Buffer, oci_, sys >>> dbc=Connect("weiming/weiming") >>> c=dbc.cursor() Traceback (innermost last): File "", line 1, in ? AttributeError: 'Connection' object has no attribute 'cursor' >>> c=dbc.Cursor() Traceback (innermost last): File "", line 1, in ? AttributeError: 'Connection' object has no attribute 'Cursor' It complained AttributeError, regarding 'Connection' object has no attribute 'Cursor' 2. >>> import Buffer, oci_, sys >>> dbc=Connect("weiming/weiming") >>> c=oci_.newCursor(dbc) >>> c.execute("select * from emp") Traceback (innermost last): File "", line 1, in ? AttributeError: execute It complained AttributeError too. I saw your examples are prefect, but I am wondering why I have these AttributeError above. May I missed something? On your examples, you have 'from DCOracle import Connect', where is DCOracle? I only have oci_.so, Buffer.so, does them generate DCOracle? From README.txt in release didn't say that. I am sorry for having so many questions to ask you. But I am really appreciate you would like to give me some your good idea and advises. Thank you very much. Weiming He Oleg Broytmann wrote: > On Fri, 19 Jan 2001, Weiming He wrote: > > Thank you for your response. I got compile and link to Buffer.so and oci_.so. > > Since it only has > > one connection test python program with the release, can you point me where can > > I find examples including > > query, insert, update and etc. Or if you have some, would you please show me > > one or two. > > Thank you very much. > > (JWT = jwt.com = J. Walter Thompson; once I wrote a site for their > Russian branch jwt.ru; the site was not deployed) > > ----- file jwt_connecnt.py ----- > jwt = None > > import os > os.environ["ORACLE_HOME"] = "/usr/local/oracle/app/oracle/product/8.0.5" > os.environ["NLS_LANG"] = "AMERICAN_AMERICA.CL8KOI8R" > > def jwt_connect(login="xxx", password="yyy", SID="jwt_cm"): > global jwt > from DCOracle import Connect > jwt = Connect("%s/%s@%s" % (login, password, SID)) > ----- /file jwt_connecnt.py ----- > > ----- file test1.py ----- > #! /usr/local/bin/python -O > "Simple test" > > from jwt_connect import jwt_connect > jwt_connect() > from jwt_connect import jwt > > cursor = jwt.cursor() > format = "%s | "*13 + "%s\n" > > cursor.execute("SELECT * FROM sides_view") > while 1: > olist = cursor.fetchmany(10) > if not olist: break > for row in olist: > sys.stdout.write(format % row) > > cursor.close() > jwt.close() > ----- /file test1.py ----- > > ----- file test2.py ----- > #! /usr/local/bin/python -O > "LOB (large objects) and procedures example" > > from jwt_connect import jwt_connect > jwt_connect() > from jwt_connect import jwt > > #infile = open("xxx", 'r') > #data = infile.read() > #infile.close() > > print "Creating..." > id = jwt.procedures.add_side_image(1028, 1423) > print "New id =", id > > print "Loading image..." > try: > jwt.execute("""SELECT the_image FROM images > WHERE id_image = %d > FOR UPDATE OF the_image""" % id) > > lob = jwt.fetchone()[0] > lob.write("xyzzy") > > finally: > jwt.close() > ----- /file test2.py ----- > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. From tim.one at home.com Mon Jan 29 05:36:11 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 29 Jan 2001 05:36:11 -0500 Subject: invalid-token syntax hook (was Re: Hack request: rational numbers) In-Reply-To: <950vg1026tu@news2.newsguy.com> Message-ID: [Tim] > That said, I believe your only hope of getting new literal syntax is to > embed it in a general proposal. ... [Alex Martelli] > What I was thinking, too. So what about the "invalid-token syntax > error hook" idea -- whenever the compiler is about to raise a > SyntaxError because of an invalid token ('3r','@@x',etc), if > sys.invalidTokenHook (or something of that ilk) is set to some > callable, that callable is invoked, passed the invalid-token string, > and given a chance to either return None (confirming that, yes, it > IS a syntax error) or a tuple (possibly empty or singleton) of tokens > to be used instead. I think there are technical and philosophical reasons that won't fly. Primarily, Guido would be appalled by any scheme that can take an arbitrary sequence of characters and let people call that "Python". Technically, schemes that rely on compiler internals probably can't be extended to all the tools I mentioned before (e.g., *lots* of tools "parse" Python via half-assed regexp tricks now, but with the right half of the ass needed to get the pieces they're looking for). The compiler internals are dicey too. For example, look closely at "3r". That's not an invalid token today, it's a sequence of two valid tokens. Python doesn't complain about 3r at the lexer level, it complains after failing to find any *grammar* production matching the "3" "r" token sequence. Note that >>> 3or 2 3 >>> is legit Python today (just making concrete that digit letter+ is not an error at the tokenization level). Similarly, "@@x" is a sequence of two illegal characters followed by a legit token. If Python got hooked, it would complain about the first "@" and that's that -- it would not have even gotten around to reading the following "@x" by then. > Not sure how (if?) a module specifies what hook it wants to > be set during its own compilation -- perhaps it can't, in which > case a module whose source contains syntactically invalid > tokens can only be compiled after 'something else' has set > the (global?) hook 'appropriately'. > > No, doesn't look like a necessarily great idea to me, either. I expect that while the technical problems would prove solvable given extraordinary effort (i.e., fat chance ), the philosophical objections would be fatal anyway. > It allows a very modest amount of syntax extension (token > level only -- really nothing more than the sugariest kind) > and modules using it become not-understandable unless > what hook they use is known/documented. At least it does > not allow _altering_ syntax in general (as only currently > invalid tokens would ever been passed to the hook), but, > it _would_ make it harder or impossibly to extent this > level of syntax in the future (a currently-invalid token could > not become valid in the future without risking a breakage > to some existing hook). > > Consider it a strawman just to try and fathom if there IS > some halfway-good general idea for extensibility... We *might* get somewhere being even less ambitious. Perhaps by extending Python's grammar in a *fixed* way, so that every tool can learn to deal with it via "cheap tricks", and no compile-time hooks are needed to decide whether a piece of text *is* Python code. The simplest thing I can think of would be to allow any letter as a prefix to a string (instead of just the [uUrR] allowed today), and ditto for a suffix on "a number" (instead of just [lL] today). But screw strings, since everyone who ever brings this up complains they hate typing strings anyway (e.g., Fixed("3.45") and Rational("3/4") are always rejected by people who want fixed-point decimal and rational types). That leaves numbers, and rat = 3/4r to divide int 3 by Rational 4, or my_base10_float = 3.45d wouldn't cause much trouble at compile-time. Presumably the earlier >>> 3or 2 would become illegal (since it's now two adjacent numeric tokens), but I don't think Guido would mind that (e.g., IDLE doesn't colorize it correctly today, and I believe that's intentional). The compiler could simply generate code to call a new function, say, sys.user_literal(basestring, tags) so that rat = 3/4r would compile "as if" rat = 3 / sys.user_literal("4", "r") had been written, and my_base10_float = 3.45d as if my_base10_float = sys.user_literal("3.45", "d") Then the user would be responsible for plugging in a suitable user_literal function at runtime, before any module using the feature got imported. Damned cute: If I decorated all my floating-point literals with a "d" suffix, then I could run an algorithm once with a hook that converted the literals to builtin floats, and then change the hook to convert to an emulation of floats with twice the precision and run it again. That's a wonderful way to get a quick feel for whether native float precision is suffering catastrophic numeric errors. Or run it again changing the hook to convert them to rationals, and get an exact result (if the operations were just simple arithmetic). Heck, the body of a function could dynamically set the hook based on the type of an argument, giving the effect of truly polymorphic literals. Could be very useful, to an ever decreasing audience <0.5 wink>. That's the best I can do in 15 minutes, but afraid that's all the time I've got now ... do-the-simplest-thing-that-could-possibly-get-rejected-ly y'rs - tim From scarblac at pino.selwerd.nl Fri Jan 12 02:30:45 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 12 Jan 2001 07:30:45 GMT Subject: isnumeric (mhlib.py) References: <3A548B2A.B45DC580@cs.utwente.nl> Message-ID: Richard van de Stadt wrote in comp.lang.python: > I needed a function to check if a string is a number. If you are using Python 1.6 or 2.0, strings have the isdigit() method: >>> x = "0" >>> x.isdigit() 1 >>> x = "1234" >>> x.isdigit() 1 >>> x = "1234a" >>> x.isdigit() 0 -- Remco Gerlich From wlsonna at attglobal.net Fri Jan 5 21:33:00 2001 From: wlsonna at attglobal.net (William Sonna) Date: 6 Jan 2001 02:33:00 GMT Subject: A single, general looping construct? (was: why no "do : until"?) References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <92qc21$538$1@nnrp1.deja.com> <0O7zTzsxerl5-pn2-SISYKtwXTOmR@bill> <931lji02ik1@news2.newsguy.com> <0O7zTzsxerl5-pn2-DVVVoFhFP1jH@bill> <934sg602sfh@news2.newsguy.com> Message-ID: <0O7zTzsxerl5-pn2-d47FDdZYq25y@bill> On Fri, 5 Jan 2001 16:23:46, "Alex Martelli" wrote: [snip] > > So what's the deal with Python? > > It's a general-purpose programming language, with no need for > any special compatibility with existing ones. I was going to drop this, Alex, but I simply CAN'T let a statement like that go by unchallenged, so (with apologies)......... .......Since you haven't backed this seemingly sweeping statement up with any examples, would you mind explaining what you mean by "special" compatibility? > Having a general > construct, introducing equivalent ones for several special > cases would be unPythonic. (You'll hear no Pythonista claim > the re sublanguage is highly Pythonic, I'm sure -- particularly > since it's basically identical to the Perl sublanguage that > serves the same purpose:-). > > 1. Wasn't the adoption Perl-style regex's essentially a tip of the hat to a widely used, widely understood (and refreshingly un-lippy) syntax? 2. If convenience at the expense of redundancy trully has no place in Python, how do explain the likes of map, reduce and list comprehensions? Are THEY not "special" instances of "while" with abbreviated syntax? I submit that the ONLY practical purpose 1) or 2) serve is to produce cleaner (ie, less wordy) code. They ARE, therefore, Miesian (Mies Van Der Rohe), or minimalist, or Pythonic, if you prefer; DESPITE being redundant. From trentm at ActiveState.com Tue Jan 16 14:41:39 2001 From: trentm at ActiveState.com (Trent Mick) Date: Tue, 16 Jan 2001 11:41:39 -0800 Subject: help finding python20_d.lib for download? In-Reply-To: <3A649853.5CFBC157@psl.nmsu.edu>; from ccosse@psl.nmsu.edu on Tue, Jan 16, 2001 at 11:52:03AM -0700 References: <3A649853.5CFBC157@psl.nmsu.edu> Message-ID: <20010116114139.J30209@ActiveState.com> On Tue, Jan 16, 2001 at 11:52:03AM -0700, charles cosse wrote: > Hi, i have to use python in windows for 1 small task and > can't link my C module because i need python20_d.lib. > Can anyone help me find the downloadable archive which > contains it? Thanks a lot! > Charles http://www.activestate.com/Products/ActivePython/Download.html look for the "ActivePython-2.0.0.202.debug.tar.gz" link under the "Debug libraries" section. Cheers, Trent -- Trent Mick TrentM at ActiveState.com From chris at 2s2iNO_SPAM.com Sun Jan 28 01:09:59 2001 From: chris at 2s2iNO_SPAM.com (Chris) Date: Sun, 28 Jan 2001 01:09:59 -0500 Subject: "print" strange with Sybase module References: <3A70163A.10D995@schlund.de> <94q0f6$lu5$1@news.cybercity.dk> Message-ID: I've been experiencing this unflushed buffer issue as well when running some Python programs in the background and redirecting their output to log files. Is there any way that I could force the buffers to flush somehow? I am being plagued by incomplete log files! Or perhaps there is a better approach? Thank you! Erwin S. Andreasen wrote in message news:94q0f6$lu5$1 at news.cybercity.dk... > On Thu, 25 Jan 2001 13:04:10 +0100, Carsten Gaebler wrote: > > >The following simple program (sqltest.py) returns about 20 lines of > >Sybase output when run as "./sqltest.py". But if I say > > > >./sqltest.py | tee /tmp/test.txt > > > >there is no output and test.txt is empty. What's going wrong? It's > >Sybase module 0.10 with Python 2.0. > > Does your Python interpreter exit before the very end with some fatal error? > (do echo $? after you run the script without piping it to see the exit error > code, is it 0?). > > You see, standard output which "print" prints to is line-buffered when > connected to a terminal (i.e. the buffer is flushed after each line). When it > is run through a pipe, it is block buffered (i.e. the buffer is flushed after > 4096 bytes of output has been gathered). > > If the program exits unexpectedly (sys.exit(1) or an exception is OK, but > os._exit(1) or a fatal signal isn't) these buffers will not be flushed. > > I can't see a reason to why it would exit that way quietly, but unflushed > buffers are the first thing that comes to mind when seeing those symptoms. > > > PS: Any Python-users attending Linux Expo in Paris? > > -- > ======================================================================= > Herlev, Denmark Software Designer > <*> LASAT^WEicon Networks > ======================================================================= > From robin at jessikat.fsnet.co.uk Sat Jan 27 19:36:53 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 28 Jan 2001 00:36:53 +0000 Subject: . Python 2.1 function attributes References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> Message-ID: <0S4MTKAlm2c6EwWL@jessikat.fsnet.co.uk> In article , Tim Peters writes ... Wow these are 'must have' features. I must start growing fingernails at once. >> seems to me that having multiple ways of doing return is a bad idea > >You might like this new 2.1 feature better then, best illustrated by >example: > >>>> def f(\d+)(i): >... return int(\1) + 1 >... >>>> f12(6) >18 >>>> f0(3) >3 >>>> f666(42) >708 >>>> > >That is, "the name" of a function can be a regular expression now, and >anything that "looks like" a call is matched against all regexp func defs. >\1, \2 etc can be used in the body of the function to return substrings of >the matched function name, just as for any other use of regexps in Python. > >Of course there is a full set of disambiguating rules, based on the notion >of "most specific match". For example, > >def f.*(i): > return i > >also matches names like f12 and f666, but the set of strings matching f.* is >a strict superset of those matching f(\d+), so the latter is more specific. >By the same rule, > >def f666(i): > pass > >is a more specific match than f(\d+), so f666 is unambiguous. > >The primary reason for adding this was all the complaints about not being >able to reliably obtain the name of a function within its own body. Now >it's available via \0. > >>>> def anyfuncatall(): >... print \0 >... >anyfuncatall >>>> > >or, via the new attribute notation, > >>>> anyfuncatall.\0 >'anyfuncatall' >>>> > >Combining this with the new return spelling is very powerful: > >>>> x1 = 10 >>>> x2 = 20 >>>> x3 = 30 >>>> def f(\d)() >> eval("x" + \1): >... pass >... >>>> f2() >20 >>>> > >can't-wait-to-see-who-supports-this-one-ly y'rs - tim > > -- Robin Becker From torkil at fast.no Mon Jan 8 09:13:49 2001 From: torkil at fast.no (Torkil Grindstein) Date: Mon, 08 Jan 2001 15:13:49 +0100 Subject: How to set up an XML-RPC server (newbie) References: <3A59B00B.4CB407D3@fast.no> <3A59C319.E878838C@fast.no> <4YwvRIAvqcW6Ewnk@jessikat.fsnet.co.uk> Message-ID: <3A59CB1D.9AC912F@fast.no> Robin Becker wrote: > Is it possible you aren't running python with the script? Yes!!! Thanks a lot, now I have something to work with! (Still surprised about the error messages, though...:) -- Torkil Grindstein Mail: Torkil.Grindstein at fast.no System Architect Web: http://www.fast.no Fast Search & Transfer ASA Phone: +47 21 60 11 90 Gr?nnegata 80, Pb 571 Fax: +47 77 69 66 89 NO-9261 Troms?, NORWAY Mob: +47 98 06 61 38 Try FAST Search: http://www.alltheweb.com From delza at antarcti.ca Thu Jan 25 11:35:23 2001 From: delza at antarcti.ca (Dethe Elza) Date: Thu, 25 Jan 2001 16:35:23 GMT Subject: what GUI, please advise References: <3A6F18F2.536F27FE@crepido.com>, <3A6F0B27.A88D11C9@crepido.com> <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7@lp.airnews.net> <%aHb6.34$4vh.3735820@news.randori.com> Message-ID: Do you have pointers to the "upcoming XML resources format?" Is this the wxPWyitdhoonws resource format, or something more general. Any documentation? I'm very interested in cross-platform XML for building GUIs. --Dethe "Robin Dunn" wrote in message news:%aHb6.34$4vh.3735820 at news.randori.com... "Moshe Zadka" wrote in message news:mailman.980360668.7701.python-list at python.org... > > Check out wxPython and Tkinter. I think Boa-Constructor is a gui > builder for wxWindows, For a few bucks there's also wxDesigner, which is real solid and can generate code for Python, C++, Perl as well as the upcoming XML resource format > but you might have more trouble building > it on exotic platforms. This is getting better than it used to be before switching to distutils. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From donn at u.washington.edu Fri Jan 12 13:07:58 2001 From: donn at u.washington.edu (Donn Cave) Date: 12 Jan 2001 18:07:58 GMT Subject: How robust is Python ? References: <9358nn$3c5$1@nnrp1.deja.com>, <9354f9$vbi$1@nnrp1.deja.com>, <20010106103938.8FCAFA84F@darjeeling.zadka.site.co.il> Message-ID: <93nh5u$9nk$1@nntp6.u.washington.edu> Quoth "Sandipan Gangopadhyay" : [ ... re top level exception handlers ... ] | I want this in my code, but came across a problem - | | while binAliveMarker: | if binIWannaStartAgain: | time.sleep(1) | continue | work code ... | | If I try a catch-all except, continue hits except on the outer level rather | than while. Probably the reason that it results in syntax error. | | while binAliveMarker: | try: | if binWannaStartAgainLater: | time.sleep(1) | continue | work code ... | except: | pass | | Any suggestions to make it work with continue (or an alternative) ? Apart | from removing continue completely by making the work code inside an else ? Why apart from that? I guess we've already covered the "try: continue" issue: "try: continue" just isn't supported (though the more useful "try: ... except: continue" does work.) Readable flow control inside a loop is very doable. It's hard for me to see that try: continue would really improve on that - on the contrary, continue is liable to detract from readability if it's used in conjunction with too many other flow control options. I think "goto" would be fun, too, but I can see why in some ways we're better off without it. But back to the subject, I would be interested in more concrete examples of what exceptions we're liable to catch in a case like that. I have used top level handlers, but only as basically an alternative to the traceback, not to resume execution. I think the initial proposal was to execute the program again from scratch after it exits, and it's pretty obvious what that's about. But after catching some random exception at the top of the program, I would be concerned that the program might be in a compromised state and not really fit to go back to work. And would that really catch the kind of lossage that could break a correctly written Python program, or do those things usually break the interpreter directly? Donn Cave, donn at u.washington.edu From root at rainerdeyke.com Sat Jan 27 18:09:43 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 27 Jan 2001 23:09:43 GMT Subject: . Python 2.1 function attributes References: Message-ID: "Roy Katz" wrote in message news:Pine.GSO.4.21.0101271156550.3501-100000 at y.glue.umd.edu... > On Sat, 27 Jan 2001, Rainer Deyke wrote: > > > Syntax sugar for singletons could chop another line from the class-based > > idiom: > > > > > > singleton g: > > attr = 0 > > def __call__(): pass > > > I thought of that, so I wrote the other post (about an Entity type). > I noticed that your __call__() doesn't pass self. Was this intentional, > given that you specified a singleton? No, I just forgot to put 'self' in the argument list. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From kkoller at newfocus.com Thu Jan 25 15:21:52 2001 From: kkoller at newfocus.com (Ken Koller) Date: Thu, 25 Jan 2001 12:21:52 -0800 Subject: Crash using Python 2.0 Extension References: <3A707199.FBDF1A81@newfocus.com> Message-ID: <3A708AE0.D6B27233@newfocus.com> Thanks, I knew I was missing something. And I was looking at some of the source, it's just that it was pretty late and I was burned out. I should have caught that though. Fredrik Lundh wrote: > Ken Koller wrote: > > I originally wrote the routine below to return Py_None, but the > > interpretter would crash after calling the routine several times (maybe > > 100-200) in a row. > > you mean like > > static PyObject * pt_pSetModule(PyObject * self, PyObject * args) > { > return Py_None; > } > > this doesn't work -- Python expects your function to own a > reference to the object you'll returning, and will decrement > the reference counter once it's done with the return value. > When the return value reaches zero, the None object is > removed, and anything can happen. > > (in a stock interpreter, there already are 100-200 references > to None when your program starts running. sys.getrefcount(None) > will give you the exact number for your setup). > > But if you look in the library sources (*always* do this when you > cannot figure out how to use the C API), you'll notice that many > functions/methods do return Py_None -- but they all do one very > important thing before doing so: > > Py_INCREF(Py_None); /* get another reference to None */ > return Py_None; /* return an owned reference */ > > for more info, see: > http://www.python.org/doc/current/ext/refcounts.html > (especially "ownership rules") > > Cheers /F > > From flognat at flognat.myip.org Thu Jan 18 09:50:40 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Thu, 18 Jan 2001 14:50:40 GMT Subject: Curses module for Python 2.0 for Windows NT References: Message-ID: Drats, nope pdcurses didn't seem to have enough functionality to fit into the curses module, either the cygwin way, or go doing a pdcurses module for python :-) /Andy From sheila at thinkspot.net Mon Jan 15 02:20:11 2001 From: sheila at thinkspot.net (Sheila King) Date: Mon, 15 Jan 2001 07:20:11 GMT Subject: Help with Python install References: Message-ID: On Mon, 15 Jan 2001 05:33:42 GMT, Sheila King wrote in comp.lang.python in article : :I've been given a clue from the Sysadmin: :I've installed Python in the wrong directory. The mail program doesn't have :permission to access my $HOME directory, and I've installed Python2.0 in a :subdirectory of HOME. So, I need to uninstall it, and then reinstall it into a :directory that the mail program has access to. Well, I have this problem solved, at least. Python 2.0 is installed, and my script is functioning. I did have to put the full path in the .qmail file, as suggested by Emile van Sebille. That, plus installing it in a directory where the permissions allowed the mail program to access it, solved the problem. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From richard_d_papworth at my-deja.com Thu Jan 11 10:17:43 2001 From: richard_d_papworth at my-deja.com (richard_d_papworth at my-deja.com) Date: Thu, 11 Jan 2001 15:17:43 GMT Subject: Ingres II and Python Message-ID: <93kiqc$5k6$1@nnrp1.deja.com> Does anyone have experience of accessing an Ingres II database using python ? I haven't been able to find any references to ingres on the python site. Any pointers in the right direction would be appreciated. Richard Sent via Deja.com http://www.deja.com/ From scarblac at pino.selwerd.nl Tue Jan 16 02:32:57 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 16 Jan 2001 07:32:57 GMT Subject: Problem with a tuple - newbie ignorance References: <3A633531.9010303@yale.edu> Message-ID: Steven Citron-Pousty wrote in comp.lang.python: > Greetings all: > So I am writing this program to parse text files. I am using a tuple to > store the field names and values (i.e. [['id =', 't =', > ...]['','',...]]. The program reads through all the files in the > directory. For each file it writes all the all the matches in teh > appropriate field. I am having several problems, but the biggest right > now is: > When the program goes to parse the next file it doesn't clear out the > contents from the last file. Here is how I thought it should work... >

> ifields = [[fields names list][list of just '','',''] > > open file > results = ifields > > > > > For some reason I thought that each time results gets sets to ifields it > should reset the contents of results. I have tried all sorts of other > workarounds, such as using "del results" just before I go back and > repeat the loop. > What am I missing here? These are not tuples, but lists. (you can't change tuples). When you do 'results = ifields', both variables refer to the same list. So when you add elements to results, ifields is also changed, since it is the same list. Similar to: >>> a = [1] >>> b = a >>> b.append(2) >>> a [1, 2] What you need is a *copy* of the original list. So do results = ifields[:] instead. Also, if you have a structure [[name1, name2, name3, name4], [value, value, value, value]], that just screams for a dictionary { name1: value, name2: value, name3: value, name4: value } -- Remco Gerlich From stadt at cs.utwente.nl Thu Jan 4 09:39:38 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Thu, 04 Jan 2001 15:39:38 +0100 Subject: isnumeric (mhlib.py) Message-ID: <3A548B2A.B45DC580@cs.utwente.nl> Hi, I needed a function to check if a string is a number. mhlib contains a function called isnumeric(), so I used that one. This is how it determines if a string is a number: numericprog = re.compile('^[1-9][0-9]*$') def isnumeric(str): return numericprog.match(str) is not None However, this way, '0' is not regarded as a number. Is that what isnumeric is supposed to do? I don't know what the meaning of isnumeric for mh is, but why isn't numericprog simply like this: numericprog = re.compile('^[0-9]*$') Richard. From mal at lemburg.com Thu Jan 25 05:57:25 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 25 Jan 2001 11:57:25 +0100 Subject: Help for DCOracle module on AIX UNIX References: Message-ID: <3A700695.C8E35F32@lemburg.com> Oleg Broytmann wrote: > > Hello! > > On Thu, 18 Jan 2001, Weiming He wrote: > > Does anyone know how to compile and link DCOracle module on AIX UNIX? > > Please pass me a hand, thanks in advance. > > In what way AIX is different from any other UNIX? I've compiled and used > DCOracle on Linux... ... don't ask ;) I have never used DCOracle, but one of my customers uses AIX and getting things to compile on that machine isn't really straight forward at all. If DCOracle happens to use the Makefile.pre.in approach then here's what to watch out for: * copy the python.exp file generated during the compilation of the Python interpreter and the two scripts ld_so_aix and makexp_aix to each of the directories where Makefile.pre.in will be used to compile a C extension * setup your PATH so that Makefile.pre.in finds the correct Python installation (the one you have taken the python.exp file from) * Give it a go... * If something fails, it will usually be the linker (dynamic or static). -- Marc-Andre Lemburg ______________________________________________________________________ Company: http://www.egenix.com/ Consulting: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From bobhicks at adelphia.net Wed Jan 17 21:26:26 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Thu, 18 Jan 2001 02:26:26 GMT Subject: Tkinter 3000 WCK, fifth preview (was Re: Line Benchmarks - Tkinter vs. wxPython) References: <91uljk$12as$1@news2.ottawa.cyberus.ca> <%Y%56.4330$Qb7.610263@newsb.telia.net> Message-ID: Very nice...can't wait for the final product! Bob > From: "Fredrik Lundh" > Organization: Telia Internet > Newsgroups: comp.lang.python > Date: Wed, 17 Jan 2001 18:39:39 GMT > Subject: Tkinter 3000 WCK, fifth preview (was Re: Line Benchmarks - Tkinter > vs. wxPython) > > I wrote: >> I wrote: >>> As some of you know, I've been involved in a commercial UI library >>> called uiToolkit (see www.pythonware.com for more info). Tkinter >>> 3000 is a reimplementation of some uiToolkit concepts, on top of >>> Tkinter (and/or Tk). >>> >>> One such concept is something called the "Widget Construction >>> Kit", which is a small interface that allows you to implement new >>> Tkinter widgets in pure Python. > > a new preview is now available from http://tkinter.effbot.org > > send comments/questions to me or to the tkinter3000 mailing > list (see the effbot.org site for more info). > > Cheers /F > > From christophertavares at earthlink.net Wed Jan 17 22:35:58 2001 From: christophertavares at earthlink.net (Christopher Tavares) Date: Thu, 18 Jan 2001 03:35:58 GMT Subject: Any way to restrict execution with regard to execution time?? References: <944n1v$8t6$1@nnrp1.deja.com> Message-ID: wrote in message news:944n1v$8t6$1 at nnrp1.deja.com... [... snip ...] > > So here's the problem, that seems intractable in Python. > There are two pieces of code, C1 and C2. C1 wants to run > C2, but does not trust it to consume only a reasonable > amount of time (measured in any fashion). How can C1 run > C2 guaranteeing that C2's execution is interrupted after > some finite amount of time, if it hasn't finished by > then? C2 is from an untrusted source, so the answer > cannot be phrased in terms of how C2 is written. I'd be > much obliged to anyone who can tell me how to do this! > > Russell This is just an idea, but the Python debugging interface includes hooks for trace functions. These get called every function or every line. That'd let you get in there and do all sorts of stuff. It'd probably kill your performance, though. -Chris From djc at object-craft.com.au Thu Jan 25 17:45:21 2001 From: djc at object-craft.com.au (Dave Cole) Date: 26 Jan 2001 09:45:21 +1100 Subject: removing duplicates from .csv files References: <94ptre$uf0$1@nnrp1.deja.com> Message-ID: >>>>> "mspiggie" == mspiggie writes: mspiggie> I have been given several comma-delimited (.csv) files, each mspiggie> containing as many as several thousand lines of entries. mspiggie> Among the tasks I've been charged with is to remove mspiggie> duplicate entries. The files each contain fields for mspiggie> Contact Name, Company Name, Phone Number, and Address, among mspiggie> other fields, which vary from file to file. Although I can't offer much help on the data processing part, you might want to use my fast CSV parser module. It understands MS style CSV in which quoted fields can span multiple lines. It runs just a teeny bit slower than string.split() http://www.object-craft.com.au/projects/csv/ - Dave -- http://www.object-craft.com.au From cerutti at together.net Fri Jan 26 15:51:13 2001 From: cerutti at together.net (Neil Cerutti) Date: 26 Jan 2001 20:51:13 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> <3A3AF7F970D390FB.9516A3492818FA7E.F86BC486C21F50E6@lp.airnews.net> Message-ID: David Bolen posted: >I guess the one place I do use them is for menu items, but >really only when the item is created and the event attached to a >callback method. I guess we could use wxMenuItem objects instead of arbitrary(??) ID numbers. -- Neil Cerutti From aleaxit at yahoo.com Wed Jan 17 06:27:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 17 Jan 2001 12:27:23 +0100 Subject: SQL-Statement with Python References: <3A62E224.7AEE805E@students.uni-linz.ac.at> <93ut4q031hd@news1.newsguy.com> <941jnd0634@news1.newsguy.com> Message-ID: <943vlk02jai@news2.newsguy.com> "Steve Holden" wrote in message news:K4596.1054$DI.17324 at e420r-atl1.usenetserver.com... [snip] > > Anyway, if that bothers you too much you get to choose among a > > zillion other ways to ask a recordset for its contents, e.g....: > > > > for row in recordset.GetString()[:-1].split('\r'): > > first, last = row.split('\t') > > print "%s, %s" % (last, first) > > > > Or, simpler and faster, one can show off one's command of 'advanced' > > SQL:-), and get the *db engine* to do one's work: > > > > recordset, result = connection.Execute( > > "Select LastName//', '//FirstName From Employees Order By LastName") > > print recordset.GetString().replace('\r','\n') > > > pretty good, though I would suggest "... Order By LastName, FirstName" for a > definitive ordering. Wow, I wish my SQL was that good :-) And in fact I'm > one of those who tend to write SQL keywords in UPPER CASE because that's > what I'm used to. Upper-case keywords is indeed the prevalent style, as is splitting SQL statements up into clauses, also for readability: recordset, result = connection.Execute( "SELECT LastName//', '//FirstName" " FROM Employees" " ORDER BY LastName, FirstName" ) I guess this IS best, given the complexity of certain SQL statements -- it just doesn't come natural to me when plonking down some simple little thingy. My fault. (Not sure what the 'wish my SQL was that good' quip is meant for -- IS there some engine that doesnt do such simple things right?). > > Explanation for _what_ 'it'? I must be confused... > > > "It" being the row-major vs. column-major ordering. I had completely > overlooked the fact that Microsoft tend to design their subsystems to play > with *their* languages. Don't talk to me about world domination! Well, I'm sure Fortran programmers using SQL via ADO (there must be a BUNCH of those out there...) are also happy. I'm not aware of other languages oriented to column-major matrices, though I'll bet there are. But that's not really the point here. The VB/VBscript programmer will have to code nested indexed loops anyway since the language does not support equivalence between 2d arrays and arrays-of-arrays; eg, see http://www.stardeveloper.com/asp_getrows_4.asp for a typical: ' Showing Each Row For i = 0 To UBound(ds, 2) Response.Write "" & vbcrlf ' Showing Each Column For j = 0 To UBound(ds, 1) Response.Write "" Response.Write ds(j, i) Response.Write "" Next Response.Write "" & vbcrlf Next where ds is the object (a VB/VBscript array) that GetRows returns. Python equivalent would be something like (warning -- untested!): # showing each row for i in range(len(ds[0])): Response.Write("\n") # showing each column for j in range(len(ds)): Response.Write("%s" % ds[j][i]) Response.Write("\n") not really any less convenient than the VBScript equivalent above, it seems to me. The (little) defect in both cases is having to iterate by index when iterating on content directly would be more convenient and simpler if it were feasible ('For Each' in VBScript, plain Python for without the range(len(...)) rigmarole) -- it's not, in VBScript because of the non-equivalence of 2D arrays to arrays of arrays, in Python because of the column-major thingy. Had GetRows returned an array of arrays, life would be simpler in *both* scripting languages! Oh well... all in all, it's not really a major issue, just one more little design booboo (it stands out more in Python because the language itself is so free from such little errors & irregularities -- in VBScript, one does not notice it because there are so many in the language itself, that, "what's one more between friends"!-). Another viable approach, if you feel so strongly about it, is (and this will surprise nobody) to allow iteration the way GvR intended. You can do it simply, by transposing the wrong-way-round matrix once and for all, e.g: def transpose(matrix2d): result = [[] for i in range(len(matrix2d[0]))] for row in maxtrix2d: for i in range(len(row)): result[i].append(row[i]) return result which seems simplest to me; this allows recoding the above Python snippet as the marginally clearer/more convenient: for row in transpose(ds): Response.Write("\n") for col in row: Response.Write("%s" % col) Response.Write("\n") Since only references are copied anyway, this is not too bad, I think. Still, one MIGHT get fancy: class transpose: class RowWrapper: def __init__(self, matrix, index): self.matrix = matrix self.index = index def __getitem__(self, otherindex): return self.matrix[otherindex][self.index] def __init__(self, matrix): self.matrix = matrix def __getitem__(self, index): if index >= len(self.matrix[0]): raise IndexError, index return self.RowWrapper(self.matrix, index) with the same Python snippet. But I honestly fail to see any advantage to this abstruse approach -- seems substantially more complex for no performance gain, indeed I suspect it would perform less well (but I have not taken the trouble to time it:-). Alex From emile at fenx.com Sun Jan 28 09:27:05 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 28 Jan 2001 06:27:05 -0800 Subject: python-2.1 function attributes References: <94vn23$j0k$1@panix6.panix.com>, Message-ID: <951aa9$fehi9$1@ID-11957.news.dfncis.de> But move the function to a class and: class G: def f(self): G.f.a = 2 works after invocation for instance.f(). With the naming differences of methods vs functions, I like Mike Hudson's syntactic sugar of using "." for the current method/function, ala: def f(): .a = 1 class G: def f(self): .a = 2 At least when refactoring there's no ambiguity over what is meant. As it stands, if you try: class G: def f(self): f.a = 2 is valid and changes f.a. -- Emile van Sebille emile at fenx.com ------------------- "Moshe Zadka" wrote in message news:mailman.980662640.15627.python-list at python.org... > On 27 Jan 2001 15:53:39 -0800, aahz at panix.com (Aahz Maruch) wrote: > > > One thing I'm not clear on from all this discussion is whether one can > > do this: > > > > def f(): > > f.a = 1 > > Of course! > > Python 2.1a1 (#2, Jan 27 2001, 21:08:11) > [GCC 2.95.3 20010111 (prerelease)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> def f(): > ... f.a=1 > ... > >>> f.a > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: a > >>> f() > >>> f.a > 1 > > -- > Moshe Zadka > This is a signature anti-virus. > Please stop the spread of signature viruses! > Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 > From aleaxit at yahoo.com Wed Jan 10 06:17:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 10 Jan 2001 12:17:36 +0100 Subject: embedding python in C++ References: <934r1a$pda$1@troll.powertech.no> <93a3lp01kpg@news1.newsguy.com> <93b02a$tr8$1@troll.powertech.no> <93cq6n0186t@news1.newsguy.com> <93fgim04oc@news1.newsguy.com> <93g8sp$pcj$1@troll.powertech.no> Message-ID: <93hgeq014d3@news2.newsguy.com> "Syver Enstad" wrote in message news:93g8sp$pcj$1 at troll.powertech.no... > > "Alex Martelli" wrote informatively as usual in > news:93fgim04oc at news1.newsguy.com... > > > I don't know what happens if you don't let softspace be set & read > > (i.e., whether print degrades gracefully or what) > It seems to degrade gracefully in my experience, which is rather small. Mine, zero (only time I needed a C-coded Python object to be set as sys.stdout, I _did_ embue it with a softspace attribute!-). > >-- note that all > > Python instance objects ARE 'expando' (Javascript terminology) by > > defaults, so you don't normally have to do anything special to enable > > it, but, if you're using your own C-level type rather than a Python > > implemented instance... > > Of course, thats why you don't have to have a softspace member in a py > object. The caller just tags it onto the object when he needs to. Just reiterating an important point: this is true for *instances*, where such after-the-fact tagging is implemented; it may not be for a typical C-coded type, unless care is taken to let the caller set (and re-read) arbitrary attributes. Alex From sholden at holdenweb.com Wed Jan 10 16:39:33 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 10 Jan 2001 16:39:33 -0500 Subject: Reading Microsoft Outlook Express .dbx files References: Message-ID: "Tim Peters" wrote in message news:mailman.979160302.21518.python-list at python.org... > [Steve Holden] > > ... > > The problem with the usual techniques of saving as text, and some > > mailing solutions, is that attachments are frequently ignored. > > Sorry, no idea what that means. Ignored by whom? If I tell Outlook to mail > an attachment, Outlook does not ignore my suggestion . On the other > end, the attachment Outlook generates is ignored only if the receiver > intentionally ignores it. > I simply meant that some mailers forward messages without attachments, and some don't. Haven't tested OE to see which category it falls in yet. regards Steve From ben.hutchings at roundpoint.com Tue Jan 23 19:54:16 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 23 Jan 2001 16:54:16 -0800 Subject: Problem with a tuple - newbie ignorance References: <3A633531.9010303@yale.edu> <3A635C32.9E5285C5@yale.edu> <3A64D9E8.B1D52E1E@mail.mcg.edu> Message-ID: Neil Schemenauer writes: > On Tue, Jan 16, 2001 at 11:30:29PM +0000, Keith F. Woeltje wrote: > > Normal (forward) slashes won't however work in a command prompt > > window in Win2000. Does the python interpreter make the change > > "magically" (like it does the end of line marker)? > > No. I believe the Win32 API accepts either / or \ as a path > separator . Its the command shell that's braindead. They can't > use / because its used to signal a flag. I guess Win2000 still > shows its CP/M heritage. Under DOS and Windows, each program is responsible for parsing its own command lines. So some commands, including those built into the command interpreter, reserve / as a switch introducer, but others do not. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From zamri at sun1.ftsm.ukm.my Fri Jan 19 22:10:45 2001 From: zamri at sun1.ftsm.ukm.my (Mohd Zamri Murah) Date: Sat, 20 Jan 2001 11:10:45 +0800 Subject: data structure/algorithm in python Message-ID: <20010120111045.A9911@sun1.ftsm.ukm.my> I am on my second stage of learning python. ( done the tutorial, read the O'Reilly book, browse the library references, did smallish programs, etc) Now, I am interested in how to implement certain algoritms/data structure in python (binary tree, b++, avl, queue, etc)[1]. since there are yet any "data structure/algorithm in python" book, do reading "data structure/agorithm in java/C++" help? (get the basic idea from the book and try to implement it in python) Or, the python <-> C++/Java have too much differences that reading about data structure/algorithm in C++/Java will only confuse learning the same thing in python? hope to do; read Knuth's "fundamental algorithms" and able to "swing" an algorithm/data structure with a blink of an eye. zamri [1] have seem a few binary tree, avl but each with difference syntax/approach and very confusing for a newbie. From aleaxit at yahoo.com Thu Jan 18 06:19:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 12:19:36 +0100 Subject: Multiple constructors (part 2) References: Message-ID: <946jit0a77@news2.newsguy.com> "Daniel Klein" wrote in message news:D%o96.645$KD3.265469 at typhoon.aracnet.com... > OK, I've researched and read the posts (and the FAQ) on how to simulate > multiple constructors. Alex Martelli provided the most robust answer by > testing the number of *args and executing the appropriate section of code. > However in another post he says > > """ > This 'overloads' the constructors based on how many arguments > are given -- how elegant (and how Pythonic...!) this is, being > of course *debatable*. Overloading on *types* would be less > elegant *and* less Pythonic, though you could easily extend > this idea to do it -- I would discourage it even more strongly. > """ I think _this_ part of my response is what makes it "robust":-). In other words, the best answer to this sort of queries is most often: yes, you can do it (and here's how), but there are better approaches (and here they are). I didn't get _fully_ into the "here's how" and "here they are" parts, admittedly. > However, what I need to do is _exactly_ what is being discouraged, that is > creating 3 constructors both with 2 arguments where the second argument of > each is a different type. The real kicker is that in one of the > constructors, I need to check the __class__ of the object to make sure the > method is receiving the proper object. I have no problem coding this if this > is the way it has to be but if there are more acceptable (and Pythonic) ways > to do this, I would appreciate some pointers. Why do you think you *NEED* to distinguish your processing based on an argument's type, or class? More likely, what you want to know about an argument (to determine different processing in different cases) is *how it BEHAVES* -- which you can't do by testing types, or classes; rather, you may use hasattr or try/except to find out. By focusing on behavior, rather than on type-identity, you make life easier for the client-code programmer: he or she can then make polymorphic use of your components with any instance that implements the needed behavior, which IS all your code needs. The idea of 'overloading' -- having a callable with a single given name that maps to multiple internal callables depending on various conditions -- is also related to polymorphism; the only good reason to supply a single callable that maps to multiple ones is to let client-code use that single callable polymorphically if need be. It's generally a good idea to ALSO expose the multiple callables directly -- don't make client-code programmers go through strange contortions to make sure the 'right' overload is invoked in the end; when their need are non-polymorphic, let them explicitly state as much in the simplest possible way. This does not sit in well with 'constructors' -- which is why *factory functions* tend to be preferable whenever any application need of some richness and complexity is involved (factory callables that are not functions are also OK, but meet a rarer, yet-more-involved need). In Python (just like in VB, and other languages with the concept of explicitly-named and default-valued arguments) you have another stylistic alternative to 'multiple callables': one callable can be explicitly used for several related purposes by supplying different named-arguments. This can easily be overdone (and VB supplies a LOT of examples of this style being overused!-) but, used with taste and moderation, it can be very helpful too. Let's try to see one typical example. We want to expose a class Munger, whose instances need to be initialized with 'a lot of data to be munged'; the 'lot of data' could be a file, a string, or an instance of our own class DataBuffer which provides the data-access features Munger instances need -- in fact, when we are given a file or string, we construct a DataBuffer ourselves and hold that anyway. The 'overload' style might be: class Munger: def __init__(self, data): name = type(data).__name__ if name=='instance': name = data.__class__.__name__ method = getattr(self, '_init_'+name) method(data) def _init_string(self, data): self.data = DataBuffer(data) def _init_file(self, data): self.data = DataBuffer(data) def _init_DataBuffer(self, data): self.data = data Now, this IS intended as a 'bad example', and maybe I've overdone the badness, but I hope at least it IS clear why doing it this way would be heavily sub-optimal. This does not exploit in any way the polymorphism of *DataBuffer*'s own constructor, *AND* it seriously inhibits polymorphism capabilities of client-code (except via such tricks as naming a *class* as, say, 'string'...!). It's clearly simpler to frame this as 'a Munger needs to be passed a DataBuffer, or anything a DataBuffer may be built from': class Munger: def __init__(self, data): if not isinstance(data, DataBuffer): data = DataBuffer(data) self.data = data at least, we have some simplicity here. Polymorphism is still not optimal, though; if client-code wants to *mimic* a data buffer, it needs to inherit from our DataBuffer class, even if it's not using any of its implementation, just to satisfy our isinstance check. At the very least, one would 'split out' from DataBuffer the interface and implementation parts: class IDataBuffer: def rewind(self): raise TypeError, "must override .rewind method" def nextBytes(self, N): raise TypeError, "must override .nextBytes method" def pushBack(self, bytes): raise TypeError, "must override .pushBack method" etc, with class DataBuffer inheriting from this (and providing the needed overrides, of course) and the isinstance check done against IDataBuffer. Not very Pythonic, but workable if there are a LOT of DataBuffer methods we need -- checking for each of them separately may become more trouble than it's worth. DataBuffer's own 'overloading' ("am I being initialized from a file or from a string?") needs to be handled. Once again, it would be *seriously* wrong to code: class DataBuffer(IDataBuffer): def __init__(self, data): name = type(data).__name__ if name=='instance': name = data.__class__.__name__ method = getattr(self, '_init_'+name) method(data) def _init_string(self, data): self.data = data self.index = 0 def _init_file(self, data): self.data = data.read() self.index = 0 # etc etc because it horribily inhibits client-code's polymorphism. Here, all we need from a 'file object' is a .read method we can call without arguments to supply our data -- so why not code that directly...: class DataBuffer(IDataBuffer): def __init__(self, data): try: self.data = data.read() except AttributeError: self.data=data self.index = 0 # etc etc this is MUCH simpler, of course. One may add some tests at initialization to ensure the resulting data are usable for our purposes, but it's generally no big problem if the error (if any) comes at first usage rather than at initialization. An alternative architecture is also worth considering. DOES client code REALLY NEED the polymorphism implicit in passing a Munger constructor, either a file(-like) object, or a string(-like) one, with very different implied semantics regarding how one gets data from said object? Python libraries give us counterexamples of that -- file-like objects and string-like ones are generally passed through *separate* methods; there's no real polymorphism opportunity there! So...: class DataBuffer(IDataBuffer): def __init__(self, data): self.data = data self.index = 0 # etc etc class Munger: def __init__(self, data): self.data = data # etc etc def FileMunger(afile): return Munger(DataBuffer(afile.read())) def StringMunger(astring): return Munger(DataBuffer(astring)) There, isn't THIS better? Two non-overloaded factory functions, maximal simplicity in the constructors proper. Client-code knows what it IS using to construct the Munger and doesn't need the polymorphism -- it will be clearer and more explicit and readable if it calls FileMunger or StringMunger appropriately, and only uses Munger's ctor directly for those cases where it needs to reuse some existing IDataBuffer instance. If very occasionally a polymorphic use may benefit the client-code author, we can add a further factory function for that purpose only: def AnyMunger(mystery): if isinstance(mystery, IDataBuffer): return Munger(mystery) else: try: return FileMunger(mystery) except AttributeError: return StringMunger(mystery) However, one doesn't go around just adding such stuff *unless its appropriateness is clearly shown by some specific use-case/scenario* -- "you ain't gonna need it" is a GREAT design principle:-) [XP rules...!-)]. Now, this IS of course a toy-level example, but I hope that just because of this it may show up the issues more clearly -- and perhaps convince you to rethink your design in simpler and more usable ways. Alex From m.bless at gmx.de Tue Jan 30 16:40:14 2001 From: m.bless at gmx.de (Martin Bless) Date: Tue, 30 Jan 2001 21:40:14 GMT Subject: How to extend sys.path on Win9x permanently? References: <3a75ef9c.11194652@news.muenster.de> <980811891.858385@clam-ext> Message-ID: <3a7730ab.37058673@news.muenster.de> On Tue, 30 Jan 2001 12:44:51 +1300, "Mark Hadfield" wrote: >> Registry? >Yes. Take a look at the registry branch rooted at (for version 2.0) >HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.0\PythonPath Yes, it works. To be exact, it's the HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.0\PythonPath\win32 key on my machine. It adds the extra path both in Python/DOS and PythonWin. I had searched the registry but somehow overlooked it. But what I like much better is the solution to put MYLIBS.PTH into the Python dir. See thread. Martin From nicrayner at hotmail.com Mon Jan 8 07:50:19 2001 From: nicrayner at hotmail.com (Nick Rayner) Date: Mon, 08 Jan 2001 12:50:19 -0000 Subject: ok Message-ID: confirm 438765 _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From scarblac at pino.selwerd.nl Wed Jan 31 09:06:41 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 31 Jan 2001 14:06:41 GMT Subject: How do you lock your web app data? References: <956uqd$6st$1@newsreaderg1.core.theplanet.net> <957286$kde$1@reader1.imaginet.fr> Message-ID: Gilles Lenfant wrote in comp.lang.python: > If you play with lot of small files and few users you can use "lock files" > with the same name as the file the user is supposed to modify. > This is not "pythonic" but a general algorythm that can be done in python or > whatever: > > start cgi > if not exists "myfile.lock" > touch "myfile.lock" > # play with "myfile.txt" > ... > # end play with "myfile.txt" > rm "myfile.lock" > else > reply "resource in use, come back later" to the user (or anything else > relevant) > endif > end cgi This doesn't work. First both threads check if the file doesn't exist, then they both assume they're clear, make the file, and start corrupting each other. Something nearly like this does work, on Unix and Windows, as far as I know: make a directory. This is guaranteed atomic (so they can't do it both at the same time) and will give an exception when the directory already exists. import os def acquire_lock(filename): while 1: try: os.mkdir(filename+".lock") return except OSError: pass def release_lock(filename): os.rmdir(filename+".lock") acquire_lock("whee") f = open("whee","a") print >> f, "Whee!" f.close() release_lock("whee") This is a very simplistic form of spinlock and you run into deadlock when one of the processes bugs and doesn't release the lock, but simplicity is good. -- Remco Gerlich From spamfranke at bigfoot.de Mon Jan 22 08:05:16 2001 From: spamfranke at bigfoot.de (Stefan Franke) Date: Mon, 22 Jan 2001 13:05:16 GMT Subject: Python & GUI? References: <3A674896.C7E52247@crepido.com> <947j3i01h9k@news2.newsguy.com> Message-ID: <3a6c2f9c.2770560@news.btx.dtag.de> On Thu, 18 Jan 2001 21:15:56 +0100, "Alex Martelli" wrote: [...] >my personal favorite, however, is Dynamic >Html -- used in a cross-platform way, it has some limitations, >but, targeting one specific and powerful browser (such as IE), >it's awesome, I've no idea what's possible on this route, could you point me to some examples (for IE)? Stefan From dyoo at hkn.eecs.berkeley.edu Wed Jan 17 20:19:08 2001 From: dyoo at hkn.eecs.berkeley.edu (Daniel Yoo) Date: 18 Jan 2001 01:19:08 GMT Subject: "Total flattening" of a tuple References: Message-ID: <945gac$1jg$2@agate.berkeley.edu> Giuseppe Bilotta wrote: : Hello, : I'd like to know if it's possible to "totally flatten" a tuple, or to decompose it I'm not sure if this is still useful to you, but here's some tuple flattening code: ### def flatten(t): if type(t) != type(()): return (t,) elif len(t) == 0: return () else: return flatten(t[0]) + flatten(t[1:]) ### And here's a small test of it: ### >>> flatten((1, 2, 3, 4, (5,), (), (), ((6, 7, (8,))))) (1, 2, 3, 4, 5, 6, 7, 8) ### From ebecker at software-manufaktur.de Sun Jan 28 09:20:14 2001 From: ebecker at software-manufaktur.de (Edelhard Becker) Date: Sun, 28 Jan 2001 15:20:14 +0100 Subject: Pyditor, Text editor fully extendible in python a la' Emacs References: Message-ID: Hi Nahuel, i've re-sorted the wishes. Most of them IMHO are already available in VIM (http://www.vim.org/) directly or via additional scripts (e.g. CVS support). Just remember to configure VIM with --enable-pythoninterp. On Sat, 27 Jan 2001 19:38:48 -0300, Nahuel Greco wrote: > > I have a dream, of a perfect text editor (im calling it pyditor, but name it > as you want ): > > * Coded in C/Python, Scriptable with python in the emacs/elisp way > * Various backends - PyGTK, PyQT, PyQuartz(?), and.. (this is > important to me and too much other people) PyNcurses! > antialiased text if the backend support that. (soon gtk and qt) > * ligthweight in speed & ram (side note: this one obviously is _no_ attribute of emacs; sorry, couldn't resist ;^) > * Portable as python and the "backends" are > * No python centric - i mean, no another IDLE, i want a editor that > you can script in python, but you can use (as modes in xemacs), > python-mode.py, c-mode.py, perl-mode.py, java-mode.py , etc etc. > * Filesystem abstraction - you can open&save files in an http site > (with webdav), ftp, inside a tar.gz, etc. (easy with python!) > * CVS support > * Crypt support (via GPG), open crypted files in the disk, edit them, > and save encrypted again. > * Mouse capable but no mouse addict - there is keyb shorcuts for all > that you can do.. for example, if i have 3 editor windows opened, i > want to move to the window in the left of the current with > alt+leftarrow > * As i say before, "emacs modes", like fly-spell (auto word checking), > etc. > * Easy use, as commands are documented in the modules via doc strings > and, most commands are reachable in a pull-down menu. > * Editor modules repository - you need something for your editor?, > go to File/Modules/Repository and then download the latest versions. > Also to avoid duplicate effort. > * User / Newbie friendly, pulldown menus. > * Centralized keyboard "shorcuts" managment - you can go to a screen > with all the key combinations registered and the modules that use > it... you can attach custom code to that keyboard event, or change > all of them to "emacs-friendly" o "vi-friendly" with only a click > * pretty syntax highlighting The following wishes are more or less system dependant or difficult to implement: > * Font handling, syntax highlighting, with color schemes > themables, (the default will be audited by an user interfase > expert :) > * Easy configurable - the user can configure all the modules in the > same place, with a common interfase. > * Good canvas - suppose that you can type latex code in a text window, > and see at the same time the effects of that code in a latex > wysiwyg rendered window, then, switch to the wysiwyg window, select > a different font from a pulldown box, change that window, and see > the changes reflected in the text window. I'm not sure about these: > * Jython portable? > * Full UNICODE internationalization !!!!! (easy with python! :) > * client server model like gnuclient / xemacs? > [.. more good ideas snipped ..] > Later, if you want to write a mail editor, you use the text editor module > inside your MUA framework, or your ide / interfase builder. Use mutt (http://www.mutt.org/) with VIM as editor. > What do you think? Many good ideas, mostly done (from a vim-point-of-view, Python integration _could_ be better). Just "avoid duplicate effort" and don't start programming YAE (yet another editor)... > There is already a project like this? (btw, i dont like wily :) > > (Forgive my bad english :)) > --------------------------------- > Nahuel Greco > http://www.codelarvs.com.ar > Web Development - Open Source > Game programming - Research > --------------------------------- Enjoy! Edelhard -- % cat /usr/include/sys/errno.h #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ [...] #define EMACS 666 /* Editor Too Large */ % From moshez at zadka.site.co.il Sat Jan 13 16:16:38 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 13 Jan 2001 23:16:38 +0200 (IST) Subject: Web devel with python. Whats the best route? In-Reply-To: <93pii2$c4c$2@newshost.accu.uu.nl> References: <93pii2$c4c$2@newshost.accu.uu.nl>, Message-ID: <20010113211638.A5DAAA828@darjeeling.zadka.site.co.il> [Cliff Crawford] > InterTran translates the phrase "Tim Peters" as "[Tim] Godfather". :) [Steve Holden] > So he *is* a member of the PSU, or maybe even one of the leaders. > I suspected this all along! [Tim Peters] > All right, I've had it. It's time to come clean! Here's the truth > about all this! Actually, I've assasinated the real Tim Peters > a few months ago, just before the move to BeOpen. Since it seemed > BeOpen were on to me, I engineered the move to Digital Creations. > But now, it seems it is all out in the open. > From now on, I make the rules. Guido was a figurehead I need > no longer. [Martijn Faassen] > It appears there's some kind of bizarre interaction between > NNTP (or is it MailMan?) and temporal paradoxes here, that distorts > messages on transmit, sometimes simply cutting out random parts. Huh? I see no such thing at my end. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From robin at jessikat.fsnet.co.uk Wed Jan 31 03:30:08 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 31 Jan 2001 08:30:08 +0000 Subject: Poor Programming Practice? Message-ID: I have been trying to make use of the builtin medusa ftp_server classes and after struggling a while came across the strange practice some internal zope developer has of dynamically changing classes at runtime. ie in ZServer.FTPServer I came across from medusa.ftp_server import ftp_channel, ftp_server, recv_channel ....... ....... # Override ftp server receive channel reponse mechanism # XXX hack alert, this should probably be redone in a more OO way. def handle_close (self): .......... self.readable=lambda :0 # don't call close again recv_channel.handle_close=handle_close which makes it virtually impossible to re-use medusa's ftp_server in a reasonable way. The comment says it all. The real problem is that ftp_channel uses a method make_recv_channel which uses a global class recv_channel and the recv_channel class has a particular method which zope wants to override. How ought this kind of situation to be handled more cleanly? -- Robin Becker From rturpin at my-deja.com Fri Jan 5 18:33:57 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Fri, 05 Jan 2001 23:33:57 GMT Subject: How robust is Python ? References: <9354f9$vbi$1@nnrp1.deja.com> <935dus$cd2$1@saltmine.radix.net> Message-ID: <935ll5$f7n$1@nnrp1.deja.com> In article , morpheus at here.not.there wrote: > Other than the obligatory "Don't use Windows for > that", no. :) Two contradictory thoughts .. (a) Cross-platform isn't really a challenge if you mean only various Unices. That's too easy. (b) "Forever" really means "until the platform is next rebooted for other reasons." For a Sun or Linux workstation, "forever" might be a year or more. Windows has a clear advantage in this regard: "forever" is shorter. A lot shorter. Russell Sent via Deja.com http://www.deja.com/ From s2mdalle at titan.vcu.edu Sun Jan 28 00:09:22 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Sun, 28 Jan 2001 05:09:22 GMT Subject: Newbie Tkinter question References: Message-ID: <6QNc6.5350$pb6.1441348@typhoon2.ba-dsg.net> In article , "jerry keeney" wrote: > The following little program is giving me some problems. > > The problem is with self.button2. When this part of code is commented out, > the program works. When I uncomment it out, like here: I get an invalid > syntax error for self.button2.grid(row=1,column=1) > > What obvious thing am I missing here? The 'column' keyword should be 'col', not 'column'. -- David Allen http://opop.nols.com/ ---------------------------------------- A chubby man with a white beard and a red suit will approach you soon. Avoid him. He's a Commie. From sandj.williams at gte.net Tue Jan 23 10:21:47 2001 From: sandj.williams at gte.net (Steve Williams) Date: Tue, 23 Jan 2001 15:21:47 GMT Subject: How do I know all thrown exceptions of a function? References: , <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> <94ipci$afo$1@animus.fel.iae.nl> <3A6CFD8E.BD473DFD@gte.net> Message-ID: <3A6DA2F0.96BFAF2A@gte.net> Moshe Zadka wrote: > On Tue, 23 Jan 2001 07:45:18 GMT, "Fredrik Lundh" wrote: > > > No, the rule is "don't ever use from-import if you don't know what > > you're doing". > > I think we can safely generalize this rule to "don't do things unless > you understand the effects"... > -- > Moshe Zadka > This is a signature anti-virus. > Please stop the spread of signature viruses! > Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 Ars longa, vita brevis. . . From b012414 at mail.dvz.fh-koeln.de Fri Jan 12 11:14:53 2001 From: b012414 at mail.dvz.fh-koeln.de (Stephan Effelsberg) Date: Fri, 12 Jan 2001 17:14:53 +0100 Subject: Using reflection in Python? References: <93lt6g$qdb$1@troll.powertech.no> Message-ID: <3A5F2D7C.2353488@mail.dvz.fh-koeln.de> Not a bad idea, but usually modules come with their own test harness which is in many cases better than a universal tester. But reflection reminds me to Java, which makes use it to get the properties of JavaBeans. Instead of testing you should use your reflection idea to create a framewok similar to this one. Maybe you can call it PythonEggs. From chris at voodooland.net Thu Jan 11 12:00:36 2001 From: chris at voodooland.net (Chris Watson) Date: Thu, 11 Jan 2001 11:00:36 -0600 (CST) Subject: Starting application inside an application In-Reply-To: <3A5D7722.2977BFE0@proceryon.at> Message-ID: Horst, > What I want to do is simply starting a second instance of my application > (just like starting the application from the command line a second > time). I am looking for a function like spawnv() which unfortunately > only works for the windows platform. Use os.spawnv works great on FreeBSD and Python 2.0 built fresh from the ports tree. It isn't in 1.x but it is in 2.0. I am assuming your using 1.x since you say it's only a windows "feature". Just upgrade to 2.0. The call works like a charm :-) #!/usr/local/bin/python import os host = raw_input("Enter a hostname: "); os.spawnv(os.P_WAIT, '/usr/bin/scp', ('-v', 'x86bsd@%s:/home/x86bsd/TESTFILE' % host, '/tmp/TESTFILE')) -- ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From scott at csihq.com Tue Jan 2 16:23:10 2001 From: scott at csihq.com (Scott Bortman) Date: Tue, 2 Jan 2001 16:23:10 -0500 Subject: Q: JPython, NumPy, and PIL? Message-ID: Hello, Can I use the NumPy or PIL libraries from JPython? Thanks in advance, scottie From patrickdlogan at home.com Sun Jan 7 17:43:12 2001 From: patrickdlogan at home.com (Patrick Logan) Date: Sun, 07 Jan 2001 22:43:12 GMT Subject: CO-process References: <93a535$n76$1@nnrp1.deja.com> <_2666.240898$U46.7569402@news1.sttls1.wa.home.com> Message-ID: <4i666.240905$U46.7570799@news1.sttls1.wa.home.com> wrote in message news:93a535$n76$1 at nnrp1.deja.com... > > after Mirosoft create .NET , it's time to answer > > have a look to: > > http://home.t-online.de/home/aotto/mqcon_E.html The CO-process does not seem to support multiple languages in the same OS process operating on a shared object model/space. That seems to be a big advantage of .net CO-process appears to be based on multiple processes for everything. Is communication based on sockets or some other network mechanism so the processes are host-independent? That'd be interesting and flexible, but too heavyweight for many of the things you'd want to use .net for. -- Patrick Logan mailto:patrickdlogan at home.com From claird at starbase.neosoft.com Tue Jan 2 12:51:59 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 2 Jan 2001 11:51:59 -0600 Subject: Pythonic concurrency (was: Erlang (was Re: Good introduction to References: <92A081D417204A91.AF29627FD1BF4835.0C336CAB4734825B@lp.airnews.net> <3A4F8E91.3F29F97C@letterror.com> Message-ID: <881A12DF74ECCB7D.31A676568924AC5F.3D8A4DED140164F7@lp.airnews.net> In article , Will Ware wrote: >> Cameron Laird wrote: >> > Is this true: microthreads block on system calls (I/O >> > operations, most notoriously) and on invocations of >> > externally-coded extensions? > >Just van Rossum (just at letterror.com) wrote: >> They do. > >Yup, microthreads treat Python opcodes as atomic, including system I/O >calls and calls to C extensions. This is because Stackless Python is a >mechanism for tweaking the execution order of the Python virtual machine, >which steps thru Python opcodes. My earlier assertion was sloppy. My bad. . . . As you know, Will, this is a not-particularly-widely-understood region of computing, and I think it can stand a bit more expo- sure. Your good (and you're good) for making it clear. Naive readers might wonder, why does it matter? Here's an example: you need a win32api calculation, maybe something com- puted by an (external) Excel process. You ask for the result. Ten seconds later, it hasn't returned. At this point, you might want to tell the end-user, "We're still grinding; don't give up", OR start an alternate calculation likely to yield an approximation quickly OR signal Excel to give up OR ... With a conventional Python architecture, though, you can't. Even if you put the Excel invocation in its own thread or microthread, no other Python thread can regain control until Excel gives it back. That's a big issue for some people, while others go decades with- out encountering it. Correct, Just and Will? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sheila at spamcop.net Sat Jan 27 22:52:32 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 28 Jan 2001 03:52:32 GMT Subject: [Off topic] allowed to put Python material on the Web? References: <3a730931.31998180@news.skynet.be> <3A73940E.2637C648@alcyone.com> Message-ID: On Sat, 27 Jan 2001 19:37:50 -0800, Erik Max Francis wrote in comp.lang.python in article <3A73940E.2637C648 at alcyone.com>: :Sheila King wrote: : :> Technically, once the messages are posted to Usenet, anyone can :> archive and :> copy them. : ... :> Authors of Usenet posts still retain copyright to :> their own :> material. : :These two statements are inconsistent with one another. (The latter is :the one that is correct, by the way.) They are not inconsistent. Technically, you CAN archive and copy them. I can archive and copy all the posts in this newsgroup, if I want to. I have the ability, the hardware, the software and the know-how. Now legally, ethically,... that is another matter... -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From johngrayson at home.com Wed Jan 17 07:33:50 2001 From: johngrayson at home.com (John Grayson) Date: Wed, 17 Jan 2001 12:33:50 GMT Subject: Are there Tkinter examples somewhere? References: <20010117000807.198D9E951@mail.python.org> Message-ID: <9443fe$nfa$1@nnrp1.deja.com> In article , wware at world.std.com (Will Ware) wrote: For lots of example code you could try: http://www.manning.com/Grayson/Source.html John Sent via Deja.com http://www.deja.com/ From phys137 at mailcity.com Wed Jan 10 19:49:35 2001 From: phys137 at mailcity.com (phys137 at mailcity.com) Date: Thu, 11 Jan 2001 10:49:35 +1000 Subject: How to check on process time? References: <93ie2i$bse$1@nnrp1.deja.com> <93iip0$jhu$1@nntp6.u.washington.edu> Message-ID: <93isdq$fhr$1@mail.pl.unisys.com> long time ago i used sun's call 'getresourceusage' to obtain process times on bsd - some other unixes had similar calls or not on nt there are nice GetProcessTime and GetThreadTime calls maybe a module like that could be added to Python's library? I'm not volunteering to write it. In case somebody wants here's some considerations: most systems return process/thread cpu time with purported high resolution (like 100nanoseconds) but the real accuracy is 1-10ms, sometimes even worse. So no point in returning all these detailed stuff - 1ms accuracy is enough most systems return elapsed time with similar accuracy when using 'standard' c library. Yet some have microsecond clocks which actually work. On NT current call for that is QueryPerformanceCounter and QueryPerformanceFrequency. System call overheads are in order of several microseconds. 64bit integers are generally useful for that - pity Python doesn't have them. here's some very bad sample code from nt (it should use __int64 instead) HANDLE hP = OpenProcess(PROCESS_QUERY_INFORMATION, true, GetCurrentProcessId()); FILETIME creation, exit, kernel, user; if (!GetProcessTimes((HANDLE) hP, &creation, &exit, &kernel, &user)) { return -1; } // we divide processor time (in .1ms units) by 256, to make it // fit into 32 bit int. then we return the sum of kernel and user // the units are then 25.5 microseconds and range is 109951 seconds // all of these because of the lack of 64 bit add / subtract in NT... LARGE_INTEGER li; li.LowPart = kernel.dwLowDateTime; li.HighPart = kernel.dwHighDateTime; long kernelTime = Int64ShraMod32(li.QuadPart,8) & 0xFFFFFFFF; li.LowPart = user.dwLowDateTime; li.HighPart = user.dwHighDateTime; long userTime = Int64ShraMod32(li.QuadPart,8) & 0xFFFFFFFF; return kernelTime + userTime; "Donn Cave" wrote in message news:93iip0$jhu$1 at nntp6.u.washington.edu... > Quoth noahspurrier at my-deja.com: > | Which Python library do I want to get extensive process information? > | I need to look at any process running -- not just the parent, current, > | or child processes. > > As far as I know, that isn't supported on contemporary computer > platforms, at least in any meaningfully portable way, and that > would be why you don't see anything for it in Python. The "ps" > command doesn't use any kind of API, it just reads kernel memory > where this stuff is stored. > > If it doesn't need to be portable, and your present platform > supports it, I'd say use the "/proc" filesystem. The following > prints accumulated times, on FreeBSD 4.1. > > Donn Cave, donn at u.washington.edu > ---------------------------------------- > import errno > import posix > import string > > def ps(): > proc = posix.listdir('/proc') > for pid in proc: > try: > pidval = string.atoi(pid) > except ValueError: > # Ignore /proc/curproc etc. > continue > try: > fp = open('/proc/%s/status' % (pid,), 'r') > except IOError, val: > if val.errno == errno.ENOENT: > print pid, '... already gone' > continue > else: > raise > ln = fp.readline() > fp.close() > ln = string.split(ln) > cmd = ln[0] > uss, usu = map(string.atoi, string.split(ln[8], ',')) > sys, syu = map(string.atoi, string.split(ln[9], ',')) > print '%5s %-14s%6d.%06d %d.%09d' % (pid, cmd, uss, usu, sys, syu) > > ps() From mjackson at wc.eso.mc.xerox.com Fri Jan 5 16:24:57 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 5 Jan 2001 21:24:57 GMT Subject: bug with command line option - in 1.5.2? References: <3a561b87$1_1@news.nwlink.com> Message-ID: <935e39$q5g$1@news.wrc.xerox.com> "Travis Hume" writes: > Given a simple python script > > > import sys > print sys.argv[1] > > > Shouldn't the command > > python - foo < testpy.py > > print the word foo to stdout? Instead I'm getting this > > ~/tmp >python - foo < testpy.py > python: can't open file 'foo' > ~/tmp > Both "python - foo < testpy.py" and "python testpy.py foo" work for me (1.5.2 on Solaris 5.6): yngvi> python - foo < testpy.py foo yngvi> python testpy.py cat cat Does the latter work for you? -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson The power of accurate observation is frequently called cynicism by those who don't have it. - George Bernard Shaw From fredrik at effbot.org Wed Jan 3 16:45:28 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 03 Jan 2001 21:45:28 GMT Subject: Name Error References: <3A5395B5.EBE77FA4@bioeng.ucsd.edu> Message-ID: Curtis Jensen wrote: > Below is a bit from my Python interpreter. The "stored_data" variable > is a global list. It should be seen from within the "send_data" > function. However, I get a NameError here. I ran it with pdb; pdb is > able to output the "stored_data" variable from within the "send_data" > function. However, it still gives a NameError. > > "stored_data" works in all of my other functions except this one? Any > ideas? Python 1.5.2? do you by any chance assign to "stored_data" in that function? (if you can, please post the source for send_data...) cheers /F From beno at TheWebsons.com Sat Jan 20 12:43:38 2001 From: beno at TheWebsons.com (Ben Ocean) Date: Sat, 20 Jan 2001 09:43:38 -0800 Subject: Tweaking for New Co-lo Message-ID: Hi; I just moved my server. What a joy. Now my python install (on RedHat 6.2) is broken. Do I need to rebuild from scratch or is there an easy fix? TIA, BenO -------------- next part -------------- An HTML attachment was scrubbed... URL: From moshez at zadka.site.co.il Sun Jan 14 21:31:52 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Mon, 15 Jan 2001 04:31:52 +0200 (IST) Subject: how do i disable buffered output, like Perl's '$|=1'? In-Reply-To: <979490967.23219.0.pluto.d4ee691b@news.demon.nl> References: <979490967.23219.0.pluto.d4ee691b@news.demon.nl> Message-ID: <20010115023152.B51A3A828@darjeeling.zadka.site.co.il> On Sun, 14 Jan 2001 17:58:52 +0100, "floR" wrote: > I can't find anywhere how I can disable 'buffered output', or whatever it is > called. > In Perl, you simply say $|=1, but in Python? > Can anyone help me? If you want to flush, you can use fp.flush() (E.g., sys.stdout.flush()). If you want stdout to autoflush you can do: class AutoFlusher: def __init__(self, fp): self.fp = fp def write(self, s): self.fp.write(s) self.fp.flush() def writelines(self, lines): self.fp.writelines(lines) self.fp.flush() sys.stdout = AutoFlusher(sys.stdout) -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From db3l at fitlinxx.com Fri Jan 26 00:48:40 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Jan 2001 00:48:40 -0500 Subject: Scripting WMI with win32com Message-ID: I was wondering if anyone has done scripting of WMI with win32com and dealt with making method calls after parsing the typelib? I've been experimenting to see if it would be usable for management of LANs in the field, and in general it looks nice, but I run into some issues when trying to invoke methods on provider objects (such as the Win32 provider). What seems to happen is that running makepy on the provider library identifies all of the SWbem* objects, but when I obtain a provider object, it just looks like an instance of SWbemObject. That makes sense, but I'm having difficulty figuring out how to invoke a method on such an object cleanly and access properties. It would appear that both VBScript and JScript have some special support for this, which involves looking at the Properties_ and (I suppose) Methods_ collections when a direct notation (e.g., object.value or object.call()) is used. I had some issues with accessing properties too, but found some older threads that showed a function-call method of doing a name lookup on the Properties_ value (or via the Item call) which works fine. But I'm not quite sure how to play with the methods. In some respects, it's almost easier if I use the dynamic approach since I'm getting caught by the actual Python objects generated by makepy - if it just passes the attribute and method operations through they work. (But of course I'm sure I'll find something that won't handle the parameters or output right without the typelib). Thanks for any help. -- -- 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 m.hadfield at niwa.cri.nz Mon Jan 29 18:44:51 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Tue, 30 Jan 2001 12:44:51 +1300 Subject: How to extend sys.path on Win9x permanently? References: <3a75ef9c.11194652@news.muenster.de> Message-ID: <980811891.858385@clam-ext> > (1) I'd like Python.exe/DOS AND Python in PythonWin to start > up with an extended sys.path, having my own lib added, as if a > sys.path.append('c:\\mylib') had already been performed. > How can I add the extra path permanently? Edit the registry--see below > (2) Here's what sys.path is on my machine. Where is this defined? > Registry? Yes. Take a look at the registry branch rooted at (for version 2.0) HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.0\PythonPath You should be able to deduce how it works. > (3) I'd hate having to put something like "set $PYTHONPATH=..." into > AUTOSTART.BAT, since DOS environment space is very limited. No need. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/ National Institute for Water and Atmospheric Research PO Box 14-901, Wellington, New Zealand From gerhard.nospam at bigfoot.de Mon Jan 1 16:37:46 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Mon, 1 Jan 2001 22:37:46 +0100 Subject: Recursion References: Message-ID: The highest value that works for me (Python 2.0/Linux x86) is 999L. Adding L to a number makes it of type 'long' instead of type 'int'. Perhaps Perl and Ruby do automatically use long when necessary. On Mon, 1 Jan 2001 15:54:13 -0500, Bob Calco wrote: >PYTHON >====== >import sys > >def factor(n): > if n == 1: > return 1 > else: > return n*factor(n-1) > >print factor(int(sys.argv[1])) -- mail: gerhard bigfoot de web: http://highqualdev.com From jhorSPAMBGONneman at wanadoo.fr Mon Jan 29 14:19:57 2001 From: jhorSPAMBGONneman at wanadoo.fr (Jurie Horneman) Date: Mon, 29 Jan 2001 20:19:57 +0100 Subject: Unicode pb in Python 2.0 solved - no thanks to WinPython - I mean, PythonWin References: <95b65r$l27$1@wanadoo.fr> Message-ID: <95ccqg$h0r$1@wanadoo.fr> "Michael Hudson" wrote in message news:m3d7d27fjx.fsf at atrus.jesus.cam.ac.uk... "Jurie Horneman" writes: > I would very much like to "RTFM", and believe me I tried, but there isn't > much M to FR. How could I have avoided this problem with less agony? Should > I report the bug to the authors of WinPython? >>Do you mean PythonWin? I would, yes.<< OK, any remaining credibility I had is now gone ;) Yes, I meant PythonWin. I'll go find the site and report it. -- Jurie Horneman Opinions expressed are my own jhorSPAMBGONneman at wanadoo.fr From fredrik at effbot.org Wed Jan 17 03:17:14 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 17 Jan 2001 08:17:14 GMT Subject: Command language definition References: <3A6542EC.99ED1149@intes.de> <20010117082100.A21854@yetix.sz-sb.de> Message-ID: Rolf FISCHER wrote: > My first (and very raw) impression on python was, that the tool has excellent > capabilites in easy programming, but I didn't see anything the like to check a > syntax or to define one. This is why I asked for additional tools. The first and most obvious question is of course why you cannot use Python itself as the command language... http://www.python.org/doc/current/lib/module-code.html If you insist on building your own command language, you can perhaps use the cmd (simple CLI) or shlex (shell-like lexing) modules: http://www.python.org/doc/current/lib/module-cmd.html http://www.python.org/doc/current/lib/module-shlex.html For fancier stuff, skip over to the vaults of parnassus and look under "programming tasks, parsing and formatting" http://www.vex.net/parnassus/ Hope this helps! Cheers /F From tjreedy at udel.edu Thu Jan 18 18:54:33 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 18 Jan 2001 18:54:33 -0500 Subject: Garbage collector - please Help !! References: <9475ob$c6v$1@nnrp1.deja.com> Message-ID: <947vml$fd0$1@news.udel.edu> > the reference counting gc in python 1.5 does not work if you have > cyclic references between objects. it is fixed in 2.0. If you explicitly import the gc module and call the gc function. From cfelling at iae.nl Sat Jan 27 22:03:34 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 28 Jan 2001 04:03:34 +0100 Subject: . Python 2.1 function attributes References: Message-ID: <950266$j06$1@animus.fel.iae.nl> Tim Peters wrote: >> -why don't we have $ and @ and \ operators-ly yrs- > Because so far, Guido hates them. This is usually something you can count > on for life. But, e.g., in the past he disliked the idea of being able to > say > if key in dict: Yuckideyuck! Just what are you feeding Guido.From carel Sun Jan 28 03:26:24 2001 From: Carel Fellinger Subject: klets Newsgroups: thuis.test Organization: Summary: Keywords: sd fsdf sdf sd fsd -- groetjes, carel From root at rainerdeyke.com Mon Jan 29 13:59:38 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 29 Jan 2001 18:59:38 GMT Subject: marshal doesn't work with "file-like" objects References: <5.0.2.1.0.20010126135016.029c4d90@mail.mindspring.com> <94t1bi$m73$1@nnrp1.deja.com> <950ab5$2h2$1@nnrp1.deja.com> <9546kl$q4$1@nnrp1.deja.com> Message-ID: wrote in message news:9546kl$q4$1 at nnrp1.deja.com... > In article , > Erno Kuusela wrote: > > did you try cPickle's binary mode? it is many times faster than > > the default text mode at least on my machine. > > Yes, my benchmark was cPickle vs. marshal. If you look at the extra > benefits that pickle offers over marshal (providing custom hooks, > handling recursive data structures, handling user-defined objects, etc.) > it's clear that marshal pretty much *has* to be faster, provided that > both implementations are high quality. He was refering to binary vs text mode within cPickle, not pickle vs cPickle. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From clarence at netlojix.com Tue Jan 30 13:10:20 2001 From: clarence at netlojix.com (Clarence Gardner) Date: Tue, 30 Jan 2001 10:10:20 -0800 Subject: Thread Safety References: Message-ID: <980878523.1347842479@news.silcom.com> I'll make a last contribution to this thread, reiterating Timmy's wisdom: >cleverness-is-the-#1-cause-of-thread-bugs-ly y'rs - tim and >"thread safety" is not an absolute judgment I received a message in email saying that my function was thread-safe after all: > >> Python executes bytecodes atomically, but makes no guarantees beyond that. > >> Do you still think you're "threadsafe"? > > Nope. > You'd be wrong. > > [...] given that the function shown is the only place that > > the Pending... names are bound (other than initialization). > That's why you're wrong. > > answer to "That's not safe, no". Given the need for mutex, I'll change > > them to classes, I think. > [...] > > Of course, I'll need to protect all the additions to the lists, also. > You don't need a mutex, and you don't need to protect any additions to > (or removals from) the lists. As long as nothing else _assigns_ > ("binds" by the common Pythonic misuse of that word) the global > variable, which you've said above isn't going to happen, there's no > possibility of losing items. It doesn't make the slightest difference > whether you use > data, Pending... = Pending..., [] > or > data = Pending... > Pending... = [] > though; either way is thread-safe given the above condition. Now, my original question related to the Data,PendingDataStorage = PendingDataStorage,[] type of statements, but nonetheless, with respect to the actual context, Data,PendingDataStorage = PendingDataStorage,[] if Data: StoreDataPoints(Data) this is not safe; even though an append to PendingDataStorage done elsewhere will not be lost (it will appear in either Data or the new PendingDataStorage), it might appear in Data *after* the StoreDataPoints function runs, which is effectively the same as losing it. Looking at code for the append, 18 LOAD_GLOBAL 1 (PendingDataStorage) 21 LOAD_ATTR 2 (append) 24 LOAD_FAST 0 (data) 27 CALL_FUNCTION 1 this situation would arise if StoreDataPoints is called (and completes) after instruction #18 and before #27. cleverness?-I've-got-some-cheap-ly y'rs - clarence (I said in a post almost three years ago that I wouldn't cheapen Tim's signature art form with my pedestrian attempts; I guess I lied :) ) From moshez at zadka.site.co.il Mon Jan 8 16:20:17 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Mon, 8 Jan 2001 23:20:17 +0200 (IST) Subject: zombie question In-Reply-To: <93c19g$5k7$1@nnrp1.deja.com> References: <93c19g$5k7$1@nnrp1.deja.com> Message-ID: <20010108212017.68C4CA82D@darjeeling.zadka.site.co.il> On Mon, 08 Jan 2001 09:29:25 GMT, jianchen at my-deja.com wrote: > I have tried some methods from W.R.Stevens's famous work Unix Network > Programming such as catch the SIGCHLD signal in the daemon process. But > strangly when the child process exit, no signal send! Even when I > explicitly use kill to send SIGCHLD signal to the parent process, the > signal function seems not get called! ;( can you post a short code example? Nothing with SMTP, just something that registers the handler, creates a child, and the child dies. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From laura_01 at my-deja.com Sat Jan 20 18:01:31 2001 From: laura_01 at my-deja.com (laura_01 at my-deja.com) Date: Sat, 20 Jan 2001 23:01:31 GMT Subject: Neophyte looking for good books on Python References: <94ak66$dra$1@nnrp1.deja.com> <94aulr$m1o$1@nnrp1.deja.com> <980023572.27042@iris.nyx.net> Message-ID: <94d5c9$99m$1@nnrp1.deja.com> Hi, That's an interesting idea you suggest on price point, and I think it can work for e-books. In this particular case, I can say (as Fredrik did) that Mark's 2nd edition is completely new (I'd say 80% new). Therefore, it will be like buying a new book anyway. Laura LLewin at oreilly.com In article <980023572.27042 at iris.nyx.net>, sarayu balu wrote: > laura_01 at my-deja.com wrote: > : Hi! The next edition of "Programming Python" by Mark Lutz is due out in > : early March, > : if you can wait about a month. > > : Laura > : LLewin at oreilly.com > > I have the old edition of "Programming Python" by Mark Lutz. > I do not know if Oreilly suggests that I pay the full price > for this new edition. These days, there seems to be a newer > edition so often, that we programmers have become suckers > for the publishing company. Java is the classical example. > > Oreilly should take the leadership in this area, in selling > newer editions at substantial discounts for owners of older > editions, or follow Bruce Eckel's model of putting the whole > book on the web. What do you folks think ? > -sb > -- > Dr.Sarayu Balu,M.D.,FAAP Tel.(802)888-2448 > Ryder Brook Pediatrics, > P.O.Box 608, Morrisville, VT 05661. > Sent via Deja.com http://www.deja.com/ From daniel.dittmar at sap.com Fri Jan 19 12:30:00 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Fri, 19 Jan 2001 18:30:00 +0100 Subject: Global interpreter locks, thread states et al... References: <979902284.26681.1.nnrp-10.c3ad12d2@news.demon.co.uk> Message-ID: <949tiq$cn$1@news1.wdf.sap-ag.de> I found the python standard modules to be excellent examples. Grep for the macros and see how they are used. Daniel -- Daniel Dittmar daniel.dittmar at sap.com SAP DB, SAP Labs Berlin http://www.sapdb.org/ "Toby" wrote in message news:979902284.26681.1.nnrp-10.c3ad12d2 at news.demon.co.uk... > Are there any examples (other than pysvr.c shipped with Python 2.0) to > explain the appropriate calls and architecture ? documentation seems to be a > little sketchy.. > > Toby > > From phd at phd.pp.ru Tue Jan 23 07:04:48 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 23 Jan 2001 15:04:48 +0300 (MSK) Subject: os.system easy question In-Reply-To: Message-ID: On 23 Jan 2001, Erno Kuusela wrote: > import signal, os > class BgProc: Found on http://www.vex.net/parnassus/apyllo.py/990075885: "Process.py: high-level process class, plus some high-level functions." http://www.lib.uchicago.edu/~tao/software/libraries/Process2.py Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From claird at starbase.neosoft.com Wed Jan 24 09:18:43 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 24 Jan 2001 08:18:43 -0600 Subject: Conspiracy Revealed References: Message-ID: <585D1BBE4D788B4E.35313289DCB42713.B5A348AE8684A9E7@lp.airnews.net> In article , Fredrik Lundh wrote: >anonymous at zadka.site.co.il (doubt you'll need Don Foster >to figure out who hides behind this nom de guerre) wrote: > >> Tim is actually an alien intelegience, capable of taking over people's >> minds > >he's pure software. part lisp, part python. > >> Alex Martelli came into c.l.py and started to write scarily-timbot-like >> postings > >same software, different verbosity settings (this one >goes to eleven) > > Incidentally, where's the PSA been relocated? I've got a DVD of "This is Spinal Tap" I've been intending to donate. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From clgonsal at keeshah.penguinpowered.com Mon Jan 29 03:01:55 2001 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Mon, 29 Jan 2001 08:01:55 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> Message-ID: On Sun, 28 Jan 2001 22:04:38 -0600, Grant Griffin wrote: >Hi Gang, > >I'm sure this has been asked a thousand times, but I haven't seen it >asked lately (or ever ). > >Why does Python use square braces ([]) instead of curly braces ({}) >when accessing dictionaries? > >This strange inconsistency in Python seems strangely inconsistent with >its otherwise very consistent application of consistency: since we use I think there are many that would argue that using a different notation would be far *more* inconsistent. x[y] gets the thing that x maps y to. In Python, a sequence is a map of integers to values, while a dictionary is a map of arbitrary keys to values. Why use a different notation for what's really the same sort of thing? Actually, the thing that's always bugged me is that Python makes a distinction between subscripting (__getattr__) and function calls (__call__). Mathematically speaking, a dictionary is really just a function that maps from 'keys' to 'values'. It always seems silly to me that given: m = {'one': 1, 'two':2} l = ['two', 'one'] one can't write: map(m, l) Instead one has to write: map(m.get, l) or (depending on your level of paranoia): map(lambda k,m=m:m[k], l) >Anyway, although curly braces are perhaps slightly harder to type than >square braces, this is one example (maybe the only one) where I find >Perl code more readable: I appreciate the mnemonic effect curly braces >have in reminding me that the thing being accessed is a dictionary*. I'm not sure why you need to be reminded whether something is a sequence or a dictionary. -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From timr at probo.com Thu Jan 11 00:22:54 2001 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Jan 2001 21:22:54 -0800 Subject: compiling .cgi files References: Message-ID: carlhiga at yahoo.com wrote: > >I'm running some python cgi scripts that need to have the '.cgi' >extension in their filename. > >Is there anyway to get them to be byte code compiled? I understand >that if they were '.py' files I could simply import them using the >interpreter and it would produce the '.pyc' files. But I don't know >how to do this with '.cgi' files. What about this? It's not too ugly, and the "import" will cause the pyc to be generated and used. myscript.cgi: #! /usr/bin/python import myscript myscript.py: #! /usr/bin/python # ... rest of the script .. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From hvrosen at world-online.no Wed Jan 31 17:46:17 2001 From: hvrosen at world-online.no (Henning VON ROSEN) Date: Wed, 31 Jan 2001 23:46:17 +0100 Subject: Best way to match everything between tags Message-ID: Hi! I am learning regular expressions. What is thenatural way to match everything that is not "something" fx i want to maipulate all the text of a html document, but none of the tags This matches all the tags; s="textsome textmore texttext" r = re.compile(r"<.*?>") print r.sub("WWW",s) this works fine if I want to manipulate the tags, but I want to maipulate the text between tags I haven't found a one-expression way. Thankful for any indications! /Henning von Rosen From fabrice.n at home.com Sun Jan 28 13:56:54 2001 From: fabrice.n at home.com (shaka) Date: Sun, 28 Jan 2001 18:56:54 GMT Subject: Anyone get python on win98?? Message-ID: Ok, I need some help here. I just download python on my computer. I installed it to C:\programming\python20 I know how to use the interactive mode. And when write a script I usually run it from the editor(idle) by clicking on "run script". But when I try to run the script using the interpreter, it doesn't work. What I do is to type the name of the script.py in the interactive mode. It always give me an error message like: Traceback (most recent call last): File "", line 1, in ? NameError: There is no variable named 'hello' Is the interpreter suppose to be in interactive mode everytime? If you have no idea of what I am talking about, can you just describe me how you usually run your script. From mike at thebumblebee.com Sat Jan 20 20:41:25 2001 From: mike at thebumblebee.com (Mike Morasky) Date: Sat, 20 Jan 2001 17:41:25 -0800 Subject: relocation problems Message-ID: <3A6A3E45.960FAD45@thebumblebee.com> I've written a stack of python extension modules and fear that I have outgrown the allowable dynamic addressing space. When loading a module I get: ImportError: /usr/local/lib/foo.so: R_PPC_REL24 relocation out of range I'm assuming that I've (unbelievably) outgrown the allowable address space of dynamically loaded modules. I'm somewhat new to dsos on linux so if anyone could shed a little light on this I'd appreciate it. From fredp at mygale.org.nospam Fri Jan 12 03:46:33 2001 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 12 Jan 2001 08:46:33 GMT Subject: ANNOUNCE: PyXPCOM - Python bindings for Mozilla XPCOM technology References: <93le4v$10m$1@nnrp1.deja.com> Message-ID: Mark Hammond said : >ActiveState is pleased to announce the first release of the Python >bindings for the Mozilla XPCOM (Cross-Platform COM) technology. Great news ! Thanks to you & to AS Mark... One thing isn't very clear to me though : do these bindings allow Python to directly manipulate the Gecko rendering engine, or do they talk to some abstraction layer(s) above that ? To illustrate the question I'm thinking about what Galeon (for Unix) or K- meleon (for Win32) are doing on the one hand, vs. scripting the actual Mozilla interface (requiring the whole enchilada) on the other hand. Sorry if the question is really dumb, but I'm quite lost in the complexity of the Mozilla architecture right now :) -- YAFAP : http://www.multimania.com/fredp/ From hadidab at yahoo.fr Fri Jan 26 07:23:09 2001 From: hadidab at yahoo.fr (=?iso-8859-1?q?ABDENOUR=20HADID?=) Date: Fri, 26 Jan 2001 13:23:09 +0100 (CET) Subject: how to excecute the script.. Message-ID: <20010126122309.12576.qmail@web206.mail.yahoo.com> dear friends; i just started to progam with python. I download it and I can write and excute somethings in the interpreter.... but I want to write my progam or script in another text editor and excute it...with the command (python filename..)...but Its dosn"t work... can you help me? thank you ___________________________________________________________ Do You Yahoo!? -- Pour dialoguer en direct avec vos amis, Yahoo! Messenger : http://fr.messenger.yahoo.com From akuchlin at mems-exchange.org Tue Jan 23 17:50:52 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 23 Jan 2001 17:50:52 -0500 Subject: I mean *setup.py* ! ... (more questions) References: Message-ID: <3dwvbl3msz.fsf@ute.cnri.reston.va.us> "Steven D. Majewski" writes: > If there no simple fix for that: what do we need to do to > get a lib/plat-Darwin1.2 directory with prebuilt files > added to the distribution ? ( I have all the files after > a successful install. ) Probably just submit a patch on SourceForge with the files. --amk From quinn at ngwee.ugcs.caltech.edu Sat Jan 27 00:56:23 2001 From: quinn at ngwee.ugcs.caltech.edu (Quinn Dunkan) Date: 27 Jan 2001 05:56:23 GMT Subject: Execute an external application from inside a python script References: Message-ID: On Fri, 26 Jan 2001 12:26:44 +0100, Arild Hansen wrote: >Hello, > >How do I execute an (executable) application from inside some python code, See os.system(), os.fork(), or os.spawnv() >and how do I terminate this application? All help greatly appreciated. Under unix, os.kill(). Under windows, I dunno. Poke about in the win32 module documentation. Unix example with os.spawnv (python2 feature): import os pid = os.spawnv(os.P_NOWAIT, '/bin/sleep', ('sleep', '500')) ... stuff ... # time to kill it: os.kill(pid, signal.SIGTERM) wpid, status = os.waitpid(pid, 0) signal = status & 0xff status = status >> 8 print '%d killed by signal %d with status %d' %(wpid, signal, status) From fredrik at effbot.org Wed Jan 17 17:42:14 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 17 Jan 2001 22:42:14 GMT Subject: Location of variables References: <9456a4$8bi$1@pulp.srv.ualberta.ca> Message-ID: Grzegorz Dostatni wrote: > Is there a way in Python to find out the memory location of variables? > Something like > > def s(): > pass > > print s > > will print the type and memory location of s. > Is there something like that if s is just a simple variable? > (int for example). > > I need it to help me debug a problem... print type(s) print id(s) footnote: objects don't have addresses, they have identities. the identity happens to be a memory address in CPython, but that's an implementation detail. more info here: http://effbot.org/guides/python-objects.htm hope this helps! Cheers /F From andrew_dot_henshaw_at_earthling_dot_net Sun Jan 14 13:58:32 2001 From: andrew_dot_henshaw_at_earthling_dot_net (Andrew Henshaw) Date: Sun, 14 Jan 2001 13:58:32 -0500 Subject: Using re - side effects or misunderstanding References: <87y9wel7fm.fsf@sune.interspace.dk> Message-ID: This is all part of my question about side effects. As soon as I introduce grouping, then the behavior of findall changes dramatically. With findall, using groups for grammatical purposes has the side-effect of dramatically changing the return type. I have a class that uses passed in re's. Internal to the class, I'm using findall against those re's. Because theuser may want to use groups for grammatical purposes only (he doesn't care about what it does to the findall command), then I have to program in a manner that reduces performance. I have to either apply string.join to all return values (which seems pretty extravagant when the return value is already a string), or check the return type. I was asking the question to see if I was missing something, but apparently I wasn't. Would not an acceptable solution be to define a new re compile flag that indicates that grouping only serves a grammatical function? AH "Sune Kirkeby" wrote in message news:87y9wel7fm.fsf at sune.interspace.dk... > > [ "Andrew Henshaw" ] > > But I thought that ?: is for matching but not returning. And so it is, > > under certain circumstances, e.g. > > It always is, and it always does. > > > if my pattern is > > '(ab)(c)xyz' > > I get > > [('ab', 'c')] (Yikes! a tuple. I'm going to have to change my code a > > bit to handle this) > > but > > '(ab)(?:c)xyz' > > yields, > > ['ab'] > > and > > '(?:ab)(?:c)xyz' > > gives > > ['abcxyz'] > > All of the above are what one would expect, since re.findall returns > a list of matches, if there are no groups in the re. But if there are > groups it will _only_ return a list of tuples with the matched groups. > > Note that (?:...) is non-grouping, so in '(?:ab)(?:c)xyz' there are > no groups, but in '(ab)(?:c)xyz' there is one group, which will then > be returned. > > > so how do I get the result > > ['abxyz'] > > ?? > > Something along the lines of, > > >>> r = re.compile('(ab)c(xyz)') > >>> matches = r.findall('..abcxyz..') > >>> matches > [('ab', 'xyz')] > > almost there, just have to join the tuples, > > >>> map(lambda l: string.join(l, ''), matches) > ['abxyz'] > > Voila! > > > In other words, adding groups for the purpose of adding repetitions seems to > > have a greater side-effect than I would desire. Is there something that I'm > > missing in my use of re's? > > Yes, you weren't using groups (all the time, anyway) :-). > > first-posting-ly yrs' > > -- > Sune Kirkeby | "Imagine, if you will, that there were no > http://mel.interspace.dk/~sune/ | such thing as a hypothetical situation..." From ommadawn at club-internet.fr Fri Jan 5 07:01:22 2001 From: ommadawn at club-internet.fr (Christophe Prevost) Date: Fri, 5 Jan 2001 12:01:22 -0000 Subject: MySQL with Windows References: Message-ID: <9349hk$6in$1@reader1.imaginet.fr> "deadmeat" a ?crit dans le message news: yJd56.9184$KY1.25399 at news1.rivrw1.nsw.optushome.com.au... > Is there anywhere I can download pre-compiled MySQL modules with no > dependencies? MySQLdb seems to need MSVC.. http://home.t-online.de/home/err666/ From m.faassen at vet.uu.nl Wed Jan 10 22:17:03 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 11 Jan 2001 03:17:03 GMT Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> <93iuqb$rn9$1@panix3.panix.com> Message-ID: <93j8jf$k3u$1@newshost.accu.uu.nl> D-Man wrote: > On Wed, Jan 10, 2001 at 04:30:03PM -0800, Aahz Maruch wrote: > | In article <20010110184830.13286.00000826 at ng-fg1.aol.com>, > | Crutoy wrote: > | > > | >Hi , i haven't used Python but i do have experience in other languages vb , > | >java , c++ . Is Python a fully object oriented ? Thanks > | > | Python is fully object oriented if you consider Java and C++ to be fully > | object oriented. If you don't consider those two fully object oriented, > | you may not consider Python to be fully object oriented. > Python also support free-standing functions, similar to C++. But those functions are objects too. :) Anyway, there's no problem with doing object oriented programming in Python, and it's in fact more fun and easier than doing the same in Java and C++, by many reports (I can testify personally for the comparison with C++). And as said by the previous poster, Python works fine with a procedural or mixed style of programming as well. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From glinds at acxiom.com Mon Jan 15 15:17:46 2001 From: glinds at acxiom.com (glinds - Greg Lindstrom) Date: Mon, 15 Jan 2001 14:17:46 -0600 Subject: Relational Databases and Python Message-ID: Greetings- I am wanting to access a relational database via Python. Knowing that a "simple" query such as "Why no "do until" statement" can generate replies for months, I offer the following: * What relational database to use? I am constructing a routine to track incident reports for the volunteer fire department I run with. I also want to track personnel information, training records, equipment, etc. It will be a small to medium database (the databases I work with professionally run in the terabytes, but we spend millions on software). I am looking at MySQL. Whatever base I use must be free. * How to access the database? I would like to use SQL via ODBC. I have attempted to install the mxODBC module, but have run into trouble with the first step (get and install mxDateTime). That's not a good sign. I would like a simple communication to the database (else I will write a "C" routine to do it for me!). What's out there? * With an eye to the future, I would like to write a Web-based system so that I can offer this system to other volunteer departments in the county. We simply cannot afford $2500+ for reporting software (that will fully outfit 2 firefighters including SCBA (breathing equipment) and PASS (a safety device)). Though I have talked with a couple of companies offering a "volunteer rate", we simply cannot afford to spend that kind of money on software. How do I get started writing web apps? I have good friends at work telling me that Perl is the way to go; I program both, but am partial to Python. Thanks to any and all offering suggestions. Greg Lindstrom, FF/FR Vilonia Volunteer Fire Department Vilonia, Arkansas (that's 30 miles North of Little Rock) From aleaxit at yahoo.com Wed Jan 10 06:28:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 10 Jan 2001 12:28:58 +0100 Subject: help / examples reading floats / doubles, user definded objs References: <93aomd$7nd@dispatch.concentric.net> <93crei019hm@news1.newsguy.com> <93g594$ia8@dispatch.concentric.net> Message-ID: <93hh43014s9@news2.newsguy.com> "Bryan Webb" wrote in message news:93g594$ia8 at dispatch.concentric.net... > Alex, > Sorry for the vagueness. I'm red headed, we tend to have lapses. Hey, np - though my hair is brown (with some gray these days), if I had a penny for each time _I_'ve been vague, I'd be pretty rich:-). > I want to read the floats/doubles from a binary file that was written from c > or python. Great! Do note that this is hard to do *cross-platform*, i.e., if the files need to be written on any platform and read back on any other one. But, within a single platform, your life is a bit simpler. > I have used the array builtin to write the data out to a binary file. In this case, the fromfile method of array objects should serve you just as well to read them back in -- just be sure to open the file as 'binary' if you need this to work on such platforms as Windows. E.g., here's a Python script that writes some floats with array: import array ar = array.array('f', range(6)) ar.tofile(open("foo.dat","wb")) and here's one that reads them back and prints them: import array ar = array.array('f') try: ar.fromfile(open("foo.dat","rb"), 999) except EOFError: pass for x in ar: print x Note that I assume we don't know exactly how many items we have to read, just "no more than 999" -- which is why I need to catch EOFError explicitly: that's what .fromfile raises (after correctly inserting what data it finds) to let us know it has not found quite as many items as were specified it should read. Running these two scripts one after the other will emit something like 0.0 1.0 2.0 3.0 4.0 5.0 to ensure us that all is working fine:-). > I found the struct builtin module and am toying around with it... with some > success. > I'll work at it some more and repost my question if i need some other help. struct is great, but you may not need it if what you want to read is a file (or big stretch of it: also check out the fromstring method) containing nothing but an array of binary-written floats (or doubles); the array module is then likely to prove simpler for the purpose. Alex From gotcha at swing.be Wed Jan 17 05:01:57 2001 From: gotcha at swing.be (gotcha at swing.be) Date: Wed, 17 Jan 2001 10:01:57 GMT Subject: cross platform file lock Message-ID: <943qij$had$1@nnrp1.deja.com> This is a newbie question... But after browsing Python Library reference, Python FAQ, and comp.lang.python, I have not been able to determine if there is a cross platform file locking mechanism available for Python. any help appreciated Thanks Godefroid Chapelle BubbleNet sprl Louvain-la-Neuve Belgium Sent via Deja.com http://www.deja.com/ From tim.one at home.com Thu Jan 4 22:28:34 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 4 Jan 2001 22:28:34 -0500 Subject: Migrating to perl? In-Reply-To: <3Fa56.4580$of7.216286@news1.atl> Message-ID: [Joel Ricker] > I'm thinking of moving from perl to python and I was looking for > opinions on the difference. Don't bother . Seriously, download Python, install it, and work your way through the tutorial that comes with it. In no more than a few hours you'll know for certain whether Python is for you! Much more efficient than guessing whether the replies you get here are lying . > ... > So basically what I'd like to know is, how do the two compare? Python's motto is "there's only one way to do it" -- they're polar extremes in some ways. Python is very uniform in its syntax and semantics (compared to Perl, not compared to e.g. Scheme). That can make it wordier than Perl, and, in some cases, slower (for example, regular expressions are just another module in Python -- the language proper knows nothing at all about them, so can't special-case the snot out of them). On the other hand, the uniformity and makes it much easier to read other peoples' code, and that includes your own. > Is there an easier learning curve with Python? Absolutely -- try the tutorial and judge for yourself. > Are the modules and add-ons as good as perl (ie, Database -- > I'm primarily interested in MySQL, CGI, Graphics). I haven't done any of that stuff in Python; must leave for someone else. > What about OOP? Is it it a full OO language? Is it easier than > to use than perl? Perl OO just feels like it has been cludged > together. A simple example should make this clear immediately (cut from an interactive Python shell session): >>> # Make a class with a method >>> class C: def amethod(self, anargument): return anargument + 1 >>> # Subclass it >>> class D(C): def anewmethod(self, anargument): return anargument + 2 >>> # Instantiate an instance >>> d = D() >>> # Invoke methods >>> d.amethod(42) 43 >>> d.anewmethod(42) 44 >>> You even get to name your arguments in Python, just like in a real language . > And lastly, what about the Python community? Is it friendlier > than the perl community? Too many times I've asked questions and > all I'll get is pointers to documentation, which I've already > read and so thats why I'm asking for information in the first > place. I understand simple questions for basic or novice > information will warrant answers like that but not the things I've > asked. The day I was proudest of comp.lang.python was a day last year when, at a very busy time, someone posted the question "what's a text editor?". Amazingly, they got several gentle introductions to the topic. That doesn't mean we're not vicious, though: just try suggesting that Python should add curly braces <0.9 wink>. you-also-have-to-put-with-s-and-stupid-signoff- lines-here-ly y'rs - tim From aleaxit at yahoo.com Thu Jan 4 06:43:38 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 12:43:38 +0100 Subject: CGIHTTPServer.py References: <7F5BC4310EDD615A.1D87832E39807480.8066D4EF5FF33D4C@lp.airnews.net> Message-ID: <931nn102kjt@news2.newsguy.com> "alan runyan" wrote in message news:7F5BC4310EDD615A.1D87832E39807480.8066D4EF5FF33D4C at lp.airnews.net... > I'm playing around CGIHTTPServer.py and have some problems that I can seem > to fix. any help would be greatly appreciated. > > in the Library Reference it shows its availability as Unix only, why not > Windows? it seems to work just fine on Windows. A bug in the docs, I think; it didn't USE to work on Windows, as of Python 1.5.2 (it used fork, making it unix-only) -- its applicability has been enhanced in 2.0, but the docs may not reflect that yet. The docstring in the Python sources is very clear, though: ''' If the os.fork() function is not present (e.g. on Windows), os.popen2() is used as a fallback, with slightly altered semantics; if that function is not present either (e.g. on Macintosh), only Python scripts are supported, and they are executed by the current process. ''' > GET appears to work just fine on both unix and win32. (this is a > SimpleHTTPServer, not CGIHTTPServer's job) Why not? GET can perfectly well reach a CGI, not just a simple page. Form-parameters get appended to the URL in the ?name=value syntax, in GET's case. Simple test: make a cgi-bin directory and copy cgi.py into it. Now, run cgihttpserver.py from the directory just above it. Now from your browser visit url http://localhost:8000/cgi-bin/cgi.py?foo=bar: it should return a large 'page' with all sorts of info, including Form Contents: foo: MiniFieldStorage('foo', 'bar') and work uniformly across all platforms. OK so far? Now, build a very simple correct HTML file for this cgi, e.g.: CGI POST test
visit it with your browser, enter some text, clic on 'submit'. You should again receive the same page as above, except of course the 'form contents' will be a bit different. This works just fine for me on Windows NT 4 with IE 5.5. Can you reproduce your observed problems with this very simple test? Alex From Bill.Scherer at VerizonWireless.com Tue Jan 2 18:12:43 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Tue, 02 Jan 2001 18:12:43 -0500 Subject: HTTPServer, performance References: <0_s46.921678$8u4.18404294@news1.rdc1.bc.home.com> Message-ID: <3A52606A.D98C4AE4@VerizonWireless.com> Actually, I recently found the problem. It turns out that when creating a multithreaded httpserver as I outlined, you get a deadlock in BaseHTTPServer.BaseHTTPRequestHandler.log_request. Overriding this method in my handler with: def log_request: pass eliminates the lockups. Eventually I'll write a log method using a queue and use another thread to handle the queue. Bill Dethe Elza wrote: > > Sounds like garbage collection behavior, at least in Java-land. > > There are lots of lightweight web servers out there, in Java and in Python. > Might want > to check out the code in one (or more) of those... > > --Dethe > > "Bill Scherer" wrote in message > news:mailman.977951836.8921.python-list at python.org... > > Hello eveyone, hope you had a nice holiday... > > > > Question: Is the code below the proper way to create a multi-threaded > > http server in Python, and what kind of performance should one expect > > out of it? > > > > The code below works. It's an extremely stripped down verison of my > > current project which really runs under J(p)ython. I was unsatisfied > > with performance, so I stripped out all that wasn't web server and tried > > it under CPython and JPython. > > > > With the code below, CPython does about 12 tps on a dual 733 Mhz machine > > under RedHat 6.2. JPython is only slightly slower (when using a JVM that > > uses native threads and therefore both processors). Apache on the same > > box does over 70 tps with a greater number of simulated users (100 vs > > 25). > > > > One thing I do see with both CPython and JPython running this code is > > random stalling. ie. The server will be happily serving requests, then > > for no apparent reason, it justs stops. CPU load drops during the > > stall, although it never gets very high. Two, maybe three, seconds > > later, it resumes serving. Pings during this time show no change to > > network latency (0.4ms). > > > > Any and all help is appreciated. > > > > Thanks! > > > > -------------------------------------------------------------------------- > ------ > > > > import SocketServer, BaseHTTPServer > > > > PORT = 9777 > > > > class HTTPServer(SocketServer.ThreadingMixIn, > > BaseHTTPServer.HTTPServer): > > pass > > > > class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): > > def do_GET(self): > > self.send_response(200) > > self.send_header("Content-type", 'text/plain') > > self.end_headers() > > self.wfile.write('hello world') > > return > > > > if __name__ == '__main__': > > httpd = HTTPServer(('', PORT), RequestHandler) > > print 'serving on port', PORT > > httpd.serve_forever() > > > > > > -- > > William K. Scherer > > Sr. Member of Applications Staff - Verizon Wireless > > Bill.Scherer_at_VerizonWireless.com > > > > -- > http://www.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From emile at fenx.com Mon Jan 15 07:50:12 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 15 Jan 2001 04:50:12 -0800 Subject: converting an id() into an object References: <93uppg$bm4b8$1@ID-11957.news.dfncis.de> Message-ID: <93urmp$bifje$1@ID-11957.news.dfncis.de> Ok, it's early still. Forget this question, maybe. Would this be different from simply: poof = spam off-to-a-bad-start-ly y'rs -- Emile van Sebille emile at fenx.com ------------------- "Emile van Sebille" wrote in message news:93uppg$bm4b8$1 at ID-11957.news.dfncis.de... > Is there a way to inverse the functionality of id()? This > of course depends on items not moving around in memory and > not being decref'd into gc. > > eg: > > foo = id(spam) > ... > ... > poof = swizzled(foo) > > spam is poof # this would be true? > > > I don't have an immediate need for this, but the thought has > crossed my mind often enough that if it were available, I > may have done something with it. > > > -- > > Emile van Sebille > emile at fenx.com > ------------------- > > > > From sheila at thinkspot.net Wed Jan 10 16:46:44 2001 From: sheila at thinkspot.net (Sheila King) Date: Wed, 10 Jan 2001 21:46:44 GMT Subject: Running cgi-scripts on my home Apache server References: <3A5CC786.4B3C53B8@bigfoot.de> Message-ID: Thanks SOOO much! This worked perfectly. (Of course it is simple, when you already know how!) :D -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Wed, 10 Jan 2001 21:35:18 +0100, Gerhard H?ring wrote in comp.lang.python in article <3A5CC786.4B3C53B8 at bigfoot.de>: :Yes, it's actually quite simple: : :1) Add the following line at the end of {Path of Apache}\conf\httpd.conf : :ScriptInterpreterSource Registry : :2) give your CGI scripts the extension .py (the Python installer should :have registered .py, .pyc, .pyo to be handled by python.exe), as in this :script: : :file test.py in cgi-bin: :######################## :#!/usr/bin/env python : :print 'Content-type: text/html\n\nhello!' From cfelling at iae.nl Thu Jan 25 15:43:40 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 25 Jan 2001 21:43:40 +0100 Subject: Markov.py References: <94eavq$5cl$1@nnrp1.deja.com> <94eulk$dduhj$1@ID-11957.news.dfncis.de> <3A6B7716.68A62115@home.com> <94h5he$9kl$1@nnrp1.deja.com> <94ides$6t2$1@animus.fel.iae.nl> <94jrt701eg4@news1.newsguy.com> <94l59e$4kc$1@animus.fel.iae.nl> <94mbet01ruh@news2.newsguy.com> <94n920$e66$1@animus.fel.iae.nl> <94p6i40244j@news2.newsguy.com> Message-ID: <94q35s$6bn$1@animus.fel.iae.nl> Alex Martelli wrote: > "Carel Fellinger" wrote in message > news:94n920$e66$1 at animus.fel.iae.nl... > [snip] >> Impressive! (I take it it did single words only, and I guess it needed >> training to get a good profil of the speaker, but still impressive) > Real-time speech but not continuous one (short-as-you-wish, > but mandatory, pause between words -- we called it 'dictation' > speech), and 15-minutes training needed per speaker; took a > dedicated IBM mainframe with a few CPU's and 'vector features', > or equivalent (3rd party vector-processing units for the same > class of mainframe). It _was_ 1985 before 'we' (actually > some brilliant HW guys in IBM Research) turned out special- Ah that project (mid 80-s IBM Research), it's claims *stunned* us at the time! > purpose boards that you could stuff inside an IBM PC/AT to > make it perform the same task (maybe even early '86 before > the latter box was reliable enough to announce & demo) -- > what we contributed to the miniaturization effort was a > study of numeric sensitivity, to turn the computations into > fixed-point ones at various minimal-sufficient precisions > along the algorithms' paths. >> But if I remember correctly, the use of frequency analysis to >> recognize spoken words was not what was criticised at all. We (the > You don't (remember correctly) -- being the target of such > criticisms sharpens one's memories:-). I remember silencing Well I should have spoken only for our project then:), and within Philips Research there were some clever man working on continous speech recognition using stochastic models too, so we were perfectly aware of the feasability of the approach. But still we thought that some decent grammar might be usefull for the weeding of ambiguities:) > for occasional [and inadvertent] lack-of-pause between two > adjacent words... which occasionally made HER go wrong, too!). striking similarity, makes me wonder: your father build a bot before? >> members of the Rosetta team) felt a bit awkward by the claim that >> stochastic models were better suited to attach meaning to (written) >> natural language and even to weed ambigueties. Grammars, on the other >> hand, are soo crisp and clear, hence easy to understand:) Probably had > Right -- and therefore insufficient to model what human beings > actually DO with language:-). yep, and we were painfully aware of that, we refrained from even beginning to try to translate novels, let alone poetry. And then that dreadfull `context' in which an utterance had to be interpreted, no way to model *that* in sufficient detail (or actually: at all), so we left it out:) -- groetjes, carel From tdelaney at avaya.com Sun Jan 28 20:32:09 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 29 Jan 2001 12:32:09 +1100 Subject: xor operator? Message-ID: Well, we went over this a little while ago ... To a large extent, != is the boolean XOR. There is however 1 caveat ... not(a) != not (b) is the boolean XOR ... ;) Tim Delaney Avaya Australia +61 2 9352 9079 > -----Original Message----- > From: Def P [mailto:def-p at usa.net] > Sent: Friday, 26 January 2001 11:52 PM > To: python-list at python.org > Subject: xor operator? > > > Hi, > > I notice that there doesn't seem to be a boolean xor operator > in Python. Does > someone know the reasons behind this? > > Regards, > > Def P > > ____________________________________________________________________ > Get free email and a permanent address at > http://www.netaddress.com/?N=1 > > -- > http://mail.python.org/mailman/listinfo/python-list > From amritansh at mobilian.com Wed Jan 31 19:30:06 2001 From: amritansh at mobilian.com (Amritansh Raghav) Date: Wed, 31 Jan 2001 16:30:06 -0800 Subject: overloading == Message-ID: can it be done? i looked at the operator documentation under Python Runtime Services - but didnt find anything to suggest it could be done. From sandj.williams at gte.net Sun Jan 7 17:03:30 2001 From: sandj.williams at gte.net (Steve Williams) Date: Sun, 07 Jan 2001 22:03:30 GMT Subject: boolean xor References: <93ace8$nmo$1@panix3.panix.com> Message-ID: <3A58E8F7.83DA8D35@gte.net> Aahz Maruch wrote: > I need a boolean (not bit-wise) xor function. I've got the following > function, but my logic skills are rusty enough that I'm wondering if > this is the "right" way to do it (I've validated that it produces the > correct outputs, at least): > > def xor(a,b): > return not ( (a and b) or (not (a or b)) ) > -- > --- Aahz (Copyright 2001 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > "This is Usenet. We're all masturbating in public places." -DH (A or B) and not (A and B) has fewer knots. DeMorgans Law. From vesemir at pro1.promail.pl Fri Jan 12 15:07:59 2001 From: vesemir at pro1.promail.pl (Vesemir) Date: Fri, 12 Jan 2001 21:07:59 +0100 Subject: changing unix password via www python script Message-ID: <93no1v$svv$1@sunsite.icm.edu.pl> Hello! How to change unix account password by python script? I want to write www script, controled by form. Yours QdlatY qdlaty at wielun.dhs.org From donn at oz.net Sat Jan 27 21:55:56 2001 From: donn at oz.net (Donn Cave) Date: 28 Jan 2001 02:55:56 GMT Subject: Avoiding the __repr__ call or protecting an instance from evaluation URG. please References: Message-ID: <9501ns$jf7$0@216.39.151.169> Quoth Fernando Rodrguez : | I have a class whose __repr__ method returns a string. Whenever I pass | an instance of this class to a function, what the function gets is the result | of __repr__. Most of the time this is OK, but under certain circumstances I | also need to make sure that a function receives an instance of the class, and | the the string that __repr__ returns. Somewhere in this, you have been deceived. Python doesn't do that kind of thing, converting function arguments like C++, and whatever you pass to a function should arrive intact. It's hard to say what has been happening to confuse the issue. Note that if you "print" a sequence, repr will be used to render its contents. Donn Cave, donn at oz.net From tebeka at lycosmail.com Wed Jan 31 07:44:21 2001 From: tebeka at lycosmail.com (Miki Tebeka) Date: Wed, 31 Jan 2001 14:44:21 +0200 Subject: Time limited threads? Message-ID: <9591b8$2if@news.or.intel.com> Hello All, Is there a way I can limit a threads execution time? (and then resume it later?) Background: We're giving an exercise in scheduling. I'd like to give the students a service that runs one thread for a given time quota. Then they will write the scheduler. Thanks ---------------------------------------------------------------------------- -- Smile, damn it, smile. lambda msg: { 'name' : 'Miki Tebeka', 'email' : 'tebeka at lycosmail.com', 'homepage' : 'www.tebeka.freeservers.com', 'quote' : "I don't suffer from insanity, I enjoy every minute of it." }[msg] From slhath at flash.net Thu Jan 18 10:37:25 2001 From: slhath at flash.net (scott hathaway) Date: Thu, 18 Jan 2001 15:37:25 GMT Subject: what happens when cookies get too big? References: Message-ID: When IE 4 and above encounter a cookie that is too large, it tosses all cookies for that site! Scott "Skip Montanaro" wrote in message news:mailman.979830522.31537.python-list at python.org... > > This isn't really a Python question, but since I'm using Python to implement > things, I figured perhaps I could sneak this in. > > What happens when cookies get too big? Do browsers tend to barf, toss out > the cookie, truncate it, or something else I've not anticipated? RFC 2109 > says oversize cookies (double-stuff?) must be discarded, but I wonder if all > browsers adhere to that requirement. I'm storing a cookie that represents a > list of names. It's zlib compressed and base64 encoded, so I can store > quite a few names. > > Thanks, > > -- > Skip Montanaro (skip at mojam.com) > Support the Mojam.com Affiliates Program: http://www.mojam.com/affl/ > (847)971-7098 > From clgonsal at keeshah.penguinpowered.com Tue Jan 2 01:36:40 2001 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Tue, 02 Jan 2001 06:36:40 GMT Subject: Simulating WWW button press References: Message-ID: On 2 Jan 2001 01:49:15 GMT, Lutz Schroeer wrote: > >Well, maybe this snippet of the (very unreadable) source is large >enough. > >
METHOD=POST> > >
> >I tried and read some more stuff and ended at the example 11.3.2 in the >Library reference (1.5.2). Unfortunately my own version of this code >doesn't work (it stucks after the getfile() ). > >Is my suggestion right that the base address for the submission is the >same as the page's base address if the code defines nothing different? > >Additionally I came to the conclusion that I seem to have to send a >Content-Length header entry (the server replied me an error 411) but >have no idea about the value. > >To make it totally complicated the form is on a password protected >page. So how do I send my username and passwd to the server? You'll want to include an "Authorization:" line in your HTTP headers. eg: Authorization: Basic dXNlcmlkOnBhc3N3b3Jk The junk after "Basic" is the userid and password encoded in base64. You can generate this by doing something like: import string, base64 # need to use strip, because base64.encodestring adds a trailing # '\r' that we don't want auth = string.strip(base64.encodestring(userid+':'+password)) Incidently, you might want to test if this server works with HTTP GET requests. If you aren't sending many parameters to it (and from the looks of the HTML above, you aren't), there isn't really any point in using POST, unless the server requires it. Most CGI programs don't actually care which way they get the parameters. -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From tony at lsl.co.uk Fri Jan 26 08:24:32 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Fri, 26 Jan 2001 13:24:32 -0000 Subject: python-2.1 function attributes In-Reply-To: Message-ID: <004b01c0879b$51be71d0$f05aa8c0@lslp7o.int.lsl.co.uk> Michael Hudson wrote: > How about "having"? > > def func(param) having (publish=1, secure=0): > """ docco """ > print "bobbins" > > to emphasize the attribute-ness one could use a dot prefix: > > def func(param) having (.publish=1, .secure=0): > """ docco """ > print "bobbins" > > I think I like this (though I'm not sure about the dot > prefix). I might see if I can whip up a patch... Yes, "having" is better than "with". That's neat. And it doesn't have any obvious other meaning for me. (the important thing was probably getting away from "with" - once that's done, if people really don't like "having", suggesting new words is simple enough, at leisure) I'm not sure about the dot prefix either - it makes them obviously odd, but feels sort-of unPythonic. I think I prefer without. Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ "How fleeting are all human passions compared with the massive continuity of ducks." - Dorothy L. Sayers, "Gaudy Night" My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From bram at sara.nl Wed Jan 3 04:17:32 2001 From: bram at sara.nl (Bram Stolk) Date: Wed, 03 Jan 2001 10:17:32 +0100 Subject: using 'global' across source files. References: <3A51E6B7.82FFE8F4@sara.nl> <92sqc8$nm9$1@news.wrc.xerox.com> Message-ID: <3A52EE2C.32432EF5@sara.nl> Mark Jackson wrote: > > Bram Stolk writes: > > According to the manuals, it should simply be in the namespace > > '__main__', but that doesnt work either. > > You're misreading the manuals. Can you tell us how you drew this > conclusion? (Possibly the manuals could be clearer.) Well, because in execframes.html, it can be read that: "The main module for a script is always called __main__" And because I can do: dir(__builtins__) I thought, why the heck doesn't dir(__main__) work? I also tried dir(__mains__), dir(main), etc. Now I know, (thx Remco) that I first have to map the string __main__ to a module using sys. This could be in the ref manual. I think it is not in there currently. Also, I had no idea that using a 'global val' cmd, creates another copy of val, which I deduct from your comment: "But the val that change_val changes is defined in funcs.py, NOT prog.py" I thought that python's 'global' acted like C's 'extern' cmd, meaning, that 'global val' does NOT define/create 'val', only refers to a val that exists somewhere else. I don't know wether me thinking this is due to my poor understanding, or the quality of the manuals, though. Anyway, to clear things up: what I wanted to achieve is pretty straightforward: I can use "global vars" that reside outside a func body, but in the same module. I wanted one step further: use "even more global vars" that reside outside a func body, and even outside the current module (read: sourcefile). I can achieve this now, with the sys lookup of __main__. (Provided ofcourse that __main__ is the module that holds the req'd variable). I thought that the subject line that I had chosen "using 'global' across source files" summed up my problem pretty accurate. But appearantly it did not ;-) Bram > > -- > Mark Jackson - http://www.alumni.caltech.edu/~mjackson > The power of accurate observation is frequently called > cynicism by those who don't have it. > - George Bernard Shaw -- ------------------------------------------------------------------------------ Bram Stolk, VR Specialist. SARA Academic Computing Services Amsterdam, PO Box 94613, 1090 GP AMSTERDAM email: bram at sara.nl Phone +31-20-5923059 Fax +31-20-6683167 "I heard if you play the NT-4.0-CD backwards, you get a satanic message." "Thats nothing, if you play it forward, it installs NT-4.0" ------------------------------------------------------------------------------ From abc at 21cn.com Mon Jan 22 02:01:07 2001 From: abc at 21cn.com (ccc) Date: Mon, 22 Jan 2001 07:01:07 +0000 (UTC) Subject: test Message-ID: <94glrj$4l7$344@mail.cn99.com> An HTML attachment was scrubbed... URL: From phd at phd.pp.ru Mon Jan 22 13:37:21 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 22 Jan 2001 21:37:21 +0300 (MSK) Subject: .cgi or .cgp or .py or ? In-Reply-To: <3A6C77B5.25B7DA13@yahoo.com> Message-ID: On Mon, 22 Jan 2001, haaserd wrote: > There isn't any advice in cgi.py. What is the recommended > naming convention? Always use .py as the extension. Thus you always remember what is it, any python newbe will easily recognize it, and (what is much more important) - this is visible on the web. This way you promote The One And The Only True Programming Language. (I am a bit exagerating here, but really not too much. Promoting Python is very important in the world full of other damn P* languages :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sholden at holdenweb.com Sat Jan 20 12:57:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 20 Jan 2001 12:57:53 -0500 Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> <3a685ef2.3403798@reading.news.pipex.net> <949rii0a76@news1.newsguy.com> Message-ID: "D-Man" wrote in message news:mailman.979929746.2047.python-list at python.org... > On Fri, Jan 19, 2001 at 05:55:45PM +0100, Alex Martelli wrote: > | [ ... ] > | (shame's about to engulf me...). I like :set expandtab always > | on -- no tab/space confusion; I also like :set ff unix, so that my > | scripts can be shared between Win and Unix machines (and why > | waste one byte per line to tell a 'carriage' that is not there > | to 'return' [to where?]...?!-). > > Exactly. DOS/Windows never did operate from a teletype did it? I > suppose no one will ever figure out why a system that began on the > teletype (Unix) doesn't use the extra character and a system that > didn't (DOS/Windows) does. > My guess is that the Unix implementors realised that whether to include a CR was a decision correctly left to the appropriate device driver. Whereas the implementors of DOS didn't really understand such refinements, and decided to put the CR in files so that any device could handle the output. This is speculation, based on the philosophical attitudes I have observed in the two groups concerned. 8^} Who designed DOS anyway, Gary Kildall wasn't it? regards Steve From tony at lsl.co.uk Fri Jan 26 06:00:32 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Fri, 26 Jan 2001 11:00:32 -0000 Subject: python-2.1 function attributes In-Reply-To: Message-ID: <004701c08787$33ae0070$f05aa8c0@lslp7o.int.lsl.co.uk> Michael Hudson wrote: > Ooh, I've come up with a strawman! I'm ignoring his first option, since I think the double indent will doom it, regardless of other considerations, and the variant is more interesting: > def f(a, b, c) with publish = 1; secure = 0: > print "bobbins" > > Then you use backslashes when the attribute or argument list get long. > > def f(long_name, even_longer_name, still_longer_name) \ > with publish = 1; secure = 0 > grammar = f_grammar: > print "bobbins" > > Thoughts? My first thought is that the examples need to have doc strings to make it a bit more obvious how they work in practice. Also, I think it needs a ";" after "secure=0" to be "consistent". Of course, we already have ways in Python to allow continuation over lines and indenting for a list of items - and I'd have said the obvious one to use here *was* the dictionary specification, which takes us back to: def f(long_name, even_longer_name, still_longer_name) \ with {publish : 1, secure : 0, grammar : f_grammar}: """and here is the doc string.""" print "bobbins" But a better result might be to use a compromise, of sorts, and "tupleise" it, with syntax similar to an argument list: def f(long_name, even_longer_name, still_longer_name) with \ (publish=1, secure=0, grammar=f_grammar): """and here is the doc string.""" print "bobbins" - this allows the user to "forget" it's a dictionary, and doesn't require that (slightly) awkward mixing of () and {} in the same statement. In fact this is my favourite so far. And it's close to current Python layout rules, which must be a Good Thing. I'm still a little concerned about the use of "with" as the keyword, though, since it has precedent for uses where the value being defined is a "local" constant - but on the other hand I can't think of a better word at the moment. From syver at NOSPAMcyberwatcher.com Fri Jan 19 19:53:18 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Sat, 20 Jan 2001 01:53:18 +0100 Subject: Python COM and DCOM. References: <3RV96.10957$wt2.125028@news1.oke.nextra.no> <949ion0v1@news1.newsguy.com> Message-ID: <94anmj$98f$1@troll.powertech.no> Alex wrote: > If you register a COM object as having different servers (in-process, > local aka out-of-process, remote), the fastest one of these will > always be used by 'default instance creation methods' in all > languages. You will need to de-register the 'faster' (in-process, > local) servers if you want 'slower' servers to be used for such > default creation. I've deregistered the inproc server option, registered the python com class with _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER as a class variable > Or else (not available from all languages) you can explicitly ask > for the kind of server you want by passing appropriate values from > the CLSCTX enumeration: > > typedef enum tagCLSCTX > { > CLSCTX_INPROC_SERVER = 1, > CLSCTX_INPROC_HANDLER = 2, > CLSCTX_LOCAL_SERVER = 4, > CLSCTX_REMOTE_SERVER = 16, > CLSCTX_NO_CODE_DOWNLOAD = 400, > CLSCTX_NO_FAILURE_LOG = 4000 > } CLSCTX; > #define CLSCTX_SERVER (CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | > CLSCTX_REMOTE_SERVER) > #define CLSCTX_ALL (CLSCTX_INPROC_HANDLER | CLSCTX_SERVER) Yes, I know. This seems to work okay. The problem is when you already have compiled code (that uses default instance creation methods) or ASP that as far as I've seen from the docs doesn't support CLSCTX specification. From python at mattrussell.plus.com Fri Jan 5 19:58:41 2001 From: python at mattrussell.plus.com (python at mattrussell.plus.com) Date: Sat, 06 Jan 2001 00:58:41 GMT Subject: ssl Message-ID: <935qju$j8d$1@nnrp1.deja.com> Hi, has anyone implemented any ssl connections in python? I am trying to get it to work on a win2k box (yuk). I understand that the unix implementation uses openSSL||SSLeay libraries. Does win *have* use the same? More importantly, in python 1.5.2 ssl was availble as a third party patch that needed to be compiled in to the main disto - has python 2.0 rectified this and made it part of the distro? thnaksinadvance. Sent via Deja.com http://www.deja.com/ From p at mjs400.co.uk Thu Jan 18 10:25:30 2001 From: p at mjs400.co.uk (Pete) Date: Thu, 18 Jan 2001 16:25:30 +0100 Subject: Jython on the i400 (was: Python and Industry, IBM I'm afraid) References: Message-ID: <3A670AEA.14278A8@mjs400.co.uk> Simon Brunning wrote: > You're probably one of those people who use kilograms and grams, rather than > pounds and ounces as God intended, right? It's the AS/400, dammit. ;-) No, personally I believe that a good handfull of food, esp. meat (ie. a pound) is about right for a proportioned meal for two adults. Add an ounce of each of a variety of spices, and after some heat....voila, un repas parfait. Vive la difference! Mort to politikans! --Pete From sdm7g at virginia.edu Tue Jan 23 17:08:55 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 23 Jan 2001 17:08:55 -0500 (EST) Subject: I mean *setup.py* ! ... (more questions) In-Reply-To: <3d3dea3vuh.fsf@ute.cnri.reston.va.us> Message-ID: On 23 Jan 2001, Andrew Kuchling wrote: > > setup.py was written using 2.0's Modules/Setup.in as a guide to > platform specific problems; it didn't mention MacOS X, of course. Try > the untested patch below; you'll need to fix whatever sys.platform is > on MacOS X. Please let me know what it is and let me know if it > works. > > + if sys.platform == 'XXX fill this in': < + if sys.platform == 'Darwin1.2': make clean make Oops! I forgot to delete the phoney libm.a I created. Try again: It works. ( for the -lm problem. I did readline without the -ltermcap manually and continued with make. ) I answered one of my other questions with a test: sticking termios and fcntl into Modules/Setup did seem to cause it to NOT build as a shared lib. I did find one other MacOS case insensitivity problem: although socketmodule is built as _socketmodule.so, and included by lib/socket.py, lib/plat-Darwin1.2/SOCKET.py appears to be un-importable. ( on an HFS+ volume, that is. ) I noticed again that 'make test' doesn't really work until after a 'make install' , as none of the platform files are generated from lib/plat-generic until the install phase. Ideally, this ought to get done earlier in the make. If there no simple fix for that: what do we need to do to get a lib/plat-Darwin1.2 directory with prebuilt files added to the distribution ? ( I have all the files after a successful install. ) -- Steve Majewski From tim.one at home.com Tue Jan 16 02:42:44 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 16 Jan 2001 02:42:44 -0500 Subject: Python and Industry, IBM I'm afraid In-Reply-To: <3A63D9E8.F9B74ACE@mjs400.co.uk> Message-ID: [Pete] > Has anyone ported Python to IBM iSeries 400?...Or is this > considered too much hassle, because they are big fat trucks > of servers - and come bundled with no GUI support (they have > had posix for many years)?...Or are people waiting for Linux > support in a logical OS partition?...Or does no one care? A Python port to platform X, regardless of X, is almost always done by some user of X who wants to run Python on X, and usually working alone. That's how things work in any project without revenue to pay for a port (don't know whether you've used Python, but if you have and someone charged you for it, you were suckered bigtime). I don't know whether there are any Python ports to IBM iSeries 400, but, if there aren't, that would be because no IBM iSeries 400 user bothered to port it. In which case, you'll have to ask them what their hangup is -- or ask IBM why they don't think it's worth their time to make a port available. Note that Intel and Microsoft cared enough to pay ActiveState for a Win64 Python port. So there's more than one way to get a port done, but the only way that's free requires a volunteer. > I say this because in the rarified atmosphere of this newsgroup (hee > hee) an ignorant observer might well think that Python thrives only > in academy land. Huh -- that really *would* be an ignorant observer <0.7 wink>. win95-ain't-exactly-a-postdoc-status-symbol-ly y'rs - tim From tim.one at home.com Fri Jan 12 17:02:36 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 12 Jan 2001 17:02:36 -0500 Subject: ZODB and Python 2.0 In-Reply-To: <93nta2$p59$1@newsmaster.axxent.ca> Message-ID: [Steve Menard] > ... > So finally, my question is this : Why isn;t ZODB available as a separate > package using the distutils? http://sourceforge.net/projects/zodb/ From mlh at idi.ntnu.no Wed Jan 31 19:56:59 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 1 Feb 2001 01:56:59 +0100 Subject: Sets in Python References: Message-ID: <95aceb$s79$1@tyfon.itea.ntnu.no> "Tim Peters" wrote in message news:mailman.980905187.10012.python-list at python.org... [...] > Note Greg Wilson's PEP for adding a set type to Python: Nice! Any chance that this may be included some time in the future? And as regards "... in dict"; It would perhaps be more natural to see a dict as a set of pairs, so that the dictionary would act similarly to dict.items()? I.e. "(key, val) in dict" would be the same as "(key, val) in dict.items()" except that it would take O(1) time...? Oh, well... If we get a set type I guess that isn't necessary. (And I would *love* to have a set type. :-))) -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From ljohnson at resgen.com Fri Jan 5 11:07:04 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Fri, 5 Jan 2001 10:07:04 -0600 Subject: Returning the path of a file References: Message-ID: > 2) Is there a builtin or method to delete a file or do I have to > execute an os process to do this? Use the os.remove() function: import os os.remove("thefile"); Sorry I can't answer your first question ;) From hwanjoyu at students.uiuc.edu Sat Jan 6 15:54:42 2001 From: hwanjoyu at students.uiuc.edu (hwan-jo yu) Date: Sat, 6 Jan 2001 14:54:42 -0600 Subject: Q: operation not permitted error... Message-ID: Hi, When I try to call keys() function of a shelve, it returns the following error. Traceback (most recent call last): File "size.py", line 6, in ? k = s.keys() File "/usr/local/lib/python2.0/shelve.py", line 55, in keys return self.dict.keys() bsddb.error: (1, 'Operation not permitted') ### source code ### import shelve s = shelve.open("aaa") # 'aaa' is a shelve data file created before k = s.keys() print len(k) What caused this error ? Thanks From jacobs at darwin.epbi.cwru.edu Mon Jan 22 11:30:58 2001 From: jacobs at darwin.epbi.cwru.edu (Kevin Jacobs) Date: 22 Jan 2001 16:30:58 GMT Subject: Python & GUI? References: <3A674896.C7E52247@crepido.com> <947j3i01h9k@news2.newsguy.com> <3a6c2f9c.2770560@news.btx.dtag.de> Message-ID: <94hn82$j43$1@eeyore.INS.CWRU.Edu> Stefan Franke wrote: > On Thu, 18 Jan 2001 21:15:56 +0100, "Alex Martelli" wrote: > [...] >>my personal favorite, however, is Dynamic >>Html -- used in a cross-platform way, it has some limitations, >>but, targeting one specific and powerful browser (such as IE), >>it's awesome, > I've no idea what's possible on this route, could you point me > to some examples (for IE)? I've written a very simple DHTML spreadsheet at: http://gallery.theopalgroup.com/DOMsheet Its not Python, though I use Python to process the information server-side. -Kevin -- -----------> Kevin Jacobs <-----------|-------> (216) 986-0710 <-------- Informatics Consultant | Department of Epidemiology Primary mail: jacobs at theopalgroup.com | & Biostatistics Alternate mail: jacobs at darwin.cwru.edu | Case Western Reserve University ---------------------------------------------------------------------------- From glandrum at my-deja.com Sun Jan 21 10:56:09 2001 From: glandrum at my-deja.com (Greg Landrum) Date: Sun, 21 Jan 2001 15:56:09 GMT Subject: SVG Tools? References: Message-ID: <94f0qn$ju1$1@nnrp1.deja.com> In article , msrisney at rocketmail.com wrote: > I've been messing about with a collection of Perl modules, > and scripts related to dynamic SVG generation. > Are there any equivilant Python efforts out there ?, Here are just a couple I know about. Sketch supports SVG exports: http://sketch.sourceforge.net/ but I haven't used it. Piddle includes an SVG canvas in the CVS version http://sourceforge.net/projects/piddle/ and Sping (the new name for piddle) includes the same canvas. Sping is accessible from the piddle pages on sourceforge. I'm the author of the SVG canvas for piddle/sping. It supports static SVG, no interaction or fancy filters or anything like that (this is consistent with the Piddle Canvas API). I keep thinking about adding interactivity support to the Piddle SVG canvas, but I haven't devoted any significant time to it yet (other things always seem to come up). I hope this helps, -greg Sent via Deja.com http://www.deja.com/ From andreas at andreas-jung.com Wed Jan 17 10:04:59 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Wed, 17 Jan 2001 16:04:59 +0100 Subject: gettings mounted file systems [newbie] In-Reply-To: <20010117161413.E3B19A828@darjeeling.zadka.site.co.il>; from moshez@zadka.site.co.il on Wed, Jan 17, 2001 at 06:14:13PM +0200 References: <20010117161413.E3B19A828@darjeeling.zadka.site.co.il> Message-ID: <20010117160459.A24154@yetix.sz-sb.de> On Wed, Jan 17, 2001 at 06:14:13PM +0200, Moshe Zadka wrote: > On Wed, 17 Jan 2001, Langa Kentane wrote: > > Greetings gurus. > > > > I am trying to find a way how I can get a list of mounted file systems using > > python. > > How would I go about doing this? I have looked into the documentation and > > have not found anything to help. I think there is no portable way. Either check /etc/mtab or under Linux /proc/mounts. Andreas From thomas at xs4all.net Wed Jan 31 04:58:32 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 31 Jan 2001 10:58:32 +0100 Subject: localtime(clock()) yields 12/31/69 under Wme In-Reply-To: <957a4e$fp7vt$1@ID-59885.news.dfncis.de>; from thomas.heller@ion-tof.com on Tue, Jan 30, 2001 at 10:02:00PM +0100 References: <3A772BB5.77A3078C@yahoo.com> <957a4e$fp7vt$1@ID-59885.news.dfncis.de> Message-ID: <20010131105831.M962@xs4all.nl> On Tue, Jan 30, 2001 at 10:02:00PM +0100, Thomas Heller wrote: > Try time.localtime(time.time()) Or, in Python 2.1, just do 'time.localtime()' ;-) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From ivnowa at hvision.nl Fri Jan 26 10:56:19 2001 From: ivnowa at hvision.nl (Hans Nowak) Date: Fri, 26 Jan 2001 16:56:19 +0100 Subject: xor operator? In-Reply-To: <20010126165038.O922@xs4all.nl> References: <3A719880.6621@hvision.nl>; from ivnowa@hvision.nl on Fri, Jan 26, 2001 at 04:32:16PM +0100 Message-ID: <200101261559.QAA27362@axil.hvision.nl> On 26 Jan 01, Thomas Wouters wrote: > > > In the specific Python > > > sense, the return value of the boolean xor operation would also be > > > vague. > > > Simply 0 or 1 would be a possibility, but that is not what Python's > > 'and' and 'or' do. So maybe, if it evaluates to true, it returns the > > 'true' element; otherwise it returns 0 (like 'and' and 'or' do). > > 'and' and 'or' never return '0'. They always return one of their elements, > that's what makes them so useful (in my eyes :) xor doesn't have that Hm, I see what you mean: >>> (2==1) and (4>5) 0 >>> 3 and [] [] I originally come from a Pascal-ish background, and in that language a boolean expression always returns a Boolean, so either True or False, but not something else. I guess it's in the nature of the language. I found Python's behavior very confusing at first -- 'and' and 'or' that return something else than 0 and 1? I've come to like it now, but apparently haven't fathomed everything of it. > > Can't speak for him, but I always wondered why the xor was missing, too. > > It simply belongs there next to the and/&, or/| pairs. :) > > Well, that might be, but like I said, none of the languages I know have a > boolean xor operator. If you really really want it, you can use > > (not not x)^(not not y) > > which is just about as obvious as 'x xor y'. I never needed it myself; I have just been wondering why it wasn't there. Same thing for C, by the way. > I'm not really explaining why it isn't there, because I don't know, I'm just > explaining why not many people care :) The chance of getting it now, though, > is very slim. 'and' and 'or' are keywords, and 'xor', as an operator, would > have to be, too. Introducing keywords can break a lot of code :P We might slip in this keyword when the string module will be removed. Everyone's code will then be broken anyway, so people will hardly notice. ;-) --Hans Nowak (ivnowa at hvision.nl) Info Vision Europe BV From jan.dries at dcube-resource.be Sun Jan 7 16:09:22 2001 From: jan.dries at dcube-resource.be (Jan Dries) Date: Sun, 07 Jan 2001 22:09:22 +0100 Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> Message-ID: <3A58DB02.ED3022B@dcube-resource.be> Jonathan Polley wrote: > > Is is possible to modify the 'enum' function so that I don't have to provide a > class? I would like to use something like this method to create enumerated types, > but I don't want to keep generating classes that say: > > I would like to just do a: > > MIDI_Event = enum("NOTE_ON", "NOTE_OFF", 3, "POLYPHONIC_KEY_PRESSURE", > "CONTROLLER_CHANGE") I once wrote a class to simulate enums. Using it, you can write: colors = enum("GREEN","BLUE","RED","YELLOW") and you can subsequently refer to the enum constants as: x = colors.GREEN If no value is supplied, the first name is assigned 0, the second 1 and so on. But you can supply values, as in: colors = enum("GREEN=1","BLUE=0x08","RED","YELLOW") Anyway, here's the class: import re class enum: def __init__(self,*names): self.__mnames = {} value = 0; for i in names: pairs = re.split("\s*[=]\s*",i) if len(pairs) == 2: value = eval(pairs[1]) self.__mnames[pairs[0]] = value value += 1 def __getattr__(self,name): try: return self.__mnames[name] except: raise AttributeError def __setattr__(self,name,value): if name == "_enum__mnames": self.__dict__[name] = value else: raise AttributeError From cg at schlund.de Wed Jan 10 04:20:05 2001 From: cg at schlund.de (Carsten Gaebler) Date: Wed, 10 Jan 2001 10:20:05 +0100 Subject: Determine whether STDIN is gzipped References: <3A5ADB84.194BAD4E@schlund.de> <93f0sf020mm@news1.newsguy.com> Message-ID: <3A5C2945.37447ADD@schlund.de> Hi Alex! Many thanks for your suggestions. I think it'll work that way and performance is not really an issue here. cg. From djmoore at uh.edu Wed Jan 31 18:39:12 2001 From: djmoore at uh.edu (DaveMoore) Date: Wed, 31 Jan 2001 17:39:12 -0600 Subject: Any practice exercises for beginner??? References: Message-ID: On Wed, 31 Jan 2001 21:36:22 GMT, "shaka" wrote: > > I was just wondering beside the tutorial if there was any practice >exercises to reinforce beginners strength in python? >I can recall that when learning Java, some Java website offered some >exercises for beginners. > First of all, check out the Useless Python Page: . Download and run the code, see what it does, then try to duplicate it. There is a link there to the Association for Computing Machinery Collegiate Programming Contest Problem Set Archive, but it's been updated: http://acm.uva.es/problemset/ (Note that contest entries must be in C/C++ or Pascal.) (Great Grotty Ghu, this thing has an automated on-line judge! I bet that's a pretty piece of code!) Here's a problem I recently had fun with: Many of the Win32 Network Resource enumeration tools return a list of dictionaries: [{'name':'comp1','comment':'room 100','type':WKSTATION}, {'name':'comp2','comment':'room 101','type':SERVER}] Try converting this to a dictionary of lists: {'comp1':['room100',WKSTATION],'comp2':['room 101',SERVER]} (Typed by hand, hope I got the punctuation right.) Now step through the dictionary, printing out the characteristics associated with each computer in a neatly-formatted table. Hm, didn't come out in order, did it? Fix that. It's interesting to do this with a large (15-20 entries), sorted list(the Win32 functions return a list sorted by computer name); if you print the result dictionary out as each entry is added, you can watch the dictionary reorganize itself as it grows. (This is as far as I got, I'm interested in the enumerated resources, and this turns out not to be the best way to do what I want. But it was an educational exercise.) If you have a lot of time to waste, er, invest, write a wrapper that solicits input to fill the source list, and then lets you search the resulting dictionary for a particular entry. Duplicates of already-existing entries should be handled gracefully. If you're really ambitious, provide a mechanism to edit and delete entries as well. OK, now re-write the interface so it uses Tk/Tcl dialogs instead of a text-based interface. -- Dave Moore == djmoore at uh.edu == I speak for me. In the wrong hands, sanity is a dangerous weapon. From dbrueck at edgix.com Thu Jan 25 17:01:13 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Thu, 25 Jan 2001 15:01:13 -0700 Subject: Tkinter vs wxPython: your opinions? In-Reply-To: Message-ID: > On 25 Jan 2001 19:41:19 GMT, Neil Cerutti wrote: > >The current documentation for Tkinter is much better than what is > >available for wxPython. > > This is very strange. Where is good documentation for Tkinter to > be found? > When I had tried to learn using it (this was 5 years ago, true) I couldn't > find any documentation at all. wxWindows documentation is probably what > has personally attracted me so much to it. Heehee ... the main reason I ended up using wxPython instead of Tkinter was because with wxPython I had little or no problems finding answers to my questions.. the documentation isn't 100% but I found it to be far more comprehensive than anything I could find for Tkinter. That and wxPython's layout, events, etc. are very straightforward and easy to use (not that Tkinter's aren't, I just didn't find wxPython's confusing or difficult at all). -Dave From warrickb at my-deja.com Tue Jan 30 07:14:13 2001 From: warrickb at my-deja.com (warrickb at my-deja.com) Date: Tue, 30 Jan 2001 12:14:13 GMT Subject: Wrapping up a C++ class References: <954496$ues$1@nnrp1.deja.com> <9546rv01ahd@news2.newsguy.com> <9565q3$nnh$1@nnrp1.deja.com> Message-ID: <956b6i$ri8$1@nnrp1.deja.com> I've gone through the mentioned stuff (Which of course makes sense to a C++ programmer ;) but it doesn't help that much if I want a simple example of a C++ class made accessible to Python. I've just been looking through the Boost library which seems quite good if a little tricky to unravel at first glance. I was wondering how exactly most people keep track of the class instance pointers though? Thanks. In article , "Fredrik Lundh" wrote: > "warrickb at my-deja.com" wrote: > > Thankyou all I shall take a look and see if I can make sense of it! It > > does strike me as odd that there isn't a simple one source file example > > of how to do it in the docs though... > > well, it does strike me as odd that there are C++ programmers > out there who don't understand C: > > Objects/xxobject.c > Modules/xxmodule.c > > overviews and reference docs are here: > > http://www.python.org/doc/current/ext/ext.html > http://www.python.org/doc/current/api/api.html > > Cheers /F > > Sent via Deja.com http://www.deja.com/ From sheila at spamcop.net Thu Jan 18 13:24:59 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 18 Jan 2001 18:24:59 GMT Subject: Slicing and offsets References: <945bvp$thj$1@nnrp1.deja.com> <3A672D9B.6E71F709@san.rr.com> Message-ID: <43de6t4pt870d9qb54l6nek6pf21n1m26g@4ax.com> On Thu, 18 Jan 2001 17:53:30 GMT, Darren New wrote in comp.lang.python in article <3A672D9B.6E71F709 at san.rr.com>: :gustabares at my-deja.com wrote: :> Why is it that when I slice S it's no longer the 0 offset anymore, but :> now it is 1? : :I'm not sure I understand the question, but I'm guessing this might be the :answer: : :You don't "slice S". Instead, you're asking for a slice of S. Unlike pie, :this doesn't change S. Slicing is a function that gives back a new and :different string that's independent of what you sliced. Ah, I think you have got it. I've been following this thread, trying to see what it was about. Maybe this illustration would help? >>> S='spam' >>> S[0:] 'spam' >>> S[1:] 'pam' >>> T=S[1:] >>> T[0:] 'pam' >>> -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From trotts at mit.edu Mon Jan 29 00:19:02 2001 From: trotts at mit.edu (Issac Trotts) Date: Sun, 28 Jan 2001 21:19:02 -0800 Subject: ANN: clifford.py 0.6 In-Reply-To: <952pv7$4do@gap.cco.caltech.edu>; from kern@myrddin.caltech.edu on Mon, Jan 29, 2001 at 04:01:43AM +0000 References: <952pv7$4do@gap.cco.caltech.edu> Message-ID: <20010128211902.C10658@llnl.gov> Cool, so do you know if anyone is working on a symbolic package for Clifford/Geometric Algebra (other than me)? Issac Robert Kern (kern at myrddin.caltech.edu) wrote: > Okay, I finally got off my lazy duff and put the fixed version > on the Starship. > > clifford.py is an implementation of Clifford (geometric) algebras > in Python using Numerical Python (http://numpy.sourceforge.net). > > I posted a previous (and embarassingly buggy) version to c.l.py, > so now, I belatedly fix that mistake and put the new version on > the Starship. > > Location: http://starship.python.net/crew/kernr/source/clifford.py > > New in version 0.6: > > * fix a few stupid bugs that don't show up in 3 Euclidean dimensions > * introduce a new algorithm for join and meet that actually works, > but isn't very numerically stable: but it's better than nothing > * various fixes and clean-ups > > -- > Robert Kern > kern at caltech.edu > > "In the fields of hell where the grass grows high > Are the graves of dreams allowed to die." > -- Richard Harter > -- > http://mail.python.org/mailman/listinfo/python-list From erno-news at erno.iki.fi Mon Jan 1 14:12:49 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 01 Jan 2001 21:12:49 +0200 Subject: STRPTIME method missing from TIME class, in win32 ? References: Message-ID: "Werner" == Werner Geuens writes: | Can someone give me a sane explanation WHY ? windows doesn't implement it. this has been discussed numerous times before, you can look in the archives for more discussion. -- erno From joejava at dragonat.net Fri Jan 5 18:47:02 2001 From: joejava at dragonat.net (Joel Ricker) Date: Fri, 5 Jan 2001 18:47:02 -0500 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <935093030hc@news2.newsguy.com> Message-ID: Alex Martelli wrote in message <935093030hc at news2.newsguy.com>... >"Skip Montanaro" wrote in message >news:mailman.978707587.25701.python-list at python.org... > [snip] >> I couldn't tell you. I'm a Unix weenie. I boot my laptop into Windows >when >> I need to run Excel... ;-) >Having a good cross-platform Python interface to StarOffice things >would be a GREAT thing, by the way... An Excel interface may be a possibility as well. I know that there is work on an Excel module for perl thats coming along nicely -- only write capabilities for now though. It takes some reverse engineering but it is possible. Although being a windows weenie I'm not sure that an Excel file could be imported or exported onto a unix platform and work just as well on windows. I'll keep it in mind ;) Joel From lsloan00 at my-deja.com Tue Jan 2 13:25:20 2001 From: lsloan00 at my-deja.com (lsloan00 at my-deja.com) Date: Tue, 02 Jan 2001 18:25:20 GMT Subject: book recommendation? Message-ID: <92t6e7$9jn$1@nnrp1.deja.com> I'm new to Python and I would appreciate suggestions for what would be a good reference book to buy? I'm an old hand in general. I know C and Perl very well and Java a little. I've been a programmer and sysadmin for eight years. I'm looking for a book that would be a good language reference, but also has introductions to Python's special features without being too "slow". Sent via Deja.com http://www.deja.com/ From murple at my-deja.com Mon Jan 22 05:07:15 2001 From: murple at my-deja.com (murple at my-deja.com) Date: Mon, 22 Jan 2001 10:07:15 GMT Subject: Python 2.0 parser module bug(?) and a Q References: Message-ID: <94h0oh$69j$1@nnrp1.deja.com> Hi, > > A colleague of mine has an "unparser" module for Python AST; that is > > not (yet) released to the public, and works not (yet) for 2.0. I'm the colleague mentioned. My solution to the problem doesn't look as good as yours: I was rebuilding the Python-code by examining the structure of the syntax-tree. This is also the reason,why it's not working with Python 2.0. I was using the strings in the syntax-tree only for identifiers. Feeling a little bit stupid for not seeing this other solution. > Any constructive critisism is welcome! Ok, your wish is my command :-) I noticed two problems: 1. If you have double DEDENT, there is a '\r' left in the resulting string. This seems to be easely solved by an replace() 2. Anything like "modul.class.function" comes out as "modul . class . function". Using replace to solve this is not good, since you would replace also in wrong places. I think, here you would have to look into the structure of the syntax-tree. Maybe you have an solution for 2.? Another question is, which way is faster. You have to do more recursions, because when I find a symbol.sym_name["class_stmt"] in the tree, I write a "class", you go another step to find the "class"-string in the tree. On the other side, I have to do a lot more comparisons then you do. Maybe after a code-cleanup I will compare the solutions. Anyway, I learned a lot about Python by doing this Unparser (as I call it). It was my first Python-program ever. And I learned a lot about Python-Syntax this way. Hope my comments help you in any way. By, Andreas Sent via Deja.com http://www.deja.com/ From paulp at ActiveState.com Thu Jan 18 23:01:59 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 18 Jan 2001 20:01:59 -0800 Subject: adding the XML to 2.0 to be a mistake? References: <3d8zocuqrd.fsf@kronos.cnri.reston.va.us> Message-ID: <3A67BC37.213BAACB@ActiveState.com> Andrew Kuchling wrote: > > John Schmitt writes: > > Pardon the ignorance, but where is the mistake? Is it in adding PyXML to > > 2.0 or is it the way it was done? Is there no development strategy that > > makes this less of a burden? If a previous release of PyXML had been added > > to 2.0, would you still consider it a mistake? > > Duplicating complex code in two different projects, so that they have > to be kept in sync manually at the cost of time and effort, is the > mistake. I agree with this. I don't think that minidom should have an existence independent of Python. The PyXML minidom should be phased out. The only reason it was not is because some people still use it with older versions of Python. But that will always be a problem when code is moved from an "extension" environment to the standard library. > Another one is tying a fast-moving project such as PyXML to > the slower releases of Python; Python 2.0 was released on October 16, > and there have been two PyXML releases (0.6.2 and 0.6.3) since then. I don't know what you mean by saying that PyXML is "tied to Python." PyXML depends on Python, just as PIL and NumPy do. Paul Prescod From cerutti at together.net Thu Jan 25 15:14:53 2001 From: cerutti at together.net (Neil Cerutti) Date: 25 Jan 2001 20:14:53 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: Neil Cerutti posted: >Fredrik Lundh posted: >>Neil Cerutti wrote: >>> My advice, although I've got limited experience, is to go with >>> Tkinter, and read the following great document, by Python Labs' >>> Fredrik Lundh: >> >>footnot: I work for Secret Labs, also known as PythonWare. >> >>(for some reason, someone thought it would be a good idea to >>create a new company name from two of our trademarks...) >> >>Cheers /F > >Sorry. I'm still proud that I spelled your name correctly. One more thing: No new-line characters in check-box labels in wxPython. At least, I couldn't figure out how to do that or to get the label to wrap at a boundary. -- Neil Cerutti From ngps at madcap.dyndns.org Sat Jan 13 10:42:56 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 13 Jan 2001 15:42:56 GMT Subject: How robust is Python ? References: <9358nn$3c5$1@nnrp1.deja.com> <20010106103938.8FCAFA84F@darjeeling.zadka.site.co.il> <93psqa$ucd$1@coco.singnet.com.sg> Message-ID: <93pt20$7ks$1@clematis.singnet.com.sg> According to Ng Pheng Siong : > while alive: Ouch! Reading that again I hope this does not continue the recent "while 1" thread. ;-) -- Ng Pheng Siong * http://www.post1.com/home/ngps From ommadawn at club-internet.fr Wed Jan 10 10:41:41 2001 From: ommadawn at club-internet.fr (Christophe Prevost) Date: Wed, 10 Jan 2001 15:41:41 -0000 Subject: Problems with zipfile module... References: <93ha6j$ca6$1@reader1.imaginet.fr> <3aW66.5508$AH6.782619@newsc.telia.net> Message-ID: <93hsb3$gjh$1@reader1.imaginet.fr> "Fredrik Lundh" a ?crit dans le message news: 3aW66.5508$AH6.782619 at newsc.telia.net... > > backup = zipfile.ZipFile(zip, "w", "ZIP_DEFLATED") > > ZIP_DEFLATED is a module constant, not a string value. > try changing the above line to: > > backup = zipfile.ZipFile(zip, "w", zipfile.ZIP_DEFLATED) Yes! Thank you Fredrik! It works now From joe at apk.net Fri Jan 12 23:22:20 2001 From: joe at apk.net (Joseph T. Adams) Date: 13 Jan 2001 04:22:20 GMT Subject: Should I learn Python or Java? References: <9393jk$fku$1@plonk.apk.net> <939q0a$d8s$1@newshost.accu.uu.nl> Message-ID: <93ol5s$2c8$1@plonk.apk.net> Martijn Faassen wrote: : Joseph T. Adams wrote: : [snip] :> Smalltalk is far more similar to Java than to Python, so this may make :> Java feel a little more familiar for you. : This I don't believe is true; Smalltalk is far more similar to *Python* : than to Java. Syntaxwise, Smalltalk is as different from Java as it : is from Python, and the semantics of dynamic typechecking is far : more like Python than like than like statically-typed Java. : The one aspect where Java and Smalltalk are more similar is that both : have the tendency to isolate themselves into Java-only and Smalltalk-only : environments, instead of focusing on interoperability. Oh, and another : similarity between Java and Smalltalk is a focus on OO everywhere, : where Python is more paradigm agnostic -- but the way they ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : try to accomplish it is quite different; Java basic types are not : really objects as far as I know, for instance, whereas Python's are : (with some restrictions). : So why do you say Smalltalk is far more similar to Java than to Python? Probably the part I underscored above. Smalltalk and Java both seem attuned to the same OO-centric mindset, while Python is as you say more paradigm-agnostic. Joe From marco at crepido.com Sat Jan 20 07:45:29 2001 From: marco at crepido.com (Marco =?iso-8859-1?Q?Seiri=F6?=) Date: Sat, 20 Jan 2001 13:45:29 +0100 Subject: Python & GUI? References: <3A674896.C7E52247@crepido.com> Message-ID: <3A698869.198D6263@crepido.com> Thank you VERY much for the help. I have now tested some of your suggestions and I think I'll use Python in my project. Not Perl as I thought of first.... The Python community seems to be just super from what I can read here.... /M > > Are there any GUI components or ways to build a GUI in > Python that contains all the widgets that one would expect to > find in a VB or Java environment. Can you (easily) build things > like explorer like applications and such... > > /M From raseliar at dts.mg Sat Jan 6 09:41:41 2001 From: raseliar at dts.mg (Nirina Raseliarison) Date: Sat, 06 Jan 2001 17:41:41 +0300 Subject: How To Think Like A Computer Scientist Message-ID: <3A572EA5.9B2E10DA@dts.mg> Hi All, Can you point to me another URL for the Python version? This one, I found in the archive: http://www.elkner.net/obp/thinkCS/thinkCSpy/index.htm seems to be broken now. Thanks in advance for your help Nirina From shenwang at my-deja.com Mon Jan 22 15:15:48 2001 From: shenwang at my-deja.com (shenwang at my-deja.com) Date: Mon, 22 Jan 2001 20:15:48 GMT Subject: How to define event handler in win32com? References: <94hfsd$hkd$1@nnrp1.deja.com> Message-ID: <94i4da$5nc$1@nnrp1.deja.com> Thanks guys, I will start looking at the codes. Sent via Deja.com http://www.deja.com/ From bowman at montana.com Tue Jan 23 21:43:37 2001 From: bowman at montana.com (bowman) Date: Tue, 23 Jan 2001 19:43:37 -0700 Subject: How do I kill an empty file ?? References: <94k9p5$vs2$1@nnrp1.deja.com> Message-ID: wrote in message news:94k9p5$vs2$1 at nnrp1.deja.com... > Ultimately I'm looking for sytax that will > ignore processing a file if it is empty. os.stat(file) will yeild a tuple including st_size. the stat module defines indices, so if os.stat(file)[ST_SIZE] == 0: pass or somesuch From aahz at panix.com Fri Jan 19 10:33:08 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Jan 2001 07:33:08 -0800 Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> Message-ID: <949mnk$bgu$1@panix6.panix.com> In article , Gerhard =?iso-8859-1?Q?H=E4ring?= wrote: > >jstar from joe here. Everybody who grew up with MS-DOS and Turbo-Pascal >knows that the WordStar keybindings are the one-and-only that really count. Except that *I* grew up with CP/M and TurboPascal. And I still prefer vi these days. (Largely because of the fuckheads who mucked with the Proper way to design a keyboard, with the control key to the left of the "A" the way Ghod intended.) -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I guess I mostly see Life [tm] as a process of closing doors that you might want to go through. --Aahz From fredrik at effbot.org Tue Jan 30 16:08:41 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 30 Jan 2001 21:08:41 GMT Subject: Cannot find libModules.a lib*.a, etc... References: <9578l9$nj3$1@nnrp1.deja.com> Message-ID: jvanar1 at my-deja.com wrote: > I have a serious dilemma. I am trying to embed python into C and I'm > having the most difficult time locating libModules.a libParser.a and > libObjects.a. From what I read they were supposd to have been created > in their respective folders (i.e. Python/Modules/libModules.a) but are > not. I tried re-building and installing the newest version (2.0) > several times. looks like you've been using old embedding docs; the library name was changed in 1.5 (released in january 1998). $ cd Python-2.0 $ ls -l *.a -rw-r--r-- 1 eff bot 3473280 Jan 12 09:39 libpython2.0.a Cheers /F From grey at despair.rpglink.com Sat Jan 20 02:45:40 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 20 Jan 2001 07:45:40 -0000 Subject: Translating a Perl script into Python References: Message-ID: On Sat, 20 Jan 2001 07:13:25 GMT, Sheila King wrote: >Thanks. I guess, I was kind of wondering about the comparison to the Perl >command, which is pretty common for opening files in Perl: I'm going to go backwards on this. Answer this and then move back to see what your original post was. >open PROC, ">proc.test" || die "Couldn't open file for write: $!"; >Is the closest I can get in Python, to a Perl "die" statement, is to use >exceptions? (I'm directing this to the group, not just Erno, as I realize he >may not know Perl. Off the top of my head, might not be the best way... import os import sys file = 'proc.test' try: proc = os.open(file,O_WRONLY) except IOError, error: sys.exit('Counldn't open file for write: error') -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From michael at stroeder.com Thu Jan 18 06:04:21 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 18 Jan 2001 12:04:21 +0100 Subject: Python and Industry, IBM I'm afraid References: <3A63D9E8.F9B74ACE@mjs400.co.uk> <941c14$dok$1@nnrp1.deja.com> <946evt02mr@news2.newsguy.com> Message-ID: <3A66CDB5.CEB18AF5@stroeder.com> Alex Martelli wrote: > > "D-Man" wrote in message > news:mailman.979786609.2939.python-list at python.org... > [snip] > > I have a part time job at a local grocery store that has a > > video department. The computer system they use is an IBM > > mainframe with AIX (4 I think). > > (there _was_ an AIX/370, or > something like that, that you *could* run on mainframes, but > it didn't sell much at all); If you're talking about using Python by running a Unix-flavour you could try to convince your mainframe admin to install Linux in a VM. AFAIK e.g. S.u.S.E. is planning to build a Linux distribution for this platform. Ciao, Michael. From tim.one at home.com Wed Jan 31 02:42:04 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 31 Jan 2001 02:42:04 -0500 Subject: interactive test In-Reply-To: <958a1s$kjb$1@nnrp1.deja.com> Message-ID: [mrnolta at my-deja.com] > What's the appropriate way to test for an > interactive Python session? Right now I'm using: > > if sys.path[0] == '': > interactive = 1 > > which works, but it's often screwed up by people > mangling the search path. > > I tried testing the Py_InteractiveFlag global, but > that doesn't seem to work. Py_InteractiveFlag works fine, but it's non-zero only when -i is an argument to Python (it records whether the Interactive Flag was specified). Beyond that, Python doesn't really know whether it's in an interactive session. It decides whether to run off printing prompts based on whether its input file appears to be a tty (or doesn't but -i was specified). A side effect of that is probably the best handle you've got: the prompt (normally ">>> ") is the value of sys.ps1, but that attribute of sys doesn't get created *unless* Python believes it needs to print a prompt. So import sys if hasattr(sys, "ps1"): # probably interactive else: # probably not interactive You can't be certain with this, though, because there's nothing to stop a user from creating or destroying sys.ps1 themself. although-i-have-yet-to-see-someone-do-either-ly y'rs - tim From m.faassen at vet.uu.nl Sat Jan 13 08:31:55 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 Jan 2001 13:31:55 GMT Subject: Should I learn Python or Java? References: <93phsc$c4c$1@newshost.accu.uu.nl> <9393jk$fku$1@plonk.apk.net> <939q0a$d8s$1@newshost.accu.uu.nl> <93ol5s$2c8$1@plonk.apk.net> Message-ID: <93plcb$c4e$3@newshost.accu.uu.nl> Moshe Zadka wrote: > On 13 Jan 2001 12:32:12 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >> But there's a huge difference in the way OO is done in both languages. >> Smalltalk approach to objects is a lot more similar to Python's than >> Java's. Anyway, it's of course debatable. :) > OTOH, Java and Smalltalk both take the "we are the world" approach, > while Python slithers into whatever niches it finds, playing nicely > with everyone it finds there. (UNIX? It can fork/pipe/munge text files with > the best of them. Windows? It can COM and ActiveX until your face > turned blue. Java? There isn't a class it can't use) > (I know you know this) And in fact, I wrote it a few posts higher up in this thread. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From phrxy at csv.warwick.ac.uk Mon Jan 29 08:47:48 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Mon, 29 Jan 2001 13:47:48 +0000 Subject: win32 DLL import problem Message-ID: Python 2.0 running on win95 gives me the following on trying to import a copy of multipack I compiled on NT: > >> import Multipack > Traceback (most recent call last): > File "", line 1, in ? > File "c:\python20\multipack\Multipack.py, line 16, in ? > from minpack import * > File "c:\python20\multipack\minpack.py", line 2, in ? > import _minpack > ImportError: DLL load failed: One of the library files needed to run this > application cannot be found. but apparently doesn't feel the need to tell me *which* library file it can't find. It can't be _minpack.pyd, because it just found two other files in the same directory -- unless it doesn't recognise it as a valid .pyd for some reason? I compiled multipack on NT with cygwin, with the -mno-cygwin switch, which is supposed to link against the same C run-time library as the python 2.0 distribution itself, msvcrt.dll (which is there on the win95 machine) rather than the cygwin crtdll, so presumably that can't be the problem, but since I don't know which file it can't find, it's hard to say! It does import okay on NT. Thanks for any help John From gregj at pobox.com Thu Jan 11 02:15:08 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 11 Jan 2001 07:15:08 GMT Subject: Reading Microsoft Outlook Express .dbx files References: Message-ID: <04d76.251982$U46.8023631@news1.sttls1.wa.home.com> "Tim Peters" wrote in message news:mailman.979155094.17298.python-list at python.org... > Hint: The undocumented Ctrl+F3 brings up a box with the actual raw email, > headers and MIME separators and all (only in OE; Outlook doesn't support > this, and AFAICT Outlook doesn't even save the original stream). Both Outlook and Outlook Express can show the original raw message source, though it isn't obvious. In OE choose File | Properties | Details | Message Source (or use ctrl+F3 to do the same thing). Outlook has a different path to the message source; I don't have Outlook at home so I don't remember the path, but it's there. Outlook can save selected messages to a text file, which OE can't do. -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com From cpsoct at my-deja.com Sat Jan 20 03:41:39 2001 From: cpsoct at my-deja.com (cpsoct at my-deja.com) Date: Sat, 20 Jan 2001 08:41:39 GMT Subject: Random and whrandom Message-ID: <94bj03$59v$1@nnrp1.deja.com> does random call whrandom or are they two completly different random number algorhythms? I could never figure that out. And Rand? That is depreciated, no? Why is there random *and* whrandom and when do you use which? inquiring minds wanna know! cheers, kevin parks seoul, korea Sent via Deja.com http://www.deja.com/ From Dan.Rolander at marriott.com Thu Jan 18 10:29:27 2001 From: Dan.Rolander at marriott.com (Rolander, Dan) Date: Thu, 18 Jan 2001 10:29:27 -0500 Subject: How to run script from interpreter? Message-ID: <6176E3D8E36FD111B58900805FA7E0F80CCF62D3@mcnc-mdm1-ex01> What is the best way to run a python script from within the interpreter? What command should I use? Thanks, Dan From bhoel at starship.python.net Fri Jan 12 14:47:25 2001 From: bhoel at starship.python.net (Berthold Höllmann) Date: 12 Jan 2001 20:47:25 +0100 Subject: mxtools install (for PySplines) References: <93nkme$sgl$1@nnrp1.deja.com> Message-ID: bernard604 at my-deja.com writes: > Hello > > > I am trying to install PySplines and it requires mxtools. > I have tried to install mxtools but have failed. I tried to compile it > using the instructions (make -f Makefile.pre.in boot). Is there a rpm > of it anywhere. I have seen > something at http://www.2xtreme.net/chadn/python/RPMS/, but I was not > able to download it from there. I am using Mandrake 7.1 if that is of > any use. > > If anyone has gotten PySplines installed, I would like to know how they > did it Hello, Of course I was able to install it, because I've written it (at least I once wrote a PySpline that somehow needs mxTools). What is your problem, when you compile mxTools? What is your Python version. I never worked on Mandrake, so could you please tell what gcc version Mandrake 7.1 uses? Could you post a error message. Cheers Berthold -- bhoel at starship.python.net / http://starship.python.net/crew/bhoel/ It is unlawful to use this email address for unsolicited ads (USC Title 47 Sec.227). I will assess a US$500 charge for reviewing and deleting each unsolicited ad. From michael at stroeder.com Sat Jan 27 14:19:02 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sat, 27 Jan 2001 20:19:02 +0100 Subject: Interested in a Crypto-SIG? References: <3A72C8A3.C4B4D69A@stroeder.com> Message-ID: <3A731F26.15461A27@stroeder.com> "A.M. Kuchling" wrote: > > There's already a > python-crypto list at egroups which could be used to coordinate work > on such a unified API -------- Original Message -------- Subject: Welcome to python-crypto Date: 27 Jan 2001 18:58:49 -0000 From: python-crypto Moderator [..]

The list is hosted inside the US, as are its archives, so to avoid falling afoul of the US export restrictions, it's recommended that postings not contain complete programs or modules. A few lines of code, for illustrating a point or a bug, are probably OK. Patches to existing crypto code falls in a grey area; it's best to mail them to the software's maintainer. -------- Original Message -------- This does not attract me very much. Ciao, Michael. From avv at quasar.ipa.nw.ru Tue Jan 9 13:56:39 2001 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Tue, 09 Jan 2001 10:56:39 -0800 Subject: What's about PyTix? References: <3A5ABF19.3771F634@proceryon.at> Message-ID: <3A5B5EE7.AFF939E3@quasar.ipa.nw.ru> Hi Horst Gassner wrote: > Does anyone know if PyTix is still available? > > If yes, where can I find a actual version? > Will PyTix work with Python 2.0, too? This worked for me: ftp://starship.python.net/pub/crew/avv/PyTix/ Note that binaries placed there are built against Python 1.5.2. Quite recently a person told me that he incorporated this into modern versions of Tcl/Tk/Tkinter. See http://tix.sourceforge.net/, but I didn't find any mention of Pytix there. Alexander From andrew.spambgone.chatham at duke.edu Sun Jan 14 21:41:14 2001 From: andrew.spambgone.chatham at duke.edu (Andrew H. Chatham) Date: 15 Jan 2001 02:41:14 GMT Subject: names References: Message-ID: On Mon, 15 Jan 2001 01:26:45 GMT, Elliott Chapin wrote: >How can I get the name of an object as a string? As a biginner I might >imagine something like > >>>>b=[[1],[2]] >>>>name(b) >'b' You can't. The object doesn't know what it's name is, because the name corresponds to the reference to the object, not the actual object. It's sometimes tough to realize that variables don't store objects, they store references to objects. So if I do >>>b = [[1],[2]] >>>c = b c and b refer to the same list. If I then tried to hypothetical "name" function, the list would have no idea whether to say 'c' or 'b'. Andrew -- Andrew Chatham Duke University '02 andrew.chatham at duke.edu From fredrik at effbot.org Sat Jan 20 15:53:28 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 20 Jan 2001 20:53:28 GMT Subject: Neophyte looking for good books on Python References: <94ak66$dra$1@nnrp1.deja.com> <94aulr$m1o$1@nnrp1.deja.com> <980023572.27042@iris.nyx.net> Message-ID: Sarayu Balu wrote: > These days, there seems to be a newer edition so often, > that we programmers have become suckers for the publishing > company. ...on the other hand, the first edition is nearly five years old, and the new edition is rumoured to be a complete rewrite... Cheers /F From ksaehwa at my-deja.com Tue Jan 2 04:00:10 2001 From: ksaehwa at my-deja.com (ksaehwa at my-deja.com) Date: Tue, 02 Jan 2001 09:00:10 GMT Subject: LCTES 2001 (ACM SIGPLAN Workshop) Message-ID: <92s5ap$fvf$1@nnrp1.deja.com> Call for Papers ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Snowbird, Utah, June 22 - 23, 2001 (in conjunction with PLDI'2001) http://redwood.snu.ac.kr/lctes2001/ ====================================================================== Important Dates * papers due: Feb. 25, 2001 (5pm EST) * author notification: Apr. 15, 2001 * final papers due: May. 19, 2001 ====================================================================== Scope of the Conference As the complexity of the application domains for the embedded systems increases, new research challenges are encountered for achieving desired level of performance goals (which could be diverse such as speed, real time constraints, code size, power, and scalability). Due to limited resources locally available, embedded systems are increasingly used in a networked (wired, wireless, as well as mobile) environment. In addition, advances in hardware reflect into solving issues using a combination of hardware and software techniques. The aim of LCTES is to provide a forum for discussing the latest research related to the above trends and to allow researchers and developers working on different aspects to get together and synergize. Original submissions are invited in all areas relevant to this theme. ====================================================================== Paper Submission Guidelines Papers should report new research and should not exceed 6000 words (approximately 10 typeset on 16-point spacing), including figures and references (11 pages). Short papers that describe existing implementations or work-in-progress, or outline new problems or important issues are also welcome. Short papers should not exceed 3000 words (6 pages). All accepted papers will be presented at the workshop and published in the proceedings, which will be distributed at the workshop. We anticipate that the proceedings will be published as an issue of the ACM SIGPLAN Notices. Electronic submissions must be received by 5:00 PM Eastern Standard Time,Sunday, February 25, 2001. Interactive submissions through the workshop's web page are encouraged. Submissions may also be sent as a single e-mail message to either of the program co-chairs (MIME attachments are allowed); the message should contain both the filled- out form (see web page) and the Postscript paper. Electronic papers should be in Postscript form, which must be interpretable by Ghostscript. The Postscript must use standard fonts, or include the necessary fonts, and must be prepared for USLetter (8.5"x11") or A4 page sizes. Authors who cannot meet these requirements should submit 15 hard copies by post to either of the program co-chairs by airmail that must be received on or before February 25, 2001. These are firm constraints; submissions not meeting the criteria described above will not be considered. ====================================================================== Co-Chairs Santosh Pande College of Computing, 801 Atlantic Drive Georgia Institute of Technology Atlanta, GA 30332, USA phone: +1-404-385-2169, fax: 385-2295 email: santosh at cc.gatech.edu Seongsoo Hong School of Electrical Engineering Seoul National University Seoul 151-742, KOREA phone: +82-2-880-8370, fax: 882-4656 email: sshong at redwood.snu.ac.kr Sent via Deja.com http://www.deja.com/ From duncan.booth at lineone.net Fri Jan 26 04:54:58 2001 From: duncan.booth at lineone.net (Duncan Booth) Date: Fri, 26 Jan 2001 09:54:58 +0000 (UTC) Subject: python-2.1 function attributes References: <94pmsj$36d$1@animus.fel.iae.nl> Message-ID: Carel Fellinger wrote in <94pmsj$36d$1 at animus.fel.iae.nl>: >Duncan Booth wrote: >> Paul Prescod wrote in >> : >... >> How about something along the following lines? > >> __attributes__= { 'attribute1' : 'val1', 'attribute2' : val2 } >> def spam(): >> """The doc string.""" >> pass > >or even better(?) after the def but before spam making it visual clear >that it belongs to spam's definition, but hasn't access to anything but >the enclosing scope, like in: > >def { 'attribute1' : 'val1', 'attribute2' : val2 } spam(): > """The doc string.""" > pass > >this only works nice for litteral dicts, so bumber. The advantage of my suggestion is that not only does it not require new syntax, but it doesn't put any limitations on how you create __attributes__. For example: __attributes__ = ProjectDefaultAttributes() __attributes__['unittest'] = '''Some unit test description''' __attributes__['interface'] = SomeInterfaceStructure() def spam(a, b): pass From rturpin at my-deja.com Sat Jan 20 10:28:11 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Sat, 20 Jan 2001 15:28:11 GMT Subject: I (don' ) will kill my Python References: <94b6vr+8av8@eGroups.com> Message-ID: <94caq6$kij$1@nnrp1.deja.com> In article , "Tim Peters" wrote: > Python was never designed for standalone operation. > That's life. What they *should* say is: "This is my > program! I have created it by myself! Look! And it's > only 507 bytes! Now you go to http://www.python.org/2.0/ > and click on 'Windows installer'. Then we can share tiny > Python programs via email forever after." This makes good sense. For amateurs exchanging their experiments. > Businesspeople have other concerns .. Distribution is much more an issue for commercial enterprises, especially those that want to support an application on thousands (millions?) of clients. Once you start thinking about this, you quickly believe that the sensible thing is to create a new Python distribution on each platform, regardless of whether one already exists. (a) You want to know that the platform was installed correctly. If you just check for the presence of Python, it might be a partial or corrupt distribution someone ignorantly copied from a friend of a friend. (b) You want to make sure that the distribution is the version against which you have regression tested the code. Despite the strong efforts to keep Python backward compatible, anyone who has been involved in QA of commercial products gets very paranoid about shipping what is tested. Nothing more. Nothing less. Nothing different. (c) You want to guard against someone else on the platform purposely or accidently changing any of the libraries, before or after your product is installed. > .. but they can afford to hire Gordon. Is he job hunting? Russell Sent via Deja.com http://www.deja.com/ From scarblac at pino.selwerd.nl Wed Jan 10 09:26:25 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 10 Jan 2001 14:26:25 GMT Subject: book recommendation? References: <92t6e7$9jn$1@nnrp1.deja.com> <93gg3l$nje$1@nnrp1.deja.com> Message-ID: lsloan00 at my-deja.com wrote in comp.lang.python: > In article <92t6e7$9jn$1 at nnrp1.deja.com>, > lsloan00 at my-deja.com wrote: > > I'm looking for a book > > that would be a good language reference, but also > > has introductions to Python's special features without > > being too "slow". > > Okay, I'm being too picky. Since nobody's given any > suggestions, maybe my request should be: > > Please recommend a good Python book. Since you have experience with three other languages already, I'm tempted to recommend "Python Essential Reference". It's a very good reference book. It also includes a short tutorial, but at 11 pages it may be too short. I don't own it myself, but the reviews have been uniformly positive. I learned Python with "Learning Python", also having programming experience, and I liked it a lot. Python has only a few tricky things to understand, and this book explained them well. But it's not a reference at all. There are lots of other books, see http://www.amk.ca/bookstore/python.html . There is of course also the online method: read the tutorial at www.python.org, browse the library reference, read this group, ask questions and help other newbies on the Tutor list, that sort of thing :). -- Remco Gerlich From hwhite at chiliad.com Thu Jan 4 12:45:13 2001 From: hwhite at chiliad.com (Heather Lynn White) Date: Thu, 4 Jan 2001 12:45:13 -0500 (EST) Subject: Alex Martinelli's solution to regular expression/findall problem Message-ID: Your searchall function is just what I needed and it will sit happily in my library. Thanks alot. Heather From parz at home.com Tue Jan 9 11:39:02 2001 From: parz at home.com (Parzival Herzog) Date: Tue, 09 Jan 2001 16:39:02 GMT Subject: One bug and yer out with Pythonwin debugging? Message-ID: I am using Python 1.5.2 with Pythonwin 1.25 on a Win2K machine. I am running a wxPython application, using "post-mortem debugging", and whenever the app fails with an unhandled exception (e.g. Attribute error), the debugger window comes up, and I can see where and what the problem is. Next, I try to correct the source code in the Pythonwin IDE, and run the app again. This never succeeds: Sometimes a Pythonwin process appears that is caught in a compute loop, sometimes an exception occurs in wxWindows that says you can't have more than one wxApp instance, sometimes nothing happens (apparently). I get the impression that the previous instance of the my app is not properly terminated at the time the first bug (exception) occurs. I have told the debugger to "End", and closed the debugger window, and searched in vain for some other way to terminate the running application. The only way I have found to continue after an exception is to terminate the entire Pythonwin IDE, and then restart it. Is there anyway to continue the Pythonwin IDE session after an exception occurs in the debugged app? Thanks, Parzival From joejava at dragonat.net Sat Jan 6 18:44:25 2001 From: joejava at dragonat.net (Joel Ricker) Date: Sat, 6 Jan 2001 18:44:25 -0500 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <935093030hc@news2.newsguy.com> <937o8801nva@news1.newsguy.com> Message-ID: Alex Martelli wrote in message <937o8801nva at news1.newsguy.com>... >"Joel Ricker" wrote in message >news:j4t56.1073$4Z.78460 at news2.atl... > [snip] >> An Excel interface may be a possibility as well. I know that there is >work >> on an Excel module for perl thats coming along nicely -- only write >> capabilities for now though. > >Write-only? Seems _just_ the right job for Perl, then:-). > >[Yah, yah, I know, we're not supposed to badmouth the competition, but >the coincidence with the thread's peculiar subject was irresistible...]. [I realized I should have said *from perl* instead of *to perl* the instant I clicked post. I tried running after it in an attempt to stop it. Almost caught up with it at my ISP but the light changed and it was gone...] I had dreams of expanding that module to read Excel files. Guess now I'll just do a Find-and-Replace on my todo list from "in Perl' to "in Python". Joel From pearu at ioc.ee Tue Jan 2 10:08:06 2001 From: pearu at ioc.ee (Pearu Peterson) Date: Tue, 2 Jan 2001 17:08:06 +0200 Subject: sre \Z bug or feature? Message-ID: Hi, In python 1.5.2, I have >>> re.match(r'(?ms).*?}\s*\Z(?P.*)','{}\012}\012').groupdict() {'rest': ''} but in Python 2.0 the same match gives >>> re.match(r'(?ms).*?}\s*\Z(?P.*)','{}\012}\012').groupdict() {'rest': '\012}\012'} which is surprising because according to docs: \Z Matches only at the end of the string. It seems that the `{}' part is somehow responsible to this behaviour because >>> re.match(r'(?ms).*?}\s*\Z(?P.*)','aa\012}\012').groupdict() {'rest': ''} is expected result and is obtained with Python 2.0. In Python docs and its release notes I found nothing that could explain this behaviour. So, is this a bug or an undocumented feature? If later, could some one, please, explain the basics of this feature? If former, any hints how to go around this bug without updating Python from CVS after it is fixed? Thanks, Pearu From fredrik at effbot.org Fri Jan 19 12:52:56 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 19 Jan 2001 17:52:56 GMT Subject: How to run script from interpreter? References: Message-ID: Dan Rolander wrote: > One more thing, is there a way to pass a command line parameter to the > script named in execfile? Say if I have a script to test which expects a > value in sys.argv[1]? did you try putting it in sys.argv[1] ? import sys sys.argv = ["spam.py", "one", "two", "three"] execfile("spam.py") Cheers /F From donn at u.washington.edu Thu Jan 25 14:03:21 2001 From: donn at u.washington.edu (Donn Cave) Date: 25 Jan 2001 19:03:21 GMT Subject: sockets: client dies... References: <94kmt5$cuj$1@nnrp1.deja.com> <94ksfl$r2a$1@nntp6.u.washington.edu> <94ngqn$rph$1@nnrp1.deja.com> <3A6F8AB1.BDF23F5D@home.com> <94pj8n$jfl$1@nnrp1.deja.com> <94pn5h$t3e$1@nntp6.u.washington.edu> <94ppr8$qac$1@nnrp1.deja.com> Message-ID: <94pt9p$o6e$1@nntp6.u.washington.edu> Quoth Keith Murphy : ... | if i don't setblocking to 0, then it will get hung up on one client... | waiting for a message, right? i'm afraid i don't know what select() | is... | | i guess what i'd like is a better way to sit around and listen to n | hosts, and be able to detect when one has died. select() is documented, it's in the select module. If you want to really understand sockets and a lot more, the classic reference is Stevens, any decent bookstore will have it. If you want a solution already written in Python, asyncore in the standard distribution might be worth a look. Donn Cave, donn at u.washington.edu From donn at u.washington.edu Tue Jan 2 13:25:29 2001 From: donn at u.washington.edu (Donn Cave) Date: 2 Jan 2001 18:25:29 GMT Subject: Returning objects from C extension modules. References: Message-ID: <92t6ep$ch6$1@nntp6.u.washington.edu> Quoth Roy Smith : | I've played around a bit with building extension modules in C, and I think | I've got the hang of the basic stuff. I (think) I understand how to use | Py_BuildValue() to return simple values, and lists, tuples, or dictionaries | of these. | | But, what I don't get is how to implement a class and return an object of | that class. For example, let's say I've got a function in C which looks like | this: | | typedef struct { | int weapon_count; | char name[MAX_NAME]; | } record; | | record *get_record () | { | record *rec_ptr; | | rec_ptr = (record *) malloc (sizeof (record)); | rec_ptr->weapon_count = 3; | strcpy (rec_ptr->name, "spanish inquisition"); | return rec_ptr; | } | | and I want to turn it into a python module which returns an object of class | sketch, as if I had done something like: | | class sketch: | def __init__ (self) | self.weapon_count = 3 | self.name = "spanish inquisition" | | Do I need to have my extension module return a tuple of values, then build a | thin wrapper in python which creates the class, instantiates an object of | that class, and then copies the items of the tuple into the object? Or is | there something more straight-forward? If it's appropriate for your application, you can make a "type" in C. There are plenty of examples in the source tree - look for PyObject_New() in the Modules subdirectory. I didn't see anything about this in the Extending document, to my surprise. The resulting object is like a class instance, but isn't one. I think a bona fide class is most easily created, as you surmise, in Python instead of C. That's a good alternative to a "type" object, if the C functions can make do with ordinary Python data types. Donn Cave, donn at u.washington.edu From pblanchette at pixelsystems.com Wed Jan 3 08:56:39 2001 From: pblanchette at pixelsystems.com (Patrick Blanchette) Date: Wed, 03 Jan 2001 13:56:39 GMT Subject: Memory leak References: <92t8gp$blv$1@nnrp1.deja.com> Message-ID: <1103_978530180@display_02> I experienced a similar problem when I run script that use the win32 extension embeded in a server. When I call the Py_Finalize method, the memory is not free completely. I think the Patch #101713 talk about this problem. It seems that python have problem handling multiple Py_Initialize and Py_Finalise when extension are used. I hope this problem will be corrected soon. On Tue, 02 Jan 2001 19:00:48 GMT, alex116321 at my-deja.com wrote: > I am experiencing memory leakage when using Python and COM. > Specifically, I am using the Micosoft XML Parser to load and traverse > XML DOM stuctures. Everytime I access an XML node, more memory is > consumed. After a while, this can eat away most of the system > resources if the Python session is not terminated. Here is a simple > example (assume the interpreter is used as a server and does not exit): > > ############################################ > #Note: using del doesn't seem to help > ############################################ > import win32com.client > > o = win32com.client.Dispatch("microsoft.xmldom") > o.loadXML("") > > for idx in range(50000): > node = o.selectSingleNode("//test") > > ############################################# > > Any suggestions would be appreciated. > > > > Sent via Deja.com > http://www.deja.com/ From fgeiger at datec.at Thu Jan 25 08:10:29 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Thu, 25 Jan 2001 14:10:29 +0100 Subject: Why does using threads not speed up things? References: <94oob9$ahq$1@newsreaderg1.core.theplanet.net> Message-ID: <94p8if$j2a$1@newsreaderg1.core.theplanet.net> This question really was not very precise. Sorry abaout that, stupid me. Source was on a machine in the LAN, destination on the local machine (drive D:). Singlethreaded: Scanning the directory tree on the machine in the LAN took 1300 seconds, 600 secs for the local drive. Multithreaded: This was in total 300 secs faster, which means, that 50% of the "local job" were done in parallel to the "LAN job". Now that's really not so bad, is it? Thanks for your quick reply and sorry not being that precise. Best regards Franz "Franz GEIGER" wrote in message news:94oob9$ahq$1 at newsreaderg1.core.theplanet.net... > > I wrote a file synchronizer, which copies newer files to a backup > destination and there deletes files that don't exist anymore on the source. > The synch source and the synch destination are connected by a LAN. So I > thought it would be a good idea to scan the source and the destination in > parallel, using two threads. I expected a performance gain of let's say 30 > %. > > So I did a few tests and wrote a sample programm that gathers file names. It > does this in 2 tasks: Task 1 gathers the file names on the source, task 2 on > the destination. To be able to compare this version with the one is used > until now, I did it that way too: First scan the source, then scan the > destination. I called the former multithreaded version and the latter > singlethreaded version. > > The singlethreaded version took 1900 seconds to execute, the multithreaded > version took 1600 seconds. The gain is 300 seconds, which is about 15 % > faster than the singlethreaded version. > > If source and destination lies on the same machine, there is no significant > difference in performance. > > As I said I'd expected more, because there is a lot of slow disk I/O > involved and data transfer over a 10MBit section of our LAN. Or did I miss > something? > > Best regards > Franz GEIGER > > > > From db3l at fitlinxx.com Thu Jan 18 18:18:17 2001 From: db3l at fitlinxx.com (David Bolen) Date: 18 Jan 2001 18:18:17 -0500 Subject: Access, Field names, mxODBC References: <947ods$uk4$1@nnrp1.deja.com> Message-ID: vmarkwart at my-deja.com writes: > I'm using the mxODBC.Windows module with an Access database. Can anyone > tell me, or point me to an SQL or other statement which can return the > field names returned from a query. Once you have made the query, you can use .description, where is your cursor for the query, which is a tuple of tuples, with each inner tuple representing a column of the query. I haven't done this with Access myself (only with other databases), but I'd presume the ODBC method to Access works the same way. This method and the per-column tuples are documented in the Python DB-API html files that come with mxODBC. -- -- 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 tim.one at home.com Wed Jan 3 22:21:50 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 3 Jan 2001 22:21:50 -0500 Subject: split hangs In-Reply-To: <14Dq0m-0PX-00@mercurio.localdomain> Message-ID: [Tim, tweaks Davide] > Then you had better start reading better stuff . I'll repeat > the original recommendation: Jeffrey [note: I erroneously said > Jonathan before] Friedl's excellent book "Mastering Regular > Expressions" (O'Reilly). [davide at mercurio.localdomain] > Sorry, but the dragon book (Aho Sethi, Ullman), Introduction to > automata theory, languages and computation (Hopcroft, Ullman) and > thousand of others books on language theory are surely a better > reference . Those are excellent references for the Theory of Regular Languages, but are pretty much irrelevant to the practice of regular expressions. They're not going to teach you anything about the pragmatics you need to learn if you want to use regexps effectively in Python, Perl, Emacs, etc. The "theoretical best" algorithms rarely get implemented in real life. For example, take a construction that promises marvelous big-O improvement, but at the up-front cost of doing work proportional to the alphabet size (which-- for any actual alphabet --is a fixed and usually finite constant, and so doesn't contribute to big-O). In a Unicode world (w/ a 64K alphabet), the result is likely of no practical use. That doesn't mean I despise theory (quite the contrary), it means that if you're asking (as you did) why some regexp took exponential time in Python, your notion of "better" is inverted if it prevents you from discovering the answer. The books you favor aren't going to tell you; Friedl will (I cheerfully agree that Aho et alia will tell you a world of stuff Friedl won't though -- just not stuff that will answer your question). >> There are two "obvious" ways to implement a regexp engine. > Indeed, regexp matchig is quite simple. No, Regexp Matching is simple. The matching of regexps, on the other hand, is a god-awful engineering nightmare. Pick your favorite language and study its regexp-matching source code! Study its bug history. Try to improve it. Ponder why no two regexp implementations even support the same notation. Besides being fun, it will give you a healthy skepticism about "better" . >> One extreme>Friedl calls "the NFA" way (although he's using >> "NFA" in a sense that >differs from its technical meaning in the >> literature). > Yes, reading your post I understand that the reason is these are not NFA, > "backreferences" are not part of regualar expressions and so we are not > talking of regular languages. I had more in mind that an NFA is formally defined in various ways by various authors (like with or without epsilon transitions, with or without multiple start states, with or without multiple same-symbol outgoing transitions from a single state, with or without expressions (as opposed to single symbols) on transitions, ...), but that in the implemented engines Friedl calls "NFA" you'll rarely find any of that stuff. At least not as such. The typical "NFA engine" in practice is really a general-purpose graph-crawling backtracking engine, as powerful as the engine in SNOBOL4 -- and about as hard to predict in all cases. While regexp notations rarely let you get at all that power (not to mention debugging headaches), there's been a steady trend in the Perl language to expose more of it over time (e.g., to match nested bracket constructs, which is in the realm of context-free languages, and so beyond what an NFA (in the non-Friedl sense) can do). Backreferences are just part of that; the point is that Regexp Theory doesn't even *inform* most people who write a non-DFA regexp engine, and that's why Regexp Theory has no useful point of contact with such engines. they're-only-called-regexps-they're-really-luxury-yachts-ly y'rs - tim From echuck at mindspring.com Sun Jan 28 00:18:39 2001 From: echuck at mindspring.com (echuck at mindspring.com) Date: Sun, 28 Jan 2001 05:18:39 GMT Subject: marshal doesn't work with "file-like" objects References: <5.0.2.1.0.20010126135016.029c4d90@mail.mindspring.com> <94t1bi$m73$1@nnrp1.deja.com> Message-ID: <950a3c$27b$1@nnrp1.deja.com> In article , "Fredrik Lundh" wrote: > Chuck wrote: > > Does anyone really believe that there is any difference in performance? > > Supporting file-like objects would add the overhead of a message pass. > > "a couple of thousand message passes", that is. > > > But what's taking place here is file I/O that easily ranges from 1K to > > 40K (according to my dir *.pyc). > > marshal does lots of single byte reads. the're only one fread > in marshal, and that's used to read string literals. > > > I seriously doubt that if message passing were suddenly employed [a] > > anyone would notice and [b] any Python benchmarks would change. > > maybe, but people sure notice when we *improved* marshal's > performance: > > http://deja.com/=dnc/getdoc.xp?AN=715125331 > > > I win <0.95 wink>. > > nope. > > Cheers /F OK, here's my next attempt: It would be even faster to simply write the marshal results to memory first and then blast them out to disk in one fell swoop, e.g. ultimately one fprintf() call. In which case, my original thought that a single message pass wouldn't matter becomes correct. Sound good? -Chuck Sent via Deja.com http://www.deja.com/ From marco at crepido.com Sat Jan 20 11:07:41 2001 From: marco at crepido.com (Marco =?iso-8859-1?Q?Seiri=F6?=) Date: Sat, 20 Jan 2001 17:07:41 +0100 Subject: Different deployment considerations (was: Python & GUI?) References: <3A674896.C7E52247@crepido.com> <3A698869.198D6263@crepido.com> <301DBDE62C14BD35.683C43A181247CB3.8398E5428BE1B406@lp.airnews.net> Message-ID: <3A69B7CD.41CCEDE9@crepido.com> Actually deployment is very important. But it might be the part that is least fun to make work nicely.... In an academic world deployment often is of no concern, but in my world I have to be able to send out a CD with a very easy installation procedure... A single binary package is preferable, my users should really not have to care what language or run-time I use. It is an internal issue for me as a programmer. /M Cameron Laird wrote: > > In article <3A698869.198D6263 at crepido.com>, > Marco =?iso-8859-1?Q?Seiri=F6?= wrote: > >Thank you VERY much for the help. I have now tested > >some of your suggestions and I think I'll use Python > >in my project. Not Perl as I thought of first.... > > > >The Python community seems to be just super from what > >I can read here.... > . > . > . > The Python community is. > > So is Perl's--but in a different way. > > Scripting GUIs with Python is a far richer experience > than with Perl, in general; I've studied and done both > in some depth, and write this with confidence. HOWEVER, > one significant advantage of Perl/Tk (there's a second > one, not apposite for this discussion) is its "deploy- > ability". There is more than one practical way to > generate a single-file executable from a conventional > Perl/Tk application. What's the situation on the Python > side? Gordon's Installer makes Win* Tkinter apps into > single files ... I know of *no* other of the many Python > GUI bindings which enjoys this benefit. > > Does anyone have evidence to the contrary? > > Assume the usual disclaimers: I'm not claiming this > deficiency, if true, is cause for alarm, hairy palms, > starvation in the southern hemisphere, or so on. I'm > just out to get the facts. > -- > > Cameron Laird > Business: http://www.Phaseit.net > Personal: http://starbase.neosoft.com/~claird/home.html -- Marco Seiri? - Tel: 0708-88 04 64 - marco at crepido.com Crepido Systems AB - www.crepido.com - Tel: 031-86 87 71 Box 6131, 400 60 G?teborg. Bes?k: ?v?gen 6, G?rda From aleaxit at yahoo.com Mon Jan 22 12:19:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 22 Jan 2001 18:19:36 +0100 Subject: How to define event handler in win32com? References: <94hfsd$hkd$1@nnrp1.deja.com> Message-ID: <94hq370ar5@news1.newsguy.com> wrote in message news:94hfsd$hkd$1 at nnrp1.deja.com... > After using makepy, I can easily access properties and methods of a com > object, but I do not how to bind my python function to the events > defined in that object. Any help? Using DispatchWithEvents rather than Dispatch is probably simplest, if you can use it (i.e., if you are creating the object whose events you need to bind to): you define a class whose methods have the name of the event-functions you want to be called (when each suitable event occurs), and pass the class object to DispatchWithEvents (it's in win32com.client, just like Dispatch). For a more general solution, you may derive your class from the makepy-wrapper for the source-interface you're interested in getting, and instantiate your class with, as its argument, the specific already-existing object whose events you want to bind to (remember to call the base-class's __init__ if you have an __init__ yourself -- THAT is the one that needs the already-existing object as argument!). Alex From sheila at spamcop.net Sat Jan 20 18:22:01 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 20 Jan 2001 23:22:01 GMT Subject: Translating a Perl script into Python References: <94d4hk$1sq$1@animus.fel.iae.nl> Message-ID: [reply posted and e-mailed] On 20 Jan 2001 23:47:16 +0100, Carel Fellinger wrote in comp.lang.python in article <94d4hk$1sq$1 at animus.fel.iae.nl>: :Sheila King wrote: : :for this piece of code :> print PROC "$key = $ENV{$key}\n"; :you used :> PROC.write(key + " = " + os.environ[key] + "\n") : :whereas I often prefer (the (to me atleast) more Pythonic) : PROC.write("%s = %s\n" % (key,os.environ[key]) : :and yet in some circumstances even the more elaborate variant : PROC.write("%(key)s = %(value)s\n" % {key:key, val:os.environ[key]}) : :The latter form comes very close to the Perl way of coding, and :is espescially suited for format strings spanning several lines. Hmm. Interesting. I've kind of been scared off by the % stuff. I didn't understand it, or what it was doing, and never really saw it mentioned in the docs, other than: "You can use the 'C'-like way of doing things..." But I don't really know C, so that put me off. But looking at your code, I'd venture that it works like this? %s is a substitute for something that will be revealed later, when you write ("%s = %s\n" % (key,os.environ[key]) The %s in the string is taking the place for something that comes later, and then at the end you list in parenthese the later stuff, behind a % sign. Um, did you leave out a parenthese in the above statement? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dsavitsk at my-deja.com Fri Jan 26 17:09:07 2001 From: dsavitsk at my-deja.com (dsavitsk at my-deja.com) Date: Fri, 26 Jan 2001 22:09:07 GMT Subject: xor operator? References: <20010126125141.18593.qmail@nw128.netaddress.usa.net> <3A7188A9.1482CA3D@divalsim.it> <3A71951D.20A2@hvision.nl> <94sbo702lon@news2.newsguy.com> Message-ID: <94sshs$hlp$1@nnrp1.deja.com> In article <94sbo702lon at news2.newsguy.com>, "Alex Martelli" wrote: > "savitsk" wrote in message > news:Fihc6.6515$Ch.1522702 at newsrump.sjc.telocity.net... > [snip] > > > > > the only language I'm famialiar with, with a boolean XOR operation > :) > > > > > for better or worse, visual basic 6 has an Xor operator (according to VB & > > VBA in a nutshell, pg. 611) > > Sure, but, as the same excellent nutshell book indicates in the > same page, it's *bitwise* -- 15 Xor 179 is worth 188. It is > thus roughly equivalent to the ^ operator of Python and is not > the 'boolean' kind that I think is being discussed. not correct. look back a few pages (608) and you will notice that it is both logical and "... [it] doubles[s] as [a] bitwise operator ..." ds Sent via Deja.com http://www.deja.com/ From sheila at thinkspot.net Mon Jan 15 14:03:11 2001 From: sheila at thinkspot.net (Sheila King) Date: Mon, 15 Jan 2001 19:03:11 GMT Subject: File I/O, rfc822, and stdin/stdout References: Message-ID: This situation has been brought to resolution. The script I was having trouble with before, quoted below, is now working on my web host, with the MTA invoking it. I have installed Python 2.0 and am using that now. The web host only had Python 1.5.1, and I believe that may have been the problem. Of course, I've had to change the path of the script to point to my install of Python 2.0. On Sun, 14 Jan 2001 06:35:28 GMT, Sheila King wrote in comp.lang.python in article : :Of course, the problem with the above script, is it doesn't give me any easy :way of handling the message headers, for filtering purposes. : :So, I now tried to combine them, into a script that would be of more use to :me: :---------------------------------------- :#! /usr/bin/python : :import sys, rfc822 : :raw_message = sys.stdin : :inheaders=rfc822.Message(raw_message) :body=raw_message.read() : :print inheaders :print :print body :---------------------------------------- : :Supposedly, it should read from stdin, retrieve the headers and body :separately, and then write them to stdout. But I'm getting no e-mail :delivered. I would also like to thank Eric Rahmig, who went to a great deal of trouble to write a similar script, which will actually be of great use to me, as I work to my final goal. Here is my adaptation of his script: ----------------------------------------- #! /my/path/to/Python-2.0/python import rfc822, sys origheaders=rfc822.Message(sys.stdin, 0) for h in origheaders.headers: print h, print for line in sys.stdin.readlines(): print line, print print print "This message was passed through a Python script" print ----------------------------------------- He sent me some assistance through e-mail. The above script is invoked on my system through a .qmail file, with the following contents: ------------------------------------------ |/my/path/to/Python-2.0/python /my/path/to/scriptname.py ------------------------------------------ The script reads in the e-mail from stdin, and then puts it back out to stdout, adding a short tag. The point is, now I will be able to do what I want: analyze the headers and decide how to handle the mails. Thanks to all for their assistance. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From redhouse at my-deja.com Mon Jan 8 14:40:02 2001 From: redhouse at my-deja.com (redhouse at my-deja.com) Date: Mon, 08 Jan 2001 19:40:02 GMT Subject: Problems with py-indent-region in XEmacs References: <93655e$rds$1@nnrp1.deja.com> <3A5723C1.7B53721@python.net> Message-ID: <93d52g$46g$1@nnrp1.deja.com> Thanks. The thing I'm doing is that I am taking a parm list and assigning each parameter to a class data member of the same name. I have an elisp function which is just a glorified macro to do this, but when it is done the indentation of the code it generates is hosed. I guess I can do a save current column earlier and then a C-c > on the generated code. I'm doing this because I find myself writing: def __init__(foo,bar): self.foo=foo self.bar=bar very frequently and was trying to speed it up. Thanks again. -Carter Sent via Deja.com http://www.deja.com/ From Pieter_Claerhout at CreoScitex.com Wed Jan 17 03:49:29 2001 From: Pieter_Claerhout at CreoScitex.com (Pieter Claerhout) Date: Wed, 17 Jan 2001 09:49:29 +0100 Subject: checking free disk space Message-ID: <2B1262E83448D211AE4B00A0C9D61B030130184C@msgeuro1.creo.be> Here's how you can do this on Windows: #### START OF CODE #### import string import win32api import win32file def PrintSpaceReport(drive): sectorsPerCluster, bytesPerSector, numFreeClusters, totalNumClusters = win32file.GetDiskFreeSpace(drive + ":\\") sectorsPerCluster = long(sectorsPerCluster) bytesPerSector = long(bytesPerSector) numFreeClusters = long(numFreeClusters) totalNumClusters = long(totalNumClusters) print print "Drive: ", drive + ":\\" print "FreeSpace: ", (numFreeClusters * sectorsPerCluster * bytesPerSector) / (1024 * 1024), "MB" print "TotalSpace:", (totalNumClusters * sectorsPerCluster * bytesPerSector) / (1024 * 1024), "MB" print "UsedSpace: ", ((totalNumClusters - numFreeClusters ) * sectorsPerCluster * bytesPerSector) / (1024 * 1024), "MB" def main(): AvailableDrives = [] for i in string.split(win32api.GetLogicalDriveStrings(), '\000'): if win32file.GetDriveType(i) == 3: # we only need fixed drives (no CD drives) AvailableDrives.append(i[:-2]) DriveInfo = [] print "Drive free space report" for drive in AvailableDrives: PrintSpaceReport(drive) if __name__ == '__main__': main() #### END OF CODE ### Kind regards, Pieter -----Original Message----- From: sill at localhost.kitenet.net [mailto:sill at localhost.kitenet.net] Sent: Wednesday, January 17, 2001 2:56 AM To: python-list at python.org Subject: Re: checking free disk space On Mon, 15 Jan 2001 14:23:59 +0200, Langa Kentane wrote: >Good day. > >I want to write a script that I can use to check the free disk space on all >drives. The script will be used in Linux and Wind0ze. > >For instance, I want to write something like: > >get list of mounts/drives >for i in mount_list > check disk space left in % > if disk space is certain amout: > do this > else > do that > endif >endrun > >Please can you point me in the right direction. I posted something before >on this list but I realised that will not work in a wind0ze environment. On unix you can parse output of df, and on windows I'm not entirely sure but doesn't dir command tell you how much space is left on drive? So you can keep trying cd X:; dir; starting with C and until you run out of drives.. You can tell if it's a cd if it's under 650mb and has no free space at all. > >Thanks in advance. > >__________________________________________________________ >Langa Kentane | TEL: (011) 290 3218 >Security Administrator | Cell: 082 606 1515 >DISCOVERY HEALTH | http://www.discoveryhealth.co.za >__________________________________________________________________ > > -- Andrei -- http://mail.python.org/mailman/listinfo/python-list From aahz at panix.com Wed Jan 31 11:55:15 2001 From: aahz at panix.com (Aahz Maruch) Date: 31 Jan 2001 08:55:15 -0800 Subject: Time limited threads? References: <9591b8$2if@news.or.intel.com> Message-ID: <959g1j$l79$1@panix2.panix.com> In article <9591b8$2if at news.or.intel.com>, Miki Tebeka wrote: > >Is there a way I can limit a threads execution time? (and then resume it >later?) Not directly in standard Python. >Background: >We're giving an exercise in scheduling. >I'd like to give the students a service that runs one thread for a given >time quota. >Then they will write the scheduler. You might try looking at microthreads. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "People sometimes focus too much on the fact of communication rather than the substance of communication." --Dave Morton From Stowasser.h at idowa.de Wed Jan 3 09:54:31 2001 From: Stowasser.h at idowa.de (Harald Stowasser) Date: Wed, 03 Jan 2001 15:54:31 +0100 Subject: Zope ZClass & Namespace Message-ID: <3A533D27.254D9B5D@idowa.de> First of all, hello to all who read this. Im new in this group, so feel free to tell me if im dooing something wrong ;-) So now to my problem. I have a Apache-Server with ZOPE and want to write some ZClasses in PythonMethod's. Now i got a problem with the propertys where my method is in. I wan't to write into the property by my Python-programm but this don't work. my code: /______ ZOPE (dtml):

Ort=

Ort=

/______ Redaktion-Objekt: test="P" + self.Ort + "P" ---> self.Ort = test <--- DONT WORK return test brings the error: Error Type: Python Method Error Error Value: Forbidden operation STORE_ATTR at line 3 So you see if the property Ort is "THING" then should apear: THING PTHINGP PTHINGP If i delete the marked line my Progamm works, but it brings me this: THING PTHINGP THING ( Of course ) Why i can not write into the variable ? P.S. sorry for my bad english. From m.faassen at vet.uu.nl Sat Jan 13 11:00:48 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 Jan 2001 16:00:48 GMT Subject: Python language suggestion References: <93l4ve$no3$1@nnrp1.deja.com> <3A5E1D2B.1DC60661@alcyone.com> <93m3r6$fuj$1@nntp9.atl.mindspring.net> <3A5E9E45.9A59848F@alcyone.com> Message-ID: <93pu3g$cem$1@newshost.accu.uu.nl> Erik Max Francis wrote: > Andrew Dalke wrote: >> I believe he means >> foo.'bar bletch' >> as an alternate way of doing >> getattr(foo, 'bar bletch') >> >> not as foo['bar bletch'] > That's not what he said. He explicitly used the subscription notation > and even said "dictionary-like objects." But an instance is quite a bit like a dictionary, and can be considered to be syntactic sugar for one. Anyway, if the proposal is what Andrew is suggesting, it's an interesting idea, which I'm mulling over too. I don't know.. One problem seems to be the string methods. What happens here? foo.' bar '.strip() Also, where does it end? After all, not only strings can be used as dictionary keys: foo.1 = 2 Though I just checked and setattr() certainly doesn't accept: settattr(a, 1, "foo") It does work through __dict__ though: a.__dict__[1] = "foo" print a.__dict__[1] But this seems to be of limited applicability; getattr only takes strings too. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rturpin at my-deja.com Wed Jan 17 14:27:12 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Wed, 17 Jan 2001 19:27:12 GMT Subject: threading: how to kill a (possibly blocked) thread? References: <3A649FE4.E582D0E0@ll.mit.edu> <944ekb$ri$1@nnrp1.deja.com> Message-ID: <944rm3$dg4$1@nnrp1.deja.com> In article , grante at visi.com (Grant Edwards) wrote: > Where does set_interrupt come from? You didn't read my post. The second sentence after: "Unfortunately, I don't see such a facility in the library." I was describing what I want, not what is there. I share your disappointment. Russell Sent via Deja.com http://www.deja.com/ From chris at 2s2iNO_SPAM.com Sun Jan 28 09:21:26 2001 From: chris at 2s2iNO_SPAM.com (Chris) Date: Sun, 28 Jan 2001 09:21:26 -0500 Subject: "print" strange with Sybase module References: <3A70163A.10D995@schlund.de> <94q0f6$lu5$1@news.cybercity.dk> <9518u5$1rk0$1@news.cybercity.dk> <_LVc6.9609$Qb7.1426225@newsb.telia.net> Message-ID: Erwin & Fredrik - Thank you both very much. Your responses have shed significant light into dark areas for me! Chris Fredrik Lundh wrote in message news:_LVc6.9609$Qb7.1426225 at newsb.telia.net... > Erwin S. Andreasen wrote: > > AFAICS, there is no way to turn the buffering to be line-based on an existing > > file object (it might be an idea for a future release?). You could do > > something like: > > > > sys.stdout = os.fdopen(os.dup(sys.stdout.fileno()), 'w', 1) > > > > which would reopen standard output as a line-buffered (the 1) stream, > > i.e. every time you have written a full line to the file object, it's flushed > > -- just like when you run the program on the console. > > here's a variant, which works for any kind of sys.stdout: > > class UnbufferedStream: > def __init__(self, stream): > self.stream = stream > def write(self, data): > self.stream.write(data) > self.stream.flush() > def __getattr__(self, attr): > # delegate everything else > return getattr(self.stream, attr) > > sys.stdout = UnbufferedStream(sys.stdout) > > Cheers /F > > > > > From sholden at holdenweb.com Fri Jan 5 08:11:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 5 Jan 2001 08:11:27 -0500 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> Message-ID: Joel Ricker wrote in message news:V%c56.4648$of7.221797 at news1.atl... > Wow, great answers for a probably frequent question. Thanks everyone! > > Skip Montanaro wrote in message ... > > [...] > > Sounds great. Perl always seems to be very unix-centric which tends to bug > me. Only one book I've gotten on Perl went for a cross-platform approach to > perl (Perl Black Book). Another question. I just downloaded Activestates > build for Python. I went there first since I've got accustomed to their > services. Is a good build? As good as Pythonlabs? Better? > ActivePython is pretty much the "BeOpen 2.0" release of Python plus the Mark Hammond Win32 extensions, with the added bonus that the help files have been munged into a Windows .chm (HTML help) file. It's great stuff, and the only distribution of 2.0 I've found necessary to install on Windows (given that on Windows, unlike Unix, I don't compile Python from source). > >Your comment about Perls multitude of contexts really rings true with me. > I > >use Perl in the guise of Mason these days to maintain the Mojam.com > website. > >(Mason is great, by the way. I just wish it used Python. ;-) A couple > weeks > >ago I thought I had all the reference stuff figured out, but then this > >morning it all came crashing down on me (again). Ah well, back to the > >perlref manpage... > > > No kidding. I just but Object Oriented Perl by Damian Conway and I thought > I had the idea and concepts down and by the end of the third chapter it all > came crashing down. Things are working that shouldn't and vice versa. I > probably need to take a look at the perlref manpage myself but I'm > suspecting it may be the new build from Activeperl but I'm getting too > fustrated to dig into it. I could post for help but I already know the > answer that I'll be given: > > perldoc perltoot > Well, you'll often get links to web pages in replies on this newsgroup, but the "eat s**t and die, m*****f**ker"-style hostility observed in other groups from time to time very rarely happens in c.l.py. I did consider posting such a response to your question (as a joke...) followed by some helpful advice, but a) it goes against the grain of this group, and I would have doubtless needed asbestos pants myself then, and b) I knew you'd get good advice from the many worthies who are the mainstay of the group. [...] > > Joel By now you should be running Python happily. I was a Perl user once, but when I came to the object-oriented mess I said "blerch" and decided to look for a sensible language. I've found that, and more, in Python, and wouldn't consider Perl nowadays. This is NOT to say that Perl doesn't have its uses -- as the timbot pointed out, it has "optimized the snot" out of r-e pattern matching. But it began to seem as though almost any random string had meaning in Perl, and I don't have time for that sort of nonsense. Good luck. I-used-to-program-in-Perl-but-i'm-all-right-now-ly y'rs - steve From matt at virtualspectator.com Sat Jan 20 17:04:18 2001 From: matt at virtualspectator.com (matt) Date: Sun, 21 Jan 2001 11:04:18 +1300 Subject: interesting bound-built-in-method technique In-Reply-To: References: <9476k6$d55$1@nnrp1.deja.com> Message-ID: <01012111062403.00900@localhost.localdomain> On Sun, 21 Jan 2001, Quinn Dunkan wrote: > On Thu, 18 Jan 2001 16:46:01 GMT, Chris Ryland wrote: > >Reading the Quixote sources taught me an interesting little "hack" > >using bound-built-in methods: > > > >>>> m = {'foo': 1, 'bar': 0}.has_key > >>>> m('foo') > >1 > >>>> m('bar') > >0 > > > >Is this a common idiom in Python? Very clever for turning a dictionary > >lookup into a functional form. > > > >Are there other clever but generally obscure idia? (Idioms? ;-) > except that your example has an error ..... m('bar') should return 1 since your bound method should return 'true', not the value of that item. eg : >>> m = {'foo':'one','bar':'two'}.has_key >>> m('foo') 1 >>> m('bar') 1 >>> From gregj at pobox.com Thu Jan 25 14:28:35 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 25 Jan 2001 19:28:35 GMT Subject: removing duplicates from .csv files References: <94ptre$uf0$1@nnrp1.deja.com> Message-ID: <94puol$v7q$1@nnrp1.deja.com> I suggest Excel, unless you have to do this a lot. What I've done when faced with this problem is import the file(s) into an Excel worksheet, clean up the columns you care about (remove leading/trailing spaces, normalize upper/lower case), and fix phone numbers, zip codes, etc. so the punctuation is normalized (e.g. 800-555-1212 vs 800 555 1212). Next sort the whole thing on one of the columns that will identify duplicates--phone number is a good start. Add a colum that will flag duplicates: in the second non-blank row of the new column enter: if(X2=X1,"*","") Where X refers to the column in your worksheet. If you have blank phone numbers your row numbers will be higher than 1 and 2, but you get the idea. Copy this formula down to the end of the rows. Now you'll see a * in any row where the phone number is the same as the previous row. You can merge/correct the duplicate rows, then delete the ones you don't want. Do this with all of the columns that may identify duplicates until the data is clean. If you will be doing this a lot it would be an interesting and non- trivial programming problem in Python, or any language. There are commercial programs that do de-duping/merging of name/address info, and some of them are quite expensive. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From smigowsky at dspace.de Fri Jan 19 10:27:35 2001 From: smigowsky at dspace.de (Stefan Migowsky) Date: Fri, 19 Jan 2001 16:27:35 +0100 Subject: AW: Python COM and DCOM. Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13A90D@newsintern.dspace.de> Hi, what kind of error did you get ? If it was E_ACCESSDENIED you should check the launch and authentication permissions on the client computer with dcomcnfg.exe. The example in the WIN32 book was running probably DCOM with a W95 client and there are no security issues. Stefan -----Urspr?ngliche Nachricht----- Von: Syver Enstad [mailto:syver at NOSPAMcyberwatcher.com] Gesendet: Freitag, 19. Januar 2001 12:49 An: python-list at python.org Betreff: Python COM and DCOM. I am having a bit of a problem getting a python COM object to work over DCOM. As far as I can see I've done exactly what is proposed in the Python on Win32 book. But the object is started on the local machine, when using win32com.client.Dispatch or the default instance creation methods in other languages such as JScript with ASP and C++. It seems like DCOM works when using the DispatchEx to explicitly choose the machine to run on but not else. Help very much appreciated, thank you. -- http://mail.python.org/mailman/listinfo/python-list From ullrich at math.okstate.edu Mon Jan 22 09:51:19 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 22 Jan 2001 14:51:19 GMT Subject: pyXML support for XSL tranformations?? References: <94d1tj$6sa$1@nnrp1.deja.com> <3a6aef10.3738521@nntp.sprynet.com> Message-ID: <3a6c4800.3297821@nntp.sprynet.com> On 21 Jan 2001 21:50:04 +0100, Martin von Loewis wrote: >ullrich at math.okstate.edu (David C. Ullrich) writes: > >> I have the 4Thought XSL stuff from a little while ago. When I >> installed it I had to replace the current (1.5.2) Python xml.dom >> with one that came with 4Thought, which I gather was an >> older version. I didn't like this but I did it and it works fine. > >In Python 1.5.2, there was no xml.dom - so I doubt you had replaced >the Python xml.dom. Right. I actually meant the xml.dom from what seems to be called "the Python xml-sig distribution". (Or what was in any case called that at that time...) >What you might have replaced was some xml.dom from >some PyXML; whether it was older or new would much depend on what >PyXML version you actually had. > >> Q: Does the current 4Thought XSL stuff get along a little >> more _cleanly_ with Python? (I actually haven't got around >> to getting Python 2.0 precisely because it took a little >> tweaking to get the XSL going in 1.5.2...) > >The current 4Suite release contains a copy of PyXML 0.6.3, enhanced by >a few patches that will only appear in PyXML 0.6.4; you should use the >PyXML version that comes with 4Suite. Thanks. >Regards, >Martin > From aahz at panix.com Sun Jan 7 13:27:20 2001 From: aahz at panix.com (Aahz Maruch) Date: 7 Jan 2001 10:27:20 -0800 Subject: boolean xor Message-ID: <93ace8$nmo$1@panix3.panix.com> I need a boolean (not bit-wise) xor function. I've got the following function, but my logic skills are rusty enough that I'm wondering if this is the "right" way to do it (I've validated that it produces the correct outputs, at least): def xor(a,b): return not ( (a and b) or (not (a or b)) ) -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "This is Usenet. We're all masturbating in public places." -DH From m.faassen at vet.uu.nl Wed Jan 10 08:59:55 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 10 Jan 2001 13:59:55 GMT Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com> <93dfft077p@news1.newsguy.com> <93f4q7$ji4$1@newshost.accu.uu.nl> <90259B539rcamesz@127.0.0.1> Message-ID: <93hpsr$k1k$2@newshost.accu.uu.nl> Robert Amesz wrote: > Martijn Faassen wrote: >> [Snip] >> >>Dus, voorwaards met dat Nederlands! > --------^- > Well, one can but hope... Een anglisme. Ik tiep ook veel Engels. :) Groeten, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From root at rainerdeyke.com Thu Jan 18 21:50:02 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 19 Jan 2001 02:50:02 GMT Subject: Why is "as" not a keyword? References: <3A679717.1328@loop.com> Message-ID: "Jesse W" wrote in message news:3A679717.1328 at loop.com... > Most people know about the functionality of the import statement that > lets you import something under a differnt name. It uses the word "as" > to tell the interpreter. Why is "as" not a keyword? Other flag parts > of commands are keywords, like "in", or "from". Why not "as"? > Currently, it seems to me to be confusing when you type > import foo as bar > in IDLE, and import lights up as a keyword, but "as", which has to be > there and is clearly part of the syntax, does not. If this question has > been answered already, pardon me; I have not seen the answer anywhere. There are two issues here: whether or not 'as' should be a keyword, and whether or not IDLE should highlight it. On the first issue: 'as' was added to the language fairly recently. There could still be legacy code which uses 'as' as a variable name. If 'as' was a keyword, this code would break. The way things currently are, legacy code merely becomes confusing. On the second issue: I think it should, personally. It would be even if IDLE only highlighted 'as' where it is used as a keyword. For example, in 'import as as as', only the middle 'as' should be highlighted. But I don't use IDLE, so it's really a non-issue to me. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tjreedy at udel.edu Mon Jan 29 14:07:49 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 29 Jan 2001 14:07:49 -0500 Subject: "in" for dicts (was: Python 2.1 function attributes) References: Message-ID: <954f49$b3k$1@news.udel.edu> > The only reason to like .xreadlines() is speed -- but, again, that's reason enough. Comparers of Perl and Python constantly notice that Perl is (was?) faster in its equivalent of the new 'for l in f.xreadlines()'. My first thought was 'hope this is enough faster to quiet some of the noise. Python won't be the first system to optimize a common 'benchmark'. From shochet at hotmail.com Tue Jan 23 15:05:24 2001 From: shochet at hotmail.com (shochet at hotmail.com) Date: Tue, 23 Jan 2001 20:05:24 GMT Subject: += return value Message-ID: <94ko5t$e5n$1@nnrp1.deja.com> I am confused with the return values of the augmented assignment opertators. When redefining them in a class, what should they return? Coming from a C++ background, I assumed returning None (aka void) would suffice, but it looks like you need to return self (?) class MyInt: def __init__(self,value): self.value = value def __iadd__(self, other): self.value = self.value + other.value return None f = MyInt(1) g = MyInt(2) f+=g f is now None, not a MyInt with a value of 3 as I expected. So that is fine, returning self in __iadd__ does the trick, but now all the C++ code I have wrappers for that return void do not work. Does this appear broken to anybody else? Why do these operators need any return value? It would seem enough simply to set the object's internal state. Even stranger is: x = 2 x+=1 ...does not return anything but it works!? Sent via Deja.com http://www.deja.com/ From emile at fenx.com Sun Jan 14 12:37:34 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 14 Jan 2001 09:37:34 -0800 Subject: how do i disable buffered output, like Perl's '$|=1'? References: <979490967.23219.0.pluto.d4ee691b@news.demon.nl> Message-ID: <93so5m$biirv$1@ID-11957.news.dfncis.de> I'm not sure what the perl code means, but perhaps what you're looking for is the '-u' parameter to python: eg python -u myscript.py HTH -- Emile van Sebille emile at fenx.com ------------------- "floR" wrote in message news:979490967.23219.0.pluto.d4ee691b at news.demon.nl... > I can't find anywhere how I can disable 'buffered output', or whatever it is > called. > In Perl, you simply say $|=1, but in Python? > Can anyone help me? > > TIA, > Rolf Raven > > From joejava at dragonat.net Fri Jan 5 00:30:05 2001 From: joejava at dragonat.net (Joel Ricker) Date: Fri, 5 Jan 2001 00:30:05 -0500 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> Message-ID: Wow, great answers for a probably frequent question. Thanks everyone! Skip Montanaro wrote in message ... > > Joel> Are the modules and add-ons as good as perl (ie, Database -- I'm > Joel> primarily interested in MySQL, CGI, Graphics). > >I use MySQL all the time from Python. It's pretty straightforward: > > import MySQLdb > conn = MySQLdb.Connection(...) > c = conn.cursor() > c.execute("select id,name from performers where name like "Paul%") > for (pid,name) in c.fetchall(): > print pid, name I'm not sure about what the cursor() method does but I follow the rest. A prepare statement maybe? But I follow the rest of you code and it looks nice and simple. Yea! >There is a CGI module that's also fairly easy to use, though it is >undergoing some close scrutiny by the experts to see if it can be improved >upon. There are also a number of CGI replacements like FastCGI, PyApache, >mod_python and mod_snake (the last three being mod_perl analogs). I thought of the question about security and the need for taint modes but then I realized since there may not be system calls like `del *.*` there might not be a need for it. I'm sure that if Python is in general use as a CGI language then those issues have been cleared up. Are there any thing you have to watch for like running in taint mode in perl? >"Graphics" covers a multitude of things, so I can only guess what you might >be interested in. There are Python bindings for VTK >(http://www.kitware.com/) if you are looking for sci-viz and 3d rendering >sorts of things. I believe there is a gnuplot interface module floating >around. PythonWare (http://www.pythonware.com/) developed and distributes >PIL (the Python Imaging Library). I believe there's something called (I >think) Piddle for doing device-indepndent 2d stuff. Yes it is rather vague. Opps. My main reason is I'm working on a web based game and need to build a map image dynamically. Its a hex based map and I worked hard with the help of geometry expert on another group to make it work right. I would hate to have to build a module like that from scratch, especially since graphic file standards are not exactly my forte. I only have a vague understanding of their inner workings. >Python's infrastructure for module distribution and installation is not as >mature as Perl's CPAN, but there you can search the Vaults of Parnassus >(http://www.vex.net/parnassus/) for third-party modules and there are >packages like distutils that are moving things in the right direction. The >vast majority are easily installed. > >Python is also somewhat more portable that Perl. There are fully >functioning Windows and Mac ports. The lag time between the release of a >new Unix version and corresponding Windows and Mac versions is pretty short >(generally a couple weeks to a month at most). Sounds great. Perl always seems to be very unix-centric which tends to bug me. Only one book I've gotten on Perl went for a cross-platform approach to perl (Perl Black Book). Another question. I just downloaded Activestates build for Python. I went there first since I've got accustomed to their services. Is a good build? As good as Pythonlabs? Better? >Your comment about Perls multitude of contexts really rings true with me. I >use Perl in the guise of Mason these days to maintain the Mojam.com website. >(Mason is great, by the way. I just wish it used Python. ;-) A couple weeks >ago I thought I had all the reference stuff figured out, but then this >morning it all came crashing down on me (again). Ah well, back to the >perlref manpage... No kidding. I just but Object Oriented Perl by Damian Conway and I thought I had the idea and concepts down and by the end of the third chapter it all came crashing down. Things are working that shouldn't and vice versa. I probably need to take a look at the perlref manpage myself but I'm suspecting it may be the new build from Activeperl but I'm getting too fustrated to dig into it. I could post for help but I already know the answer that I'll be given: perldoc perltoot BTW, I noticed when I first looked around this newsgroup there was a mention of a couple of options of using Perl modules with Python. Minotaur I think it was called. Could you use that to wrap Python around Mason? I agree, its a nice package. I really don't have a problem with perls packages but writing my own or doing anything off the beaten path is getting to be too much like work -- making the hard things harder. Joel From edward.collins at unisys.com Thu Jan 25 18:43:33 2001 From: edward.collins at unisys.com (Ed Collins) Date: Thu, 25 Jan 2001 15:43:33 -0800 Subject: How to spawn another program? Message-ID: <94qdjl$5hk$1@mail.pl.unisys.com> Is there a way in python to launch another program, like a batch file or other executable? edward.collins at unisys.com From erwin at andreasen.com Fri Jan 26 17:15:51 2001 From: erwin at andreasen.com (Erwin S. Andreasen) Date: 26 Jan 2001 22:15:51 GMT Subject: "print" strange with Sybase module References: <3A70163A.10D995@schlund.de> <94q0f6$lu5$1@news.cybercity.dk> <3A713DE8.592E8BDE@schlund.de> Message-ID: <94ssun$25ua$1@news.cybercity.dk> On Fri, 26 Jan 2001 10:05:44 +0100, Carsten Gaebler wrote: >If I give Python the "-u" option the following happens: > >[cg at cg test]$ ./sqltest.py | tee /tmp/test.txt >Traceback (most recent call last): > File "./sqltest.py", line 12, in ? > print row >IOError: [Errno 32] Broken pipe > > >Broken pipe?? BTW it's the same with "|less", "|more", "|gzip" etc. I'm >confused. Indeed -- "broken pipe" means that the other end of the connection has been closed (i.e. the end of the pipe that is with tee) at the time the writer sends some data down the pipe. And that's just weird. Does it happen if you run some other shell? Or as perhaps another user? -- ======================================================================= Herlev, Denmark Software Designer <*> LASAT^WEicon Networks ======================================================================= From amk at mira.erols.com Thu Jan 11 21:40:17 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 12 Jan 2001 02:40:17 GMT Subject: BUG Python 2.0 FreeBSD compile problem References: Message-ID: On Thu, 11 Jan 2001 14:31:26 -0600 (CST), Chris Watson wrote: >Python is IN the ports tree. And someone (the maintainer of that port) had >already gone to the trouble to patch it and insure it compiles well and >added the other nice features of "ports" in FreeBSD. So there was no need And this points up an annoying thing about FreeBSD; patches are made to get Python to compile on the platform, but those changes aren't contributed *back* to the original Python source tree. How can one find out what changes were made to a package in the ports tree? --amk From quinn at bolivar.ugcs.caltech.edu Mon Jan 29 14:50:41 2001 From: quinn at bolivar.ugcs.caltech.edu (Quinn Dunkan) Date: 29 Jan 2001 19:50:41 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> Message-ID: On Mon, 29 Jan 2001 08:01:55 GMT, C.Laurence Gonsalves wrote: >On Sun, 28 Jan 2001 22:04:38 -0600, Grant Griffin > wrote: >>Hi Gang, >> >>I'm sure this has been asked a thousand times, but I haven't seen it >>asked lately (or ever ). >> >>Why does Python use square braces ([]) instead of curly braces ({}) >>when accessing dictionaries? While sequences and mappings are different, access is the same. Think of it this way: import operator a = [0, 1, 2] d = {1: 'a', 2: 'b'} t = (9, 8, 7) for obj in a, d, t: print operator.__getitem__(obj, 1) >Actually, the thing that's always bugged me is that Python makes a >distinction between subscripting (__getattr__) and function calls >(__call__). Mathematically speaking, a dictionary is really just a >function that maps from 'keys' to 'values'. Even haskellers usually don't implement finite maps and arrays as functions (though they usually acknowledge that would be the elegant solution). So even in a language where functions are the major important element, efficiency dictates a data-oriented view. And python is pretty data-oriented anyway, so a functional representation would be out of character. And mutation is important in python, while a functional representation gives no opportunity for that. >It always seems silly to me that given: > > m = {'one': 1, 'two':2} > l = ['two', 'one'] > >one can't write: > > map(m, l) What if 'm' implemented both __call__ and __getitem__? If you really like the functional thing: import UserDict class FDict(UserDict.UserDict): def __call__(self, key): return self[key] def __add__(self, other): # we could define just a method, but functions # don't have methods but '+' is a method too :) # incidentally, I think this indicates a bug in UserDict, which should # use isinstance to avoid breaking when inherited d = self.data.copy() d.update(other.copy()) return d Of course, to be consistent here, the only way to change an FDict is to write: d = old_dict + {'new': 'changes'} ... which forces one to introduce the bizarre concept of adding a function to a literal, and is also not the most efficient thing in the world, considering that the usual use of python dicts is incremental mutation, and python naturally has no optimizations to detect when a value is unused afterwards and switch to mutation in that case. >I'm not sure why you need to be reminded whether something is a sequence >or a dictionary. Another way to think of it is that 'sequence' is an iteration pattern. 'dictionary' is a data structure. For example, eiffel has seperate iterator classes that capture common iteration patterns, which can be applied by any class that implements their routines (or 'effects' their 'deferreds', if you like). From csrabak at uol.com.br Sat Jan 27 11:07:48 2001 From: csrabak at uol.com.br (Cesar Rabak) Date: Sat, 27 Jan 2001 14:07:48 -0200 Subject: Problem Install UPDATE References: Message-ID: <3A72F254.822246C7@uol.com.br> Ben Ocean wrote: > > Hi; > Okay, I see how you traced back the error. I took off the angle brackets in > > # include linux/errno.h > > and got this error message: > > /usr/include/bits/errno.h:25: `#include' expects "FILENAME" or Humm it seems that this FILENAME (and perhaps the whole errno.h at this location) is built by a script which may be failing in the generation of this name. > > I tried > > # include linux/errno.h > > and > > # include linux/errno.h FILENAME > > but maybe it would like a real filename . Got the same error message. > Where to now? You must to figure out one of: 1) Why the scripts/Makefile/etc. did generate the correct line (and the name in it); 2) Discover what is the include file supposed to be there and write the appropriate filename (and with the appropriate quoting ["" or <>]). HTH Cesar > TIA, > BenO From dsh8290 at rit.edu Mon Jan 22 19:17:58 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 22 Jan 2001 19:17:58 -0500 Subject: Jython on the i400 (was: Python and Industry, IBM I'm afraid) In-Reply-To: <31575A892FF6D1118F5800600846864D5B1723@intrepid>; from SBrunning@trisystems.co.uk on Thu, Jan 18, 2001 at 08:57:15AM +0000 References: <31575A892FF6D1118F5800600846864D5B1723@intrepid> Message-ID: <20010122191758.A17166@harmony.cs.rit.edu> On Thu, Jan 18, 2001 at 08:57:15AM +0000, Simon Brunning wrote: | > From: Pete [SMTP:p at mjs400.co.uk] | > | > Don't forget to call it the i400, or iSeries 400, these things matter. | > Especially as this machine seems misunderstood by those outside of the | > clique. | [snip] | If you just say i400, people will think that you are talking about something | running one of those nasty *nix OSs. Or worse, one of those *really* nasty | Micros~1 OSs. Actually, i400 sounds to me more like a new kind of iMac . . . :-) -D From jdnier at execpc.com Fri Jan 26 16:12:06 2001 From: jdnier at execpc.com (David Niergarth) Date: Fri, 26 Jan 2001 15:12:06 -0600 Subject: Use of os.popen3() under WinNT4 Message-ID: <3a71e809$0$7160$272ea4a1@news.execpc.com> I would like to be able to run a command in a subprocess under WinNT4 and read/write (as appropriate) to stdout, stdin, and stderr. I'm trying to understand how to use os.popen3(). Perhaps I'm misunderstanding it's purpose or it's behavior is different under NT? I'm using Python 2.0 so the old Windows popen problem shouldn't be an issue. In my current case, I want to run Ghostscript (gswin32c.exe) and need to be able to write to the process and, hopefully, capture its stdout. In the following example: >>> import os >>> command = 'gswin32c -help' >>> child_stdout, child_stdin, child_stderr = os.popen3(command, mode='b') child_stdout ends up as a file descriptor opened in write mode, while child_stdin is a file descriptor opened in read mode; in and out seems backwards here. In the above command, Ghostscript prints a help message and quits. To get at the help message, you need to read from stdin. >>> child_stdin.read() "6.01 (2000-03-17)\012Copyright (C) 2000 Aladdin... [etc.]" >>> child_stderr.read() '' So is it just an issue of perspective? (I found this confusing.) More importantly, if you run a command that doesn't immediately terminate, trying to read from child_stdin or child_stderr before doing a child_stdout.close() causes a hang. (The only way I've found to recover is to kill the parent Python process.) Is there a way to tell if the process has terminated before trying a .read() or, better yet, is there a way to signal or force the process to finish? Any elaborations or pointers to code examples would be appreciated. I'll sumarize if I get many responses. Thanks, --David Niergarth jdnier at execpc.com From hwanjoyu at uiuc.edu Mon Jan 29 18:40:54 2001 From: hwanjoyu at uiuc.edu (Hwanjo Yu) Date: Mon, 29 Jan 2001 17:40:54 -0600 Subject: Q: function parameter Message-ID: Hi, It seems that the python's function parameters are passed call-by-value as a default. How to make it call-by-reference, so it allows the parameters to be changed after calling a function ? Thanks in advance. From aleaxit at yahoo.com Thu Jan 18 11:42:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 17:42:12 +0100 Subject: python compiled to native in less than a year? References: <8pF86.6015$J%.595435@news.flash.net> <0luc6toovfccbqspkvc0dkqkuc5dck7u51@4ax.com> <946coc130tl@news2.newsguy.com> Message-ID: <9476fp015jj@news2.newsguy.com> "scott hathaway" wrote in message news:qcE96.8755$J%.858944 at news.flash.net... > All the .NET languages will be translated to IL and then from IL to native > code...including python and perl. I am at VSLive 2001 this week (no flames, > please) and ActiveState gave a demo of Visual Perl, showing how a class > written in it (living in a .dll - now called an assembly) could be called > from VB. This will be the same for Python. Sure. But, as I said, that's not necessarily related to optimization, if what gets 'compiled' is actually a sequence of subroutine calls to the interpreter runtime. > This will be huge for Python - whether you like MS or not. I think this is > awesome. I will be able to use Python to do "real" development in Windows. Funny, I do lots of "real" Python development in Windows today, already. > Programmers like me have a very difficult time learning how to do a gui with > wxWindows or Tkinter. It is much easier to paint the controls on a form. > Now, I will be able to do that and use Python as the language! I basically do that today (with Dynamic HTML, Active/X controls, etc), but, yes, I guess .NET webforms can be seen as an incremental improvement to that. In general, .NET promises a lot of incremental improvements that, in the aggregate, can indeed make things a lot better -- putting all languages on a playing-field that's much more level than of yore, for example, so that languages can be chosen per-component based on the abilities of each language rather than on peripheral issues related to how well they can interact with the system. I'm glad that Python is a part of that. But it's not so _drastically_ different from what I already get today with COM and Automation -- just a little bit smoother. > This is wonderful for anyone programming on Windows now, and will be even > more wonderful as soon as someone converts IL to native on Linux. In the meantime, I wouldn't hold my breat, but, rather, go for XPCOM integration... remember that even if/when IL can be installed on Linux, that doesn't mean all of the runtime parts will be there -- the GUI ones, in particular. > I think that this will be much more influential to Python than Jython. I > think it may be the new "preferred" way to use Python for many Windows > developers. If .NET takes off in proportion to what Microsoft's investing on it, then, yes, it's quite likely that it will surpass COM as the main way to integrate with Windows in the next 2-3 years; and, so far, the MS .NET teams have already surprised me a few times with the speed at which they've delivered reasonably-solid betas -- if this keeps up, then the technical SW portions of the equation, at least, will be in place in time. .NET has more vulnerabilities that are not really in MS techies' hands -- how fast is broadband net access spreading, will people really upgrade to Office 10 on a subscription model rather than keep using their good old fully-paid-for copies of existing Office releases [transitioning from a sales-based business model to one based on subscription is troublesome -- we've already completed *our* own transition, true pioneers that we are:-), and the post-transition place is a great one to be, but the transition itself WAS hard], etc. Technically, .NET deserves success -- so far. But there are many issues with its pathway to success that are still question-marks. Still, it's _great_ to know that Python will be in on the game, whether .NET floats or sinks!-) Just don't expect to get some magical performance boost by 'compiled to native' mantras...!-) Alex From rzantow at my-deja.com Mon Jan 29 08:56:04 2001 From: rzantow at my-deja.com (rzantow at my-deja.com) Date: Mon, 29 Jan 2001 13:56:04 GMT Subject: importing glut References: Message-ID: <953spi$nt4$1@nnrp1.deja.com> In article , =?iso-8859-1?q?ABDENOUR=20HADID?= wrote: > hello > I am just beginner in programing with python. I > installed python and pyopengl on win98platform. > when I tried to import glut.py i receive the error > message :"importing the GLUT Library failed. the > GLUT32.DLL file should be on your path...." > > I see the file Glut.py in the directory > c://python20//OpenGl// > > I tried to import :OpenGl.Glut but same problem. > i added the c://python20//OpenGl// to Path..always > same problem... > > so, can you help me.. > > thanks > Check out reality.sgi.com/mjk/glut3/glut3.html . Or Google search for other links. -- Pythons, unlike some other snakes, do have hindlimbs, but they never develop beyond vestigial stumps. The arrest of limb development is due to a failure of the sonic hedgehog signalling system ... Sent via Deja.com http://www.deja.com/ From tim.one at home.com Wed Jan 24 16:02:34 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 24 Jan 2001 16:02:34 -0500 Subject: Random and whrandom In-Reply-To: <94mjv402318@news2.newsguy.com> Message-ID: [posted & mailed] [Alex Martelli, sorts out the random/whrandom mess -- thanks!] > ... > The situation might be clearer if Python had MANY random > number generation modules in its standard library -- one > as the abstract/high-level thingy, and the other N-1 as > specific implementations for specific needs. The "abstract random number generator interface" stuff has been removed from the 2.1a1 docs. This is a case where an eager contributor launched into a Grand Generalization that Guido accepted, then vanished from the face of the earth immediately thereafter, and nobody else cared enough to take over. Python's core randomization facilities are too meager to justify all this conceptual hair, and newbies have been stumbling over the overly-complex docs ever since ("Define the universe. Give 3 examples." ). [kevin parks] >> It would be great if the random whrandom poop could be cleaned up in >> future versions of python. One clear module. [Alex] > ONE module, I think, would not be enough -- the distinction > between abstract and concrete IS important enough, after all, > to be worth a little bit of effort. It's been counter-productive so far, so got dropped. "The best" pure-Python suite of state-of-the-art RNGs is Ivan Frohne's rv.py, and if someone wants to revive an ARNGI crusade they would do well to mimic his excellent design. Alas, while it's still possible to find rv's *docs* on the web, I can't find the actual code anymore (and the Parnassus link is dead). > ... > Ideally, too, whrandom should be renamed to _whrandom, the > leading underline indicating it's meant for internal use > and not of direct user interest; We can't, at least not for a few years: too many programs import it under the old name. whrandom's *docs* will get moved into the Obsolete Module section (where you can also find "rand"). > before this 'deprecation' is done, though, I dearly hope > checkpoint/restart needs will be considered in the abstract > RNG interface. The ARNGI is gone. Deprecation of whrandom.py is independent of adding C/R to random.py's bag of tricks. I agree this would be a good trick to add. sourceforge-is-open-for-patches-ly y'rs - tim From tim.one at home.com Sun Jan 28 16:45:27 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 28 Jan 2001 16:45:27 -0500 Subject: SIGs In-Reply-To: <951p9a0mn@news2.newsguy.com> Message-ID: [Alex Martelli] > Which reminds me -- is it just me, or does the page at > http://www.python.org/sigs/ REALLY state that EVERY > Python SIG has expired except catalog-sig (with 5 more > months' life to go) and the two perennials meta-sig and > pythonmac-sig? Yup, that's what it says. CNRI still hosts python.org but nobody at CNRI ever updates it. The only person outside of CNRI with sufficient access to change anything there is Guido, and he just doesn't have time to keep the site up to date by himself. This will remain the case until some agreement is reached with CNRI about moving python.org to a different host. sad-but-true-ly y'rs - tim From yoonseo at my-deja.com Mon Jan 22 10:58:05 2001 From: yoonseo at my-deja.com (yoonseo at my-deja.com) Date: Mon, 22 Jan 2001 15:58:05 GMT Subject: [Q] telnetlib References: Message-ID: <94hla8$mmk$1@nnrp1.deja.com> Dear Doug This is the log of my telnet manual telnet session. I intentionally hided host name and user name. Hope you can find what I am doing wrong. sy ======================================================== LOCAL_PROMPT$ telnet REMOTE_HOST_NAME Trying 129.116.218.132... Connected to REMOTE_HOST_NAME Escape character is '^]'. Cray UNICOS (aurora) (ttyp028) The University of Texas at Austin Advanced Computing Center for Engineering and Science *** UNAUTHORIZED ACCESS PROHIBITED *** ACCES staff may monitor and record user activity to detect unauthorized access. By using this system you are consenting to such observation. ---- Remote access via telnet, rlogin and ftp, for NPACI users or users coming in from outside the University of Texas, is no longer supported on this system; use secure shell and secure copy instead. Get more information on NPACI security activities and ssh at http://www.npaci.edu/Security ---- login: USER_NAME Password: Active label set to : level0,none Last successful login was : Mon Jan 22 09:46:36 from LOCAL_HOST_NAME UNICOS 10.0.0.7 CRAY SV1-1A/16-16384 sn3002 (REMOTE_HOST_NAME) --> SV1 information at http://www.hpc.utexas.edu. --> SV1 manuals at http://dynaweb.hpc.utexas.edu:8080/ Please send problem reports to: remark at hpc.utexas.edu (UT Austin Users mail here) http://www.npaci.edu/Consult (NPACI Users use this web page) ----------------------------------------------------------------------------- ACCT SYS Allocated Used AVAILABLE Period Updated Status ------- --- --------- -------- --------- --------- --------- ------ A-byaa T3E 20000 3806.57 16193.43 1Q01-4Q01 Sun_23:55 active A-byaa SV1 62415 3325.91 59089.09 4Q00-4Q01 Sun_23:55 active ----------------------------------------------------------------------------- TERM = (vt100) REMOTE_PROMPT% ls Bin Lib OUTPUT README dead.letter libtime.a temp.txt REMOTE_PROMPT% ======================================================== In article , Doug Stanfield wrote: > Just a guess, but you may not be following exactly the sequence of strings > are exchanged when you telnet to this device. Try to manually log in and > copy the session to a followup. > > -Doug- > > > -----Original Message----- > > From: yoonseo at my-deja.com [mailto:yoonseo at my-deja.com] > > Sent: Friday, January 19, 2001 10:01 AM > > To: python-list at python.org > > Subject: [Q] telnetlib > > > > > > Hi, > > > > I am trying to run commands on a remote computer using Python. > > I think that using 'telnetlib' is the way to go, but I have trouble. > > The following is the script that I wrote but it stops before > > it reaches prompt, that is after 'TERM = (vt100) '. > > Can somebody tell me what is wrong? > > > > Thanks in advance > > > > sy > > > > > > -------------------------------------- > > import telnetlib > > > > HOST = 'host_name' > > user = 'user_name' > > pwd = 'my_password' > > > > tn = telnetlib.Telnet(HOST) > > > > print tn.read_until('login: ') > > tn.write(user+'\n') > > > > print tn.read_until('Password:') > > tn.write(pwd+'\n') > > > > print tn.read_until('TERM = (vt100) ') > > tn.write('\n') > > > > print tn.read_until('% ') > > tn.write('ls\n') > > > > print tn.read_until('% ') > > tn.write('exit\n') > > > > print tn.read_all() > > -------------------------------------- > > > > > > Sent via Deja.com > > http://www.deja.com/ > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > Sent via Deja.com http://www.deja.com/ From erno-news at erno.iki.fi Wed Jan 17 12:33:36 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 17 Jan 2001 19:33:36 +0200 Subject: How to close all files between fork and exec? References: Message-ID: In article , Harald Kirsch writes: | On some systems there is a constant like OPEN_MAX but I read that on | recent Solaris versions there is no real limit to it. | How do I get hold of the highest numbered open file descriptor, in | particular in python? a reasonable heuristic might be to try closing from 0 ... n and break the loop when you've hit m EBADF errors in a row (m=500?) some systems have nonportable ways of finding out the open fd numbers, like /proc//fd/ in linux. -- erno From phd at phd.pp.ru Wed Jan 17 03:38:09 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 17 Jan 2001 11:38:09 +0300 (MSK) Subject: Python2C In-Reply-To: <87hf2zpchy.fsf@nirvana.sysfrog.org> Message-ID: On 16 Jan 2001, Guenther Starnberger wrote: > the python2c homepage doesn't seem to work and the cvs version looks > rather old. The home page is http://www.mudlib.org/~rassilon/p2c/ but it still holds the same rather old version, and I think there is no development :( Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From MarkH at ActiveState.com Thu Jan 18 13:09:47 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 18 Jan 2001 18:09:47 GMT Subject: Python training on east coast? References: Message-ID: <947bh2$hug$1@nnrp1.deja.com> In article , Robert L Hicks wrote: > Are there any Python training courses on the east coast? I believe some can be found in both Sydney and Melbourne. Unless of course you meant the east coast of some other country? ;-) Sent via Deja.com http://www.deja.com/ From NoSpam at NoSpam.com Wed Jan 3 00:16:08 2001 From: NoSpam at NoSpam.com (Tom) Date: Wed, 03 Jan 2001 05:16:08 GMT Subject: Electronic edition of 'The Standard Python Library' References: <92tkm007t8@news1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:92tkm007t8 at news1.newsguy.com... > "W.Izatt" wrote in message > news:ZQf46.83865$df5.2962770 at news1.crdva1.bc.home.com... > > I had a nightmare getting my copy of this book to "work". My office is > > behind a firewall, so of course the registration process would not work. > > Same here. > > > Repeated calls to Fatbrain (more than 10) did not produce results. Emails > > were replied to by bots. > > Identical experience here. And that's why I didn't bother trying to contact Fatbrain when mine stopped working. I don't buy books so I can waste time with stuff like that. Tom. > > > Don't buy from Fatbrain. I don't know about the others. > > I will heartily second this advice -- which *IS* a pity, because 's > book itself is SO darned useful. But Fatbrain's "support" for the ebooks > they sell appears to be repeatably abysmal. > > > Alex > > > From jcollin at exis.net Tue Jan 23 13:34:20 2001 From: jcollin at exis.net (Jay Collins) Date: Tue, 23 Jan 2001 13:34:20 -0500 Subject: news - nntp server In-Reply-To: <3a6daab8@news.xtml.co.uk> References: <3a6daab8@news.xtml.co.uk> Message-ID: On Tue, 23 Jan 2001, it was written: >I'm trying to set up an NNTP/newsgroup server on an NT4 machine. > >What is the easiest way to do this please. Can Python help me?! Why are you posting here? From grey at despair.rpglink.com Thu Jan 18 16:49:32 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 18 Jan 2001 21:49:32 -0000 Subject: I must be missing something obvious: os.path.isexecutable? References: Message-ID: On Thu, 18 Jan 2001 21:22:06 -0000, Steve Lamb wrote: > I cannot, for the life of me, find a comparable call in Python to replace >the -x call in Perl. OK, after further digging on deja I found a thread between Fredrik Lundh and Lenny Self regarding using the os.stat() call with the stat macros. Is there an easier way? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From amk at mira.erols.com Mon Jan 1 12:05:39 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 1 Jan 2001 17:05:39 GMT Subject: Python bookstore revised Message-ID: The PSA bookstore has been revised and given a new home at www.amk.ca/bookstore/. It's been updated to list the currently available Python books, books in languages other than English, and links to more reviews. Please take a look. Also, suggestions for additional titles, book descriptions, or brief capsule reviews would be very welcome. --amk From waltonl at franklin.edu Mon Jan 29 01:37:40 2001 From: waltonl at franklin.edu (Lynn Walton) Date: Mon, 29 Jan 2001 00:37:40 -0600 Subject: Making a hyperlink in a text widget Message-ID: <3A750FB4.1AC7A807@franklin.edu> I read in the tk intro on text widgets that you can make hyperlinks in text widgets by using the text.tag_bind method. I'm wondering if anyone could share some code examples with me that would do the following on a windows platform (98 and/or 2000) : - display a URL (a file:/// so it opens a file on the local drive) in the text widget that when clicked on opens that file in the default browser on that machine, or if that's too generic, opens Netscape 4.x if installed as default browser. TIA, Lynn From steve.menard at polyester.com Fri Jan 12 16:33:31 2001 From: steve.menard at polyester.com (Steve Menard) Date: Fri, 12 Jan 2001 16:33:31 -0500 Subject: ZODB and Python 2.0 Message-ID: <93nta2$p59$1@newsmaster.axxent.ca> My problem is simple : I need ZODB. But I also need Python 2.0's Unicode handling so .... The binaries for ZOPE require Python 1.5.2 .... And compiling from source is a bit of a problem for me since I am on Windows and the setup scripts simply do not work for me. So finally, my question is this : Why isn;t ZODB available as a separate package using the distutils? Failing an answer to that question, has anyone build ZOPE for python 2.0 and could send me the ZODB package and dependencies? Thanks in advance .... From aleaxit at yahoo.com Sat Jan 20 07:42:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 20 Jan 2001 13:42:58 +0100 Subject: Tabbing/Spaces References: <20010120011201.72310F44E@mail.python.org> Message-ID: <94c14d0mdi@news2.newsguy.com> "Fredrik Lundh" wrote in message news:n3aa6.7716$AH6.1213290 at newsc.telia.net... [snip] > > But surely there's a simple way to please both -- aren't > > there de-tabbing filters I can use to substitute spaces for tabs > > (or vice-versa)? What _I_ find really irritating is that my code > > usually winds up being a mixture of the two. > > I'm pretty sure your editor can do it for you (I'll leave > it to the vim gurus to explain how). The :retab command is what you use for this task in vim. If you've set expandtabs to 1, :%retab will change all tabs to the appropriate number of spaces (you can also give it the tabstop size you want as an argument); if you've set it to 0, :%retab! will insert tabs wherever possible (again, you can pass tabstop size as argument). Alex From mwh21 at cam.ac.uk Sun Jan 21 11:44:41 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Jan 2001 16:44:41 +0000 Subject: Unicode string output References: Message-ID: "Alexander Kostyrkin" writes: > Surprisingly printing a unicode string that contains a Japanese kanji > character raises an exception > For example > > print u"\u55f4" > UnicodeError: ASCII encoding error: ordinal not in range(128) > Try print u"\u55f4".encode('kanji') though I don't know what should go in the place of 'kanji' - in fact, I don't know if Python 2.0 shipped with any japanese codecs at all. Not much help, I know... Cheers, M. -- languages shape the way we think, or don't. -- Erik Naggum, comp.lang.lisp From fredrik at effbot.org Tue Jan 2 17:00:47 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 02 Jan 2001 22:00:47 GMT Subject: Electronic edition of 'The Standard Python Library' References: <4f746.2529$AH6.401534@newsc.telia.net> <3A517247.1B79FFC2@ieeeSPAMnot.org> Message-ID: John D. Gorman wrote: > I also had a registration problem with the Fatbrain ematter > version of /F's book. > /F has also turned off text copying (i.e., cut and paste to the > clipboard, perhaps for obvious reasons) Just a couple of notes: - Fatbrain has stopped using their custom distribution format (well, you cannot even buy it from them right now, but that will change). Fatbrain and MightyWords are now using Adobe's own "secure PDF" format, which is supposed to work much better. (It should also work on non-Windows platforms, but I haven't tested that myself) - And yes, the final preparation is made by the publisher; they want their material to be printable, but hard to copy. Cannot do much about that at this time (if I could chose, I'd bundle a ZIP file with the PDF). - Finally, the eff-bot library guide will be available in a more traditional book form in a not too distant future, under a slightly different title. (In fact, if you do a little digging, you can already buy it from amazon and fatbrain, and have it shipped when it's released. I wouldn't trust the given release date, though. And I don't know any of the authors... ;-) stupid-ly yrs /F From cg at schlund.de Tue Jan 9 04:36:04 2001 From: cg at schlund.de (Carsten Gaebler) Date: Tue, 09 Jan 2001 10:36:04 +0100 Subject: Determine whether STDIN is gzipped Message-ID: <3A5ADB84.194BAD4E@schlund.de> Hi there! I'm writing a program that reads its input data from STDIN. Now I'd like it to be able to determine whether the input data is gzipped or not and do the right thing automatically. This is my approach: import gzip, sys f = gzip.GzipFile("", "rb", fileobj=sys.stdin) try: f.readline() # raises exception if not gzipped except: f = sys.stdin while 1: line = f.readline() if not line: break # do something with line The problem is that if STDIN is not gzipped I am missing the first few bytes of the first line in the while loop, if STDIN is gzipped I am even missing the whole first line, all because of the readline() in the try block. Unfortunately f.seek(0) doesn't work for STDIN. Any hints? Regards Carsten. From jafo-pythonlist at tummy.com Sun Jan 21 02:28:56 2001 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Sun, 21 Jan 2001 00:28:56 -0700 Subject: changing unix password via www python script In-Reply-To: ; from andymac@bullseye.apana.org.au on Sat, Jan 13, 2001 at 06:04:36PM +1100 References: <93no1v$svv$1@sunsite.icm.edu.pl> Message-ID: <20010121002856.F20336@tummy.com> On Sat, Jan 13, 2001 at 06:04:36PM +1100, Andrew MacIntyre wrote: >On Fri, 12 Jan 2001, Vesemir wrote: >> How to change unix account password by python script? >> I want to write www script, controled by form. > >Its clumsy and trouble prone, but what I did was use one of the expect >modules (PyExpect?- can't remember for sure), and telnetted to localhost It depends on what platform, but on Linux you can simply feed the data to "passwd --stdin username". At one point (before the --stdin patch was available) I hacked the source code to "passwd" so that I could do something like: "echo user:oldpass:newpass | pwweb" and it would do all the appropriate checking and return a success or failure string. Sean -- I keep just enough vi knowledge in my head so that I can edit a Makefile and build Emacs. -- Tony Foiani, 1999 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From akuchlin at mems-exchange.org Thu Jan 11 11:23:39 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 11 Jan 2001 11:23:39 -0500 Subject: Module for reading tarfiles? References: <200101111322.IAA00533@207-172-57-151.s151.tnt2.ann.va.dialup.rcn.com> Message-ID: <3du2763vn8.fsf@kronos.cnri.reston.va.us> Jeff Bauer writes: > Perhaps some version of the code could make it into the > standard distribution. It looks like there's been quite a bit of wheel-reinventing; /F, DC, Hintze, and http://phobos.fs.tum.de/PyTar/ (a wrapper around a library for reading tar files). This is for the catalog, which would need to be able to unpack both tar archives and .zip files; zipfile.py is already there, but tarfile.py should be added, too. (It's too late for 2.1, though.) I'll look at all the different versions; thanks everyone! --amk From Alain.Desilets at nrc.ca Thu Jan 18 18:17:56 2001 From: Alain.Desilets at nrc.ca (Alain Desilets) Date: Thu, 18 Jan 2001 18:17:56 -0500 Subject: Testing for is-kind-of relationships (at runtime) Message-ID: <3A6779A4.E9315EB1@nrc.ca> Is there a way in Python to test for "is-kind-of" relationships? For example, suppose x is an instance of A which is a subclass of B which is a subclass of C. I want to be able to ascertain at run time that x is a descendant of class C. Thanks. -- Alain D?silets Research Officer National Research Council Canada Institute for Information Technology Agent de recherche Conseil national de recherche Canada Institut de technologies de l'information email/courriel: alain.desilets at iit.nrc.ca --- Arguing with an engineer is like mud wrestling with a pig. You soon realize you both enjoy it. --- From teep at inet.co.th Thu Jan 18 21:35:22 2001 From: teep at inet.co.th (Prateep Siamwalla) Date: Fri, 19 Jan 2001 09:35:22 +0700 Subject: generating simple graphs and chart images in python References: Message-ID: <94890m$9th$1@news.inet.co.th> could this be what you are looking for? http://athani.pair.com/msteed/software/gdchart/ -teep Ian L wrote in message news:aVK96.3220$tD2.216083 at newsread1.prod.itd.earthlink.net... > Hey, > > Could anyone point me in the right direction as to how i can generate some > simple graphs dynamically in python? I want to make something like a bar > graph, or line graph? > > From sholden at holdenweb.com Fri Jan 12 17:48:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 12 Jan 2001 17:48:22 -0500 Subject: cgi module question References: <3a5f7b52.253219421@localhost> Message-ID: "Victor Muslin" wrote in message news:3a5f7b52.253219421 at localhost... > Is there a way to parse a query string of this form: > > foo=bar&x=y=z&xyz > > Is this format against application/x-www-form-urlencoded guidelines? > Can somebody point me to a definitive document? > > What I would ideally like is: > > { 'foo' : 'bar', 'x' : 'y=z', 'xyz' : None } > As in, for example, the cgi module docs: parse_qs (qs[, keep_blank_values, strict_parsing]) Parse a query string given as a string argument (data of type application/x-www-form-urlencoded). Data are returned as a dictionary. The dictionary keys are the unique query variable names and the values are lists of values for each name. The optional argument keep_blank_values is a flag indicating whether blank values in URL encoded queries should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. The optional argument strict_parsing is a flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. It even works, see: >>> d = cgi.parse_qs("foo=bar&x=y=z&xyz") >>> d {'foo': ['bar'], 'x': ['y=z']} I think your problem is the missing "=" on xyz: see what happens if we keep blank values and put "=" at the end of the query string. >>> d = cgi.parse_qs("foo=bar&x=y=z&xyz=", 1) >>> d {'foo': ['bar'], 'xyz': [''], 'x': ['y=z']} With strict parsing requested, an error is raised when the "=" is missing, which presumably means this is not confirmant witht he required format: >>> d = cgi.parse_qs("foo=bar&x=y=z&xyz", 1, 1) Traceback (innermost last): File "", line 1, in ? File "d:\python20\lib\cgi.py", line 169, in parse_qs for name, value in parse_qsl(qs, keep_blank_values, strict_parsing): File "d:\python20\lib\cgi.py", line 201, in parse_qsl raise ValueError, "bad query field: %s" % `name_value` ValueError: bad query field: 'xyz' However, I seem to remember PEP 222 (http://python.sourceforge.net/peps/pep-0222.html) proposed a change to this. However, the PEP isn't likely to make it into 2.1 - everyone who might have commented is too busy putting web applications together, or too lethargic to comment on it: cgi.py: Currently, query data with no `=' are ignored. Even if keep_blank_values is set, queries like `...?value=&...' are returned with blank values but queries like `...?value&...' are completely lost. It would be great if such data were made available through the FieldStorage interface, either as entries with None as values, or in a separate list. Hope this helps. it's-all-there-if-you-know-where-to-look-for-it-ly y'rs - steve From JoeSmith at bogusaddress.com Thu Jan 4 20:47:52 2001 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Fri, 05 Jan 2001 01:47:52 GMT Subject: Unexpected result for list operator "+=" References: <3A542778.E1BC06E3@bogusaddress.com> Message-ID: <3A552867.32A48A23@bogusaddress.com> I knew about mutable v. immutable. I just got surprised at the side effect. I guess I have not used lists that much; otherwise, I would have probably used "L = L1[:]" before. While it makes sense after realizing what is going on, I just was surprised. Maybe I was thinking that it might copy on a change operation; this way "L = L1; L += L2" really does the same thing as "L = L1 + L2". (Including side effects.) Greg Jorgensen wrote: > Thanks to Fredrik, Alex, Tim, and Thomas for pointing out that Python only > binds names to objects under the hood. I was guessing (maybe wrongly) that > the original poster might not know about mutable and immutable objects, > bindings, etc. That's why I wrote "Assignment of immutable objects > essentially makes a copy of the object." I lifted the explanation almost > verbatim from Beazley's "Python Essential Reference," page 19. Beazley wrote > "... effectively creates a copy..." but it amounts to the same thing--a > simplification. The real distinction--that assignment operations on > immutable objects create new objects (or bind a reference to a different > existing object)--is important but perhaps more information than necessary > to answer the question. > > I appreciate the clarifications and detailed implementation info. From garabik-news at spam.melkor.dnp.fmph.uniba.sk Wed Jan 31 05:04:45 2001 From: garabik-news at spam.melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: 31 Jan 2001 10:04:45 GMT Subject: fork, exec and wait on WINDOWS? References: <3A774C91.40835F30@lbl.gov> Message-ID: <980935407.666821@cdwork.cvt.stuba.sk> Nigel W. Moriarty wrote: : I have an app that needs to run on UNIX and Windows. I have the UNIX fork() and exec() setup but how doe one do a similar thing in Windows? there is no fork for standard windows version of python, you can however compile (unix version of) python under cygwin and then you get fork. -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ melkor.dnp.fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From emile at fenx.com Tue Jan 23 01:50:12 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 22 Jan 2001 22:50:12 -0800 Subject: Can I decompile PYC files? References: <94j8j5$50e$1@nnrp1.deja.com> Message-ID: <94j9kp$do29r$1@ID-11957.news.dfncis.de> What OS are you working on? Under dos, there are some undelete type utilities that may help. I'm not familiar with the options under unix. There is a decompyle.py I've heard mention of, but IIRC, it doesn't really get your code back. Sorry I don't have any good answers. -- Emile van Sebille emile at fenx.com ------------------- wrote in message news:94j8j5$50e$1 at nnrp1.deja.com... > > > A process just deleted my .py file. I still have the .pyc file. > Can I recover anything? I'm desparate. It doesn't have to be perfect. > Thanks, > Noah > > > > Sent via Deja.com > http://www.deja.com/ From thomas at xs4all.net Thu Jan 4 11:47:58 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 4 Jan 2001 17:47:58 +0100 Subject: Unexpected result for list operator "+=" In-Reply-To: ; from erno-news@erno.iki.fi on Thu, Jan 04, 2001 at 11:05:52AM +0200 References: <3A542778.E1BC06E3@bogusaddress.com> Message-ID: <20010104174758.H2467@xs4all.nl> On Thu, Jan 04, 2001 at 11:05:52AM +0200, Erno Kuusela wrote: > In article , "Greg > Jorgensen" writes: A > > | Assignment of immutable objects (numbers, strings, tuples) > | essentially makes a copy of the object. Assignment of mutable > | objects (lists, dictionaries) creates a new reference to the > | original object. > actually (non-augmented) assignment is always just about references, even > with immutable objects. actually *augmented* assignment is, too. *everything* is about references :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From fredrik at effbot.org Wed Jan 10 04:44:31 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 10 Jan 2001 09:44:31 GMT Subject: Problems with zipfile module... References: <93ha6j$ca6$1@reader1.imaginet.fr> Message-ID: <3aW66.5508$AH6.782619@newsc.telia.net> Christophe Prevost wrote: > I've python 2.0, zlib etc... and when i try to use zipfile i've some > problems > > for fch in lch: > if fch == sys.argv[0]: continue > print fch > dt = time.mktime(time.gmtime(os.path.getmtime(fch))) > if dt < veryold: > cpt += 1 > if cpt == 1: > backup = zipfile.ZipFile(zip, "w", "ZIP_DEFLATED") ZIP_DEFLATED is a module constant, not a string value. try changing the above line to: backup = zipfile.ZipFile(zip, "w", zipfile.ZIP_DEFLATED) > backup.write(fch) > if cpt != 0: > backup.close() hope this helps! cheers /F From sheila at spamcop.net Sat Jan 27 14:34:38 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 27 Jan 2001 19:34:38 GMT Subject: [Off topic] allowed to put Python material on the Web? References: <3a730931.31998180@news.skynet.be> Message-ID: It would probably be polite, to ask the authors of the messages you are using (assuming you are quoting exactly from the messages) whether they would mind if you used their material. I'm not sure if this would be practical, though, since many Usenet participants munge their "from" address, and I'm not sure how many people you are talking about. Technically, once the messages are posted to Usenet, anyone can archive and copy them. However, if you were using them for commercial gain (i.e. ad banners and such), the authors might request that you remove their material from your site. Authors of Usenet posts still retain copyright to their own material. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Sat, 27 Jan 2001 17:51:57 GMT, Daniel.Kinnaer at Advalvas.be (Daniel) wrote in comp.lang.python in article <3a730931.31998180 at news.skynet.be>: : :Dear newgroupreaders, : :As a Python newbie, I've been collecting lots of questions and answers :from this newsgroup. It contains stuff not readily found in the many :good FAQ from the net. : :Before setting up a new site, I would like to ask if it is allowed to :put my collection of questions and answers from this newsgroup (which :helped me a lot) on my site,so everyone can enjoy/learn from it :without going to the d?j? palace. : :E.g. :- the Tutor beep question :- reading a file line by line :- make a stringcopy of a list :and so on. I've collected replies from Fredrik Lundh, Emile van :Sebille, Aahz Maruch, Alex Martelli and Sheila King to name only a :few. Yes, I've learned a lot from you! : :Thus, before starting the time-consuming task to create this new site, :I'd like to know if putting this collection on the Web is actually :legal/allowed. : :Hope to hear from you soon. : :Best regards, : :Daniel : From sdm7g at virginia.edu Wed Jan 10 11:31:46 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Wed, 10 Jan 2001 11:31:46 -0500 (EST) Subject: why no "do : until"? In-Reply-To: <93i12s$ul5$1@nnrp1.deja.com> Message-ID: On Wed, 10 Jan 2001 gregory_wilson at my-deja.com wrote: > > A proposal I floated a year ago, based on feedback from students in > the Python course I teach, was: > > do: > first-half > while cond: > second half > > which would allow the following degenerate forms: > > do: > body > while cond > > and > > while cond: > body > How do you distinguish between a single loop: do: stuff while cond: more_stuff and two separate degenerate loops: do: stuff # done stuff while cond: other_stuff ? ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From dsh8290 at rit.edu Wed Jan 3 07:58:41 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 3 Jan 2001 07:58:41 -0500 Subject: using 'global' across source files. In-Reply-To: <3A52EE2C.32432EF5@sara.nl>; from bram@sara.nl on Wed, Jan 03, 2001 at 10:17:32AM +0100 References: <3A51E6B7.82FFE8F4@sara.nl> <92sqc8$nm9$1@news.wrc.xerox.com> <3A52EE2C.32432EF5@sara.nl> Message-ID: <20010103075841.A4655@westsidecnc.rh.rit.edu> On Wed, Jan 03, 2001 at 10:17:32AM +0100, Bram Stolk wrote: > I thought that python's 'global' acted like C's 'extern' cmd, > meaning, that 'global val' does NOT define/create 'val', > only refers to a val that exists somewhere else. > 'global' is not the same as 'extern'. In python there are only 2 scopes (actually 3): local (inside a function), module, and builtin. If you are inside a function and you try to do an assignment, you will assign to a local variable. If it doesn't exist yet you have just created it. If this isn't what you want, you tell the interpreter with the 'global' keyword. It then searches for the variable in an outer scope (the module) rather than creating a new local variable. 'global' doesn't actually *do* anything except inform the interpreter of your intent. The variable was created when you executed the assignemnt, not global. In C, however, you must explicitly declare variables first. This is how a C compiler knows where to assign the value to. Since C's static type checking, etc, must know where to find a variable and check that it's name/type match the operation you need to tell it that there is such a variable in existence, but external to the current location. If you *really* need global variables, I would recommend making a module such as "Constants" or some other appropriate name and putting them in there. Also *don't* use "from import *". This will make the names be in the current module's namespace rather than sharing them with other clients of the imported module. Maybe it would be better if you redesigned your app to not use global variables, or to use OO principles instead? HTH, -D From scherrey at innoverse.com Thu Jan 4 10:42:29 2001 From: scherrey at innoverse.com (Benjamin Scherrey) Date: Thu, 4 Jan 2001 10:42:29 -0500 Subject: Exiting a program from within an object method. Message-ID: <9325ne014j@news2.newsguy.com> I've written a small python program that instantiates an object which inherits from SocketServer.BaseRequestHandler. The __main__ function starts this thing up with the serve_forever() method. Inside the handle() method of my object I check for a command to shutdown and, if received, call sys.exit(0). All this does is generate a SystemExit exception and does not terminate my program. Even if I wrap the call to serve_forever() with a try: except: block, the exception is not caught. I presume because the object's handle() method is possibly being executed in a child thread and python must not support cross thread exception handling (I'm not instantiating any threads explicitly, I'm assuming that the BaseRequestHandler is doing this internally)? What's a simple way to have my object exit the application cleanly? thanx & later, Ben Scherrey From aleaxit at yahoo.com Mon Jan 8 17:25:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 8 Jan 2001 23:25:23 +0100 Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com>, <20010109015253.2CBFEA82D@darjeeling.zadka.site.co.il> Message-ID: <063b01c079c2$883d29e0$b3ff1a97@martelli> "Moshe Zadka" writes: > > CGI. Really. Your admin system doesn't look like the kind of thing that > > will be continuously getting multiple hits a second, making CGI overhead > > a problem. If that is the case, CGI is easiest. *Do the simplest thing > > that can possibly work*! > > CGI is not an answer. Perhaps you meant "CGI with lots of little > print '' this and print '' that", which is as far from > the simplest thing that could possible work as possible. Most Python web Actually, I think the simplest way to generate HTML output in most cases is by smart copying of an input template (which is HTML with embedded Python expressions and a few Python statements -- if, for, while). The 'smart-copy' facility was the first significant Python utility I ever wrote for myself, back as a very, very raw Python newbie: a few well-invested hours mostly spent learning the details of how re's work in Python. I think I could redo it now in a couple of hours if I had to, of course, having learned some Python in the meantime (my first, and still-working, version, was far too rich in functionality, allowing completely-general RE's to demarcate embedded expression, statements, etc, for example; "I'm younger than that now"). The cool thing (from my POV) is I can use any decent HTML editor (I recommend Arachnophylia, but of course there's a surfeit of them around, of all shades between wysiwybywg [what you see is what you _believe_ you will get] and vim's textediting+syntax colouring) as a 'GUI builder', with just a little touch of text-editing to ensure the needed embedded-expressions and conditional and repeated portions. In any case, if you prefer other approaches such as HTMLgen or whatever, by all means go for them -- they're not really very related to the question at hand. Who's saying you're going to output HTML at all, rather than XHTML, XML, plaintext, or whatever? That may depend on the details of the query you get, current state, blah blah. Before that becomes an issue, your Python code has to be running in response to a 'query'; the question was posed in the context of how to get that to happen (mod_this, mod_that, PyTheOther) -- and my point is that the simplest practicable way is likely to be CGI, using (if one needs session continuity) cookies and perhaps shelves. > Of course, the simplest thing that can possible work interface-to-the-browser > part is of course not even going with CGI, but with inheriting from > BaseHTTPRequestHandler. I fail to see how that's simpler than 'import cgi', which parses up GET or POST parameters in a simple, standard way and presents them to your code in a very dict-like way (OK, the cgi module itself could be simpler, no doubt -- but, there's a PEP out on Python Web enhancements, isn't there?). Then you can run CGIHTTPRequestHandler directly, or Xitami, or Apache, or PWS, or whatever other webserver you think is the easiest and simplest to run, administer, and keep running. Alex __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com From grante at visi.com Sat Jan 13 21:13:56 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 14 Jan 2001 02:13:56 GMT Subject: BOOTP and TFTP servers in Python? Message-ID: I need a self-contained BOOTP and TFTP server application for Linux (portibility to other Unices would be a plus). I'd like to write it in Python if possible. Is it possible to write a BOOTP server in Python using the standard socket libs? Since TFTP is a normal UDP based protocol, I know a TFTP server is possible: does one exist already? -- Grant Edwards grante Yow! Can you MAIL a BEAN at CAKE? visi.com From MarkH at ActiveState.com Thu Jan 25 16:10:01 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 25 Jan 2001 21:10:01 GMT Subject: Need Python Enabled Rich Edit Control Similiar to PythonWin.Exe References: <94q1rt$2ip$1@nnrp1.deja.com> Message-ID: <94q4n0$5en$1@nnrp1.deja.com> In article <94q1rt$2ip$1 at nnrp1.deja.com>, btheld2 at my-deja.com wrote: > Hello, > > I need a python-enabled rich edit control to use in my application that > looks similar to the view in PythonWin.exe. However, I need a control The Pythonwin rich-edit view is based on a rich-edit control, and can be used without problem (eg, the "Edit/Preferences" menu item uses this) However, you should definitely check out scintilla - www.scintilla.org Mark. Sent via Deja.com http://www.deja.com/ From erno-news at erno.iki.fi Sun Jan 7 00:08:09 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 07 Jan 2001 07:08:09 +0200 Subject: LoadLibrary/dllopen in python. References: <3a57ea9f.348172625@nntp.interaccess.com> Message-ID: In article <3a57ea9f.348172625 at nntp.interaccess.com>, olczyk at interaccess.com (Thaddeus L. Olczyk) writes: | Is there a way to call LoadLibrary (Win32 ) or dllopen (Linux ) in yep, with the calldll and dl modules, the dl module (which wraps dlopen(3)) is pretty limited though. dl comes with python, calldll not. -- erno From richard_chamberlain at ntlworld.com Sat Jan 13 06:14:46 2001 From: richard_chamberlain at ntlworld.com (ntlword) Date: Sat, 13 Jan 2001 11:14:46 -0000 Subject: COMMERCIAL: BlackAdder Windows/Linux Python/Qt Development Environment References: <3A5CBDB7.F82290B9@river-bank.demon.co.uk> <3A5CE2D6.1A954AD7@monitor.net> <93jvvb0h08@news1.newsguy.com> Message-ID: A plan so cunning you could put a tail on it and call it a weasel? Richard Alex Martelli wrote in message news:93jvvb0h08 at news1.newsguy.com... > "Stephen R. Figgins" wrote in message > news:3A5CE2D6.1A954AD7 at monitor.net... > > M'lord, I have a cunning plan..... > > Does it involve a turnip? > > > Alex > > > From erno-news at erno.iki.fi Thu Jan 4 19:08:33 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 05 Jan 2001 02:08:33 +0200 Subject: Unexpected result for list operator "+=" References: <3A542778.E1BC06E3@bogusaddress.com> Message-ID: In article , Thomas Wouters writes: | actually *augmented* assignment is, too. *everything* is about references :) fair enough :) what i was trying to refer (no pun intended) to, augmented assignment can make new copies. as in: s = s2 = 'foo' s += 'bar' s2 is not s -- erno From moshez at zadka.site.co.il Wed Jan 10 09:37:16 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 10 Jan 2001 16:37:16 +0200 (IST) Subject: escape sequences and string comparisons In-Reply-To: <93f1rd$iv7$1@nnrp1.deja.com> References: <93f1rd$iv7$1@nnrp1.deja.com>, <93cboe$ctj$1@nnrp1.deja.com> <93elo7$aoh$1@nnrp1.deja.com> Message-ID: <20010110143716.4F350A82D@darjeeling.zadka.site.co.il> On Tue, 09 Jan 2001 12:57:18 GMT, jkndeja at my-deja.com wrote: > To which I reply: > - Serves me right for not RTFM ... ;-/ > - not sure that I'm convinced by the debugging argument > - I still think this makes re.escape() less useful than it > might be. How about a function which turns a string into an 'escaped' > form such that it would be an 'exact' RE match with itself? Do you have any evidence that the following does not hold: for any strings s and t, re.compile(re.escape(s)).search(t) is true iff s is a substring of t? -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From n8gray at nospam.nospam Mon Jan 29 02:18:16 2001 From: n8gray at nospam.nospam (Nathaniel Gray) Date: Sun, 28 Jan 2001 23:18:16 -0800 Subject: "in" for dicts (was: Python 2.1 function attributes) References: <3A7496A7.253B7B67@caltech.edu> Message-ID: <9535qg$8mu@gap.cco.caltech.edu> Tom Satter wrote: > "Nathaniel Gray" wrote in message > news:3A7496A7.253B7B67 at caltech.edu... > ... > > > > If I was to ask you, "Tim, is 'larch' in Webster's dictionary?" would > > you reply, "Yes, it's under 'L'", or would you reply, "No, there's no > > 'larch' section, just A,B,C,D,..."? > > > > (I know you'd _actually_ reply "Look it up yourself!" ;^) > > > > "in" just doesn't imply "has_key" for dictionaries. > > Except that in Webster's dictionary, 'larch' IS a key with the definition > (basically a tree) being the value. So I would expect that 'larch' is IN > Webster's. Ahh. Nothing like using a clever analogy to prove just the opposite of your point. :^) It just goes to show, once again, that one should never post to usenet when one's in a rush. Nevertheless, there are still three big problems with "in" for dictionaries: Number 1: There is no reason, a priori, to think that "in dict" should mean "in dict.keys()" rather than "in dict.values()" or even "in dict.items()". Explicit is better than implicit, right? Number 2: The chosen semantics for "in dict" are inconsistent with the meaning of "in" in the context of lists. The "keys" of a list are the integers from 0 to len(the list) - 1. When I write: list1 = [] list2 = ['dead', 'parrot'] for thing in list2: list1.append(thing) print list1 I get ['dead', 'parrot'], the list's "values", not [1, 2]. Naively, one would then expect that: list1 = [] dict1 = {1:'dead', 2:'parrot'} for thing in dict1: list1.append(thing) print list1 should either print ['dead', 'parrot'] or ['parrot', 'dead']. With lists, "in" refers to the thing being stored, not the thing you use to _get_ the thing being stored. Why should dictionaries be different? It's counterintuitive. Number 5: (three, sir) Oh yes, number 3: We've already got "for a_key in dict.keys()"! The only reason we're introducing these ambiguous, inconsistent semantics is so that we can use a dictionary as a set and still say "for thing in a_set:". (I sure hope we're not doing it just to save a few keystrokes every now and then!) We're not straightening out an awkward idiom or clearing up a Python wart, we're masquerading one data structure as another. "It's not a big dog. Perhaps if we clipped it's ears and taught it to meow it could pass for a cat!" Once again, wouldn't it just be better to have a collections module for Python with a Set class and let dictionaries be dictionaries? And yes, I dislike list.pop() too. ;^) Lest I come off as too much of a grumpy Gus, I should add that I really like most of the new stuff in Python 2.1a1, particularly xreadlines. I'll be first in line to upgrade when 2.1 stabilizes, even if "in dict" survives. -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From Bill.Scherer at VerizonWireless.com Thu Jan 18 14:24:48 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Thu, 18 Jan 2001 14:24:48 -0500 Subject: emacs / autocompletion References: <20010118152340.A31004@isohypse.org> Message-ID: <3A674300.7FA2264E@VerizonWireless.com> Put this in your .emacs file: (define-key global-map (read-kbd-macro "M-RET") 'hippie-expand) Then hitting M-RET (Escape followed by Return for me) will atempt auto completion. Siegmund Fuhringer wrote: > > hi.. > > is there anywhere an emacs autocompletion mode available? > i'm unable to find something like that. > > bye siegmund > > -- > http://mail.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From jepler at inetnebr.com Sat Jan 6 15:06:12 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Sat, 06 Jan 2001 20:06:12 GMT Subject: Speed of Python vs. Perl References: Message-ID: On Sat, 6 Jan 2001 13:23:25 -0500, AndroidMonkey wrote: >In the last Maximum Linux magazine, there was an article about using Perl >for a car MP3 player. It got me wondering - What's the speed of Python like >compared to Perl? I've never used Perl before, so I hope someone could >answer my question here. Thanks -vm I haven't read the magazine you refer to, but either Python or Perl would be fast enough to control an mp3 player, including displaying the state of playback, manipulating playlists, and accepting user input. In Python, you might use Gtk, Tkinter, or curses to display a GUI interface, popen2 or a custom extension module to control the underlying mp3 decoder, and custom classes class for playlists and tracks. I am not familiar with the format of mp3 tags, but there have been several threads in the newsgroup about them recently. I imagine that a nicely written module for getting title/ artist/etc information out of the files must exist by now. You won't actually write an mp3 decoder in perl or python, it will be written in C, possibly with portions in assembler for the lowest CPU consumption. Jeff From aahz at panix.com Fri Jan 19 10:35:49 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Jan 2001 07:35:49 -0800 Subject: Beginning with threads References: <948rj1$rhu$1@nnrp1.deja.com> Message-ID: <949msl$buo$1@panix6.panix.com> In article <948rj1$rhu$1 at nnrp1.deja.com>, wrote: > >I am just starting with threads and am trying to grasp what should and >shouldn't be done... I have a class that uses threads in one of its >functions. Should I make it inherit from threading?? I recommend inheriting from threading; I think it makes things simpler. You may want to break up your class into two separate classes. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I guess I mostly see Life [tm] as a process of closing doors that you might want to go through. --Aahz From matt at virtualspectator.com Sun Jan 21 18:26:11 2001 From: matt at virtualspectator.com (matt) Date: Mon, 22 Jan 2001 12:26:11 +1300 Subject: patch for python configure for freeBSD and Zope In-Reply-To: References: Message-ID: <01012212294102.00887@localhost.localdomain> On Mon, 22 Jan 2001, Chris Watson wrote: > > Hi, I'm using freeBSD 4.2-RELEASE and just tried to install python-1.5.2 and > > Zope. If you are trying to do the same and tun into the following error when > > trying to start zope, then apply this patch to the configure script of python > > and rebuild it. > > > > ImportError: ./ExtensionClass.so: Undefined symbol "PyMethod_Type" > > Matt, > > Is this an error in the port itself of python? Python 2.0 is in > ports as well as zope. If there is a problem with either port can you give > more detail so the apropriate maintainer can be notified. Thanks! Sorry, to be more explicit : I built python 1.5.2 and Zope 2.2.2 from source, although the most recent stable release of Zope also gave the same error. I did not use the ports distribution of python or zope, so I don't know if the same default configure script is used by them too. Is that what you wanted to know? Matt > > -- > ============================================================================= > -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek > Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas > Home: scanner at deceptively.shady.org | http://open-systems.net > ============================================================================= > WINDOWS: "Where do you want to go today?" > LINUX: "Where do you want to go tomorrow?" > BSD: "Are you guys coming or what?" > ============================================================================= > GNU = Gnu's Non-portable & Unstable > irc.openprojects.net #FreeBSD -Join the revolution! > ICQ: 20016186 -- From dsh8290 at rit.edu Tue Jan 23 16:32:54 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 23 Jan 2001 16:32:54 -0500 Subject: Can I decompile PYC files? In-Reply-To: <94j8j5$50e$1@nnrp1.deja.com>; from noahspurrier@my-deja.com on Tue, Jan 23, 2001 at 06:33:09AM +0000 References: <94j8j5$50e$1@nnrp1.deja.com> Message-ID: <20010123163254.B22126@harmony.cs.rit.edu> I heard once that .pyc files are simply Python Code objects that have been marshalled. You could take a look at the marshall module and see how to load such objects. Maybe you could write them out as strings? (maybe repr or str will help) I don't have any other ideas. (next time you may want to try cvs or rcs to manage revisions in your files) -D On Tue, Jan 23, 2001 at 06:33:09AM +0000, noahspurrier at my-deja.com wrote: | | | A process just deleted my .py file. I still have the .pyc file. | Can I recover anything? I'm desparate. It doesn't have to be perfect. | Thanks, | Noah | | From ckrill at qvlinc.com Sat Jan 20 22:12:16 2001 From: ckrill at qvlinc.com (Coy Krill) Date: Sat, 20 Jan 2001 19:12:16 -0800 Subject: wyPython References: Message-ID: <3A6A538F.E8D82AC2@qvlinc.com> Doug Farrell wrote: > Hi, > > I'd like to hear what people think of wyPython and any experience they've > had with it, in particular as to how it compares to useing other GUI tookits > like Tcl/Tk for instance. > > Thanks, > Doug I've tried it. It seems nice. I don't like the printing support, especially cross-platform. That said, I don't use it and probably won't. I've used and prefer PyQt. There are licensing issues for those who want to distribute the Qt libs for Windows apps (i.e. you have to purchase a commercial license of BlackAdder from thekompany.com) but the pricing is quite reasonable. It is of course free for linux or any other platform where Qt is free. I highly recommend it for Open Source developers and use it for home stuff all the time. Coy From chris at voodooland.net Sun Jan 14 02:29:10 2001 From: chris at voodooland.net (Chris Watson) Date: Sun, 14 Jan 2001 01:29:10 -0600 (CST) Subject: storing passwords In-Reply-To: <93rdmr$ihu$1@flotsam.uits.indiana.edu> Message-ID: > I have a Python script that makes a Telnet connectio to a remote server and > right now I have the password just stored within my code. I'd don't like > the idea of leaving the password available like that (the script runs > automatically every night, so I can't prompt the user for it), so is there > any other way to store the password in some kind of encrypted fashion?? Brian, I would ditch telnet and use ssh and a rsa key. No password needed then. Unless your stuck with telenet. :-| -- ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From warlock at eskimo.com Sat Jan 13 03:41:43 2001 From: warlock at eskimo.com (Jim Richardson) Date: Sat, 13 Jan 2001 00:41:43 -0800 Subject: making a string copy of a list References: Message-ID: On Fri, 12 Jan 2001 22:53:04 -0800, Jim Richardson, in the persona of , brought forth the following words...: >OK, I swear I've looked for this, but how do I make a copy of a list, into a >string, complete with commas seperating the entries in the list? > > > >-- Okay, I a replying to my own post to say Doh!, str() does this... "This was not a real question, this was only a test, had this been a real question, something approaching intelligence would have been visible. We now return you to your regularly scheduled regexps." -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From tim.one at home.com Mon Jan 29 15:25:02 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 29 Jan 2001 15:25:02 -0500 Subject: win32 DLL import problem In-Reply-To: Message-ID: [Robin Becker] > ... > try and get hold of depends.exe the dependency checker and use it to see > what DLL's your exetnsion is linked against/expecting. It comes as part > of the VC++ tools, but it can be downloaded from M$oft somewhere. The original author of that tool also distributes it (well, a fancier version, but still free for personal use): http://www.dependencywalker.com/ From fischer at intes.de Wed Jan 17 02:53:19 2001 From: fischer at intes.de (Rolf FISCHER) Date: Wed, 17 Jan 2001 08:53:19 +0100 Subject: Command language definition In-Reply-To: <20010117082100.A21854@yetix.sz-sb.de> References: <3A6542EC.99ED1149@intes.de> <20010117082100.A21854@yetix.sz-sb.de> Message-ID: <01011708573000.21025@rolf> On Wed, 17 Jan 2001, Andreas Jung wrote: > On Wed, Jan 17, 2001 at 07:59:56AM +0100, Rolf Fischer wrote: > > Or is there a combination with another tool that you would recommend ? > > hm...please be a bit more detailed... > > Andreas Thanks for the reply if you want to build a grammar, the basic problem is a syntax definition and the check of its validity i.e command:= keyword [parameter = value] To setup a command with parameters and values requires a syntax analysis. My first (and very raw) impression on python was, that the tool has excellent capabilites in easy programming, but I didn't see anything the like to check a syntax or to define one. This is why I asked for additional tools. Best regards Rolf From coral945 at aol.com Fri Jan 5 18:59:07 2001 From: coral945 at aol.com (coral945 at aol.com) Date: Fri, 05 Jan 2001 23:59:07 GMT Subject: Get paid alot of money for being online!$ 6526 Message-ID: Go to http://eazymoney01.homestead.com/main.html for all the info ekfmzfepvdhewgiutgucwi From aleaxit at yahoo.com Wed Jan 10 06:32:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 10 Jan 2001 12:32:23 +0100 Subject: Silly question from a newbie References: <7KM66.70326$Wq1.27682542@nnrp5-w.sbc.net> Message-ID: <93hhag0150d@news2.newsguy.com> "Phlip" wrote in message news:7KM66.70326$Wq1.27682542 at nnrp5-w.sbc.net... [snip] > > I'm using the Python for Windows thingy, as I don't have UNIX (apart from > > Linux, which I ordered from Amazon.com, but hasn't arrived yet!). > > You'v done a courageous thing just coming here, and we are all here to > support you. Admitting you have a problem is the first, biggest step to > recovery. A-*hem* -- "my name is Alex, and I use Windows". (Hey, I'd rather be Linuxing, too -- but if the market is ready to shower me with gold for developing Windows applications instead of Linux ones, who am I to resist? I _am_ rather the corruptible, greedy type, after all!). Alex From harrc at my-deja.com Wed Jan 3 13:57:51 2001 From: harrc at my-deja.com (harrc at my-deja.com) Date: Wed, 03 Jan 2001 18:57:51 GMT Subject: Playing an .mov, .avi etc. file?? Message-ID: <92vsna$hdq$1@nnrp1.deja.com> Does anyone know of a good way from Python to play a video file (.avi or .mpg or .mov)? Or even better, a way to play slected tracks off a DVD? Any info is helpful! Chad Harrington Sent via Deja.com http://www.deja.com/ From jens.vogelgesang at de.bosch.com Thu Jan 4 03:44:36 2001 From: jens.vogelgesang at de.bosch.com (Jens Vogelgesang) Date: Thu, 4 Jan 2001 09:44:36 +0100 Subject: Reading from a pipe (open mode w) Message-ID: <931d5j$m0e$1@proxy.fe.internet.bosch.de> I need a wrapper to capsulate an interactive tool which is waiting for keyboard input. I can generate the input by writing into the pipe. To be able to retrieve the tool output, I tried to read from the pipe. My Problem is, that I don't know, how to flush the pipe, to force the pipe not to be buffered?? Any hints ?? Jens From rturpin at my-deja.com Tue Jan 16 09:04:30 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Tue, 16 Jan 2001 14:04:30 GMT Subject: Web devel with python: Best route? XML to HTML translation! References: <93cqvi0191h@news1.newsguy.com> <93hfp1013sm@news2.newsguy.com> <93vnlv$2qq$1@nnrp1.deja.com> <3A6412BC.A07C547@stroeder.com> Message-ID: <941kd8$k9n$1@nnrp1.deja.com> In article <3A6412BC.A07C547 at stroeder.com>, Michael =?iso-8859-1?Q?Str=F6der?= wrote: > In theory this is a good way. But how about the performance? > Last time I played with a Python-written XSLT processor it > was pretty slow. Did it process the filter/spec on each translation? Or did it cache the resulting code? Some translation systems use a pre-processing step to convert filters/specs into translation code. The resulting code often performs quite well. Russell Sent via Deja.com http://www.deja.com/ From johann at physics.berkeley.edu Sat Jan 20 14:29:08 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 20 Jan 2001 11:29:08 -0800 Subject: Tabbing/Spaces References: Message-ID: Barry A Warsaw writes: > Not for python-mode. The default for new Python files is 4-space > indentation levels and no tabs. Python-mode will adapt somewhat to > the conventions already existing in the file though. My mistake. I just recently upgraded my python-mode, and hadn't noticed the change, since I (setq indent-tabs-mode nil) in my .emacs. Thanks for the info; it's good to see python-mode is sane. :-) -- Johann Hibschman johann at physics.berkeley.edu From andrefor at axionet.com Sun Jan 28 13:05:18 2001 From: andrefor at axionet.com (Andre Fortin) Date: Sun, 28 Jan 2001 10:05:18 -0800 Subject: How to call a class method from a string representing a class name Message-ID: <3A745F5E.5F035F1D@axionet.com> Hi!, I'm trying to do the following: if there is an object named 'test' in this namespace, call its well-known class method 'myFunc'. The 2 snippets of code below show how I'm currently doing this. Is there a better/easier way, avoiding globals() and vars() ? Thanks, -- Andre #------------ Main file: question.py ------------------- #! /usr/bin/env python import test className = 'test' try: myObj = globals()[className] apply(vars(myObj)['myFunc'], ('Some text',)) except KeyError: pass #------------ File 2: test.py ------------------- class test: pass def myFunc(someText): print "[%s]" % someText From chris at voodooland.net Thu Jan 18 01:27:34 2001 From: chris at voodooland.net (Chris Watson) Date: Thu, 18 Jan 2001 00:27:34 -0600 (CST) Subject: OS Module (how to check free space) In-Reply-To: <945aq5$2kd$1@nntp.itservices.ubc.ca> Message-ID: > Hi - newbie question: I've looked over the OS module documentation and I can't find a > tool within python that will allow me to check how much free space is available on a > storage device such as a hard drive. > > Does anyone know how to do this? Kris, AFAIK I would use os.spawnv() to call df to get free space assuming this is on unix. Otherwise call whatever win32 equiv there is. If you need help with spawnv mail me and ill send you sample code. -- ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= GNU = Gnu's Non-portable & Unstable irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From mwh21 at cam.ac.uk Fri Jan 26 08:54:34 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 26 Jan 2001 13:54:34 +0000 Subject: Umlauts revisited: Now they prevent program from running References: <94rt05$tbe$1@newsreaderg1.core.theplanet.net> Message-ID: "Franz GEIGER" writes: > I pull data out of an Excel sheet using DAO. There are field values > containing text strings. Everything works fine until a text reads e.g. > "St?ck". > > After stopping before the exception > > "UnicodeError: ASCII encoding error: ordinal not in range(128)" > > occurs I display the field in the interactive window of PythonWin > (ActiveState 2.0 on NT4) by simply typing "fld.Value". > > It displays u'St\374ck'. > > Conversion into a Python string by applying print or str() yields: > > "Traceback (innermost last): > File "", line 1, in ? > UnicodeError: ASCII encoding error: ordinal not in range(128)" > > Any idea how to overcome this? fld.Value.encode('cp1252') maybe? -- 41. Some programming languages manage to absorb change, but withstand progress. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From paul.moore at uk.origin-it.com Mon Jan 8 07:01:48 2001 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Mon, 8 Jan 2001 13:01:48 +0100 Subject: How do I get a mimetools.Message object from a mailbox.UnixMailbox object? References: Message-ID: On Mon, 8 Jan 2001 02:34:31 +0100 , "Steve Holden" wrote: >The mimecntl module was invented to overcome the impedance mismatch between >mailbox and rfc822, and does so quite well, so you may wish to consider >using that instead. I've used it fairly extensively and only had one >problem with it (which I'm debgging between times, but haven't looked at >lately). Thanks for the pointer. However, the module doesn't seem to handle mbox format mailboxes, and the mailbox module doesn't offer a method of generating data in a form that can be passed to mimecntl (that would need mimecntl.MIME_document to have a constructor from a rfc822.message). I hand-parsed the Unix mbox format file in the end - it's not hard, after all... Thanks, Paul. From clarence at netlojix.com Tue Jan 30 12:45:42 2001 From: clarence at netlojix.com (Clarence Gardner) Date: Tue, 30 Jan 2001 09:45:42 -0800 Subject: SSL EOF References: <980790776.835347129@news.silcom.com> <3A75DEB9.308FE746@san.rr.com> Message-ID: <980877001.384793985@news.silcom.com> On Mon, 29 Jan 2001, Darren New wrote: >Clarence Gardner wrote: >> The issue is the SSL support in the socket module, which raises an >> exception when the reading socket is at EOF, rather than returning an >> empty string. > >Do you mean when the SSL library reads EOF on the socket, or when you read >EOF from the SSL library? SSL requires packets that say "I'm closing the >socket", and I can understand getting an error if the other side is (for >example) just exitting without telling its SSL to close the socket first. > Here is the relevant code. I don't know what error==6 signifies, but even if the other side closed improperly, I don't think that's so significant as to warrant making these sockets behave differently from non-ssl ones. count = SSL_read(self->ssl, PyString_AsString(buf), len); res = SSL_get_error(self->ssl, count); switch (res) { case 0: /* Good return value! */ break; case 6: PyErr_SetString(SSLErrorObject, "EOF"); Py_DECREF(buf); return NULL; break; case 5: default: return PyErr_SetFromErrno(SSLErrorObject); break; From erno-news at erno.iki.fi Thu Jan 25 01:11:33 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 25 Jan 2001 08:11:33 +0200 Subject: Python and postgreSQL ?? References: Message-ID: In article , Sean Reifschneider writes: | On Thu, Jan 25, 2001 at 03:31:59AM +0200, Erno Kuusela wrote: || pygresql comes with a tutorial. it's in the "tutorial" directory. | It's kind of odd though because it makes use of the "pgtools" weirdness. | "Where does this "pgcnx" come from?" It also doesn't seem to do much in | the way of handling results of queries. hmm, yeah, i didn't actually remember what was in the tutorial, just that it was there. seems the latest version of pygresql doesn't have the pgtools thing. but, it doesn't use the db-api interface either. i guess best advice to the original poster would be to find some generic db-api examples and use those. | An example of the use of large objects would be cool. Seems to be | underdocumented in the regular pgsql documentation as well though. the readme doesn't make it sound very hard... -- erno From krussll at cc.umanitoba.ca Wed Jan 10 17:07:14 2001 From: krussll at cc.umanitoba.ca (Kevin Russell) Date: Wed, 10 Jan 2001 16:07:14 -0600 Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: <3A5CDD12.B1D0A857@cc.umanitoba.ca> Jason Cunliffe wrote: > > hmmm... let's consider for a moment neither you nor I.. > What about all the newcomers to Python, as beginining programmers, kids, > students, newbies, > immigrants from other languages..? What sanity it would be to arrive in > Pythonia, where DateTime() is actually corresponds to the scope of > historical time, instead of some *nixed no-life before 1970! > > Any kind of datetime needs [beyond system timestamping of files or message > packets] > needs mxDateTime(). Any use concerning people and not machine prblems, > including even basics like date of birth. Anyone over the age of 30+ is out > luck. Let's see that is maybe 2-3 billion people? > > mxDateTime() gets it right the first time. It allows for sane administering > of all kinds of historical, scientific, statistical, medical, geographic, > demographic and business data......Or how about wonderful extended features > of mxDateTime for easier design of more intuitive and useful calendar > applications. I have to add my agreement that the standard library needs a module that actually does dates and times correctly -- which for now means mxDateTime. I find the not-enough-people-use-it-so-it's-just-bloat argument utterly unconvincing in this case. Are there honestly fewer Python users who need to deal with dates than there are users who do other things that the standard library provides for? (Like interfacing to the Berkeley DB engine, using the gopher protocol, dealing with image files under SGI IRIX, interfacing to Sun's NIS?) If it honestly turns out that there *are* fewer, then by the same logic the standard library shouldn't include the current broken DateTime. If there aren't enough Python users who need dates done right, how many Python users could there possibly be who need dates done wrong? If the standard library can't handle dates in the transparent and correct way that a user would expect (given the rest of the standard library), then it shouldn't be pretending to handle dates at all. -- Kevin From tim.hochberg at ieee.org Wed Jan 24 19:10:30 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 25 Jan 2001 00:10:30 GMT Subject: The fundamentals... References: Message-ID: "Mike Read" wrote in message news:F8Jb6.30683$pp2.2619941 at news3.cableinet.net... > Newbie first script alert! No problem - it does what I intended (which > probably says more about Python than me...), but I just wanted to start > off on the right foot - is it as elegant as it could be? If it's not blindingly > obvious, I was separating fields around a period delimiter. Hi Mike, There are a couple of things you can do to make it more concise. First, you can use replace rather than split and join. Second, you can use string methods instead of the functions from the module string. With these two changes, it becomes: infile = open('\\Windows\\Desktop\\test.txt', 'r') outfile = open('\\Windows\\Desktop\\out.txt', 'w') outfile.write(infile.read().replace(". ", "\n")) infile.close() outfile.close() Finally, it is common practice to omit the closing of files in many situations. (Whether it's good practice is an issue for another thread). This works because the file is automatically closed when the file's reference count drops to zero(*). So, if the above were appearing in a function: def dotToReturn(inpath, outpath): infile = open(inpath, 'r') outfile = open(outpath, 'w') outfile.write(infile.read().replace(". ", "\n")) dotToReturn('\\Windows\\Desktop\\test.txt', '\\Windows\\Desktop\\out.txt') the files would be closed at the end of the dotToReturn function. One final entry for those who crave terseness: open(outpath, 'w').write(open(inpath, 'r').read().replace(". ", "\n")) This is a bit too terse for my tastes, but tastes vary... -tim (*) One needs to be careful about this if using Jython, formerly Jpython From zeitlin at seth.lpthe.jussieu.fr Thu Jan 25 16:36:51 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 25 Jan 2001 21:36:51 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: [disclaimer: my other email address is vadim at wxwindows.org so I'm not really impartial] On 25 Jan 2001 19:41:19 GMT, Neil Cerutti wrote: >The current documentation for Tkinter is much better than what is >available for wxPython. This is very strange. Where is good documentation for Tkinter to be found? When I had tried to learn using it (this was 5 years ago, true) I couldn't find any documentation at all. wxWindows documentation is probably what has personally attracted me so much to it. >Tkinter's 'pack' layout manager is super easy to use, and with >some practice and the excellent documentation, powerful. wxPython >seems to have a couple of layout managers, but how they should be >used is a mystery. Well, this *is* explained in the docs. Besides, the sizers are mostly what you'd expect them to be (if you have experience with other GUI frameworks using such things). I don't even think they are that far from Tkinter layout manager although I don't know it well enough to be sure. >I've been forced to place everything pixel by pixel so far. No offense intended, but this is the worst possible way to do it. >Binding widgets to callbacks in Tkinter is much easier for me to >understand than the wxPython EVT_ macros. This depends on your background, I guess. >Tkinter's events seem >much easier to bind, since I don't have to worry about which >widget generates what event -- they all seem to generate everything >I've wanted to bind. It is possible to handle events from several widgets or different events from the same widget in the same event handler in wxPython, so I'm not sure how much different can it be. >The objects in wxPython are more full-featured (I guess--for some >definition of full featured), but aren't as easily configurable >as the Tkinter ones. There is a trade off between having your own, completely customizable (because you can tweak them in any way you like) widgets and using the standard ones. wxWindows chooses the 2nd i.e. it favours the native look and feel. >wxPython's documentation seems to be in the state Tkinter's was >back when all there was was the _Tkinter life preserver_. I still wonder what documentation are you speaking of? Do you mean wxWindows documentation (because this is what you should use, it has special python notes in it but globally it's the same set of docs) or something else? Also, I'd advise you to ask the various technical questions you had (handling ESC, popup menus, ...) on wxPython mailing list. I'm not sure they will be answered, but it's certainly worth a try. >Better advice is probably to try them both for some small sample >app, like I have, and make up your own mind. Perhaps wxPython >makes perfect sense if you are a good C++ programmer. On my own example it certainly does :-) Regards, VZ -- GCS/GM d? H+ s++:-- p2 au--- a- w+ v C+++ UBLS+++ P- L++ N++ E--- W++++ M? V-- -po+ R++ G`` !tv b+++ D--- e++++ u++ h--- f+ r++ n- y? From aleaxit at yahoo.com Sun Jan 7 03:35:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 7 Jan 2001 09:35:53 +0100 Subject: Should I learn Python or Java? References: <938h6r$26j$1@troll.powertech.no> <938ops$b51$1@news.inet.co.th> <938p9i$bn7$1@news.inet.co.th> Message-ID: <939a0v0nma@news1.newsguy.com> "Prateep Siamwalla" wrote in message news:938p9i$bn7$1 at news.inet.co.th... > Ok, correction, you can do stuff with java+ms apps: > > "Automating excel with Java" > http://support.microsoft.com/support/kb/articles/q169/7/96.asp The article covers Microsoft's VJ++ version, only; and besides any other issues, VJ++ looks sure to be orphaned in the next generation of Visual Studio (VS7, aka VS.NET, has C# in place of Java). There are 'bridges' to let you interoperate (e.g.) Corba<->COM, and you can do Corba with any Java, but it's rather a curve-ball, involving commercial (perhaps costly) 3rd party components, etc. Alex From msoulier at storm.ca Sun Jan 14 22:14:01 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Mon, 15 Jan 2001 03:14:01 GMT Subject: win32all crashes win98 References: <3a621864$0$21002@SSP1NO25.highway.telekom.at> Message-ID: In article <3a621864$0$21002 at SSP1NO25.highway.telekom.at>, Wolfgang Neff wrote: >Python extensions for Windows (win32all) work fine on Windows 2000 and also >on Windows 98 SE / IE 5.5 when run within PythonWin. Withing python/pythonw, >however, the same script causes kernel32.dll to crash with a stack error. > >Is there someone who knows a work-around? Install Linux? :) Mike -- Michael P. Soulier "...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 PGP Public Key: http://24.43.42.96/email.phtml From andreas at andreas-jung.com Tue Jan 9 05:10:11 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Tue, 9 Jan 2001 11:10:11 +0100 Subject: Determine whether STDIN is gzipped In-Reply-To: <3A5ADB84.194BAD4E@schlund.de>; from cg@schlund.de on Tue, Jan 09, 2001 at 10:36:04AM +0100 References: <3A5ADB84.194BAD4E@schlund.de> Message-ID: <20010109111011.A5539@yetix.sz-sb.de> On Tue, Jan 09, 2001 at 10:36:04AM +0100, Carsten Gaebler wrote: > Hi there! > > I'm writing a program that reads its input data from STDIN. Now I'd like > it to be able to determine whether the input data is gzipped or not and > do the right thing automatically. This is my approach: > > > import gzip, sys > > f = gzip.GzipFile("", "rb", fileobj=sys.stdin) > try: > f.readline() # raises exception if not gzipped > except: > f = sys.stdin > > while 1: > line = f.readline() > if not line: break > # do something with line > Something like the following should work (I assume we can read all data from STDIN in one read() call): import os,gzip,sys from cStringIO import StringIO SIO = StringIO(sys.stdin.read()) try: data = gzip.GzipFile('','r',fileobj=SIO).read() except: data = SIO.getvalue() print data Andreas From kmbotha at netinfo.ubc.ca Fri Jan 5 00:50:00 2001 From: kmbotha at netinfo.ubc.ca (Kris Botha) Date: Fri, 05 Jan 2001 05:50:00 GMT Subject: using snack to eat an mp3 stream Message-ID: <3a555fe8.47773420@news.interchange.ubc.ca> Has anyone ever tried this? I know that snack is able to open files from hard-drive or through streams, using the channel parameter in snack. Unforunately, I've found no documentation on this sort of thing anywhere. I'm trying to play audio files through a tcp/ip connection using snack.. Can anyone point me in the right direction? Thanks, ~~====----..----====~~ Kris Botha From oblomov at freemail.it Fri Jan 19 17:04:06 2001 From: oblomov at freemail.it (Giuseppe Bilotta) Date: Fri, 19 Jan 2001 22:04:06 GMT Subject: Literate programming in Python References: <3A681A33.C49C1920@earth.ox.ac.uk> Message-ID: Nick Belshaw wrote [Interscript] > I found that a bit clumsy so wrote a WYSIWYG editor for it using Python/Tkinter - rough but easy. > > - it certainly works. Maybe a bit slow for big projects but it sure maintains readability!! > Is it available on the Net? I would really appreciate it. -- Giuseppe Bilotta From ivnowa at hvision.nl Wed Jan 17 10:32:46 2001 From: ivnowa at hvision.nl (Hans Nowak) Date: Wed, 17 Jan 2001 15:32:46 GMT Subject: help with code for combinations/permutations References: <944adl$2bf@dispatch.concentric.net> Message-ID: <3A65B95C.7539@hvision.nl> Bryan Webb wrote: > > HI, > I have a list with 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 in it, > I need to come up with all possible combinations of the numbers in the above > list ie. 1 +2, 1+2+3, 1+2+3+4, 1+2+3+4+5 and so on. > I will have multiple lists to deal with, larger and smaller. > Any help or ideas will be appreciated > > Thanks > Bryan Webb This code might help you: http://tor.dhs.org/~zephyrfalcon/snippets/source/338.py http://tor.dhs.org/~zephyrfalcon/snippets/source/298.py N.B. I do not maintain the snippets site anymore; you should be able to find the same code, and possibly more, at the Python FAQTS site (http://python.faqts.com). --Hans Nowak From NoSpam at NoSpam.com Mon Jan 1 17:02:01 2001 From: NoSpam at NoSpam.com (Tom) Date: Mon, 01 Jan 2001 22:02:01 GMT Subject: Electronic edition of 'The Standard Python Library' Message-ID: I tried to use my electronic copy of 'The Standard Python Library' today (Jan 1), but was unable to. It is possible that I did something wrong - I have no idea - but I would caution anyone else who might be considering buying this. The book is fine, but the format is a complete hassle. You pay your money, but you don't really get the book. I have nothing against the author trying to make money from his work - I just don't like it when copy protection schemes impede the ligit use of the product (usually software) to such an extent. Is there any other book like it (ie. the standard library with sample code)? Tom. From pj at sgi.com Fri Jan 12 23:26:53 2001 From: pj at sgi.com (Paul Jackson) Date: 13 Jan 2001 04:26:53 GMT Subject: Speed of Python vs. Perl References: Message-ID: <93oled$o48b3$1@fido.engr.sgi.com> Tim wrote |> Talk someone into writing a patch; I've got no bandwidth to spare. See another branch of this news thread for a patch (both 1.5.2 and 2.0 variants). Me thinks this (getting startup time competitive with Perl) is a hard problem, and that the two tweaks in my patch help, but not greatly. The combination of the dynamic nature of Python, with having much of its run time library support loaded from Python code, not compiled in, would seem to force Python to do upwards of 10 million instructions on startup. I don't see anyway around this. -- I won't rest till it's the best ... Manager, Linux System Software Paul Jackson 1.650.933.1373 From vivatexas at thesimpsons.com Thu Jan 18 18:28:06 2001 From: vivatexas at thesimpsons.com (TonyB in VA) Date: Thu, 18 Jan 2001 18:28:06 -0500 Subject: Python training on east coast? References: <3a6711b0.2563646@news.laplaza.org> Message-ID: <9CCE84644311D495.D97124594C5FF211.CC807CD25C59DBB5@lp.airnews.net> On Thu, 18 Jan 2001 15:59:02 GMT, xyzmats at laplaza.org (Mats Wichmann) wrote: >On Thu, 18 Jan 2001 14:45:43 GMT, Robert L Hicks > wrote: > >>Are there any Python training courses on the east coast? > > >See http://www.learningtree.com/us/ilt/courses/430.htm > >Classes are regularly scheduled in Washington D.C., New York and >Boston. >Mats Wichmann > >(Anti-spam stuff: to reply remove the "xyz" from the >address xyzmats at laplaza.org. Not that it helps much...) And let me the first to say, having just taken this course in the DC area, it is really first rate. Course material was comprehensive, and complete. The instructor really new the material, and was able to make the time fly. I now have 2 co-workers who are looking at taking the class. I highly recommend this class to call. TonyB in VA From NOSPAM at pacificnet.net Thu Jan 18 18:22:46 2001 From: NOSPAM at pacificnet.net (Ian L) Date: Thu, 18 Jan 2001 23:22:46 GMT Subject: generating simple graphs and chart images in python Message-ID: Hey, Could anyone point me in the right direction as to how i can generate some simple graphs dynamically in python? I want to make something like a bar graph, or line graph? From news at dorb.com Sat Jan 27 17:20:01 2001 From: news at dorb.com (Darrell) Date: Sat, 27 Jan 2001 22:20:01 GMT Subject: wxPython activexwrapper_IE installer Message-ID: Tried to use Gordon's installer with the wxPython demo activeXwrapper_IE I'm stuck on this exception. Any ideas? Traceback (most recent call last): File "iep.py", line 184, in ? frame = TestFrame() File "iep.py", line 175, in __init__ self.tp = TestPanel(self, sys.stdout, self) File "iep.py", line 41, in __init__ self.ie = theClass(self, -1, style=wxSUNKEN_BORDER) File "d:\python20\wxpython\lib\activexwrapper.py", line 106, in axw__init__ self._eventBase.__init__(self, self._dispobj_) File "win32com\gen_py\EAB22AC0-30C1-11CF-A7EB-0000C05BAE0Bx0x1x1.py", line 310 , in __init__ cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) ValueError: argument is not a COM object This is for a tool to run on an intranet. The idea being much of the main app runs on the server. But provide a client side interface with the advantages of HTML and wxPython. Thanks --Darrell From ykingma at accessforall.nl Wed Jan 17 10:50:20 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Wed, 17 Jan 2001 16:50:20 +0100 Subject: Jython on the AS/400 (was: Python and Industry, IBM I'm afraid) References: Message-ID: <3A65BF36.27128C07@accessforall.nl> Simon Brunning wrote: > > > From: Simon B. [SMTP:sbrunning at bigfoot.com] > > Now, a Jython port is a bit more likely - the '400 comes with what I'm > > told is a very good JVM. I've not had any sucess getting it to work > > just yet, but I keep trying. If I ever do get it going, c.l.py will be > > the first to know... > > OK, I have Jython working on my AS/400 now - using beta 2. If anyone wants > details of how I did this, give me a shout. > > It's not ready for showtime yet, though. For a start, the os module doesn't > seem to be working, which is no surprise, really. I'll try to look into > that. > The os module is implemented as javaos, ie. the OS facilities that are available in Java. As Java is a basically a common denominator in that area, there is less that you can expect from each OS individually. > The other thing is that I'm having problems passing byte arguments: > > >>>myInStream.read(27) > Traceback (innermost last): > File "", line 1, in ? > TypeError: read(): 1st arg can't be coerced to byte[] > > Any tips on this one, anyone? (Jython tries to convert 27 to a Java byte array, ie. byte[]. You might be able to do that in C, but even then I wouldn't recommend it unless you are writing a boot loader or sth like that.) The read() method needs a byte array argument. Check the Jython documentation on how to do that from Jython: http://jython.sourceforge.net/docs/jarray.html Also, you might want to cross post to one of the Jython mailing lists. Have fun, Ype Kingma -- email at xs4all.nl From moshez at zadka.site.co.il Fri Jan 19 08:57:59 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Fri, 19 Jan 2001 15:57:59 +0200 (IST) Subject: Finding source from class or instance? In-Reply-To: <946dsv0qs@news2.newsguy.com> References: <946dsv0qs@news2.newsguy.com>, <979777210.145620@sj-nntpcache-5> Message-ID: <20010119135759.8154FA83E@darjeeling.zadka.site.co.il> On Thu, 18 Jan 2001 10:42:32 +0100, "Alex Martelli" wrote: > There is a dis module, that does 'disassembly' of bytecode, but > that's lower-level than the Python source you seek, and also > seems to apply only to _methods_ defined in a class rather than > to the code in the classbody itself (offhand, I don't know how > to get to the codeobject for the latter -- anybody...?). AFAIK, you can't. The code is executed, and then forgotten. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From robin at jessikat.fsnet.co.uk Thu Jan 4 07:55:58 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 4 Jan 2001 12:55:58 +0000 Subject: WIN2K batch problem Message-ID: I'm trying to run Zope 2.2.2 under win2000 in a batch file. I'm just watching error messages and prints. I find that when zope has written a page to the cmd.exe window it locks further prints from python until I hit a key in the window and then it releases another page full. Is there a Win NT/2K guru who knows about such things and how to prevent this? -- Robin Becker From dalke at acm.org Sat Jan 6 12:32:19 2001 From: dalke at acm.org (Andrew Dalke) Date: Sat, 6 Jan 2001 10:32:19 -0700 Subject: 2001 Enchancement Wishlist References: <3A4CEACB.220998A0@javanet.com> <92j83r13gh@news1.newsguy.com> <20001231175940.A5435@xs4all.nl> <008301c07501$c036ae40$43931497@martelli> <20010104165116.F2467@xs4all.nl> <008601c07675$0adf2020$102b2bc1@cadlab.it> <20010104203232.P402@xs4all.nl> <006801c0769b$ac0cc3a0$9d8a1a97@martelli> <20010105110459.Q402@xs4all.nl> Message-ID: <937l3u$gbi$1@slb2.atl.mindspring.net> Alex Martelli: >Recognizing (e.g.) a "def __setattr__" at module-level as providing >a similar function to a similarly-named method in a class instance >would (in my opinion) not 'complicate' the Python language: it would >just extend an already-existing concept (which currently only applies >to class-instances, and modules coded in C) to some more objects >(to wit, modules coded in Python). It would just add a modest amount >of functionality at an even more modest conceptual cost. I wrote a system once which proxies local functions to a remote machine. It only used strings, floats and ints so pass by copy worked and I used pickle. The idea was that I wanted to do something like import remote remote.proxy("math", remote.RshConnection("other.machine")) import math math.cos(0.0) I wanted module level __getattr__ and __setattr__ to do this but found I could implement remote.proxy as class Proxy: def __init__(self, (to_remote, from_remote)): self.to_remote = to_remote self.from_remove = from_remote # ask the remote server for a list of all constants # and their values. # ask the remote server for a list of functions ... def __getattr__(self, key): # if it is a constant, return the value # if it is a function, return a __call__ able proxy wrapper # else raise an AttributeError def proxy(module_name, connection): import sys proxy = Proxy(...) sys.modules[module_name] = proxy In other words, what you import doesn't need to be a module. It can be a class instance instead - or any other data type. This makes it possible to emulate the module __getattr__ behaviour without changing the definition of a module. I suppose a modified import could also be written to wrap every module inside of a proxy instance that forwards calls to the underlying module, and forwards __getattr__/__setattr__ calls to the appropriate function. Andrew dalke at acm.org From SBrunning at trisystems.co.uk Fri Jan 5 05:46:17 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 5 Jan 2001 10:46:17 -0000 Subject: 2001 Enchancement Wishlist Message-ID: <31575A892FF6D1118F5800600846864D5B169B@intrepid> > From: Fredrik Lundh [SMTP:fredrik at effbot.org] > (better make it short, before someone plonks me for using > words that have more than one meaning ;-) /F, Good Lord, I hope you don't mean me! I was pointing out the multiple meaning thing 'cos I wanted to see if it would point that interminable thread in a more constructive direction. It seemed to kill it stone dead, instead - very nearly as good! I'm on this list to learn - plonking you would be foolish indeed! 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 lawter at codefab.com Tue Jan 16 16:07:29 2001 From: lawter at codefab.com (John Lawter) Date: Tue, 16 Jan 2001 16:07:29 -0500 Subject: Using PyParser_ParseFile ? Message-ID: Hi I'm having some trouble re-using PyParser_ParseFile(). I'm trying to use it to get a parse tree from a Python Module. I am calling it like: Node *n = PyParser_ParseFile(fp, filename, &_PyParser_Grammar, 257, (char *)0, (char *)0, &err); which I think is correct. When I traverse the tree it returns, all the node types are the values from token.h, not the values from graminit.h; I was expecting the latter, so I could use "TYPE(n) == funcdef" as in compile.c. Obviously, there's something I've missed. Could anyone shed some light on this ? From ryant at thawte.com Tue Jan 16 10:09:22 2001 From: ryant at thawte.com (Ryan Tracey) Date: Tue, 16 Jan 2001 17:09:22 +0200 Subject: URL replacement in text References: <3A5F2A5A.494023BF@thawte.com> <8qH76.14451$Im.109356@e420r-atl1.usenetserver.com> Message-ID: <3A646422.569C5EC@thawte.com> Thanks for the example Fredrik. Steve, thanks for the caution. Much obliged. Cheers, Ryan > "Fredrik Lundh" wrote in message > news:MrG76.5696$Qb7.794378 at newsb.telia.net... > > Ryan Tracey wrote: > > > Can anybody point me in the right direction on this one. I'd like to > > > pass a block of plain text (string) to a function and have that function > > > look for URLs and turn them into HTML URL tags > > > > import re > > > > links = re.compile("(?:http|ftp|gopher):[a-z0-9._~/%-]+") > > > > def fixlink(m): > > href = m.group(0) > > return "%s" % (href, href) > > > > sometext = """ > > here's a link: http://www.pythonware.com > > """ > > > > print links.sub(fixlink, sometext) > > > > Hope this helps! > > > > Cheers /F > > > Tracey: > > Note that this won't cope with some of the more pathological URLs (such as > those with CGI arguments [http://system/cgi?arg1=val1] or those which link > to a named anchor in the target page [http://system/pageref#target-name]). > > Since it's about six times better that anything I could do, however, let > this act as a caution rather than a correction. > > i-like-to-look-at-examples-too-but-avoid-re-when-I-can-ly y'rs - steve -- Ryan Tracey Thawte Certification From moshez at zadka.site.co.il Tue Jan 30 12:05:45 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: 30 Jan 2001 11:05:45 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jan 30) Message-ID: Moments too late for last week's Python-URL!, Guido announces Python 2.1a1 http://deja.com/=dnc/getdoc.xp?AN=719153679 available at http://sourceforge.net/project/showfiles.php?group_id=5470 Tim Peters explains why "if key in dict:" is a good idea for Python 2.1 http://deja.com/=dnc/getdoc.xp?AN=721332761 why function attributes are good http://deja.com/=dnc/getdoc.xp?AN=720829036 why windows beep sounds the same no matter what the frequency is http://deja.com/=dnc/getdoc.xp?AN=720041274 Alex Martelli explains how to use Python for web serving http://deja.com/=dnc/getdoc.xp?AN=719248281 implements a Pythonic boolean xor http://deja.com/=dnc/getdoc.xp?AN=720595249 Fredrik Lundh gives an example of sophisticated search-and-replace http://deja.com/=dnc/getdoc.xp?AN=719079807 Bryan Mongeau announces an implementation of AES for Python http://deja.com/=dnc/getdoc.xp?AN=720935577 Tim O'Malley announces a timeoutsocket that works with Python 2 http://deja.com/=dnc/getdoc.xp?AN=719743512 Sean Reifschneider announces SRPMS for Python 2.1a1 http://deja.com/=dnc/getdoc.xp?AN=720611564 Mark Pilgrim plugs his free Python teaching book http://deja.com/=dnc/getdoc.xp?AN=721660836 Albert Hopkins announces a list of Python IDE http://deja.com/=dnc/getdoc.xp?AN=719447661 Dr. David Mertz enhances the list a bit http://deja.com/=dnc/getdoc.xp?AN=719573413 Barry Warsaw announces mimelib http://deja.com/=dnc/getdoc.xp?AN=720274419 Carel Fellinger implements Observer pattern http://deja.com/=dnc/getdoc.xp?AN=719506967 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://deja.com/group/comp.lang.python.announce Andrew Kuchling writes marvelous summaries twice a month of the action on the python-dev mailing list, where the future of Python is truly determined http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From msoulier at storm.ca Sun Jan 14 15:30:38 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Sun, 14 Jan 2001 20:30:38 GMT Subject: reading line by line References: Message-ID: In article , Fredrik Lundh wrote: >The standard pydiom is: > > while 1: > line = file.readline() > if not line: > break > ... > >In the current cvs version, you can also use: > > for line in file.xreadlines(): > ... > >where xreadlines is a lazy version of readlines (cf. xrange) Excellent, thank you. Mike -- Michael P. Soulier "...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 PGP Public Key: http://24.43.42.96/email.phtml From aleaxit at yahoo.com Sat Jan 20 18:30:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 21 Jan 2001 00:30:11 +0100 Subject: Translating a Perl script into Python References: <94d4hk$1sq$1@animus.fel.iae.nl> Message-ID: <94d721022sp@news2.newsguy.com> "Carel Fellinger" wrote in message news:94d4hk$1sq$1 at animus.fel.iae.nl... [snip] > and yet in some circumstances even the more elaborate variant > > PROC.write("%(key)s = %(value)s\n" % {key:key, val:os.environ[key]}) > > The latter form comes very close to the Perl way of coding, and > is espescially suited for format strings spanning several lines. I think this is error-prone, though -- the dictionary after the % would have to be coded as {'key':key, 'value':os.environ[key]}. Alex From dsh8290 at rit.edu Sat Jan 20 14:36:34 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 20 Jan 2001 14:36:34 -0500 Subject: Python and Industry, IBM I'm afraid In-Reply-To: <946evt02mr@news2.newsguy.com>; from aleaxit@yahoo.com on Thu, Jan 18, 2001 at 11:01:10AM +0100 References: <3A63D9E8.F9B74ACE@mjs400.co.uk> <941c14$dok$1@nnrp1.deja.com> <946evt02mr@news2.newsguy.com> Message-ID: <20010120143634.A8553@harmony.cs.rit.edu> On Thu, Jan 18, 2001 at 11:01:10AM +0100, Alex Martelli wrote: | "D-Man" wrote in message | news:mailman.979786609.2939.python-list at python.org... | [snip] | > I have a part time job at a local grocery store that has a | > video department. The computer system they use is an IBM | > mainframe with AIX (4 I think). What is the language that the | > software is most likely written in (earliest copyright on it | > is late '80s, around the time the ANSI C standard was | > published)? COBOL or C (or some other language)? | | Hard to say without more data, but, since AIX is and always | was a Unix flavour, C is your most likely bet (but, of course, | just about any language is available for Unix). | | Late-'80s AIX was a VERY different (still Unix-flavoured) | beast from the later AIX 4, and AFAIK it was not practically [snip] I checked again, the system is running AIX 4.2. The terminals are 3515, but I don't think that helps much. [snip] | not really surprise me much:-). As I recall, its main | "here's our horrible surprise of the day for you" feature | was a malloc that would never return 0 even if you asked | it for FAR more memory than you had around -- rather, the | program died horribly later when it actually tried to USE Ugh! | the memory it THOUGHT it had allocated... a "designed-in | feature", they adamantly insisted, NOT a bug (later I [snip] People actually design a system to prevent proper error handling in applications? I'm glad I haven't had to develop on it (yet). I had thought that it would be C, but I wasn't considering COBOL. When someone mentioned the difficulty in finding a C compiler for AS/400 systems (ok, I don't actually know what hardware this mainframe is) I began to doubt my original assumption. It's a horribly broken program anyways. It can no longer calculate the late fees correctly. The company has the bad habit of changing policy long /before/ changing the software. Coupons almost never scan at the correct value -- the value is usually dependent on what is being purchased but the software uses a simple (maybe not) table lookup so a single price is hard-"coded" in. There is also a program that if you rent a certain number of videos, you get a free rental. The computer used to keep track of it. When the updated the system to allow expiration dates beyond 12/31/99 they broke the counter (this was /before/ the New Year too!). For a couple months the counter would randomly count up, down, or stay the same. Since then they have reverted to punch cards the customer must keep track of. I really wish they would redesign the system to meet the current requirements! (I imagine, and sincerely hope, that it met the requirements when it was originally installed) -D From SBrunning at trisystems.co.uk Mon Jan 8 06:56:38 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 8 Jan 2001 11:56:38 -0000 Subject: rstrip vs. champ (was: python-dev summary, Dec. 16-31) Message-ID: <31575A892FF6D1118F5800600846864D5B16AD@intrepid> > From: A.M. Kuchling [SMTP:akuchlin at mems-exchange.org] > People have suggested adding a chomp() function that performs the same > task as the Perl built-in: it removes the trailing newline from a > string. > > http://sourceforge.net/patch/?func=detailpatch&patch_id=103029&group_id=54 > 70 > > Reaction was mixed: Moshe liked it, but others thought that the > existing rstrip() method, which removes *all* whitespace from the end > of a string, is sufficient. It would be even better if rstrip (and its siblings strip & lstrip) took an optional argument specifying which characters to strip... 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 grey at despair.rpglink.com Mon Jan 29 11:30:03 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Mon, 29 Jan 2001 16:30:03 -0000 Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> Message-ID: On Mon, 29 Jan 2001 08:35:42 -0600, Grant Griffin wrote: >It helps me when reading code (even my own) to be reminded of the difference. >(I am the proud owner of a skull of strictly limited size.) One too many trips to the south pacific, I take it? :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From tim.hochberg at ieee.org Tue Jan 9 10:18:27 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Tue, 09 Jan 2001 15:18:27 GMT Subject: string escaping problems with MySQLdb References: <93f2cr$ofq$1@news2.dtag.de> Message-ID: <7ZF66.128944$15.27235477@news1.rdc1.az.home.com> The mysterious BxT spake thusly: > Hi, i know this is a new-bie question, > i'm using MySQLdb and, as i'm extracting records, i get string escaped as > follows: > for example, instead of ? i'm getting \\337 (yes, with doppel \). When i'm > printing the string i'm getting blah\337 (internally is blah\\337). The string you are getting only has a single '\', it is displayed with two because a "\337" is the escape code for the beta symbol. Hmmm, that's not very clear, I suggest you peruse the manual and or play around till this becomes clear. However, the difference you are seeing the string displayed in the interpreter and the string printed is that printing formats stuff using the str function, while in the interpreter repr is used. >I tried > to use string.replace but it's giving me the same string. Is there a way to > print blah?? I'm sure there's a better way, but: import re print re.sub(r"\\(\d\d\d)", lambda x : chr(int(x.group(1),8)), myString) or more clearly: escapedOctal = re.compile(r"\\(\d\d\d)") def matchToChr(match): n = int(match.group(1), 8) return chr(n) print re.sub(escapedOctal, matchToChr, myString) I'll let you figure out how that actually works.... -tim From ckalista at realproject.be Mon Jan 15 05:54:38 2001 From: ckalista at realproject.be (Kalista Christophe) Date: Mon, 15 Jan 2001 11:54:38 +0100 Subject: ALARM on windows? Message-ID: <93ukvl$cdp$1@news0.skynet.be> I'm having trouble handling SIGALRM under windows! I'd like to do the following : A python script listens to port 6664(for example). When it gets a connection, it then sets an alarm handler and then tries to read from the socket. If it does not get data within 10 seconds, it then times out, at which point the alarm handler throws an axception and aborts the socket read. The problem is that I don't know how to handle signals under WINDOWS. Any ideas? Thanks in advance. Kalis. From hansboehm at my-deja.com Wed Jan 31 13:53:24 2001 From: hansboehm at my-deja.com (hansboehm at my-deja.com) Date: Wed, 31 Jan 2001 18:53:24 GMT Subject: Python vs Ruby References: <20010129111820.C15924@harmony.cs.rit.edu> Message-ID: <959mv0$qke$1@nnrp1.deja.com> In article , "Tim Peters" wrote: > [Neil Schemenauer] > > RC also works quite well with data caches and VM managers. Using > > the Boehm-Demers GC with Python and disabling reference counting > > slows the interpreter down by a significant amount. > Are you sure the collector is working correctly, and not retaining garbage for some reason? I looked at the source tree quickly, and it appeared to me that the interpreter maintained a doubly linked list of all Python objects? That would effectively keep the collector from reclaiming anything. Is that list essential? When I last looked at this 4 or 5 years ago, there were some other issues that prevented a direct plug-in of a tracing collector. I think some subsystems did their own free-list management. This tends to be a pessimization with a tracing GC, especially if the objects on the free list still point to other long-dead objects, etc. I couldn't find such issues now, but I didn't look very hard. You can probably get a good idea whether any of these are an issue by building the collector without -DSILENT, and looking at the amount of reachable memory it found. ... > Thanks to refcounting, the storage for "s" is reclaimed on each iteration, > and overwhelmingly most iterations manage to reuse the storage left behind > from a preceding iteration. As Neil said, that's very cache-friendly. > Without refcounting, you're likely to stomp on new memory addresses each > iteration until some limit is reached, then gc will go lurching all over a > large blob of memory at least once (possibly more) cleaning it up. That's > cache-hostile. True, although there are some tricks you can play to reduce the effect. See http://www.hpl.hp.com/techreports/2000/HPL-2000-99.html (also in the ISMM 2000 Proceedings). Much of the remaining cost is that with reference counting (or malloc/free style memory management) you often get to allocate memory that's already in the cache. With a M/S GC, you usually don't. On the other hand, reference counting is also rather cache-unfriendly, in a different way. Assigning a reference now needs to touch both the previously referenced and the newly referenced object, which are very unlikely to be on the same cache line. And both lines are dirtied, so they will need to be written back when they are replaced. Reference counting tends to look considerably worse if you fully support concurrency, so that you have to update reference counts with atomic operations. But in my experience it rarely wins for small objects even in the single-threaded case. (It can win for large objects, or if you are very tight on space, so that you would have to collect too often.) > > Python has extremely high dynamic memory throughput, because *nothing* is > exempted from the "everything's an object, and all objects are > heap-allocated" scheme. Mark-&-sweep-- and especially simple M&S --is > happier with modest rates of memory turnover. I agree that reference counting looks relatively better with a high allocation to pointer assignment ratio. But I would also claim that there are some high allocation rate programs for which mark/sweep is clearly the winning strategy, e.g. if you repeatedly build a large data structure, traverse/tweak it a few times, and then drop it. If you mostly allocate very short-lived objects, copying generational collectors are hard to beat. ... Hans Hans_Boehmhpcom Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Sat Jan 27 06:38:35 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 27 Jan 2001 11:38:35 GMT Subject: Python vs Ruby References: <94mdkd$222e$1@news.adamastor.ac.za> <94pvd8$3g$1@nnrp1.deja.com> Message-ID: <%qyc6.9474$Qb7.1381390@newsb.telia.net> andrew wrote: > Hrm... In the Jones/Lins book on garbage collection, section 2.1 and > chapter 3 are on reference counting, and they refer to it as "one of > the classial garbage collection algorithms", which settles the matter > for me; clearly reference counting *is* a form of GC the GC FAQ lists reference counting under "basic algorithms", together with mark-and-sweep and copying: http://www.iecc.com/gclist/GC-faq.html Cheers /F From peter at engcorp.com Sat Jan 6 02:15:11 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 06 Jan 2001 02:15:11 -0500 Subject: variable inirialization and loop forms (was Re: why no "do : until"?) References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4D6A05.EEC97FA6@uswest.net> <92v6m002nlr@news2.newsguy.com> <3A560294.9C943D5E@ltec.net> Message-ID: <3A56C5FF.DA0C8BD8@engcorp.com> Lloyd Sommerer wrote: > > While I'm just learning Python, I was wondering if anyone knows a good reason > not to express a loop in this manner: > > T = getCurrentTemperature() > while warmEnough(T): > T = getCurrentTemperature() > > This is expressed in Alex's generalization, but I think also applies to the > original code: [snip] > I realize that written this way there is a maintainability issue. Perhaps that's > reason enough not to do it this way. Yes! That is definitely reason enough not to do it this way. The moment I catch myself writing lines that are that clearly redundant that close together, I refactor to remove the redundancy. Maintenance issues are, in my opinion, one of the most under-appreciated problems of software development. All code has to be maintained, even if it's just by the author, and even if it's just a day after the code was written. The likelihood (as shown by direct experience and long observation) of code like the above being broken by subsequent changes being made incorrectly is much higher than if the code were written without the duplicate lines. From aleaxit at yahoo.com Tue Jan 16 09:08:56 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 16 Jan 2001 15:08:56 +0100 Subject: python compiled to native in less than a year? References: Message-ID: <941koq077o@news1.newsguy.com> "jason petrone" wrote in message news:n7vv39.r1f.ln at demonseed.net... > Giuseppe Bilotta wrote: > > > Knowing M$, at least one of the following will hold : > > > 1) M$ will not cleanly document IL, making it almost impossible to know it > > appor priately; > > Actually, the IL documentation is pretty good. Assuming the MS implementation > of it follows the specification, this won't be a problem. Do you have an URL for non-microsoft sites with the IL docs, please? > > 2) M$ will patent IL, so royalties will have to be paid for its use (aka: > > bye-by e, Free Software) > > Right now MS is trying(along with HP) to get IL accepted by a standards > commitee, though I forget which one. If this happens, there won't be a patent > problem. However, MS also tried to put ASF on the standards track, but gave > up and went the patent route instead, so who knows. What's ASF? Also, _are_ patents incompatible with standards? I thought, for example, the MPEG group did standardize on a patent-covered format for the now-very-popular MP3 files, and indeed some German public-sector body is now trying to cash in on the patent they hold. So what might stop MS from getting a patent _after_ some standards group (ECMA maybe?) blesses their IL. Not trying to fuel paranoia -- I'd *love* it if a standard did emerge for a bytecode such as IL -- just trying to understand... Alex From mike at skyweb.ca Wed Jan 31 21:22:47 2001 From: mike at skyweb.ca (mike) Date: Wed, 31 Jan 2001 20:22:47 -0600 Subject: serial port Message-ID: <3a78ca89_2@skyweb.ca> is there any modules for serial port communication? From kwoeltje at mail.mcg.edu Tue Jan 16 18:30:29 2001 From: kwoeltje at mail.mcg.edu (Keith F. Woeltje) Date: Tue, 16 Jan 2001 23:30:29 GMT Subject: Problem with a tuple - newbie ignorance References: <3A633531.9010303@yale.edu> <3A635C32.9E5285C5@yale.edu> Message-ID: <3A64D9E8.B1D52E1E@mail.mcg.edu> Normal (forward) slashes won't however work in a command prompt window in Win2000. Does the python interpreter make the change "magically" (like it does the end of line marker)? >K Grant Edwards wrote: > Apparently. Forward slashes have been accepted by MS > "operating systems" since the very beginning, but I don't know > how many times I've seen people (mostly in C programs) shooting > themselves in the foot by trying to use backslashes instead. > > -- > Grant Edwards grante Yow! I want to so HAPPY, > at the VEINS in my neck STAND > visi.com OUT!! From fredrik at effbot.org Wed Jan 24 09:49:14 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 24 Jan 2001 14:49:14 GMT Subject: Random and whrandom References: <94bj03$59v$1@nnrp1.deja.com> <3a6a3540.1976549@news.xo.com> <94jkh0011gg@news1.newsguy.com> <94m9bf$nge$1@nnrp1.deja.com> <94mjv402318@news2.newsguy.com> Message-ID: Alex Martelli wrote: > What is 'rand', I don't know: the Python docs don't mention it > at all. If it ever existed It's an old emulation of C's "pick up troll or throw axe"- style generator; here's the version from 1.4: import whrandom def srand(seed): whrandom.seed(seed%256, seed/256%256, seed/65536%256) def rand(): return int(whrandom.random() * 32768.0) % 32768 def choice(seq): return seq[rand() % len(seq)] It disappeared somewhere on the way from 1.4 to 1.5.2. Cheers /F From robin at jessikat.fsnet.co.uk Mon Jan 29 17:34:40 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 29 Jan 2001 22:34:40 +0000 Subject: freebsd extension problem In-Reply-To: <20010129141823.A1010242@vislab.epa.gov> References: <20010129141823.A1010242@vislab.epa.gov> Message-ID: In message <20010129141823.A1010242 at vislab.epa.gov>, Randall Hopper writes >Robin Becker: > |I'm trying to build an extension which used to work with 1.5.2 unde > |freebsd. > | > |I seem to be able to build the extension using the old > | > |make -f Makefile.pre.in boot method and have linked to various > |libraries. However for some reason I'm getting a bad magic number error > |when trying to import the module. > | > |I assume that this is somehow caused by a missing import. Is there an > |easy way to find out what I'm missing? > >Potentially useful links below. Could be that you have an ELF python and >an AOUT module, or vice versa. Run 'file' on each to see. > >I assume these are FreeBSD binaries (not Linux under emulation). > >http://www.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=704455585 >http://www.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=704541401 > ... Thanks. The problem was exactly that. Overnight the ISP changed OS and python etc etc resulting in a good deal of confusion. Thanks for the kind thought any how. -- Robin Becker From tim.one at home.com Sun Jan 28 00:40:26 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 28 Jan 2001 00:40:26 -0500 Subject: . Python 2.1 function attributes In-Reply-To: <980659490.312565807@news.silcom.com> Message-ID: [Clarence Gardner] > I was somewhat amazed at the addition of print>>, and I assure you > that I will never use it. But since I consider Guido, et al, as > nearly godlike, Watch it there, Clarence -- I love you, but that's pretty faint praise of my boss. > and given that the last four years of my programming career have been > much more joyful than they would have been without Python, I have > magnanimously given him a pass on this issue :) At a PythonLabs meeting a few weeks ago, Guido happened to mention that, of all the new 2.0 features, "print >>" is the one he found himself using the most so far. I believe it! It's very handy. Which is, of course, why Barry fought for it so hard. would-be-more-impressed-by-the-damnation-of-people-who've-actually- tried-it-ly y'rs - tim From rcameszREMOVETHIS at dds.removethistoo.nl Thu Jan 11 07:38:51 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Thu, 11 Jan 2001 12:38:51 GMT Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> <93dde1$8d2$1@animus.fel.iae.nl> <93f3nb023mv@news1.newsguy.com> <90259DC4Arcamesz@127.0.0.1> <93i57b01qms@news2.newsguy.com> Message-ID: <90268BCE3rcamesz@127.0.0.1> Alex Martelli wrote: >"Robert Amesz" wrote in >message news:90259DC4Arcamesz at 127.0.0.1... >> >> [Snip] >> >> It also would be much easier to parse the argument list in that >> form. > >Fine, but can't be "*much* easier" -- it's just one .split away from >the 'bar=32' proposal to ('bar','32'), after all:-). Oh, allright. let's just call it a *little* easier, then. I mainly like the lispy flavour. Also, as a small extra bonus, you can use expressions with the tuple-notation. That allows you to do things like: #global constants base1 = 100 base2 = 200 #Someplace else xx = enum(('foo',base1), 'foo2', 'foo3', ('bar',base2), 'etc') Of course, you can always eval() the right hand part of 'foo=base1', but the other form catches any syntax errors in those expressions before the program actually runs. Robert Amesz From rickylee at americasm01.nt.com Thu Jan 18 20:41:41 2001 From: rickylee at americasm01.nt.com (Lee, Rick) Date: Thu, 18 Jan 2001 20:41:41 -0500 Subject: MAC IDE & Debugger References: Message-ID: <3A679B55.BE95A2AA@americasm01.nt.com> I think it does have colored syntax highlighting. In any window, at the right hand side near the top, there is a right-arrow button; try clicking on that; it actually expands into a menu. You will find all kinds of neat things in that menu. My gripe is that there is no way to tell its editor to automatically expand tab keystroke to 4 spaces. Most of the files that I am working with come from other people, who use 4 space indent convention. - Rick Robert L Hicks wrote: > I really like the MAC version of the Python IDE and Debugger...even over > IDLE. > > I only wish that it had basic (bolding maybe) syntax highlighting. > > Bob From vmarkwart at my-deja.com Thu Jan 18 17:24:35 2001 From: vmarkwart at my-deja.com (vmarkwart at my-deja.com) Date: Thu, 18 Jan 2001 22:24:35 GMT Subject: Access, Field names, mxODBC References: <947ods$uk4$1@nnrp1.deja.com> Message-ID: <947qen$p8$1@nnrp1.deja.com> I have just discovered cursor.description, which solves my problem. Cheers Victor Sent via Deja.com http://www.deja.com/ From phrxy at csv.warwick.ac.uk Sun Jan 28 14:14:07 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Sun, 28 Jan 2001 19:14:07 +0000 Subject: PyMacs vs. Pym (was: Pyditor, Text editor fully extendible in python a la' Emacs) In-Reply-To: <0O7zTzsxerl5-pn2-xdzE56cler1k@bill> References: <20010127193848.59d0f64b.ngreco@softhome.net> <950k0f01tco@news2.newsguy.com> <0O7zTzsxerl5-pn2-xdzE56cler1k@bill> Message-ID: On 28 Jan 2001, William Sonna wrote: > On Sun, 28 Jan 2001 08:06:49, "Alex Martelli" > wrote: > > > "Nahuel Greco" wrote in message > > news:mailman.980638952.20592.python-list at python.org... > > [snip] > > > > By the way, my ideal text editor will also keep my coffee cup full of > > warm, > > > > fresh Expresso while I'm working. Haven't found one yet that can do > > that, > > [snip] > > > > I'll have to insist on the java (small j) support... no, you're wrong: you want M-x global-auto-brew-mode John From DavidLNoNOSpammy at raqia.com Fri Jan 12 14:30:18 2001 From: DavidLNoNOSpammy at raqia.com (David Lees) Date: Fri, 12 Jan 2001 14:30:18 -0500 Subject: Thanks got the e-mail address References: <3A5E05F9.253D2E62@raqia.com> Message-ID: <3A5F5B4A.45A4F63C@raqia.com> Thanks Robert and Brad for sending me Doug's contact info. david David Lees wrote: > > I am trying to locate Doug Hellmann who wrote a Python code for > generating input to the graph display package daVinci. The e-mail on > his code (from January 1998) is doughellmann at mindspring.com , but it is > now defunct. If anyone knows him could you pass on my e-mail address > which is: > > davidl at raqia.com > > Thanks, > > David Lees From Kimmo.Paakkonen at helsinki.fi Tue Jan 30 09:36:21 2001 From: Kimmo.Paakkonen at helsinki.fi (Kimmo =?iso-8859-1?Q?P=E4=E4kk=F6nen?=) Date: Tue, 30 Jan 2001 16:36:21 +0200 Subject: MMTK and Scientific python for NT 4.0 Message-ID: <3A76D165.348D5C2A@helsinki.fi> Hi, is there a precompiled version of MMTK and Scientific Python for Windows NT 4.0 somewhere? I found older binaries from site http://starship.python.net/crew/kernr/binaries/Binaries.html but those were linked against Python 1.5, and I'm using Python 2.0. I also noticed that in that page the versions of the MMTK and Scientific Python are older than in their FTP sites (those new versions seem to support threading, and I have 2 processor on my NT machine :). If there are no such binaries, are there some instructions how to compile them for NT? I have the free Borland 5.5 compiler, and I have made couple of extensions with it (with the very nice help from http://www.cyberus.ca/~g_will/pyExtenDL.shtml ), but building MMTK extensions seems confusing, as I don't have experience of compiling bigger projects. Any help appreciated!! Kimmo P??kk?nen Kimmo.Paakkonen at helsinki.fi From debl at NONOSpammytheworld.com Mon Jan 8 00:50:54 2001 From: debl at NONOSpammytheworld.com (David Lees) Date: Mon, 08 Jan 2001 05:50:54 GMT Subject: ActivePython Installer for 2.0? Message-ID: <3A595540.9D34A5AA@NONOSpammytheworld.com> I just tried uninstalling and reinstalling Python 2.0 (I broke something in IDLE). I first downloaded the ActivePython2.0.0.202.msi When I double click on it I get a message that says I need a newer version of the Windows Installer service? I am using Win98SE. What do I need to get this '.msi' extension to install? Anyway, I am up and running again by downloading BeOpenPython2.0 and Mark Hammonds Win32all-135. However, it would be handy for new machines to use the single Active Python. Thanks in advance. David Lees From derek at realware.com.au Wed Jan 17 19:23:51 2001 From: derek at realware.com.au (Realware Systems) Date: Thu, 18 Jan 2001 10:23:51 +1000 Subject: Regular expressions Message-ID: Hi, I have been looking at the docs at python.org but I must be missing something. I cannot find an example of how to set up a regular expression. I would like to know how to 1. set up an RE 2. apply it to a string (to just perform a match) 3. apply it to a string to perform a replacement 4. how to join RE's If any one can help I would much appreciate it Thanks in advance Derek P.s the docs at python.org seem quite good as a reference but they do not provide examples of use (other than the tutorial and this is limited) does any one know of a site with good examples for a beginner. I have plenty of programing experience, in C/C++ some Perl + others but python is very new to me Thanks again From tolot at utolot.toppoint.de Wed Jan 17 14:31:46 2001 From: tolot at utolot.toppoint.de (Marc Christiansen) Date: Wed, 17 Jan 2001 20:31:46 +0100 Subject: Stupid Newbie References: <3A645C7B.248902E4@mdx.ac.uk> Message-ID: <2vr449.fub.ln@utolot.toppoint.de> DAVID wrote: > To run this file (spam.py), I type: > python spam.py a b c > > I get following message: > File "", line 1 > python spam.py a b c > SyntaxError: Invalid syntax > > Any ideas?? Yes. "python" is not a python command. The line you're typing works only from the commandline (DOS-Box it's called iirc). To use a module from within python you use "import modulename_without_extention". But then you can't supply parameters to the module, except by setting up argv yourself. Or you implement a function in the module which when called, does the same as the module does when called from the commandline. And take care, when you use "import" the module is read in only once, subsequent imports only create a new reference in the current namespace. To re-read the module use reload(modulename_without_extention). Ciao Marc -- Save the rainforest: Go to http://rainforest.care2.com/welcome?w=190056410 PGP-Key fingerprint EE 2E C1 06 D1 28 89 D2 F9 CE 35 7B F8 F4 42 52 Marc Christiansen 24109 Kiel From aleaxit at yahoo.com Thu Jan 18 05:01:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 11:01:10 +0100 Subject: Python and Industry, IBM I'm afraid References: <3A63D9E8.F9B74ACE@mjs400.co.uk> <941c14$dok$1@nnrp1.deja.com> Message-ID: <946evt02mr@news2.newsguy.com> "D-Man" wrote in message news:mailman.979786609.2939.python-list at python.org... [snip] > I have a part time job at a local grocery store that has a > video department. The computer system they use is an IBM > mainframe with AIX (4 I think). What is the language that the > software is most likely written in (earliest copyright on it > is late '80s, around the time the ANSI C standard was > published)? COBOL or C (or some other language)? Hard to say without more data, but, since AIX is and always was a Unix flavour, C is your most likely bet (but, of course, just about any language is available for Unix). Late-'80s AIX was a VERY different (still Unix-flavoured) beast from the later AIX 4, and AFAIK it was not practically used on mainframes at the time (there _was_ an AIX/370, or something like that, that you *could* run on mainframes, but it didn't sell much at all); AIX 3.2 was the OS for the IBM 6150 workstation (here in Italy it did sell reasonably well, including many used to run our CAD software of the time on -- just 2D, back then -- but I don't think it was much used for grocery stores' video departments:-). AIX 4 came out in the early '90s (I remember the trips to the heavily secured IBM location where the only not-yet- announced workstation running AIX 4 was kept -- that's where we had to go to port our software so it would be announced together with the new machine and OS... as I was freshly moved to this CAD software firm after many years with IBM Research, the paranoia-level security did not really surprise me much:-). As I recall, its main "here's our horrible surprise of the day for you" feature was a malloc that would never return 0 even if you asked it for FAR more memory than you had around -- rather, the program died horribly later when it actually tried to USE the memory it THOUGHT it had allocated... a "designed-in feature", they adamantly insisted, NOT a bug (later I did meet some BSD variants with this wonderful 'feature' too -- never did I really understand WHY one would play such a trick to poor application programs...!); that accounted for well over half of our porting woes to that specific box/OS. Later, they did relent and allow some ways to bypass the 'malloc never fails' feature. Not that this helps determining the unknown application language used where you work, of course, but, it's good to keep these things in mind when complaining about today's porting difficulties -- they aren't NEW problems...!-). Alex From grey at despair.rpglink.com Wed Jan 3 10:53:36 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Wed, 03 Jan 2001 15:53:36 -0000 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <3A4F4B4D.ECD6B172@engcorp.com> Message-ID: On Wed, 03 Jan 2001 14:45:29 GMT, Grant Edwards wrote: > if (whatever) { > do something; > do something else; > } else { > yet another thing; > } >I simply can't read read code like that, and generally do an >'indent -gnu' on it before I try to figure out what's going on... I normally do a variation of this. if (whatever) { do something; do something else; } else { yet another thing; } This is so the ending brace is lined up with what it is ending. The { else } in the middle of the K&R ruins that. How does a } close a } !?!?!? In the one I write we see an if closed and an else closed. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From phd at phd.pp.ru Wed Jan 24 05:44:55 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 24 Jan 2001 13:44:55 +0300 (MSK) Subject: thread In-Reply-To: <3A6EADD6.11122913@acriter.com> Message-ID: On Wed, 24 Jan 2001, Johan Jonkers wrote: > At the company I work we use python 1.5.2 on Solaris. I made a python > script on my home computer running linux (same python version btw), but > when I tried it at work it couldn't find the thread module. I thought > that the thread module was a standard module? Am I wrong in this? It is builtin (compiled from C) module. May be it just hasn't been compiled in. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From rschlack at my-deja.com Tue Jan 16 12:08:19 2001 From: rschlack at my-deja.com (rschlack at my-deja.com) Date: Tue, 16 Jan 2001 17:08:19 GMT Subject: how can I get the current url Message-ID: <941v5r$ubl$1@nnrp1.deja.com> Please help. I have 4 domains pointing to the same IP. I want my index.html page to determine the current domain so that I can change the headers and footers accordingly. I am new to python and have no idea how to do this. I am trying to change the headers and footers on our Ultraseek software. thanks, Rob Sent via Deja.com http://www.deja.com/ From sheila at spamcop.net Sat Jan 20 02:13:25 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 20 Jan 2001 07:13:25 GMT Subject: Translating a Perl script into Python References: Message-ID: On 20 Jan 2001 09:05:23 +0200, Erno Kuusela wrote in comp.lang.python in article : :In article , Sheila King : writes: :| slurp = sys.stdin.read() :| qmail = ["SENDER", "NEWSENDER", "RECIPIENT", "USER", "HOME", "HOST", "LOCAL", :| "EXT", "EXT2", "EXT3", "EXT4", "DTLINE", "RPLINE", "UFLINE"] :| try: :| PROC = open("proc.test","w") :| except: : :it's usually a bad idea to have a blanket "except:" statement, :because it might mask other errors in your code. :in this case i'd use : except (IOError, OSError), why: : sys.exit('Couldn't write file: %s' % why) : :sys.exit(), if supplied with a string, will print it to :stderr and exit with status 1. Thanks. I guess, I was kind of wondering about the comparison to the Perl command, which is pretty common for opening files in Perl: open PROC, ">proc.test" || die "Couldn't open file for write: $!"; Is the closest I can get in Python, to a Perl "die" statement, is to use exceptions? (I'm directing this to the group, not just Erno, as I realize he may not know Perl. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From danielk at aracnet.com Mon Jan 29 09:01:59 2001 From: danielk at aracnet.com (Daniel Klein) Date: Mon, 29 Jan 2001 06:01:59 -0800 Subject: biggner question References: <952951$m4r1@news.qualitynet.net> Message-ID: On Sun, 28 Jan 2001 20:28:09 +0300, "baasad" wrote: >how can I read from the command line Look in the Python documentation for the 'python' command as well as 'sys.argv'. >also how can I read users input :) myinput = raw_input("What's new?") Daniel Klein From murple at my-deja.com Mon Jan 22 05:01:13 2001 From: murple at my-deja.com (murple at my-deja.com) Date: Mon, 22 Jan 2001 10:01:13 GMT Subject: Python 2.0 parser module bug(?) and a Q References: Message-ID: <94h0d7$5vb$1@nnrp1.deja.com> Hi, > > A colleague of mine has an "unparser" module for Python AST; that is > > not (yet) released to the public, and works not (yet) for 2.0. I'm the colleague mentioned. My solution to the problem doesn't look as good as yours. I was rebuilding the Python-code by examining the structure of the syntax-tree. This is the reason, it's not working with Python 2.0. I was using the strings in the syntax-tree only for identifiers. Feeling a little bit stupid for not seeing this other solution. > Any constructive critisism is welcome! Ok, your wish is my command :-) I noticed two problems: 1. If you have double DEDENT, there is a '\r' left in the resulting string. This seems to be easely solved by an replace() 2. Anything like "modul.class.function" comes out as "modul . class . function". Using replace to solve this is not good, since you would replace also in wrong places. I think, here you would have to look into the structure of the syntax-tree. Maybe you have an solution for 2.? Another question is, which way is faster. You have to do more recursions, because when I find a symbol.sym_name["class_stmt"] I write a "class", you go another step to find the "class" string in the tree. On the other side, I have to do a lot more comparisons then you. Maybe after a code-cleanup I will compare the solutions. Anyway, I learned a lot about Python by doing this Unparser (as I call it). It was my first Python-program ever. And I learned a lot about Python-Syntax this way. Hope my comments help you in any way. By, Andreas Sent via Deja.com http://www.deja.com/ From keisari_ at hotmail.com Sat Jan 27 11:56:48 2001 From: keisari_ at hotmail.com (joonas) Date: Sat, 27 Jan 2001 18:56:48 +0200 Subject: Creating files. Message-ID: <3A72FDD0.2C1206CF@hotmail.com> Is there any functions in Python for creating files? Joonas. From aleaxit at yahoo.com Thu Jan 18 04:42:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 18 Jan 2001 10:42:32 +0100 Subject: Finding source from class or instance? References: <979777210.145620@sj-nntpcache-5> Message-ID: <946dsv0qs@news2.newsguy.com> "Stuart Stanley" wrote in message news:979777210.145620 at sj-nntpcache-5... > > > Folks, > > Is there a (easy!) way to get the source code from a class or instance > of a class? A preference would lie in just getting the source of the > base class itself, but I would settle for getting the file name where > the base class lives in. I figure the information is sitting in the > modules somewhere, but I don't know how to navigate there to get it.... A class object has an attribute __module__ which identifies the *name* of the module in which the class was defined; from an instance object, you can get its class object via its attribute __class__ (I'm not sure where 'the base class' comes in, but if you need a class's bases you'll want to look at the class object's attribute __bases__ which just lists them in order -- these are class objects, not names). Given the module name, you may look for the module object in dictionary sys.modules; if you do find it (it _could_ have been removed in the meantime), it MAY have an attribute __file__ which gives the path to the file the module was loaded from IF it was indeed loaded from a file (it need not have been). For 'normal' cases, then, something like: theclass = instance.__class__ modname = theclass.__module__ import sys modobj = sys.modules[modname] thepath = modobj.__file__ may give you what you want (or rather, what you would settle for). Just make sure you trap all the possible exceptions and anomalies at each step! The file named by thepath may not be around any more, of course -- it may have been erased or renamed just after it was compiled to a .pyc or .pyo, for example. Or, if it exists, it need not be the same as it was back when the class definition was executed (it may have been overwritten, and who can tell what differences may have been caused by such overwriting!). There is a dis module, that does 'disassembly' of bytecode, but that's lower-level than the Python source you seek, and also seems to apply only to _methods_ defined in a class rather than to the code in the classbody itself (offhand, I don't know how to get to the codeobject for the latter -- anybody...?). Alex From thomas at xs4all.net Fri Jan 26 16:37:07 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 26 Jan 2001 22:37:07 +0100 Subject: SourceForge problems In-Reply-To: ; from grante@visi.com on Fri, Jan 26, 2001 at 08:46:09PM +0000 References: Message-ID: <20010126223707.L962@xs4all.nl> On Fri, Jan 26, 2001 at 08:46:09PM +0000, Grant Edwards wrote: > >don't-even-try-discussing-hot-steaming-faggots-ly y'rs - tim > You're probably not talking about cigarettes or firewood, so > I'm guessing it's some sort of sausage. But English food is > best left undiscussed if not uneaten. ;) As opposed to the wonderful american inventions of, uuhmm... the hotdog ? -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From cfelling at iae.nl Sun Jan 28 13:29:32 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 28 Jan 2001 19:29:32 +0100 Subject: [Python-Help] Globals References: Message-ID: <951oec$6ab$1@animus.fel.iae.nl> Aleksei Guzev wrote: ...problem snipped The global name scope of Python is the module scope. So it's impossible to refer to entities in other modules without importing those modules. e.g. $ cat a.py # module a g_var = None class CA: def foo( self ): print g_var $ cat b.py # module b import shelve, a s = shelve.open( 's' ) s[ "va" ] = a.CA() s.close() $ cat c.py # module c import shelve, a s = shelve.open( 's', 'r' ) va = s[ "va" ] s.close() a.g_var = "the string to be printed" va.foo() $ python b.py $ python c.py the string to be printed -- groetjes, carel From fredrik at effbot.org Thu Jan 25 14:20:01 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 25 Jan 2001 19:20:01 GMT Subject: Crash using Python 2.0 Extension References: <3A707199.FBDF1A81@newfocus.com> Message-ID: Ken Koller wrote: > I originally wrote the routine below to return Py_None, but the > interpretter would crash after calling the routine several times (maybe > 100-200) in a row. you mean like static PyObject * pt_pSetModule(PyObject * self, PyObject * args) { return Py_None; } this doesn't work -- Python expects your function to own a reference to the object you'll returning, and will decrement the reference counter once it's done with the return value. When the return value reaches zero, the None object is removed, and anything can happen. (in a stock interpreter, there already are 100-200 references to None when your program starts running. sys.getrefcount(None) will give you the exact number for your setup). But if you look in the library sources (*always* do this when you cannot figure out how to use the C API), you'll notice that many functions/methods do return Py_None -- but they all do one very important thing before doing so: Py_INCREF(Py_None); /* get another reference to None */ return Py_None; /* return an owned reference */ for more info, see: http://www.python.org/doc/current/ext/refcounts.html (especially "ownership rules") Cheers /F From jasonic at nomadicsltd.com Tue Jan 9 14:09:15 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Tue, 9 Jan 2001 14:09:15 -0500 Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: Oleg Broytmann wrote: > Anyone here has any doubts that at least mxDateTime simply MUST be in > the Python core? :) YES!! PLEASE PLEASE PLEASE let's end this 1970.epoch.ticks.DateTime-oriented mAdNeSs now = include mxDateTime in Python core for perpetuity.. - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] From NWMoriarty at lbl.gov Tue Jan 30 18:21:53 2001 From: NWMoriarty at lbl.gov (Nigel W. Moriarty) Date: Tue, 30 Jan 2001 15:21:53 -0800 Subject: fork, exec and wait on WINDOWS? Message-ID: <3A774C91.40835F30@lbl.gov> I have an app that needs to run on UNIX and Windows. I have the UNIX fork() and exec() setup but how doe one do a similar thing in Windows? Nigel From Daniel.Kinnaer at AdValvas.be Thu Jan 4 15:54:47 2001 From: Daniel.Kinnaer at AdValvas.be (Daniel) Date: Thu, 04 Jan 2001 20:54:47 GMT Subject: How-to create a Pascal Record using Python References: <3a54c7cf.15612195@news.skynet.be> Message-ID: <3a54e0c0.21998314@news.skynet.be> On Thu, 4 Jan 2001 14:21:27 -0500, "Steve Holden" wrote: > > return file.read().splitlines() > > >regards > Steve > Thanks for your reply. Was it correct to handle Pascal-like records the way I did, or is there a more Python-ly manner of handling this? Suppose I have something like TMyRecord = record aName : string; adate : TDateTime; aZIP : integer; end; //record var MyRecs : array [1..100] of TMyRecord; f : file of TMyRecord; How is this handled in Python? Sorry for these questions, but I really would like to learn about all of this. Thanks From fabrice.n at home.com Tue Jan 30 22:48:02 2001 From: fabrice.n at home.com (shaka) Date: Wed, 31 Jan 2001 03:48:02 GMT Subject: Does python20. package come all Libraries References: Message-ID: I download ActiveState python and I didn't like it, because all the module were scattered all over the place. they were not contain into a folder and there is no text iditor like IDLE, so that's why I download python20. "David A. Fuess" wrote in message news:TdF2Ou9AYBnAM=adnPwZpPUdXtAs at 4ax.com... > No. Many of the special libraries are available on www.python.org. For > some you're better off going to the library developer's site for the > latest version. If your planning to run pythonwin, you might consider > installing ActiveState python instead of Python20. It comes with all > of the Win32 libraries installed. > > Dave > > "shaka" wrote: > > > > > > >I was just wondering if all the libraries published on the python web site > >are contained in downloading package of python20. If no, how can I get > >those libraries?? > > > >thanks > > > From nospam at mega-nerd.com Sun Jan 14 05:56:24 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Sun, 14 Jan 2001 10:56:24 GMT Subject: libpython2.0 as a Linux shared library Message-ID: <3A618354.577B192A@mega-nerd.com> Hi all, I'm interested in in using Python as an embedded language inside and application I'm wriitng under Linux. My first attempt was a small text program which I did manage to get to link. The problem is that a 10 line C program with embedded Python becomes a 2+ Meg stripped executable. Does anybody know how to configure and compile Python so that libpython2.0 is a shared library? TIA, Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) +-----------------------------------------------------------+ The difference between genius and stupidity is that genius has its limits. From kkinder at tridog.com Wed Jan 17 19:27:51 2001 From: kkinder at tridog.com (Ken Kinder) Date: Wed, 17 Jan 2001 17:27:51 -0700 Subject: Best way to learn Python ? References: <3A66211B.F7F4F6BB@bioeng.ucsd.edu> Message-ID: <3A663887.95AE8023@tridog.com> Lemmie jump in here... There is a school that teaches Perl and Python -- TCPC. I don't have the URL. Curtis Jensen wrote: > > J5 wrote: > > > > No schools teach it, so what books do you recommend ? > > I had a class that used it here at UCSD. It was a camparative languages > class. The class' focus wasn't Python, but we did discuss it and had a > programming assingment in it. > > Though, yes, it is not realy taught in schools. But neither is Pearl, > Awk, Shell scripting, ML, Pascal (anymore), etc. > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- A non-text attachment was scrubbed... Name: kkinder.vcf Type: text/x-vcard Size: 333 bytes Desc: Card for Ken Kinder URL: From mhammond at my-deja.com Sun Jan 7 22:32:03 2001 From: mhammond at my-deja.com (Mark Hammond) Date: Mon, 08 Jan 2001 03:32:03 GMT Subject: Python, ADO, VC++ 6 References: Message-ID: <93bcbj$lfl$1@nnrp1.deja.com> In article , "Keith Farmer" wrote: > I've been attempting to create a Python module in C++ which uses ADO to > perform calculations against a database. You should be able to use the COM extensions to use ADO. > >>> AstroMath.countRows("workqueue") > 12 [this is correct] > >>> AstroMath.countRows("workqueue") > [promptly crashes with a memory reference error] A quick glance doesn't offer any ideas. Where exactly does the program crash? You have MSVC, so should be able to get a debuggable version of your module. Mark. Sent via Deja.com http://www.deja.com/ From paulp at ActiveState.com Sun Jan 21 18:28:49 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 21 Jan 2001 15:28:49 -0800 Subject: how to test for nesting inlist References: <94bhte$4iv$1@nnrp1.deja.com> <94bvgu0kt4@news2.newsguy.com> <94ea6k$4uc$1@nnrp1.deja.com> Message-ID: <3A6B70B1.2F91BC90@ActiveState.com> cpsoct at my-deja.com wrote: > > Thanks. and here i get a chance to learn something > recursion hurts my brain. map does everything but make coffee > doesn't it. It is amazing to me how many places map and filter > show up. i used map with None to lace lists last night. amazing > the things you can do in python..... You can do a lot with list comprehensions that otherwise would be done with map and I think that the list comprehension versions are often much more readable. Paul Prescod From fredrik at effbot.org Wed Jan 17 03:37:48 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 17 Jan 2001 08:37:48 GMT Subject: Curses module for Python 2.0 for Windows NT References: Message-ID: jurgen.defurne at philips.com wrote: > I am busy automating tasks across some Windows NT workstations, where > I control another program (Continuus/CM, if any one knows that). > Unfortunately, that control is not that easy. Ihave built a GUI interface, > but I am not really satisfied with it, so I want to simplify it somewhat so that > it can run in a DOS box using curses. Is there a curses add-on available > for the Win32 binaries ? It sure isn't part of the distribution I am using, > which is still the BeOpen version of Python 2.0 if you can live with a simpler API, here's an alternative console driver for windows: http://effbot.org/efflib/console Cheers /F From danielk at aracnet.com Sat Jan 13 11:39:42 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sat, 13 Jan 2001 08:39:42 -0800 Subject: making a string copy of a list References: Message-ID: <4m016t8kkpphqj3gu5jevpvamp8i3dap8n@4ax.com> On Fri, 12 Jan 2001 22:53:04 -0800, warlock at eskimo.com (Jim Richardson) wrote: >OK, I swear I've looked for this, but how do I make a copy of a list, into a >string, complete with commas seperating the entries in the list? The simplest way would be s = str(mylist)[1:-1] # removes the enclosing square brackets This does not remove brackets, parenthesis or curly braces from members inside the list. For instance, >>> mylist = ['dead','parrot'] >>> print str(mylist)[1:-1] 'dead', 'parrot' >>> mylist = [['dead','parrot'], (1, 2, 3), {1:'foo', 2:'bar'}] >>> print str(mylist)[1:-1] ['dead', 'parrot'], (1, 2, 3), {2: 'bar', 1: 'foo'} Daniel Klein From rturpin at my-deja.com Mon Jan 15 18:20:30 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Mon, 15 Jan 2001 23:20:30 GMT Subject: Determining names of instances References: Message-ID: <9400jl$b2u$1@nnrp1.deja.com> In article , "Daniel Klein" wrote: > The question is, is there a way for the object 'foo' > to know that its name is 'foo'? Sure. Search the namespace dictionaries for which names are bound to the the object. When it comes to introspection few languages beat Python. But (a) this is inefficient, (b) it is questionable programming, likely a mistake unless you are writing special debug code, or playing games with the implementation, (c) other names may be bound to the same object, including names in currently inactive namespaces, and (d) the binding changes. Consider the following code: global bar foo = Foo() bar = foo return Afer the assignment to "bar", the names "foo" and "bar" reference exactly the same object. Which name do you want? After the return, the binding to "foo" disappears, while the binding to "bar" remains. Russell Sent via Deja.com http://www.deja.com/ From tjreedy at udel.edu Thu Jan 18 18:18:10 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 18 Jan 2001 18:18:10 -0500 Subject: who imported me? References: <947jh5$puv$1@nnrp1.deja.com> Message-ID: <947ti8$ect$1@news.udel.edu> > (Hopefully) easy question: I'm writing a module that uses values in > variables from the script that imported it. > > How can I tell which script is importing me? I do not believe you can, unless the importing module were to stick a flag somewhere accessible by the imported module. (Besides which, a module can be imported multiple times by one or more other modules.) > Is there some easier way to get the parent module's variable values? The 'parent' module can stick values into an imported module, or probably, include them as parameters in fu;nction calls. Terry J. Reedy From moshez at zadka.site.co.il Wed Jan 24 09:29:20 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 24 Jan 2001 16:29:20 +0200 (IST) Subject: Python: what's the best way to copy files on a LAN? In-Reply-To: <3a6f0af0.272878461@news.interchange.ubc.ca> References: <3a6f0af0.272878461@news.interchange.ubc.ca> Message-ID: <20010124142920.7FAE9A83E@darjeeling.zadka.site.co.il> On Wed, 24 Jan 2001 17:04:50 GMT, kmbotha at netinfo.ubc.ca (Kris Botha) wrote: > I mean security-wise. I'd like to use FTPLIB but am hesitant about the > security issues involved in using that plain-text protocol. You probably mean "clear text", not "plain text". Why not use HTTPS? Or, even better, set up a port-forward via ssh, and then use plain HTTP. Python can do HTTP both in client and server, so there shouldn't be a problem. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From mceesay at coldspam.com Wed Jan 24 13:36:24 2001 From: mceesay at coldspam.com (Mamading Ceesay) Date: Wed, 24 Jan 2001 18:36:24 -0000 Subject: Tkinter spreadsheet or textgrid widget? References: <94l7fo$k6k$1@news.fas.harvard.edu> Message-ID: William Ryu wrote in message <94l7fo$k6k$1 at news.fas.harvard.edu>... >Tried a Google search but didn't come up with anything. Can someone point >me to a Tkinter textgrid (i.e. spreadsheet type text/number entry) widget? > TkTable is probably your best bet. It is actually a Tk widget, so it may require a little more work than a Tkinter widget to use. Regards, Mamading. From aleaxit at yahoo.com Sat Jan 6 04:18:24 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 6 Jan 2001 10:18:24 +0100 Subject: enhancing module objects (was Re: 2001 Enchancement Wishlist) References: <011001c07726$5ced6be0$102b2bc1@cadlab.it>, <3A4CEACB.220998A0@javanet.com> <92j83r13gh@news1.newsguy.com> <20001231175940.A5435@xs4all.nl> <008301c07501$c036ae40$43931497@martelli> <20010104165116.F2467@xs4all.nl> <008601c07675$0adf2020$102b2bc1@cadlab.it> <20010104203232.P402@xs4all.nl> <006801c0769b$ac0cc3a0$9d8a1a97@martelli> <20010105110459.Q402@xs4all.nl> <20010106013001.17FB7A84F@darjeeling.zadka.site.co.il> Message-ID: <01d001c077c7$675b2e40$b3ff1a97@martelli> > > Recognizing (e.g.) a "def __setattr__" at module-level as providing > > a similar function to a similarly-named method in a class instance > > would (in my opinion) not 'complicate' the Python language: it would > > just extend an already-existing concept > > For the record, I'm heavily +1 on the concept. Sadly it's sure > not to make it to 2.1, as the PEP deadline is due. But you can > write a PEP which will be considered for 2.2. OK, but, as I kept on musing in the other post, I'm not sure adding this (recognition of a __setattr__ function in a module object) is the best way to provide the related functionality -- as opposed to similar work on dictionary objects themselves (so that modules, and anything else using a dictionary, can equally benefit) OR just accepting any suitable mapping object where currently only real builtin dictionaries can go, an often-mooted concept. I think the latter approach would be 'simplest' _from a Python user's viewpoint_ -- in fact, I think most budding Pythonistas are _surprised_ to learn that in certain roles they cannot use (e.g.) an instance of a UserDict-derived class of their own, but only a real bona fide builtin dict object will do. One gets so used to the convenience and power of "anything implementing such-and-such interface goes here". And I gather an existing PEP raises just this restriction in a different context (I forget whether it was exec, eval, or both). I guess I'm still not fully clear on the PEP concept: is it appropriate when a range of possible approaches to providing a certain functionality are still under consideration, or only when one single approach is being proposed? The lack of a formal arrangement for specifically discussing a given PEP sort of suggests the latter -- in which case discussing it a bit more here might be a better preliminary...? Alex _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From aleksei.guzev at bigfoot.com Sun Jan 28 02:43:57 2001 From: aleksei.guzev at bigfoot.com (Aleksei Guzev) Date: Sun, 28 Jan 2001 12:43:57 +0500 Subject: [Python-Help] Globals In-Reply-To: <004601c088fa$e7aab5e0$0341fea9@arthur> Message-ID: I meant the following doesn't work # # module A.py # class CA: def foo( self ): print g_var def __getstate__( self ): return "CA" def __setstate__( self, state ): print state next file # # script B.py # import shelve import A va = A.CA() s = shelve.open( 's' ) s[ "va" ] = va s.close() the last file: # # C.py # import shelve s = shelve.open( 's', 'r' ) va = s[ "va" ] s.close() g_var = "the string to be printed" va.foo() Run . Next exit Python shell. Then restart the shell and run . g_var whould be undefined in va.foo(). From danielk at aracnet.com Wed Jan 3 08:51:21 2001 From: danielk at aracnet.com (Daniel Klein) Date: Wed, 03 Jan 2001 05:51:21 -0800 Subject: using 'global' across source files. References: <3A51CC63.A90A0E0B@sara.nl> <01s35tgmoirgtplgs46402vqpootc2oe7u@4ax.com> Message-ID: <1hb65tc1tjgtj91eig1sf96hotgbkipve7@4ax.com> On 2 Jan 2001 15:15:01 GMT, scarblac at pino.selwerd.nl (Remco Gerlich) wrote: >You mean val = funcs.change_val(val). Yep! From trotts at mit.edu Sun Jan 28 17:28:44 2001 From: trotts at mit.edu (Issac Trotts) Date: Sun, 28 Jan 2001 14:28:44 -0800 Subject: Hack request: rational numbers In-Reply-To: <3A749696.2BD57BA9@alcyone.com>; from max@alcyone.com on Sun, Jan 28, 2001 at 02:00:54PM -0800 References: <951h34$tch$1@nnrp1.deja.com>, <2W%c6.128157$ge4.46108705@news2.rdc2.tx.home.com> <3A749696.2BD57BA9@alcyone.com> Message-ID: <20010128142844.C711@llnl.gov> > (There is a geometric algebra module for Python, by the way.) I've been looking for something like this. Do you know the URL? Issac From sholden at holdenweb.com Wed Jan 3 03:42:17 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 3 Jan 2001 03:42:17 -0500 Subject: A Suggestion for Python Colon Syntax References: Message-ID: Thomas Wouters wrote in message news:mailman.977594969.22002.python-list at python.org... > On Fri, Dec 22, 2000 at 11:50:28PM +0000, Vadim Zeitlin wrote: > > > BTW, what was the real rationale for adding composed assignment operators > > (+=) to Python 2.0 (which I'm really extremely glad to have now)? Wasn't > > it meant to make Python more attractive to the people coming from C-lie > > languages? > > No, honestly not. If that was the case, '++' and '--' would have been added > too. The funny part is that I never saw a concious decision not to add them > being made, everyone involved (Guido, Michael Hudson, me, the rest of > python-dev) seemed to naturally accept that the auto-inc/dec operators had > no place in Python, and that in itself is plenty of validation, don't you > think ? :-) > > Guido-probably-made-all-decisions-about-Python-years-ago--he's-just-waiting- > -for-people-to-_implement_-them-ly y'rs, No. He _will_ make them years ago, once concensus has appeared in the present. > -- > Thomas Wouters > > Hi! I'm a .signature virus! copy me into your .signature file to help me spread! > paradoxical-ly y'rs - steve From fredrik at effbot.org Wed Jan 24 06:02:21 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 24 Jan 2001 11:02:21 GMT Subject: Parsing html links References: <3A6EB2F7.D26C7974@hotmail.com> Message-ID: <1Dyb6.9010$Qb7.1276496@newsb.telia.net> "Joonas" wrote: > How can I make a script im Python that changes all > 'http://myaddress.spam ' into ' href="http://myaddress.spam">http://myaddress.spam' recently seen on comp.lang.python: Subject: Re: URL replacement in text Date: Tue, 16 Jan 2001 Steve Holden wrote: > Note that this won't cope with some of the more pathological URLs (such as > those with CGI arguments [http://system/cgi?arg1=val1] or those which link > to a named anchor in the target page [http://system/pageref#target-name]). import re links = re.compile(r"(?i)(?:http|ftp|gopher):[\w.~/%#?&=-]+") def fixlink(m): href = m.group(0) return "%s" % (href, href) sometext = """ here's another link: http://www.pythonware.com?FOO=1&bar=10#BAR """ print links.sub(fixlink, sometext) Cheers /F From sbalu at nyx.net Mon Jan 22 14:10:17 2001 From: sbalu at nyx.net (sarayu balu) Date: Mon, 22 Jan 2001 19:10:17 GMT Subject: Newbie Question Message-ID: <980192858.449719@iris.nyx.net> I just downloaded pygtk-0.6.6 and installed it. On trying the examples, I am getting an error- ImportError: /usr/local/lib/python2.0/site-packages/ _gtkModule.so: undefined symbol: g_thread_init . I have no clue as to what's going on, is it a gtk library problem, or python2.0 problem ? Hope one of you can help. Thanks, - SB From MarkH at ActiveState.com Thu Jan 18 20:59:21 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 19 Jan 2001 01:59:21 GMT Subject: Python calls Trace Handler fn within call to PyObject_Str References: <3RM96.183472$59.49047774@news3.rdc1.on.home.com> Message-ID: <94871m$bpo$1@nnrp1.deja.com> In article <3RM96.183472$59.49047774 at news3.rdc1.on.home.com>, "Tom" wrote: > > My C++ module calls the PyObject_Str function, as so: > > PyObject* pPyStr = PyObject_Str( m_pPyObject ); // New Ref > > Stepping through the code in my debugger, I see that beneath (or 'within') > this call, Python is calling my trace handler function. The trace event is > a 'call'. Is this normal behavior? If the process of converting the object to a string calls .py code, then yes. Mark. Sent via Deja.com http://www.deja.com/ From sholden at holdenweb.com Tue Jan 2 16:53:45 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 2 Jan 2001 16:53:45 -0500 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4F3671.AAA18BFF@stroeder.com> Message-ID: Steve Lamb wrote in message news:slrn94uht3.150.grey at teleute.rpglink.com... > On Sun, 31 Dec 2000 14:36:49 +0100, Michael Str?der > wrote: > >While you're at it: Can you please *plonk* me too? We might disagree > >in the future and we can avoid flame wars in advance and save work. > >And it's a great honor for me to be in the same kill-file as the > >Eff-bot. > > I don't plonk people for disagreements. I plonk them for stupidity. > There's a difference. Since you have a moderate wit that shows at least some > intelligence. > > -- > Steve C. Lamb | I'm your priest, I'm your shrink, I'm your > ICQ: 5107343 | main connection to the switchboard of souls. > -------------------------------+------------------------------------------ --- > At last we have a good example of the meaning of the epithet "plonker". Sorry. Couldn't resist. pouring-fuel-on-the-flames-ly y'rs - steve From aleaxit at yahoo.com Wed Jan 24 10:46:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 24 Jan 2001 16:46:16 +0100 Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> <3a685ef2.3403798@reading.news.pipex.net> <949rii0a76@news1.newsguy.com> <3a6eb2fa.2347467@reading.news.pipex.net> Message-ID: <94mtc702d2h@news2.newsguy.com> "Ray Drew" wrote in message news:3a6eb2fa.2347467 at reading.news.pipex.net... [snip] > I'm having problems getting the indentation right with gvim. I've got > the following in my .vmrc file: > > au FileType py set ts=4 > au FileType py set sw=4 > au FileType py set expandtab on I think you need to omit the 'on' here. > au FileType py set ff=unix > > as far as I can make out from the docs, this should set those options > for all .py files. Tabs appear as 4 chars in gvim but when viewed in > an IDLE edtor window, tabs appear as 8 and throw a syntax error when There should never be any tabs in files generated with vim if 'set expandtab' was executed. Try a :set from within vim to see all that's set; is expandtab among the variables shown? > imported (files originally created in IDLE with tab space of 4). Do I > need to do anything else to get this to work? If you ever edit existing files that may have tabs in them, and want to ensure they're turned into spaces, you may add to your startfile something like: au BufRead *.py %retab but take care -- this will NOT make vim think the file has been _modified_ yet, so a ZZ will not write the changes (you'll need a :w to write anyway, although of course ZZ will also write if you DO some editing which causes other changes). Starting your startfile with a set verbose=9 will ensure you get a trace that will help you debug your startfile settings. I suspect that on comp.editors you may find people *much* more skilled than me at VIM-tweaks:-). Alex From hadidab at yahoo.fr Mon Jan 29 08:49:16 2001 From: hadidab at yahoo.fr (=?iso-8859-1?q?ABDENOUR=20HADID?=) Date: Mon, 29 Jan 2001 14:49:16 +0100 (CET) Subject: need Numeric module Message-ID: <20010129134916.11960.qmail@web216.mail.yahoo.com> hello.. I want to excute a scrit wich import a Numeric module, where can I find this module? thanks ___________________________________________________________ Do You Yahoo!? -- Pour dialoguer en direct avec vos amis, Yahoo! Messenger : http://fr.messenger.yahoo.com From marco at crepido.com Wed Jan 24 13:03:30 2001 From: marco at crepido.com (Marco =?iso-8859-1?Q?Seiri=F6?=) Date: Wed, 24 Jan 2001 19:03:30 +0100 Subject: what GUI, please advise References: <3A6F0B27.A88D11C9@crepido.com> <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7@lp.airnews.net> Message-ID: <3A6F18F2.536F27FE@crepido.com> Well, something like this... - I'm going to run mostly on Unix, although it would be nice to be able to recycle my GUI knowledge when forced to write for Windows. Mac, not very important... - A GUI builder is a very big advantage. allmost a must. - I like there to be all the widgets one would expect from the Windows world. - Easy of use for the programmer. Don't know a thing about GNOME widgets, yet... Cameron Laird wrote: > > > >There seems to be several good options to choose from when > >it comes to GUI developent with Python. > > > >Can someone say somthing, without killing each other with flames, what > >GUI one should choose? > > > >Stupid and impossible question by the way as everything depends as > >usual... but anyway.. > > > >/M > > > > No. > > Unless you tell us more about yourself. Do you care about > portability to MacOS? Does the GNOME widget collection > infatuate you? Do you prefer or disdain a GUI builder? > > In the meantime, > > -- > > Cameron Laird > Business: http://www.Phaseit.net > Personal: http://starbase.neosoft.com/~claird/home.html From hamish_lawson at yahoo.co.uk Tue Jan 9 10:56:42 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Tue, 09 Jan 2001 15:56:42 GMT Subject: Grab text from html with user and pass??? References: Message-ID: <93fcbm$rag$1@nnrp1.deja.com> Paul Goodyear wrote: > I know for well that the password is correct I realise I may be stating the obvious, but when you say that you know that the password is correct, does this mean that you have actually been able to access the page using an ordinary browser? Hamish Lawson Sent via Deja.com http://www.deja.com/ From gbreed at cix.compulink.co.uk Thu Jan 11 11:10:16 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 11 Jan 2001 16:10:16 GMT Subject: ActivePython2.0 - Server Side objects for ASP problem References: <3A5DD081.F37275A@gte.net> Message-ID: <93klt8$qon$1@plutonium.compulink.co.uk> In article <3A5DD081.F37275A at gte.net>, sandj.williams at gte.net (Steve Williams) wrote: > Danger Will Robinson!! > > You can, indeed, write and install a COM object on the server before > bedtime, > but you might be up all night getting your client to talk to it. Some > pitfalls: > > 1) The client doesn't have Python installed. It uses MS Access or > VB or > Excel or Word. How do you register your COM server on the client? > Whose > classid/appid do you use? Light a taper and go down into the regedit > dungeon. Dude! The subject line says "Server Side objects". ASP can indeed call server side objects. The client doesn't have to know anything about them. The following may well be problems, but I've not had much trouble with Python COM servers. Now DCOM, that's a different kettle of ball games ... > 2) When you try to use the COM object you get 'Permission Denied'. > Time to > read a ton of MS Q documents and maybe talk to an unfriendly and > ignorant NT > administrator. > > 3) When you try to use the COM object, you get 'ActiveX can't > create. . .'. > Time for some more bedtime reading. > > 5) You call your friends and they say "I've never had that problem, > maybe you > should install MTS. . ." From moshez at zadka.site.co.il Fri Jan 19 14:13:14 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Fri, 19 Jan 2001 21:13:14 +0200 (IST) Subject: How to run script from interpreter? In-Reply-To: <00ef01c081fd$375c2ab0$11260340@yin> References: <00ef01c081fd$375c2ab0$11260340@yin>, Message-ID: <20010119191314.5A489A83E@darjeeling.zadka.site.co.il> On Fri, 19 Jan 2001, "Dan Rolander" wrote: > This doesn't work for me. I know how to import and how to use the if > __name__ trick, but how can I execute a script from the interactive Python > interpreter? That is, can I load a script and have it run from inside the > interpreter? (I'm sure this is easy I'm just not seeing it.) execfile(script_name) E.g., execfile("test.py") -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From aleaxit at yahoo.com Sat Jan 6 14:26:38 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 6 Jan 2001 20:26:38 +0100 Subject: mxTools (was Re: why no "do : until"?) References: Message-ID: <937rqs01sal@news1.newsguy.com> "Simon Brunning" wrote in message news:mailman.978711906.28690.python-list at python.org... [snip] > Marc Lemburg's mxTools includes an indices function - indices(a) is > synonymous with range(len(a)). ...which reminds me: why no PEPs about adding to Python's core some of the nicest ideas in Lemburg's neat mxTools...? I assume there must be a reason (e.g., Guido must already have seen them all and decided they don't belong in the core, or something), but I'd like to know... Alex From msoulier at nortelnetworks.com Fri Jan 12 11:16:53 2001 From: msoulier at nortelnetworks.com (Michael P. Soulier) Date: 12 Jan 2001 16:16:53 GMT Subject: A small suggestion for Python References: <3A5F27F7.30268D9A@erols.com> Message-ID: <93nall$7cd$1@bmerhc5e.ca.nortel.com> In article <3A5F27F7.30268D9A at erols.com>, Edward C. Jones wrote: >I have been programming in Python for several years. I still >occasionally make mistakes with functions (such as sort) that >return only "None". I suggest that functions like sort should >return either "Nothing" or nothing. "Nothing" would be exactly >like "None" except it can't be assigned. Whether "Nothing" or >nothing is used, the statement "x= y.sort()" would raise a >run-time Exception. Or perhaps some kind of pragma to enable this behaviour? Mike -- Michael P. Soulier, TD12, 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 Nortel Linux User's Group Ottawa: (internal) http://nlug.ca.nortel.com From muk_pr at yahoo.com Fri Jan 19 08:22:04 2001 From: muk_pr at yahoo.com (Victor Black) Date: Fri, 19 Jan 2001 15:22:04 +0200 Subject: How to get method's arguments Message-ID: 1.How does IDLE show the argument list of a method or procedure. e.g when you write "dir(" a hint writing "dir([object]) -> list of strings" pops up. (The sources are available but overwhelming) 2.Are there any other open source IDEs for python ? Thanks. From tim.one at home.com Sat Jan 13 22:17:33 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 13 Jan 2001 22:17:33 -0500 Subject: Web devel with python. Whats the best route? In-Reply-To: Message-ID: [Penhasco Crawford] > Por que est? todos afixar no portugu?s? Eu sinto esquerdo para > fora agora. Os povos que vivem na casa portuguese n?o devem jogar pedras de Enlish. "the-peoples-who-live-in-the-house-portuguese-do-not-have- to-play-rocks-of-Enlish"-isn't-exactly-the-translation- i-was-hoping-to-get-back-ly y'rs - tim From loewis at informatik.hu-berlin.de Mon Jan 1 09:09:07 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Jan 2001 15:09:07 +0100 Subject: Bug? in os.chown() References: <3A4FC0DD.530F90E6@ev1.net> Message-ID: David Lambert writes: > I am running Python 2.0 on Mandrake Linux 7.2 and have come across an > apparent anomaly with os.chown(). Running a process as root, I can > change any file's ownerships apart from symbolic links. No error is > given, but the ownership refuses to be changed. Is this a feature or a > bug? How do I change a symbolic link's owner and group? Python delegates the call to Linux, so if anything, it's a bug or feature of Linux. In this case, it's a feature of Linux: chown(2) modifies the file behind the symbolic link, not the symbolic link itself (I believe in conformance with POSIX, which makes it a feature). To change the symbolic link itself, use lchown(2). Unfortunately, lchown is not exposed in the Posix module. If you have a need for it, I recommend to make a bug report at sourceforge.net/projects/python. Better yet, submit a patch to the posix module. Regards, Martin From stuarts at 171.69.180.197 Fri Jan 12 14:59:16 2001 From: stuarts at 171.69.180.197 (Stuart Stanley) Date: Fri, 12 Jan 2001 19:59:16 -0000 Subject: "Full" object and class pickling? Message-ID: <979329680.407225@sj-nntpcache-3> I am doing some experimenting with mobile objects. I.E., python objects that physically migrate from process to process via some mechanism. I had thought (c)pickle was my ticket, but pickle does not bring the _code_ with. Does anyone know a mechanism to: 1) "pickle" the _complete_ object, including its byte-code? 2) "pickle" a class so I can create instances from it without using imports? I.E., I want to migrate the classes used in return values from the above (#1) transported objects and use them to create objects that can do things like compare against the return values from the migratory objects... For a number of reasons I need to avoid doing imports in the "non-home" processes... Clues? Hints? Complete packages that does all this already? ;) Thank you -- stuart -- "Computer Science is no more about computers than | Stuart Stanley astronomy is about telescopes." - E. W. Dijkstra | stuarts at cisco.com | Cisco Systems, inc | St Paul, MN | 612.578.6412 From SBrunning at trisystems.co.uk Fri Jan 5 11:21:26 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 5 Jan 2001 16:21:26 -0000 Subject: why no "do : until"? Message-ID: <31575A892FF6D1118F5800600846864D5B16A6@intrepid> > From: Tim Peters [SMTP:tim.one at home.com] > A study I did at the time said that about 15% of all "for" loops in Python > code were of the form > > for i in range(len(a)): > > and that's both an obscure and inefficient way to spell the underlying > idea. Marc Lemburg's mxTools includes an indices function - indices(a) is synonymous with range(len(a)). 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 neilh at scintilla.org Tue Jan 30 19:36:32 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 31 Jan 2001 00:36:32 GMT Subject: Using PythonWin Python Rich Edit Control in MFC App References: <956vrc$eon$1@nnrp1.deja.com> Message-ID: btheld2 at my-deja.com: > ... Basically, I want a control that I can use as a python > command line in a dialog that acts like the one in PythonWin.exe. I > have looked at scintilla, but if I use that, I need to implement all of > the python specific stuff for indenting, coloring, etc... It would be > much easier just to use a control from the PythonWin.exe if possible. PythonWin uses Scintilla for this purpose but enhances Scintilla with quite a lot of Python code much of which is shared with IDLE. It is not packaged up in a form that would be easy to reuse in a C++/MFC application. OTOH, PythonWin is an MFC application and is designed to be extensible, so if you were to base your application on PythonWin then you could include its Interactive Window. Some other toolkits (wxPython and JPython, IIRC) have developed what you are looking for but their Python console components would only be easily reusable within projects based on those toolkits. Neil From rcameszREMOVETHIS at dds.removethistoo.nl Fri Jan 12 21:28:17 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sat, 13 Jan 2001 02:28:17 GMT Subject: why no "do : until"? References: <90278A4rcamesz@127.0.0.1> Message-ID: <902820CBFrcamesz@127.0.0.1> D-Man wrote: >On Fri, Jan 12, 2001 at 12:33:58AM +0000, Robert Amesz wrote: >[snip] >| >| Well, to put in my fl 0,02 (soon te be about E 0,01 ) I have to >| say I feel that syntax is flawed: not only does it break the block >| in two parts (whereas a dedent in other cases means the end of the >| block is reached), but it's also visually ambiguous because a >| 'while' could be the start of a loop, but it might also be >| somewhere in the middle of one. >| >| As I prefer programming languages to be as context-free as >| possible, I'd like to make a counter-proposal: >| >| do: >| something >| until condition >| something else >| > >This also breaks the indent-denotes-block-structure style. Is the >"until" clause really a part of the "something" block? Well, no, my point is that the entire block should run from 'something' to 'something else', following the normal flow of the program. The 'until' is a statement for breaking out of the block, and therefore it should be part of it visually. Also, splitting the block is a bad thing from the point of view of the compiler: after a dedent the compiler will have to look ahead an extra token to determine wether the loop just ends there, or continues with an 'until'. Changing the lookahead in a parser can cause a huge loss of performance, and older parser generators can only cope with LL(0) grammars anyway. Also, such inconsistencies may have the effect of making some error message more obscure and unhelpful, and that will really make the syntactic sugar turn sour on you. There's a way out of this dilemma, and that is to disallow 'do:' whithout an 'until' in the loop, but then we'd have to lose the ability to use 'do:' as an infinite loop and we'd still be stuck with the 'while 1:' idiom. >If it is adopted I think it ought to stand out more tying it more >closely to the "do". I wouldn't mind if, say, the until was to >recieve a half-indent (or half-dedent depending on your view) as >compared to the "something" and "something else" blocks. If you want the 'until' to stand out more, just put an empty line after it. That's a lot easier than breaking Python's basic structure with half-dedents. Take a look: do: something until condition something else That seems clear enough to me. Also, one common case, when the 'until' is at the end of the loop, would be problematic if you dedent the until. You either get: do: something something else until condition Oh, great, no colon or block after 'until': another special case to confuse the compiler and Python programmers alike. Or - wait for it: do: something something else until condition: pass Ugh, yacc![1], this is truly ugly. It's more like syntactic artificial sweetener this way. In short, my proposal may be a compromise, but it gets the job doen, and would only call for a modest addition to Python's grammar, and thus would only require simple changes to the bytecode-compiler. It may be a low cost low impact proposal, but it would both add the 'do: until' idiom and provide an alternative for the 'while 1:' convention at the same time. Robert Amesz -- [1] Horrible pun alert. You may groan. From Bill.Scherer at VerizonWireless.com Fri Jan 19 09:40:13 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Fri, 19 Jan 2001 09:40:13 -0500 Subject: Best Python Web Site References: <6176E3D8E36FD111B58900805FA7E0F80CCF62DF@mcnc-mdm1-ex01> Message-ID: <3A6851CD.A152D1B9@VerizonWireless.com> http://www.pythonware.com/daily/ "Rolander, Dan" wrote: > > The http://www.python.org website seems to have many pages that have not > been updated in a long time. Particularly distressful are the pages that say > things like "This information is obsolete but we don't have time to update > it". I like to scour the web everyday for updated Python info. What are the > best sites for getting new Python information? Any thoughts on this? > > Thanks, > Dan > > -- > http://mail.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From nils.hensel at online.de Wed Jan 24 18:42:50 2001 From: nils.hensel at online.de (Nils Hensel) Date: Thu, 25 Jan 2001 00:42:50 +0100 Subject: The fundamentals... References: Message-ID: <94npcb$jit$1@news.online.de> Hi Mike, import string boo = string.join (open('\\Windows\\Desktop\\test.txt').read().split('.'), '\n') open('\\Windows\\Desktop\\out.txt', 'w').write(boo) is definitely shorter. I don't know if I consider it to be more elegant. Anayway, you should note that the string object returned by the read function now has a builtin split function, refering to itself, and that you need not close the file if it's not assigned to a variable. The file closes itself when there are no more references to it. And if you prefer to close your files explicitely don't forget to close the "test" file too :) Enjoy Python, Nils "Mike Read" schrieb im Newsbeitrag news:F8Jb6.30683$pp2.2619941 at news3.cableinet.net... > Newbie first script alert! No problem - it does what I intended (which > probably says more about Python than me...), but I just wanted to start > off on the right foot - is it as elegant as it could be? If it's not blindingly > obvious, I was separating fields around a period delimiter. > > Cheers, > > Mike > > > import string > test = open('\\Windows\\Desktop\\test.txt', 'r') > boo = test.read() > boo = string.split(boo , ". ") > boo = string.join(boo , "\n") > > outfile = open('\\Windows\\Desktop\\out.txt', 'w') > outfile.write(boo) > outfile.close() > > > From tbryan at python.net Mon Jan 8 19:19:22 2001 From: tbryan at python.net (Thomas A. Bryan) Date: Mon, 08 Jan 2001 19:19:22 -0500 Subject: Is there a Python binding for daVinci? References: <3A5A15CE.30C8DD48@raqia.com> Message-ID: <3A5A590A.C4C20FBB@python.net> David Lees wrote: > > I would like to display directed graphs and daVinci has been > recommended. Does anyone know if there is a Python binding or a Python > equivalent? > > daVinci is at http://www.tzi.de/daVinci/ There is a Python interface to working with the node definitions and such. I don't remember where I got it, and I've never really used it. I still have a copy if you can't find it from someone else. ---Tom From tim.one at home.com Sun Jan 14 02:04:21 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 14 Jan 2001 02:04:21 -0500 Subject: why is a negative shift value illegal? In-Reply-To: Message-ID: [Rainer Deyke] > I don't buy the speed argument. If that implies you do buy the other arguments, there's no point haggling over the weakest one <0.5 wink>. > ... > Consider 16 bit color formats. > ... OK, I did. I concluded that if I were doing significant amounts of pixel twiddling, I sure as heck wouldn't be writing it in Python no matter what gimmicks were added to shifts (an extension module, sure, but not in Python proper). OTOH, if I weren't doing significant amounts, speed would be a non-issue. In every case Python raises an exception, *someone* eventually says "hey! let's make it mean something instead!". That way lies madness. Allowing negative shift counts simply isn't a compelling idea, and seems at least as likely to mask program bugs as to do anyone a lick of real good. I've gotten ValueErrors from shift counts that mistakenly went negative, and I'm glad I did (shifting "in the other" direction would have been dead wrong). I'm still one-quarter unhappy that modern Python allows, e.g. sequence[-1] Python originally called that an error, and that caught bugs too. But at least indexing "from the right" is very useful very often for very many programmers (e.g., string[:-1] is probably in every Python programmer's idiom bag). if-you-still-like-it-write-a-pep!-ly y'rs - tim From hdemers at venus.astro.umontreal.ca Fri Jan 19 11:22:22 2001 From: hdemers at venus.astro.umontreal.ca (Hugues Demers) Date: Fri, 19 Jan 2001 16:22:22 GMT Subject: ImportError: undefined symbol Message-ID: Hi, This question must have come up many times, but I cannot find any answers in the official documentation or the FAQ or this newsgroup. So here it is. I'm writing a small extension in C++ that call functions from a C++ library (GALib). My extension looks like this (it's a test): #include #include #include float objective( GAGenome & ); void gaFit(); extern "C" { static PyObject* fit( PyObject* self, PyObject* args ) { gaFit(); Py_INCREF( py_None ); return Py_None; } static PyMethodDef gaPhotoMethods[] = { {"fit", fit, METH_VARARGS}, {NULL, NULL} }; static initgaPhoto() { (void) Py_InitModule( "gaPhoto", gaPhotoMethods ); } } // End of extern "C" void gaFit() { // Call to C++ library } void objective( GAGenome& c ) { // do stuff } My setup file is written like this: *shared* gaPhoto gaPhotomodule.cpp -L/usr/local/lib -lga When in Python I import the module I get this error: ImportError: ./gaPhotomodule.so: undefined symbol: __ls__7ostreamPCc Can someone help me? Thanks Hugues From strupl at my-deja.com Tue Jan 9 11:59:58 2001 From: strupl at my-deja.com (strupl at my-deja.com) Date: Tue, 09 Jan 2001 16:59:58 GMT Subject: jython beta question References: <93305c$7ej$1@nnrp1.deja.com> <93cetr$f7f$1@nnrp1.deja.com> Message-ID: <93fg2a$uaf$1@nnrp1.deja.com> Hi all, in my previous mail i described the way how to integrate a new language with NetBeans. I looked at the Jython doc and it seems to be a new version of JPython (JPython being supported in NetBeans ver. 3.1). So the answer to the original question should probably be: it is highly probable that in next version of NetBeans the new version of Jython will be supported. Meanwhile you can (at your own risk) replace the jpython.jar file with a new one and see what happens. Sorry for the confusion. David Strupl Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Sun Jan 21 05:02:23 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sun, 21 Jan 2001 10:02:23 GMT Subject: Traversing A Directory For Files References: Message-ID: Ben wrote: > I am looking for examples of a recusive Python algorithm to traverse a > directory and all subdirectories for files and return them to a list for > further processing. os.path.walk (you'll find sources in posixpath.py/ntpath.py) here's a non-recursive version that's much easier to use: http://www.deja.com/=dnc/getdoc.xp?AN=695333869 Hope this helps! Cheers /F From nas at arctrix.com Tue Jan 16 09:46:48 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Tue, 16 Jan 2001 06:46:48 -0800 Subject: Binary list class, strings or longs? In-Reply-To: <942cbc$7qp$1@news.gu.se>; from msandin@remove_this.hotmail.com on Tue, Jan 16, 2001 at 09:51:34PM +0100 References: <942cbc$7qp$1@news.gu.se> Message-ID: <20010116064647.A8748@glacier.fnational.com> Look at the standard modules array and mmap. However, if you're doing image manipulation then you probably want to get PIL. Neil From zeitlin at seth.lpthe.jussieu.fr Mon Jan 29 10:07:35 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 29 Jan 2001 15:07:35 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> <952lo9$qme$1@nnrp1.deja.com> Message-ID: On Mon, 29 Jan 2001 02:49:46 GMT, thelazydogsback at my-deja.com wrote: >(1) Does one toolkit behave better in a multi-threaded application than >another? In addition to the design of the toolkit, any kit that uses >native widgets has native restrictions on threading and the GUI (e.g., >only "main" thread talks to the GUI, etc.), so I'd guess that self-draw >GUIs would have a chance of behaving better here. At least for Windows, this is not true as any toolkit is going to use GDI calls (at least tkInter surely does, it might be possible to use DirectX or whatever instead, but I don't think it's a good idea for a GUI toolkit) and the usual restrictions about multiple GUI threads come from GDI layer, so you gain nothing here. >When threads spawned from the main thread >need to update GUI state, what is the standard method used? In wxWindows you may either: 1. set a global variable (protected by a critical section) from the worker thread and check it in the main thread during the next idle loop iteration or 2. use wxPostEvent() to send a (custom) event to the main GUI thread which will then get it some time later > Does wx's doc/view architecture make this more straightforward? No, it predates the threads support by about 5 years so I don't think so. >(2) I assume I could have an app the used both wx & tk at the window >level, Assuming you can share the message loop between them... > but is it possible to host WX inside of Tk, or visa-versa, at > the frame and/or widget level? It should be possible to embed Tk in a C++ application in the "usual" way but I don't know much about it. OTOH embedding wxWin into Tk application is probably quite hard to do. Regards, VZ -- GCS/GM d? H+ s++:-- p2 au--- a- w+ v C+++ UBLS+++ P- L++ N++ E--- W++++ M? V-- -po+ R++ G`` !tv b+++ D--- e++++ u++ h--- f+ r++ n- y? From infotechsys at pivot.net Wed Jan 31 10:29:11 2001 From: infotechsys at pivot.net (Wayne) Date: Wed, 31 Jan 2001 10:29:11 -0500 Subject: Help in understanding some code! Message-ID: <3A782F47.D078FBEC@pivot.net> Hello, I have a Red Hat distro and I'm trying to emulate one of there program's. The program is netcfg.py The part that I'm trying to do is to allow the user to click on a button, those that are at the top of the initial window, and get a form displayed. The code that is at the end of this program reads as follows: # magic to keep a root window from appearing L = Label() L.tk.call('wm','withdraw', '.') del L win = WindowFrame(Toplevel()) win.wait_window(win) The whole program is over my head, but on my 5th reading I'm starting to understand it I haven't figured out why they want to remove the toplevel window and why do they have to create a labell to do it. Also where will I find the syntax for the call statement. I have a book title "Practical Programming in Tcl and Tk" by Brent B Welch. I couldn find its use in the book. TIA Wayne From aleaxit at yahoo.com Sat Jan 13 18:42:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 14 Jan 2001 00:42:53 +0100 Subject: A small suggestion for Python References: <3A5F27F7.30268D9A@erols.com> Message-ID: <93qpbc02n4a@news1.newsguy.com> "Matt Dunford" wrote in message news:G74HuE.AGn.0.sinope at news.jtan.com... [snip] > Although, I wouldn't mind having a builtin method that returns a sorted > array. Then we could do something like this: > > dict = { 'this' : 1, 'that' : 2 } > for key in dict.keys().sort(): > print key And instead we have to do for key in return_sorted(dict.keys()): print key Is it that much of a problem...? return_sorted's pretty trivial too: def return_sorted(alist): alist.sort() return alist Alex From michael at stroeder.com Fri Jan 26 07:44:22 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 26 Jan 2001 13:44:22 +0100 Subject: Why isn't crypt.py in Win32 Python distribution? References: Message-ID: <3A717126.BF8D346A@stroeder.com> Tim Peters wrote: > > cryptmodule.c, which is not compiled on Windows, because it relies on a > non-standard external C function > > extern char * crypt(const char *, const char *); > > that comes with Unix C libraries but is not supplied by Microsoft's C > runtime. So the only way it will ever show up on Windows is if someone > contributes an unencumbered Windows implementation. If the OpenSSL lib is around cryptmodule.c of Python 2.x could be built against it. Not sure about Windows though...and I'm not a C programmer... Ciao, Michael. From SBrunning at trisystems.co.uk Fri Jan 12 08:47:26 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 12 Jan 2001 13:47:26 -0000 Subject: is Python fully object oriented ? Message-ID: <31575A892FF6D1118F5800600846864D5B16EA@intrepid> > From: Max M?ller Rasmussen [SMTP:maxm at normik.dk] > From: Simon Brunning [mailto:SBrunning at trisystems.co.uk] > > This came up in this tread recently - see > . > > Yes but it only explains why there is a self at all, not why it has to be > explicit. > > I really cannot see why the second example here is better than the first. > > class accumulator: > > def __init__(): > self.sum = 0 # self is implicit here > > def add(value): > self.sum += value > > def getSum(): > return self.sum > > class accumulator: > > def __init__(self):# self is explicit > self.sum = 0 > > def add(self, value): > self.sum += value > > def getSum(self): > return self.sum > > Well not something I want to start a religious war about, but its annoying > having an itch you can't scratch ;-) > > Regards Max M > Max, Remember, Pythoneers don't *have* religious wars. We have reasoned discussions. ;-) I do see your point. Thing is though, if object instances were not marked in some way, method locals would have to be. Either way, something would have an itchy prefix. Putting the prefix on the object instances makes locals consistent with ordinary, non-class functions. 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 dan.rolander at marriott.com Sat Jan 20 18:25:21 2001 From: dan.rolander at marriott.com (Dan Rolander) Date: Sat, 20 Jan 2001 18:25:21 -0500 Subject: [XML-SIG] Re: Using Installer with PyXML References: <02c401c08311$a66e8f00$11260340@yin> <200101202225.f0KMPl200861@mira.informatik.hu-berlin.de> Message-ID: <037201c08338$42ce08a0$11260340@yin> Thank you for your assistance Martin. Although your analysis of the problem ("operator error") is close, I would probably more correctly identify it as operator ignorance. I'm still trying to figure out how to effectively use PyXML and build standalone executables with it. Since the Installer seems to play by its own rules when it comes to imports, it is especially challenging. I have not found the xml-sig documentation, or the python library reference, to be too helpful for someone new to xml processing, so I bought Sean McGrath's book "XML Processing with Python" and have found that to be *very* helpful. But his examples, which I was testing, use references to pyexpat. I tested your suggestion of using "from xml.parsers import expat" vs. "import pyexpat" and that works fine, but I'm not sure what the benefit of using that form is. I haven't quite grok'd all of this yet, but once I do I would have no problem with writing a mini-howto. Thanks again, Dan ----- Original Message ----- From: "Martin v. Loewis" To: Cc: ; ; Sent: Saturday, January 20, 2001 5:25 PM Subject: Re: [XML-SIG] Re: Using Installer with PyXML > from xml.sax import saxexts, saxlib, saxutils [...] > the packager (Gordon McMillan's Installer) is able to find xml.sax.saxutils, > but is not able to find xml.sax.saxexts or xml.sax.saxlib which actually > reside in _xmlplus.sax. I was going to claim this to be a bug in the installer, but it now rather seems like an operator error: The installer has now way of knowing that it ought to load the _xmlplus.sax.saxexts into the distribution, since there is no import statement for it. So announcing the full _xmlplus package to it is the right thing to do. > I can force builder.py to include the entire > _xmlplus tree by adding a packages=_xmlplus line to the [APPZLIB] section of > the .cfg file, but the exe still fails because it is looking for xml.sax.*: > > ImportError: cannot import name xml.sax.saxexts It's not clear what is causing that. It could be a bug in the installer, or it could be the distribution contains no pyexpat.pyd. In that case, you'll have to explicitly request inclusion of pyexpat.pyd. It would be good to check what files are actually included. > When I rename _xmlplus to xml and then run builder again without specifying > any additional packages, the EXE fails because it can't find an available > parser: > > File "c:\program files\python20\_xmlplus\sax\saxexts.py", line 77, in > make_parser > xml.sax._exceptions.SAXReaderNotAvailable: No parsers found No surprise. The installer is looking at import statements, but there are no import statements for xml.sax.drivers.*; instead, they are imported by calling __import__ for a computed string. So again, that is an operator error: everything imported "by magic" must be announced explicitly to such a packager. > If I manually import the entire PyXML tree (now named 'xml') by adding a > packages=xml line to the .cfg file, I get a little farther but now the exe > isn't able to find pyexpat. > > ImportError: cannot import name xml.parsers.pyexpat > > I then try to manually import pyexpat by adding xml.parsers.pyexpat to the > misc line in the [MYCOLLECT] section, but finder.py is not able to find it: > > File "D:\DOCUME~1\Dan\Software\Python\INSTAL~1\MEInc\Dist\finder.py", > line 121, in identify > ValueError: xml.parsers.pyexpat.pyd not found You did not say *how* you specified it - it might be that Installer mistook your command as trying to import a module named "pyd" from a package named "pyexpat" - that is not available. > If I changed the .cfg line in [MYCOLLECT] to misc=pyexpat.pyd then the core > \DLLs version of pyexpat.pyd is found and put into the dist directory. Now > when the exe is run I get a Windows error stating that the xmlparse.dll > couldn't be located. > > I add xmlparse.dll to the misc= line and then I get an error stating that > the xmltok.dll couldn't be found. > > I add xmltok.dll to the misc= line and voila! it works! When you use the pyexpat from PyXML, the difference should be that xmlparse.dll and xmltok.dll are not required. > I then replaced the core version of pyexpat.pyd in \DLLs with the > PyXML version and found that I could build a good exe without having > to manually include the xmlparse.dll and xmltok.dll. Not only do you not need to include them manually - they are not needed at all. Care to write a small howto document for the XML topic guide? > I start with the _xmlplus directory renamed to xml, because I know that's > necessary, and I build a new standalone installation. This time the pyexpat > file is imported to the dist directory as xml.parsers.pyexpat.pyd but the > exe won't import it: > > ImportError: cannot import name xml.parsers.pyexpat Do you have a traceback for that? All applications should import xml.parsers.expat, which should have from pyexpat import * so there should be no request to load xml.parsers.pyexpat. Older PyXML versions had such code, but it should have been wrapped with catching and ImportError, which then should fall back to load pyexpat unqualified. > The only fix I can figure out is to change the import statement to: > > import pyexpat > > and that works. As I said, the real solution is to write from xml.parsers import expat or, if you need to keep the pyexpat name, from xml.parsers import expat as pyexpat > 1. Replace the core xml directory with the _xmlplus directory, by renaming > _xmlplus to xml. I'm not entirely sure *why* this is needed, but it certainly can't hurt. > 2. Copy the PyXML pyexpat.pyd file from the xml.parsers directory to the > \DLLs directory. That is a good idea, yes. > 3. If pyexpat is needed, either explicitly import it in your script, or > manually include it in the standalone installation by adding an entry to the > misc line in the COLLECT section of the builder .cfg file. pyexpat should always be included in PyXML applications, so that is also fine. > 4. If importing from xml.sax, manually import the entire PyXML tree (source > files only) by specifying either packages=xml or directories=xml in the PYZ > section of the builder .cfg file. I would guess the same applies when importing DOM stuff - the DOM readers also use make_parser at some point. Regards, Martin From gregj at pobox.com Thu Jan 4 20:02:24 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Fri, 05 Jan 2001 01:02:24 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4E95FD.D6C737A7@engcorp.com> <3A52AD6A.62D043A2@engcorp.com> <3A534367.36B1FD18@uswest.net> <3A53F4B1.6227D241@uswest.net> <931gf302dsi@news2.newsguy.com> <932d0k$ita$1@nntp6.u.washington.edu> Message-ID: "A.M. Kuchling" wrote: > Yes. I've argued in the past that we should just leave Python's > syntax alone; all the proposed changes usually add 1% more > functionality and aren't worth the pain. Leave fancy changes to the > hypothetical Python3K or some other future descendent of Python, and > just work on the infrastructure around the language. I say leave the fancy syntax changes to the Perl programmers. They're animals anyway. ;-) -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com From scarblac at pino.selwerd.nl Tue Jan 2 08:59:03 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 2 Jan 2001 13:59:03 GMT Subject: using 'global' across source files. References: <3A51CC63.A90A0E0B@sara.nl> Message-ID: Bram Stolk wrote in comp.lang.python: > Using the 'global' keyword, I can have my functions > access global variables, like: > > # try.py > val=100 > > def change_val() : > global val > val = 2*val > > change_val() > print val > > However, this scheme falls apart if I split up this > code in two files, one containing the global, and > one containing the func. > > # prog.py > > from funcs import * > > val = 100 > > change_val() > print val > > # funcs.py > > def change_val() : > global val > val = val * 2 > > When running I get an error: > > bram at gazoo> python -i prog.py > Traceback (most recent call last): > File "prog.py", line 7, in ? > change_val() > File "funcs.py", line 5, in change_val > val = val * 2 > NameError: There is no variable named 'val' > > > Why? Because, at the time you imported everything from funcs.py, val didn't exist yet. You then run change_val(), funcs.val is created, but it doesn't get copied into every module that ever did 'from funcs import *'. > And how can I fix this? The best way is not to use "from module import *" at all. from...import can be tricky, and you should only use it when you know exactly what you're doing. If you did, you wouldn't ask this question :). Simply "import funcs" and use "funcs.val" to access it. An alternative is to do "from funcs import *" again after change_val(), but that's clearly inferior in my opinion. You'd have to do it again after every single change to val. Don't use from...import and certainly not from...import *. -- Remco Gerlich From huwdotlynes at ic.ac.uk Tue Jan 23 05:38:35 2001 From: huwdotlynes at ic.ac.uk (Huw Lynes) Date: 23 Jan 2001 10:38:35 GMT Subject: os.system easy question Message-ID: Hi all, I'm writing a script that will run an external program over a list of files such that: os.system("program %s" % filename) which would be fine if the program exited after running, however it doesn't. So the script stops when program is run for the first time. So the question is how to kill the external program after it has run. Or alternatively how to run an external program in such a way that the script will not halt. This is running on linux BTW. Thanks in advance, Huw Lynes To reply you know what "dot" should really be. From dsh8290 at rit.edu Fri Jan 19 13:06:20 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 19 Jan 2001 13:06:20 -0500 Subject: PSU uses emacs? In-Reply-To: <9490t009on@news2.newsguy.com>; from aleaxit@yahoo.com on Fri, Jan 19, 2001 at 10:10:12AM +0100 References: <948e4b$hm0$1@nnrp1.deja.com> <948fvj$oq1$1@panix6.panix.com> <3A67CDC3.7EACB07D@Lugoj.Com> <9490t009on@news2.newsguy.com> Message-ID: <20010119130620.J4478@harmony.cs.rit.edu> On Fri, Jan 19, 2001 at 10:10:12AM +0100, Alex Martelli wrote: | "James Logajan" wrote in message | news:3A67CDC3.7EACB07D at Lugoj.Com... | > Aahz Maruch wrote: | > > vi | > | > Viva vi! | | vi here too (gvim, actually -- Python-programmable and all:-). | I second the motion. :-) It's refreshing to see that the giants of python-list use a Real editor. ;-) -D From ehagemann at home.com Fri Jan 26 21:30:39 2001 From: ehagemann at home.com (Eric Hagemann) Date: Sat, 27 Jan 2001 02:30:39 GMT Subject: Use Python instead of Perl's GifGraph? References: <94sneo$507$1@sshuraaa-i-1.production.compuserve.com> Message-ID: Richard, I am doing that very thing presently with DISLIN. The package allows for a large number of graph type and options. I use the png format for my graphs. Do a web search for DISLIN and you will find the home page. Package is free for many platforms Good luck "Scobee, Richard" wrote in message news:94sneo$507$1 at sshuraaa-i-1.production.compuserve.com... > I have done very little Perl programming and that was a while back, but I am > finding a need for a feature that seems to be well developed in Perl: > generating Web-browser compatible charts/graphs at run-time from database > data and calculations. I have a copy of O'Reilly's Programming Web Graphics > with Perl & GNU Software by Shawn P. Wallace and it describes GIFGraph which > seems perfectly suited to this task. But being a casual follower of > programming trends, it seems that Python is quickly replacing Perl as the > web programmers scripting language of choice. So I was just wandering if > there are any libraries similar to GIFGraph already in Python or if I should > just go ahead and figure out how to do it in Perl. > > I am working on a couple of intranet applications and both have potential > uses for run-time generated charts/graphs generated from database data and > calculations. My background is mostly in VB but the biggest of these > projects is primarly using Oracle's implementation of J2EE in Windows NT so > I am already struggling with new tools, true OO programming, Java, etc. > From what I've read, Python sounds far more attractive for getting something > new to work in a new language than I remember Perl being. But if I have to > write my own graph generating library in Python, wouldn't it be more > productive to just struggle with Perl's GIFGraph? I would try to do most of > the work in Java but probably use CGI to feed the numbers to be graphed to > the Perl or Python script to generate a GIF. Does this approach make sense? > Is Python a good choice for this? > > Any opinions on this would be greatly appreciated. > > Richard J. Scobee > Information Solutions Developer > PBS&J > Miami, FL > rscobee at pbsj.com > > From bsb at winnegan.de Wed Jan 31 06:38:15 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 31 Jan 2001 12:38:15 +0100 Subject: Joining lists In-Reply-To: <0056900015556676000002L062*@MHS> References: <0056900015556676000002L062*@MHS> Message-ID: <87y9vs3qag.fsf@winnegan.de> jurgen.defurne at philips.com writes: > Hello, list members, > > Is there a simple way of joining two list to form only one list, like : > > [1, 5, 6, 4] [4, 6, 7] -> [1, 5, 6, 4, 4, 6, 7] >>> [1, 5, 6, 4] + [4, 6, 7] [1, 5, 6, 4, 4, 6, 7] HTH Siggy From grante at visi.com Wed Jan 3 09:45:29 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 03 Jan 2001 14:45:29 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> <3A4F4B4D.ECD6B172@engcorp.com> Message-ID: In article , Samuel A. Falvo II wrote: >On Tue, 02 Jan 2001 21:19:19 GMT, Grant Edwards wrote: >>>while (1) >>> { >>> T = f(); >>> if (T < 25) >>> break; >>> } >> >>I used that C indentation style for years, but I finally gave >>up since a) I could never get editors and the "indent" program >>to do it automatically, and b) nobody else on my projects >>wanted to do it that way, and it's important that all the >>source code on a project be indented consistently. [...] >To make it self-consistent, you need to do this: > >void f2( int c ) > { > int x = 0; > > while( x < c ) > { > printf( "X=%d\n", x ); > x++; > } > } That's how I did it. Except I used generally used 2 spaces per level instead of 3. That style was a hold-over from how I learned to do write Pascal: if whatever then begin do something; do something else end; >Though both methods are equally readable to me, I consider it >to be rather ugly syntax. Ya wanna talk about ugly? Apparently people pay prefectly good money for Pontiac Aztecs. ;) Personally, I find either style to be infinitely preferable to the K&R style: if (whatever) { do something; do something else; } else { yet another thing; } I simply can't read read code like that, and generally do an 'indent -gnu' on it before I try to figure out what's going on... -- Grant Edwards grante Yow! .. does your DRESSING at ROOM have enough ASPARAGUS? visi.com From spamers at must.die Mon Jan 29 11:41:28 2001 From: spamers at must.die (Fernando Rodríguez) Date: Mon, 29 Jan 2001 17:41:28 +0100 Subject: Scope rules in Python Message-ID: Hi! Is there any plans to change the scope rules in Python, so that function B can also access everything (including itself) defined inside function A?: def A(): def B(): return None return None It would make defining internal functions and closures _much_ easier... :-) TIA //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From claird at starbase.neosoft.com Mon Jan 15 07:19:00 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 15 Jan 2001 06:19:00 -0600 Subject: PHP vs Python References: <3A6283B3.76D07875@engcorp.com> Message-ID: <72B6C6200E534B63.3D98F933D99B17F4.4ABEC098883B13C3@lp.airnews.net> In article <3A6283B3.76D07875 at engcorp.com>, Peter Hansen wrote: . . . >> 2-who has more users > >Don't know. Suspect it's Python, that one being >rather broader in scope ("rather" means "massively" >in my world). No one understands the question, let alone being certain about the answer. This is often an obscured form for, "How many resumes include 'PHP' vs. 'Python'?" PHP might actually win out on that score. > >> 3-who hits the wall in scaling up and or handing complexity > >PHP. Yes. Most of the languages popularly aggregated as "scripting" have converged remarkably in their capabilities. One of the strongest differentiations, though, is that Python handles complexity well, and PHP is on the low end of that particular dimension. > >> 4-general performance > >Python is better for "general" performance, >given that PHP is not designed for "general" >use. Often people asking this question mean, "How's the CPU load when working with Apache, IIS, and iPlanet?" That's not *your* idea of "general", of course, and perhaps not even the original questioner's. 'Makes sense in Webworking circles, though. > >> 5-where would I be better off using PHP over Python > >An environment already using PHP. Or an environment >where Python is not available. Or if you know >only PHP. Only sure about the first two... There will be commercial announcements about PHP next week that will slightly extend PHP's domain of dominance. Here's what I emphasize: if you hang out (are a fellow employee, for example) with a lot of PHP enthusiasts, it's absolutely right to go with their flow and enjoy the advantage of their exper- tise. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From scarblac at pino.selwerd.nl Mon Jan 22 12:54:04 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 22 Jan 2001 17:54:04 GMT Subject: how to test for nesting inlist References: <94bhte$4iv$1@nnrp1.deja.com> <94bvgu0kt4@news2.newsguy.com> <94ea6k$4uc$1@nnrp1.deja.com> <94h7pi$b86$1@nnrp1.deja.com> Message-ID: cpsoct at my-deja.com wrote in comp.lang.python: > What are list comprehensions? I have looked and looked and looked in > books and on www.python.org and i see no mention of these. Is this > something new? or i am i just getting tripped up by the jargon and list > compreshensions are something i already know by another name? I am > confused. Hmm..... They're new in Python 2.0, they are inspired by languages like Haskell. >>> [ord(x) for x in "SPAM"] [83, 80, 65, 77] >>> [3*x for x in range(5)] [0, 3, 6, 9, 12] >>> [x for x in range(10) if x%2==0] [0, 2, 4, 6, 8] >>> [(x,y) for x in range(2) for y in range(3)] [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)] >>> [x for x in zip("SPAM", "EGGS")] [('S','E'), ('P', 'G'), ('A','G'), ('M','S')] There must be docs on it somewhere, but you can get a feel for it playing with examples, I think... -- Remco Gerlich From fredrik at effbot.org Mon Jan 29 18:50:17 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 29 Jan 2001 23:50:17 GMT Subject: marshal doesn't work with "file-like" objects References: Message-ID: Tim Peters wrote: > > Note the second part ("more of a puzzle" is a polite way to say > > "impossible, if you care about performance"). > > That wasn't my intent how about "impossible, if you care about performance, and don't want to invent yet another file format". Cheers /F From loewis at informatik.hu-berlin.de Sun Jan 21 15:50:04 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jan 2001 21:50:04 +0100 Subject: pyXML support for XSL tranformations?? References: <94d1tj$6sa$1@nnrp1.deja.com> <3a6aef10.3738521@nntp.sprynet.com> Message-ID: ullrich at math.okstate.edu (David C. Ullrich) writes: > I have the 4Thought XSL stuff from a little while ago. When I > installed it I had to replace the current (1.5.2) Python xml.dom > with one that came with 4Thought, which I gather was an > older version. I didn't like this but I did it and it works fine. In Python 1.5.2, there was no xml.dom - so I doubt you had replaced the Python xml.dom. What you might have replaced was some xml.dom from some PyXML; whether it was older or new would much depend on what PyXML version you actually had. > Q: Does the current 4Thought XSL stuff get along a little > more _cleanly_ with Python? (I actually haven't got around > to getting Python 2.0 precisely because it took a little > tweaking to get the XSL going in 1.5.2...) The current 4Suite release contains a copy of PyXML 0.6.3, enhanced by a few patches that will only appear in PyXML 0.6.4; you should use the PyXML version that comes with 4Suite. Regards, Martin From misfit at chopstick.cc Wed Jan 31 01:01:41 2001 From: misfit at chopstick.cc (T.C. Thomas) Date: Wed, 31 Jan 2001 06:01:41 GMT Subject: DataBase support References: <3a72fff7@news.bezeqint.net> Message-ID: <9TNd6.182765$15.39742565@news1.rdc1.az.home.com> "guy bashan" wrote: >Hello, > >I'm new to Python, and just installed the Komodo working with AcivePython >2.0. I gave a little overview over the syntax and built-in capabilities and >was really impressed. But I couldn't notice any database support. Was I >missing something ?? Does Python have any class dealing with databases >and tables ?? I am running kinfxdb against an Informix 7.3 database (data warehouse). It has worked quite well. Kinfxdb appears to be just a C library (Informix ESQL/C) of database functions with a Python wrapper module. --TC From paulp at ActiveState.com Sat Jan 13 05:09:40 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 13 Jan 2001 02:09:40 -0800 Subject: Speed of Python vs. Perl References: <93o3td$oee3u$1@fido.engr.sgi.com> Message-ID: <3A602964.78466D16@ActiveState.com> Paul Jackson wrote: > > ... > > Here are the two diff's. Probably there is something better I > should be doing with these diff's than just posting them here > -- if so, let me know. http://www.python.org/patches/ Paul Prescod From mikael at isy.liu.se Fri Jan 12 10:59:47 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 12 Jan 2001 16:59:47 +0100 (MET) Subject: boolean xor In-Reply-To: Message-ID: On 12-Jan-01 Steve Holden wrote: > I do not not not not not not not not not not agree with Mikael's assertion, > which I did not not not not not not not not not not make in a feeble > attempt > to be humorous. Apparently this was not not not not not not not not not > quite as funny as I thought. > > Usenet error: sense of humour failure. :o) /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 12-Jan-01 Time: 16:59:23 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From DavidL at SpamNONONoraqia.com Mon Jan 8 10:05:46 2001 From: DavidL at SpamNONONoraqia.com (David Lees) Date: Mon, 08 Jan 2001 10:05:46 -0500 Subject: ActivePython Installer for 2.0? References: <3A595540.9D34A5AA@NONOSpammytheworld.com> <3A5960F1.FBEDA567@SpamNonotheworld.com> Message-ID: <3A59D74A.65644F19@SpamNONONoraqia.com> Sorry Joel, I was tired and missed your question. Yes, you can download Python 2.0 and IDLE in one package at http://www.python.org/2.0/#download (this carries a BeOpen label). Mark Hammond's package nicely integrates itself with this and you can download it from http://www.activestate.com/Products/ActivePython/win32all.html His package adds PythonWin which is a Windows IDE for Python, which is what I have been using on both my NT and Win98SE machines. david > > Is Mark Hammonds Win32all-135 the Interactive Windows Developer program? If > > so, that means it is available as a seperate package from ActivePython or > > python in general? > > -- > > I have been Perl-Free for 3 Days, 2 Hours, 13 Minutes, and 28 Seconds. > > ------------------------------------------------------------ > > Joel Ricker joejava at dragoncat.net > > Just Another Python Hacker From jafo at tummy.com Sun Jan 21 01:37:59 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Sat, 20 Jan 2001 23:37:59 -0700 Subject: How do I know all thrown exceptions of a function? In-Reply-To: <94d93h$55d$1@troll.powertech.no>; from syver@NOSPAMcyberwatcher.com on Sun, Jan 21, 2001 at 01:02:36AM +0100 References: <94d93h$55d$1@troll.powertech.no> Message-ID: <20010120233759.B20336@tummy.com> On Sun, Jan 21, 2001 at 01:02:36AM +0100, Syver Enstad wrote: >Couldn't you use the source? Yeah, I suppose so. I don't think you should *HAVE* to review the code of the libraries you call, AND *EVERYTHING* that *THEY* call. It's not an effective use of my time... I usually just end up leaving it and track down what exceptions get thrown later. Luckily, Python exceptions are (almost) user-readable. Exceptions is something that I think Java does right... When you write a method, you have to either trap all exceptions which can be generated in it, or declare that it may throw those exceptions (so that the caller can handle them). Why do Python's exceptions remind me of one (frowned upon) way of handling automatic weapons: "Spray and pray". Sean -- One person's data is another person's program. -- Guy L. Steele, Jr. Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From aleaxit at yahoo.com Fri Jan 12 05:20:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 12 Jan 2001 11:20:10 +0100 Subject: boolean xor References: Message-ID: <93mlrr0h71@news1.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.979258453.29329.python-list at python.org... > Actually, I think it should work the other way. Because it is not *always* > possible to return one of the arguments, xor should never return either of > the arguments. This is the path of least-astonishment. Guess one could argue this way, yes. But "do this if feasible" is a pretty common metaparadigm -- it won't astonish anybody if 'this' doesn't get done when not feasible:-). > There's just no way to short circuit xor. Of course not, but, what's that got to do with it? > Your proposed method presumably continues as (Function, not method, but I guess you knew that -- we overload so many common words that it's extremely easy to hit one:-). > def xor(A,B): > if not A: return B > if not B: return A > return 0 No, I explicitly mentioned leaving off this last line you're adding. Why '0'? Returning None seems more Pythonic here (and can get accomplished by just having no third line in the function's body, although I acknowledge that cutesy touch is quite doubtful). > This may be better (returning only requires the implementation detail of > returning a reference), but it can also be worse (need to evaluate 2 values > after dereferencing them, plus then need to return a *different* reference). Sorry, I don't follow you at all here. E.g., "returning a reference" is definitely NOT an "implementation detail" in Python -- it's a deep, crucial part of its semantics; so, I don't get what you're driving at. Considerations in C would of course be completely different (C does NOT return original values, but rather 0 or 1, even from short-circuited && and || -- a design flaw, IMHO, but, to keep consistent with it, one would NOT want to 'return original values' from an xor-function either). Alex From sandj.williams at gte.net Sat Jan 20 13:30:14 2001 From: sandj.williams at gte.net (Steve Williams) Date: Sat, 20 Jan 2001 18:30:14 GMT Subject: Python COM and DCOM. References: <3RV96.10957$wt2.125028@news1.oke.nextra.no> <3A686640.534195EE@gte.net> <94ao0h$9ee$1@troll.powertech.no> Message-ID: <3A69DA94.F3A43841@gte.net> Syver Enstad wrote: > "Steve Williams" wrote > > Just a thought. Run dcomcnfg on your server, highlight Python server > name, > > click on properties and look at the location tab. You may also want to > look > > at the Identity tab, as well. > > > I've done this on the client machine, what should I look at on the server? > > FYI, I am already having several .exe C++ implemented COM objects being > accesed through DCOM from the same machine. Only the python object is > causing me headache. AFAIK, the only thing you have to do on the client machine is register the DCOM object. If the object is running on your client, then it's registered. You don't run dcomcnfg on the client--you run it on the server. In my client applications (VB and ACCESS, for the most part) I include the second parameter servername when I instantiate the object. Set PythonObject = CreateObject("PythonProgram.PythonClass","SrvrName") From dan.rolander at marriott.com Sat Jan 20 16:56:53 2001 From: dan.rolander at marriott.com (Dan Rolander) Date: Sat, 20 Jan 2001 16:56:53 -0500 Subject: Different deployment considerations (was: Python & GUI?) References: <3A674896.C7E52247@crepido.com> <3A698869.198D6263@crepido.com> <301DBDE62C14BD35.683C43A181247CB3.8398E5428BE1B406@lp.airnews.net> <94cm0r01b6j@news2.newsguy.com> Message-ID: <033801c0832e$d843a520$11260340@yin> Installer works fine with wxPython. It's just that Installer has built-in support for including the tk files. Dan ----- Original Message ----- From: "Alex Martelli" Newsgroups: comp.lang.python To: Sent: Saturday, January 20, 2001 10:27 AM Subject: Re: Different deployment considerations (was: Python & GUI?) "Cameron Laird" wrote in message news:301DBDE62C14BD35.683C43A181247CB3.8398E5428BE1B406 at lp.airnews.net... [snip] > side? Gordon's Installer makes Win* Tkinter apps into > single files ... I know of *no* other of the many Python > GUI bindings which enjoys this benefit. > > Does anyone have evidence to the contrary? I haven't checked, but, why wouldn't Installer (or other such solutions) work equivalently for, say, wxPython? Alex -- http://mail.python.org/mailman/listinfo/python-list From aleaxit at yahoo.com Thu Jan 11 11:19:06 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 11 Jan 2001 17:19:06 +0100 Subject: Error in pythonic InternetExplorer hta application References: <93k5cs$hc5$1@papyrus.erlm.siemens.de> Message-ID: <93kmgk018qn@news1.newsguy.com> "Christof Pastors" wrote in message news:93k5cs$hc5$1 at papyrus.erlm.siemens.de... [snip] > I get a NameError exception because the name "TheAddress" is not found. > In which object can I find "TheAddress"??? > I guessed "window.TheAddress" and "document.TheAddress" without success. It's actually: TheAddress = document.all('TheAddress') Javascript does peculiar things this way! Note that TheAddress is the ID attribute of one tag: > I notice (with curiosity) that the expressions with which the width attribute is computed ARE evaluated in Javascript (so they can use, e.g., AddText and AddGo "as if" they were objects!), but that's normal I guess, since so far nobody's said that Python is the default language for this HTA, so the default remains Javascript. Fine, just be *careful* -- you can't use *Python* expressions here (not without specifying the language!), it MUST be JavaScript. The 'general expressions to determine/recompute attributes transparently at runtime' feature of IE is new enough (5.5?) that I've never digged deep into it, so I can't yet be of much help about it. I guess that, for a rich and complex HTA, an OK solution might be to wrap the real 'document' object into a utility class: class docWrapper: def __init__(self, doc): self.__doc = doc def __getattr__(self, name): try: return getattr(self.__doc, name) except AttributeError: return self.__doc.all(name) for example, with something like document = docWrapper(document) at the start, if one insists on using document.Whatever for BOTH real attributes of the document object AND descendant objects thereof which have a certain ID (personally, I find it clearer to distinguish, but, whatever floats your boat). Or, to be able to just use TheAddress AS IF it was a global variable, one would have to use black-magic on the module object -- substituting it with a class-instance with the required __getattr__ (shades of a very recent thread...) -- I doubt this would work, though (perhaps a good thing: *explicit is better than implicit*!-). There's a worse problem, though, which I've met before, but to which I don't yet know a solution. Once you've fixed the 'TheAddress' problem, the script will break again, right here...: > TheAddress.onkeypress = clickShortcut Specifically, a large messagebox with a traceback will explain to you (it's win32com talking, I think) that "Object of type 'function' can not be converted to a COM VARIANT". And it's right -- there's no normal Python (win32com) conversion to take a function (clickShortcut) and make a VARIANT out of it -- and a Variant is what you need to be able to set a COM object's property, like, here, the 'onkeypress' property. I *THINK* that what MS's HTML DOM expects here is a dispatch-pointer, i.e. in Python terms a wrapped COM object -- but, I'm not sure, nor do I know exactly *what* would be expected of this object. I've tried finding out experimentally, by setting such onwhatever properties to wrapped Python objects that would trace the names and/or ID's of methods being queried for and/or called, etc, but I've never been able to find out more. If anybody *does* know what's supposed to go into the various .onfoobar properties, when scripting the HTML DOM from Python, *please* let us all know...!!! Any pointers to docs, no matter how obscure, will also be very welcome -- I'm an old hand at squeezing some bits of info out of obscure MS docs, it's just that in this case I've been able to found no shreds thereof. So, anyway, until we manage to crack the secret of the .onplok properties, we'll have to catch the events in other ways. Note that the same issue applies to attributes set inline, such as the onclick="navigate()" which you set in the button element of id AddGo: the property is apparently just a string, and it's NOT clear what happens to it when the button is clicked (even if one sets the further attribute to specify the language -- language=Python, for example); the function appears to never execute -- it would be hard to tell in your version, since 'print' goes nowhere, but it's easy to add something like: import win32api class OdsFile: def write(self, what): win32api.OutputDebugString(what) import sys sys.stderr = sys.stdout = OdsFile() so that 'print' statements become useful for debugging (this needs dbmon.exe, or some other ways to watch for outputdebugstrings being slinged around by processes not under a debugger -- I guess you could easily use win32traceutility for the same purpose, I'm just not used to it since dbmon-plus-OutputDebugString are not language-dependent so I can use them for multi-language debugging &c). There are several other approaches to handling HMTL DOM events. win32com's general approaches to event handling can be used. Also, the attachEvent method of HTML DOM elements helps -- the COM class instance' thus 'attached' is supposed to get its DISPID_VALUE method (method of DISPID 0 -- the 'default' one -- should be mapped to a method named _value_ according to DesignatedWrapPolicy) called when the event occurs (with the event-object as an argument). The latter doesn't *quite* work, because that policy only uses _value_ to set the attributes-to-dispids map, and the 'call' from the HTML DOM is looking more specifically for a *method*. Workaround is easy, though (that is one great thing of Python: while a very high level language, it DOES 'expose its internals' so you can, at need, work around issues, problems, bugs, limitations; just try doing that for most others...:-). So, anyway, here's a version of your HTA which should work as (I believe) you intended it to...: HTML Application Example Address

Note that all of the output is based on OutputDebugString; dbmon can be downloaded as a sample application from http://msdn.microsoft.com/library/devprods/vs6/visualc/vcsample/vcsmpdbmon.h tm it's also part of the win32 sdk, and you can also get several equivalent utilities such as dbwin32 at http://www.winsite.com/info/pc/win95/programr/dbwin32.zip/ etc, etc. It shouldn't be hard to change it to use win32trace instead, if you wish to, since the actual OutputDebugString call is, after all, in just one place!-) Alex From banksam at swanhill.net.au Mon Jan 15 16:34:21 2001 From: banksam at swanhill.net.au (banksam at swanhill.net.au) Date: Mon, 15 Jan 2001 21:34:21 GMT Subject: Beginner's question - class definition References: <3a6366a8.4537644@news.ruralnet.net.au> Message-ID: <3a636cb7.6088966@news.ruralnet.net.au> On Mon, 15 Jan 2001 21:14:20 GMT, banksam at swanhill.net.au wrote: >Can anyone explain please why the following definition ( from the >Python documentation) > Thank you. Problem solved. From tebeka at lycosmail.com Sun Jan 28 03:59:44 2001 From: tebeka at lycosmail.com (Miki Tebeka) Date: Sun, 28 Jan 2001 10:59:44 +0200 Subject: Python 2.1 slower than 2.0 References: <94v49b$fhueb$1@ID-11957.news.dfncis.de> Message-ID: <950n22$pfj@news.or.intel.com> On my win2k 2*P500 I get: [10:57]>c:/apps/Python20/python.exe pystone.py Pystone(1.1) time for 10000 passes = 1.55122 This machine benchmarks at 6446.56 pystones/second [10:58]>c:/apps/Python21/python.exe pystone.py Pystone(1.1) time for 10000 passes = 1.60395 This machine benchmarks at 6234.6 pystones/second A little slowdown here as well. Bye. ---------------------------------------------------------------------------- -- Smile, damn it, smile. lambda msg: { 'name' : 'Miki Tebeka', 'email' : 'tebeka at lycosmail.com', 'homepage' : 'www.tebeka.freeservers.com', 'quote' : "I don't suffer from insanity, I enjoy every minute of it." }[msg] From joe at apk.net Sun Jan 7 01:50:28 2001 From: joe at apk.net (Joseph T. Adams) Date: 7 Jan 2001 06:50:28 GMT Subject: Should I learn Python or Java? References: Message-ID: <9393jk$fku$1@plonk.apk.net> Charlotte Williams wrote: : Hello, : I am a Visual Basic programmer who wants to increase his knowledge of : programming languages. Now that the curses, boos, and barrage of rotten : fruit are out of the way, I would like to ask this group a few questions : :-) ... Welcome to the Light Side. We hope you'll stay! :) : I notice that there is a lot of demand for Java programmers. The only : experience I have with an OO language is Smalltalk. My questions are: : 1. Which language would be best to learn, Java or Python. From a VB : standpoint, which has the least learning curve? That probably is going to depend on what you want to do. Java and Python have different strengths. I've found both fairly simple and easy to learn. Smalltalk is far more similar to Java than to Python, so this may make Java feel a little more familiar for you. But I'd strongly recommend learning *both* languages if possible. : 2. Is going from object-based to object-oriented programming that huge a : jump? I want to learn an OO language, however I plan on utilizing it in my : career. It is a jump for people who know only VB, but Smalltalk is arguably the purest OOPL, so with that background you shouldn't have much trouble. : 3. Which one is the most "fun" to program in? I kind of like both. : 4. Is Python multi-platform? How is it's performance compared to JAVA in : an internet situation? It's reliability? Python is very portable/cross-platform - arguably in some respects more so than Java. Can't address the performance or portability issues as I've never had any occasion to directly compare them. : 5. Do you for see Python as becoming a major player like Java servlets and : MTS? Can you see Python demand outstripping Java demand in 2 years time? In 2 years, unlikely, since Java has a large and growing mindshare inside medium to large IT organizations. Over time, I would expect both to grow, largely at the expense of lower level languages including C and VB. Python will probably grow faster, but I don't see it ever replacing Java because the two languages have very different design goals and fill very different niches. : Many of these questions are in response to a post I saw earlier where Python : was being touted as the next evolution of OO programming. It went something : like... : C --> C++ --> Java --> Python. : I'm really interested in hearing from VB programmers that decided to jump : into one or both of the languages, has pretty good knowledge (enough to get : a Java or Python job) and the headaches and experiences they had learning : about them. Do you need a formal CS education to grasp them? I tried : finding information on these two, but the experiences I always found were C : or C++ programmers that tried to tackle them. Some sites actually belittled : me as a VB programmer. Since I have heard such good things about this : groups hospitality, I thought I would ask here first. Thanks. I'm actually an xBase guy who was forced by the market into VB, but is now trying to learn some more powerful (and portable) languages including both Java and Python. I don't have a strong CS background, but wish I did, and am now belatedly beginning to focus more on learning theory and application of that theory, rather than just the mechanics of a specific tool, because it seems to have a much greater effect on the quality and cost of the final product, particularly during the maintenance phase. Joe From fredrik at effbot.org Thu Jan 25 15:04:30 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 25 Jan 2001 20:04:30 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: Neil Cerutti wrote: > My advice, although I've got limited experience, is to go with > Tkinter, and read the following great document, by Python Labs' > Fredrik Lundh: footnot: I work for Secret Labs, also known as PythonWare. (for some reason, someone thought it would be a good idea to create a new company name from two of our trademarks...) Cheers /F From eandroid at my-deja.com Mon Jan 8 11:42:09 2001 From: eandroid at my-deja.com (eandroid at my-deja.com) Date: Mon, 08 Jan 2001 16:42:09 GMT Subject: Arrow Keys in the Interpreter Interface Message-ID: <93cqku$prk$1@nnrp1.deja.com> I use zsh as my shell instead of bash and as a result my arrow keys do not properly work in the interpretter, printing ^[[A instead of scrolling back though my history. Has anyone seen this? If I change my default shell to bash and relogin it starts working. I think that this may be related to scripts that the shell runs on login but Python is the only program that seems affected. Thanks, I appreciate all suggestions. Sent via Deja.com http://www.deja.com/ From sholden at holdenweb.com Thu Jan 11 11:57:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 11 Jan 2001 11:57:09 -0500 Subject: ActivePython2.0 - Server Side objects for ASP problem References: <93j0qi$7cv$1@bob.news.rcn.net> <93k6k5$1g7$1@bob.news.rcn.net> <9li76.10661$X3.66765@e420r-atl1.usenetserver.com> <3A5DD081.F37275A@gte.net> Message-ID: "Steve Williams" wrote in message news:3A5DD081.F37275A at gte.net... > Steve Holden wrote: > > > "Satheesh Babu" wrote in message > > news:93k6k5$1g7$1 at bob.news.rcn.net... > > [snip] > > > > Making a COM object on the server is also beyond me. > > > > If you get a copy of Mark Hammond and Andy Robinson's "Python Programming on > > Win32" you'll be doing it before bedtime and thinking nothing of it. > > Seriously, it's a lot less complicated than you might imagine. > > > > [snip] > > Danger Will Robinson!! > > You can, indeed, write and install a COM object on the server before bedtime, > but you might be up all night getting your client to talk to it. Some pitfalls: > > 1) The client doesn't have Python installed. It uses MS Access or VB or > Excel or Word. How do you register your COM server on the client? Whose > classid/appid do you use? Light a taper and go down into the regedit dungeon. > > 2) When you try to use the COM object you get 'Permission Denied'. Time to > read a ton of MS Q documents and maybe talk to an unfriendly and ignorant NT > administrator. > > 3) When you try to use the COM object, you get 'ActiveX can't create. . .'. > Time for some more bedtime reading. > > 4) Your client is a laptop manufactured in the Pleistocene era and needs > dcomcnfg and regsvr32. . . Don't forget the service packs. > > 5) You call your friends and they say "I've never had that problem, maybe you > should install MTS. . ." > I understand these objections. But I also understood Satheesh to mean he was thinking of having the web server communicate with the COM object, not the web client. He clearly knows what he's doing in that area (did you take a look at the site he was testing with?), and he clearly already had PythonCom installed on his server (even if it was PWS: the same server I used to debug his original problem). In other words the COM object's client will be the web server, which has Python installed. So I suspect that all your valid objections are objections to something I wasn't suggesting, and are not required. I could be wrong, though. Maybe I *was* suggesting that, or maybe that *is* required :-) if-mts-is-the-answer-then-the-problem-was-probably-created-by-microsoft-ly y'rs - steve From kern at myrddin.caltech.edu Sun Jan 28 22:29:30 2001 From: kern at myrddin.caltech.edu (Robert Kern) Date: 29 Jan 2001 03:29:30 GMT Subject: Hack request: rational numbers References: <951h34$tch$1@nnrp1.deja.com> <2W%c6.128157$ge4.46108705@news2.rdc2.tx.home.com> <3A749696.2BD57BA9@alcyone.com> <3A74A0DD.30DE420A@alcyone.com> Message-ID: <952o2q$3ll@gap.cco.caltech.edu> In article <3A74A0DD.30DE420A at alcyone.com>, Erik Max Francis writes: > Issac Trotts wrote: > >> > (There is a geometric algebra module for Python, by the way.) >> >> I've been looking for something like this. Do you know the URL? > > I don't know if there's a Web page for it, but it was announced on > comp.lang.python: > > http://www.deja.com/=dnc/getdoc.xp?AN=662575210 > -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." From jafo-pythonlist at tummy.com Sun Jan 21 01:54:43 2001 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Sat, 20 Jan 2001 23:54:43 -0700 Subject: curses, python20/152, RH70/62, postgresql problems In-Reply-To: <94731d$9j4$1@nnrp1.deja.com>; from dubal@my-deja.com on Thu, Jan 18, 2001 at 03:44:49PM +0000 References: <94731d$9j4$1@nnrp1.deja.com> Message-ID: <20010120235443.D20336@tummy.com> On Thu, Jan 18, 2001 at 03:44:49PM +0000, dubal at my-deja.com wrote: >First we tried to install the Beopen Py20 rpm on >RedHat 7.0. It looks for some old libs and >doesn't install. Ugh. Yeah, I found the BeOpen RPM to be lacking. I've got a copy I've tweeked a bit, in particular it includes SSL support in the sockets, and doesn't stick Python in /usr/local/bin. You can download the SRPM from: ftp://ftp.tummy.com/pub/tummy/RPMS/SRPMS Turn it into a binary RPM with "rpm --rebuild Python-2.0-1.src.rpm" (which stores the binary RPM in /usr/src/redhat/RPMS/i386 or the like by default). Note that this builds Python as "/usr/bin/python2", so you can install it *NEXT TO* instead of on top of Python 1.5.2. This can be changed by installing the SRPM, and editing the .spec file -- the third line or so specifies what the suffix is -- commenting that out should make it install to /usr/bin/python You'll probably need to install the glibc and possibly gcc errata from RedHat to build it as AMK mentioned. Sean -- "Action... Romance... Welding... That movie has everything." -- Evelyn Mitchell speaking about _Subway_, 1998 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From ullrich at math.okstate.edu Sat Jan 13 13:31:31 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 13 Jan 2001 18:31:31 GMT Subject: is Python fully object oriented ? References: <93nifo$qa7$1@nnrp1.deja.com> Message-ID: <93q6u4$rh9$1@nnrp1.deja.com> In article , "Rainer Deyke" wrote: > "David C. Ullrich" wrote in message > news:93nifo$qa7$1 at nnrp1.deja.com... > > A person could invent syntax to do exactly that one thing > > with an implicit self, maybe with an "inherited" keyword > > as in the one language I know with an implicit self (Object > > Pascal). How would a person do > > > > class C(A, B): > > def __init__(self): > > A.__init__(self) > > B.__init__(self) > > > > with an implicit self? > > The following is valid C++: [...] > > A better example might be a non-constructor function: Yes. > struct A { > void f() {} > }; > > struct B { > void f() {} > }; > > struct C : A, B { > void f() { A::f(); B::f(); } > }; Ok. I won't ask how you would call a method of another class passing something other than the current instance in place of an implicit self - probably you'd have an answer, and if you didn't it would be a slightly contrived question anyway. I can't help it, I have to ask. All the examples so far have been a little special, like the "other" class is an ancestor. Can a person do something equivalent to AnyClassAtAll.AMethod(AnyInstanceOfAnyOtherClass) with an implicit self? (It just seems to me that an explicit self _must_ be more general than an implicit self, allowing _something_ that an implicit self doesn't. Maybe not.) Besides, I was wondering how you'd do it in Python, not in C++. (haha) > -- > Rainer Deyke (root at rainerdeyke.com) > Shareware computer games - http://rainerdeyke.com > "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor > > -- Oh, dejanews lets you add a sig - that's useful... Sent via Deja.com http://www.deja.com/ From cpsoct at my-deja.com Sat Jan 20 03:23:12 2001 From: cpsoct at my-deja.com (cpsoct at my-deja.com) Date: Sat, 20 Jan 2001 08:23:12 GMT Subject: how to test for nesting inlist Message-ID: <94bhte$4iv$1@nnrp1.deja.com> Is there a way to test if a list in nested and if so how deep? so that you could type y=[1,2,3] x=[1,[2,3]] howDeep(y) howDeep(x) and it would return 0 (no nesting) for y and 1, for x (1 level of nesting) Is this possible? It would seem really useful, but i don't see anything in the docs about how to do this. cheers, kevin parks seoul korea cpsoct at lycos.com Sent via Deja.com http://www.deja.com/ From tbryan at python.net Mon Jan 8 19:13:39 2001 From: tbryan at python.net (Thomas A. Bryan) Date: Mon, 08 Jan 2001 19:13:39 -0500 Subject: Problems with py-indent-region in XEmacs References: <93655e$rds$1@nnrp1.deja.com> <3A5723C1.7B53721@python.net> <93d52g$46g$1@nnrp1.deja.com> Message-ID: <3A5A57B3.1D87EF3D@python.net> redhouse at my-deja.com wrote: > > Thanks. > > The thing I'm doing is that I am taking a parm list and assigning each > parameter to a class data member of the same name. I have an elisp > function which is just a glorified macro to do this, I'm guessing that you're also an (X)Emacs fan. You could start on the def line with something like this: (defun next-line-indent() (interactive) (back-to-indentation) (next-line 1) (forward-char-command 4) ) > very frequently and was trying to speed it up. Never type something twice when you can program it once, right? laziness-is-one-the-first-great-virtues-of-a-programmer*-ly yours ---Tom *_Programming_Perl_, p. 609 From aleaxit at yahoo.com Fri Jan 12 03:19:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 12 Jan 2001 09:19:07 +0100 Subject: is Python fully object oriented ? References: <20010110184830.13286.00000826@ng-fg1.aol.com> <3A5E5C21.3E036BFE@intelligenesis.net> <3A5E935D.CF641658@dcube-resource.be> Message-ID: <93meoq0bit@news1.newsguy.com> "Fredrik Lundh" wrote in message news:GKy76.5649$Qb7.787381 at newsb.telia.net... > Ben Hutchison wrote: > > I'd like to see some primary evidence of this "design choice" process, describing > > the motivating reasons. Presumably there are some web references somewhere. My > > instinct tell me it resembles an implementation consequence, rather than a free and > > deliberate choice. > > http://www.python.org/doc/FAQ.html#6.7 > > "6.7. Why must 'self' be declared and used explicitly in > method definitions and calls?" > > "By asking this question you reveal your C++ background. :-)" Actually, these days, a very similar question might come from somebody who's never touched C++ with a 10-foot pole and detests it -- a 100% Pure Java user, for example. > (summary: python's not C++. given Python's object model, this is a > simple and straightforward solution to the "is this a local variable or > an instance variable?" problem. and guido likes it. end of story.) The answer's substance looks impeccable to me -- I was just wondering about the reference to C++ specifically, which might perhaps cause some consternation... Alex From aleaxit at yahoo.com Tue Jan 9 17:32:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 9 Jan 2001 23:32:17 +0100 Subject: Should I join the PSA if it's "no longer relevant"? References: Message-ID: <93g3lj0e7c@news2.newsguy.com> "Lyle Johnson" wrote in message news:t5mvkjd31cvh98 at corp.supernews.com... [snip] > This is not a direct answer to your question, but if you're just looking for > website & other development-related hosting for an open source project you > might consider SourceForge: > > http://sourceforge.net > > I've had pretty good luck with them so far (for hosting FXPy). Or OpenAve.Net (http://www.openave.net/) -- I have no experience with them yet, but (after a couple of months of reasonably plain sailing) I've found the service at sourceforge over the last month or so degrading near-unbearably, to the point that I'm seriously thinking of moving elsewhere unless they get their act together again. Alex From KatMouse at gmx.de Wed Jan 10 14:21:09 2001 From: KatMouse at gmx.de (Eduard Hiti) Date: Wed, 10 Jan 2001 20:21:09 +0100 Subject: Reading Microsoft Outlook Express .dbx files References: Message-ID: <93ico2$vui$00$1@news.t-online.com> Go to www.freshmeat.net and type 'outlook' into the find box. You'll get links to various Outlook .dbx converters which should be open sourced. Maybe those will give you an idea about how to proceed. Eduard "Steve Holden" wrote in message news:h7_66.8949$X3.91000 at e420r-atl1.usenetserver.com... | In my trek through the various mail packages the Windoze user may be | confronted with I am currently battling with Outlook Express. It's actually | rather better than I feared. | | Its native folder format appears to be a ".dbx" file, about which I have no | information. Does any reader have experience with either reading these | files, or automating OEx to provide them to a Python program in RFC822-style | formats? | | Or, indeed, any other way of extracting mail items from the files created by | OEx. | | regards | Steve | -- | Tools, training and technology can help you meet your information needs | | From m.faassen at vet.uu.nl Mon Jan 15 07:19:31 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jan 2001 12:19:31 GMT Subject: is Python fully object oriented ? References: Message-ID: <93upsj$k0a$1@newshost.accu.uu.nl> Delaney, Timothy wrote: [snip me describing how object attributes can be copied into local variables] > Ooh - dangerous in a multithreaded app ... ;) I have little experience programming multithreaded apps, but find it hard to believe that avoiding this techniques makes all the danger go away without the need for special attention anyway. Could you elaborate? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From junaftnoon at nospamplzyahoo.com Thu Jan 18 07:19:28 2001 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Thu, 18 Jan 2001 21:19:28 +0900 Subject: Displaying HTMLs with Tkinter References: <945db6$umq$1@nnrp1.deja.com> <945g0b$sd$1@nnrp1.deja.com> <3A66C964.46EEE52C@mail.dvz.fh-koeln.de> Message-ID: <946n3c$p48$1@news.nuri.net> "Stephan Effelsberg" wrote in message news:3A66C964.46EEE52C at mail.dvz.fh-koeln.de... > > > penman schrieb: > <...> > > > The Tk module indeed does have the capability to display HTML. If you > > look > > in the Demos/www directory in the standard Python distribution, try > > running > > "www8.py file:" and "www12.py file:". > > [end of quote] > > > > But I can't find the files anywhere. Are they obsolete now? > > In my distribution (1.5.2 for Windows) it is located in Demo/tkinter/www . > > You can still download this version if it is missing(?) in yours . > > The tkinter demos from Python 1.5.2 spit out raw html texts to text widgets. If you want to interpret and show them like a web browser, just as wxHTMLWindow does, you'd better look for Grail or PySol. However, PySol's tkhtml doesn't seem work very well with general HTMLs -- it's too slow and heavy. Haven't tried Grail yet. Best regards, June. From mwh21 at cam.ac.uk Fri Jan 26 08:49:30 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 26 Jan 2001 13:49:30 +0000 Subject: python-2.1 function attributes References: Message-ID: "Tony J Ibbs (Tibs)" writes: > Michael Hudson wrote: > > How about "having"? > > > > def func(param) having (publish=1, secure=0): > > """ docco """ > > print "bobbins" > > > > to emphasize the attribute-ness one could use a dot prefix: > > > > def func(param) having (.publish=1, .secure=0): > > """ docco """ > > print "bobbins" > > > > I think I like this (though I'm not sure about the dot > > prefix). I might see if I can whip up a patch... > > Yes, "having" is better than "with". That's neat. And it doesn't have > any obvious other meaning for me. (the important thing was probably > getting away from "with" - once that's done, if people really don't like > "having", suggesting new words is simple enough, at leisure) Cheers for the support! > I'm not sure about the dot prefix either - it makes them obviously odd, > but feels sort-of unPythonic. I think I prefer without. Whichever I do it will be dead simple to convert to the other, so I'll do both and play around with them, and post them to sf (assuming I can actually work out how to write the patch). Done Grammar/Grammar, on to Python/compile.c (haven't been in *there* for a while...)! Cheers, M. -- ARTHUR: But which is probably incapable of drinking the coffee. -- The Hitch-Hikers Guide to the Galaxy, Episode 6 From debl at NOnoNoSpammytheworld.com Sat Jan 6 20:15:29 2001 From: debl at NOnoNoSpammytheworld.com (David Lees) Date: Sun, 07 Jan 2001 01:15:29 GMT Subject: Should I learn Python or Java? References: Message-ID: <3A57C33A.7AB8DF6D@NOnoNoSpammytheworld.com> I only feel competent to answer your question 1, 3 and a bit of 4. I have done VB over the years from version 1 to 5 along with a bit of C and started playing with Python recently. I have only done the 'hello world' type Java programs, but I can tell you that Python is a LOT easier in terms of learning curve. I have done several smallish Python programs (The biggest about 200 lines). and found it a pleasure to work with. It is a very different experience than VB, because the standard IDEs (IDLE and PythonWin in the PC world) are not GUI builders. However, once I got a little familiar with the string library (for the particular text processing I am doing) I found the environment pretty good. You can switch back and forth between an interactive screen and a program you are writing/debugging. I have found it real helpful to be able to try out methods and functions interactively while coding. The experience is somewhat analogous to VB in terms of ease of debugging and development, but the feel IS very different. However, you will not find anywhere near the number of books to guide you. Also, this group is a big help for advice on specific language details. Multiplatform? It is excellent. At my office we run both RedHat Linux and NT and at home I run Win98. The same source code runs all 3 OS without modification. Of course there are some functions that are OS dependenent, like spawning and threads that you need to read the documentation. The book by Beazley is a real nice compact summary that gives you a lot of this info. The tutorial is a bit terse, so I would suggest a book like the one by Alan Gauld (Learning to Program using Python) or the Lutz and Ascher Book (Learning Python). I have started to play with some of the internet capability. My biggest problem has been lack of examples, but I think there are several authors working on remedying that. Further, the simple cgi program that I wrote and another simple URL reader that I wrote, with help from the folks on this group, work great. The only downside I can see is that in terms of jobs, Java seems to be bigtime compared with Python. However, if enough of us use it this could change :) david lees > 1. Which language would be best to learn, Java or Python. From a VB > standpoint, which has the least learning curve? > 2. Is going from object-based to object-oriented programming that huge a > jump? I want to learn an OO language, however I plan on utilizing it in my > career. > 3. Which one is the most "fun" to program in? > 4. Is Python multi-platform? How is it's performance compared to JAVA in > an internet situation? It's reliability? > 5. Do you for see Python as becoming a major player like Java servlets and > MTS? Can you see Python demand outstripping Java demand in 2 years time? > > Many of these questions are in response to a post I saw earlier where Python > was being touted as the next evolution of OO programming. It went something > like... > C --> C++ --> Java --> Python. > > I'm really interested in hearing from VB programmers that decided to jump > into one or both of the languages, has pretty good knowledge (enough to get > a Java or Python job) and the headaches and experiences they had learning > about them. Do you need a formal CS education to grasp them? I tried > finding information on these two, but the experiences I always found were C > or C++ programmers that tried to tackle them. Some sites actually belittled > me as a VB programmer. Since I have heard such good things about this > groups hospitality, I thought I would ask here first. Thanks. > > David Williams From kirschh at lionbioscience.com Fri Jan 19 03:41:41 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 19 Jan 2001 09:41:41 +0100 Subject: How to close all files between fork and exec? References: <9463d9$eif$1@panix6.panix.com> <9475av$t13$1@panix2.panix.com> Message-ID: aahz at panix.com (Aahz Maruch) writes: > In article , > Harald Kirsch wrote: > >aahz at panix.com (Aahz Maruch) writes: > >> In article , > >> Harald Kirsch wrote: > >>> > >>>Python has fork/exec. I want to use it. After fork and before exec I > >>>would like the child process to close all files other than 0, 1 and 2 > >>>(i.e. standard input/output/error). > >> > >> Why not simply keep track of all open files in a dict or list? > > > >Thereby duplicating the work the operating system does anyway? And how > >would a module for forking special processes keep track of the files > >opened by the main program calling it? Hmm... > > from fork import open > Hmm, this is becoming somehow interesting because I have got no idea why you think this relates in any way to my question. Either you try to tease me or we have a communication problem. But I think I should stay calm and try to start all over: Suppose you have the assignment to write a module for me which, for whatever reasons, has to fork/exec certain subprocesses. I want to use your module as a service in my software. But my software will have a whole bunch of files open when it calls your module. How did your module keep track of all these files so that it is able to close them all before execing. --- If you now say that your module cannot do that and that it would be the obligation of my software to close unneded files before calling your module, I at least start to understand your arguments. However I maintain the opinion that this would be nonsense. > As for your first question, you're always responsible of keeping track > of whatever resources you're using; it's just that sometimes, the > language you're using provides conveniences to make that easier. Philosophically deep, general statements don't really help me on practical problems. Thanks anyway, Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION Bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From grante at visi.com Wed Jan 17 13:28:58 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 17 Jan 2001 18:28:58 GMT Subject: threading: how to kill a (possibly blocked) thread? References: <3A649FE4.E582D0E0@ll.mit.edu> <944ekb$ri$1@nnrp1.deja.com> Message-ID: In article <944ekb$ri$1 at nnrp1.deja.com>, rturpin at my-deja.com wrote: >> What you really need to do is ensure that your threads >> can accept an external request to terminate themselves .. > >The ideal way to do this is with a timed interrupt that >invokes a function in the thread. The thread would start >by setting this interrupt: > > set_interrupt(8, funcCallBack) Where does set_interrupt come from? I can't find it in any of the documentation. I did a search on www.python.org, and it claims a hit on section 4 (Exception Handling) of the API reference manual, but when examined, it doesn't contain the string "set_interrupt". A search of comp.lang.python turns up only the occurrance quoted above. -- Grant Edwards grante Yow! AIEEEEE! I am having at an UNDULATING EXPERIENCE! visi.com From dsh8290 at rit.edu Thu Jan 11 12:23:36 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 11 Jan 2001 12:23:36 -0500 Subject: Defining a new exception with multiple args In-Reply-To: ; from danielk@aracnet.com on Thu, Jan 11, 2001 at 07:14:25AM -0800 References: Message-ID: <20010111122336.A18281@dman.rh.rit.edu> On Thu, Jan 11, 2001 at 07:14:25AM -0800, Daniel Klein wrote: | Using the Beazley book as a guide, I have defined a new exception as: | | class RecordNotFoundException(Exception): | def __init__(self, filename, recordid): | self.filename = filename | self.recordid = recordid | Here you have set some instance variables that only exist in your class. | However, this is what happens when I raise this exception: | | >>> raise RecordNotFoundException("myfile", "myid") | Traceback (innermost last): | File "", line 1, in ? | raise RecordNotFoundException("myfile", "myid") | RecordNotFoundException: Here the interpreter has the exception instance, but the print routine doesn't know about your special arguments. | Why is it showing '' instead of the arguments I | passed? | | Thanks for any assistence, | Daniel Klein try this: class MyExcept( Exception ) : def __init__( self , *args ) : # init the Exception's members Exception.__init__( self , args ) raise MyExcept( "hello" ) raise MyExcept( "hello" , "another arg" ) # You can even type this without any error (that is, other than the one # you are explicitly creating ;-)) raise Exception( "first arg" , "second arg" , "etc" ) And you will see the arguments printed. The *args argument is a tuple, so when the exception is printed, you will have the arguments wrapped in ()'s. Check the documentation on exceptions, there is probably (at least I hope so) an function you can define that will handle custom printing of custom Exceptions. HTH, -D From Dan.Rolander at marriott.com Thu Jan 18 13:44:29 2001 From: Dan.Rolander at marriott.com (Rolander, Dan) Date: Thu, 18 Jan 2001 13:44:29 -0500 Subject: How to run script from interpreter? Message-ID: <6176E3D8E36FD111B58900805FA7E0F80CCF62D5@mcnc-mdm1-ex01> What is the best way to run a python script from within the interpreter? What command should I use? Thanks, Dan From db3l at fitlinxx.com Fri Jan 26 20:58:19 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Jan 2001 20:58:19 -0500 Subject: Use of os.popen3() under WinNT4 References: <3a71e809$0$7160$272ea4a1@news.execpc.com> Message-ID: David Niergarth writes: > >>> import os > >>> command = 'gswin32c -help' > >>> child_stdout, child_stdin, child_stderr = os.popen3(command, mode='b') > > child_stdout ends up as a file descriptor opened in write mode, while > child_stdin is a file descriptor opened in read mode; in and out seems > backwards here. In the above command, Ghostscript prints a help message and > quits. To get at the help message, you need to read from stdin. The os.popen# interface result tuple is not in the same order as that for the popen2 module. I forget the exact reason (popen2 was first I think, but importing the win32all pipe module into the Python core for Windows was different, and I think considered more regular, and probably some other stuff). I think there was some discussion on the python-dev list about it all. The net of it is that the os.popen# functions result tuple is not the same as the popen2 module functions tuple for stdin/stdout: os.popen# child_stdin, child_stdout, child_stderr popen2.popen# child_stdout, child_stdin, child_stderr You can find comments to this effect (both availability and a warning about the inversion of the result) in the reference in 6.1.2 for the OS module and 6.8 for the popen2 module. Just don't depend on the docstrings for the popen2 module to work for the os module. Things are consistent across platform in each module though. If you use the os.popen# functions, then they use the builtin under Windows, or wrap the popen2 module under Unix, but in the latter case reverse the result. Conversely, if you use the popen2 module functions, then they wrap the builtin os.popen# functions under Windows, but reverse the result. > More importantly, if you run a command that doesn't immediately terminate, > trying to read from child_stdin or child_stderr before doing a > child_stdout.close() causes a hang. (The only way I've found to recover is > to kill the parent Python process.) Is there a way to tell if the process > has terminated before trying a .read() or, better yet, is there a way to > signal or force the process to finish? Deadlock is always a risk when you are in control of both the stdin and stdout handles for the child process, depending on the interaction of how both you and the child process handle I/O. First, let's invert your handles to their reality, so the problem becomes hanging while trying to read from child_stdout or child_stderr before doing a child_stdin.close() - which sounds more sensible, or at least explainable. In such a case, what I expect is happening is you anticipate your read eventually terminating (with an empty result) when the process finishes and exits (closing its stdout). But the process is still waiting for further input on its stdin before it wants to exit, and you're neither providing more input nor have you closed it to signal to the process that you are done. So you both wait for more "input". Deadlock. In this case, since you know that this is how this particular process behaves, the simplest approach may just be designing your application so that you know you're going to close the stdin of the child before you ever expect to see the stdout close. Since presumably you are feeding input to the child, just close its stdin once you are done with your input. A more general mechanism is to handle the stdin/stdout flows in separate threads. That way, even if your thread reading the stdout is blocked, presumably the thread that is supplying stdin to the child will eventually finish and close that file, thus freeing up your reading thread. Note that even in this case there is a risk of deadlock if you design badly so that you end up in a state where you aren't draining the child's stdout, but your thread to drain the stdout is coupled to the feeding of stdin, which may then block because the child isn't reading it until it can get its stdout done. But in a threaded model that's normally not too hard to avoid. -- -- 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 hamish_lawson at yahoo.co.uk Thu Jan 18 12:28:18 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Thu, 18 Jan 2001 17:28:18 GMT Subject: Is it possible to write a python module in Java? References: <3A6713C3.88C2F64F@satis.com> Message-ID: <947935$fhk$1@nnrp1.deja.com> Julien Reynier wrote: > I know it's possible to write a python module in C or C++. But is it > possible to do the same thing with Java? And how ? > > I know JPython, but JPython can't access to system call as os.chdir(), > os.system() etc So I want to use Python. I'm not quite sure what you are after (do you want to write an extension module in Java for use by Python programs, or write a module in Python for use by Java programs), but the Java-Python Extension project may be what you are looking for: http://sourceforge.net/projects/jpe Hamish Lawson Sent via Deja.com http://www.deja.com/ From tim.one at home.com Mon Jan 29 18:35:19 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 29 Jan 2001 18:35:19 -0500 Subject: marshal doesn't work with "file-like" objects In-Reply-To: Message-ID: [Tim] > ... > You could do this instead: > > filelikeobject.write(marshal.dumps(object)) > > Reading a sequence of marshaled values back from a file-like > object is more of a puzzle! [/F, to Chuck] > ... > Note the second part ("more of a puzzle" is a polite way to say > "impossible, if you care about performance"). That wasn't my intent, but I confess I don't have time or interest to flesh it out. Sketch: if Chuck wants a filelike object to marshal in and out of, he can craft a filelike object that also tucks away an index (or length prefixes, a la Rainer's followup), so he can know in advance how much of the stream needs to be read. I've got no interest in seeing such cruft added to the Python core, though. marhsal-works-great-for-what-it-was-designed-for-ly y'rs - tim From joconnor at cybermesa.com Thu Jan 25 16:27:33 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Thu, 25 Jan 2001 21:27:33 GMT Subject: __set_attr__ References: Message-ID: <3a7099e0.64296487@news.cybermesa.com> On Wed, 24 Jan 2001 17:59:19 -0800, "Amritansh Raghav" wrote: >(Newbie alert - its been less than a week) > >Under what circumstances does __set_attr__ get callled? I thought it was >only if the name wasnt found in the dictionary. However I can see my >function being called even when the name is present. (I print out >self.__dict__ and also do a self.__dict__.has_key(name) just to make sure >there isnt a spelling error). >This is happening within my constructor so I wonder if I need to do >something special here >Any help is appreciated >Thanks __setattr__ is called for every variable reference. If you say person.lastName = "O'Connor" it will indeed call __setattr__ __setattr__ is not used for catching erros or misspellings; you simply use it if there is extra stuff you need to do on variable references. Take care, Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor "God himself plays on the bass strings first, when he tunes the soul" From grante at visi.com Fri Jan 5 10:43:09 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 05 Jan 2001 15:43:09 GMT Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <933fa1$j2i$1@newshost.accu.uu.nl> Message-ID: In article , Joel Ricker wrote: >I heard something about curley braces as well. No {} for blocks? Thats >going to take some getting used to :) That's what I thought initially, but it took no time at all. >>I've seen people beinn pleasantly surprised by the quality of >>answers they've received in this newsgroup, so you may like it. > >I know I have been. Nothing like a friendly newsgroup to >convince me to switch -- at least take a break from perl for >awhile to see how the other side lives. This is one of the friendlier groups I've seen in my 15 years of Usenetting. While the "do until" thread got a bit contentious by Python standards (the worst I recall is somebody being called a "cowboy"), it was still pretty pleasant compared to a lot of other groups (even other supposedly technical groups). -- Grant Edwards grante Yow! I'm RELIGIOUS!! I at love a man with a visi.com HAIRPIECE!! Equip me with MISSILES!! From katz at Glue.umd.edu Sat Jan 27 13:18:31 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Sat, 27 Jan 2001 13:18:31 -0500 Subject: . Python 2.1 function attributes In-Reply-To: References: , <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> <14962.62953.304511.523826@anthem.wooz.org> Message-ID: Hello Moshe, thank you for your response. first, to be clear, I mean *no* hostility towards Moshe or anyone else in this response. On Sat, 27 Jan 2001, Moshe Zadka wrote: > I disagree: in most cases, it was "well, there was a very ugly way to > do it, but so-and-so came up with a patch and a convincing argument.". > > Examples: > > Printing: > Standard output is a sinch: > > print foo, bar > > Does lots of things in an intuitive way (prints new lines and spaces, > calls str()). But when you decide to modify it to print to standard > error, or a log file it turns into either > > sys.stderr(str(foo)+' '+str(bar)+'\n') > > Or > > sys.stdout = sys.stderr > try: > print foo, bar > finally: > sys.stdout = sys.__stdout__ > what is wrong with redirection? must we wrap the output in a try: anymore than wrap a standard print in a try:? > Compared to both, > > print >>sys.stderr foo, bar > > Is obvious, simple and easy to understand. Perhaps simple, but to me it looks like it has the potential to be ambiguating. If we have print>>file, why not print>>obj (if not already so); if we already have print>>obj, why not extend it to statement>>obj? Why stop there? if not statement>>obj, why not func>>obj? since obj's can implement __call__(self), why not obj>>obj? All messed up. > List comprehensions: I'm fine with this. I really am. > You may wonder why it all happened all of a sudden? For years, > there was one-and-a-half people working on Python seriously who > could check in directly to the master CVS. Suddenly an explosion > of developers happened and there were many more man hours to invest > in Python. I'm only interested in why it happened at all, and how to prevent it from screwing up our language further :) > > I call for boycotting print>>. I expect one person, maybe less, > > to support me on that. > Sadly, too many people here support you in that. Sadly, because it's > a feature that was added by people who write a *lot* of Python, and > wanted to make Python-writing more fun. Let's see it! petition! vote! who wants and who doesn't? No more of this of this 'Benevolent Dictator' or 'Hey I've got a patch' garbage. *vote* and make Python not the patcher's language, not my language, and not yours, but *our* language. Lechayim, people! Let's add bless(). I want to change the class of an object at runtime. How 'bout it? Add @ to indicate a list! that way, instead of 'stringlist = string.split('\n')' we have '@stringlist = string'. Oooh! another idea! let's add s///. Damnit, I want dollar signs! And so on. all this when real issues like typing and making int's first-class objects falls to the wayside. Na'im lehakir! Roeykaleh. From gerhard.nospam at bigfoot.de Thu Jan 11 23:29:48 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 12 Jan 2001 05:29:48 +0100 Subject: Binaries for mySQL module ? References: <9%t76.1516$B6.336141@news1.rdc1.md.home.com> Message-ID: http://highqualdev.com On Fri, 12 Jan 2001 02:30:29 GMT, Eric Hagemann wrote: >Are there binaries for mySQLmodule for win32 available ? A quick pointer >would be appreciated -- mail: gerhard bigfoot de web: http://highqualdev.com From JoeSmith at BogusAddress.bogusaddress.com Thu Jan 4 02:50:35 2001 From: JoeSmith at BogusAddress.bogusaddress.com (JoeSmith) Date: Thu, 04 Jan 2001 07:50:35 GMT Subject: list operation '+= ' or assignment problem Message-ID: I unexpectedly get l1 modified by doing "l += l2" (see example 1). I take it is because l and l1 point to the same object. If I use the string type instead of the list type, I don't get l2 modified. I guess that list assignment is an assignment of the reference to the object and it does not copy the object. Where as a string object gets copied (see example 2). example 1: >>> l1 = [0, 1] >>> print l1 [0, 1] >>> l2 = [2, 3] >>> l = l1 >>> print l1 [0, 1] >>> print l [0, 1] >>> l += l2 >>> print l1 [0, 1, 2, 3] >>> print l [0, 1, 2, 3] >>> example 2: >>> s1 = "1" >>> s2 = "2" >>> s = s1 >>> s += s2 >>> print s1 1 >>> From tjreedy at udel.edu Sat Jan 27 15:55:42 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 27 Jan 2001 15:55:42 -0500 Subject: undefined variable References: Message-ID: <94vcpk$qbr$1@news.udel.edu> "shaka" wrote in message news:nHsc6.252522$59.63479549 at news3.rdc1.on.home.com... > > hi, I am a beginner learning python, and I have notice that in python > variables are not declared or defined. Python does not have variables in the same sense as other languages (fixed chunks of memory with one name attached to each). It has PyObjects with zero to many names attached as labels and access handles. 'Type' is a property of PyObjects. It is declared, usually implicitly, in the creation process. Names, unlike variables, do not have types; each can be attached to any object of any type. Hence there is no type information to be declared or defined in respect to names. You can use a name as a variable by always rebinding it objects of the same type. This discipline/restriction is, however, a programmer's responsibility. > But does it mean that your cannot use the same variable twice > and all your variable have to be of different name. In each namespace, each name is currently attached to exactly one PyObject. > In java you can have a variable of the same name but of different type and > it makes programming much more flexible. In Python, the same name can be used concurrently in more than one namespace. Terry J. Reedy From lvanderfeltz at knowledgetrax.com Sat Jan 13 21:31:19 2001 From: lvanderfeltz at knowledgetrax.com (Lennard van der Feltz) Date: Sun, 14 Jan 2001 02:31:19 GMT Subject: ZODB and Python 2.0 References: Message-ID: That's great news (to me at least). I based my understanding on the following post (by you, I believe) to the ZEO mailing list: http://lists.zope.org/pipermail/zope-zeo/2000-October/000172.html I know it was a while ago, but I haven't seen any further announcements. Lennard "Neil Schemenauer" wrote in message news:mailman.979423662.10934.python-list at python.org... > On Sat, Jan 13, 2001 at 08:31:31PM +0000, Lennard van der Feltz wrote: > > Isn't the bigger issue that ExtensionClasses are not yet available for > > Python 2.0? > > Huh? It works fine AFAIK. > > Neil > From slhath at flash.net Mon Jan 15 11:18:12 2001 From: slhath at flash.net (scotth) Date: Mon, 15 Jan 2001 16:18:12 GMT Subject: python compiled to native in less than a year? References: Message-ID: <8pF86.6015$J%.595435@news.flash.net> Since Python will be one of the .NET languages, it will get compiled like all the other .NET languages. Whatever the problems, ActiveState/MS have/are going to over come it if my info is correct. Scott "Roy Katz" wrote in message news:Pine.GSO.4.21.0101151106200.7702-100000 at z.glue.umd.edu... > Scott, > > the problem with Python compilation is optimization; you can "freeze" a > python program into an executable even now. I heard it somewhere that > compiled Python would consist of nothing more than calls to Python's C > API. Granted, that shaves off the interpreter layer, but you're still > going through the P-API. I suspect it is the same way in JPython > (given that JPython implements the Python API in Java, am I right? (?)).. > > > > /R > > > > On Mon, 15 Jan 2001, scotth wrote: > > > Hello, > > > > Since the new .NET platform from MS will take all the compatible .NET > > languages and transform them to an IL (intermediate language ???), then take > > the IL to native compiled code, this means that python will be compiled, but > > only for the Windows platform. > > > > Is what I have said correct, or have I missed something? This would give > > python a huge boost! > > > > Scott > > > > > > > From victor at prodigy.net Fri Jan 5 22:19:41 2001 From: victor at prodigy.net (Victor Muslin) Date: Sat, 06 Jan 2001 03:19:41 GMT Subject: Iterating over multiple lists (a newbie question) References: <3a539f3a.445366109@localhost> <3a54d0c5.523585234@localhost> Message-ID: <3a5566c9.135365705@newnews.prodigy.net> Thanks, but I must have not been very clear. The fact that my example was parsing command line arguments is incidental. The point was that it is nice to have a clean iteration over a list as in: for item in list: but this nice paradigm breaks down when you have to move the iterator along the list inside a loop under certain conditions. Then you are into the ugliness of iteration via indexes. If there were another method associated with a list object to move the iterator it would have been very useful. On Fri, 05 Jan 2001 00:50:32 GMT, "Greg Jorgensen" wrote: >Here's a somewhat generalized parser for simple argument/parameter strings >like command lines. You'll probably want to make it into a function or a >class for real-world use. > >-- >Greg Jorgensen >PDXperts >Portland, Oregon, USA >gregj at pobox.com > > > ># command line or other string to parse >commandline = '-log -port 25 -file -debug -bogus dummy' > ># args is keyed by the valid argument names ># args[arg] = 1 if -arg expects a parameter, else args[arg] = 0 >args = { 'debug':0, 'port':1, 'file':1, 'log':0 } > ># argp will contain the parsed argument list ># add any default values to argp here >argp = {'log':0, 'port':20} > >errmsg = '' >paramkey = '' >for a in commandline.split(): > if a[0] == '-': # -argument > a = a[1:].lower() > p = args.get(a, -1) # get parameter flag, default to 0 > paramkey = '' > if p == 1: # next parameter will be associated with >args[a] > paramkey = a > elif p == 0: # no parameter expected > argp[a] = '' > else: > errmsg += 'unexpected argument: -%s\n' % a > else: # parameter found... > if paramkey: # which argument does it belong to? > argp[paramkey] = a > paramkey = '' > else: > errmsg += 'unexpected value: %s\n' % a > ># let's see the result >if errmsg: > print 'errors:\n' + errmsg > >print 'parsed arguments:' >for e in argp.keys(): > if argp[e]: > print '-%s %s' % (e, argp[e]), > else: > print '-%s' % e, > >print '\n' > > From huwdotlynes at ic.ac.uk Wed Jan 24 09:56:21 2001 From: huwdotlynes at ic.ac.uk (Huw Lynes) Date: 24 Jan 2001 14:56:21 GMT Subject: os.system easy question References: Message-ID: Thanks guys, I think I can get what I need done now. Thanks again, Huw From jpet at eskimo.com Sun Jan 28 21:37:42 2001 From: jpet at eskimo.com (Jeff Petkau) Date: Mon, 29 Jan 2001 02:37:42 GMT Subject: . Python 2.1 function attributes References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk><14962.62953.304511.523826@anthem.wooz.org><3A7333F5.DA1E367B@mail.com> Message-ID: Jeff Petkau wrote in message news:FFSc6.2506$iG3.539254 at dfiatx1-snr1.gtei.net... > Barry A. Warsaw wrote in message > news:mailman.980662113.14859.python-list at python.org... > > > > JD> Perhaps if "print >> file, something" were written as "print > > JD> to file, something" there wouldn't be so much controversy over > > JD> it, even though it wouldn't be doing more or less than it does > > JD> today. > > > > We tried it. Using an identifier in that spot caused irreconcilable > > syntactic ambiguities, so we had to pick a non-identifier. After > > extensive market research `>>' was picked because it had the > > The following seems to work fine for 'print to', even if you insist > on naming your variables 'to'. > > In Grammar/Grammar > print_stmt: 'print' test [test] [',' test]+ [','] > > In compile.c: > Sorry, the evil genie of 1:30am postings got hold of my message. That should have been, print_stmt: 'print' [ test [test] [ ( ',' test)* [ ',' ] ] ] --Jeff From gustafl at algonet.se Mon Jan 22 15:15:47 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 22 Jan 2001 20:15:47 GMT Subject: Modifying .htpasswd from Python? References: <90312091gustaflalgonetse@194.213.69.148> <3A6BCCEC.EA8CE857@stroeder.com> <90316137Fgustaflalgonetse@194.213.69.148> Message-ID: <9031D9546gustaflalgonetse@194.213.69.152> sholden at holdenweb.com (Steve Holden) wrote: >Another poster has already told you why you don't find it: it must be >configured in, which doesn't happen by default. What is the reason to leave out some modules? At least you won't save processing time, since modules has to be imported anyway using the import statement. >Note also that you should not expect to find crypt on Windows systems >since it relies on the Unix crypt() library routine. I'll use this in a CGI script in UNIX. The server is on a web hotel, so I guess there is no possibility other than asking the Python administrator to recompile it with this module included, right? Or can I put only crypt in my own directory? Gustaf From gregj at pobox.com Fri Jan 5 14:36:58 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Fri, 05 Jan 2001 19:36:58 GMT Subject: Unexpected result for list operator "+=" References: <3A542778.E1BC06E3@bogusaddress.com> <93435m022if@news2.newsguy.com> Message-ID: This thread really peels the onion, from the simplified explanations down to the underlying principles and implementation. Understanding the subtleties (or at least knowing where they are) will save me from frustration someday. Thanks! -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com From chris.gonnerman at usa.net Fri Jan 26 08:47:00 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Fri, 26 Jan 2001 07:47:00 -0600 Subject: defining class References: Message-ID: <004a01c0879e$79da3520$a100000a@local> ----- Original Message ----- From: "Aleksei Guzev" > I'm sure I don't understand something since I can't find an article > on creating a class object from a C or C++ module. That's because it isn't easy, AFAIK. Check out the Boost Python Library at http://www.boost.org/libs/python/doc/index.html; on the page on writing extensions they say: > Another obstacle that most people run into eventually when extending Python is that there's no > way to make a true Python class in an extension module. Further down you are referred to a page about Python's metaclass feature. There they actually explain how you can do what you want to do. For reference, the URL of that page is: http://www.python.org/doc/essays/metaclasses/ It about burned out my brain though. From Bill.Scherer at VerizonWireless.com Wed Jan 3 09:20:24 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Wed, 03 Jan 2001 09:20:24 -0500 Subject: UML-tool References: <3A5311F8.52984B6E@zeitspringer.de> Message-ID: <3A533528.92CFE30D@VerizonWireless.com> Sven - OD is the only UML tool I know of the explicitly supports Python. You can probably get a third party to write a plugin for Rational Rose to support Python, but that'll cost you plenty. It is possible to get OD to run well, and once you've done that, it's a mostly satisfying experience. Problem is, what you need to run it well may not be immediatly available to you... I get good performance running OD on a quad 400Mhz Xeon box with 1 GB RAM and RedHat 6.1, using IBM's 1.1.8. I haven't tried it yet with their IBM's latest JVM on this box. I did run OD under IBM's current JVM on a 300Mhz box with 96 MB ram, and it was far better than I had seen with other JVM's on the same box (also RH6.1). Alas, it's also fatser on NT, given equivalent hardware. There used to be a problem with OD on NT on a multiprocessor box; I'm not sure whether or not that's been resolved... I've also used Dia for UML diagramming. It offers no language support of any kind, but you can generate most common UML diagrams with it. You can also get funky with it and mix diagram types together... Good luck! Sven Hohage wrote: > > Hello, > I'm asking myself if there are any UML-tools for Python. > I've used ObjectDomain which was very unsatisfying(horrible JAVA). > Are there any other tools?? > Thanks. > > -- > http://www.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From p.g at figu.no Mon Jan 29 05:30:35 2001 From: p.g at figu.no (Per Gummedal) Date: Mon, 29 Jan 2001 11:30:35 +0100 Subject: Python and Industry, IBM I'm afraid In-Reply-To: <3A729E57.6CE19B86@katamail.com> References: <20010111172342.10148.00000934@ng-ca1.aol.com> <3A63D9E8.F9B74ACE@mjs400.co.uk> <3A729E57.6CE19B86@katamail.com> Message-ID: <29869373883.20010129113035@figu.no> 27.01.2001, 11:09, Stefano wrote: >> I'm currently trying to do a port to AS/400. >> I have it up running with a limited set of modules, but it's not >> ready yet. > It's very interesting!! > Version # ? Python 2.0 compiled to V4R3 or higher. > P.S. Are You an IBM's internal? No, I'm an AS/400 consultant. If you would like to test a beta version look at this web page. http://home.no.net/pgummeda Per From sholden at holdenweb.com Wed Jan 10 21:20:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 10 Jan 2001 21:20:20 -0500 Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> <93dde1$8d2$1@animus.fel.iae.nl> <93f3nb023mv@news1.newsguy.com> <90259DC4Arcamesz@127.0.0.1> <93i57b01qms@news2.newsguy.com> Message-ID: <8N876.2727$24.36420@e420r-atl2.usenetserver.com> "Rainer Deyke" wrote in message news:fC576.21284$ge4.9901878 at news2.rdc2.tx.home.com... > "Alex Martelli" wrote in message > news:93i57b01qms at news2.newsguy.com... [ etc ] > > Fine, but can't be "*much* easier" -- it's just one .split away from > > the 'bar=32' proposal to ('bar','32'), after all:-). > > The problem with 'bar=32' is that it cannot be interleaved with unnumbered > args: > > >>> enum('foo', bar=32, 'fee') > SyntaxError: non-keyword arg after keyword arg > > Even if it could, there would be no way to determine the order of the > arguments and therefore no way to find out that 'fee' should have a value of > 33. > This seems a little obtuse. What would be wrong with enum('foo', 'bar=32', 'fee') regards Steve From gregj at pobox.com Sun Jan 21 13:31:33 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Sun, 21 Jan 2001 18:31:33 GMT Subject: How to write to tempfile, remove whitespace, and copy to source ..? References: Message-ID: <94f9u5$r78$1@nnrp1.deja.com> tempfile.TemporaryFile() creates a new temporary file and opens it for you; the value you get back is a file object ready for writing, so you don't need to open it. But since you need the temporary file name so you can rename it, you need to use the mktemp() method instead: ---- import glob, fileinput, os, tempfile, string files = glob.glob(r'e:\text\*.txt') for filename in files: tempname = tempfile.mktemp() temp = open(tempname, 'w') for s in fileinput.input(filename): temp.write(string.strip(string.join(string.split(s)))) temp.close() os.remove(filename) os.rename(tempname, filename) --- I would add exception handling before deploying; there are several places where file operations can fail. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com In article , "Randolph MacKenzie" wrote: > I want a module that will remove the extra whitespace from all text files in > a target directory. I want to use the tempfile command (on a Windoze2000 > box). I guess I'm having trouble opening the tempfile and appending to it... > and then, after processing it, I need to copy (overwrite) it to source file. > > Any suggestions ? > > # X2space.py removes all extra whitespace from textfiles > > target = "E:\\text\\" > import glob, fileinput, os, shutil, string, tempfile > filelist = glob.glob(target+"*.TXT") > > for fl in filelist: > L3 =[]; > tmp = tempfile.TemporaryFile('a') > #tmpfile = open(tmpflname,'a') > for line in fileinput.input(fl): > tmp.write(string.strip(string.join(string.split(line)))) > tmp.close() > shutil.copyfile(tmp,fl) > Sent via Deja.com http://www.deja.com/ From cerutti at together.net Fri Jan 26 16:44:13 2001 From: cerutti at together.net (Neil Cerutti) Date: 26 Jan 2001 21:44:13 GMT Subject: SourceForge problems References: Message-ID: Thomas Wouters posted: >On Fri, Jan 26, 2001 at 08:46:09PM +0000, Grant Edwards wrote: > >> >don't-even-try-discussing-hot-steaming-faggots-ly y'rs - tim > >> You're probably not talking about cigarettes or firewood, so >> I'm guessing it's some sort of sausage. But English food is >> best left undiscussed if not uneaten. ;) > >As opposed to the wonderful american inventions of, uuhmm... the >hotdog ? A hotdog is one thing, but to then put chili on the hotdog... -- Brain Guy -- Neil Cerutti From crutoy at aol.com Wed Jan 10 18:48:30 2001 From: crutoy at aol.com (Crutoy) Date: 10 Jan 2001 23:48:30 GMT Subject: is Python fully object oriented ? Message-ID: <20010110184830.13286.00000826@ng-fg1.aol.com> Hi , i haven't used Python but i do have experience in other languages vb , java , c++ . Is Python a fully object oriented ? Thanks From aleaxit at yahoo.com Mon Jan 29 11:44:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 29 Jan 2001 17:44:16 +0100 Subject: . Python 2.1 function attributes References: <3A7595D9.E9F080CE@bioreason.com> Message-ID: <9546l301a4i@news2.newsguy.com> "Mitch Chapman" wrote in message news:3A7595D9.E9F080CE at bioreason.com... [snip] > > > -- at least once tried writing 'print>file' for the latter purpose > > > > [...]That is, it isn't so clear *where* he got confused. > > It might be clearer if we could assume he's spent time with > (Unix?) command shells. ">" overwrites files, ">>" appends. He used Unix, and later Linux, as a small child -- back then, it was the Martelli Family's OS (I got Interactive's System V implementation as soon as I could afford an 80386 -- before that, Coherent -- and, as soon as it was usable, Linux 0.9?). [He never really liked vi much -- with ups and downs, but he tended to prefer non-modal editors even then; his motivation towards vi was that he saw it as a "Big Man's Editor", since it was what Dad used, while his mother and sister were Pico users -- at times, when he managed to "let his fingers to the thinking", he was a pretty effective vi-er, actually -- but he kept reverting to 'reasoning' about it, and tripping up]. But that was many years ago -- in recent years, both at home and at school, I think he saw nothing but DOS and DOS-alikes. However, those, also, implement >, >>, and < in their command shells. Alex From kuncej at mail.conservation.state.mo.us Wed Jan 17 16:45:00 2001 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Wed, 17 Jan 2001 15:45:00 -0600 Subject: cross platform file lock References: <943qij$had$1@nnrp1.deja.com> Message-ID: > But after browsing Python Library reference, > Python FAQ, and comp.lang.python, I have not been > able to determine if there is a cross platform > file locking mechanism available for Python. I have a module that implements [most of] the posixfile file-locking protocol on NT. This lets you run nearly the same code on unix or NT. See: ntposixfile.py at: http://starship.python.net/crew/jjkunce/ --Jeff From peter at engcorp.com Tue Jan 16 01:27:21 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 16 Jan 2001 01:27:21 -0500 Subject: python -O -u vs. -Ou References: <3A6343FF.174BB2B7@schlund.de> Message-ID: <3A63E9C9.EF238084@engcorp.com> Carsten Gaebler wrote: > > There seems to be a difference between > > #! /usr/bin/python -O -u > > and > > #! /usr/bin/python -Ou > > Can anyone explain this to me? I think "ou" is the British spelling, while "o" is the American form. (Sorry, lousy English language joke. I'm leaving....) (Words like "humor" and "vapor" are spelled "humour" and "vapour" in British and Canadian forms, for anyone not well versed in this particular wart of the English language. Okay, I'm leaving again.) From jcm at bigskytel.com Sat Jan 27 09:33:04 2001 From: jcm at bigskytel.com (David Porter) Date: Sat, 27 Jan 2001 07:33:04 -0700 Subject: Problems with Install In-Reply-To: <5.0.0.25.0.20010127045146.00a42dc0@thewebsons.com>; from zope@thewebsons.com on Sat, Jan 27, 2001 at 05:16:20AM -0800 References: <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net> <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net> <20010126133015.B7309@harmony.cs.rit.edu> <5.0.0.25.0.20010127045146.00a42dc0@thewebsons.com> Message-ID: <20010127073304.A6783@bigskytel.com> * Ben Ocean : [...] > I've run into this error while running *make*. D said it was due to an > error in the myreadline.o So I re-ran make and copied what printed to > screen. The myreadline.o stuff doesn't appear until the last few lines: > > In file included from /usr/include/errno.h:36, > from ../Include/Python.h:59, > from myreadline.c:42: > /usr/include/bits/errno.h:25: linux/errno.h: No such file or directory > make[1]: *** [myreadline.o] Error 1 > make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Parser' > make: *** [Parser] Error 2 I have encountered this type of error (No such file or directory). First check if /usr/include/linux/errno.h exists. If it doesn't, maybe you need to install the Linux kernel headers. Perhaps something like kernel-headers*.rpm? if it *does* exist, you could try editing line 25 /usr/include/bits/errno.h changing it from # include linux/errno.h to # include > Just for fun I tried installing an rpm as you mentioned. The strangest > thing happened. When I got to the actual installation command, the darn > thing just vanished into thin air! running a whereis for python turns up > *nothing*! Oh, geez, what'd I do wrong? Maybe it installed python in a place that is off your path. David -- Import os. Import os Import os Import os! From akuchlin at mems-exchange.org Tue Jan 9 10:53:12 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Tue, 09 Jan 2001 10:53:12 -0500 Subject: Stopping work on PEP 222 Message-ID: The most recent release schedule for Python 2.1 calls for an alpha release on 19 Jan. That's only 10 days away, which isn't much time. Given that there's been so little response to PEP 222, the design specified in the PEP can't be considered complete or a consensus, and it doesn't seem possible to discuss the PEP and implement it in that time frame. Therefore, I'm taking PEP 222 off the table for Python 2.1. It may be revived for Python 2.2, or I may simply implement the design in Quixote and leave it there. --amk From aleaxit at yahoo.com Sat Jan 6 14:20:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 6 Jan 2001 20:20:37 +0100 Subject: Iterating over multiple lists (a newbie question) References: <3a539f3a.445366109@localhost> <3a54d0c5.523585234@localhost> <3a5566c9.135365705@newnews.prodigy.net> Message-ID: <937rgo01rvo@news1.newsguy.com> "Greg Jorgensen" wrote in message news:QkD56.235798$U46.7334091 at news1.sttls1.wa.home.com... [snip] > Someone correct me if I'm wrong, but Python only looks like it has list > iterators. Based on my understanding of the methods supported by sequence > types, the statement > > for item in list: > ... > > is equivalent to > > for i in range(len(list)): > item = list[i] > ... Almost, not quite. It's closer to: i = 0 while 1: try: item = list[i] except IndexError: break i += 1 # the rest goes here I.e., the sequence being iterated upon with for does not have to define a 'length': rather, it lets the iteration know that it's done by raising an IndexError exception. This is somewhat meaningful, in that it lets you implement a sequence 'lazily' pretty easily: you don't have to know in advance how many items you'll have -- just to be able to fetch them in order, 0-th upwards, and know when you have no more to give (then raise IndexError). E.g.: >>> class Numbers: ... def __getitem__(self, i): ... return i ... >>> for x in Numbers(): ... print x, ... if x>10: break ... 0 1 2 3 4 5 6 7 8 9 10 11 >>> A 'for' iterating over an instance of Numbers had better have its own terminating-break, of course -- "for x in Numbers():" works much like a "while 1:" that knows which time around this is. The sequence-iteration protocol is also used by the zip builtin function, which terminates with the _shortest_ sequence it's given: >>> a=zip("ciao",Numbers()) >>> a [('c', 0), ('i', 1), ('a', 2), ('o', 3)] >>> and THIS can be somewhat handy -- e.g., you can do: for index, item in zip(Numbers(), sequence): # whatever rather than: for index, item in zip(range(len(sequence)), sequence): # whatever and the former is a simpler form (though not as bright and beautiful as Tim's proposed "for index indexing item in sequence"!). The map builtin function, OTOH, does need to know the length of each sequence in advance (and the _longest_ one controls, with the others being 'extended' with as many 'None' as needed), so, no such techniques (tricks?-) are available in that case. Alex From yoonseo at my-deja.com Fri Jan 19 15:01:03 2001 From: yoonseo at my-deja.com (yoonseo at my-deja.com) Date: Fri, 19 Jan 2001 20:01:03 GMT Subject: [Q] telnetlib Message-ID: <94a6dp$118$1@nnrp1.deja.com> Hi, I am trying to run commands on a remote computer using Python. I think that using 'telnetlib' is the way to go, but I have trouble. The following is the script that I wrote but it stops before it reaches prompt, that is after 'TERM = (vt100) '. Can somebody tell me what is wrong? Thanks in advance sy -------------------------------------- import telnetlib HOST = 'host_name' user = 'user_name' pwd = 'my_password' tn = telnetlib.Telnet(HOST) print tn.read_until('login: ') tn.write(user+'\n') print tn.read_until('Password:') tn.write(pwd+'\n') print tn.read_until('TERM = (vt100) ') tn.write('\n') print tn.read_until('% ') tn.write('ls\n') print tn.read_until('% ') tn.write('exit\n') print tn.read_all() -------------------------------------- Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Fri Jan 12 03:17:35 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 12 Jan 2001 08:17:35 GMT Subject: new enum idiom References: <938jmh$919$1@animus.fel.iae.nl> <3A58B9C0.9F2A5CC0@collins.rockwell.com> <93an8v02d2n@news1.newsguy.com> <93dde1$8d2$1@animus.fel.iae.nl> <93f3nb023mv@news1.newsguy.com> <90259DC4Arcamesz@127.0.0.1> <93i57b01qms@news2.newsguy.com> <90268BCE3rcamesz@127.0.0.1> <93kb0m0r3s@news1.newsguy.com> <90273B4rcamesz@127.0.0.1> Message-ID: Robert Amesz wrote: > Hmm I see a problem here: doesn't the %-operator take a tuple on the > right hand side, or has that changed in 2.0? no, and no. http://www.python.org/doc/current/lib/typesseq-strings.html "The right argument should be a tuple with one item for each argument required by the format string; if the string requires a single argument, the right argument may also be a single non-tuple object" Cheers /F From aahz at panix.com Wed Jan 24 13:13:22 2001 From: aahz at panix.com (Aahz Maruch) Date: 24 Jan 2001 10:13:22 -0800 Subject: PSU uses emacs? References: <948e4b$hm0$1@nnrp1.deja.com> <3a6eb2fa.2347467@reading.news.pipex.net> <94mtc702d2h@news2.newsguy.com> <3a6f1114.10352226@reading.news.pipex.net> Message-ID: <94n602$iv6$1@panix6.panix.com> In article <3a6f1114.10352226 at reading.news.pipex.net>, Ray Drew wrote: > >Is there a good book on vi? Try my web site. Won't help you much with vim, though. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 'I'm not in the mood to say "yes" today.' --SJM From aleaxit at yahoo.com Thu Jan 4 11:26:09 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 4 Jan 2001 17:26:09 +0100 Subject: Exiting a program from within an object method. References: <9325ne014j@news2.newsguy.com> Message-ID: <93288o04m9@news2.newsguy.com> "Benjamin Scherrey" wrote in message news:9325ne014j at news2.newsguy.com... > I've written a small python program that instantiates an object which > inherits from SocketServer.BaseRequestHandler. The __main__ function starts > this thing up with the serve_forever() method. Inside the handle() method > of my object I check for a command to shutdown and, if received, call > sys.exit(0). All this does is generate a SystemExit exception and does not > terminate my program. Even if I wrap the call to serve_forever() with a > try: except: block, the exception is not caught. I presume because the > object's handle() method is possibly being executed in a child thread and > python must not support cross thread exception handling (I'm not > instantiating any threads explicitly, I'm assuming that the > BaseRequestHandler is doing this internally)? I think it's simpler than that -- your handle method is being called by the TCPServer's process_request method, which, in turn, is in a try/except that catches ALL exceptions: try: self.process_request(request, client_address) except: self.handle_error(request, client_address) and, by default, handle_error prints a traceback but does not terminate. > What's a simple way to have my object exit the application cleanly? I suspect the simplest way is: inherit from TCPServer and override the handle_error method, so that (e.g.) a SystemExit, only, will be re-raised. I am, however, not sure about how this may interact with possible threading, and I DO know a request executed in another process won't be able to communicate this way...! So, IF you're using a Forking or Threading server, you may need to use another 'termination-indicator', which your handle() method can set (e.g., create a file with a distinguished and pre-agreed name!), and you will also override serve_forever to to periodic checks on that termination-indicator. But there's no need for this extra complexity if you're not forking (or, possibly, threading). Alex From lele at seldati.it Mon Jan 8 20:27:41 2001 From: lele at seldati.it (Lele Gaifax) Date: 09 Jan 2001 02:27:41 +0100 Subject: Web devel with python. Whats the best route? In-Reply-To: D-Man's message of "Mon, 8 Jan 2001 14:33:43 -0500" References: <93cqvi0191h@news1.newsguy.com> <93dfft077p@news1.newsguy.com> Message-ID: >>>>> On Mon, 8 Jan 2001 14:33:43 -0500, D-Man said: D> On Mon, Jan 08, 2001 at 11:30:26PM +0100, Alex Martelli wrote: D> | "Lele Gaifax" wrote in message | | > PS: D> Alex, un ciao particolare! Ti ricordi di me? Sublink... :) | | D> E vorrei vedere, che ci si potesse scordare della gloriosa D> sublink.org e | di tutti i suoi protagonisti...!-) Ciao Lele! D> | D> You do realize that it's impolite to "whisper" in public? Now D> I'm curious to know what you are talking about. But maybe it's D> my own fault for being "deaf" . Sorry, my fault: I was only saying "hello" to a good&old friend. I thought it was clear... after all, "ciao" *is* international, isn't it ?-) Roughly: `Hi, do you remember me?' - `Yes, of course'. bye, lele. -- nickname: Lele Gaifax | Quando vivro' di quello che ho pensato ieri real: Emanuele Gaifas | comincero' ad aver paura di chi mi copia. email: lele at seldati.it | -- Fortunato Depero, 1929. From hamish_lawson at yahoo.co.uk Tue Jan 23 08:14:57 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Tue, 23 Jan 2001 13:14:57 GMT Subject: urllib.urlretrieve("http://free.bsdshell.net/") References: Message-ID: <94k04c$mp0$1@nnrp1.deja.com> Oleg Broytmann: > Strange problem with urllib: urlretrieve("http://free.bsdshell.net/") > always reports "Connection refused". Always: I'm afraid I don't have any suggestion why it didn't work for you - unless the web server doesn't like something about your combination of user agent ("Python-urllib/1.13" for me), IP address, etc - but it worked for me using Python 2.0 on Windows. Hamish Lawson Sent via Deja.com http://www.deja.com/ From nielsenjf at my-deja.com Wed Jan 24 08:08:39 2001 From: nielsenjf at my-deja.com (John Nielsen) Date: Wed, 24 Jan 2001 13:08:39 GMT Subject: unpack sequence to tuple? References: <94j6j1$3na$1@nnrp1.deja.com> <94jjtb0108j@news1.newsguy.com> <94kf4n$58u$1@nnrp1.deja.com> <94krq40bh6@news2.newsguy.com> Message-ID: <94mk4k$vhh$1@nnrp1.deja.com> > Clarity, I guess, is in the eye of the beholder; even if I > did decide to split this simple function into three statements, > they'd likely be: > > def padSequence(seq, length): > temp = list(seq) > temp += [None]*length > return temp[:length] > > at least the [None]*length is clearly simply than starting > from the (None,)*length tuple then casting it to a list (not > that you NEED the cast, if .extend is what you want to > use -- .extend can be called with any sequence). In python 2.0 yes, in 1.5.2 no :-( Is there any reason for extend versus +=? It's odd python 2.0 has what seems like really subtle changes at first. But, when you start using those changes, you begin to see how they really help. It's kinda like dictionaries. It's easy to get people to understand what they mean, but they don't see the utility of it until they actually use it. > def padSequence(seq, length): > if len(seq)>=length: return seq[:length] > return list(seq)+[None]*(length-len(seq)) > > This is probably the first thing that will come to mind > to a newbie, after all, and thus might be simplest for > said newbie to understand. As usual, you have great taste. That's even clearer. The first example, though perfectly fine, reminded me of perl. (i.e. I thought hmm if I showed this to one of my colleagues just picking up python, would they be able to make sense of it -- tend to have to think that a lot w/perl). john -- nielsenjf at my-Deja.com Sent via Deja.com http://www.deja.com/ From gregj at pobox.com Thu Jan 25 14:18:46 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 25 Jan 2001 19:18:46 GMT Subject: Count and replacing strings a texfile References: <94i9ft$apq$1@nnrp1.deja.com> <94llph$8dl$1@nnrp1.deja.com> <94mans01r5p@news2.newsguy.com> <94nc43$n0g$1@nnrp1.deja.com> <94p56k022uc@news2.newsguy.com> Message-ID: <94pu6b$use$1@nnrp1.deja.com> In article <94p56k022uc at news2.newsguy.com>, "Alex Martelli" wrote: > ... > It's a good maxim, but collecting the pieces in a list > and joining them up at the end is no harder than joining > them up as you go... You are right. Here's my original code with your simple change and a typo corrected: === # read all text from the file f = open(filename, "r") s = f.read() f.close() # split text into a list at every occurence of %id% t = s.split("%id%") n = len(t) # number of list elements r = [t[0]] # start with first element in list # iterate over list, inserting counter between elements for i in range(1,n): r.append(str(i) + t[i]) result = ''.join(r) print "%s occurences replaced" % (n-1) print result === -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From robin at jessikat.fsnet.co.uk Sat Jan 27 11:37:47 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 27 Jan 2001 16:37:47 +0000 Subject: . Python 2.1 function attributes In-Reply-To: <14962.62953.304511.523826@anthem.wooz.org> References: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> <14962.62953.304511.523826@anthem.wooz.org> Message-ID: <3rHctJAblvc6Ewku@jessikat.fsnet.co.uk> In message <14962.62953.304511.523826 at anthem.wooz.org>, Barry A. Warsaw writes .... > >It was a joke. Tim meant to write "def f() << x" because "the >function f `gets' the value of x". The patch also places the return >value as a function attribute so you really write it like this: > >def f() << x: > x = 1 > y = 2 > >print f.x > >That both calls f and returns the x attribute value. Add in >__setattr__ semantics and arguments as list comprehensions, and you >get the power and clarity of: > >>>> def f(x * [x-1 for x > 1]) << x: pass >... >>>> print f.x = 5 >120 > >What could be more natural than that? .... aaarrggghhhh the Inquisition auto da fe with << and >> -- Robin Becker From robin at jessikat.fsnet.co.uk Thu Jan 11 08:35:20 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 11 Jan 2001 13:35:20 +0000 Subject: BUG Python 2.0 FreeBSD compile problem Message-ID: When building Python 2.0 with FreeBSD xxx.com 2.2.7-STABLE FreeBSD 2.2.7-STABLE I get undefined references to _TELL64 at load time unless I change line 61 of Objects/fileobject.c from #elif defined(__NetBSD__) || defined(__OpenBSD__) to #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) -- Robin Becker From db3l at fitlinxx.com Mon Jan 22 16:06:29 2001 From: db3l at fitlinxx.com (David Bolen) Date: 22 Jan 2001 16:06:29 -0500 Subject: [XML-SIG] Re: Using Installer with PyXML References: <02c401c08311$a66e8f00$11260340@yin> <200101202225.f0KMPl200861@mira.informatik.hu-berlin.de> <037201c08338$42ce08a0$11260340@yin> Message-ID: "Martin v. Loewis" writes: > > I tested your suggestion of using "from xml.parsers import expat" > > vs. "import pyexpat" and that works fine, but I'm not sure what the > > benefit of using that form is. > > To get independent from the location of the pyexpat module. If you say > "import pyexpat", and you use PyXML, you still won't get the PyXML > version of that module - this lives in xml.parsers.pyexpat. BTW, this resolves the issue I mentioned in the other thread on this point, since the reference to expat then references pyexpat, which at run time (in the installer output product) will be found in the root of the distribution directory as the pyd. You still get the right variant (PyXML) of the pyd, since the installer will copy the pyd from the xml.parsers directory as it determines what is in use. And no explicit misc= entry for the pyd file should be necessary in the installer configuration file. -- -- 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 moshez at zadka.site.co.il Mon Jan 8 10:00:24 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Mon, 8 Jan 2001 17:00:24 +0200 (IST) Subject: Web devel with python. Whats the best route? In-Reply-To: References: Message-ID: <20010108150024.307F7A828@darjeeling.zadka.site.co.il> On Sun, 7 Jan 2001, Chris Watson wrote: > I'm about to start converting the small fool proof (ha ha) admin > system I have been working from console based to web based. What is the > easiest way to go about integrating python into apache so I can start > web'izing this app? mod_python, mod_snake, PyApache? I'm not giving you any answers, only more questions: Quixote, Zope PSP, WebWare? The only thing I'm pretty certain about is that PyApache has been superseded by mod_apache. Other then that, all have strong points, so you should pick something you like... -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From tam_dominic at my-deja.com Mon Jan 15 02:41:59 2001 From: tam_dominic at my-deja.com (tam_dominic at my-deja.com) Date: Mon, 15 Jan 2001 07:41:59 GMT Subject: pmz variable in html Message-ID: <93u9k7$ris$1@nnrp1.deja.com> Hi, Cannot get the value out from pmz because I'm new to html & python. Could somebody tell me why I cannot get the value in the following : Filename : test.pmz myvar = 'this test sux' print '==> ' + myvar The value of myvar is : myvar After I lunched IE or Netscape, it displayed : ==>this test sux The value of myvar is : Unknown variable myvar ^^^^^ Thank you in advance Dominic Sent via Deja.com http://www.deja.com/ From erno-news at erno.iki.fi Tue Jan 23 06:39:35 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 23 Jan 2001 13:39:35 +0200 Subject: os.system easy question References: Message-ID: In article , huwdotlynes at ic.ac.uk (Huw Lynes) writes: | how to kill the | external program after it has run. Or alternatively how to | run an external program in such a way that the script will | not halt. do something like... import signal, os class BgProc: def __init__(self, cmdline): pid = os.fork() if pid > 0: self.pid = pid else: try: os.execvp('/bin/sh', ['sh', '-c', cmdline]) finally: os._exit(255) def wait(self): return os.waitpid(self.pid, 0) def kill(self, sig = signal.SIGTERM): os.kill(self.pid, sig) return self.wait() -- erno From peter at engcorp.com Sun Jan 7 22:21:26 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 07 Jan 2001 22:21:26 -0500 Subject: Thank you (was Re: Should I learn Python or Java?) References: Message-ID: <3A593236.6331BE0C@engcorp.com> D-Man wrote: > > I am currently employed to do Java development. (I'm a co-op, still > in college so if anyone knows of a company that does python > development, let me know) As someone who hires programmers, including co-ops, I would recommend you be careful focusing on companies who demand experience with specific languages. Although some companies hire people for their language-specific experience, in cases of general-purpose programming this is misguided. (For things like DB work, SQL would of course be one requirement.) My company now does a significant amount of Python development, but I would still not strongly favour a "Python developer" over a developer with a broad background in a variety of languages, at different levels and in different application areas. The only thing 'Python' would do on a resume is slightly increase the time I would spend looking at the candidate (out of several hundred resumes I've seen in the last six months only one included the word Python.) Or perhaps you were just expressing a strong desire to work for a progressive company that recognizes the benefits of Python and provides an opportunity for people to work with it. I'd try the same thing in your shoes. Another thing I'd do, though, would be to learn Python well enough and broadly enough to be able to find novel and useful ways to apply it in _any_ company I worked for. Given how easy it has been to demonstrate the advantages of Python over many alternatives, I would think you could successfully build yourself an opportunity to program in Python in your next company. > static type-checking). Also, Java does some weird things with respect > to objects vs. built-in types and not having generics. One of the > results is that you *can't* put an 'int' in a list/vector/etc. Python is not without weirdities. You can't easily subclass a File 'object', because it's essentially a built-in type. I don't think I know of any language without warts, and I think there's a theory (from Hofstadter? (sp?)) that says you can't have a theory that is both consistent and complete (so maybe you can't have a programming language that is practical but without warts...) > As for portability, Python is much more portable than Java is. It is > also much older (and stabler, and faster, etc) than Java so I don't > think it will displace Java soon (unless someone can convice a big > name company to spend lots of money promoting it ;-)). Although "much older" applies, "much stabler", "much faster", and "much more portable" are, in my opinion and experience, definitely not true. Both Python and Java have very high stability and acceptable performance given today's hardware, and either are so much more portable than many other languages that they are in a class alone (together :). Compared to many languages Java deserves respect. From sholden at holdenweb.com Tue Jan 9 16:20:04 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 9 Jan 2001 16:20:04 -0500 Subject: escape sequences and string comparisons References: <93cboe$ctj$1@nnrp1.deja.com> <93elo7$aoh$1@nnrp1.deja.com> Message-ID: wrote in message news:93elo7$aoh$1 at nnrp1.deja.com... > OK, my question is being purified ;-) into the following: > > [Quotes Python behavior] > > [Quotes K&R C Book] > > [Quotes Harbison and Steele] > > My question - is there a good reason that Python has moved from this > 'traditional' effect, which seems to me to be a useful one, for > instance in the context of my original question? Would this behaviour > have broken something else? Shall I raise a PEP? ;-) > There is indeed, as the fine manual goes on to explain shortly after the section you quote: if you make a mistake in an escape sequence, it's much easier to spot this if the backslash isn't just silently ignored as it will be in ANSI C. There are two accepted ways to put backslashes in your strings. The first is to use the escape sequence "\\" to represente each backslash you want. The second is to use "raw" strings, which are standard strings preceded by an r or R. When Python processes these it passes backslashes through. In this latter case, the character following the backslash is ALWAYS copied literally into the string, which means that even a raw string cannot end in a single backslash (because the single backslash will escape the quote meant to terminate the string. regards Steve From jianchen at my-deja.com Mon Jan 8 22:50:40 2001 From: jianchen at my-deja.com (jianchen at my-deja.com) Date: Tue, 09 Jan 2001 03:50:40 GMT Subject: zombie question References: <93c19g$5k7$1@nnrp1.deja.com> <93ci26$hog$1@nnrp1.deja.com> Message-ID: <93e1qf$sbp$1@nnrp1.deja.com> Thank you, Blair. what is the matter with coon.close()? is there more things should I do in the parent process? As to the question of Os type, how can I decide it? And after that, what actions should be performed? oh, so many questions. :) thanks again! Sent via Deja.com http://www.deja.com/ From zeitlin at seth.lpthe.jussieu.fr Fri Jan 26 14:54:27 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 26 Jan 2001 19:54:27 GMT Subject: Tkinter vs wxPython: your opinions? References: <3A6F899F.E164F628@home.com> Message-ID: On Thu, 25 Jan 2001 21:49:18 GMT, Fredrik Lundh wrote: >Vadim Zeitlin wrote: >> This is very strange. Where is good documentation for >> Tkinter to be found? > >on my newsserver, his post included pointers to John Grayson's >book and the pythonware docs. Ah, thanks. >maybe you flamed away before reading the entire post? Sorry, I didn't mean to flame anybody/thing at all. Of course, I prefer wxPython and try to help people using it and to point to its strong points, however you would notice that I try hard to not comment on TkInter at all (if I ever did, it was always preceded by "IMHO") which only makes sense to my very limited knowledge of it. I'd really hate if people took my posting as any kind of flame, so once again: it was really not meant like one. Regards, VZ -- GCS/GM d? H+ s++:-- p2 au--- a- w+ v C+++ UBLS+++ P- L++ N++ E--- W++++ M? V-- -po+ R++ G`` !tv b+++ D--- e++++ u++ h--- f+ r++ n- y? From delza at antarcti.ca Tue Jan 9 16:57:42 2001 From: delza at antarcti.ca (Dethe Elza) Date: Tue, 09 Jan 2001 21:57:42 GMT Subject: Season's greetings (was Re: Some Python 2.1 ideas) References: <928otj02l39@news1.newsguy.com> <92dar2$juv$1@nnrp1.deja.com> <931bhs$ol7$1@nnrp1.deja.com> Message-ID: Nils wrote: > Please can you help me with the installation of > Vpython. > My operating system is SuSE Linux 7.0. > Which libraries are required ? > Which version of Python is essential ? I'm not sure if VPython has been updated to Python2.0 for linux. You can check out the VPython page at http://virtualphoton.pc.cc.cmu.edu/projects/visual/ Or the mailing list archives: http://www.geocrawler.com/archives/3/3931/2000/ Or the SourceForge site: http://sourceforge.net/projects/visualpython/ I've been using it under windows mainly because configuring linux for OpenGL (not to mention all the extensions, etc.) is painful to me. Because I'm a sucker for punishment, however, I'm going to try to get it working under RedHat on my laptop and if I have any success I'll pass along any insights. --Dethe From mikael at isy.liu.se Mon Jan 29 09:57:54 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 29 Jan 2001 15:57:54 +0100 (MET) Subject: Books In-Reply-To: <3a757ac1$1@netnews.web.de> Message-ID: On 29-Jan-01 Volker Jahns wrote: > Second: I searchin links about PHYTON and fpound not very much. The german > web- > addr is dead and behind the .org have nothing to do (I think) with the > language... Try python instead... www.python.org is very much alive. It is the official home of python. www.phyton.org however, is something completely different... HTH /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 29-Jan-01 Time: 15:54:19 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From fredrik at effbot.org Tue Jan 9 14:45:06 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 09 Jan 2001 19:45:06 GMT Subject: mxTools (was Re: why no "do : until"?) References: <93fobh$rqs$1@nntp6.u.washington.edu> Message-ID: <6TJ66.4634$AH6.762830@newsc.telia.net> Donn Cave wrote: > I have never used mxDateTime, so I have 0 cents on that, but I have > used mxTextTools. I found it to be efficient and powerful, and ought > to be useful in a significant number of applications and modules > that have text to parse -- if it were already available with the > distribution. can anyone summarize what mxTextTools can do that you cannot do with the 're' module? cheers /F From aleaxit at yahoo.com Fri Jan 19 04:51:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 19 Jan 2001 10:51:49 +0100 Subject: who imported me? References: <947jh5$puv$1@nnrp1.deja.com> Message-ID: <9492nu0b1f@news2.newsguy.com> wrote in message news:947jh5$puv$1 at nnrp1.deja.com... > (Hopefully) easy question: I'm writing a module that uses values in > variables from the script that imported it. A very bad practice, like most all practice relying on global variables; it will not 'scale' well and is likey to cause you nothing but trouble. I suggest a redesign and refactoring. > How can I tell which script is importing me? Your module's code is executed the FIRST time some other module imports it, and, also, when the reload built-in function is used. All other imports have no effect on your module, *just* on the namespaces your module is being imported from. If detecting the FIRST import is what you want (and you can handle reloads), then a general approach can be something like: import sys try: raise 'foo' except 'foo': impname = sys.exc_info()[2].tb_frame.f_back.f_globals['__name__'] importing_module = sys.modules[impname] The importing_module variable is now bound to the module object that is importing you (for the first time, or by reload); the name of that module is referred to by variable impname. > Is there some easier way to get the parent module's variable values? A module does not have a 'parent module' in general: there is not even a directed acyclic graph of imports, as cycles are possible (although dependency cycles are never a good idea, of course). Further, when the module is first imported, variable values in the importing modules are often not yet defined; the import statement is generally placed before other variables' definitions. If you want one module to pass variables to another, I suggest you do so explicitly: have the 'child' module define an init function, and the 'parent' module call it with the dictionary of values to be passed. This may just mean placing right after the: import child a line of: child.init(globals()) if you want to pass all of the currently-defined names-values dictionary; but this explicit setup is clearer and more flexible than any obscure metaprogramming/reflection/introspection trick you might be playing, such as the one I exemplify above. If you consider that a module will often be imported by several places, each wanting to pass it ITS own settings, you may also realize that a module is not the ideal way to do this -- it may well be preferable to define a *class* in the module, and use *instances* of that class from the various 'importers'. When you create such an instance, you get to pass whatever you want as the arguments to the constructor (received as arguments to the __init__ method of the class you're "calling" for creation). Alex From fredrik at effbot.org Sat Jan 13 06:48:57 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 13 Jan 2001 11:48:57 GMT Subject: A small suggestion for Python References: <3A5F27F7.30268D9A@erols.com> <93p4oh$919$1@newsreaderg1.core.theplanet.net> Message-ID: from the when-did-you-last-read-the-faq-before-posting department (or maybe the of-course-guido's-already-thought-of-that department): > > I have been programming in Python for several years. I still > > occasionally make mistakes with functions (such as sort) that > > return only "None". I suggest that functions like sort should > > return either "Nothing" or nothing. "Nothing" would be exactly > > like "None" except it can't be assigned. Whether "Nothing" or > > nothing is used, the statement "x= y.sort()" would raise a > > run-time Exception. today, chances are that you get a run-time exception when you try to do something with "x". That's of course the reason sort returns None and not the sorted list (see below). (sure, if you don't do something with x, you won't get an exception -- but in that case, does it really matter?) > Another idea: It could return what we all excpect to be returned: The object > that was sorted! So if a list is sorted, why not return the sorted list? http://www.python.org/doc/FAQ.html#6.20 6.20. Why doesn't list.sort() return the sorted list? "In situations where performance matters, making a copy of the list just to sort it would be wasteful. Therefore, list.sort() sorts the list in place. In order to remind you of that fact, it does not return the sorted list. This way, you won't be fooled into accidentally overwriting a list when you need a sorted copy but also need to keep the unsorted version around." Cheers /F From DSHIN at nc.rr.com Sun Jan 28 16:07:17 2001 From: DSHIN at nc.rr.com (Daehyok Shin) Date: Sun, 28 Jan 2001 21:07:17 GMT Subject: [Q] Python hook for NCAR graphic lib? Message-ID: <9S%c6.63925$YQ.13603018@typhoon.southeast.rr.com> Is there any python program to support NCAR graphic lib? -- Daehyok Shin (Peter) From juergen.erhard at gmx.net Fri Jan 26 16:54:47 2001 From: juergen.erhard at gmx.net (Jürgen A. Erhard) Date: Fri, 26 Jan 2001 22:54:47 +0100 Subject: PSU uses emacs? In-Reply-To: <%KYa6.1423$eI2.487638@ruti.visi.com> (grante@visi.com) References: <94cktu$d9c$1@news.wrc.xerox.com> <%KYa6.1423$eI2.487638@ruti.visi.com> Message-ID: <26012001.2@wanderer.local.jae.ddns.org> >>>>> "Grant" == Grant Edwards writes: Grant> In article <94cktu$d9c$1 at news.wrc.xerox.com>, Mark Jackson wrote: >>> [...] Who designed DOS anyway, Gary Kildall wasn't it? >> That was CP/M, the 16-bit version of which was considered by >> IBM for their PC but not chosen. MS-DOS was first licensed and >> then purchased by Microsoft from Seattle Computer Products. It >> was written by Tim Paterson; heavy CP/M influence is evident, >> but it was far from a clone. See Paul Ceruzzi, /A History of >> Modern Computing/. Grant> Looked like a clone to me. Virtually identical FCB Grant> structure, BIOS entry point at 0x0005, same executable Grant> layout, etc. etc. What I recall from the time is that (I heard then) there was a tool (from Intel?) that could convert 8080 assembly code to 8086/88 assembly code. So with a virtually identical OS (in the important things as you, Grant, mentioned), application vendors could *very* easily port their CP/M software to QDOS (recall that *then*, and especially on CP/M, virtually all software was still being written in assembly). Big win for all involved (except for the slow, "bloated" apps because they were not adapted to the 8086 arch). At least, that's my recollection... Bye, J PS: Does this all mean that I'm *OLD*? ;-) -- J?rgen A. Erhard juergen.erhard at gmx.net phone: (GERMANY) 0721 27326 MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html The 80-20 rule for an NT project: 20% time for real coding -- 80% time for working around NT bugs From rayed at mail.com Fri Jan 26 01:26:39 2001 From: rayed at mail.com (Rayed Al-Rashed) Date: Fri, 26 Jan 2001 06:26:39 GMT Subject: Simple HTML template modules? Message-ID: <3A711877.4C5B51AF@mail.com> Hi, I am trying to build CGI programs using Python, and I searched for simple HTML templates modules but couldn't find any ... any ideas where I can find such module. Thanks, Rayed From michael at stroeder.com Tue Jan 2 01:51:16 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 02 Jan 2001 07:51:16 +0100 Subject: Simulating WWW button press References: Message-ID: <3A517A64.9FD43B5F@stroeder.com> Jan Dries wrote: > > >
> METHOD=POST> > > Oops, a zip-file. That's not making things easier. It does not necessarily have to be a ZIP file. Maybe the CGI-BIN is just named that way to make it more convenient to choose an appropriate file name when saving it. Ciao, Michael. From phil at geog.ubc.ca Sat Jan 6 14:20:17 2001 From: phil at geog.ubc.ca (Phil Austin) Date: 06 Jan 2001 11:20:17 -0800 Subject: How To Think Like A Computer Scientist References: Message-ID: Nirina Raseliarison writes: > Hi All, > > Can you point to me another URL for the Python version? > This one, I found in the archive: > http://www.elkner.net/obp/thinkCS/thinkCSpy/index.htm > seems to be broken now. > Thanks in advance for your help > Nirina > I've converted the web pages to pdf format at: http://www.geog.ubc.ca/~phil/courses/think.html Regards, Phil From jerry_spicklemire at my-deja.com Tue Jan 2 14:29:16 2001 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Tue, 02 Jan 2001 19:29:16 GMT Subject: book recommendation? References: <92t6e7$9jn$1@nnrp1.deja.com> Message-ID: <92ta60$d6l$1@nnrp1.deja.com> > I'm new to Python and I would appreciate suggestions > for what would be a good reference book to buy? > I'm an old hand in general. I know C and Perl very > well and Java a little. I've been a programmer and > sysadmin for eight years. I'm looking for a book > that would be a good language reference, but also > has introductions to Python's special features without > being too "slow". Since being published last year, David Beazley's 'Python Essential Refernce' (ISBN 0735709017) has rapidly gained a reputation for living up to its name. The first hundred pages are a compact introduction to language features and usage, with the bulk being a well indexed reference. If you haven't seen the online materials, check out: http://www.python.org/doc/ and assorted links from there. Also see : http://x57.deja.com/=dnc/threadmsg_ct.xp? thitnum=97&AN=709570769.1&mhitnum=0&CONTEXT=978462644.1602355257 (you'll have to re-assemble the URL) for an enthusiastic review of a very recent publication, and a long thread on that and related topics. Have fun! Jerry S. Sent via Deja.com http://www.deja.com/ From sdm7g at virginia.edu Thu Jan 25 12:51:20 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 25 Jan 2001 12:51:20 -0500 (EST) Subject: I mean *setup.py* ! ... (more questions)[Re: libraries=['m'] inconfig.py [Re: Python 2.1 alpha 1 released!]] In-Reply-To: <94p66v$e55qc$1@ID-59885.news.dfncis.de> Message-ID: On Thu, 25 Jan 2001, Thomas Heller wrote: > > "M.-A. Lemburg" wrote in message news:mailman.980419470.4109.python-list at python.org... > > > > Please post these suggestions on the Python bugs listm, Python-Dev > > or Andrew Kuchling who wrote the setup.py script -- the > > distutils approach to auto-configuring Python's builtin modules > > is very new and still needs some refinements. > > > Andrew and Guido seem to have zero interest in supporting > platforms other than linux/unix. > > Thomas > I've gotten some quick responses from Andrew on this and other OSX specific bugs I've posted at SourceForge. I think they have the interest in having Python supported on those platforms, but they can't do the testing on all those platforms and have to rely on other folks submitting bugs and patches. They seem to have fixed most of the Mac OSX problems that were in the 2.0 release. The problem is that the new setup and configure method fixed a few and broke a few more things. The only things they haven't really fixed are the things for which we (Mac OSX Python users) haven't given them a consensus on how it ought to be fixed or handled. ( Or things like the case insensitivity problems which can't be fixed in the obvious simple way ( changing the names of modules so there can't be any confusion ) without some backwards compatibility problems. ) Also: Mac and Windows require so many additional modules that they really need a separate distribution to manage them. The trick is to keep it simple to be able to merge the platform specific stuff into a new standard distribution. I think that's part of the goal of the new setup and using disutils. I *hope* it's like the highway construction signs: "Temporary Inconvenience, Permanent Improvement!" -- Steve Majewski From fredrik at effbot.org Fri Jan 5 03:14:15 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 05 Jan 2001 08:14:15 GMT Subject: Unexpected result for list operator "+=" References: <3A542778.E1BC06E3@bogusaddress.com> Message-ID: Greg Jorgensen wrote: > The real distinction--that assignment operations on immutable objects > create new objects (or bind a reference to a different existing object) Careful. Ordinary assignment operations (a = b) bind names in a name- space, they never create new objects. Things that may look as assignment operations, but are really syntactic sugar for method calls, may do whatever they want: a[x] = b # short for __setitem__ a.x = b # short for __setattr__ a += b # short for __iadd__ a.append(b) There's no distinction between mutable and immutable objects in Python itself. An object is immutable only if it doesn't have any methods that allow you to change its content. Neither you nor Python can do an "ismutable(x)" test. Cheers /F From prestonlanders at my-deja.com Wed Jan 10 11:43:21 2001 From: prestonlanders at my-deja.com (Preston Landers) Date: Wed, 10 Jan 2001 16:43:21 GMT Subject: why is this namespace weirdness happening? Message-ID: <93i3f7$122$1@nnrp1.deja.com> Hi All. I noticed some namespace/import behavior that seems weird to me. It happens in both Python 1.5.2 and 2.0 (though the error message is different.) Sorry if this is a FAQ; maybe someone could briefly explain why this happens. file1.py:--------------------- import file2 def foo(): import file2 # the line below fails if the line above is cmted out # but works fine if present print "file2 bar: ", file2.bar import file2 print "file2 baz: ", file2.baz foo() file2.py:--------------------- bar = 1 baz = 2 ------------------------------ It seems that on the file1 "bar" line, if the 'import file2' above it is commented out, the file2.bar reference will fail (file2 being the unrecognized item.) Despite the 'import file2' at the top of the file. It seems to be due to the 'import file2' following the statement. Python seems to be scanning ahead for imports...? I know that doing an import inside a function is not neccesary if you have imported the module at the top of the file. However, it seems strange that it only fails if there is an odd number of import statements for that module. thanks! Preston pibble at yahoo dot com Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Mon Jan 22 18:14:03 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 22 Jan 2001 23:14:03 GMT Subject: Count and replacing strings a texfile References: <94i9ft$apq$1@nnrp1.deja.com> Message-ID: <%83b6.8735$Qb7.1226624@newsb.telia.net> pucko (?) wrote: > This is a probably basic question. > I have a textfile about 120k large, and there is several strings in it > which I must replace. > The strings are named "%id%" and the number of strings are unknown. > > First, I need to count them all. > Then I must replace every one of them with a incrementing number. > Like the first %id% is replaced with 1, the second with 2 etc. how about: import re class Replacer: pattern = re.compile(r"%id%") def __init__(self): self.counter = 0 def getcounter(self): return self.counter def fixup(self, m): self.counter = self.counter + 1 return str(self.counter) def replace(self, text): return self.pattern.sub(self.fixup, text) x = "%id% spam %id% egg %id%" r = Replacer() print r.replace(x) print r.getcounter() # if you really have to count the %id%s before you replace # them, use len(r.pattern.findall(x))) Hope this helps! Cheers /F From donn at u.washington.edu Wed Jan 10 16:04:32 2001 From: donn at u.washington.edu (Donn Cave) Date: 10 Jan 2001 21:04:32 GMT Subject: How to check on process time? References: <93ie2i$bse$1@nnrp1.deja.com> Message-ID: <93iip0$jhu$1@nntp6.u.washington.edu> Quoth noahspurrier at my-deja.com: | Which Python library do I want to get extensive process information? | I need to look at any process running -- not just the parent, current, | or child processes. As far as I know, that isn't supported on contemporary computer platforms, at least in any meaningfully portable way, and that would be why you don't see anything for it in Python. The "ps" command doesn't use any kind of API, it just reads kernel memory where this stuff is stored. If it doesn't need to be portable, and your present platform supports it, I'd say use the "/proc" filesystem. The following prints accumulated times, on FreeBSD 4.1. Donn Cave, donn at u.washington.edu ---------------------------------------- import errno import posix import string def ps(): proc = posix.listdir('/proc') for pid in proc: try: pidval = string.atoi(pid) except ValueError: # Ignore /proc/curproc etc. continue try: fp = open('/proc/%s/status' % (pid,), 'r') except IOError, val: if val.errno == errno.ENOENT: print pid, '... already gone' continue else: raise ln = fp.readline() fp.close() ln = string.split(ln) cmd = ln[0] uss, usu = map(string.atoi, string.split(ln[8], ',')) sys, syu = map(string.atoi, string.split(ln[9], ',')) print '%5s %-14s%6d.%06d %d.%09d' % (pid, cmd, uss, usu, sys, syu) ps() From Armin_member at newsguy.com Mon Jan 1 05:15:09 2001 From: Armin_member at newsguy.com (Armin Steinhoff) Date: 1 Jan 2001 02:15:09 -0800 Subject: SMB Module References: <92n1lh02evv@drn.newsguy.com> <3A4F6374.1A6C549F@dittmar.net> Message-ID: <92plbd0134j@drn.newsguy.com> In article <3A4F6374.1A6C549F at dittmar.net>, Daniel says... > > >> Makes no sense, because a SMB client mapps normaly a M$ volume to a directory >>tree (UNIX) or a virtual drive (M$) ... I don't see in that case any tasks for >> Python. > >Makes the same sense as ftplib: you want to access files on a host which >exports them in a specific way. Hmm ... when I have mapped a SMB volume to my directory tree at /tmp ... I make just e.g. an f=open('/tmp/workfile', 'w'). I believe that's different to a FTP like file handling ... Armin Happy New Year to ALL From wmiller34 at my-deja.com Wed Jan 3 10:59:08 2001 From: wmiller34 at my-deja.com (wmiller34 at my-deja.com) Date: Wed, 03 Jan 2001 15:59:08 GMT Subject: time.mktime bug in 2.0? Message-ID: <92vi86$7cp$1@nnrp1.deja.com> I'm getting this "TypeError" when I use mktime in 2.0. It works in 1.52. Any ideas? >>> import time >>> t = time.mktime(1999,12,21,0,0,0,0,0,0) Traceback (innermost last): File "", line 1, in ? TypeError: mktime requires exactly 1 argument; 9 given -Walter Sent via Deja.com http://www.deja.com/ From t.harris at robinsons.co.uk Fri Jan 19 04:21:16 2001 From: t.harris at robinsons.co.uk (Toby) Date: Fri, 19 Jan 2001 09:21:16 -0000 Subject: Debugging Message-ID: <979896042.23819.1.nnrp-10.c3ad12d2@news.demon.co.uk> Is it possible to debug an Python 2.0 extension (a DLL) written in MSVC++ 6.0 ? If so how ? I presume I would need a debug version of Python as well... TIA Toby From moshez at zadka.site.co.il Wed Jan 3 09:37:20 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 3 Jan 2001 16:37:20 +0200 (IST) Subject: Recursion In-Reply-To: References: , Message-ID: <20010103143720.B8D5FA84F@darjeeling.zadka.site.co.il> On 3 Jan 2001 00:30:35 GMT, amk at mira.erols.com (A.M. Kuchling) wrote: > Ignore the "#ifdef sparc" branch, and it's quite > simple. rb_gc_stack_start is determined by doing {VALUE start; > rb_gc_stack_start = &start;} during program initialization. I've already hinted at something like this a few months ago, after getting the very same idea from guile. The big problem is that Python is designed to be embedded easily. Don't know about Ruby, but Guile is a pain to embed especially because of this reason. This is the same reason Python (unlike Ruby and Guile) doesn't have "traditional" GC. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From grante at visi.com Mon Jan 22 11:45:55 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 22 Jan 2001 16:45:55 GMT Subject: What does Python do References: <94gmeu$4fc$1@sooner.brightok.net> Message-ID: <7tZa6.1434$eI2.491200@ruti.visi.com> In article <94gmeu$4fc$1 at sooner.brightok.net>, Dead Dan wrote: >What kinds of programs can you make with Python. Does anyone have some >examples. Drawing programs Web browsers System administration utilities Text processing Web servers Games Numerical/scientific calculations Data visualization E-mail clients E-mail servers FTP clients FTP servers [...] almost anything -- Grant Edwards grante Yow! I put aside my at copy of "BOWLING WORLD" visi.com and think about GUN CONTROLlegislation... From erno-news at erno.iki.fi Sun Jan 14 10:59:06 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 14 Jan 2001 17:59:06 +0200 Subject: libpython2.0 as a Linux shared library References: <3A618354.577B192A@mega-nerd.com> Message-ID: In article , Erno Kuusela writes: | /debian/dists/woody/main/source/interpreters/python2-* erm, it's not in woody yet(testing), it's in sid (unstable)... so it's at http://http.us.debian.org/debian/pool/main/p/python2/ -- erno From thomas at cintra.no Wed Jan 10 09:52:29 2001 From: thomas at cintra.no (Thomas Weholt) Date: Wed, 10 Jan 2001 15:52:29 +0100 Subject: Generating a DIFF between two xml-files ?? Message-ID: I need to generate a diff between to xml-files. They're based on the same schema or DTD. The diff-file must be in xml-format too. ( And that's where the problem starts. ) Any clues on how to do this ? Thomas From amk at mira.erols.com Fri Jan 12 22:25:00 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 13 Jan 2001 03:25:00 GMT Subject: ZODB and Python 2.0 References: Message-ID: On Fri, 12 Jan 2001 17:02:36 -0500, Tim Peters wrote: >[Steve Menard] >> ... >> So finally, my question is this : Why isn;t ZODB available as a separate >> package using the distutils? > >http://sourceforge.net/projects/zodb/ That's not really going to help if he's on Windows without a compiler. Someone needs to download the code and run "python setup.py bdist_wininst"; I have no idea if it'll work, but it's worth a try. Paul Prescod also recently reported compiling ZODB for Windows and offered to mmake binaries available. Paul, if you want to provide a pointer to them, I'll add a copy to the SourceForge site. --amk From glenfant at equod.com.nospam Wed Jan 17 12:49:13 2001 From: glenfant at equod.com.nospam (Gilles Lenfant) Date: Wed, 17 Jan 2001 18:49:13 +0100 Subject: urgent help required References: <944ik7$4m4$1@nnrp1.deja.com> Message-ID: <944lko$n0m$1@reader1.imaginet.fr> Remove the trailing "/" from the file name. This should work ! a ?crit dans le message news: 944ik7$4m4$1 at nnrp1.deja.com... > well, when i try to load an image using python| > PIL under zope, i received the following error > mesg: > > Error Type: IOError > Error Value: [Errno 20] Not a > directory: "MyImage.jpg/" > > i know it isn't a directory!!! it s an image!!! > > what's the mess ?????? > does anybody know why?? > plz help...... > > Thanks by advance > > > > Sent via Deja.com > http://www.deja.com/ From dkuhlman at rexx.com Wed Jan 17 17:23:40 2001 From: dkuhlman at rexx.com (Dave Kuhlman) Date: Wed, 17 Jan 2001 22:23:40 -0000 Subject: DCOracle + Python Question References: Message-ID: <979770232.135032@rexx.com> If DCOracle is writing to either stdout or stderr, then look at the description of stdout and stderr in the sys module described at: http://www.python.org/doc/current/lib/module-sys.html in order to learn how to either re-route or throw away that output. Basicaly, you define a class containing a "write" method taking one parameter (the input string). Then, assign an instance of this class to sys.stdout or sys.stderr. An example that hides error messages, then restores them: >>> class MyHandler: ... def write(self, msg): ... pass ... >>> import sys >>> savehandler = sys.stderr >>> sys.stderr = MyHandler() >>> a = x >>> a = y >>> sys.stderr = savehandler >>> a = x Traceback (innermost last): File "", line 1, in ? NameError: x - Dave Jose Martin wrote: > > try: > dbc=DCOracle.Connect(connectstring) > except: pass > > > if an error occurs , i dont want to show the message in the screen. > how can hide the error message. > > > > > > _ _ > @ @ > 'J > ~^ > > -- Dave Kuhlman dkuhlman at rexx.com From claird at starbase.neosoft.com Thu Jan 25 17:44:36 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 25 Jan 2001 16:44:36 -0600 Subject: what GUI, please advise References: <3A6F18F2.536F27FE@crepido.com> Message-ID: In article , D-Man wrote: >On Wed, Jan 24, 2001 at 05:32:30PM -0600, Cameron Laird wrote: >| In article , >| D-Man wrote: >| > >| >(steering the discussion in my direction ...) >| > >| >What is the general feeling of GTK+ vs. wxWindows? >| . >| . >| . >| Does | http://www.sunworld.com/unixinsideronline/swol-12-2000/swol-1218-wxwindows.html >| > >| help? > >Thanks, but I had already read it. It was a good article, but it >didn't talk much about how it compares against GTK+ from a >application design point of view. > >What is your personal opinion Cameron? (You apparently have a rather . . . I usually get uncomfortable when people ask for *that*. OK, for you: GTK+ has never worked out right for me. The people behind it are bright, energetic, and ambiti- ous. They have wonderful plans for the future. I think they might well dominate the GUI toolkit arena some day in the future. Right now, though, wxPython does better for me. It's a more solid binding to a more mature tool- kit. I think any of these toolkits are likely to take you a long way. Many of the differences between them are "subjective" or at least personal, and only to be dis- covered through intimate work with them. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From dan.rolander at marriott.com Sat Jan 13 05:39:18 2001 From: dan.rolander at marriott.com (Dan Rolander) Date: Sat, 13 Jan 2001 05:39:18 -0500 Subject: Installer Problem References: <6176E3D8E36FD111B58900805FA7E0F80CCF62C1@mcnc-mdm1-ex01> Message-ID: <012401c07d4d$1549dd50$11260340@yin> FYI: Gordon helped me. The problem was that I was using an older version of Installer. Check his http://www.macmillan-inc.com for the latest. Dan ----- Original Message ----- From: "Rolander, Dan" To: Sent: Friday, January 12, 2001 10:17 AM Subject: Installer Problem > Can anyone help me understand this traceback I'm getting when trying to > use > Gordon McMillan's Installer? > > C:\Program Files\Installer\projects\actionizer>..\..\standalone.py > action.py > File 'action.cfg' already exists. Overwrite? [yn]y > > "C:\Program Files\Python20\python.exe" C:\PROGRA~1\INSTAL~3\Builder.py > action. > cfg > opts: [] > args: ['action.cfg'] > Initializing > Traceback (most recent call last): > File "C:\PROGRA~1\INSTAL~3\Builder.py", line 502, in ? > main(opts, args) > File "C:\PROGRA~1\INSTAL~3\Builder.py", line 473, in main > target = makeTarget(cfg, section) > File "C:\PROGRA~1\INSTAL~3\Builder.py", line 416, in makeTarget > return dispatch[cfg.get(section, 'type')](cfg, section, optcnvrts) > File "C:\PROGRA~1\INSTAL~3\Builder.py", line 337, in __init__ > FullExeTarget.__init__(self, cfg, sectnm, cnvrts) > File "C:\PROGRA~1\INSTAL~3\Builder.py", line 281, in __init__ > ArchiveTarget.__init__(self, cfg, sectnm, cnvrts) > File "C:\PROGRA~1\INSTAL~3\Builder.py", line 245, in __init__ > CollectTarget.__init__(self, cfg, sectnm, cnvrts) > File "C:\PROGRA~1\INSTAL~3\Builder.py", line 144, in __init__ > Target.__init__(self, cfg, sectnm, cnvrts) > File "C:\PROGRA~1\INSTAL~3\Builder.py", line 34, in __init__ > print "Initializing", self.__name__ > AttributeError: 'ExeTarget' instance has no attribute '__name__' > > C:\Program Files\Installer\projects\actionizer> > > -- > http://www.python.org/mailman/listinfo/python-list > From phd at phd.pp.ru Thu Jan 11 05:04:31 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 11 Jan 2001 13:04:31 +0300 (MSK) Subject: mxTools (was Re: why no "do : until"?) In-Reply-To: <31575A892FF6D1118F5800600846864D5B16CF@intrepid> Message-ID: On Thu, 11 Jan 2001, Simon Brunning wrote: > So, if this were a democracy, which it isn't, I'd vote for mxDateTime to > definitely go in, for someone to think about the additional built-ins, and > for mxODBC to stay separate. > > As it is, though, it's a one-man-one-vote system. Guido is the man, he has > the vote. So we'll just have to wait and see... Though it is not a democracy, you can (a kind of) force a resolution of the question. If the mxDateTime's license permits it, create a patch for Python distribution and upload it to the patch manager. :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleaxit at yahoo.com Sat Jan 6 14:09:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 6 Jan 2001 20:09:00 +0100 Subject: Migrating to perl? References: <3Fa56.4580$of7.216286@news1.atl> <3A571A63.7B2022AF@python.net> Message-ID: <937qt301r4t@news1.newsguy.com> "Thomas A. Bryan" wrote in message news:3A571A63.7B2022AF at python.net... [snip] > > And lastly, what about the Python community? > > I've seen people post obvious trollbait. Instead of starting a flamefest, > instead of being ignored, a meaningful discussion resulted. > > Even when Tim Peters tells you that you don't know what you're talking > about, he does it with a wink and a thorough explanation. > > couln't-be-happier-ly yours The 's and the -ly's, of course, are the price one has to pay; but the thorough explanations are part of the payback, and it seems to me that one gets good value overall. Alex From aleaxit at yahoo.com Mon Jan 22 15:20:47 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 22 Jan 2001 21:20:47 +0100 Subject: how to test for nesting inlist References: <94bhte$4iv$1@nnrp1.deja.com> <94bvgu0kt4@news2.newsguy.com> <94ea6k$4uc$1@nnrp1.deja.com> <94h7pi$b86$1@nnrp1.deja.com> <94hau902rvd@news1.newsguy.com> Message-ID: <94i4nt01ru1@news2.newsguy.com> "Patricia Hawkins" wrote in message news:wkn1cjjrb5.fsf at mail.connact.com... > >>>>> "AM" == Alex Martelli writes: > > AM> wrote in message news:94h7pi$b86$1 at nnrp1.deja.com... > >> What are list comprehensions? I have looked and looked and looked in > >> books and on www.python.org and i see no mention of these. Is this > > AM> A list comprehension is a syntax form such as: > > AM> [ for in ] > > Like this: > > def howDeep2(x): > if type(x) != type([]): > return 0 > return 1 + reduce(max, [howDeep(y) for y in x]) Yes, that's an example I posted recently, but I fear in this context it might perhaps confuse (by adding reduce, a typical 'functional' construct; as well as recursion; plus a little mis-spelling as it tries to recursively call 'howDeep' but calls itself 'howDeep2'... the latter, my fault!-). There are many simpler examples, e.g, "return a list of N random numbers": def randomN(N): return [random.random() for i in range(N)] or "return the squares of the integers from A to B included": def squares(A,B): return [x*x for x in range(A,B+1)] etc, etc. Alex From donn at u.washington.edu Fri Jan 5 12:54:16 2001 From: donn at u.washington.edu (Donn Cave) Date: 5 Jan 2001 17:54:16 GMT Subject: Calling an application from inside a python script Take 1 References: Message-ID: <9351o8$8qm$1@nntp6.u.washington.edu> Quoth Chris Watson : (Quoting myself) |> The easiest thing to write is |> |> import os |> ... |> os.system('ssh -l root %s vi /usr/local/etc/apache.conf' % host) |> |> |> It's also about as dangerous as anything you can do in Python. It |> puts you completely at the mercy of whoever typed in that text at |> the "Enter a hostname: " prompt. Intentionally or not, a space |> or a semi-colon etc. could yield very different results than you |> intend. | | Someone else pointed out the exact same way. However they also described | it was bad h0h0 magic to do it that way. So... | |> Luckily, with Python 2.0 we're getting to the point where you can |> do this in a safer way without writing all the fork & exec stuff |> yourself. The function, os.spawnv(), is apparently here for |> compatibility with Windows! but it seems to be what we need; |> you can look at the os module to see how it works if you want. |> |> import os |> os.spawnv(os.P_WAIT, '/usr/local/bin/ssh', ('ssh', '-l', 'root', |> host, 'vi', '/usr/local/etc/apache.conf')) |> |> That last argument is a tuple of the argument list to ssh, starting |> with argv[0]. In the system() function, we would eventually invoke |> the shell to parse the string into these arguments, and that's where |> the unexpected metacharacters wreak their havoc. By passing the |> arguments directly to the ssh process, we avoid that. | | I had thought about this briefly as well. And decided on an earlier | repliers advice it would be wiser to copy the file to the local machine | instead of editing it remotely. | |> Now, for this particular command, ssh, you might as well fold the |> 'vi' and the file together, because ssh is going to do that for |> the remote shell to parse back out. So don't think you can get |> a sanitary calculated argument list through to the remote shell - |> that can't happen. Your example is OK, because the remote command |> is constant. | | Well what I finally came up with, and I am no coder by any means, was the | following: | | #!/usr/local/bin/python | | import os | | host = raw_input("Enter a hostname: "); | | # Copy the file from the remote server to the local machine. | os.system("scp user@%s:/home/user/TESTFILE /tmp/TESTFILE" % host) | | # Edit the local copy. | os.system("vi /tmp/TESTFILE") | | # "Push" the new config file from the local machine to the remote machine | # using a secure ssh transport | os.system("rsync -v -P -p -e ssh /tmp/TESTFILE user@%s:/home/user/TESTFILE" % host) So picture what happens if the input isn't legit. os.system("scp user@%s:/home/user/TESTFILE /tmp/TESTFILE" % "; rm -r /*; ") --> scp user@; rm -r /*; :/home/user/TESTFILE /tmp/TESTFILE Want to try that and see what happens? That's an intentionally hostile input (don't try it, really.) Accidental input errors might be harmless, or might not. I didn't see anything wrong with the ssh in your initial post, the problem was system(). system() + user-supplied input = unpredictable results. Use spawnv(). Donn Cave, donn at u.washington.edu From MarkH at ActiveState.com Thu Jan 11 18:04:04 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 11 Jan 2001 23:04:04 GMT Subject: ANNOUNCE: PyXPCOM - Python bindings for Mozilla XPCOM technology Message-ID: <93le4v$10m$1@nnrp1.deja.com> ActiveState is pleased to announce the first release of the Python bindings for the Mozilla XPCOM (Cross-Platform COM) technology. These bindings provide a Python package that allows a Python programmer to use or implement any IDL specified XPCOM interface. General information on the Mozilla XPCOM technology can be found at http://www.mozilla.org/projects/xpcom/ Although this is the first public release of these extensions, they are being used extensively in the Komodo project, ActiveState's cross- platform, multilanguage IDE based on Mozilla. Thus the functionality and stability of this package is remarkably high for a first release. The current release should build under Windows and most Linux variants. Although a manual build system is currently used, the intention is to integrate the PyXPCOM build process with the Mozilla CVS tree and build process. Thus, in the future we can expect these extensions to work anywhere Mozilla itself does. This package was developed by ActiveState, and is being released under the Mozilla Public Licence (MPL). The source code (in .tar.gz and .zip form) can be downloaded from http://www.ActiveState.com/Products/Komodo/PYXPCOM ActiveState is maintaining a mailing list for the Python XPCOM package. All queries, comments and suggestions should be made via this mailing list rather than in the forums where this announcement has been posted. Information on the mailing list, including subscription options, can be found at http://listserv.ActiveState.com/mailman/listinfo/pyxpcom Sent via Deja.com http://www.deja.com/ From bowman at montana.com Sat Jan 27 10:11:47 2001 From: bowman at montana.com (bowman) Date: Sat, 27 Jan 2001 08:11:47 -0700 Subject: Python exporting Message-ID: Ghana python export earnings plummet due to glut ACCRA (Reuters) - Ghana's earnings from exporting pythons slid more than 40 percent in 2000 as rising exports from neighbouring states flooded the world market, forestry officials said on Wednesday. Around 30,000 pythons, both farmed and caught in the wild, were exported, mainly to the United States and Europe, for a total of $91,000 -- down from over $160,000 taken the previous year from the sale of 33,000 of the reptiles. "Due to exports in larger quantities by Togo and Benin, causing price fluctuation from five to between two and three dollars per python, trading did not favour Ghanaian wildlife exporters," Brian Basuglo, senior wildlife protection officer at Ghana's Forestry Commission, told Reuters. "They are mostly used as pets and in some instances for scientific purposes. However, the larger ones are sometimes used as delicacies in restaurants," Basuglo said. Python skins are also used for highly priced shoes, bags and belts. sorry -- just couldn't resist From tblin at my-deja.com Tue Jan 2 21:31:32 2001 From: tblin at my-deja.com (TB) Date: Wed, 03 Jan 2001 02:31:32 GMT Subject: HELP! win32com, COM, Invoke problem References: <92rv3q$asi$1@nnrp1.deja.com> <3A51EDBF.3000808@ActiveState.com> <92tmjr$oj1$1@nnrp1.deja.com> <3A5274F3.3070001@ActiveState.com> Message-ID: <92u2u4$2vi$1@nnrp1.deja.com> > You may have trouble with an OCX. Python doesn't really support them. > Pythonwin does to some degree - check out pywin\demos\ocx. > Well, it sounds like a naive question but what does it take to have python support OCX? the reason here is that if it doesn't provide a drop-in replace VBScript/JScript, it's hard to have the management's (sorry, you know that) buy-in on using it. Plus, it's nice to have this feature anyway. I tried to read something about COM and etc, but the info I'm getting is just overwhelmingly complex. could you shed some light on how does VB use OCX? and why it's different from other things (that win32com that currently support) ? Any plan to support OCX in win32com in the future? I'd like to help but I guess I have a lot to learn even before I can make sense of what you've done. Any suggest reading to begin with? I'm more of a unix/perl/java guy and do some VB but never went seriously into C++ on Windows. Do you think it makes sense to manually write some wrappers to solve this immediate problem? any idea how to do that (w/o going into C++ and pyd) ? Thanks for your help, really appreciate it. --TB Sent via Deja.com http://www.deja.com/ From aleaxit at yahoo.com Thu Jan 11 04:28:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 11 Jan 2001 10:28:16 +0100 Subject: Web devel with python. Whats the best route? References: <93cqvi0191h@news1.newsguy.com> <93hfp1013sm@news2.newsguy.com> Message-ID: <93juec0fk6@news1.newsguy.com> "Sam Penrose" wrote in message news:spenrose-149DD9.22095710012001 at news.dnai.com... [snip] > > +for i in range(len(results)): > > @i@ @results[i]@ > > - > > > > All the presentation logic goes into the template, all of > > the computation into the Python CGI script, and my little [snip] > 1) There is an irreducible need to either put Python statements into > HTML or HTML tidbits into Python. You've chosen the former; my > preference is for the latter: Or else place both Python and HTML pieces into something 'above' either, yes (it doesn't _have_ to be HTML, of course; any kind of textual 'presentation language' will do just as well). Against the 'something above either' approach (side note)...: Even if the (somewhat richer/more complicated/more flexible and indirect) '3-pronged' approach is used, the presentation language template will still have to be using SOME kinds of markers to signify [a] substitution points for Python-computed values, [b] pieces that need to be repeated and conditions for repetition, [c] conditionally-included pieces (could be framed as a special case of [b] with 0 or 1 'repetitions'). [b] in particular seems to require some sort of minilanguage, and I don't see a need to invent, document, and implement a special-purpose minilanguage for something I can better express directly in Python. So, back to the 2-pronged approaches only...: For me, the deciding issue is separating issues of computation and presentation. With the presentation language (whatever it might be) embedding Python pieces, all of the presentation issues are fully concentrated in the 'template' file; the only level of coupling are the names of the variables being presented (there's nothing that stops a template-author from putting business logic in the Python snippets he or she embeds, but the convention is that this is "just not done" -- no enforcement... highly Pythonesque IMHO:-). There is an underlying asymmetry: I'm quite willing to commit to Python, only, as the language dealing with computation (as far as the interface to presentation is concerned; if any other language is involved with computing the results, Python will be dealing with that, presenting a Python-only view at the interface anyway). On the other hand, I'm *not* willing to commit to HTML, only, as the language dealing with presentation; I want emitting RTF, or Postscript, etc (or even different 'kinds' of HTML -- dialects for different user-agents, 'skins', etc), to be as easy as using a different presentation-language-template file (the broad class of 'textual presentation languages' seems a satisfactory set). [Actually, what I _do_ have that IS important to me in that toy application are different HTML templates for different *human* languages -- just one Python, since the computations are the same, but different templates anyway; maybe supporting multiple human languages is not important to you, but, working in a country whose native language is not English, it looms large]. I'm not sure that it is this asymmetry that makes the direction I've chosen for the embedding so satisfactory to me, but I do suspect it's that. > 2) You appear to use '+' and '@' (and '-'?) as non-Python, non-HTML > markers to indicate the border between the two languages. One of the Right, that's what I was using in this example (the '-' at line start indicates 'de-dent', i.e., block-end; not strictly needed if one trusts whitespace, I guess, but what with whitespace-eating viruses about to be unchained, I played it safe:-). > reasons I don't like systems involving executable language statements > embedded in HTML, such as Zope, is that they all seem to require such > markers. There are two costs associated with this: > i. Yet Another Syntax to learn. Someone who knows Python and HTML > (me, for example) will not know how the syntax works. It looks as though > you are using the '+' (an otherwise valid HTML character) to indicate > the beginning of a Python block and the paired '@' markers for string > substitution--but there might be regular expressions involved. I can't > tell. No, of course you can't tell from an undocumented 3-line example -- sorry, I was not meaning to imply one could! Particularly given that...: There is a class of programmer, to whom I appear to belong, who's past master at delaying key architectural decisions through insertion of possibly-unwarranted generality in "infrastructure" modules. In my case, it comes from a lifetime spent programming (to-me) fascinating software infrastructure and regularly clashing with a slight variant of one of Parkinson's Laws -- and herein lies a tale. The original version of the Law I have in mind: time spent discussing decisions at a board-meeting is inversely proportional to the actual financial impact of each decision. Rationale: a decision swinging huge amounts of money is likely to need lots of research and possibly some specialistic background to even start approaching understanding, and by far most board members won't have the needed background and will not have bothered to do lots of homework in advance anyway. Such decisions often end up rubber-stamped because of that -- the proponent is the only one who really understands the pro's and con's, he or she gives a skewed presentation reflecting a specific viewpoint, the board members are not willing to display too much ignorance (and the fact that they have NOT read through the 400-pages document summarizing the points that was supplied in advance of the meeting:-). OTOH, board-meetings also take lots of trivial decisions, and _those_ often require no special background or preparation -- anybody can argue hotly and longly about whether the 2000 pounds budgeted for repainting the walls of the executives' bathroom is or isn't a reasonable amount, far more than they can understand whether the 2 million pounds budgeted for an overhaul of the firm's information-systems are. Whence, MUCH more heated discussion on the thousands, than on the millions. The programming equivalent is, "syntax sugar". I've made many deep, and sometimes subtly wrong, design decisions over the last 25 years. But when I go present my prototype, and propose turning it into a key production element which will contribute to make or break our software's overall success, hardly ever does anybody perk up and say, "I don't understand why, in the transaction protocol you present on page 84, you specify _synchronous_ handshaking -- what will *that* do to our scalability on multiprocessor systems, haven't you accidentally ended up introducing unwarranted processor-affinity?". Oh no, the debates are invariably about my choice of commas as opposed to semicolons (or vice versa) as item-separators in debug-dumps, or something equally "crucial". THAT is something everybody's sure to have a strong opinion about, even if they think processor affinity is a fancy new ice cream taste. So, over the years, one learns the (not necessarily optimal) habit of leaving such silly surface issues flexible and easily generalized -- perhaps even exposing them as subsystem configuration variables or the like. Saves just too much time in design-review meetings!-( So, in this vein, do you think I *hard-wired* the way embedded Python expressions and statements are specified in the templates?! *Not on your life*! They're *arguments* to the 'expand-this-template' function; *regular expressions*, even, just so as to ensure I can wiggle out of whatever syntax-sugar quibble is thrown across the meeting room. (Yeah, yeah, I know this was a little toy utility for my own use, and NOT bloody likely to ever see the light of a design-review meeting room -- but certain habits are hard to unlearn!-). You can probably read between the lines that I'm not _proud_ of this meta-decision to shirk decision, in the general case. Here, though, it was easy to rationalize, because I did in fact need this generality to enable _whatever_ textual presentation language as the underlying language... I could NOT rely on specific characteristics of HTML. Also, I *was* keen to allow stuff that would survive intact any round-trip through my favourite HTML editors (Arachnophylia & such). > ii. Another layer of magic characters to parse in BOTH HTML and > Python--quick, how do you tell the difference between the '@' marking a > Python variable, the '@' in an email address and the '@' and end user > typed as an abbreviation for 'at' in a data chunk that you are > re-inserting into your template for some reason? I don't get the difference between the 2nd and 3rd cases -- it seems to boil down to 'how do you tell the difference between occurrences of the RE that define an embedded expression, and ones which just happen'. Answer: you pick an RE that doesn't "just happen". The RE I always end up using for embedded Python expressions in HTML is '@([^@]+)@' (the group in it defines what goes back to eval) -- it so happens that one never needs _two_ @-signs _on the same line_ in my HTML usage (if two email addresses are given, they can be given on separate lines since the intervening linebreak is no trouble). If that wasn't the case (e.g. with a different textual presentation language, or a different HTML style using
, etc), you'd just
choose a different RE -- '@@([^@]+)@' or whatever you like best --
see what I mean about wiggling out of syntax-sugar issues?-)

> What about '+' in URLs
> and Python statements? Presumbaly there are rules (Yet Another Syntax),

Embedded Python statements are line-oriented, which is hardly 'another'
syntax given that Python itself is; so, the '+' (or whatever else -- will
you believe, I made *that* into an RE too...!-) only matters if it's the
very first character on the line ('^+(.*)$', if you please... I'm surely
NOT proud of that, but it does give lots of wiggleroom:-).

> conventions (documented or otherwise), workarounds for troublesome
> cases, etc., but you've inherently added a third layer of logic, whose
> interaction with the Python and HTML layers will, in non-trivial
> projects, require non-trivial management.

Sorry, but I have to disagree on the latter point -- this *is* pretty
trivial stuff.  Hardwiring the RE's (which would then not really need
to be REs any more, at least for the statements) would in fact simplify
things (if the presentation-language flexibility could be dropped).


> 3) Those costs seem to have been worth it for you and many others
> (Digital Creations not least). I don't wish to argue with how others get
> their work done if that's what works for them. I do want to note that
> straight Python and HTML work fine for projects involving thousands of
> lines of Python in a couple dozen modules and hundreds of HTML files.

But if, for example, you need to be preparing your output in English,
or Italian, or French, depending on a 'session-state' variable, how
do you handle that without some form or other of template-substitution?

WITH the template thingy, I can just take a reference template (e.g.
the English one) and have it translated by somebody whose main skill
will be natural language translation -- all they have to understand
about Python, HTML, or the RE's in play to merge the two, is "enough
to avoid breaking things"... they just translate the textual parts,
after all -- having done a couple of templates with some supervision,
they've "learned the rules" (the tiny subset thereof they actually
need care about) and can just proceed.

An alternate (but more complex) approach would ensure translators
need only see a "catalog of messages", strictly pieces of natural
language text *with* markers (you really can't do without some kind
of marker-syntax, as word-order can change between languages even
among items that are program-output) -- make the translators' life
slightly simpler at the price of more substantial program logic
(merging the natural-language-message-catalog, the presentation-
language-template, *and* the program results -- be it on the fly,
or, partly beforehand).  In my previous experiences with programs
needing multiple natural languages' output (in somewhat different
settings), I've found this approach somewhat inferior: isolating
the messages reduces amount of context available to translators, and
risks impairing translation-quality; and I believe translators are
generally smart enough people to learn what pieces of the template
they should leave alone, particularly if you give them an easy way
to run output-tests displaying the effects of their work on a given
template-page.


Alex





From matt at virtualspectator.com  Sun Jan 21 17:24:05 2001
From: matt at virtualspectator.com (matt)
Date: Mon, 22 Jan 2001 11:24:05 +1300
Subject: patch for python configure for freeBSD and Zope
Message-ID: <01012211280401.00887@localhost.localdomain>

Hi, I'm using  freeBSD 4.2-RELEASE and just tried to install python-1.5.2 and
Zope.  If you are trying to do the same and tun into the following error when
trying to start zope, then apply this patch to the configure script of python
and rebuild it.

ImportError: ./ExtensionClass.so: Undefined symbol "PyMethod_Type"

have fun
Matt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: configure.diff
URL: 

From wagnernils at hotmail.com  Sat Jan  6 14:54:58 2001
From: wagnernils at hotmail.com (Nils Wagner)
Date: Sat, 06 Jan 2001 19:54:58 -0000
Subject: Fwd: Recompilation of Vpython
Message-ID: 




>From: "Nils Wagner" 
>To: python-help at python.org
>CC: wagnernils at hotmail.com
>Subject: Recompilation of Vpython
>Date: Sat, 06 Jan 2001 19:23:03 -0000
>
>Hi,
>
>I tried to recompile Vpython
>
>http://cil.andrew.cmu.edu/projects/visual/index.html
>
>for Linux (Kernel 2.2.16).
>Python version : Python 2.0 (#1, Oct 16 2000, 18:10:03)
>[GCC 2.95.2 19991024 (release)] on linux2
>
>A make in cvisual/ produces the following messages (Makefile.res).
>
>Who can help me ?
>
>Nils

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makefile.res
Type: application/octet-stream
Size: 3335 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xgl.cpp
Type: application/octet-stream
Size: 5431 bytes
Desc: not available
URL: 

From chris at voodooland.net  Tue Jan 16 19:38:52 2001
From: chris at voodooland.net (Chris Watson)
Date: Tue, 16 Jan 2001 18:38:52 -0600 (CST)
Subject: Relational Databases and Python
In-Reply-To: 
Message-ID: 


> My reading of the PostgreSQL web site leads me to believe you'll be
> "limited" to UNIX platforms, I can't remember far enough back in the thread
> to determine whether this matters or not.

	Limited in platforms? AFAIK Postgresql runs on more unix platforms
than any other DB out there.

--
=============================================================================
-Chris Watson         (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek 
Work:              scanner at jurai.net | Open Systems Inc., Wellington, Kansas
Home:  scanner at deceptively.shady.org | http://open-systems.net
=============================================================================
WINDOWS: "Where do you want to go today?"
LINUX: "Where do you want to go tomorrow?"
BSD: "Are you guys coming or what?"
=============================================================================
GNU = Gnu's Non-portable & Unstable
irc.openprojects.net #FreeBSD -Join the revolution!
ICQ: 20016186




From emile at fenx.com  Wed Jan 17 20:08:52 2001
From: emile at fenx.com (Emile van Sebille)
Date: Wed, 17 Jan 2001 17:08:52 -0800
Subject: Best way to learn Python ?
References:  <3A66211B.F7F4F6BB@bioeng.ucsd.edu>
Message-ID: <945fp1$ch3dc$1@ID-11957.news.dfncis.de>

"Curtis Jensen"  wrote in message
news:3A66211B.F7F4F6BB at bioeng.ucsd.edu...
> J5 wrote:
> >
> > No schools teach it, so what books do you recommend ?
>
> I had a class that used it here at UCSD.  It was a
camparative languages
> class.  The class' focus wasn't Python, but we did discuss
it and had a
> programming assingment in it.
>
> Though, yes, it is not realy taught in schools.  But
neither is Pearl,
> Awk, Shell scripting, ML, Pascal (anymore), etc.

Actually, IIRC, Wes Chun (of Core Python Programming) has
been teaching Python at UCSC in Santa Cruz and Santa Clara
for at least a year.  Maybe more will start. ;-)


--

Emile van Sebille
emile at fenx.com
-------------------







From fakeaddress at nospammail.com  Mon Jan 29 01:02:03 2001
From: fakeaddress at nospammail.com (Ben Catanzariti)
Date: Mon, 29 Jan 2001 17:02:03 +1100
Subject: curly-brace-aphobic?
References: <3A74EBD6.3C87FD15@seebelow.org>
Message-ID: <951359.d5s.ln@mail>

Would this be to visually seperate lists and tuples creating less ambiguity?

"Grant Griffin"  wrote in message
news:3A74EBD6.3C87FD15 at seebelow.org...
> Hi Gang,
>
> I'm sure this has been asked a thousand times, but I haven't seen it
> asked lately (or ever ).
>
> Why does Python use square braces ([]) instead of curly braces ({}) when
> accessing dictionaries?
>
> This strange inconsistency in Python seems strangely inconsistent with
> its otherwise very consistent application of consistency: since we use
> curly braces to _create_ dictionaries, why not use them to _access_
> dictionaries?  (Or better yet, if the underlying design principle is to
> access things using a different syntax than what we used to create them,
> why not use curly braces to access lists?  )
>
> Anyway, although curly braces are perhaps slightly harder to type than
> square braces, this is one example (maybe the only one) where I find
> Perl code more readable: I appreciate the mnemonic effect curly braces
> have in reminding me that the thing being accessed is a dictionary*.
>
> or-is-python-just-"curly-brace-aphobic?-{wink}-ly y'rs,
>
> =g2
> * perl_terminology = { 'dictionary': 'hash' }
>
> -------------
>
> Addendum:  Now that I've written all that, I just had a flash.  Is it so
> that dictionary code can be sortta polymorphic wrt list code?
>
> doesn't-sound-like-a-very-good-reason-to-me...-ly y'rs,
>
> =g3
> --
> _____________________________________________________________________
>
> Grant R. Griffin                                       g2 at dspguru.com
> Publisher of dspGuru                           http://www.dspguru.com
> Iowegian International Corporation            http://www.iowegian.com




From benc at rehame.com  Mon Jan  8 22:52:28 2001
From: benc at rehame.com (Ben Catanzariti)
Date: Tue, 9 Jan 2001 14:52:28 +1100
Subject: API\dll
Message-ID: 

Hi,

This may seem like a simple q for a lot of you?

I have an API with a dll. To call Functions from this dll the examples for
the API are written in C. However I would like to use Python to make the
same function calls. Does the dll have to be written specifically in the
language that is making the call to do this... in this case C? Or can Python
make calls to any dll?

thanks in advance

--
benc at rehame.com




From jasonic at nomadicsltd.com  Tue Jan  2 12:27:17 2001
From: jasonic at nomadicsltd.com (Jason Cunliffe)
Date: Tue, 2 Jan 2001 12:27:17 -0500
Subject: Electronic edition of 'The Standard Python Library'
References:  <4f746.2529$AH6.401534@newsc.telia.net>  <3A517247.1B79FFC2@ieeeSPAMnot.org>
Message-ID: 

I too had had major headaches getting a working copy of 'The Standard
Library' from Fat-Brain. The forst one was corrupt - finally they answered
then forgot to do the followup.After more nagging I succeeded.

Recently I also upgrade laptops = first the search for the oginal install
file and then began the search for the email holdiing the crucial install
key. Eventually found that on a CD bakup I had made. phew! I burned these
onto  asingle CD so at least now I don't have to waste time like that again.

Took the disk around to a local printshop and had them pintout + bind it up
into a comb binder with covers :-).
Now at least it is readable and reliable.

It is a great book, but disabling the 'copy text' feature is !@#$ pain for
bad tpist liek me. On the one hand it encourages me to enter code myself adn
learn by doing. Can't argue with that. But I honestly feel that should be
_my_ choice. Effectively it is only distribution trick - and by the time I
had lost time and paid for even a cheap binding, I was left wondering what
the real advantages were.

I am all in favour of electronic publishing, but throwing away one of the
key features [cut'n'paste] like this seems crazy.
Isn't there a better way to handle this which works for everyone?

- Jason
___________________________________________________________
Jason CUNLIFFE = NOMADICS['Interactive Art and Technology']




From aleaxit at yahoo.com  Tue Jan  2 17:23:23 2001
From: aleaxit at yahoo.com (Alex Martelli)
Date: Tue, 2 Jan 2001 23:23:23 +0100
Subject: Electronic edition of 'The Standard Python Library'
References:  
Message-ID: <92tkm007t8@news1.newsguy.com>

"W.Izatt"  wrote in message
news:ZQf46.83865$df5.2962770 at news1.crdva1.bc.home.com...
> I had a nightmare getting my copy of this book to "work". My office is
> behind a firewall, so of course the registration process would not work.

Same here.

> Repeated calls to Fatbrain (more than 10) did not produce results. Emails
> were replied to by bots.

Identical experience here.

> Don't buy from Fatbrain. I don't know about the others.

I will heartily second this advice -- which *IS* a pity, because 's
book itself is SO darned useful.  But Fatbrain's "support" for the ebooks
they sell appears to be repeatably abysmal.


Alex





From aleaxit at yahoo.com  Tue Jan 16 06:45:04 2001
From: aleaxit at yahoo.com (Alex Martelli)
Date: Tue, 16 Jan 2001 12:45:04 +0100
Subject: Where to find the 'dbi' and 'odbc' modules?
References: 
Message-ID: <941cbh02uo8@news1.newsguy.com>

 wrote in message
news:mailman.979634964.31590.python-list at python.org...
> Hi all,
> I am a python newbie. I recently downloaded Python(2) for WinNT at my
> office and was fiddling with database access. Although the Python
> documentation mentions the dbi and odbc modules, they are not
> available with the Python 2 distribution. Can anyone tell me where
> these are available for download?

Python's "DB API", equivalent to Perl's "DBI", is, just like that
one, a _specification_, not 'a module': it specifies the interface
that must be supplied by any module that does offer access to a DB,
so client-code can be reasonably independent of the specific module
it uses.

mxODBC is a module, that implements ODBC for Python and (more or
less) meets the DB API specs.  www.lemburg.com/python/mxODBC.html.


A side note...

My favourite way of accessing DB's on NT (fastest, convenient) is
via Microsoft's ADO/AODX object model; you can use it (just like you
can use any other COM/Automation object model) via module win32com,
which is a part of 'win32all', the Windows extensions of Python.
(You already have them if you downloaded the ActiveState Python
distribution; if you got the standard Python distribution, you can
download win32all separately from ActiveState and install it -- it's
really, REALLY useful on Windows for all sorts of things).

However, ADO/ADOX don't meet the Python DB API specs (seems MS did
not know about them, can that be?-), so you'd need to wrap them up
in a DB-API compliant wrapper to keep your client-code portable.


Alex





From aleaxit at yahoo.com  Thu Jan  4 07:28:51 2001
From: aleaxit at yahoo.com (Alex Martelli)
Date: Thu, 4 Jan 2001 13:28:51 +0100
Subject: One Python 2.1 idea
References: <92va7o02rpj@news2.newsguy.com>, <018a01c071a5$e52abde0$102b2bc1@cadlab.it>, <92gjnu02q3r@news2.newsguy.com>,  <20001229190243.78478A84F@darjeeling.zadka.site.co.il>  
Message-ID: <931qbt02mss@news2.newsguy.com>

"Moshe Zadka"  wrote in message
news:mailman.978534843.948.python-list at python.org...
> [Moshe asks for problem where changing __class__ would be useful]

Actually, you asked more generally -- for problems in which
*transiently changing the behavior of a few methods of a few
objects* is the application-need.  I think it's meaningful
that you now phrase this as 'changing __class__' -- that's
just one WAY to 'change behavior', yet you think of them as
one and the same thing.  It's thus not surprising that you
conclude:

> I must say that in this case, I'm *sure* I'd fiddle with __class__
> rather then the new module. It's simple more obvious to write:

It's surely more obvious if one equates 'belongs to class X'
with 'has the behavior of class-X instances'... trivially true,
in fact.  But I thought the point of this sub-thread was
separating actual application-needs (transient behavior
changes in selected methods of certain objects: are they
ever really needed?) with ways to meet them (as I said, I
was _not_ using Python in that system, so neither changing
class nor transiently setting bound-methods was an option!-).


> > The simplest way to frame this, is to tell the plug-in authors
> > that they can just substitute their own code for any given
> > subset of methods of any exposed objects they can identify,
> > and 'restore' the original behavior when needed.
> [Ed. -- Other solution is to implement half of common lisp yourself]

It's not really that bad -- in fact, a full-fledged rich event
system is what we've used as the underlying framework for the
current version of our application, and it does work great (by
'rich' event-system, I have in mind one in which 'an event' is
incarnated into an event-object, just like in HMTL's DOM, rather
than being an insubstantial 'message' [function-call, etc], as
in most GUI's event-systems, COM events, etc).  Its generality
does make it somewhat harder to present; it's just easier for the
uninitiated to think of "A calls method B on object C", than of
"A instantiates eventobject E with E.request=B, E.target=C, then
posts E to the event-manager's queue (say, as a blocking-request
with high priority); C is among the listeners waiting for such
events [often, since the event-object has a specific target, the
_only_ listener, so the event-manager can be very speedy in its
delivery] -- when its turn comes to have a go at handling the
event, it runs whatever code is needed, sets E.response in the
appropriate way, and tells to the event-manager 'I've been quite
thorough in handling this event E, I don't think anybody else
needs to have a go at it' -- and the eventmanager finally
unblocks the waiting A, which can extract E.response and use it".

However, such typical use cases can and do get easily cast
into code -- it's just that the 'normal' call, in A's code:
    response = C.B()
becomes, in reality
    response = EventManager.PostMethodEvent(C, B)
where method MethodEvent of the EventManager handles the
above-mentioned semantic complexity (in fact, syntax can
be prettified back to the former case, if all possible
targets inherit from the appropriate mixin class that
knows how to direct stuff to the event-manager).

Similarly, 'hooking' the specific method B of the specific
object C is quite easy here -- C itself never even learns
about some of its methods being 'hooked' -- the 'hooker'
just asks _the event manager_ to install a listener on its
behalf, with priority just higher than C's listener, for
certain event patterns (those with target=C, request=B),
and basically "steals" the messages just before they actually
reach C itself.  Again, of course, this typical use case is
presented to plugin authors in encapsulated form, as easy
to use as 'temporarily changing C's own method B' would be.

Yeah, yeah, I know, nobody believes this can be as speedy
as it turns out to be without loss of generality, but, the
proof of the pudding being in the eating, I can but invite
interested parties to have a look at thinkdesign's new
release 6 (www.think3.com) -- all of the UI (G, speech, &c)
is based on the new 'rich event manager', as is some part of
the internals' object-model exposure.  The simplest caching
techniques in the event-manager turn out to be enough to
practically avoid overhead in the simple (and by far most
frequent) cases.  Who knows, maybe one day I'll be allowed
to opensource it (one of my fondest dreams)...!


Back to the general issues...: the kind of dynamism we're
considering here may not be really warranted in production
applications *unless* one needs a lot of dynamic, flexible
configurability in one's program (including 3rd-party
plug-ins, etc); however, I think that such 'needs' are
becoming more and more common.

The more dynamic things get, the less, I believe, a
purely class-based object model is appropriate -- but
that is a separate issue, related to HOW one meets such
needs, rather than to the facts that the needs emerge.

"Events rule" -- or, at least, that is my current opinion.
It _would_ be great if Python had better support for them,
at least on a par with Tcl's...


Alex





From carlhiga at yahoo.com  Wed Jan 10 17:38:25 2001
From: carlhiga at yahoo.com (carlhiga at yahoo.com)
Date: Wed, 10 Jan 2001 22:38:25 -0000
Subject: compiling .cgi files
In-Reply-To: <3A5CCB5B.547F92FA@bigfoot.de>
Message-ID: <93io91+qmi6@eGroups.com>

Thanks, 

That sounds like the way to go. I'll give it a try. Either that or 
I'll have to negotiate with the hosting ISP to turn on the 'py'/'pyc' 
postfix for cgi's. Not sure if they'll go for that.

--- In python-list at egroups.com, Gerhard H?ring 
 
wrote:
> As a quick hack, you could write a wrapper script like this:
> 
> wrap.cgi:
> #!/bin/sh
> python realscript.pyc
> 
> I can't think of any other way, apart from hacking the Python source
> itself.
> 
> Gerhard




From phd at phd.pp.ru  Wed Jan 31 11:36:08 2001
From: phd at phd.pp.ru (Oleg Broytmann)
Date: Wed, 31 Jan 2001 19:36:08 +0300 (MSK)
Subject: Date-time class
In-Reply-To: <95982i$bta$1@nnrp1.deja.com>
Message-ID: 

On Wed, 31 Jan 2001 psalvan at my-deja.com wrote:
> I need a simple and practical DateTime class....

   Search the Net for the best module in this class called mxDateTime!

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.




From sylvieb at icestormfx.com  Mon Jan 29 10:59:56 2001
From: sylvieb at icestormfx.com (Sylvie Bruneau)
Date: Mon, 29 Jan 2001 10:59:56 -0500
Subject: Python2.0 and Pmw 0.8.4 counter problem
References: <3A71D728.EE4B9F03@icestormfx.com> 
Message-ID: <3A75937B.14C8D022@icestormfx.com>


Thank you !!  Now it works well.  But why the Pmw team doesn't make the
modification in their last version ?  Anyway.  Do you know if there are other
modifications like this one that as to be done to make sure that all the Pmw widgets
works fine ?

Thanks again...



Richard Townsend wrote:

> >     We used Python1.5 with Pmw 0.8.3 to develop an in-house application.
> For some
> > reasons, we changed to Python2.0 and we decided to use the new Pmw version
> (
> > 0.8.4 ).  In our application, we have a Pmw.Counter of integers and it
> doesn't work
> > anymore.  The behaviour is strange :  if we type a new integer in the
> entry field,
> > everything is fine.  But using the arrows ( left or right, up or down )
> just clean
> > the entry field, without updating its content.  I try the demos in the Pmw
> > distributions and they don't work either.  We installed Python1.6 with Pmw
> 0.8.3, and
> > it still doesn't work !!!  I tried all the other types of counters and
> they all work
> > fine, but the integer.
> >
> >     Anybody has a suggestion ?
> >
>
> I posted the same question a few months ago and got the following solution
> from Roberto Amorim
>
> > Hi, to correct it is simple. You'll have to edit PmwCounter.py. Here it
> > is:
> >
> > - Find the function called _changeNumber() (line 273)
> > - On line 279 there's the return statement for this function. Change it
> > to return str(value) (and not return str(value)[:-1])
> >
> > That ocurred because str(long) on Python 2.0 doesn't return a number
> > with L on the end like Python 1.5.2 did.
> >
>
> regards,
> Richard Townsend

--
/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/
Sylvie Bruneau ( sylvieb at icestormfx.com ) Tel: (514) 527-3963
Software Developer, IceStorm Digital.     Fax: (514) 527-5165
2595 Place Chasse, Montreal, Quebec, H1Y 2C3.

Where would you have gone today if Window's hadn't crashed?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From aahz at panix.com  Mon Jan  1 20:34:14 2001
From: aahz at panix.com (Aahz Maruch)
Date: 1 Jan 2001 17:34:14 -0800
Subject: module question
References: <3A5118AB.BDE840D5@uniserve.com>
Message-ID: <92rb6m$92$1@panix2.panix.com>

In article <3A5118AB.BDE840D5 at uniserve.com>,
Bob van der Poel   wrote:
>
>In my main program I start off with a
>
>	from Tkinter import *
>	from edit import Edit
>
>Now, in the main program I call 'Edit', but it fails. Seems that I have
>to insert a 'from Tkinter import *' in 'Edit' as well. So, does this
>mean that each and every module needs to re-import all the 'global-type'
>stuff? I suppose this aids in keeping data private, etc. but must add a
>lot of overhead at the same time. Maybe I should keep my monolithic
>program structure?

If your edit module accesses Tkinter functionality, it does need the
"from Tkinter import *".  However, it does not add much in the way of
overhead to import the same module into multiple user modules.
(Consider how often you have to "import string", for exmaple.)

>Now, to complicate my understanding even more...if I declare a variable
>in the 'main' module or program how do I access it from imported modules?
>For example, I might have something like:
>
>	versionNumber = 1.4
>
>in the mainline. Now, a module (and I guess it might be deeply
>nested), wants to find out what version is running. I just tried a
>few variations of 'global', but nothing seems to work. Passing this
>variable around to everyone who might need it gets real old, real
>fast...so I'm thinking I'm not understanding something!

Ordinarily I'd recommend against this, but this seems like it might be
an appropriate use.  In your edit module, do this:

import __main__
print __main__.versionNumber


OTOH, that's such a horrid kludge that what you *really* should do is
have a config module of some sort where you store the version number and
import *that* into all your modules (including main).
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

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

Tenth Virtual Anniversary: 364 days and counting


From aleaxit at yahoo.com  Thu Jan  4 16:42:04 2001
From: aleaxit at yahoo.com (Alex Martelli)
Date: Thu, 4 Jan 2001 22:42:04 +0100
Subject: why no "do : until"?
References: <92jj3j$ff7$1@nnrp1.deja.com>      <3A4E95FD.D6C737A7@engcorp.com>    <3A52AD6A.62D043A2@engcorp.com> <3A534367.36B1FD18@uswest.net>  <3A53F4B1.6227D241@uswest.net> <931gf302dsi@news2.newsguy.com> <3A54B6BA.F4550C96@uswest.net>
Message-ID: <932r3e010bd@news1.newsguy.com>

Bjorn Pettersen"  wrote in message
news:3A54B6BA.F4550C96 at uswest.net...
    [snip]
> > I *WOULD* mind, *A LOT*, if, rather than regularizing syntax for the
> > general form of loop, Python were to add other special-cases with
> > their own syntax variations.  *SIMPLICITY*!  *ONE* general loop form
>
> I guess this is where our opinions differ. I'm of the school of "make the
> general case easy, but make the common case trivial". This means I'm
strongly
> in favor of adding special cases for often used looping constructs. I'm
_not_

No issue with that -- it's just a matter of defining how 'often' must
'often'
be to warrant complicating the language. "for" is a special case, but as
it's
used for roughly 50% of the loops (depending on style), I'm happy it's
singled out in the language.  THAT is special enough for me:-).

> probably argue for special syntax for the Pythonic "for i in
> range(len(sequence))"... (perhaps "for i in 1..10" or perhaps a special
form of
> list comprehensions "for i in [1..10 by 2]" )

Surely, if a special syntax existed for what's now written as "range(1,10)",
it would be absurd to restrict it to being used in for loops -- why add
rules
(complication) to _diminish_ expressiveness?  I know that a PEP on such
a proposal was reently rejected, but I don't know why.


Alex





From paulp at ActiveState.com  Sat Jan  6 14:43:06 2001
From: paulp at ActiveState.com (Paul Prescod)
Date: Sat, 06 Jan 2001 11:43:06 -0800
Subject: Speed of Python vs. Perl
References: 
Message-ID: <3A57754A.318C1F74@ActiveState.com>

AndroidMonkey wrote:
> 
> In the last Maximum Linux magazine, there was an article about using Perl
> for a car MP3 player.  It got me wondering - What's the speed of Python like
> compared to Perl? I've never used Perl before, so I hope someone could
> answer my question here. Thanks  -vm

What's the relationship between performance and suitability for a car
MP3 player? I'd think even something as slow as JavaScript would be
applicable for that task. There is already a car MP3 player written in
Python! The company that did it was bought by S3.

http://www2.linuxjournal.com/lj-issues/issue63/3420.html

 Paul



From rcstadheim at scarabweb.com  Sat Jan 20 10:14:22 2001
From: rcstadheim at scarabweb.com (RCS)
Date: Sat, 20 Jan 2001 16:14:22 +0100
Subject: SV: wyPython
References: 
Message-ID: 

In my opinion wxPython is the best GUI toolkit for Python today, BUT I'm not
using it.

The reason for this is that I'm consistently (I have tried several of the
latest downloads) getting memory leaks, so that the machines I've tested it
on, crashes due to memory problems.

I must add that I have only used it on Windows 98 machines, and that
apparently this problem does not exists on Windows NT.

I submitted this problem to the developers, but is seems they did not detect
this problem, and no one else have reported this ( on this newsgroup ) , so
I do not really know what it is.........

Other than this, if you do not experience this problem, go for
it....................

Faster than Tcl/Tk,
Better organization of the layout than Tcl/Tk,
etc

RCS

Doug Farrell  skrev i
meldingsnyheter:Mk9a6.3589$3T2.181641 at newsread1.prod.itd.earthlink.net...
> Hi,
>
> I'd like to hear what people think of wyPython and any experience they've
> had with it, in particular as to how it compares to useing other GUI
tookits
> like Tcl/Tk for instance.
>
> Thanks,
> Doug
>
>




From fredrik at effbot.org  Tue Jan 23 02:45:18 2001
From: fredrik at effbot.org (Fredrik Lundh)
Date: Tue, 23 Jan 2001 07:45:18 GMT
Subject: How do I know all thrown exceptions of a function?
References:  <94d93h$55d$1@troll.powertech.no>   <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> <94ipci$afo$1@animus.fel.iae.nl> <3A6CFD8E.BD473DFD@gte.net>
Message-ID: 

Steve Williams wrote
> > you should use
> >
> >      import somelib
>
> Well, yes.  But that brings in all the other cruft in somelib, when we just
> wanted somefunc.

No, it doesn't.  "import" is not the same thing as C's "include"
statement.  The above statement brings in "somelib", and no-
thing else.

I think you need to read up on how imports work, before
proceeding.

Start here:

    http://effbot.org/guides/import-confusion.htm

and then read the relevant portions of the standard docs.

> We could also use
>
>     from somelib import *

As long as we're talking imports, that's about as far from
"import somelib" as anything can get.

> Now we are getting dangerously close to saying something like "don't ever use
>
>     from somelib import somefunc
>
> because we don't know the exceptions or how the exceptions are defined."

No, the rule is "don't ever use from-import if you don't know what
you're doing".

Cheers /F




From loewis at informatik.hu-berlin.de  Sat Jan 20 19:04:11 2001
From: loewis at informatik.hu-berlin.de (Martin von Loewis)
Date: 21 Jan 2001 01:04:11 +0100
Subject: How do I know all thrown exceptions of a function?
References: 
Message-ID: 

gradha at iname.com writes:

> However, how can I know the built-in exceptions a function my throw?

I'd say this is under-documented. If you can contribute documentation
listing exceptions for these functions, that would be much
appreciated (submit patches to sourceforge.net/projects/python).

Normally, it should be clear what exceptions can be thrown by looking
at the parameters and what the function does. It still may throw
non-intuitive exceptions, which is then either a bug or an
undocumented feature :-(

Regards,
Martin





From nas at arctrix.com  Fri Jan 26 07:50:52 2001
From: nas at arctrix.com (Neil Schemenauer)
Date: Fri, 26 Jan 2001 04:50:52 -0800
Subject: Python vs Ruby
In-Reply-To: ; from loewis@informatik.hu-berlin.de on Fri, Jan 26, 2001 at 06:21:32PM +0100
References: <94mdkd$222e$1@news.adamastor.ac.za>  <87puhbndn5.fsf@hoyogw.netlab.co.jp> 
Message-ID: <20010126045052.A4684@glacier.fnational.com>

[Martin von Loewis on the Ruby GC]
> So I shall find some time to study its weaknesses :-)

The Python FAQ has some good information on why Python uses
reference counting.  RC gives good finalization semantics, plays
nicely with other memory managers, and is very portable.

RC also works quite well with data caches and VM managers.  Using
the Boehm-Demers GC with Python and disabling reference counting
slows the interpreter down by a significant amount.

  Neil



From zope at thewebsons.com  Sat Jan 27 10:07:03 2001
From: zope at thewebsons.com (Ben Ocean)
Date: Sat, 27 Jan 2001 07:07:03 -0800
Subject: Problems with Install
In-Reply-To: <20010127073304.A6783@bigskytel.com>
References: <5.0.0.25.0.20010127045146.00a42dc0@thewebsons.com>
 <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net>
 <5.0.0.25.0.20010126083542.009e3290@mail.earthlink.net>
 <20010126133015.B7309@harmony.cs.rit.edu>
 <5.0.0.25.0.20010127045146.00a42dc0@thewebsons.com>
Message-ID: <5.0.0.25.0.20010127070430.00a5a920@thewebsons.com>

At 07:33 AM 1/27/2001 -0700, you wrote:
>* Ben Ocean :
>
>[...]
> > I've run into this error while running *make*. D said it was due to an
> > error in the myreadline.o So I re-ran make and copied what printed to
> > screen. The myreadline.o stuff doesn't appear until the last few lines:
> >
> > In file included from /usr/include/errno.h:36,
> >                   from ../Include/Python.h:59,
> >                   from myreadline.c:42:
> > /usr/include/bits/errno.h:25: linux/errno.h: No such file or directory
> > make[1]: *** [myreadline.o] Error 1
> > make[1]: Leaving directory `/apache/vhosts/Python-1.5.2/Parser'
> > make: *** [Parser] Error 2
>
>I have encountered this type of error (No such file or directory).
>
>First check if /usr/include/linux/errno.h exists. If it doesn't, maybe you
>need to install the Linux kernel headers. Perhaps something like
>kernel-headers*.rpm?

It exists, but not with *linux* in the path


>if it *does* exist, you could try editing line 25 /usr/include/bits/errno.h
>changing it from
>
># include linux/errno.h
>
>to
>
># include 

I couldn't find that statement. What I found was

# include 

which I changed every way I could (with *linux* without brackets, etc.). No 
luck. Same error.


> > Just for fun I tried installing an rpm as you mentioned. The strangest
> > thing happened. When I got to the actual installation command, the darn
> > thing just vanished into thin air! running a whereis for python turns up
> > *nothing*! Oh, geez, what'd I do wrong?
>
>Maybe it installed python in a place that is off your path.

But I ran a *whereis python* and came up empty-handed! I appreciate any 
more help you can give me.
BenO




From kare at speech.kth.se  Fri Jan  5 09:40:46 2001
From: kare at speech.kth.se (Kare Sjolander)
Date: Fri, 05 Jan 2001 15:40:46 +0100
Subject: using snack to eat an mp3 stream
References: <3a555fe8.47773420@news.interchange.ubc.ca>
Message-ID: <3A55DCEE.71733F2E@speech.kth.se>

Unfortunately this is not possible using Snack and Python currently. I'm
working on a more native version of Snack for Python which will make such
functionality possible.

If you can resort to Tcl for this task the following snippet is a
complete audio server.
It even plays multiple simultaneous mp3 streams.

proc Cmd {sock args} {
  set snd [snack::sound -channel $sock]
  $snd play -command "[list close $sock];$snd destroy"
}
socket -server Cmd 23654

Kare


Kris Botha wrote:

> Has anyone ever tried this? I know that snack is able to open files
> from hard-drive or through streams, using the channel parameter in
> snack. Unforunately, I've found no documentation on this sort of thing
> anywhere. I'm trying to play audio files through a tcp/ip connection
> using snack.. Can anyone point me in the right direction?
>
> Thanks,
>
> ~~====----..----====~~
>         Kris Botha



From ehagemann at home.com  Thu Jan  4 20:42:47 2001
From: ehagemann at home.com (Eric Hagemann)
Date: Fri, 05 Jan 2001 01:42:47 GMT
Subject: socket block ????
Message-ID: 

Making use of the socket module, the library manual indicates that the
default behavior of the module is to block on a read or a write.  But when
using socket.recv(buf) some times it returns before reading len(buf) bytes.

I have tried seting the blocking flag explicitly via socket.setblocking()
with the same result

Beazley's book indicates a flag parameter of MSG_WAITALL which will cause
the routine to wait for len(buf) bytes, but that variable is not defined in
the socket module nor on the recv(2) manual page as suggested by the Python
Lib Docs.

Also I do not see any exceptions rased when this behavior occurs


Anybody seen this behavior ?

Cheers
Eric





From bill at libc.org  Fri Jan 26 09:30:37 2001
From: bill at libc.org (Bill Anderson)
Date: Fri, 26 Jan 2001 21:30:37 +0700
Subject: curses, python20/152, RH70/62, postgresql problems
References: <94731d$9j4$1@nnrp1.deja.com>   <3A718036.13B5B3BF@boi.hp.com>
Message-ID: <5asc6.385$l8.53383@news03.micron.net>

In article <3A718036.13B5B3BF at boi.hp.com>, "Bill Anderson"
 wrote:

...

>> Could you provide some more details on the glibc problem?  I used to
>> have RH7 and didn't find anything obviously wrong in the headers, so I
>> assumed it was the compiler that wasn't doing the comparison correctly.
>>  I solved the problem by manually editing the header (
>>  ).  I have since upgraded to Debian, but am still
>> curious.
>> 
>> Basically, for RH7 users : you can't use any rpms that people provide.
> 
> Basically, you are wrong.

Hmm upon reading this when I got home, it sounds a bit unfriendly. Just
thought I'd pop in and mention it wasn't intended in that way. :)


Bill Anderson


From financejobny at yahoo.com  Tue Jan  2 07:49:06 2001
From: financejobny at yahoo.com (Kurt Riedel)
Date: Tue, 2 Jan 2001 04:49:06 -0800 (PST)
Subject: Financial programming position in Manhattan
Message-ID: <20010102124906.1365.qmail@web11408.mail.yahoo.com>

A financial trading firm in midtown Manhattan seeks to
hire a quality systems/applications programmer in
Python and C/C++. The primary job is to develop tools
to run the trading system in real time. The programmer
would have some experience in real time systems, data
acquisition, and simple database and spreadsheet
development.

No financial experience is necessary. Compensation is
competitive and weighted towards a significant  
annual bonus.

Applicants should send an e-mail describing their
programming experience to financejobNY at yahoo.com


__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/



From aahz at panix.com  Mon Jan  8 16:08:34 2001
From: aahz at panix.com (Aahz Maruch)
Date: 8 Jan 2001 13:08:34 -0800
Subject: why no "do : until"?
References: 
Message-ID: <93da8i$1lp$1@panix2.panix.com>

In article ,
Tim Peters  wrote:
>
>A study I did at the time said that about 15% of all "for" loops in Python
>code were of the form
>
>    for i in range(len(a)):
>
>and that's both an obscure and inefficient way to spell the underlying idea.

Huh.  I've always tended to do this instead:

i = 0
for tmp in a:
    ...
    i += 1
-- 
                      --- Aahz (Copyright 2001 by aahz at pobox.com)

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

Sometimes, you're not just out of left field, you're coming in all the
way from outer space.  --Aahz


From dag at orion.no  Mon Jan 22 03:18:33 2001
From: dag at orion.no (Dag Sunde)
Date: Mon, 22 Jan 2001 08:18:33 GMT
Subject: What does Python do
References: <94gmeu$4fc$1@sooner.brightok.net>
Message-ID: 

I almost said everything, but devicedrivers might
be a little hairy for Python... ;-)

Out lates app written in Python was for a stock-exchange.
It connects to a couple of CORBA-servers and extract all
the bids, asks and trades on all products. It then calculates
the official closing-prices for the Exchange, and sends it
out on a live TCP/IP feed when trading ends.

Dag.



"Dead Dan"  wrote in message
news:94gmeu$4fc$1 at sooner.brightok.net...
> What kinds of programs can you make with Python. Does anyone have some
> examples.
>
> Dan
>
>




From gregj at pobox.com  Tue Jan 23 23:30:40 2001
From: gregj at pobox.com (Greg Jorgensen)
Date: Wed, 24 Jan 2001 04:30:40 GMT
Subject: Count and replacing strings a texfile
References: <94i9ft$apq$1@nnrp1.deja.com>
Message-ID: <94llph$8dl$1@nnrp1.deja.com>

Try this:

----
# read all text from the file
f = open(filename, "r")
s = f.read()
f.close()

# split text into a list at every occurence of %id%
t = s.split("%id%")
n = len(t)      # number of list elements
result = s[0]   # start with first element in list
# iterate over list, appending counter and next text chunk
for i in range(1,n):
        result += str(i) + s[i]

print "%s occurences replaced" % (n-1)
print result
----

--
Greg Jorgensen
Portland, Oregon, USA
gregj at pobox.com


In article <94i9ft$apq$1 at nnrp1.deja.com>,
  puckoh at my-deja.com wrote:
> Hello.
>
> This is a probably basic question.
> I have a textfile about 120k large, and there is several strings in it
> which I must replace.
> The strings are named "%id%" and the number of strings are unknown.
>
> First, I need to count them all.
> Then I must replace every one of them with a incrementing number.
> Like the first %id% is replaced with 1, the second with 2 etc.
>
> I've been told that this is a perfect job for Perl, but I don't
> understand Perl.
> I merely understand Python. Well, I think I got the basics anyway. :)
>
> Anyone care to help me out for a minute to suggest what to do?
> Any pointers to examples are alot appreciated.
>
> Thanks.
>
> /Andreas
>
> Sent via Deja.com
> http://www.deja.com/
>


Sent via Deja.com
http://www.deja.com/


From hzhu at users.sourceforge.net  Sun Jan  7 00:01:12 2001
From: hzhu at users.sourceforge.net (Huaiyu Zhu)
Date: Sun, 07 Jan 2001 05:01:12 GMT
Subject: Iterating over multiple lists (a newbie question)
References: <3a539f3a.445366109@localhost> <3a54d0c5.523585234@localhost>
Message-ID: 

On Thu, 04 Jan 2001 19:55:43 GMT, Victor Muslin  wrote:
>Thank you all for the insights. Here is another variation on the them,
>though this involves a single list.
>
>Suppose I want to parse command line arguments (never mind getops,
>since this could be some other situation not involving command line
>arguments). Here is how I could possibly parse command line arguments
>for command: "myprog -port 10 -debug":
>
>	import sys
>	debug = port = 0
>	i = 1                                      # ugly
>	while i < len(sys.argv):
>	    if sys.argv[i] == '-debug':
>	        debug=1
>	    elif sys.argv[i] == '-port':
>	        i = i + 1                          # ugly!
>	        if i < len(sys.argv):           # very ugly!
>	            port = int(sys.argv[i])
>	    i = i + 1                              # quite ugly
>
>Pretty ugly, huh? Is there a more elegant way?

I think you are looking for something like the following hyperthetical code

for x in sys.argv:
    if x == '-debug':
        debug = 1
    elif x == '-port':
        next x         # This does not exist now
        port = int(x)

Can this syntax be added to Python?  My take is that it would be difficult
to design a good syntax, but not difficult to implement. This is because the
"next x" must associate the internal loop counter (which is your i) with the
name x.  But what if there are several for loops?  Limiting this to a single
loop is too restrictive.  Maybe someone can come up with a better syntax.

An alternative approach would be to expose the loop counter and let user do
whatever with the loop counter, but that might be too free.

Huaiyu




From mal at lemburg.com  Mon Jan 29 07:24:15 2001
From: mal at lemburg.com (M.-A. Lemburg)
Date: Mon, 29 Jan 2001 13:24:15 +0100
Subject: [Python-Dev] Re: Python 2.1 slower than 2.0
References:  <200101271858.NAA04898@mira.erols.com>
Message-ID: <3A7560EF.39D6CF@lemburg.com>

Here the results of my micro benckmark pybench 0.7:

PYBENCH 0.7

Benchmark: /home/lemburg/tmp/pybench-2.1a1.pyb (rounds=10, warp=20)

Tests:                              per run    per oper.  diff *
------------------------------------------------------------------------
          BuiltinFunctionCalls:    1102.30 ms    8.65 us   +7.56%
           BuiltinMethodLookup:     966.75 ms    1.84 us   +4.56%
                 ConcatStrings:    1198.55 ms    7.99 us  +11.63%
                 ConcatUnicode:    1835.60 ms   12.24 us  +19.29%
               CreateInstances:    1556.40 ms   37.06 us   +2.49%
       CreateStringsWithConcat:    1396.70 ms    6.98 us   +5.44%
       CreateUnicodeWithConcat:    1895.80 ms    9.48 us  +31.61%
                  DictCreation:    1760.50 ms   11.74 us   +2.43%
                      ForLoops:    1426.90 ms  142.69 us   -7.51%
                    IfThenElse:    1155.25 ms    1.71 us   -6.24%
                   ListSlicing:     555.40 ms  158.69 us   -4.14%
                NestedForLoops:     784.55 ms    2.24 us   -6.33%
          NormalClassAttribute:    1052.80 ms    1.75 us  -10.42%
       NormalInstanceAttribute:    1053.80 ms    1.76 us   +0.89%
           PythonFunctionCalls:    1127.50 ms    6.83 us  +12.56%
             PythonMethodCalls:     909.10 ms   12.12 us   +9.70%
                     Recursion:     942.40 ms   75.39 us  +23.74%
                  SecondImport:     924.20 ms   36.97 us   +3.98%
           SecondPackageImport:     951.10 ms   38.04 us   +6.16%
         SecondSubmoduleImport:    1211.30 ms   48.45 us   +7.69%
       SimpleComplexArithmetic:    1635.30 ms    7.43 us   +5.58%
        SimpleDictManipulation:     963.35 ms    3.21 us   -0.57%
         SimpleFloatArithmetic:     877.00 ms    1.59 us   -2.92%
      SimpleIntFloatArithmetic:     851.10 ms    1.29 us   -5.89%
       SimpleIntegerArithmetic:     850.05 ms    1.29 us   -6.41%
        SimpleListManipulation:    1168.50 ms    4.33 us   +8.14%
          SimpleLongArithmetic:    1231.15 ms    7.46 us   +1.52%
                    SmallLists:    2153.35 ms    8.44 us  +10.77%
                   SmallTuples:    1314.65 ms    5.48 us   +3.80%
         SpecialClassAttribute:    1050.80 ms    1.75 us   +1.48%
      SpecialInstanceAttribute:    1248.75 ms    2.08 us   -2.32%
                StringMappings:    1702.60 ms   13.51 us  +19.69%
              StringPredicates:    1024.25 ms    3.66 us  -25.49%
                 StringSlicing:    1093.35 ms    6.25 us   +4.35%
                     TryExcept:    1584.85 ms    1.06 us  -10.90%
                TryRaiseExcept:    1239.50 ms   82.63 us   +4.64%
                  TupleSlicing:     983.00 ms    9.36 us   +3.36%
               UnicodeMappings:    1631.65 ms   90.65 us  +42.76%
             UnicodePredicates:    1762.10 ms    7.83 us  +15.99%
             UnicodeProperties:    1410.80 ms    7.05 us  +19.57%
                UnicodeSlicing:    1366.20 ms    7.81 us  +19.23%
------------------------------------------------------------------------
            Average round time:   58001.00 ms              +3.30%

*) measured against: /home/lemburg/tmp/pybench-2.0.pyb (rounds=10, warp=20)

The benchmark is available here in case someone wants to verify
the results on different platforms:

	http://www.lemburg.com/python/pybench-0.7.zip

The above tests were done on a Linux 2.2 system, AMD K6 233MHz. 
The figures shown compare CVS Python (2.1a1) against stock
Python 2.0. 

As you can see, Python function calls have suffered
a lot for some reason. Unicode mappings and other Unicode database
related methods show the effect of the compression of the Unicode
database -- a clear space/speed tradeoff. 

I can't really explain why Unicode concatenation has had a 
slowdown -- perhaps the new coercion logic has something to
do with this ?!

On the nice side: attribute lookups are faster; probably due to
the string key optimizations in the dictionary implementation.
Loops and exceptions are also a tad faster.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/



From DavidLNoSpammy at raqia.com  Thu Jan 11 14:14:01 2001
From: DavidLNoSpammy at raqia.com (David Lees)
Date: Thu, 11 Jan 2001 14:14:01 -0500
Subject: Looking for Doug Hellmann - daVinci.py author
Message-ID: <3A5E05F9.253D2E62@raqia.com>

I am trying to locate Doug Hellmann who wrote a Python code for
generating input to the graph display package daVinci.  The e-mail on
his code (from January 1998) is doughellmann at mindspring.com , but it is
now defunct.  If anyone knows him could you pass on my e-mail address
which is:

davidl at raqia.com

Thanks,

David Lees


From fredrik at effbot.org  Fri Jan 19 05:01:28 2001
From: fredrik at effbot.org (Fredrik Lundh)
Date: Fri, 19 Jan 2001 10:01:28 GMT
Subject: Debugging
References: <979896042.23819.1.nnrp-10.c3ad12d2@news.demon.co.uk>
Message-ID: 

"Toby"  wrote:
> Is it possible to debug an Python 2.0 extension (a DLL) written in MSVC++
> 6.0 ? If so how ?

as you would debug any other DLL?  (cannot remember
doing anything special...)

> I presume I would need a debug version of Python as
> well...

if you have the Python sources and MSVC, you can build
a debug version in a couple of minutes...  (you'll find the
project files in the pcbuild subdirectory).

Cheers /F




From thomas at xs4all.net  Sat Jan 27 11:00:31 2001
From: thomas at xs4all.net (Thomas Wouters)
Date: Sat, 27 Jan 2001 17:00:31 +0100
Subject: . Python 2.1 function attributes
In-Reply-To: <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk>; from robin@jessikat.fsnet.co.uk on Sat, Jan 27, 2001 at 02:18:46PM +0000
References:   <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk>
Message-ID: <20010127170031.P962@xs4all.nl>

On Sat, Jan 27, 2001 at 02:18:46PM +0000, Robin Becker wrote:
> In article , Tim Peters
>  writes
> ....
> >Barry also added code to Python 2.1 to let you write, e.g.,
> >
> >    def f() >> x:
> >        x = 1
> >        y = 2
> >
> >as a short way to spell "whatever the value of x is at the end of the
> >function, return that".  I'm sure you'll agree that's much cleaner than the
> >clumsy
> >
> >    def f():
> >        x = 1
> >        y = 2
> >        return x
> >
> >people suffer with today.
> >
> ....
> mmmhhhh :( what happens with
> 
> def f() >> x:
>         return 1
> 
> 
> def f() >> x:
>         y=2
>         return y
> 
> seems to me that having multiple ways of doing return is a bad idea

You forgot to quote the clue:

> > hoping-a-truly-bad-idea-adds-some-perspective-ly y'rs  - tim

Tim wasn't serious, the syntax hasn't even been proposed. (At least, I
haven't seen the proposal. Then again, maybe Barry did propose it, and all
those mail delays on python-dev were an attempt to get it approved and
checked in before anyone oculd complain :-)

That-was-a-joke-too-in-case-you-wondered-ly y'rs,

-- 
Thomas Wouters 

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!



From jpl at global.co.za  Wed Jan 24 06:21:50 2001
From: jpl at global.co.za (James Lockley)
Date: Wed, 24 Jan 2001 13:21:50 +0200
Subject: Python vs Ruby
Message-ID: <94mdkd$222e$1@news.adamastor.ac.za>

Just been reading a "Ruby centric" comparison of Ruby vs Python on:
http://helium.ruby-lang.org/en/compar.html

would be interested to hear the Pythonista view....

james




From dsavitsk at e-coli.net  Sat Jan 27 01:10:36 2001
From: dsavitsk at e-coli.net (dsavitsk)
Date: Sat, 27 Jan 2001 00:10:36 -0600
Subject: Tkinter : button size
References: <3A722DED.74B41DA1@mega-nerd.com>  <3A723FD9.5AA0CDB@mega-nerd.com>
Message-ID: 

it is probably worth looking at
http://www.pythonware.com/library/tkinter/introduction/index.htm
or at mr. grayson's book about tkinter.  both are excellent references.
ds




From jerryleekeeney at yahoo.com  Fri Jan 26 19:44:22 2001
From: jerryleekeeney at yahoo.com (jerry keeney)
Date: Fri, 26 Jan 2001 16:44:22 -0800 (PST)
Subject: Tkinter: manipulating data in 'entry' widgets.
Message-ID: <20010127004422.18306.qmail@web9601.mail.yahoo.com>

Hopefully this is'nt a repeat of an oft discussed
item:

I have a Tkinter program with 3 entry widgets.  I
would like to take the numbers entered in the first
two, total them and display them in the 3rd (or even
just as a label).

I believe the idea is to capture the entry with a
DoubleVar, but beyond that I'm not sure.  

I have been perusing the various places on the web
discussing Tkinter, and I cannot find that sort of
detail.  Any pointers where I can get this info on the
web??

Thanks

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/



From emile at fenx.com  Sat Jan  6 12:22:59 2001
From: emile at fenx.com (Emile van Sebille)
Date: Sat, 6 Jan 2001 09:22:59 -0800
Subject: Pythonian string manipulation.
References: <937if5$r9q$1@nnrp1.deja.com>
Message-ID: <937kb7$91hfs$1@ID-11957.news.dfncis.de>

Strings are immutable.  You can extract string slices, but
not assign into them.  IIRC, Marc Lemburg offers text tools
that allow this, but I've not used them.  In normal python,
you must build a new string, and bind the variable to it.


>>> s = 'hello, world'
>>> l = s.split(', ')
>>> l.reverse()
>>> s = ', '.join(l)
>>> s
'world, hello'

HTH,

--

Emile van Sebille
emile at fenx.com
-------------------


 wrote in message
news:937if5$r9q$1 at nnrp1.deja.com...
> Hi,
>
> I was playing around with slices in Python (is that the
correct term?)
> and I tried, in order to switch the words `hello,' and
`world', to do:
>
> s = 'hello, world'
> l = s.find(',')
> s[0:l] = s[l + 1:]
>
> which in theory would seem to work, but I get the error:
>
> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: object doesn't support slice assignment
>
> my two questions are: why isn't this allowed, and what is
the Pythonian
> way of doing this?
>
> Thanks,
>  -- John
>
>
> Sent via Deja.com
> http://www.deja.com/




From grante at visi.com  Fri Jan 26 16:58:27 2001
From: grante at visi.com (Grant Edwards)
Date: Fri, 26 Jan 2001 21:58:27 GMT
Subject: SourceForge problems
References:   
Message-ID: <7qmc6.786$27.203609@ruti.visi.com>

In article , Thomas Wouters wrote:

>> >don't-even-try-discussing-hot-steaming-faggots-ly y'rs - tim
>
>> You're probably not talking about cigarettes or firewood, so
>> I'm guessing it's some sort of sausage. But English food is
>> best left undiscussed if not uneaten.  ;)
>
>As opposed to the wonderful american inventions of, uuhmm... the hotdog ? 

:)

I don't generally eat those either.  

-- 
Grant Edwards                   grante             Yow!  Do you need
                                  at               any MOUTH-TO-MOUTH
                               visi.com            resuscitation?


From tanzer at swing.co.at  Tue Jan 23 03:11:23 2001
From: tanzer at swing.co.at (Christian Tanzer)
Date: Tue, 23 Jan 2001 09:11:23 +0100
Subject: How do I know all thrown exceptions of a function? 
In-Reply-To: Your message of "22 Jan 2001 22:19:29 GMT."
             <94iblh$klo$1@nntp6.u.washington.edu> 
Message-ID: 

Donn Cave  wrote :

> Quoth Randall Hopper :
> | Fredrik Lundh:
> || Sean Reifschneider wrote:
> ||> Yeah, I suppose so.  I don't think you should *HAVE* to review the code of
> ||> the libraries you call, AND *EVERYTHING* that *THEY* call.  It's not an
> ||> effective use of my time...
> ||
> || yeah, and what's worse, having to *TEST* your code before
> || shipping just sucks...
> |
> | Like Steve, I think this is a bit too harsh.  What exceptions a public API
> | can throw is part of its interface, just like parameters and return values.

It is harsh. And testing certainly isn't an effective way of
finding out what exceptions can occur.

> | Groveling through library code for rare exception conditions (initially,
> | and for each dependency version update) isn't a productive use of a
> | developer's time.
> 
> Certainly not, and to me exception handling feels like the most
> unfinished part of Python.  Unfortunately I don't have any real
> ideas about it, I just find exception handling relatively error
> prone when it should be the opposite.

It's not the exception handling per se. IMHO, one of the problems is
that the exception hierarchy does not make any distinction between
exceptions indicating errors and exceptions indicating things like
KeyboardInterrupt or SystemExit which aren't errors.

If an application wants to avoid dying even in the presence of bugs it
must contain a catch-all clause somewhere. Yet, it certainly doesn't
want to catch SystemExit there, and it might not want to catch
KeyboardInterrupt either. This leads to code like:

    try :
        ...
    except (SystemExit, KeyboardInterrupt), exc :
        raise exc
    except :
        ...

Yuck.

BTW, silently dropping the exception in the catch-all handler is of
course not recommended.

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92




From dag at orion.no  Wed Jan 24 09:36:33 2001
From: dag at orion.no (Dag Sunde)
Date: Wed, 24 Jan 2001 14:36:33 GMT
Subject: usage on the time module(newbie)
References: <945neg$72d$1@nnrp1.deja.com>
Message-ID: 

I strongly reccomend you go to the
"Vaults of Parnassus" and pick up "mxDateTime"...

http://www.vex.net/parnassus/apyllo.py/514463245.769244789

Dag


 wrote in message news:945neg$72d$1 at nnrp1.deja.com...
> Hello:
>
> I'm having difficulty with the syntax for the function strptime
> in the time module
>
> For instance. If I have a variable....
> fred='Mon Jan 15 00:30:24 2001'
>
> what syntax would I use to parse this into a tuple?
> I have tried
> time.strptime(Mon Jan 15 00:30:24 2001[])
> but I receive an error..
>
> I did not see any examples in the documentation.
>
> Any help is greatly appreciated...
> Thanks,
> Chris
> fimafeng at yahoo.com
>
>
> Sent via Deja.com
> http://www.deja.com/




From tim.one at home.com  Wed Jan 10 00:04:17 2001
From: tim.one at home.com (Tim Peters)
Date: Wed, 10 Jan 2001 00:04:17 -0500
Subject: mmap (was RE: mxTools (was Re: why no "do : until"?))
In-Reply-To: 
Message-ID: 

[Paul Prescod]
> I haven't tried this recently but if I remember correctly, the
> problem is: How would I do a regexp match on "Py..n" on a 1-
> gigabyte file with a fixed amount of "lookahead"? Do I have to
> load in chunks at a time and then do the pattern matching across
> "chunk boundaries" myself? ...

[A.M. Kuchling]
> With the mmapfile module, you should be able to mmap the entire
> gigabyte file, and then do an re.search() on the whole thing.
> Performance is then up to _sre and your OS's virtual memory
> algorithms.

That's what I thought, but on Windows I never got it to work -- always ended
up staring at incomprehensible "The parameter is wrong" Windows msgs.

Just figured out why, so will share it.  There's a small bug, and key info
is missing from the docs.

Here's a working example on Windows (Win98SE; last I heard mmap doesn't work
at all on ME, but nobody knows why).  "gafat" is a large file, with one
occurrence of "zzz" at the very end:

import mmap, re, os
fname = "gafat"

size = os.path.getsize(fname)
print "os.path.getsize() says size is", size, "bytes"

f = open(fname, "rb+")
mapper = mmap.mmap(f.fileno(), 0)

print "mmap .size() says size is", mapper.size(), "bytes"

m = re.search("zzz", mapper)
print m.group(0), m.span(0)

Here's a run:

C:\Code\python\dist\src\PCbuild>python mre.py
os.path.getsize() says size is 119800271 bytes
mmap .size() says size is 119800271 bytes
zzz (119800264, 119800267)

C:\Code\python\dist\src\PCbuild>

So that all worked.  Cool!

Notes:

1) Doc needed:  The file *must* be opened for update (r+, w+, rb+ or wb+).
That's because CreateFileMapping is called with PAGE_READWRITE, and that
won't let you increase permissions over the original open mode.  Violating
this yields the baffling "The parameter is wrong" errors from mmap.mmap().

It's unfortunate that the Unix mmap.mmap() takes the "flags" arg before the
"prot" arg, because we could have implemented "prot" for Windows too.

2) Doc needed:  Passing a size of 0 makes the maximum size of the mapping
the actual current size of the file.  Don't know whether that's also true on
Unices; on Windows it's intentional; and it's handy to know so it's worth
documenting.

3) Doc bug:  The docs read as if omitting the optional tagname is different
than supplying a tagname of None.  I don't believe that's true; needs mild
rewording.

4) Code bug:  If a tagname isn't supplied, it looks like the code intended
to follow the probable meaning of the docs (by creating a mapping without a
name), but it actually creates a mapping with a name (an empty string).
I'll check in a fix for that tonight.

mmap-will-never-catch-on-if-it-can't-be-used-ly y'rs  - tim




From abramsjc at my-deja.com  Fri Jan 12 15:24:04 2001
From: abramsjc at my-deja.com (abramsjc at my-deja.com)
Date: Fri, 12 Jan 2001 20:24:04 GMT
Subject: ASP + SQL Server + Time object problem
Message-ID: <93np4p$lm$1@nnrp1.deja.com>

I'm using Python in ASP, and I have a recordset that returned a