From sabren at manifestation.com Sat Jul 1 01:11:58 2000 From: sabren at manifestation.com (Michal Wallace) Date: Fri, 30 Jun 2000 19:11:58 -0400 (EDT) Subject: MD5 - Passwords with python In-Reply-To: <2vegj8.ia5.ln@odin.hmf.de> Message-ID: On Thu, 29 Jun 2000 holger at fuessler-net.de wrote: > Unfortunately, the standard MD5-module doesn't know about the > structure of the password-string so I can't encode a password with > it. I found a perl module which accomplishs my task and so I thought > that there is also a python module. I thought redhat uses a lot of > python stuff, so there should be a routine to generate suitable > passwords. I'v already posted in comp.redhat.security. When I find > the details, I'll post them here (if I can translate them to > python). http://www.sabren.com/code/python/crypt/ Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From dsavitsk at e-coli.net Sat Jul 1 01:28:02 2000 From: dsavitsk at e-coli.net (dsavitsk) Date: Fri, 30 Jun 2000 23:28:02 GMT Subject: Web server executing Python scripts References: <4.3.1.2.20000630151218.021a7858@phear.dementian.com> Message-ID: <62a75.28853$dF.1122319@news1.rdc1.il.home.com> just to give a different point of view :-) while iis may be insecure, ms is on to something with the asp thing (or did a good job copying php/coldfusion/jsp etc). if you are on an intranet and security is less of an issue, asp is really easy and runs a bit faster than cgi. there are also asp plug-ins for apache (www.halcyionsoft.com and www.chilisoft.com) that are sometimes free, sometimes not depending on what you are doing etc. i'm not sure if these will allow PythonScript, but it might be worth looking into. doug "Steven D. Arnold" wrote in message news:4.3.1.2.20000630151218.021a7858 at phear.dementian.com... > At 08:24 PM 6/30/2000 +0200, Pieter Claerhout wrote: > > >What do you think would be the best idea? > >- Use whatever webbrowser with CGI-scripting > > I would use apache and either CGI or mod-python, more likely the latter. > > > >- Use MS IIS with ASP (and Python) > > IIS is quite probably the most insecure server on the Internet. In > addition, I don't like the closed nature of the system, I don't trust MS to > introduce the features I want/need (where I can introduce them myself in > Apache), and I don't want to depend on MS's support services to solve > problems that only they can fix because only they have the source. > > > >- Use Zope to build the whole system? > > I don't know enough about Zope to give an answer from personal experience > here. I've heard many good things about Zope; I've also heard that the > docs are poor and the learning curve steep. I have faith in the speed and > flexibility of Apache, where (to me) Zope is an unknown in these regards; > are there any benchmarks? > > > steve > > > -- > Steven D. Arnold Que quiero sera stevena at neosynapse.net > "If you have built castles in the air, your work need not be lost; that > is where they should be. Now put the foundations under them!" -- Thoreau > > From db3l at fitlinxx.com Sat Jul 1 01:30:53 2000 From: db3l at fitlinxx.com (David Bolen) Date: 30 Jun 2000 19:30:53 -0400 Subject: Following a file, or cloning tail References: <8F62AF73Egmcmhypernetcom@199.171.54.194> <36D5F4DFCA9BCA46.B5AE15F2F19F393C.28F9B766F10B5E23@lp.airnews.net> <8F62C20E2gmcmhypernetcom@199.171.54.154> Message-ID: gmcm at hypernet.com (Gordon McMillan) writes: > Well, os.popen works fine between console processes on the NT family of > Windows. However, Windows has problems with 16 bit DOS apps and Win95 has > an MS acknowledged problem with any of this stuff. The win32 extensions fix > most of these problems, (I think Bill Tutt even added a workaround for the > Win95 bug), and I believe that 1.6 will use the win32 versions if they are > installed (at least, this was discussed seriously at some point). If they do, then I hope that the extensions get augmented to return the result code of the child process on close(), since that's really the only thing holding me up from using them (for now I just use NT and ensure I have a console allocated to my process). I guess I'm just glad that my requirements to use Windows stops with NT, since I also think Python might be a non-starter for a lot of my administration apps if popen() didn't work reliably. Of course, MS is far more to blame for this than Python :-) -- -- 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 rmartin at objectmentor.com Sat Jul 1 01:56:52 2000 From: rmartin at objectmentor.com (Robert C. Martin) Date: Fri, 30 Jun 2000 18:56:52 -0500 Subject: OmPyUnit -- A python unit test framework. References: <8jhr2t$j3k$1@pollux.ip-plus.net> Message-ID: "J?rgen Hermann" wrote in message news:8jhr2t$j3k$1 at pollux.ip-plus.net... > > "Robert C. Martin" schrieb im Newsbeitrag > news:slnttnejjev80 at news.supernews.com... > > I have made our OmPyUnit unit test framework for python available in the > > 'downloads' section of http://www.objectmentor.com. This framework is > very > > similar in appearance and operation to JUnit. > > Is it in any way related to PyUnit (http://pyunit.sourceforge.net/), besides > the common JUnit heritage? No, that's a completely separate implementation. I haven't put OmPyUnit up on sourceforge yet. -- Robert C. Martin | "Uncle Bob" | Training Courses: Object Mentor Inc. | rmartin at objectmentor.com | OOD, Patterns, C++, Java, PO Box 85 | Tel: (800) 338-6716 | Extreme Programming. Grayslake IL 60030 | Fax: (847) 548-6853 | http://www.objectmentor.com "One of the great commandments of science is: 'Mistrust arguments from authority.'" -- Carl Sagan From mwh21 at cam.ac.uk Sat Jul 1 02:16:25 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Jul 2000 01:16:25 +0100 Subject: Problem with execv References: <8jg6j3$o84$1@nnrp1.deja.com> Message-ID: Jeremy Hylton writes: > The correct calling convention is to supply a tuple or list as the > second argument to execv. Example: > > >>> os.execv('/bin/ls', ('.',)) > [lists contents of current directory] ITYM >>> os.execv('/bin/ls',('ls','.')) or some such. There's also >>> os.execlp('ls','ls','.') and many other variants... Cheers, M. -- 7. It is easier to write an incorrect program than understand a correct one. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From Norman_Shelley-RRDN60 at email.sps.mot.com Sat Jul 1 01:54:37 2000 From: Norman_Shelley-RRDN60 at email.sps.mot.com (Norman Shelley) Date: Fri, 30 Jun 2000 16:54:37 -0700 Subject: UserDict and UserList issue (bug?_ Message-ID: <395D333D.9240593C@email.sps.mot.com> in UserDict and UserList there is one or more places where a call to self's __class__() method is made, e.g. def __getslice__(self, i, j): i = max(i, 0); j = max(j, 0) # This class and its subclasses need more arguments then 0 userlist = self.__class__() .... This blows causes major problems when either of these two classes are subclassed and the class which subclasses them requires creation arguments. I think maybe a copy of self instead of a __class__() may be a more robust solution. From Norman_Shelley-RRDN60 at email.sps.mot.com Sat Jul 1 01:57:34 2000 From: Norman_Shelley-RRDN60 at email.sps.mot.com (Norman Shelley) Date: Fri, 30 Jun 2000 16:57:34 -0700 Subject: ?Combination of a Dictionary and a List? Message-ID: <395D33EE.75F1E36D@email.sps.mot.com> Sometime in the past I wrote a simple combination of a dictionary and a list, where __getitem__() would first look in a hidden dictionary and then if not found it would try looking in a hidden list. I've seen this type of code out there somewhere also but I can not find my code or anyone elses. I guess I haven't figure our the "right" search criteria on www.python.org. Any pointers? From gmcm at hypernet.com Sat Jul 1 02:23:57 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 01 Jul 2000 00:23:57 GMT Subject: Passing variable-length keyworded arguments list to base class constructor? References: <962352947.103057778@news.libertysurf.fr> <8F635367Cgmcmhypernetcom@199.171.54.154> <962379073.1230449645@news.libertysurf.fr> Message-ID: <8F63C1ABDgmcmhypernetcom@199.171.54.154> Jerome Quelin wrote: >gmcm at hypernet.com (Gordon McMillan) wrote: >>>But how to pass this dictionnary to the parent class constructor? >>class F(Frame): >> def __init__(self, *args, **kwargs): >> apply(Frame.__init__, (self,)+args, kwargs) >>Generally you have to muck with the kwargs dict before passing it to the >>base class __init__. >That is exactly what I want to know: what this mucking consists of? Depends on what args the base class expects. If the base class expects **kwargs, then you can have anything in there. But if the base class were defined: class Frame: def __init__(self, x=0, y=0): .... And the kwargs you pass it has {'snoo':33,...}, it's going to barf. But maybe you've been playing with the interpreter, and have discovered all this by now... - Gordon From urner at alumni.princeton.edu Sat Jul 1 02:29:48 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Fri, 30 Jun 2000 17:29:48 -0700 Subject: PowerPoint slide presentation (Math + Python) Message-ID: Greetings educators, Python programmers -- For those of you with PowerPoint and/or the requisite browser plug-ins, I've tossed a slide show on the web at: ftp://ftp.teleport.com/pub/users/pdx4d/images/synergeo.ppt This is my standard 'Beyond Flatland' curriculum, wherein I mix spatial geometry, virtual worlds, computer programming (these days Python), and synergetics. Given this is just an outline of a talk, there's not a lot of discussion (few words). To present this material effectively, you'd need to study the background readings e.g. http://www.inetarena.com/~pdx4d/ocn/cp4e.html (see 'Numeracy + Computer Literacy' series). Uses some of those special effects PowerPoint is all about. Apologies if this is distracting, but the business culture in which I operate kinda likes these bells and whistles. Feedback welcome. Kirby 4D Solutions Portland, Oregon http://www.teleport.com/~pdx4d/ PS: use mouse clicks to get text bullets to appear, and to move from slide to slide (11 slides in all). PPS: also notified educators at http://mathforum.com/epigone/math.teaching.technology of this free download From gmcm at hypernet.com Sat Jul 1 02:34:39 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 01 Jul 2000 00:34:39 GMT Subject: command-line history in win References: <395c304e.1224185@news.student.lu.se> <8jhm03$qnm$1@nnrp1.deja.com> <8jig08$dk7$1@nnrp1.deja.com> Message-ID: <8F63D360Egmcmhypernetcom@199.171.54.154> david_ullrich at my-deja.com wrote: > David Currie wrote: >> It works for me (Python 1.5.2)... > Keen. Maybe I'm the only one who doesn't know: >_What_ works for you, exactly? Perhaps David is on NT, where it just works (not only for DOS cmds, but if you start Python, up-arrow will take you thru the history for your last Python session in that DOS box). This is all built in to NT. Sorry, can't help with Win9x. - Gordon From mwh21 at cam.ac.uk Sat Jul 1 02:36:07 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Jul 2000 01:36:07 +0100 Subject: Python MP3 Player References: <395CE50A.3BA16777@bioeng.ucsd.edu> Message-ID: Curtis Jensen writes: > Does anyone know of a Python MP3 Player? I've cobbled together some Python that you can use to control xmms if that's what you want. Anyone interested? I can stick it on my starship page if anyone is... Cheers, M. -- On the other hand, the following areas are subject to boycott in reaction to the rampant impurity of design or execution, as determined after a period of study, in no particular order: ... http://www.naggum.no/profile.html From mwh21 at cam.ac.uk Sat Jul 1 02:37:42 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Jul 2000 01:37:42 +0100 Subject: backslash in regular expression problem References: <394A55BA.69269793@wolfson.co.uk> <02de01bfd826$cf05bd80$6401a8c0@home> <8jivfr$qc2$1@nnrp1.deja.com> Message-ID: Keith Murphy writes: > what if instead of having '\\stuff' you have a str = '\\stuff' ? > > i know that you can print r'\\stuff' but you can't print rstr... > > how do you use the raw with a variable? You don't. You do know about re.escape? Asking that question suggests you might not... Cheers, M. -- I saw `cout' being shifted "Hello world" times to the left and stopped right there. -- Steve Gonedes From cbbrowne at news.hex.net Sat Jul 1 02:53:39 2000 From: cbbrowne at news.hex.net (Christopher Browne) Date: Sat, 01 Jul 2000 00:53:39 GMT Subject: ?Does Python have sorting via "Dictionary Order"? References: <395A92D0.65A205B1@email.sps.mot.com> Message-ID: Centuries ago, Nostradamus foresaw a time when Norman Shelley would say: >Does Python have sorting via "Dictionary Order"? This would be a very >handy addition as an option to list's sort() function. Feel free to avail yourself of the documentation... "The keys() method of a dictionary object returns a list of all the keys used in the dictionary, in random order (if you want it sorted, just apply the sort() method to the list of keys)." -- cbbrowne at ntlug.org - "People need to quit pretending they can invent THE interface and walk away from it, like some Deist fantasy." -- Michael Peck From thomas at xs4all.nl Sat Jul 1 03:06:50 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 1 Jul 2000 01:06:50 GMT Subject: UserDict and UserList issue (bug?_ References: <395D333D.9240593C@email.sps.mot.com> Message-ID: On Fri, 30 Jun 2000 16:54:37 -0700, Norman Shelley wrote: >in UserDict and UserList there is one or more places where a call to >self's __class__() method is made, e.g. > >def __getslice__(self, i, j): > i = max(i, 0); j = max(j, 0) > # This class and its subclasses need more arguments then 0 > userlist = self.__class__() > .... >This blows causes major problems when either of these two classes are >subclassed and the class which subclasses them requires creation >arguments. I think maybe a copy of self instead of a __class__() may be >a more robust solution. And how would you get a copy of self without creating a new instance of self.__class__ ? You usually create a copy of a list by doing: mycopy = mylist[:] Which calls __getslice__, which is exactly what you are complaining about :-) If you want to subclass UserList, either make sure you provide defaults for all arguments to the initializer, or make sure you override all places where self.__class__() may be called without your required arguments. #1 is probably the best (and most portable) solution, and not just because of the above issue: providing defaults for all initializer arguments allows your object to be pickled, for instance ;) But I dont know why you need those arguments, so YMMV. Regards, Thomas. From MarkH at ActiveState.com Sat Jul 1 03:33:55 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 01 Jul 2000 01:33:55 GMT Subject: Reference Counting Woes in Python 1.5.2! Help! References: Message-ID: <7Ub75.2486$Tb7.18780@news-server.bigpond.net.au> > I am using Visual C++ 6. It has debug libraries that are catching this > problem printing an error message and quitting. When I go to release version > of code, I get access violations and then the code quits. Alas, what I'd > like is to see the access violation location in source code, but the darn > debug library gets in the way! It shouldnt be doing this! An access violation when running under debug build should definately break into the debugger, and definately does for me. You may be seeing Py_FatalError() being called. This just prints a message and calls "exit()", which does silently die. Post Python 1.5, this routine as a block: #ifdef _DEBUG DebugBreak() #endif You could try adding that to Python 1.5.2. Then, in debug builds, a Py_FatalError() will also break into the debugger. > Has anyone else debugged pesky reference count problems in Visual C++ with > Python 1.5.x and come out on the winning end? Your help or tips or > suggestions on how to debug this sort of thing would be most welcome! I find reference underflows easier to work with generally than leaks. But you definately need the exception in the VC debugger. The symptoms are generally that other code will die when trying to use the object with the bad reference. This can usually tell you at least the _type_ of the object in question. Another good hint - when re-running the same program multiple times under VC, you almost always get identical addresses allocates between multiple runs. For example, if one run shows that object at address "0x123456" has the ref count bug, restarting the program and rerunning under the debugger will almost certainly give the same pointer the same address. This makes it easier to "back-step" through the offending code in multiple debugging sessions. (eg, next step after determining the above may be to set a break-point whenever "*(int *)0x123456" (ie, the objects reference-count) changes. Mark. From MarkH at ActiveState.com Sat Jul 1 03:35:53 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 01 Jul 2000 01:35:53 GMT Subject: Following a file, or cloning tail References: <8F62AF73Egmcmhypernetcom@199.171.54.194> <36D5F4DFCA9BCA46.B5AE15F2F19F393C.28F9B766F10B5E23@lp.airnews.net> <8F62C20E2gmcmhypernetcom@199.171.54.154> Message-ID: > I guess I'm just glad that my requirements to use Windows stops with > NT, since I also think Python might be a non-starter for a lot of my > administration apps if popen() didn't work reliably. Of course, MS is > far more to blame for this than Python :-) And Bill Tutt is to be eternally thanked for Python solving it :-) [And Gordon is correct - later builds have reliable popen on Win9x too, also thanks to Bill!] Mark. From dnotspam-jen at personic.com Sat Jul 1 03:39:21 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Fri, 30 Jun 2000 18:39:21 -0700 Subject: Communicating between two computers Message-ID: <395d48b3$0$21842@wodc7nh0.news.uu.net> FYI, I'm doing all of this on Windows NT, in case that makes a difference ... Is there a good way to get a script on one computer to talk to a script on another computer? The process I'm thinking of is pretty simple ... I want a script on a Web server to be able to send a command to a build server to start a build process. I'd also like the Web server to be able to query the build servers to find out their status (so that two builds do not run at once on the same machine, for example). I've read a little about SOAP, but I think that my needs are probably a lot simpler than that. The easiest way to accomplish this is to setup a Web server on each of the build machines, too, I guess ... but I was hoping that I could just have the scripts that run on the build servers run as NT services. Thanks! Jen From thomas at xs4all.nl Sat Jul 1 03:32:42 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 1 Jul 2000 01:32:42 GMT Subject: Controlling an external program with Python References: <3958C648.1D76@rd.francetelecom.fr> <8j7vc3$6b6q$1@nntp6.u.washington.edu> <39588741.FB7EB5FE@hursley.ibm.com> <3958A7AE.7DAA@rd.francetelecom.fr> <3958C134.7AAEF37B@hursley.ibm.com> <8jc28s$8eb$0@216.39.151.169> <8jdf8j$8tm4$1@nntp6.u.washington.edu> Message-ID: On 28 Jun 2000 18:13:39 GMT, Donn Cave wrote: >The MIT Kerberos 5 pty library I mentioned uses a getpty function that >opens the master pseudoty and returns its file descriptor and the name >of its slave terminal device. Where it uses openpty() underneath, it >doesn't supply any termios settings and closes the slave file descriptor >immediately. It doesn't use forkpty() for anything. My reflex reaction >is that's the right level of support for a C module: export all possible >semi-standard low level interfaces, and put convenience routines in a >Python module. I disagree, and I think some of the Python developers do, too, looking at the way posixmodule is laid out (and the fact that the SGI module is candidate for removal in the next Python release.) Exporting all lowlevel calls to Python and letting the pty lib take care of determining which are appropriate creates a horrible mess. I did it with the new pty lib, that switches between os.openpty, sgi._getpty and the original BSD 'try and get a tty' methods, and it blows chunks, especially if you take into account that one method might be available but fail, but another might succeed. If there was one 'openpty' call in the os module, which might be emulated from other kinds of calls in C, for whatever platform it is convenient, most of what remains are #ifdefs (of which the posixmodule, for one, already has quite a bunch) and the choice between os.openpty() and opening /dev/pty* manually. My reason for taking openpty, which returns an opened master/slave fd pair, over something a little more sgi-like (open master, return master_fd + name of slave tty) is very simple, and very selfish: I work mostly with BSDI servers, FreeBSD and Linux workstations. All support openpty. And the fact that Linux has it makes me believe it's the most used method of getting a pty. Both methods of returning a pty can emulate the other just as well; in fact, the new pty lib does just that ;) it has the old master_open() and slave_open(), and it has openpty(). I agree, though, that keeping forkpty() in the posixmodule might not be worth it. It's badly documented, for instance on wether or not the new child is a session leader or not, so it might end up much easier just using a python version that utilizes pty.openpty(), and *is* properly documented. >Some of these interfaces may be appropriate for the posix module, but >I doubt it! Aside from the narrow-minded question of whether any of it >is covered by POSIX 1003.1, from the user side it's inevitable that on >some platform that does build the posix module, the pty functions won't >be supported. They'll need another module that can be optionally >supported, like termios, fcntl et al. I'm not sure if 'POSIX defines it' is a criterium for adding a function to the posix module, though it might be. In that case, it should be factored out to a _pty module, together with things such as ttyname() possibly. But I'm not sure if it's out of place in the posix module: Adding it to posixmodule adds it to the os module, which means that other platforms can write their own, entirely seperate implementation, without the need to add more #ifdefs. >The more we can steal, the better. There's too much platform specific >folklore in here to write a good C implementation from scratch with >man pages. Agreed. I do like the idea of an external, extensive pty-emulation library or such, but I have two very simple problems with that: I do not have the time to write it, and I do not have a need for it ;) openpty() is exactly what I need. I'd be happy to move sgi._getpty into openpty() (if the sgi module is indeed going to be deprecated/removed) and add other variants, as a bunch of #ifdefs, but I don't feel like supporting non-UNIX operating systems, and I don't feel like building an external project for this ;) Besides, it's late, I shouldn't be posting at this hour :-P Note-my-crafty-and-elegant-way-of-avoiding-Pythons-version-number-ly y'rs, Thomas. From sridhar at mediaone.net Sat Jul 1 03:49:06 2000 From: sridhar at mediaone.net (Sridhar Bidigalu) Date: Fri, 30 Jun 2000 21:49:06 -0400 Subject: Subscribe Message-ID: <395D4E11.EBAEA908@mediaone.net> -------------- next part -------------- A non-text attachment was scrubbed... Name: sridhar.vcf Type: text/x-vcard Size: 371 bytes Desc: Card for Sridhar Bidigalu Url : http://mail.python.org/pipermail/python-list/attachments/20000630/6ec58387/attachment.vcf From db3l at fitlinxx.com Sat Jul 1 04:10:48 2000 From: db3l at fitlinxx.com (David Bolen) Date: 30 Jun 2000 22:10:48 -0400 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: "donotspam-jen at personic.com" writes: > I've read a little about SOAP, but I think that my needs are probably a lot > simpler than that. The easiest way to accomplish this is to setup a Web > server on each of the build machines, too, I guess ... but I was hoping that > I could just have the scripts that run on the build servers run as NT > services. Well, there's probably no end to the number of protocols and methods by which you could get the machines to talk, but given that it's Python invoking Python, you might take a peek at Fredrik Lundh's XML-RPC library. XML-RPC was sort of the precursor to SOAP. Similar in concept, but it's dirt simple to get two Python processes communicating (calling arbitrary methods with any Python objects and returning any Python objects). See http://www.pythonware.com/products/xmlrpc/index.htm. I imagine you could run a server utilizing this within a service using the PythonService module included in the Pythonwin extensions without too many problems. -- -- 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 dgoodger at bigfoot.com Sat Jul 1 04:38:51 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Fri, 30 Jun 2000 22:38:51 -0400 Subject: ?Combination of a Dictionary and a List? References: <395D33EE.75F1E36D@email.sps.mot.com> Message-ID: on 2000-06-30 19:57, Norman Shelley (Norman_Shelley-RRDN60 at email.sps.mot.com) wrote: > Sometime in the past I wrote a simple combination of a dictionary and a > list, where __getitem__() would first look in a hidden dictionary and > then if not found it would try looking in a hidden list. I've seen this > type of code out there somewhere also but I can not find my code or > anyone elses. I guess I haven't figure our the "right" search criteria > on www.python.org. Any pointers? > Many people have had such a need at some point (myself included; see my signature below), but each with slightly different requirements. Do you want a list that acts like a dictionary, or a dictionary that acts like a list, and in what way? Look for the c.l.p thread "indexed dictionaries?" of 2000-04-09, see "seqdict" on Parnassus, and examine the "UserDict" and "UserList" modules in the standard Python library. -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From claird at starbase.neosoft.com Sat Jul 1 05:17:34 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Jun 2000 22:17:34 -0500 Subject: Web server executing Python scripts References: <2B1262E83448D211AE4B00A0C9D61B030130125E@msgeuro1.creo.be> Message-ID: <80EB8C0C818F320D.2A60B0748B6BCCB3.6A1C28BCC752E3D8@lp.airnews.net> In article <2B1262E83448D211AE4B00A0C9D61B030130125E at msgeuro1.creo.be>, Pieter Claerhout wrote: >Hello all, > >I'm working on a web based system, which consist of a whole >bunch of Python scripts, which connect to a bunch of machines >on a network (either using ethernet or dailup networking) and >execute some to code to for example get things from the >windows registry of those machines. > >What do you think would be the best idea? >- Use whatever webbrowser with CGI-scripting >- Use MS IIS with ASP (and Python) >- Use Zope to build the whole system? > >It should also connect to a database running on the host. > > >Pieter > Others have already demonstrated that there's a large ... situational, if not subjective, component to the decision about which Web server to use. Your first paragraph interests me. Do you realize that Python can retrieve registry information directly through your LAN, without a need for installation of "some to code" on the reporting hosts? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From samwun at yahoo.com Sat Jul 1 05:24:33 2000 From: samwun at yahoo.com (Sam Wun) Date: Sat, 01 Jul 2000 13:24:33 +1000 Subject: how to make popen secure? Message-ID: <395D6471.79CF0908@yahoo.com> I want to use popen execute an external C program. The C program is written to read kmem network traffic form the kernel memory. Therefore the C program is given a special permission to read the kmem device. How do I make popen secure? or how to make kmem secure even thought it is read by the C program? thanks Sam. From olczyk at interaccess.com Sat Jul 1 06:40:10 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Sat, 01 Jul 2000 04:40:10 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> Message-ID: <395d728e.117049078@nntp.interaccess.com> On 28 Jun 2000 06:02:09 GMT, thomas at xs4all.nl (Thomas Wouters) wrote: >On Wed, 28 Jun 2000 04:05:21 GMT, Courageous wrote: > >>> On top of that, very likely that if SUN sues they win. > >>Ridiculous. > >Very much so. But it wouldn't be suprising just the same, given the American >patenting/registration practices and the average american courthouse ;-) > >Overseas-ly y'rs, > Thomas Virtually all SUN has to do is pull some of the demo programs out of Microsofts manual. Write the equivalent code in python, perl, C++, pascal, and a few other languages. Compare them side by side. A fairly sophisticated person can see that it's resemblance to Java. Look at the law judges are sophisticated enough. Given that Microshit is being sued by SUN for their abuse of Java, I don't think it will be hard at all for SUN to convince a judge that all C# is, is a variant of Java with tons of proprietary crap glued on and the label changed. From frankc at colconsulting.com Sat Jul 1 06:56:30 2000 From: frankc at colconsulting.com (Frank V. Castellucci) Date: Sat, 01 Jul 2000 00:56:30 -0400 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> <962367319.379353174@news.libertysurf.fr> Message-ID: <395D79FE.4E4FDBCE@colconsulting.com> Jerome Quelin wrote: > > "Alex Martelli" wrote: > >By calling the accessors, rather than accessing the data > >directly, you ensure that if somebody overrides the > >accessor functions in a derived class you'll be calling > >the derived-class versions of those functions. If that is > >what you want (one direction along which you want to let > >inheritors of your class extend or tweak behaviour), then > >it's probably worth the overhead you mention. > The class isn't to be derived any further. It's a class that I use in an > application, and that may be imported in some other applications, but not to be > inherited. > > Then, is it better/cleaner to access private members with accessors or not? > Is it a matter of style? Or are there hidden caveheats using (or not using) > accessors? It _seems_ cleaner to use accessors, but man, it's quite awkward. > > Jerome > -- > jerome.quelin at insalien.org As you really have no way to "prohibit" further derivation (unless I missed the "final" keyword in the reference), using your accessors and praying that anyone over-riding the accessor/mutator methods does the proper thing would be my direction. -- Frank V. Castellucci http://corelinux.sourceforge.net OOA/OOD/C++ Standards and Guidelines for Linux http://PythPat.sourceforge.net Pythons Pattern Package From jkraska1 at san.rr.com Sat Jul 1 07:10:50 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 01 Jul 2000 05:10:50 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> Message-ID: <395D7E14.B18EC77D@san.rr.com> > Virtually all SUN has to do is pull some of the demo programs out of > Microsofts manual. Write the equivalent code in python, perl, C++, > pascal, and a few other languages. Compare them side by side. A fairly > sophisticated person can see that it's resemblance to Java. Look at > the law judges are sophisticated enough. Given that Microshit is being > sued by SUN for their abuse of Java, I don't think it will be hard at > all for SUN to convince a judge that all C# is, is a variant of Java > with tons of proprietary crap glued on and the label changed. And all Java is is a variant of the C++ language with the kitchen think glued on and the label changed. Hence the ridiculousness of the claim. Sun would be stupid to even try. C/ From jcm at bigskytel.com Sat Jul 1 07:22:10 2000 From: jcm at bigskytel.com (David Porter) Date: Fri, 30 Jun 2000 23:22:10 -0600 Subject: Python MP3 Player In-Reply-To: ; from mwh21@cam.ac.uk on Sat, Jul 01, 2000 at 01:36:07AM +0100 References: <395CE50A.3BA16777@bioeng.ucsd.edu> Message-ID: <20000630232210.A1287@novara.avenue> * Michael Hudson : > Curtis Jensen writes: > > > Does anyone know of a Python MP3 Player? > > I've cobbled together some Python that you can use to control xmms if > that's what you want. Anyone interested? I can stick it on my > starship page if anyone is... I am! I was just thinking about doing something like this. Thanks, David From donn at oz.net Sat Jul 1 08:06:22 2000 From: donn at oz.net (Donn Cave) Date: 1 Jul 2000 06:06:22 GMT Subject: Controlling an external program with Python References: <3958C648.1D76@rd.francetelecom.fr> <8j7vc3$6b6q$1@nntp6.u.washington.edu> <39588741.FB7EB5FE@hursley.ibm.com> <3958A7AE.7DAA@rd.francetelecom.fr> <3958C134.7AAEF37B@hursley.ibm.com> <8jc28s$8eb$0@216.39.151.169> <8jdf8j$8tm4$1@nntp6.u.washington.edu> Message-ID: <8jk1ou$jq9$0@216.39.151.169> Quoth thomas at xs4all.nl (Thomas Wouters): | On 28 Jun 2000 18:13:39 GMT, Donn Cave wrote: |> The MIT Kerberos 5 pty library I mentioned uses a getpty function that |> opens the master pseudoty and returns its file descriptor and the name |> of its slave terminal device. Where it uses openpty() underneath, it |> doesn't supply any termios settings and closes the slave file descriptor |> immediately. It doesn't use forkpty() for anything. My reflex reaction |> is that's the right level of support for a C module: export all possible |> semi-standard low level interfaces, and put convenience routines in a |> Python module. | | I disagree, and I think some of the Python developers do, too, looking at | the way posixmodule is laid out (and the fact that the SGI module is | candidate for removal in the next Python release.) No way did I mean to call for more things like the sgi module. The kind of semi-standard operations I have in mind are like termios, for example - we already have a termios module, so avoid the termios option in openpty - and then some abstraction of the characteristic operations performed on pseudotty devices. Here's how MIT sorts this out: long pty_init(void); long pty_getpty ( int *fd, char *slave, int slavelength); long pty_open_slave (const char *slave, int *fd); long pty_open_ctty (const char *slave, int *fd); long pty_initialize_slave ( int fd); long pty_update_utmp (int process_type,int pid, char *user, char *line, char *host, int flags); long pty_logwtmp (char *tty, char * user, char *host); long pty_cleanup(char *slave, int pid, int update_utmp); Cleanup, for example, performs various platform-specific functions like revoke() that have to do with shutting down and hanging up the tty. But whatever functions are provided should certainly be the same for all platforms inasmuch as possible, not like the way pty.py does it today. The big head-scratcher for me is MS Windows. Apparently it would be possible to support some similar functionality, but obviously from a completely different implementation. It would be terrific if the API were a comfortable fit for Windows too, but that might have to occur at a much higher level of abstraction, so to speak. | My reason for taking openpty, which returns an opened master/slave fd pair, | over something a little more sgi-like (open master, return master_fd + name | of slave tty) is very simple, and very selfish: I work mostly with BSDI | servers, FreeBSD and Linux workstations. All support openpty. And the fact | that Linux has it makes me believe it's the most used method of getting a | pty. You could be right about openpty's coverage. It's in the man pages on Digital UNIX too. I don't know exactly why MIT chose to close the slave tty from openpty(), instead of opening it after ptsname() etc. to support an openpty-like function. There might be no particular reason, but I defer to their accumulated expertise, since they manage to support telnet and rlogin on a reasonable range of platforms with this stuff. Donn Cave, donn at oz.net From donn at oz.net Sat Jul 1 08:14:42 2000 From: donn at oz.net (Donn Cave) Date: 1 Jul 2000 06:14:42 GMT Subject: Problem with sys.exit() References: <395CC5BA.AE64BB75@sas.upenn.edu> Message-ID: <8jk28i$jq9$1@216.39.151.169> Quoth "Steven M. Castellotti" : | I'm having some difficulty with a particular python script. I'm taking | gzipped log files and calling zcat (from the command line) with one | script (feeder.py), which pipes the output to the second script | (parser.py). The second script addes up few things, and I want it to | report the final total back to the feeder script. I tried passing it via | sys.exit() (ugly I know, but it seemed like a good idea at the time) but | when I use the numbers in the feeder script, the numbers are way off: | | End of parser.py: | | print total_registrations | sys.exit(total_registrations) | | Relevant portion of feeder.py: | | ... | | grand_total = grand_total + \ | os.system('zcat %s | python authlog_parser.py' % (filename) ) | print "%i" % os.system('zcat %s | python authlog_parser.py' % (filename) | ) | print "Grand Total: %s" % grand_total | | | But my output looks something like this: | | 3 | 768 | Grand Total: 1024 | | ...where the "3" is the actual total getting passed into sys.exit(), | 768 is what parser.py is recieving, and 1024 being the total. | | Any ideas about what might be wrong, or perhaps a better way to do | this? If there was a way to read a gzip'd text file directly into python | that'd probably take care of it, but why isn't this working? Try shifting the result of os.system() right 8 bits. Also note that you have only 7 or 8 bits to work with here, so it will work for 3 or 30 but not 300. It wouldn't hurt all that much to use popen(). Donn Cave, donn at oz.net From dalke at acm.org Sat Jul 1 08:37:01 2000 From: dalke at acm.org (Andrew Dalke) Date: Sat, 1 Jul 2000 00:37:01 -0600 Subject: ?Does Python have sorting via "Dictionary Order"? References: <395A92D0.65A205B1@email.sps.mot.com> Message-ID: <8jk3d0$t38$1@slb0.atl.mindspring.net> Christopher Browne wrote in message ... >Centuries ago, Nostradamus foresaw a time when Norman Shelley would say: >>Does Python have sorting via "Dictionary Order"? This would be a very >>handy addition as an option to list's sort() function. > >Feel free to avail yourself of the documentation... > >"The keys() method of a dictionary object returns a list of all the >keys used in the dictionary, in random order (if you want it sorted, >just apply the sort() method to the list of keys)." I do believe you misunderstood the original poster's question. He gave a description of "Dictionary Order" based on how words in a paper-bound dictionary (as in the Oxford English Dictionary) might be ordered. He was not refering to their order as used in a Python dictionary data structure (mapping unique keys to values). Andrew dalke at acm.org From boud at rempt.xs4all.nl Sat Jul 1 09:02:50 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 1 Jul 2000 07:02:50 GMT Subject: [Tkinter]: Where is a good place to learn how to use this...? References: <20000630211051.11572.qmail@web5301.mail.yahoo.com> Message-ID: <8jk52q$6fs$1@news1.xs4all.nl> Dave Williams wrote: > Where is a good (free maybe) online resource for > this?? And my "book" doesn't really seem to get into > Tkinter either, so is there one I should be reading > that does? Python and Tkinter Programming, by Grayson and published by Manning, is the very best resource for Tkinter programming there is - and if you use another toolkit, then it's still full of insight, useful advice and inspiration. -- Boudewijn Rempt | http://www.valdyas.org From jerome.quelin at insalien.org Sat Jul 1 09:48:12 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Sat, 1 Jul 2000 09:48:12 +0200 Subject: Are tk derived objects ever destroyed? References: <962360149.1278823422@news.libertysurf.fr> <5b875.1088$Tb2.20649@news6-win.server.ntlworld.com> Message-ID: <962437692.935044161@news.libertysurf.fr> "richard_chamberlain" wrote: >Unless you explicitly call destroy against your class it doesn't seem to >call ___del__. You can get round it in the following manner: >#!/usr/bin/python >from Tkinter import * >class Frm(Toplevel): > def __init__(self): > Toplevel.__init__(self) > Label(self, text='spam').pack() > self.bind('',self.kill) > def kill(self,event): > self.destroy() > def __del__(self): > print 'Kai kai kai' >Button(text='create', command=Frm).pack() >mainloop() Well, when I look at this code, I feel like python will start an infinite loop. But, ok I'll try this. Can you explain why this work this way, and why should we trap the destroy event? Regards, Jerome -- jerome.quelin at insalien.org From jerome.quelin at insalien.org Sat Jul 1 09:51:14 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Sat, 1 Jul 2000 09:51:14 +0200 Subject: Passing variable-length keyworded arguments list to base class constructor? References: <962352947.103057778@news.libertysurf.fr> <8F635367Cgmcmhypernetcom@199.171.54.154> <962379073.1230449645@news.libertysurf.fr> <8F63C1ABDgmcmhypernetcom@199.171.54.154> Message-ID: <962437874.1408268869@news.libertysurf.fr> gmcm at hypernet.com (Gordon McMillan) wrote: >>That is exactly what I want to know: what this mucking consists of? >Depends on what args the base class expects. If the base class expects >**kwargs, then you can have anything in there. >But maybe you've been playing with the interpreter, and have discovered all >this by now... Yep, this works fine by now. Thanks all for your replies. Regards, Jerome -- jerome.quelin at insalien.org From holger at fuessler-net.de Sat Jul 1 09:24:32 2000 From: holger at fuessler-net.de (holger at fuessler-net.de) Date: Sat, 1 Jul 2000 09:24:32 +0200 Subject: MD5 - Passwords with python References: Message-ID: > http://www.sabren.com/code/python/crypt/ That's it! Thanks a lot! Greetings Holger From dougfort at downright.com Sat Jul 1 13:06:35 2000 From: dougfort at downright.com (Doug Fort) Date: Sat, 1 Jul 2000 07:06:35 -0400 Subject: Missing OmPyUnit module in OmPyUnit Message-ID: <0hk75.10271$HD6.284269@iad-read.news.verio.net> We've been using Steve Purcell's PyUnit from SourceForge. It's limited, but reliable. I'm attempting to investigate OmPyUnit as an alternative. It seems to offer more functionality, plus I have great respect for ObjectMentor ands Robert Martin. However, the package I downloaded seems to be missing a module: OmPyUnit. What's up with this? It doesn't fill me with confidence. -- Doug Fort Meat Manager Downright Software http://www.dougfort.com/~dougfort From moshez at math.huji.ac.il Sat Jul 1 13:12:07 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 1 Jul 2000 14:12:07 +0300 (IDT) Subject: Example how to use cgihttpserver In-Reply-To: <395CBBCA.9A241134@decrc.abb.de> Message-ID: On Fri, 30 Jun 2000, Peter Mueller wrote: > Hi, > > is there an example how to use the cgihttpserver in a way that some cgi > scripts are in /cgi-bin/* (this is simple) and others are coded in the > program itself. A simple example reading the FieldStorage, generating a > page ... would me help very much. The trick is to use (for the hard-coded "cgi" scripts) the cgi module with non-default parameters: instead of os.environ, use a special dictionary, and instead of sys.stdin, use self.rfile. You'll have to hack something up, and I'm not aware of any ready made examples, but this should give you enough to go on. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From moshez at math.huji.ac.il Sat Jul 1 13:13:03 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 1 Jul 2000 14:13:03 +0300 (IDT) Subject: Passing variable-length keyworded arguments list to base class constructor? In-Reply-To: <962379165.85859735@news.libertysurf.fr> Message-ID: On Fri, 30 Jun 2000, Jerome Quelin wrote: > "Beat Bolli" wrote: > >Starting with Python 1.6a[12], you can call Parent.__init__(self, **args). > And with python 1.5.2? Use the apply() built-in function. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From moshez at math.huji.ac.il Sat Jul 1 14:49:31 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 1 Jul 2000 15:49:31 +0300 (IDT) Subject: Transcendentals and Encryption (was Re: Nth digit of PI) In-Reply-To: Message-ID: On 29 Jun 2000, Harald Hanche-Olsen wrote: > + Fran?ois Pinard : > > | There is an aleph1 number of real numbers > > That is a statement of the continuum hypothesis, which is known to be > independent of ZFC (the Zermelo-Fraenkel set theory including the > axiom of choice, on which we tend to imagine all of modern mathematics > is based). Ummmm....a lot of modern mathematics based on ZFC + existence of "large" cardinals. These can be trivially shown to be strictly stronger then ZFC via Goedel's theorem, and the fact that under a large cardinal, life seems to be like ZFC. matrijn-is-this-progessing-in-the-direction-you-forsee-ly y'rs, Z. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From nrlpje at q35dcvw23.net Sat Jul 1 14:43:27 2000 From: nrlpje at q35dcvw23.net (nrlpje at q35dcvw23.net) Date: 1 Jul 2000 12:43:27 GMT Subject: herbal VIAGRA........without side effect Message-ID: <8jkp1f$i5t@elod.vein.hu> nmitrrzwuykhdnlkmpvhrpdvdgqencggcksttbchxukqbyopywutbitowiowycknzlddbcikbtjkxszgkoyykgbrshexsjujmcwqewpokiqjlvopycrsljwlwqtbl begin 644 d:\Advertisement\cyberking\mdpharmacy.html M/"%D;V-T>7!E(&AT;6P@<'5B;&EC("(M+R]W,V,O+V1T9"!H=&UL(#0N,"!T M <20000630232210.A1287@novara.avenue> Message-ID: David Porter writes: > * Michael Hudson : > > Curtis Jensen writes: > > > > > Does anyone know of a Python MP3 Player? > > > > I've cobbled together some Python that you can use to control xmms if > > that's what you want. Anyone interested? I can stick it on my > > starship page if anyone is... > > I am! I was just thinking about doing something like this. Righty ho; find it here: http://starship.python.net/crew/mwh/hacks/ no docs, no guarantees, no restrictions. Comments appreciated. Cheers, M. -- The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence. -- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5 From MarkH at ActiveState.com Sat Jul 1 15:35:32 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 01 Jul 2000 13:35:32 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: Just to stoke the flames a little... Check out some of the talks at the upcoming PDC - http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python :-) Mark. -- markh at activestate.com - but if you think I speak for them, you dont know Dick! From moshez at math.huji.ac.il Sat Jul 1 15:42:04 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 1 Jul 2000 16:42:04 +0300 (IDT) Subject: Communicating between two computers In-Reply-To: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: On Fri, 30 Jun 2000, donotspam-jen at personic.com wrote: > FYI, I'm doing all of this on Windows NT, in case that makes a difference > ... > > Is there a good way to get a script on one computer to talk to a script on > another computer? The process I'm thinking of is pretty simple ... I want a > script on a Web server to be able to send a command to a build server to > start a build process. I'd also like the Web server to be able to query the > build servers to find out their status (so that two builds do not run at > once on the same machine, for example). Have a look at my signature: like most everything I say, it is only half a joke. Python on two computers talking in plain old HTTP is a powerful concept. Just derive from BaseHTTPServer on one end, and implement only the do_GET() method, and use urllib at the other end to transmit requests. Both our inhouse build and backup systems are built (more or less) on these principals. I have no idea if you can run a Python script as an NT service: I'll leave that to those who know windows. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From lale at fotonation.com Sat Jul 1 15:58:02 2000 From: lale at fotonation.com (Ilariu Raducan) Date: Sat, 1 Jul 2000 14:58:02 +0100 Subject: Uploading binary files References: Message-ID: <8jktda$r10$1@kermit.esat.net> Can we see the HTML code for the form? "Chris Biegay" wrote in message news:Z9475.7$qm5.709 at ord-read.news.verio.net... > I'm trying to upload files through an HTML form, but it only works > for text files. When I try to send a jpeg or something the process just > hangs, and I can't even change the script afterward since the webserver > won't release the file! Any ideas? This is basically how I'm doing it now: > > form = cgi.FieldStorage() > formItem = form[inputName] > > if formItem.file: > print "Received file [" + formItem.filename + "]" > data = formItem.file.read() > ... > > From plusk at radford.edu Sat Jul 1 16:19:27 2000 From: plusk at radford.edu (Paul D. Lusk) Date: 1 Jul 2000 14:19:27 GMT Subject: ? WinNT sys.stdout and re-direction Message-ID: <8F6466ABEpluskrunetedu@137.45.128.146> I'm new to Python and I'm trying to run some scripts. System is WinNT, output via sys.stdout.write(). Redirecting output to file results in any empty file, for example: At the NT command prompt: script.py in.txt writes output to the screen, but script.py in.txt>out.txt gives me a empty out.txt Could somebody point me in the right direction to fix this? From dgoodger at bigfoot.com Sat Jul 1 17:34:30 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sat, 01 Jul 2000 11:34:30 -0400 Subject: Missing OmPyUnit module in OmPyUnit In-Reply-To: <0hk75.10271$HD6.284269@iad-read.news.verio.net> References: <0hk75.10271$HD6.284269@iad-read.news.verio.net> Message-ID: on 2000-07-01 07:06, Doug Fort (dougfort at downright.com) wrote: > However, the package I downloaded seems to be missing a module: OmPyUnit. > What's up with this? It doesn't fill me with confidence. OmPyUnit seems like it's meant to be a Python package, but it lacks an __init__.py file. This causes package imports to fail in my interpreter (1.5.2 on MacOS). According to Guido's essay "Built-in Package Support in Python 1.5" at http://www.python.org/doc/essays/packages.html , "package support *requires* that an __init__ module is present". Looks like an oversight. Simply creating an empty __init__.py file (module) in the OmPyUnit directory, and making sure that the OmPyUnit directory is on Python's import path, makes explicit imports work. ("from OmPyUnit import *" won't work unless you define __all__ in __init__.py, though. But we don't use the "from ... import *" form, do we?) -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From robinjim at earthlink.net Sat Jul 1 17:43:15 2000 From: robinjim at earthlink.net (robin and jim) Date: Sat, 01 Jul 2000 15:43:15 GMT Subject: Missing OmPyUnit module in OmPyUnit References: <0hk75.10271$HD6.284269@iad-read.news.verio.net> Message-ID: Hello Doug, To get OmPyUnit to work on my system, I had to do the following: - add a file called __init__.py to the OmPyUnit folder (directory) From the Packages section of the Python (1.5) tutorial ... " The "__init__.py" files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as "string", from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, "__init__.py" can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later. " - download and install a package called Pmw and add it to my Python path This package apparently provides higher-level widgets for Tk. OmPyUnit imports Pmw. I have also noted, that at least on my Win 98 system, I can't edit the test suite file (not the module being tested) while the testing framework is running because it has a lock on the test file. I learned all of the above by solving each problem, as it was encountered, while trying to use OmPyUnit. Doug Fort wrote in message news:0hk75.10271$HD6.284269 at iad-read.news.verio.net... > We've been using Steve Purcell's PyUnit from SourceForge. It's limited, but > reliable. I'm attempting to investigate OmPyUnit as an alternative. It > seems to offer more functionality, plus I have great respect for > ObjectMentor ands Robert Martin. > > However, the package I downloaded seems to be missing a module: OmPyUnit. > What's up with this? It doesn't fill me with confidence. > > -- > Doug Fort > Meat Manager > Downright Software > http://www.dougfort.com/~dougfort > > > > From amused at webamused.com Sat Jul 1 17:51:48 2000 From: amused at webamused.com (Joshua Macy) Date: Sat, 01 Jul 2000 15:51:48 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> Message-ID: <395E05CD.E38F642C@webamused.com> "Thaddeus L. Olczyk" wrote: > > On 28 Jun 2000 06:02:09 GMT, thomas at xs4all.nl (Thomas Wouters) wrote: > > >On Wed, 28 Jun 2000 04:05:21 GMT, Courageous wrote: > > > >>> On top of that, very likely that if SUN sues they win. > > > >>Ridiculous. > > > >Very much so. But it wouldn't be suprising just the same, given the American > >patenting/registration practices and the average american courthouse ;-) > > > >Overseas-ly y'rs, > > Thomas > Virtually all SUN has to do is pull some of the demo programs out of > Microsofts manual. Write the equivalent code in python, perl, C++, > pascal, and a few other languages. Compare them side by side. A fairly > sophisticated person can see that it's resemblance to Java. Look at > the law judges are sophisticated enough. Given that Microshit is being > sued by SUN for their abuse of Java, I don't think it will be hard at > all for SUN to convince a judge that all C# is, is a variant of Java > with tons of proprietary crap glued on and the label changed. You seem to be under the misapprehension that under American law, Sun owns the very concept of the Java language--that's just not true. Microsoft could make their own version of Java if they wanted...that's perfectly legal; IBM is contemplating doing just that. What Microsoft did wrong was they used Sun's own code, which came with a license that forbade making incompatible extensions, to make an implementation with incompatible extensions. If they had gone to the effort of making a clean version of the code, they would have been in the clear. The only problem they would have faced is that they might not have been able to use the Java trademark, which--guess what--C# doesn't do. Joshua From aruth at intercation.com Sat Jul 1 18:56:16 2000 From: aruth at intercation.com (Adam Ruth) Date: Sat, 1 Jul 2000 10:56:16 -0600 Subject: Communicating between two computers References: Message-ID: <8jl7uu$ve3$1@news.aros.net> You can run Python as an NT service quite simply using the brilliant PyWin extensions. There's an exe called pythonservice.exe that handles all of the nasty details. Running a service has never been simpler. You can easily implement BaseHTTPServer within a service. -- Adam Ruth InterCation, Inc. www.intercation.com "Moshe Zadka" wrote in message news:Pine.GSO.4.10.10007011639300.17559-100000 at sundial... > On Fri, 30 Jun 2000, donotspam-jen at personic.com wrote: > > > FYI, I'm doing all of this on Windows NT, in case that makes a difference > > ... > > > > Is there a good way to get a script on one computer to talk to a script on > > another computer? The process I'm thinking of is pretty simple ... I want a > > script on a Web server to be able to send a command to a build server to > > start a build process. I'd also like the Web server to be able to query the > > build servers to find out their status (so that two builds do not run at > > once on the same machine, for example). > > Have a look at my signature: like most everything I say, it is only half > a joke. Python on two computers talking in plain old HTTP is a powerful > concept. Just derive from BaseHTTPServer on one end, and implement only > the do_GET() method, and use urllib at the other end to transmit requests. > > Both our inhouse build and backup systems are built (more or less) on > these principals. > > I have no idea if you can run a Python script as an NT service: I'll leave > that to those who know windows. > -- > Moshe Zadka > There is no GOD but Python, and HTTP is its prophet. > > From bvdpoel at uniserve.com Sat Jul 1 19:02:29 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Sat, 01 Jul 2000 10:02:29 -0700 Subject: Class vrs. function Message-ID: <395E2425.8F6F8757@uniserve.com> I see sample code for python/tkinter which looks like this: class main: def __init__(self): ...do a bunch of init stuff a=main() root.mainloop() What I'm wonder is why the use of a class for this. Wouldn't it be just as clear and perhaps more efficient to do ...do init stuff root.mainloop() Is this just a good habit being developed by those who think that classes are better than functions, or god forbid, inline code? While I'd asking, are there any penalties in the speed/memory usage departments on using classes vrs. functions? In case this isn't obvious I'm an old programmer who figured that C was a really nice, almost-cross-platform assembly language.... -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From ktwyzq at money=$$$.com Sat Jul 1 19:22:15 2000 From: ktwyzq at money=$$$.com (ktwyzq at money=$$$.com) Date: 1 Jul 2000 17:22:15 GMT Subject: Online = $$$ ; Offline = $$$ too !! Message-ID: <8jl9c7$jgl@elod.vein.hu> pfsedwkhqymliwdmpbvcmjhtrmdugzgulwghwhdnrqgucunrmswtgyxkdzycxhephvbuqzznsnqozppgrteznfxfkgxjvfmpsezbmqmblppyfuswudncmpswfguydhnomwbhqsxvlzy begin 644 d:\Advertisement\cyberking\1st name.html M/"%D;V-T>7!E(&AT;6P@<'5B;&EC("(M+R]W,V,O+V1T9"!H=&UL(#0N,"!T M Message-ID: <395e2ca2.4792092@news.btx.dtag.de> A simple out-of-the box solution if win32all is installed on both machines: The PythonWin package by default registers a Python.Interpreter COM server, which you can start up via DCOM on any remote machine. Once started, you can execute any Python commands as strings. /s From paul at prescod.net Sat Jul 1 21:12:01 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 01 Jul 2000 14:12:01 -0500 Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> Message-ID: <395E4281.452C26DE@prescod.net> Bob van der Poel wrote: > > ... > > Is this just a good habit being developed by those who think that > classes are better than functions, or god forbid, inline code? Given what you've said, that one-function class looks pretty bizarre. Is there maybe something else useful about it that you haven't noticed? Classes are not better than functions. They are just different. In most cases, you use classes when you need to combine data and instructions. -- Paul Prescod - Not encumbered by corporate consensus The calculus and the rich body of mathematical analysis to which it gave rise made modern science possible, but it was the algorithm that made the modern world possible. - The Advent of the Algorithm (pending), by David Berlinski From gmcm at hypernet.com Sat Jul 1 21:27:21 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 01 Jul 2000 19:27:21 GMT Subject: ? WinNT sys.stdout and re-direction References: <8F6466ABEpluskrunetedu@137.45.128.146> Message-ID: <8F649A89Cgmcmhypernetcom@199.171.54.154> Paul D. Lusk wrote: >At the NT command prompt: > >script.py in.txt>out.txt > >gives me a empty out.txt > >Could somebody point me in the right direction to fix this? Your choices: 1) Upgrade to Win2k (hee hee) 2) say "python script.py in.txt >out.txt" - Gordon From gmcm at hypernet.com Sat Jul 1 21:48:02 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 1 Jul 2000 15:48:02 -0400 Subject: Event Binding and Variable Passing Message-ID: <1249641616-55775887@hypernet.com> [posted & mailed] Cameron subtly baited: In article <39567A5A.5B692C5D at pacbell.net>, Bruce Wolk <{HYPERLINK "http://www.deja.com/[ST_rn=ps]/profile.xp?author=bawolk at ucdavis.edu&ST=PS"}bawolk at ucdavis.edu> wrote: >You need to use a lamda expression. > >def fun(x): > print x >b.bind('', lambda event, b=x: fun(b)) . . . Can one of the old(er?)-timers help me with this? There's a sect (claiming the Guido among its sym- pathizers) that deprecates lambdas for Python, no? But their reasons (very abstractly, that object- oriented metaprogramming gives more than enough goodies, making lambdas essentially redundant) do *not* apply for communication with the event- and binding-mechanisms adapted from Tcl, true? The conclusion would be, then, that Tkinter forces a fundamental need for lambdas. Well, my version of IDLE contains all of 9 lambdas, only 3 of which are used with Tkinter. So obviously Guido is no big fan of lambda, but neither does he abstain from its use. However, the fact that that much Tkinter code uses only 3 lambdas belies your assertion. Of course there are a multiplicity of sects within Python, sharing little more than a common shortage of virgins... - Gordon From robin at jessikat.demon.co.uk Sat Jul 1 22:10:32 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sat, 1 Jul 2000 21:10:32 +0100 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: <4YiFVWA4AlX5EwzQ@jessikat.demon.co.uk> In article , Mark Hammond writes >Just to stoke the flames a little... > >Check out some of the talks at the upcoming PDC - >http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python >:-) > >Mark. >-- >markh at activestate.com - but if you think I speak for them, you dont know >Dick! > > well with netscrape I can't seem to access that. -- Robin Becker From dale at out-think.NOSPAMco.uk Sat Jul 1 23:07:33 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Sat, 1 Jul 2000 22:07:33 +0100 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: <8jlmj0$r1q$1@supernews.com> Start simple. Unless this is particularly time critical, I'd create a folder on the Build server and share it with suitably limited access. Give the Web server write access to the folder. The Web server writes a batch file or Python script to the shared directory. Every few minutes the Build server checks this folder for a file and executes it. If you need some feedback, it could change the name of the file or move it to a subdirectory while it's running so the Web server can see it's active. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants donotspam-jen at personic.com wrote in message news:395d48b3$0$21842 at wodc7nh0.news.uu.net... > FYI, I'm doing all of this on Windows NT, in case that makes a difference > ... > > Is there a good way to get a script on one computer to talk to a script on > another computer? The process I'm thinking of is pretty simple ... I want a > script on a Web server to be able to send a command to a build server to > start a build process. I'd also like the Web server to be able to query the > build servers to find out their status (so that two builds do not run at > once on the same machine, for example). > > I've read a little about SOAP, but I think that my needs are probably a lot > simpler than that. The easiest way to accomplish this is to setup a Web > server on each of the build machines, too, I guess ... but I was hoping that > I could just have the scripts that run on the build servers run as NT > services. > > Thanks! > > Jen > > > > From ssthapa at midway.uchicago.edu Sat Jul 1 23:17:45 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Sat, 01 Jul 2000 21:17:45 GMT Subject: MD5 - Passwords with python References: <6e7dj8.bvb.ln@iiab.soluma.de> <8jd74i$16vk@newton.cc.rl.ac.uk> <2vegj8.ia5.ln@odin.hmf.de> Message-ID: holger at fuessler-net.de wrote: >Hallo! > >Now I've got it. It's f for followup and not r for reply mail (in TIN). I >was wondering if somebody kills my followups ;-) > >Unfortunately, the standard MD5-module doesn't know about the structure of >the password-string so I can't encode a password with it. I found a perl >module which accomplishs my task and so I thought that there is also a python >module. I thought redhat uses a lot of python stuff, so there should be a >routine to generate suitable passwords. I'v already posted in >comp.redhat.security. When I find the details, I'll post them here (if I can >translate them to python). I vaguely remember the format of the passwd string from having to modify crack to use it. Basically the beginning of the string has a salt enclosed between $'s. This is either appended or prepended to the password and a md5sum is taken. I believe this is right but YMMV. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From ssthapa at midway.uchicago.edu Sat Jul 1 23:17:47 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Sat, 01 Jul 2000 21:17:47 GMT Subject: writing in gif format References: <8jgamf$rli$1@nnrp1.deja.com> Message-ID: Keith Murphy wrote: >does anyone know how to write in gif format. I am using the PhotoImage >class, not the Python Imaging Library. Python tells me "TclError: image >file format "gif" has no file writing capability" I believe that there are some patent issues involved in this. Unisys holds the patents for using LZW compression in gif files so you would need to pay Unisys royalties for makng apps that write gif files. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From dale at out-think.NOSPAMco.uk Sat Jul 1 23:25:25 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Sat, 1 Jul 2000 22:25:25 +0100 Subject: Threads? Message-ID: <8jlnkh$7h$1@supernews.com> Win32: Can Python execute a function from the same module in another process? I might do this, for example, to take advantage of multiple processors. Thanks -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants From darrell at dorb.com Sun Jul 2 02:59:56 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sat, 1 Jul 2000 17:59:56 -0700 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: <033401bfe3c0$d7158140$6401a8c0@home> From: "Mark Hammond" > Just to stoke the flames a little... > > Check out some of the talks at the upcoming PDC - > http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python Ok my flames are stoked. What do they mean "Visual Python"??? Could this be a good thing? --Darrell From darrell at dorb.com Sun Jul 2 03:05:15 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sat, 1 Jul 2000 18:05:15 -0700 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: <033e01bfe3c1$959868d0$6401a8c0@home> From: "Mark Hammond" > Just to stoke the flames a little... > > Check out some of the talks at the upcoming PDC - > http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python Hey! Is this something you've been working on? So all these vendors are on board with integration into this new framework? I want to know the rest of the story now. --Darrell Gallion From neilh at scintilla.org Sun Jul 2 00:44:54 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sat, 01 Jul 2000 22:44:54 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <033e01bfe3c1$959868d0$6401a8c0@home> Message-ID: > > Just to stoke the flames a little... > > > > Check out some of the talks at the upcoming PDC - > > http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python > > Hey! Is this something you've been working on? > So all these vendors are on board with integration into this new framework? > I want to know the rest of the story now. Mmm, Python has to share a session with Perl but both APL and Cobol get their own. At least we're not right down the back with Haskell, Mercury, Oberon and ML. ;) And there doesn't appear to be a Java binding - what an oversight! Neil From olivierS.dagenaisP at canadaA.comM Sun Jul 2 00:52:38 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 01 Jul 2000 22:52:38 GMT Subject: writing in gif format References: <8jgamf$rli$1@nnrp1.deja.com> Message-ID: I do believe this is why the PNG file format was invented. It supports true color and alpha, too, as opposed to the 256-color GIF... http://www.libpng.org I'm new to Python, so I don't know, yet, if there are Python bindings for it.... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Suchandra Thapa" wrote in message news:slrn8lpr8j.47q.ssthapa at ntcs-ip48.uchicago.edu... > Keith Murphy wrote: > >does anyone know how to write in gif format. I am using the PhotoImage > >class, not the Python Imaging Library. Python tells me "TclError: image > >file format "gif" has no file writing capability" > > I believe that there are some patent issues involved in this. > Unisys holds the patents for using LZW compression in gif files so > you would need to pay Unisys royalties for makng apps that write gif > files. > > > -- > ------------------------------------------------------------------ > > Suchandra S. Thapa > s-thapa at uchicago.edu > > ------------------------------------------------------------------ From aahz at netcom.com Sun Jul 2 01:37:01 2000 From: aahz at netcom.com (Aahz Maruch) Date: 1 Jul 2000 23:37:01 GMT Subject: Threads? References: <8jlnkh$7h$1@supernews.com> Message-ID: <8jlvat$ohi$1@nntp9.atl.mindspring.net> In article <8jlnkh$7h$1 at supernews.com>, Dale Strickland-Clark wrote: > >Can Python execute a function from the same module in another process? >I might do this, for example, to take advantage of multiple processors. I'm a bit confused here. The Subject says "Threads?" but your text says "process". Which is it? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From jhylton at my-deja.com Sun Jul 2 01:39:52 2000 From: jhylton at my-deja.com (jhylton at my-deja.com) Date: Sat, 01 Jul 2000 23:39:52 GMT Subject: MD5 - Passwords with python References: <6e7dj8.bvb.ln@iiab.soluma.de> Message-ID: <8jlvg7$pdt$1@nnrp1.deja.com> > Is there a library function to encode passwords crypt-style, but with md5 as > hashing-algorithm for python? > Do you know where I can find documentation about the format? > You can use the PKCS #5 implementation in Pisces. http://www.cnri.reston.va.us/software/pisces/ The PKCS #5 implementation can generate passwords with an arbitrary hash function. SHA and MD5 are currently supported. Jeremy Sent via Deja.com http://www.deja.com/ Before you buy. From johnm at cs.uit.no Sun Jul 2 02:02:08 2000 From: johnm at cs.uit.no (John Markus Bjorndalen) Date: 02 Jul 2000 02:02:08 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <4YiFVWA4AlX5EwzQ@jessikat.demon.co.uk> Message-ID: Robin Becker writes: > well with netscrape I can't seem to access that. Turn off Javascript (and possibly Java as well). That might help. -- // John Markus Bj?rndalen From cjensen at bioeng.ucsd.edu Sun Jul 2 02:11:59 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Sat, 01 Jul 2000 17:11:59 -0700 Subject: Python MP3 Player References: <395CE50A.3BA16777@bioeng.ucsd.edu> <20000630232210.A1287@novara.avenue> Message-ID: <395E88CF.47236484@bioeng.ucsd.edu> Michael Hudson wrote: > > > Righty ho; find it here: > > http://starship.python.net/crew/mwh/hacks/ > > no docs, no guarantees, no restrictions. Comments appreciated. > > Cheers, > M. > > -- > The use of COBOL cripples the mind; its teaching should, therefore, > be regarded as a criminal offence. > -- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5 Thanks very much. Though, I was asking, because xmms isn't vary stable on our systems (SGI IRIX 6.5). I figured that if there was a Python MP3 Player, then it'd probably work on our systems. Your module is interesting, though it doesn't fix my problem. :( -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From paul at prescod.net Sun Jul 2 02:17:56 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 01 Jul 2000 19:17:56 -0500 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <033401bfe3c0$d7158140$6401a8c0@home> Message-ID: <395E8A34.FE17D610@prescod.net> Darrell Gallion wrote: > > From: "Mark Hammond" > > Just to stoke the flames a little... > > > > Check out some of the talks at the upcoming PDC - > > http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python > > Ok my flames are stoked. > What do they mean "Visual Python"??? > Could this be a good thing? http://www.activestate.com/Products/VisualPython.html -- Paul Prescod - Not encumbered by corporate consensus The calculus and the rich body of mathematical analysis to which it gave rise made modern science possible, but it was the algorithm that made the modern world possible. - The Advent of the Algorithm (pending), by David Berlinski From darrell at dorb.com Sun Jul 2 07:15:21 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sat, 1 Jul 2000 22:15:21 -0700 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <033401bfe3c0$d7158140$6401a8c0@home> <395E8A34.FE17D610@prescod.net> Message-ID: <037101bfe3e4$8558c820$6401a8c0@home> From: "Paul Prescod" > > http://www.activestate.com/Products/VisualPython.html > Thanks for pointing this out. I see it comes up on google also. This should make the job of Python evangelizer that much simpler. Some people will feel that VC support puts Python on main street. --Darrell Gallion From bvdpoel at uniserve.com Sun Jul 2 04:56:34 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Sat, 01 Jul 2000 19:56:34 -0700 Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> <395E4281.452C26DE@prescod.net> Message-ID: <395EAF62.4A628573@uniserve.com> Paul Prescod wrote: > > Bob van der Poel wrote: > > > > ... > > > > Is this just a good habit being developed by those who think that > > classes are better than functions, or god forbid, inline code? > > Given what you've said, that one-function class looks pretty bizarre. Is > there maybe something else useful about it that you haven't noticed? > Classes are not better than functions. They are just different. In most > cases, you use classes when you need to combine data and instructions. Yes, that I understand. In some of the example code I've seen there is only the __init__ function and no data. That's why it doesn't make sense to me. Maybe I'm just having a bad day..... -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From plusk at runet.edu Sun Jul 2 04:52:40 2000 From: plusk at runet.edu (Paul D. Lusk) Date: 2 Jul 2000 02:52:40 GMT Subject: ? WinNT sys.stdout and re-direction References: <8F6466ABEpluskrunetedu@137.45.128.146> <8F649A89Cgmcmhypernetcom@199.171.54.154> Message-ID: <8F64E8ADDpluskrunetedu@137.45.128.146> gmcm at hypernet.com (Gordon McMillan) wrote in <8F649A89Cgmcmhypernetcom at 199.171.54.154>: >Paul D. Lusk wrote: > >>At the NT command prompt: >> >>script.py in.txt>out.txt >> >>gives me a empty out.txt >> >>Could somebody point me in the right direction to fix this? > >Your choices: > 1) Upgrade to Win2k (hee hee) This does strike me as overkill. > 2) say "python script.py in.txt >out.txt" > Can do. Thanks! Paul From stephen_purcell at yahoo.com Sun Jul 2 05:06:10 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sun, 2 Jul 2000 13:06:10 +1000 Subject: [ANNOUNCE] PyUnit 1.2.0 test framework with GUI Message-ID: <20000702130610.A31857@inkontact.com.au> The latest release of the PyUnit unit testing framework features a long overdue Tkinter based GUI akin to that of Java's JUnit. Should work straight out-of-the-box with most Python installations. Modules being tested are automatically reloaded each time they are run, so the GUI can be left running while you code and debug. As usual, interested parties can find out more at http://pyunit.sourceforge.net/ Go on, write some tests; you know you want to! Pythonic best wishes to all, -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ From darrell at dorb.com Sun Jul 2 08:15:30 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sat, 1 Jul 2000 23:15:30 -0700 Subject: urllib and linksys router Message-ID: <038701bfe3ec$ece104a0$6401a8c0@home> Tried to use urllib to access my linksys router, which requires a password. After much pain, it turns out the router needs to see the request as one string. Maybe it's a timing thing since urllib sends each line separately. This works. def direct(): s = socket(AF_INET, SOCK_STREAM) s.connect("192.168.1.1",80) msgs=[ 'GET /Status.htm HTTP/1.0\015\012', 'Authorization: Basic xxxxxxxx==\015\012', '\015\012', ] s.send(string.join(msgs,'')) print s.recv(1024) print s.recv(1024) --Darrell Gallion From fiona at sitegnome.com Sun Jul 2 05:19:26 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 2 Jul 2000 03:19:26 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 1st, 2000 Message-ID: <20000702031926.7937.qmail@synop.com> Greetings All! Below are the latest entries to be entered into http://python.faqts.com regards, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- What is bbox? In the context of the PhotoImage put(data, bbox). http://www.faqts.com/knowledge-base/view.phtml/aid/4133 ------------------------------------------------------------- Fiona Czuczman Keith Murphy The bounding box is returned as a 4-tuple defining the left, upper, right, and lower pixel coordinate. Here's what I was doing.. self.photo.put(tuple(["#000000"],), tuple([5,5,6,6])) it draws a single black pixel at (5,5) ------------------------------------------------------------- How do you print the traceback string from an exception? http://www.faqts.com/knowledge-base/view.phtml/aid/4134 ------------------------------------------------------------- Fiona Czuczman J?rgen Hermann try: whatever() except: import traceback, string msg = string.join(traceback.format_exception( sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]), "") print msg ------------------------------------------------------------- How can I concatenate external files (all the little *.htm files in a directory) into one big file? http://www.faqts.com/knowledge-base/view.phtml/aid/4135 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain import sys, string, glob, os #First I create a list: fls = glob.glob('C:\\wxpython\\wxPython-2.1.16\\docs\\wx\\wx*.htm') #Then I guess I should open an output file for writing outfile = open('temp.txt,'w') for x in fls: file=open(x,'r') data=file.read() file.close() outfile.write(data) outfile.close() We then iterate over fls to give us each file name and open each one. We then call the read method against it, which loads in the entire file and assign that to data. we close the file and write the data to our outfile. And then on to the next file. Finally we close the outfile. You have to use read() with some caution because it (trys) to load the whole file into memory which maybe an issue if it was sizable. In your case it isn't an issue because they are simple html files. ------------------------------------------------------------- What is lambda? http://www.faqts.com/knowledge-base/view.phtml/aid/4136 ------------------------------------------------------------- Fiona Czuczman Warren Postma, david_ullrich 1) Meta-Answer: Read the FAQ and Manual sections. 2) Instant Gratification Answer Here's a standard function definition: def func(x): return x *2 Here's a way to write the same thing, in effect, but using Lambda: func = lambda (x): x * 2 While that example isn't useful, it gives you the idea. Think of lambda as a way to generate a function and return that function as an object, without having to give it a name. I primarily use it to pass an algorithm or expression as a parameter to a function, or other places where I want to pass code in a variable instead of passing a reference to a method containing that code. ------------ What it does is allow you to construct "anonymous functions". Oops, not my own words. The syntax lambda x: [expression in x] is itself an expression - the _value_ of the expression "lambda x: [expression in x]" is a function which returns [expression in x] when passed x. For example "lambda x: x+x" is a function that returns x+x; saying f = lambda x: x+x has the same effect as saying def f(x): return x + x But you don't usually use it that way - people use lambda when they want to pass a function to some routine without having to make up a name for the function. For example map takes a function as a parameter; saying print map(lambda x: x+x, [1,2,3]) is the same as saying def f(x): return x + x print map(f, [1,2,3]]) You should note there's varying opinions on whether lambda is a good thing - if you're a beginner at programming as well as with Python it's not the first thing you should worry about. ## Edited Entries ############################################## ------------------------------------------------------------- How can I use the smtplib module to send email from Python? How can I send mail using the os module? How can I send mail through python? http://www.faqts.com/knowledge-base/view.phtml/aid/2607 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman, George Jansen http://www.python.org/doc/FAQ.html#4.71,Justin Sheehy On Unix, it's very simple, using sendmail. The location of the sendmail program varies between systems; sometimes it is /usr/lib/sendmail, sometime /usr/sbin/sendmail. The sendmail manual page will help you out. Here's some sample code: SENDMAIL = "/usr/sbin/sendmail" # sendmail location import os p = os.popen("%s -t" % SENDMAIL, "w") p.write("To: cary at ratatosk.org\n") p.write("Subject: test\n") p.write("\n") # blank line separating headers from body p.write("Some text\n") p.write("some more text\n") sts = p.close() if sts != 0: print "Sendmail exit status", sts Check out the os module doc for more info: http://www.python.org/doc/current/lib/module-os.html On non-Unix systems (and on Unix systems too, of course!), you can use SMTP to send mail to a nearby mail server. A library for SMTP (smtplib.py) is included in Python 1.5.1; in 1.5.2 it will be documented and extended. Here's a very simple interactive mail sender that uses it: import sys, smtplib fromaddr = raw_input("From: ") toaddrs = string.splitfields(raw_input("To: "), ',') print "Enter message, end with ^D:" msg = '' while 1: line = sys.stdin.readline() if not line: break msg = msg + line # The actual mail send server = smtplib.SMTP('localhost') server.sendmail(fromaddr, toaddrs, msg) server.quit() This method will work on any host that supports an SMTP listener; otherwise, you will have to ask the user for a host. http://www.python.org/doc/current/lib/module-smtplib.html On Windows 9x systems, you may also use the COM interface. We have recently used PythonWin to (what else?) spam a number of recipients over Novell GroupWise. It took very little time to work this out. From tim_one at email.msn.com Sun Jul 2 05:38:09 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 1 Jul 2000 23:38:09 -0400 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up In-Reply-To: <037101bfe3e4$8558c820$6401a8c0@home> Message-ID: [Paul Prescod, links to ...] > http://www.activestate.com/Products/VisualPython.html [Darrell Gallion] > Thanks for pointing this out. I see it comes up on google also. > > This should make the job of Python evangelizer that much simpler. > Some people will feel that VC support puts Python on main street. Well, that's just silly. What it *does* do is validate Microsoft as a serious competitor in the modern computer marketplace . languages-live-longer-than-platforms-ly y'rs - tim From dirck.IsGettingTooMuchSpam at pacbell.net Sun Jul 2 05:53:12 2000 From: dirck.IsGettingTooMuchSpam at pacbell.net (Dirck Blaskey) Date: Sat, 1 Jul 2000 20:53:12 -0700 Subject: ? WinNT sys.stdout and re-direction References: <8F6466ABEpluskrunetedu@137.45.128.146> Message-ID: Paul D. Lusk wrote in message news:8F6466ABEpluskrunetedu at 137.45.128.146... > ... > At the NT command prompt: > > script.py in.txt > > writes output to the screen, > > but > > script.py in.txt>out.txt > > gives me a empty out.txt If you'd like to retain the short-hand version (as opposed to the long-hand 'python script.py >out.txt') check out http://www.danbala.com/python/cmdfix d ______________________ Dirck Blaskey Danbala Software http://www.danbala.com ______________________ From jwbnews at scandaroon.com Sun Jul 2 05:52:33 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sat, 01 Jul 2000 20:52:33 -0700 Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> <395E4281.452C26DE@prescod.net> <395EAF62.4A628573@uniserve.com> Message-ID: In article <395EAF62.4A628573 at uniserve.com>, Bob van der Poel wrote: > Paul Prescod wrote: > > > > Bob van der Poel wrote: > > > > > > ... > > > > > > Is this just a good habit being developed by those who think that > > > classes are better than functions, or god forbid, inline code? > > > > Given what you've said, that one-function class looks pretty bizarre. Is > > there maybe something else useful about it that you haven't noticed? > > Classes are not better than functions. They are just different. In most > > cases, you use classes when you need to combine data and instructions. > > Yes, that I understand. In some of the example code I've seen there is > only the __init__ function and no data. That's why it doesn't make sense > to me. Maybe I'm just having a bad day..... Is there anything about those classes such that deriving from them would make sense? If not, it's probably just a style issue (someone coming from SmallTalk--to pick one example--where there isn't any code outside some class might well do that). Also, if the module is going to be imported, the code is handier if it isn't at the top level of the module: import time may well not be the right time for the code to be run. That wouldn't explain class vs function, though. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From invalid.address at 127.0.0.1 Sun Jul 2 06:29:54 2000 From: invalid.address at 127.0.0.1 (David) Date: Sun, 02 Jul 2000 04:29:54 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: <395fc536.9838883@news.telus.net> On Sat, 01 Jul 2000 05:10:50 GMT, Courageous wrote: >Java is is a variant of the C++ language with the kitchen >think glued on Heh. Pun, or typo? From neo_brave at my-deja.com Sun Jul 2 07:20:56 2000 From: neo_brave at my-deja.com (Neo Brave) Date: Sun, 02 Jul 2000 05:20:56 GMT Subject: Win32 : Making script.py executable in DOS box Message-ID: <8jmjfe$64o$1@nnrp1.deja.com> Hi all, I'm currently running Python scripts at the command line using C:\python\python script.py. Is there a way of making the MS-DOS box recognise the Python script as an executable file so I can just use the name "script.py"? Thanks in advance, Neo -- Neo Brave Sent via Deja.com http://www.deja.com/ Before you buy. From morten at src.no Sun Jul 2 08:01:50 2000 From: morten at src.no (Morten W. Petersen) Date: Sun, 2 Jul 2000 08:01:50 +0200 Subject: How to "fork off" a function Message-ID: How do I "get rid of" an annoyingly slow function, that's more of a logging facility, in the code? Do I use thread, etc? Short example would be appreciated. -Morten ------------------------------------------------------------- How to reply to email: http://home.sol.no/~vidaandr/news/OBSquoting.html (norsk) http://home.sol.no/~vidaandr/news/FAQquoting.html (english) Who is the bigger fool? The fool or the fool who follows him? From etoffi at softhome.net Sun Jul 2 09:33:12 2000 From: etoffi at softhome.net (etoffi) Date: Sun, 02 Jul 2000 03:33:12 -0400 Subject: mailman stuff Message-ID: <395EF038.D8CEBD92@softhome.net> visiting this page will print out the same thing 3 times. just thought someone would like to know http://www.python.org/mailman/subscribe/python-list/ From thomas at xs4all.nl Sun Jul 2 09:31:28 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 2 Jul 2000 07:31:28 GMT Subject: How to "fork off" a function References: Message-ID: On Sun, 2 Jul 2000 08:01:50 +0200, Morten W. Petersen wrote: >How do I "get rid of" an annoyingly slow function, that's more of a >logging facility, in the code? Do I use thread, etc? >Short example would be appreciated. Well, this ought to work: def long_function(*lots_of_args): # pass Or isn't that what you wanted ? :-) Seriously, this is the only way to get rid of a function without knowing that it's supposed to do. If the function is a logging function, try to shortcut your way out of the function for the cases where it isn't necessary. Or turn off logging. Or defer logging until later, by appending log messsages to a list and writing out the list later. You can use threads, yes, but it only makes sense if the logging function is slow because it waits for something else, not if it takes a lot of cpu time. I'd go for a seperate process and a syslogd-like daemon that listens for messages, though: easier to write and much more portable. lambda:0-ly y'rs, Thomas. From gherman at darwin.in-berlin.de Sun Jul 2 10:07:14 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Sun, 02 Jul 2000 10:07:14 +0200 Subject: reportlab: HTML->PDF via Python? References: <395CF8D0.6FD580B9@netscape.com> Message-ID: <395EF832.E6F5C9CE@darwin.in-berlin.de> Ian Oeschger wrote: > > Does reportlab or some other Python module offer a facility for printing > HTML pages to PDF? > And if so, does some rendering engine have to intercede in this process > somewhere? My experience so far has been getting text--rather than the > rendered HTML--into PDF. Well, not yet, at least from what I know about ReportLab. The question came up there very recently. The problem is more or less the implicit HTML layouting "behind the scenes", like text around images, frames, and so on. It seems, though, that a very simple HTML could be rendered rather easily into PDF. Regards, Dinu -- Dinu C. Gherman ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From esko.lehtonen at pp.htv.fi Sun Jul 2 11:34:30 2000 From: esko.lehtonen at pp.htv.fi (Esko Lehtonen) Date: Sun, 02 Jul 2000 12:34:30 +0300 Subject: PyGTK and draw_array Message-ID: <395F0CA6.A20736F@pp.htv.fi> I am trying to manipulate an image and then draw it to GtkDrawingArea using PyGtk and Numerical Python. Here is description of draw_array function from file gtk.py. (I don't know exactly what is that hassattr thing.) # this function renders an unsigned byte (type code 'b') numpy array to a # drawable. If it is a MxN or MxNx1 array, it is assumed to be a grey image. # If it is a MxNx3 or MxNx4 array, it is assumed to be an rgb image. # It should accept images that have been sliced along their first two axes, # if you want to only draw part of the image. if hasattr(_gtk, "gdk_draw_array"): def draw_array(drawable, gc, x, y, dither, array): _gtk.gdk_draw_array(drawable, gc, x, y, dither, array) So I made following code: WIDTH = 30 HEIGHT = 20 D = 3 # create rgb image as array, every value 100 img = ones((WIDTH, HEIGHT, D), 'b') img = img * 100 ---- darea = GtkDrawingArea() ---- draw_array(darea.get_window(), widget.get_style().black_gc, x, y, GDK.RGB_DITHER_NORMAL, img) I still have a problem, because then a got: "TypeError: array data must be unsigned bytes" when I'm trying to use the draw_array function. What is problem here? Or do you know alternative ways to do this using PyGTK or some other graphics library? Thanks in advance -------------------------------------------------------------------- Esko Lehtonen WYSINWYG - What You See Is Never What You Get From f98ba at efd.lth.se Sun Jul 2 11:48:10 2000 From: f98ba at efd.lth.se (f98ba at efd.lth.se) Date: 2 Jul 2000 09:48:10 GMT Subject: Traping output from os.system Message-ID: <8jn34q$kpn$1@news.lth.se> Hi, I'm executing a command with os.system and are trying to capture the output into a python variable. The only I can find to do it in at the moment is to redirrect the output to a file and the read it. That feels wrong, isn't there another simple way?? Thanks, Bjorn From sean at digitome.com Sun Jul 2 13:51:10 2000 From: sean at digitome.com (Sean Mc Grath) Date: Sun, 02 Jul 2000 11:51:10 GMT Subject: __getattr__ and pickle Message-ID: <395f26a4.1832855@news.iol.ie> I have a reproduceable GPF on NT when picking objects of a class that has a __getattr__ implementation. Take out the __getattr__ and the pickle works fine. Are there ways to implement __getattr__ and yet preserve the ability to pickle? regards, From sean at digitome.com Sun Jul 2 13:53:00 2000 From: sean at digitome.com (Sean Mc Grath) Date: Sun, 02 Jul 2000 11:53:00 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> Message-ID: <395f2748.1996610@news.iol.ie> The was a typo that could lead to confusion + a genuinely unforseen and unintentional pun in the original post. I have fixed the typo but left in the pun here: ------------------------- I have a reproduceable GPF on NT when pickking objects of a class that has a __getattr__ implementation. Take out the __getattr__ and the pickle works fine. Are there ways to implement __getattr__ and yet preserve the ability to pickle? regards, From sean at digitome.com Sun Jul 2 13:55:03 2000 From: sean at digitome.com (Sean Mc Grath) Date: Sun, 02 Jul 2000 11:55:03 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> Message-ID: <395f27ab.2095753@news.iol.ie> Sheesh! I really need a holiday! Yet another typo fixed. Sorry about this... I have a reproduceable GPF on NT when pickling objects of a class that has a __getattr__ implementation. Take out the __getattr__ and the pickle works fine. Are there ways to implement __getattr__ and yet preserve the ability to pickle? regards, From thomas_s at ebox.tninet.se Sun Jul 2 15:15:52 2000 From: thomas_s at ebox.tninet.se (thomas_s at ebox.tninet.se) Date: Sun, 02 Jul 2000 14:15:52 +0100 Subject: Tkinter and default options Message-ID: <8jnbhm$bb6$1@cubacola.tninet.se> Hello, I'm using Tkinter for the GUI parts of a little game I'm working on. What is the best way of setting default options of the widgets? For instance I want all widgets to have fg='green' and bg='black'. Is there a standard way of doing this? If not, I was thinking of maybe writing a widget factory that creates and configures them for me. Thank, Thomas From cut_me_out at hotmail.com Sun Jul 2 14:31:15 2000 From: cut_me_out at hotmail.com (Alex) Date: 02 Jul 2000 08:31:15 -0400 Subject: Problem with dynamically linked extensions that use Numeric Message-ID: Hi. I have been writing an extension that uses the Numeric API. Up until now, I have just been building it straight into python, and it's working fine. However, I want to make it more widely available, so I need to make shared objects from it. The problem with that is that it segfaults. Here is a small piece of code that demonstrates the problem I am having: /////////////////////////////////////////////////////////////////////////////// #include "Python.h" #include "arrayobject.h" PyObject *test_array_test (PyObject *self, PyObject *args) { PyObject *t; int dimensions[2], i; if (!PyArg_ParseTuple (args, "")) { return NULL; } dimensions[0] = 10; dimensions[1] = 12; for (i=0; i < 20; i++) { printf ("testing\n"); t = PyArray_FromDims (2, dimensions, PyArray_INT); } if (!t) { return NULL; } return t; } static PyMethodDef Test_ArrayMethods[] = { {"test", test_array_test, METH_VARARGS}, {NULL, NULL} }; void inittest_array () { (void) Py_InitModule ("test_array", Test_ArrayMethods); } /////////////////////////////////////////////////////////////////////////////// I compiled this using the 'make -f Makefile.pre.in boot' method. Here were the commands make generated: [alex_c at puffin blast]$ make test_arraymodule.so gcc -I/scratch2/alex/include/python2.0/Numeric -g -O2 \ -I/scratch2/alex/include/python2.0 \ -I/scratch2/alex/include/python2.0 -DHAVE_CONFIG_H \ -c ./test_arraymodule.c gcc -shared test_arraymodule.o -o test_arraymodule.so This code segfaults when it hits the line 't = PyArray_FromDims (2, dimensions, PyArray_INT);' But when it's compiled directly in to python (i.e., I move the file into the Modules directory of the python source, and add a corresponding entry in the Setup file,) it works fine. I'd be grateful for any ideas as to how to get this to work. Alex. From gmcm at hypernet.com Sun Jul 2 15:07:44 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 02 Jul 2000 13:07:44 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> Message-ID: <8F655BA3Egmcmhypernetcom@199.171.54.154> [posted and mailed] Sean Mc Grath wrote: >Sheesh! I really need a holiday! Probably ! >I have a reproduceable GPF on NT when pickling objects of a class >that has a __getattr__ implementation. Take out the __getattr__ and >the pickle works fine. > >Are there ways to implement __getattr__ and yet preserve the ability >to pickle? C'mon Sean! You've been around a while. You know when __getattr__ hacks go bad it's because they go recursive. (And the stack size on Windows is off by some tiny amount, so it GPFs instead of traps.) So what do we need: >>> class A: ... def __getattr__(self, nm): ... print "get", nm ... raise AttributeError, nm ... >>> a = A() >>> import pickle >>> s = pickle.dumps(a) get __getinitargs__ get __getstate__ >>> x = pickle.loads(s) get __setstate__ >>> import cPickle >>> s = cPickle.dumps(a) get __getinitargs__ get __getstate__ >>> x = cPickle.loads(s) get __setstate__ >>> Do you have a __getinitargs__ or __getstate__ or __setstate__ that might be triggering a call to __getattr__? Does an Irishman like to talk? - Gordon From yleteigne1 at cybercable.fr Sun Jul 2 16:06:11 2000 From: yleteigne1 at cybercable.fr (Yannick Le Teigner) Date: Sun, 02 Jul 2000 16:06:11 +0200 Subject: CGI and images Message-ID: <395F4C53.589EAFC0@cybercable.fr> Hi, I want to generate an image - plot and display it via a cgi script. Creating the image is not hard, but I can't print the image on the page. # this doesn't work the browser doesn't diplay errors but no images either... print "Content-type: image/gif\n\n" print open(myImage, "rb").read() Any ideas? Thank you! Yannick From MarkH at ActiveState.com Sun Jul 2 16:45:10 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 02 Jul 2000 14:45:10 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> Message-ID: Under Windows NT or Win2k, you can use the PATHEXT environment variable. Simply add ".py" to the semi-colon sep'd list of extensions, and off you go! No solution I am aware of for 95, although there are some tricks you can pull (Im sure someone else will fill these in for you! Mark. -- markh at activestate.com - but if you think I speak for them, you dont know Dick! "Neo Brave" wrote in message news:8jmjfe$64o$1 at nnrp1.deja.com... > Hi all, > > I'm currently running Python scripts at the command line > using C:\python\python script.py. Is there a way of making > the MS-DOS box recognise the Python script as an executable > file so I can just use the name "script.py"? > > Thanks in advance, > Neo > -- > Neo Brave > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From MarkH at ActiveState.com Sun Jul 2 16:47:41 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 02 Jul 2000 14:47:41 GMT Subject: Traping output from os.system References: <8jn34q$kpn$1@news.lth.se> Message-ID: You want "popen". For non-windows platforms, "os.popen" is where you can find it. For Win32 systems, you need the win32 extensions, and "win32pipe.popen". Mark. -- markh at activestate.com - but if you think I speak for them, you dont know Dick! wrote in message news:8jn34q$kpn$1 at news.lth.se... > Hi, > > I'm executing a command with os.system and are > trying to capture the output into a python > variable. The only I can find to do it in > at the moment is to redirrect the output > to a file and the read it. That feels wrong, > isn't there another simple way?? > > Thanks, > Bjorn From michael at stroeder.com Sun Jul 2 16:42:07 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sun, 02 Jul 2000 16:42:07 +0200 Subject: CGI and images References: <395F4C53.589EAFC0@cybercable.fr> Message-ID: <395F54BF.E3D9A0C4@stroeder.com> Yannick Le Teigner wrote: > > print "Content-type: image/gif\n\n" ^^^^ Only one \n is needed if using print. > print open(myImage, "rb").read() Again: print adds an extra \n to the output. Use sys.stdout.write() instead to have full control. If mixing print and sys.stdout.write() you might have to use sys.stdout.flush() sometimes. Ciao, Michael. From nobody at nowhere.nohow Sun Jul 2 17:57:35 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 02 Jul 2000 15:57:35 GMT Subject: Traping output from os.system References: <8jn34q$kpn$1@news.lth.se> Message-ID: On Sun, 02 Jul 2000 14:47:41 GMT, Mark Hammond wrote: >You want "popen". For non-windows platforms, "os.popen" is where you can >find it. For Win32 systems, you need the win32 extensions, and >"win32pipe.popen". The commands module has a nice function that runs a program and returns the exit status and output as a tuple. -- Grant Edwards grante Yow! I represent a at sardine!! visi.com From seanmcgrath at my-deja.com Sun Jul 2 17:45:58 2000 From: seanmcgrath at my-deja.com (seanmcgrath at my-deja.com) Date: Sun, 02 Jul 2000 15:45:58 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> Message-ID: <8jno3n$p6m$1@nnrp2.deja.com> At 09:07 02/07/00 -0400, Gordon McMillan wrote: > >Do you have a __getinitargs__ or __getstate__ or __setstate__ that might be >triggering a call to __getattr__? > I don't have calls to __getinitargs__, __getstate__ or __setstate__. What I do have is a __getattr__ which I suspect is involved in this:-) The patient is pyxie.py (http://www.digitome.com/pyxie.py). The object I am trying to pickle is a tree structure. A variable CurPos points to a sub-ordinate object which can be of type xElement or xData. The __getattr__ hook achieves a Delphi-like effect in which attributes of these sub-ordinate objects appear as attributes of the top level object. It seemed like a good idea at the time:-) Here is a test program that reproduces the problem:- from pyxie import * try: import cPickle pickle = cPickle except ImportError: import pickle t = xTree() s = pickle.dumps (t) print s t1 = pickle.loads(s) When I try and pickle using the Python implementation of pickle, I get an exception: No attribute '__getstate__' on xTree or current xNode. I don't follow this as I thought __getstate__ was for fine tuning the information to be pickled. Using cPickle I don't get an exception at save time but instead get a GPF at load time. BTW, I have a test version of Pyxie with the __getattr__ stuff taken out and it pickled just fine. Picked versions of parsed XML trees load really quickly with it. What I am implementing is analagous to Pythons .py/.pyc idea. When Pyxie loads a tree it loads the binary version unless the plain text version has been modified more recently. When saving, it saves both binary and plain text XML every time. Works great! >Does an Irishman like to talk? > Only on days that end in a "y":-) regards, Sent via Deja.com http://www.deja.com/ Before you buy. From ingo.adler at synacon.ch Sun Jul 2 19:15:43 2000 From: ingo.adler at synacon.ch (Ingo Adler) Date: Sun, 02 Jul 2000 18:15:43 +0100 Subject: Memory leaks Message-ID: <395F78BF.CBEAA090@synacon.ch> Hi, I have some simple Python-Code which generated memory leaks (ca. 4MB): (The real code is more complicated, but I could strip it down to this simple example = the smallest example with the memory leak.) //--------------------------- x = X() for i in range(100000): y = x.getY() y.getNumber() //--------------------------- It doesn't generate memory leaks when: //--------------------------- x = X() y = x.getY() for i in range(100000): y.getNumber() //--------------------------- or //--------------------------- x = X() for i in range(100000): y = x.getY() //--------------------------- So getY and getNumber don't generate memory leaks on their own. Details: X and Y are implemented in C++ and connected to python via Swig-Shadow classes. The Implementation of X: class X { Y* pY; public: X() { pY = new Y; } ~X() { delete pY; } Y* getY() { return pY; } }; The Implementation of Y: class Y { float getNumber() { return 3.4; } }; The wrapper code it generated straight forward - nothing special, nothing hidden. I use Python 1.5.2, Borland C++ Builder 5.0 with statically linked Python. My code is much bigger and works pretty well - except the memory leaks. So the basic integration works. I hope someone has a solution! Ingo -------------- next part -------------- A non-text attachment was scrubbed... Name: ingo.adler.vcf Type: text/x-vcard Size: 323 bytes Desc: Card for Ingo Adler Url : http://mail.python.org/pipermail/python-list/attachments/20000702/807a33a5/attachment.vcf From richard_chamberlain at ntlworld.com Sun Jul 2 19:19:23 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sun, 2 Jul 2000 18:19:23 +0100 Subject: Tkinter and default options References: <8jnbhm$bb6$1@cubacola.tninet.se> Message-ID: Hi Thomas, You can use an option database. If you create a file called optionDB with for example the following kind of entries: *font: Times New Roman *Button*foreground blue *foreground black You can then apply these via root.option_readfile('optionDB') Richard wrote in message news:8jnbhm$bb6$1 at cubacola.tninet.se... > Hello, > > I'm using Tkinter for the GUI parts of a little game I'm working on. What is > the best way of setting default options of the widgets? For instance I > want all widgets to have fg='green' and bg='black'. Is there a standard > way of doing this? If not, I was thinking of maybe writing a widget factory > that creates and configures them for me. > > Thank, > Thomas > From tismer at appliedbiometrics.com Sun Jul 2 19:22:02 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 02 Jul 2000 19:22:02 +0200 Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> <8jno3n$p6m$1@nnrp2.deja.com> Message-ID: <395F7A3A.FFB0B903@appliedbiometrics.com> Hi Sean, seanmcgrath at my-deja.com wrote: > > At 09:07 02/07/00 -0400, Gordon McMillan wrote: > > > >Do you have a __getinitargs__ or __getstate__ or > __setstate__ that might be > >triggering a call to __getattr__? > > > > I don't have calls to __getinitargs__, > __getstate__ or __setstate__. > > What I do have is a __getattr__ which I suspect is > involved in this:-) > > The patient is pyxie.py > (http://www.digitome.com/pyxie.py). > The object I am trying to pickle is a tree > structure. > A variable CurPos points to a sub-ordinate object > which can be of type xElement or xData. > > The __getattr__ hook achieves a Delphi-like effect > in which attributes of these sub-ordinate objects > appear as attributes of the top level object. > > It seemed like a good idea at the time:-) Well, I see that your __getattr__ is a little insane. def __getattr__(self,n): if hasattr(self.CurPos,n): return getattr(self.CurPos,n) else: raise PyxieException ( "No attribute '%s' on xTree or current xNode" % n) It redirects *every* reading attribute access to the CurPos object, so Pickle can't even figure out what your xTree's class is. Also, the CurPos object can's be saved with it, nothing is accessible. First, I suggest to redirect all requests with __ to the class, second, give access to xTree object attributes a higher priority by first looking into self by self.__dict__.has_key(n) . This might work. Maybe you also want to avoid to store CurPos in the pickle at all. This can be done by introducing __getinitargs__ or __getstate__ and __setstate__ . cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : 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 david_ullrich at my-deja.com Sun Jul 2 19:55:38 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Sun, 02 Jul 2000 17:55:38 GMT Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> Message-ID: <8jnvml$2at$1@nnrp1.deja.com> In article <395E2425.8F6F8757 at uniserve.com>, Bob van der Poel wrote: > > I see sample code for python/tkinter which looks like this: > > class main: > def __init__(self): > ...do a bunch of init stuff > > a=main() > root.mainloop() > > What I'm wonder is why the use of a class for this. You say it's "sample code". One possibility is that sample code is not supposed to do what it does in the best possible way, it's supposed to do what it does in the most _illustrative_ possible way - it's supposed to be a sample of how to do things in other situations where the class will have more interesting methods. (Another possibility is that you overlooked the fact that the class in question derives from another class, so it actually does include more than just __init__, you just don't see it on that page.) DU > Wouldn't it be > just > as clear and perhaps more efficient to do > > ...do init stuff > root.mainloop() > > Is this just a good habit being developed by those who think that > classes are better than functions, or god forbid, inline code? > > While I'd asking, are there any penalties in the speed/memory usage > departments on using classes vrs. functions? > > In case this isn't obvious I'm an old programmer who figured that C was > a really nice, almost-cross-platform assembly language.... > > -- > __ > / ) / Bob van der Poel > /--< ____/__ bvdpoel at uniserve.com > /___/_(_) /_) http://users.uniserve.com/~bvdpoel > > Sent via Deja.com http://www.deja.com/ Before you buy. From wjdandreta at worldnet.att.net Sun Jul 2 20:18:31 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Sun, 02 Jul 2000 18:18:31 GMT Subject: Problem compiling Python 1.5.2? Message-ID: I am having the following problem getting Python 1.5.2 to work correctly. I am able to compile and link OK. When I run Python with the -v switch the following messages appear ----------------------------------------------------------------- 'import exceptions' failed; traceback: ImportError: No modules named exceptions Warning! Falling back to string based exceptions #c:\pyth152\python~1.2\lib\site.pyc matches c:\pyth152\python~1.2\lib\site.py import site # precompiled from c:\pyth152\python~1.2\lib\site.pyc 'import site' failed; traceback: Traceback (innermost last): File "c:\pyth152\python~1.2\lib\site.py", line 60 in ? import sys, os SystemError bad argument to internal function Python 1.5.2 (#0, Jul 2 2000, 13:27:07) [Borland] on dos Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> ---------------------------------------------------------------------------- ----------- The exceptions.py file is in the search directory. Could it be a DOS name mangling problem? I don't know what the SystemError means. The Copyright does not cover to current date, I don't know if that indicates a problem. ---------------------------------------------------------------------------- ------------------------- I played around with some arithmetic, strings, slices etc. and it all worked correctly, so I think I am pretty close to getting it right. When I exit Python, Win98 becomes unstable. It either locks up immediately or a short time later in another program. I am sure I did something wrong when I compiled but I don't have a clue as to what that might be nor do I know what info would be useful in tracing down the problem(s). Any suggestions would be appreciated. Bill From kmp at atrium.fsnet.co.uk Sun Jul 2 22:09:51 2000 From: kmp at atrium.fsnet.co.uk (Kenneth Payne) Date: Sun, 02 Jul 2000 20:09:51 GMT Subject: Problem Installing PyQt-012 Message-ID: <20000702.20095100@linux.local> I'm trying to install the Python bindings to Qt/KDE. I've downloaded the latest sources for Sip. PyQT and pyKDE. I've compiled and installed Sip and compiled PyQT. All seemed to go Ok, though I had to fiddle a bit to get them to compile on Suse 6.3. However, on the "make install" for PyQt, I get an error when the install routine hits a Python script: Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/qt.py", line 16, in ? import libqtc ImportError: /usr/lib/python1.5/lib-dynload/libqtcmodule.so: undefined symbol: __ti8sipProxy make[3]: *** [install-data-hook] Error 1 make[2]: *** [install-data-am] Error 2 make[1]: *** [install-am] Error 2 make: *** [install-recursive] Error 1 I've obviously screwed up in either the configure scripts or there's something not set in my environment. Anyone know what I've done wrong? -- Ken From moshez at math.huji.ac.il Sun Jul 2 21:20:29 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 2 Jul 2000 22:20:29 +0300 (IDT) Subject: Internet Explorer and Python/COM Message-ID: I'm really a beginner in Windows COM programming, so I'm sorry if my question doesn't make sense. Can I use Python to run Internet Explorer and control it via COM? I mean, telling it things like "Display this URL" or "Render this HTML". (Maybe even putting a hook on URL displaying, so my Python program is notified when the URL the browser is displaying changes) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From bojar at speakeasy.org Sun Jul 2 22:08:02 2000 From: bojar at speakeasy.org (E. Jordan Bojar) Date: Sun, 02 Jul 2000 16:08:02 -0400 Subject: Python CGI security Message-ID: I'm interested in running a series of Python scripts via the Apache Python module, mostly for dynamic content but possibly for password protection as well. Are there security issues particular to (or common with) Python CGIs, in the way that buffer overflow is so common to poorly-written Perl? -- E. Jordan Bojar From tim_one at email.msn.com Sun Jul 2 22:17:07 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 2 Jul 2000 16:17:07 -0400 Subject: Bug in math.frexp? In-Reply-To: <20000630221759.A1965@xyz.donetsk.ua> Message-ID: [Kirill Simonov] > $ python > Python 1.6a2 (#2, Jun 24 2000, 12:18:54) [GCC egcs-2.91.66 > 19990314/Linux (egcs-1.1.2 release)] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import math > >>> print math.frexp.__doc__ > frexp(x) > > Return the matissa and exponent for x. The mantissa is positive. > >>> math.frexp(-1) > (-0.5, 1) > > In this example the mantissa is negative. The docs are wrong. I just checked in a repaired version of mathmodule.c. Fred, would you please get the truth into the Library Reference Manual's math module docs too? C:\pysrc\python\dist\src\PCbuild>python Python 2.0b1 (#0, Jul 1 2000, 11:28:35) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> import math >>> print math.frexp.__doc__ frexp(x) Return the matissa and exponent of x, as pair (m, e). m is a float and e is an int, such that x = m * 2.**e. If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0. >>> math.frexp(0), math.frexp(-2), math.frexp(4) ((0.0, 0), (-0.5, 2), (0.5, 3)) >>> From paul at prescod.net Sun Jul 2 23:08:06 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 02 Jul 2000 16:08:06 -0500 Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> <395E4281.452C26DE@prescod.net> <395EAF62.4A628573@uniserve.com> Message-ID: <395FAF36.5EE57FBC@prescod.net> Bob van der Poel wrote: > >... > > Yes, that I understand. In some of the example code I've seen there is > only the __init__ function and no data. That's why it doesn't make sense > to me. Maybe I'm just having a bad day..... Is this code public? It doesn't seem particularly useful for all of us to just guess why they MIGHT have done it that way. -- Paul Prescod - Not encumbered by corporate consensus The calculus and the rich body of mathematical analysis to which it gave rise made modern science possible, but it was the algorithm that made the modern world possible. - The Advent of the Algorithm (pending), by David Berlinski From newsbunny at noether.freeserve.co.uk Sun Jul 2 23:06:09 2000 From: newsbunny at noether.freeserve.co.uk (Martin P Holland) Date: Sun, 2 Jul 2000 22:06:09 +0100 Subject: Problem Installing PyQt-012 References: <20000702.20095100@linux.local> Message-ID: On Sun, 02 Jul 2000 20:09:51 GMT, Kenneth Payne wrote: >I'm trying to install the Python bindings to Qt/KDE. I've downloaded >the latest sources for Sip. PyQT and pyKDE. I've compiled and >installed Sip and compiled PyQT. All seemed to go Ok, though I had to >fiddle a bit to get them to compile on Suse 6.3. However, on the "make >install" for PyQt, I get an error when the install routine hits a >Python script: > >Traceback (innermost last): > File "", line 1, in ? > File "/usr/lib/python1.5/qt.py", line 16, in ? > import libqtc >ImportError: /usr/lib/python1.5/lib-dynload/libqtcmodule.so: undefined >symbol: __ti8sipProxy >make[3]: *** [install-data-hook] Error 1 >make[2]: *** [install-data-am] Error 2 >make[1]: *** [install-am] Error 2 >make: *** [install-recursive] Error 1 Did you run ldconfig after installing sip? Did you specify the qtdir to ./configure when compiling sip? atb Martin -- http://www.noether.freeserve.co.uk http://www.kppp-archive.freeserve.co.uk From dale at out-think.NOSPAMco.uk Sun Jul 2 23:10:55 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Sun, 2 Jul 2000 22:10:55 +0100 Subject: Threads? References: <8jlnkh$7h$1@supernews.com> <8jlvat$ohi$1@nntp9.atl.mindspring.net> Message-ID: <8job5d$6i$1@supernews.com> You mean I have a choice? It supports both? Either or both, is the answer. I want separate execution paths that run concurrently to (or appear to) the main one but share the same code. The ability for the processes/threads to share memory and signal each other would be a bonus. Thanks -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Aahz Maruch wrote in message news:8jlvat$ohi$1 at nntp9.atl.mindspring.net... > In article <8jlnkh$7h$1 at supernews.com>, > Dale Strickland-Clark wrote: > > > >Can Python execute a function from the same module in another process? > >I might do this, for example, to take advantage of multiple processors. > > I'm a bit confused here. The Subject says "Threads?" but your text says > "process". Which is it? > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > The best way to get information on Usenet is not to ask a question, > but to post the wrong information. --Aahz From pmontrasi at tiscalinet.it Sun Jul 2 23:20:24 2000 From: pmontrasi at tiscalinet.it (Paolo Montrasi) Date: Sun, 02 Jul 2000 23:20:24 +0200 Subject: CGI POST on Win98 Message-ID: <395FB218.5CCD76C8@tiscalinet.it> I have installed PWS and Python 1.5.2 on my win98 machine, created a simple form which runs the test() function on the cgi module, when i use method GET in the form all works perfectly but when I try to use the POST method the page never appears on my browser and I see python.exe in my machine process list. The same thing works perfectly under NT. I have searched the archive but I was not able to find help so I am thinking I am wrong with something but I do not know where, can you help me? ciao Paolo From iain at wombatzone.freeserve.co.uk Sun Jul 2 23:29:16 2000 From: iain at wombatzone.freeserve.co.uk (Iain Calder) Date: Sun, 02 Jul 2000 21:29:16 +0000 Subject: PyGTK and draw_array References: <395F0CA6.A20736F@pp.htv.fi> Message-ID: <395FB42C.89F435B0@wombatzone.freeserve.co.uk> Esko Lehtonen wrote: > > I am trying to manipulate an image and then draw it to GtkDrawingArea > using PyGtk and Numerical Python. > So I made following code: > > WIDTH = 30 > HEIGHT = 20 > D = 3 > # create rgb image as array, every value 100 > img = ones((WIDTH, HEIGHT, D), 'b') > img = img * 100 > ---- > darea = GtkDrawingArea() > ---- > draw_array(darea.get_window(), > widget.get_style().black_gc, x, y, > GDK.RGB_DITHER_NORMAL, img) > > I still have a problem, because then a got: "TypeError: array data must > be unsigned bytes" when I'm trying to use the draw_array function. After multiplying by 100, img is not longer of type 'b'. img.typecode() returns 'i'. Use img=img.astype('b') before the call to draw_array to cast back to bytes. HTH, Iain Calder From dnotspam-jen at personic.com Mon Jul 3 00:19:29 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Sun, 2 Jul 2000 15:19:29 -0700 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: <395fbcd8$0$5627@wodc7nh0.news.uu.net> I checked out the link, but from what I read, it sounds like this is a client-side implementation only. Is there more info on this somewhere? Maybe some examples of how to use this? Thanks! Jen "David Bolen" wrote in message news:uem5e38if.fsf at ctwd0143.fitlinxx.com... > Well, there's probably no end to the number of protocols and methods > by which you could get the machines to talk, but given that it's > Python invoking Python, you might take a peek at Fredrik Lundh's > XML-RPC library. XML-RPC was sort of the precursor to SOAP. Similar > in concept, but it's dirt simple to get two Python processes > communicating (calling arbitrary methods with any Python objects and > returning any Python objects). > > See http://www.pythonware.com/products/xmlrpc/index.htm. From dnotspam-jen at personic.com Mon Jul 3 00:19:38 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Sun, 2 Jul 2000 15:19:38 -0700 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: <395fbd8c$0$5622@wodc7nh0.news.uu.net> I checked out the link, but from what I read, it sounds like this is a client-side implementation only. Is there more info on this somewhere? Maybe some examples of how to use this? Thanks! Jen "David Bolen" wrote in message news:uem5e38if.fsf at ctwd0143.fitlinxx.com... > Well, there's probably no end to the number of protocols and methods > by which you could get the machines to talk, but given that it's > Python invoking Python, you might take a peek at Fredrik Lundh's > XML-RPC library. XML-RPC was sort of the precursor to SOAP. Similar > in concept, but it's dirt simple to get two Python processes > communicating (calling arbitrary methods with any Python objects and > returning any Python objects). > > See http://www.pythonware.com/products/xmlrpc/index.htm. From dnotspam-jen at personic.com Mon Jul 3 00:22:29 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Sun, 2 Jul 2000 15:22:29 -0700 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> <8jlmj0$r1q$1@supernews.com> Message-ID: <395fbd8c$1$5622@wodc7nh0.news.uu.net> Yes, I think for the first version I will do this (no need to deal with multi-threading or the network this way). But after the initial version works (hopefully later today), I'll try to move on to one of the other methods described above, probably starting with XML-RPC if I can find more info on it. Thanks, all! Jen "Dale Strickland-Clark" wrote in message news:8jlmj0$r1q$1 at supernews.com... > Start simple. > > Unless this is particularly time critical, I'd create a folder on the Build > server and share it with suitably limited access. > > Give the Web server write access to the folder. > > The Web server writes a batch file or Python script to the shared directory. > > Every few minutes the Build server checks this folder for a file and > executes it. > > If you need some feedback, it could change the name of the file or move it > to a subdirectory while it's running so the Web server can see it's active. > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > Business Technology Consultants > > donotspam-jen at personic.com wrote in message > news:395d48b3$0$21842 at wodc7nh0.news.uu.net... > > FYI, I'm doing all of this on Windows NT, in case that makes a difference > > ... > > > > Is there a good way to get a script on one computer to talk to a script on > > another computer? The process I'm thinking of is pretty simple ... I want > a > > script on a Web server to be able to send a command to a build server to > > start a build process. I'd also like the Web server to be able to query > the > > build servers to find out their status (so that two builds do not run at > > once on the same machine, for example). > > > > I've read a little about SOAP, but I think that my needs are probably a > lot > > simpler than that. The easiest way to accomplish this is to setup a Web > > server on each of the build machines, too, I guess ... but I was hoping > that > > I could just have the scripts that run on the build servers run as NT > > services. > > > > Thanks! > > > > Jen > > > > > > > > > > From dnotspam-jen at personic.com Mon Jul 3 00:22:33 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Sun, 2 Jul 2000 15:22:33 -0700 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> <8jlmj0$r1q$1@supernews.com> Message-ID: <395fc264$0$5621@wodc7nh0.news.uu.net> Yes, I think for the first version I will do this (no need to deal with multi-threading or the network this way). But after the initial version works (hopefully later today), I'll try to move on to one of the other methods described above, probably starting with XML-RPC if I can find more info on it. Thanks, all! Jen "Dale Strickland-Clark" wrote in message news:8jlmj0$r1q$1 at supernews.com... > Start simple. > > Unless this is particularly time critical, I'd create a folder on the Build > server and share it with suitably limited access. > > Give the Web server write access to the folder. > > The Web server writes a batch file or Python script to the shared directory. > > Every few minutes the Build server checks this folder for a file and > executes it. > > If you need some feedback, it could change the name of the file or move it > to a subdirectory while it's running so the Web server can see it's active. > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > Business Technology Consultants > > donotspam-jen at personic.com wrote in message > news:395d48b3$0$21842 at wodc7nh0.news.uu.net... > > FYI, I'm doing all of this on Windows NT, in case that makes a difference > > ... > > > > Is there a good way to get a script on one computer to talk to a script on > > another computer? The process I'm thinking of is pretty simple ... I want > a > > script on a Web server to be able to send a command to a build server to > > start a build process. I'd also like the Web server to be able to query > the > > build servers to find out their status (so that two builds do not run at > > once on the same machine, for example). > > > > I've read a little about SOAP, but I think that my needs are probably a > lot > > simpler than that. The easiest way to accomplish this is to setup a Web > > server on each of the build machines, too, I guess ... but I was hoping > that > > I could just have the scripts that run on the build servers run as NT > > services. > > > > Thanks! > > > > Jen > > > > > > > > > > From robin at jessikat.demon.co.uk Sun Jul 2 16:25:21 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sun, 2 Jul 2000 15:25:21 +0100 Subject: tkinter hanging Message-ID: I'm having problems with zombie processes under win32 with a tkinter linked against Tk 8.3. I seem to be exiting the mainloop ok and have destroyed all subwindows and then the gui object itself, but occasionally I still generate a zombie. I have checked that my after's are cancelled and debug prints seem to show me exiting the script. has anyone else had these kinds of problems? heeelllppp :( -- Robin Becker From cb750chris at email.msn.com Mon Jul 3 00:53:41 2000 From: cb750chris at email.msn.com (Roger Upole) Date: Sun, 2 Jul 2000 18:53:41 -0400 Subject: Internet Explorer and Python/COM References: Message-ID: Here's a small sample of how to navigate to a URL. >>> import win32com.client >>> x=win32com.client.Dispatch('InternetExplorer.Application.1') >>> x.Visible=1 >>> x.Navigate('http://www.python.org') If you run makepy on Microsoft Internet Controls, the file generated in Python\win32com\genpy will show all the properties and methods available for this object. HTH Roger Upole Moshe Zadka wrote in message news:Pine.GSO.4.10.10007022217420.19085-100000 at sundial... > > I'm really a beginner in Windows COM programming, so I'm sorry if my > question doesn't make sense. > > Can I use Python to run Internet Explorer and control it via COM? I mean, > telling it things like "Display this URL" or "Render this HTML". > (Maybe even putting a hook on URL displaying, so my Python program is > notified when the URL the browser is displaying changes) > > -- > Moshe Zadka > There is no GOD but Python, and HTTP is its prophet. > > From rgoto at aa.net Mon Jul 3 01:16:12 2000 From: rgoto at aa.net (Robert Goto) Date: Sun, 2 Jul 2000 16:16:12 -0700 Subject: Newbie question re: regsub Message-ID: <395fc90a$1_1@huge.aa.net> I am sure there is a very simple answer to this. >>> import regsub >>> fimo = open('fimo.txt') >>> while 1: line = fimo.readline() if not line: break regsub.gsub('orange', 'red', line) print line 'red red red red red red red' red orange red red red red red >>> The file I am opening which is called fimo.txt only contains the string withouth ' marks red orange red red red red red. What I want it to do is print the changed string only....but what I am getting is both the original string and the changed string?! Any pointers would be greatly appreciated. From rgoto at aa.net Mon Jul 3 01:30:40 2000 From: rgoto at aa.net (Robert Goto) Date: Sun, 2 Jul 2000 16:30:40 -0700 Subject: Newbie question re: regsub References: <395fc90a$1_1@huge.aa.net> Message-ID: <395fcc6d$1_2@huge.aa.net> What is even more maddening to me is that when I save it to a module and run it from NT command prompt......the output I get is the original file contents only........like there was no regsub.gsub!! "Robert Goto" wrote in message news:395fc90a$1_1 at huge.aa.net... > I am sure there is a very simple answer to this. > >>> import regsub > >>> fimo = open('fimo.txt') > >>> while 1: > line = fimo.readline() > if not line: break > regsub.gsub('orange', 'red', line) > print line > > > 'red red red red red red red' > red orange red red red red red > >>> > > The file I am opening which is called fimo.txt only contains the string > withouth ' marks red orange red red red red red. > > What I want it to do is print the changed string only....but what I am > getting is both the original string and the changed string?! > > Any pointers would be greatly appreciated. > > From darrell at dorb.com Mon Jul 3 05:02:57 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sun, 2 Jul 2000 20:02:57 -0700 Subject: Newbie question re: regsub References: <395fc90a$1_1@huge.aa.net> <395fcc6d$1_2@huge.aa.net> Message-ID: <005e01bfe49b$68c94d30$6401a8c0@home> >>> open('junk','w').write("red red red red") >>> import re >>> print re.sub("red","orange", open('junk').read()) orange orange orange orange >>> The changed string is returned. Strings in python don't change so the original buffer is unaffected. --Darrell ----- Original Message ----- From: "Robert Goto" > What is even more maddening to me is that when I save it to a module and run > it from NT command prompt......the output I get is the original file > contents only........like there was no regsub.gsub!! From bgriggs at pobox.com Mon Jul 3 02:30:36 2000 From: bgriggs at pobox.com (B Griggs) Date: Mon, 03 Jul 2000 00:30:36 GMT Subject: urllib and linksys router References: <038701bfe3ec$ece104a0$6401a8c0@home> Message-ID: Darrell, Speaking of urllib and the LinkSys router... http://greenman.dyndns.org/ls_dyndns I have written a dyndns.org client for the linksys router. Should work on all Python platforms. Regards, Bobby "Darrell Gallion" wrote in message news:038701bfe3ec$ece104a0$6401a8c0 at home... > Tried to use urllib to access my linksys router, which requires a password. > After much pain, it turns out the router needs to see the request as one > string. > Maybe it's a timing thing since urllib sends each line separately. > > This works. > > def direct(): > s = socket(AF_INET, SOCK_STREAM) > s.connect("192.168.1.1",80) > > msgs=[ > 'GET /Status.htm HTTP/1.0\015\012', > 'Authorization: Basic xxxxxxxx==\015\012', > '\015\012', > ] > s.send(string.join(msgs,'')) > print s.recv(1024) > print s.recv(1024) > > > > --Darrell Gallion > > From MarkH at ActiveState.com Mon Jul 3 02:37:27 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 03 Jul 2000 00:37:27 GMT Subject: Internet Explorer and Python/COM References: Message-ID: "Roger Upole" wrote in message news:u$mxTiH5$GA.254 at cpmsnbbsa07... > Here's a small sample of how to navigate to a URL. > >>> import win32com.client > >>> x=win32com.client.Dispatch('InternetExplorer.Application.1') > >>> x.Visible=1 > >>> x.Navigate('http://www.python.org') > If you run makepy on Microsoft Internet Controls, the file generated in > Python\win32com\genpy will show all the properties and methods > available for this object. This will work fine to control IE. However, look in "win32com\client\__init__.py", and look for the "DispatchWithEvents" docstring - this has an example that uses IE to both control it, and respond to events (such as URL load completed, etc) Mark. From swun at esec.com.au Mon Jul 3 02:41:58 2000 From: swun at esec.com.au (Sam Wun) Date: Mon, 03 Jul 2000 10:41:58 +1000 Subject: multiple inheritance in Python? Message-ID: <395FE156.C0C13FBE@esec.com.au> Does anyone have example of implement multiple inheritance in Python? From fiona at sitegnome.com Mon Jul 3 03:10:20 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 3 Jul 2000 01:10:20 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 2nd, 2000 Message-ID: <20000703011020.14359.qmail@synop.com> Hi Guys. The FAQTs knowledge base continues to grow. Currently 265 questions and answers. http://python.faqts.com Cheers, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- When executing a command with os.system how can I capture the output into a python variable? http://www.faqts.com/knowledge-base/view.phtml/aid/4152 ------------------------------------------------------------- Fiona Czuczman Mark Hammond, Grant Edwards You want "popen". For non-windows platforms, "os.popen" is where you can find it. For Win32 systems, you need the win32 extensions, and "win32pipe.popen". ......... The commands module has a nice function that runs a program and returns the exit status and output as a tuple. ------------------------------------------------------------- Is there a way of making a MS-DOS box recognise the Python script as an executable file so I can just use the name "script.py"? http://www.faqts.com/knowledge-base/view.phtml/aid/4153 ------------------------------------------------------------- Fiona Czuczman Mark Hammond Under Windows NT or Win2k, you can use the PATHEXT environment variable. Simply add ".py" to the semi-colon sep'd list of extensions, and off you go! ------------------------------------------------------------- What is the best way of setting default options of widgets? http://www.faqts.com/knowledge-base/view.phtml/aid/4151 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain You can use an option database. If you create a file called optionDB with for example the following kind of entries: *font: Times New Roman *Button*foreground blue *foreground black You can then apply these via root.option_readfile('optionDB') From cut_me_out at hotmail.com Mon Jul 3 03:19:51 2000 From: cut_me_out at hotmail.com (Alex) Date: 02 Jul 2000 21:19:51 -0400 Subject: multiple inheritance in Python? References: <395FE156.C0C13FBE@esec.com.au> Message-ID: > Does anyone have example of implement multiple inheritance in Python? What sort of example are you looking for? The basic syntax is pretty straightforward, as I understand it. >>> class A: t = 1 ... ... >>> >>> class B: s = 2 ... ... >>> class C(A, B): pass ... ... >>> C.t 1 >>> C.s 2 >>> C would also inherit methods from A and B, if they had any. Alex. From swun at esec.com.au Mon Jul 3 03:56:41 2000 From: swun at esec.com.au (Sam Wun) Date: Mon, 03 Jul 2000 11:56:41 +1000 Subject: how to push data in to ssh in python? Message-ID: <395FF2D9.1B46251D@esec.com.au> Thanks Sam -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-list/attachments/20000703/9708364b/attachment.htm From swun at esec.com.au Mon Jul 3 03:57:02 2000 From: swun at esec.com.au (Sam Wun) Date: Mon, 03 Jul 2000 11:57:02 +1000 Subject: multiple inheritance in Python? References: <395FE156.C0C13FBE@esec.com.au> Message-ID: <395FF2ED.60B6AD1D@esec.com.au> Thanks. Alex wrote: > > Does anyone have example of implement multiple inheritance in Python? > > What sort of example are you looking for? The basic syntax is pretty > straightforward, as I understand it. > > >>> class A: > t = 1 > > ... ... >>> > >>> class B: > s = 2 > ... ... > >>> class C(A, B): > pass > ... ... > >>> C.t > 1 > >>> C.s > 2 > >>> > > C would also inherit methods from A and B, if they had any. > > Alex. -- Sam Wun Firewalls / Security OneGuard Senior Software Engineer Electronic Commerce eSec Limited Phone: +61 3 83715376 mailto:swun at eSec.com.au C++/JAVA/UNIX/OOP/OOD -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-list/attachments/20000703/232dd1d9/attachment.html From dgoodger at bigfoot.com Mon Jul 3 04:00:50 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sun, 02 Jul 2000 22:00:50 -0400 Subject: multiple inheritance in Python? In-Reply-To: <395FE156.C0C13FBE@esec.com.au> References: <395FE156.C0C13FBE@esec.com.au> Message-ID: on 2000-07-02 20:41, Sam Wun (swun at esec.com.au) wrote: > Does anyone have example of implement multiple inheritance in Python? My typelib.py module does (available at http://gotools.sourceforge.net/sgflib in the sgflib.tgz archive). It defines classes which emulate most of the Python built-in types (duplicating functionality in UserList and UserDict, I know; I wrote it before I "discovered" these two standard modules :). Multiple inheritance is emplyed for common functionality reuse. For example, both the Number and String classes support the "%" (modulo, or string formatting) operator, so that functionality is implemented in the ModMixin class, which is inherited by both classes along with other superclasses: class Number(SuperType, AddMulMixin, ModMixin): class Sequence(Container, AddMulMixin): class String(Sequence, ModMixin): Hope this helps. -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From pauldubois at home.com Mon Jul 3 04:40:03 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Mon, 03 Jul 2000 02:40:03 GMT Subject: Getting double* from NumPy array? References: Message-ID: <72T75.24010$i5.229971@news1.frmt1.sfba.home.com> Please see the appropriate chapter in the Numerical Documentation (Chapter 12, I believe). There is quite a bit to know and just telling you to access x->data would not be doing you any favors. Please read the entire chapter before proceeding. The process is not very complicated but it must be done correctly. Don't overlook the import_array statement. Ted Drain wrote in message news:ted.drain-2606001323500001 at mjordan.jpl.nasa.gov... > I have some existing C/C++ code that can accept a double array ( int len, > and double* ptr) to do some processing. I want to allow users to create > arrays in python using NumPy and then provide an interface to pass these > arrays to my C/C++ code. > > Assuming a 1-dimensional NumPy array, is there an easy way to extract a > pointer to a double and length from the python object? The C/C++ isn't > going to change the object so I'd prefer not to make a copy of it. > > Thanks > Ted > > -- > Ted Drain Jet Propulsion Laboratory Ted.Drain at jpl.nasa.gov From gmol at my-deja.com Mon Jul 3 04:32:37 2000 From: gmol at my-deja.com (gmol at my-deja.com) Date: Mon, 03 Jul 2000 02:32:37 GMT Subject: Referring to method of a class without instance? Message-ID: <8jou05$mei$1@nnrp1.deja.com> In my application I use the observer/observable pattern..question I hate duplicating the information of what was changed by making up a new message type (global message variables or strings) and using tonnes of if-else clauses. I'd rather just tell my observer which method was called and the arguments passed to it. (I.e. I have atoms in 3d space, when setPosition(position) is called I would just like to tell whoever is interested that setPosition was called with the argument position)) Problem, how do I refer to the method of a given class without making an instance? Like suppose I notify my observers by giving the funciton address and arguments, I would like the observer to have a dictionary whose keys are methods class Atom: .... class myobserver: ... updateTable={.... Atom.setPosition:handle_A_setPositio } ... Hmm I have also just realized that given class A: def __init__(self...) a=A() a.init is not equal to A.__methods__['__init__'] Hmmm I thought that would be the worst way I could do it, but I guess I couldn't if I wanted to... Any thoughts or better general solution would be appreciated... Sent via Deja.com http://www.deja.com/ Before you buy. From dberlin at cygnus.com Mon Jul 3 05:09:14 2000 From: dberlin at cygnus.com (Daniel Berlin) Date: 02 Jul 2000 23:09:14 -0400 Subject: Referring to method of a class without instance? In-Reply-To: gmol@my-deja.com's message of "Mon, 03 Jul 2000 02:32:37 GMT" References: <8jou05$mei$1@nnrp1.deja.com> Message-ID: <86r99bewpx.fsf@dan2.cygnus.com> gmol at my-deja.com writes: > In my application I use the observer/observable pattern..question > I hate duplicating the information of what was changed by making up a > new message type (global message variables or strings) and using tonnes > of if-else clauses. I'd rather just tell my observer which method was > called and the arguments passed to it. (I.e. I have atoms in 3d space, > when setPosition(position) is called I would just like to tell whoever > is interested that setPosition was called with the argument position)) > > Problem, how do I refer to the method of a given class without making an > instance? Like suppose I notify my observers by giving the funciton > address and arguments, I would like the observer to have a dictionary > whose keys are methods > > class Atom: > .... > > > class myobserver: > ... > > updateTable={.... > Atom.setPosition:handle_A_setPositio > } > ... > > Hmm I have also just realized that given > class A: > def __init__(self...) > > a=A() > > a.init is not equal to A.__methods__['__init__'] > > Hmmm I thought that would be the worst way I could do it, but I guess I > couldn't if I wanted to... > > Any thoughts or better general solution would be appreciated... > This is a simple problem. Try A.__init__ >>> class B: ... def __init__(self): ... pass ... >>> B.__init__ >>> __ If you try to call it without a class instance as the first parameter, you'll get an error. >>> B.__init__(5) Traceback (innermost last): File "", line 1, in ? TypeError: unbound method must be called with class instance 1st argument Otherwise, it'll work fine. >>> B.__init__(B()) HTH, Dan From robertrutledge at my-deja.com Mon Jul 3 05:10:23 2000 From: robertrutledge at my-deja.com (robertrutledge at my-deja.com) Date: Mon, 03 Jul 2000 03:10:23 GMT Subject: Getting remote memory configuration References: <2B1262E83448D211AE4B00A0C9D61B03013011F8@msgeuro1.creo.be> Message-ID: <8jp06o$nn8$1@nnrp1.deja.com> Pieter, Ask an operator at the remote site, via telephone. Bob Rutledge In article <2B1262E83448D211AE4B00A0C9D61B03013011F8 at msgeuro1.creo.be>, Pieter Claerhout wrote: > Forgot to mention that I was talking about Windows NT machines. > > Pieter > > Pieter Claerhout > Application Support - CreoScitex Europe > > > -----Original Message----- > > From: Pieter Claerhout > > Sent: Monday, June 19, 2000 3:40 PM > > To: 'python-list at python.org' > > Subject: Getting remote memory configuration > > > > Anyone an idea on how you can find out how much memory a remote computer > > has installed? The computer is available on the same network and has the same > > login as the computer on which you are running the command. > > > > Pieter > > Sent via Deja.com http://www.deja.com/ Before you buy. From gmcm at hypernet.com Mon Jul 3 05:40:57 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 03:40:57 GMT Subject: Referring to method of a class without instance? References: <8jou05$mei$1@nnrp1.deja.com> Message-ID: <8F65FB46Fgmcmhypernetcom@199.171.54.155> gmol at my-deja.com wrote in <8jou05$mei$1 at nnrp1.deja.com>: >In my application I use the observer/observable pattern..question >I hate duplicating the information of what was changed by making up a >new message type (global message variables or strings) and using tonnes >of if-else clauses. I'd rather just tell my observer which method was >called and the arguments passed to it. (I.e. I have atoms in 3d space, >when setPosition(position) is called I would just like to tell whoever >is interested that setPosition was called with the argument position)) > >Problem, how do I refer to the method of a given class without making an >instance? Like suppose I notify my observers by giving the funciton >address and arguments, I would like the observer to have a dictionary >whose keys are methods > >class Atom: >.... > > >class myobserver: >... > > updateTable={.... > Atom.setPosition:handle_A_setPositio > } >... > >Hmm I have also just realized that given >class A: > def __init__(self...) > >a=A() > >a.init is not equal to A.__methods__['__init__'] > >Hmmm I thought that would be the worst way I could do it, but I guess I >couldn't if I wanted to... That's right: a.__init__ is a bound method, while A.__init__ is an unbound method. You can get to the latter from the former by: self.__class__.__init__ or more directly (of course) A.__init__ But you might be headed for trouble. For example, you might later add a class Molecule with a setPosition method. Now you have to go through all your observers and update their dispatch tables. IOW, you're tightly coupling your observers to your observables. OTOH, A.__init__ and a.__init__ both have __name__ attributes with singularly unexciting values . Then you just have to be sure you don't get sloppy and write Molecule.setPos(....). Of course, since there's no special name for "the currently executing method", in effect you're still maintaining a global table of message identifiers. - Gordon From neo_brave at my-deja.com Mon Jul 3 06:11:49 2000 From: neo_brave at my-deja.com (Neo Brave) Date: Mon, 03 Jul 2000 04:11:49 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> Message-ID: <8jp3pt$q7j$1@nnrp1.deja.com> In article , "Mark Hammond" wrote: > Under Windows NT or Win2k, you can use the PATHEXT environment > variable. Simply add ".py" to the semi-colon sep'd list of > extensions, and off you go! Great, thats a help for NT, but I also want to do this on Win98 :-). > No solution I am aware of for 95, although there are some tricks > you can pull (Im sure someone else will fill these in for you)! Anyone??? Neo -- Neo Brave Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Mon Jul 3 06:27:02 2000 From: aahz at netcom.com (Aahz Maruch) Date: 3 Jul 2000 04:27:02 GMT Subject: Threads? References: <8jlnkh$7h$1@supernews.com> <8jlvat$ohi$1@nntp9.atl.mindspring.net> <8job5d$6i$1@supernews.com> Message-ID: <8jp4mm$ks$1@nntp9.atl.mindspring.net> In article <8job5d$6i$1 at supernews.com>, Dale Strickland-Clark wrote: > >I want separate execution paths that run concurrently to (or appear to) >the main one but share the same code. > >The ability for the processes/threads to share memory and signal each >other would be a bonus. In that case, it'll be much simpler to use threads. Check out threading.Thread. The one problem with Python threads is that there is something called the "global interpreter lock". This means that only one thread can run Python code at any time, even on a multi-CPU machine. However, threads that call out to extensions (such as I/O) can run truly concurrently. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From mksql at my-deja.com Mon Jul 3 07:19:49 2000 From: mksql at my-deja.com (Matt) Date: Mon, 03 Jul 2000 01:19:49 -0400 Subject: Tutorials at IPC9 References: <39591877.535A96BC@sage.att.com> Message-ID: <9i80ms4tbkjjhp90t55au011qquvmsr456@4ax.com> On Tue, 27 Jun 2000 21:11:19 GMT, Garry Hodgson wrote: >I'm starting to think about what kinds of tutorials we should have at >the next Python conference. Is there information available on when and where this will be? From Martin.Kew at vsl.com.au Mon Jul 3 07:27:11 2000 From: Martin.Kew at vsl.com.au (Martin Kew) Date: Mon, 03 Jul 2000 14:57:11 +0930 Subject: Aspect-oriented Python? In-Reply-To: <8jg821$vll$1@gaia.cdg.acriter.nl> Message-ID: <4.2.0.58.20000703140633.00be3c30@imaphost> After seeing the following email, I investigated the Aspect Oriented Programing (AOP) as well. I to think that the Python language people should have a look at it. In summary an "Aspect" is a property/function of a system that cannot be cleanly encapsulated by a traditional programming language, for example: a) loop fusion and resource sharing for procedural algorithmic code, b) network traffic minimization, synchronization handling and error handling for distributed client/server systems. An aspect is captured using an "aspect language" in terms of "crosscuts" which are the connection points into the traditional program. ie. the loop construct for a loop fusion aspect. An AOP implementation of a system consists of: a) using a traditional language (called a component language) define and program the components of the system, ie. procedures, objects etc. Call it a "component program". b) using an aspect language define all aspects that will be applied in the system in terms of "cross-cuts". c) "weave" all "aspects" into the "component program" using an "aspect weaver" compiler to form a tangled "aspect program". For example, for the fusion of loops in an image processing system, there was a (35213-756)/352 = 98 reduction in code bloat for the incorporation of loop fusion. raw component program (LOC) ie. without loop fusion = 756 hand implemented code incorporating loop fusion (LOC) = 35213 all aspect programs (LOC) = 352 This information was unashamably paraphrased from "Aspect-Oriented Programming" G Kiczales et.all of Xerox PARC in "European Conference on OO Programming" June 1997 available a www.aspectj.org The reason for presenting this overview was the overwelming lack of interest in the first email by Cees de Groot. At 09:29 pm 29/06/00 +0200, you wrote: >I've been reading on aspect-oriented programming a bit, and it sounds really >interesting. A Java implementation, AspectJ (www.aspectj.org) looks promising, >but has the drawback that it only supports static weaving (wouldn't know >how to do dynamic weaving with Java, so it's not a big surprise). > >With Python, experimenting with aspect-oriented stuff would probably be >way easier, because it is easy enough to replace class methods etcetera. I've >tried Google, but didn't find anything. Is someone busy with aspect-oriented >programming for Python? > >-- >Cees de Groot http://www.cdegroot.com >GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B >Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ >-- >http://www.python.org/mailman/listinfo/python-list From fdrake at beopen.com Mon Jul 3 08:28:33 2000 From: fdrake at beopen.com (Fred L. Drake, Jr.) Date: Mon, 3 Jul 2000 02:28:33 -0400 (EDT) Subject: Bug in math.frexp? In-Reply-To: References: <20000630221759.A1965@xyz.donetsk.ua> Message-ID: <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> Tim Peters writes: > The docs are wrong. I just checked in a repaired version of mathmodule.c. > Fred, would you please get the truth into the Library Reference Manual's > math module docs too? --sigh-- So are the Solaris and Linux man pages wrong, or just confusing? Ok, I'll have something like your docstring checked in shortly. -Fred -- Fred L. Drake, Jr. BeOpen PythonLabs Team Member From rob at hooft.net Mon Jul 3 08:34:15 2000 From: rob at hooft.net (Rob Hooft) Date: 03 Jul 2000 08:34:15 +0200 Subject: (Serious?) package namespace problem (and a proposal) References: <395A66C5.E9AC4F3E@roguewave.com> <20000628151611.A2972@freei.com> <8F61C6D29gmcmhypernetcom@199.171.54.194> <395B6027.B47094CA@letterror.com> Message-ID: >>>>> "JvR" == Just van Rossum writes: JvR> JvR> If relative imports as we know them are shot in the head, an JvR> alternative spelling for relative imports could be invented. JvR> Eg. with a leading period: JvR> import .some.submodule JvR> Really interesting view. Like "sh" would mean "sh in the root directory", and "/bin/sh" means look in the current directory for a directory bin, which contains sh? Wrong way around? Wouldn't "from . import os" sound more reasonable? I still think that if you have a package from which you want to use the module "sys" or "os" or "string", you can AVOID using sys.py, os.py or string.py. See your own future code: from . import string; GLOBALstring=string import string .... c=GLOBALstring.strip(command) string.emit(c) .... And if you don't know what modules from the standard library you might need in the future, don't use any of their names in your package. And finally, claim the name of your package in the http://pitch.nist.gov/nics/ archive to prevent future collisions. Having your own modules named the same as those in the standard library is also confusing for somebody else that needs to read/modify your code. Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From michael at stroeder.com Mon Jul 3 08:47:47 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 03 Jul 2000 08:47:47 +0200 Subject: Python CGI security References: Message-ID: <39603713.47CD2012@stroeder.com> "E. Jordan Bojar" wrote: > > I'm interested in running a series of Python scripts via the Apache Python > module, mostly for dynamic content but possibly for password protection as > well. Are there security issues particular to (or common with) Python > CGIs, > in the way that buffer overflow is so common to poorly-written Perl? I tried to raise this topic here a couple of weeks ago but NO RESPONSE! Afterwards I started a similar thread in news:de.comp.security (german newsgroup). Regarding Python code a guy mentioned that your Python code should avoid eval() and exec(). I'm not a C programmer at all and therefore I just naively used a tool named ITS4: to find parts in the Python interpreter which might have buffer overrun issues. I would really like to have some discussion about the ITS4-output. Ciao, Michael. From rickhigh at aol.com Mon Jul 3 09:27:30 2000 From: rickhigh at aol.com (RICKHIGH) Date: 03 Jul 2000 07:27:30 GMT Subject: JPython and Java integration References: <8j7h3m$5v18j$1@fu-berlin.de> Message-ID: <20000703032730.01208.00001107@ng-cp1.aol.com> Think about using IBM's BSF. BSF = Bean Scripting Framework. It works with JPython, BeanShell, etc. For the price of integrating one language in your applicatoin you get many, many languages. I wrote an article on BSF and JPython at the JDJ (Java Developer's Journal). go to www.sys-con.com hit the JDJ gif, then search for BSF or JPython. From rickhigh at aol.com Mon Jul 3 09:31:06 2000 From: rickhigh at aol.com (RICKHIGH) Date: 03 Jul 2000 07:31:06 GMT Subject: Shoud I use Java or Python? References: <00062612550704.00594@dagomachine> Message-ID: <20000703033106.01208.00001108@ng-cp1.aol.com> There are many reasons to choose Java. There are also many reasons to choose Python. Why not have the best of both worlds? JPYTHON (Python that runs in the Java Virtual Machine) www.jpython.org I also wrote an article on JPython for the Java Developer's Journal. you can see it at www.sys-con.com search for JPython. From thomas at xs4all.nl Mon Jul 3 09:55:04 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 3 Jul 2000 07:55:04 GMT Subject: tkinter hanging References: Message-ID: On Sun, 2 Jul 2000 15:25:21 +0100, Robin Becker wrote: >I'm having problems with zombie processes under win32 with a tkinter >linked against Tk 8.3. I seem to be exiting the mainloop ok and have >destroyed all subwindows and then the gui object itself, but >occasionally I still generate a zombie. I have checked that my after's >are cancelled and debug prints seem to show me exiting the script. Does your Tkinter script become a zombie process, or a sub-process ? Zombie processes are processes that exited normally, but of which the parent hasn't (yet) read the exit code (with one of the 'wait' family of functions.) If your process exits without wait()ing on its children, those children will be inherited by 'init', the first process to start on a UNIX box, which does a continous wait(). Zombie processes do not really take up much resources, except a slot in the process table and the int that is needed for the exit code. If you have one or two lingering around for a couple of minutes, you shouldn't worry. However, if you see hundreds of them lying around, something might be wrong ;-P Check their parent process (with ps -l) -- if it's '1', something is wrong with your init. If it's another process, that process needs to be fixed ;-) You can always 'fix' it by killing it and starting a new one, but you might not like the side-effects. Adding waitfor() calls at appropriate places might be a less destructive and more permanent solution ;) Halloween-ly-y'rs, Thomas From thomas at xs4all.nl Mon Jul 3 10:00:11 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 3 Jul 2000 08:00:11 GMT Subject: how to push data in to ssh in python? References: <395FF2D9.1B46251D@esec.com.au> Message-ID: On Mon, 03 Jul 2000 11:56:41 +1000, Sam Wun wrote: >Thanks Your question is incomplete. What do you want to do ? Did you look at popen(), and is it not what you want ? Does ssh require the input to come from a pseudo-terminal ? Can't you use a normal shell pipeline and make your python script just 'print' what you want to output ? Are you encountering difficulties with any of these ideas, or not finding the right documentation? Oh, and it's not necessary to post both in HTML and in plaintext.. Just plaintext will do just fine ;) How-do-I-get-a-zilion-dollars-ly y'rs, Thomas. From davec999 at my-deja.com Mon Jul 3 10:23:03 2000 From: davec999 at my-deja.com (David Currie) Date: Mon, 03 Jul 2000 08:23:03 GMT Subject: command-line history in win References: <395c304e.1224185@news.student.lu.se> <8jhm03$qnm$1@nnrp1.deja.com> <8jig08$dk7$1@nnrp1.deja.com> <8F63D360Egmcmhypernetcom@199.171.54.154> Message-ID: <8jpigs$4k9$1@nnrp1.deja.com> In article <8F63D360Egmcmhypernetcom at 199.171.54.154>, gmcm at hypernet.com (Gordon McMillan) wrote: > david_ullrich at my-deja.com wrote: > > > David Currie wrote: > > >> It works for me (Python 1.5.2)... > > > Keen. Maybe I'm the only one who doesn't know: > >_What_ works for you, exactly? > > Perhaps David is on NT, where it just works (not only for DOS cmds, but if > you start Python, up-arrow will take you thru the history for your last > Python session in that DOS box). This is all built in to NT. That is correct, I am on NT. I hadn't realised it might be different for win9x... Dave Sent via Deja.com http://www.deja.com/ Before you buy. From michael at stroeder.com Mon Jul 3 10:54:57 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 03 Jul 2000 10:54:57 +0200 Subject: Python CGI security References: Message-ID: <396054E1.ED99677C@stroeder.com> "E. Jordan Bojar" wrote: > > Are there security issues particular to (or common with) Python CGIs, Additional info: - Have a close look at all os.system() and os.popen() calls. - Use smptlib instead calling sendmail via os.system(). - Build a framework for strict form parameter checking. (I have such a module. Feel free to ask for it.) Ciao, Michael. From stephen at cerebralmaelstrom.com Mon Jul 3 11:24:06 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Mon, 03 Jul 2000 09:24:06 GMT Subject: PYRO, XML-RPC, and their friends. Message-ID: <8jpm3d$6ss$1@nnrp1.deja.com> Okay, apparently i'm entering another one of my Twenty Questions phases. I've discovered recently that I have a need for some Client/Server db fucntionality in the python project that i'm working on. What I don't want is to have to deal with installing some Big Bunch Of Crap that will be needed to support my program, and even though I know nothing about ODBC, it seems like that would include more baggage then its worth in this instance.. not to mention i'd _like_ to maybe eventually have my little windows program run on Linux...maybe Anyways. It might be a bit overly complicated in and of itself, but the way i've thought of doing it is just setting up PYRO, XML-RPC, etc, to communicate between my Server and its Clients, to then access a MetaKit controlled on the server. I have two questions: #1) How fast are these? There might actually be a need to transmit quite a bit of data between the client and the server -- over an ethernet LAN connection, prolly.. Some of this data might actually be binary files, either stored in the db or on the side, and i'd need to be transmitting that across also. I don't know how long it'd take one of these systems to send across a multi-megabyte binary file.. The rest of the data i'd be sending would be irrelevant in comparison. #2) Is there a Better Way? Keep in mind that i don't want to include a lot of stuff extra which is going to require installation if I don't have to.. Thanks! --Stephen Sent via Deja.com http://www.deja.com/ Before you buy. From michael at stroeder.com Mon Jul 3 11:22:50 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 03 Jul 2000 11:22:50 +0200 Subject: Python CGI security References: <39603713.47CD2012@stroeder.com> Message-ID: <39605B6A.28B4E36D@stroeder.com> Thomas Wouters wrote: > > On Mon, 03 Jul 2000 08:47:47 +0200, Michael Str?der > wrote: > >"E. Jordan Bojar" wrote: > > >> [..] buffer overflow [..] > > >I'm not a C programmer at all and therefore I just naively used a > >tool named ITS4: to find parts > >in the Python interpreter which might have buffer overrun issues. I > >would really like to have some discussion about the ITS4-output. > > If you do want to have that discussion, feel free to send me that report, > or post it here Ok, here are some examples from Python1.6a2 sources (see below). I'm not a C programmer therefore such tools are my only possibility to raise some discussion by pointing to code. Off course the tool outputs only hints. Not every code line listed is a real security hole. I understand that the Python application itself is responsible for dealing with some issues (e.g. race conditions with files) since the Python libs only wrap some system libs. And I understand that some of the listed functions as being dangerous are used in a safe way with appropriate parameters. But IMHO a discussion about security issues would be worthful. Ciao, Michael. ---------------------------------------------------------------------- Modules/posixmodule.c:248:(Urgent) popen Easy to run arbitrary commands through env vars. Use fork + execve + pipes instead. ---------------- [..] ---------------- Modules/posixmodule.c:1151:(Urgent) system Easy to run arbitrary commands through env vars. Also, potential TOCTOU problems. Use fork + execve instead. ---------------- [..] ---------------- Modules/posixmodule.c:605:(Very Risky) access Potential race condition on: path Points of concern are: Modules/posixmodule.c:605: access Modules/posixmodule.c:701: chmod Modules/posixmodule.c:1063: mkdir Modules/posixmodule.c:1065: mkdir Modules/posixmodule.c:1254: utime Modules/posixmodule.c:2235: readlink Modules/posixmodule.c:3263: statvfs Manipulate file descriptors, not symbolic names, when possible. ---------------- [..] ---------------- Modules/main.c:117:(Very Risky) getenv Often seen in conjunction with buffer overflows, etc. Remember that env vars can contain arbitrary malicious input. Test accordingly before use. ---------------- [..] ---------------- Modules/posixmodule.c:1863:(Very Risky) getlogin It is very easy to fool. Don't trust its output. ---------------- [..] ---------------- Modules/parsermodule.c:1032:(Very Risky) sprintf This function is high risk for buffer overflows Use snprintf if available, or precision specifiers, if available. ---------------- [..] ---------------- Modules/getpath.c:186:(Very Risky) stat Potential race condition on: filename Points of concern are: Modules/getpath.c:186: stat Modules/getpath.c:216: stat Modules/getpath.c:231: stat Modules/main.c:194: fopen Python/bltinmodule.c:883: fopen Python/pythonrun.c:583: fopen Python/traceback.c:157: fopen Manipulate file descriptors, not symbolic names, when possible. ---------------- [..] ---------------- Modules/posixmodule.c:385:(Very Risky) strcat This function is high risk for buffer overflows Use strncat instead. ---------------- [..] ---------------- Modules/posixmodule.c:827:(Very Risky) strcpy This function is high risk for buffer overflows Use strncpy instead. From supersede at india.com Mon Jul 3 11:24:48 2000 From: supersede at india.com (Extra Strength Flufferin) Date: 03 Jul 2000 05:24:48 -0400 Subject: 1.5.2 extentions under 1.6 References: <8jpi6m$4aa$1@nnrp1.deja.com> Message-ID: <87lmzjefbz.fsf@litterbox.meowing.net> Stephen Hansen wrote: > My question is -- does anything need to be changed in the sources, any > differences int he API, etc? Or is it simply something which is > modified in the Python.h which needs to be included in the extention > for it to work? The only real annoyance I've run into so far is that Py_Malloc() and company went away. It makes sense that they went away and it's easy enough to work around, but do watch your links carefully for undefined symbol warnings. From alex at magenta.com Mon Jul 3 11:07:43 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 11:07:43 +0200 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> <962367319.379353174@news.libertysurf.fr> <395D79FE.4E4FDBCE@colconsulting.com> Message-ID: <8jplbd0l5c@news2.newsguy.com> Frank V. Castellucci wrote in message news:395D79FE.4E4FDBCE at colconsulting.com... > Jerome Quelin wrote: > > > > "Alex Martelli" wrote: > > >By calling the accessors, rather than accessing the data > > >directly, you ensure that if somebody overrides the > > >accessor functions in a derived class you'll be calling > > >the derived-class versions of those functions. If that is > > >what you want (one direction along which you want to let > > >inheritors of your class extend or tweak behaviour), then > > >it's probably worth the overhead you mention. > > The class isn't to be derived any further. It's a class that I use in an > > application, and that may be imported in some other applications, but not to be > > inherited. Then, "do the simplest thing that could possibly work" applies. > > Then, is it better/cleaner to access private members with accessors or not? > > Is it a matter of style? Or are there hidden caveheats using (or not using) > > accessors? It _seems_ cleaner to use accessors, but man, it's quite awkward. I would not use accessors that feel awkward to you, without specific purpose. > As you really have no way to "prohibit" further derivation (unless I > missed the "final" keyword in the reference), using your accessors and > praying that anyone over-riding the accessor/mutator methods does the > proper thing would be my direction. Such "prohibition" is not hard at all: class dontderive: def __init__(self): if self.__class__ != dontderive: raise "told you not to!" class foo(dontderive): pass However, I wouldn't normally do it, again under the "simplest thing" principle. Just documenting "this class is not meant to be derived from, so, just don't do it, or results will be unpredictable" is likely to be "the simplest thing that could possibly work" in this case. Alex From Jarkko.Veijalainen at tecnomen.fi Mon Jul 3 12:14:40 2000 From: Jarkko.Veijalainen at tecnomen.fi (Jarkko Veijalainen) Date: Mon, 3 Jul 2000 13:14:40 +0300 Subject: slicing string Message-ID: <00Jul3.130616eest.119043@sister.tecnomen.fi> Hi! I'm real newbie with Python. I started learnig Python just last week. I have a problem slicing a string, imported from file. can anyone help me with simple solution. Input string follows this pattern: attr=value , attr2=value2, attr3= , attr4=value2. I have made an Object class, where all attributes are class variables. How can i slice that sring and store those att=value pairs in my object? I'm desperated... JarkkoV From alex at magenta.com Mon Jul 3 11:16:29 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 11:16:29 +0200 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr><8jhuvn01vs0@news2.newsguy.com> <4.3.1.2.20000630145109.0201d9e0@phear.dementian.com> Message-ID: <8jplru0lfe@news2.newsguy.com> Steven D. Arnold wrote in message news:4.3.1.2.20000630145109.0201d9e0 at phear.dementian.com... > At 02:15 PM 6/30/2000 +0200, Jerome Quelin wrote: > > >Then, is it better/cleaner to access private members with accessors or not? > >Is it a matter of style? Or are there hidden caveheats using (or not using) > >accessors? It _seems_ cleaner to use accessors, but man, it's quite awkward. > > If you always use accessors, then you can store or derive the value in any > way you wish internally in your class. You may completely change the way > the value is obtained, and the class user doesn't need to change anything These are excellent arguments for always using accessors from OUTSIDE the class. Jerome, however, was talking about using them from INSIDE the class as well, which is a different issue. Alex From alex at magenta.com Mon Jul 3 11:35:43 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 11:35:43 +0200 Subject: Passing variable-length keyworded arguments list to base class constructor? References: <962352947.103057778@news.libertysurf.fr> <8jhum101vku@news2.newsguy.com> <962367281.1198008296@news.libertysurf.fr> Message-ID: <8jpn010mb7@news2.newsguy.com> Jerome Quelin wrote in message news:962367281.1198008296 at news.libertysurf.fr... > "Alex Martelli" wrote: > >> I was wondering how to pass variable-length keyworded arguments list > >> to my base-class constructor? Look at the example code below: > >Doesn't apply work for __init__ just as for any other function? > Sure it works for __init__ too, I've already tried this approch, but it doesn't > work either. In fact, I'm asking the question for __init__ because I run into > this problem when calling constructors, but the question is the same for every > inherited and overloaded method. > > When using the *args syntax, I get an error when calling my constructor because > I'm using keywords arguments. Ok, so *args is out. > When using the **args syntax, python fetches all keyworded arguments in _one_ > dictionnary in my constructor, and I want to keep the arguments in multiple > key/value pairs (and not flattened in one dictionnary) since the parent > constructor is waiting for keyworded arguments too. But that's what apply does (in part): turn a "flattened in one dictionary" set of name/value pairs into "keyworded arguments" for the function being applied. > If I use the **args syntax and then call the base constructor with: > Parent.__init__(self, args) > I got an error since it doesn't wait for a dictionnary as an argument (and args > is a dictionnary in this case) but for key=value arguments, with key and value > taken from the args dictionnary. So you should instead call apply(Parent.__init__,(self,),args), shouldn't you? Toy example: class Parent: def __init__(self, foo=23, bar=45): print foo, bar class Derived(Parent): def __init__(self, **kwargs): apply(Parent.__init__, (self,), kwargs) >>> esem.Derived(foo=99) 99 45 >>> Of course you can alter the kwargs dictionary as required in your Derived.__init__ method for whatever special needs you may have; e.g., suppose you want to change the *default* for bar from 45 to 73 in Derived (only), you might code: class Derived(Parent): def __init__(self, **kwargs): if not kwargs.has_key('bar'): kwargs['bar']=73 apply(Parent.__init__, (self,), kwargs) and now: >>> esem.Derived(foo=99) 99 73 >>> Alex From moshez at math.huji.ac.il Mon Jul 3 12:56:03 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 3 Jul 2000 13:56:03 +0300 (IDT) Subject: Python CGI security In-Reply-To: <39605B6A.28B4E36D@stroeder.com> Message-ID: On Mon, 3 Jul 2000, Michael [iso-8859-1] Str?der wrote: > Thomas Wouters wrote: > > > > On Mon, 03 Jul 2000 08:47:47 +0200, Michael Str?der > > wrote: > > >"E. Jordan Bojar" wrote: > > > > >> [..] buffer overflow [..] > > > > >I'm not a C programmer at all and therefore I just naively used a > > >tool named ITS4: to find parts > > >in the Python interpreter which might have buffer overrun issues. I > > >would really like to have some discussion about the ITS4-output. > > > > If you do want to have that discussion, feel free to send me that report, > > or post it here > > Ok, here are some examples from Python1.6a2 sources (see below). I'm > not a C programmer therefore such tools are my only possibility to > raise some discussion by pointing to code. Off course the tool > outputs only hints. Not every code line listed is a real security > hole. OK, here is an answer to the report I just snipped. There are a few types of "potential security holes": -- exposing insecure parts of the API, such as os.system(). These should stay, since the user should have those at his disposale -- OS/2 message formatting. I haven't looked at it, but this only concerns you if you're working on OS/2 -- checked "dangerous" functions, which are therefore fine as far as I could see -- one sprintf() which will work fine as long as integers are <128 bits, which is true in the forseeable feature. I'm planning to patch this, just in case, but it should be fine anyway. (I'm talking about the first sprintf() in posixmodule.c) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From thiele at muc.das-werk.de Mon Jul 3 12:40:44 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 12:40:44 +0200 Subject: From UNIX to Win NT Message-ID: <39606DAC.49A502DB@muc.das-werk.de> Hallo! I have a program running on UNIX(IRIX and LINUX). I now want to port this program to Win NT. Is there anybody who have any experience with this? The problem is I am using threads, fork and exec. And I want to have the same behaviour using NT. - at first I create a new thread. (so the main thread is ready for receiving commands) - then I fork in the child I change it's userID (os.setuid()) and replace it by os.exec() the parent reads the stderr and stdout from the started program ( like popen2.popen3() ) Last but not least I use sockets (a derived server from SocketServer.py) What have I to change? And why? And how? Thanks for help, Thomas From cg at gaia.cdg.acriter.nl Mon Jul 3 08:23:33 2000 From: cg at gaia.cdg.acriter.nl (Cees de Groot) Date: 3 Jul 2000 08:23:33 +0200 Subject: Aspect-oriented Python? References: <4.2.0.58.20000703140633.00be3c30@imaphost> Message-ID: <8jpbh5$jim$1@gaia.cdg.acriter.nl> Martin Kew said: >The reason for presenting this overview was the overwelming lack of >interest in the first >email by Cees de Groot. > Thanks :-). Somehow, I always assume I lag behind in discovering new technologies, especially on a group like this one, which so much programming language and computer-science related prowess. Seems not to have been the case this time (or, of course, the subject is genuinly boring and uninteresting ;-)). Aspect-oriented programming and its family members subject oriented programming (older, by IBM) and adaptive programming are really interesting tracks. According to the Xerox team, the status at the moment is more-or-less the status of OOP twenty years ago, all the more reason for looking for lightweight language testbeds. -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ From loewis at informatik.hu-berlin.de Mon Jul 3 13:05:25 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Jul 2000 13:05:25 +0200 Subject: PYRO, XML-RPC, and their friends. References: <8jpm3d$6ss$1@nnrp1.deja.com> Message-ID: Stephen Hansen writes: > I've discovered recently that I have a need for some Client/Server db > fucntionality in the python project that i'm working on. What I don't > want is to have to deal with installing some Big Bunch Of Crap that > will be needed to support my program, and even though I know nothing > about ODBC, it seems like that would include more baggage then its > worth in this instance.. I don't know what database you are going to use, but I believe that odbc would indeed be the soluation that involves the least amount of extra stuff. For example, Python-Win comes with an odbc module, and there is also at least one other odbc module that would work in a plain python installation, as well. > have my little windows program run on Linux It is possible to use odbc on Linux, as well. Depending on the database, it may even be easy to do so. > Anyways. It might be a bit overly complicated in and of itself, but the > way i've thought of doing it is just setting up PYRO, XML-RPC, etc, to > communicate between my Server and its Clients, to then access a MetaKit > controlled on the server. For completeness, I'd like to add CORBA in this candidate list; the implementation with least installation overhead is probably Fnorb (only one C module, which comes precompiled for Windows). > #1) How fast are these? Some of these are only protocols, which you can't compare for performance - you'd have to compare concrete implementations. I don't think anybody has done significant benchmarking on them, so far, but I guess they are "fast enough". > I don't know how long it'd take one of these systems to send across > a multi-megabyte binary file. I hope most of them would achieve approximately the raw wire speed for bulk transfer, or be at least comparable to any other bulk data protocol. Most of these will require to copy the bulk data in memory a number of times, which would be the primary source of overhead. > The rest of the data i'd be sending would be irrelevant in > comparison. That is only true if you have only "few" calls. If you have "many" calls, it is actually the number of calls that matters, not the amount of data transferred. Regards, Martin From thomas at centurion.xs4all.nl Mon Jul 3 13:18:27 2000 From: thomas at centurion.xs4all.nl (Thomas Wouters) Date: Mon, 3 Jul 2000 13:18:27 +0200 Subject: Bug in math.frexp? In-Reply-To: <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> References: <20000630221759.A1965@xyz.donetsk.ua> <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> Message-ID: <200007031118.NAA22787@centurion.xs4all.nl> In comp.lang.python, you wrote: > >Tim Peters writes: > > The docs are wrong. I just checked in a repaired version of mathmodule.c. > > Fred, would you please get the truth into the Library Reference Manual's > > math module docs too? > --sigh-- > So are the Solaris and Linux man pages wrong, or just confusing? >Ok, I'll have something like your docstring checked in shortly. Not sure which version of the Linux manpges you read, but the frexp manpage that came with RedHat 6.1 more or less exactly mirrors Tim's description: The frexp() function returns the normalized fraction. If the argument x is not zero, the normalized fraction is x times a power of two, and is always in the range 1/2 (inclusive) to 1 (exclusive). If x is zero, then the nor? malized fraction is zero and zero is stored in exp. The 'info' page about frexp states the same, in different wording. The Solaris 2.5 manpage I have access to is indeed a bit confusing, but does state the same: 'x' is in the range of [0.5, 1), or 0. That means the exponent has to be able to be negative, when the original number was negative. From * at spam.ruud.org Mon Jul 3 13:26:29 2000 From: * at spam.ruud.org (Ruud de Rooij) Date: 3 Jul 2000 13:26:29 +0200 Subject: Bug in math.frexp? References: <20000630221759.A1965@xyz.donetsk.ua> <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> <200007031118.NAA22787@centurion.xs4all.nl> Message-ID: <87lmzjo3oa.fsf@hobbes.home.ruud.org> Thomas Wouters writes: > That means the > exponent has to be able to be negative, when the original number was > negative. The sign of the exponent is not necessarily equal to the sign of the number. - Ruud de Rooij -- ruud de rooij | *@spam.ruud.org | http://ruud.org From thiele at muc.das-werk.de Mon Jul 3 13:30:22 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 13:30:22 +0200 Subject: making widgets invisible Message-ID: <3960794E.6E2B36E6@muc.das-werk.de> How can I realize that a set of widgets (buttons and entries) is invisible when I don't need them and visible when I need them? One solution is to create a dialog window (or frame) and destroy it then. But is there a better one? Withdrawn works only with top level widgets. Thanks Thomas From michael at stroeder.com Mon Jul 3 13:33:54 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 03 Jul 2000 13:33:54 +0200 Subject: Python CGI security References: Message-ID: <39607A22.CA190D70@stroeder.com> Moshe Zadka wrote: > > On Mon, 3 Jul 2000, Michael [iso-8859-1] Str?der wrote: > > > Ok, here are some examples from Python1.6a2 sources (see below). > > OK, here is an answer to the report I just snipped. Note that I only posted *excerpts* of the ITS4 output. Feel free to ask if you want the whole output by e-mail (approx. 1000 lines with a lot of repeated messages). > There are a few types of "potential security holes": > > -- exposing insecure parts of the API, such as os.system(). These should > stay, since the user should have those at his disposale Would it be possible to provide a secure version in the Python lib of e.g. os.system() with same function parameters but less unsecure behaviour instead of just wrapping it 1:1? > -- OS/2 message formatting. I haven't looked at it, but this only > concerns you if you're working on OS/2 Hmm, I do not know under which OS my demons will run. Would be worth to collect such insights somewhere. > -- checked "dangerous" functions, which are therefore fine as far as I > could see > > -- one sprintf() which will work fine as long as integers are <128 bits, > which is true in the forseeable feature. I'm planning to patch this, > just in case, but it should be fine anyway. (I'm talking about the > first sprintf() in posixmodule.c) Thanks for following up. Ciao, Michael. From thomas at xs4all.nl Mon Jul 3 13:43:31 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 3 Jul 2000 11:43:31 GMT Subject: Python CGI security References: <39603713.47CD2012@stroeder.com> <39605B6A.28B4E36D@stroeder.com> Message-ID: On Mon, 03 Jul 2000 11:22:50 +0200, Michael Str?der wrote: >Thomas Wouters wrote: >> On Mon, 03 Jul 2000 08:47:47 +0200, Michael Str?der >> wrote: >> >"E. Jordan Bojar" wrote: >> >> >> [..] buffer overflow [..] >> >> >I'm not a C programmer at all and therefore I just naively used a >> >tool named ITS4: to find parts >> >in the Python interpreter which might have buffer overrun issues. I >> >would really like to have some discussion about the ITS4-output. >> >> If you do want to have that discussion, feel free to send me that report, >> or post it here >Ok, here are some examples from Python1.6a2 sources (see below). I'm >not a C programmer therefore such tools are my only possibility to >raise some discussion by pointing to code. Off course the tool >outputs only hints. Not every code line listed is a real security >hole. >I understand that the Python application itself is responsible for >dealing with some issues (e.g. race conditions with files) since the >Python libs only wrap some system libs. And I understand that some >of the listed functions as being dangerous are used in a safe way >with appropriate parameters. Indeed. And a couple of the 'security issues', for instance those with popen() and system(), and the race conditions in stat/access etc, Python itself does not care to solve, but instead delegates to the scripts it is executing ;) Python will not run set-uid out of the box. You have to supply your own setuid-wrapper if you want it to, in which case you should also take care with those functions. None the less, the seperation of environment variables and system() and popen() makes it slightly less insecure than C. Also, this suite you used seems to be targeted towards data-handling engines, like webservers, in a hostile environment. This is entirely unlike Python's usual environment. If you plan on programming in such environments, you should take care with your programs. Python will not do the Right Thing each time, but it also does not pretend it does. The habit of throwing exceptions on errors instead of returning an undefined value and continueing on helps prevent a lot of tight spots, though. But I'll do a quick run through the 'hotspots': >---------------------------------------------------------------------- >Modules/posixmodule.c:248:(Urgent) popen >Easy to run arbitrary commands through env vars. >Use fork + execve + pipes instead. >---------------- See above. popen() is supplied to Python scripts, but python itself does not use it. Using popen() yourself should ofcourse be done carefully :P >---------------- >Modules/posixmodule.c:1151:(Urgent) system >Easy to run arbitrary commands through env vars. Also, potential >TOCTOU >problems. >Use fork + execve instead. >---------------- See popen() >---------------- >Modules/posixmodule.c:605:(Very Risky) access >Potential race condition on: path >Points of concern are: >Modules/posixmodule.c:605: access >Modules/posixmodule.c:701: chmod >Modules/posixmodule.c:1063: mkdir >Modules/posixmodule.c:1065: mkdir >Modules/posixmodule.c:1254: utime >Modules/posixmodule.c:2235: readlink >Modules/posixmodule.c:3263: statvfs >Manipulate file descriptors, not symbolic names, when possible. >---------------- See popen(). If you stat for a filename, you should be aware that it can go away from under you. >---------------- >Modules/main.c:117:(Very Risky) getenv >Often seen in conjunction with buffer overflows, etc. >Remember that env vars can contain arbitrary malicious input. Test >accordingly >before use. >---------------- Good warning for every programmer in hostile environments, but not applicable to python itself. Usually Python scripts are not setuid, so they can trust their environment (they run under the same permission as who created that environment, after all.) If you use a setuid wrapper, you should pass a new, 'safed' environment yourself. >---------------- >Modules/posixmodule.c:1863:(Very Risky) getlogin >It is very easy to fool. >Don't trust its output. >---------------- See getenv(). >---------------- >Modules/parsermodule.c:1032:(Very Risky) sprintf >This function is high risk for buffer overflows >Use snprintf if available, or precision specifiers, if available. >---------------- Used as safely as necessary. The parser module is not something quickly used in high security environments in any case. >---------------- >Modules/getpath.c:186:(Very Risky) stat >Potential race condition on: filename >Points of concern are: >Modules/getpath.c:186: stat >Modules/getpath.c:216: stat >Modules/getpath.c:231: stat >Modules/main.c:194: fopen >Python/bltinmodule.c:883: fopen >Python/pythonrun.c:583: fopen >Python/traceback.c:157: fopen >Manipulate file descriptors, not symbolic names, when possible. >---------------- See access >---------------- >Modules/posixmodule.c:385:(Very Risky) strcat >This function is high risk for buffer overflows >Use strncat instead. >---------------- String lenghts are passed in and recorded seperately, and though I haven't backtracked it the whole way, they seem to be properly kept up to date. This is an OS/2 only branch, though. >---------------- >Modules/posixmodule.c:827:(Very Risky) strcpy >This function is high risk for buffer overflows >Use strncpy instead. String lengths are explicitly checked. From cut_me_out at hotmail.com Mon Jul 3 13:55:55 2000 From: cut_me_out at hotmail.com (Alex) Date: 03 Jul 2000 07:55:55 -0400 Subject: Getting double* from NumPy array? References: <72T75.24010$i5.229971@news1.frmt1.sfba.home.com> Message-ID: > There is quite a bit to know and just telling you to access x->data > would not be doing you any favors. Ah, well my apologies for the bad advice, then. > Please read the entire chapter before proceeding. Sounds like something I ought to do, too. Alex. From thomas at xs4all.nl Mon Jul 3 14:03:16 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 3 Jul 2000 12:03:16 GMT Subject: Python CGI security References: <39607A22.CA190D70@stroeder.com> Message-ID: On Mon, 03 Jul 2000 13:33:54 +0200, Michael Str?der wrote: >Moshe Zadka wrote: >> There are a few types of "potential security holes": >> >> -- exposing insecure parts of the API, such as os.system(). These should >> stay, since the user should have those at his disposale >Would it be possible to provide a secure version in the Python lib >of e.g. os.system() with same function parameters but less unsecure >behaviour instead of just wrapping it 1:1? How could os.system() be more secure ? The way it is defined leaves no room for restriction. (It calls a shell to interpret the string passed in, after all.) What Python does do, is provide more convenient variants of os.exec*(), in the form of os.spawn*(). (At least, in Python 2.0) Also, writing your own 'secure' system() in terms of fork() and exec*() is fairly easy. Your-code-is-as-secure-as-you-make-it-ly y'rs, Thomas. From m.faassen at vet.uu.nl Mon Jul 3 14:05:06 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Jul 2000 12:05:06 GMT Subject: Books References: <8jb1ec$9mh2@news.qualitynet.net> Message-ID: <8jpvhi$jfs$1@newshost.accu.uu.nl> Dennis Lee Bieber wrote: > On Tue, 27 Jun 2000 17:09:09 +0300, "Helmit" > declaimed the following in comp.lang.python: >> Does anyone know any good python books for teaching beginers? >> > Wide-open question... > Beginners in programming; I saw others recommend Learning Python; I wouldn't do so for beginners in programming. The Quick Python book or Python in 24 Hours seem to be better suited for this. > beginners in Python; Learning Python is fine here, though it may partially depend on the answer to the next question: > beginners in OO... I'm not sure how good Learning Python is at teaching OO concepts to people who don't know about it yet. *Python* would be good though. Any opinions? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jerome.quelin at insalien.org Mon Jul 3 14:06:53 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Mon, 3 Jul 2000 14:06:53 +0200 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr><8jhuvn01vs0@news2.newsguy.com> <4.3.1.2.20000630145109.0201d9e0@phear.dementian.com> <8jplru0lfe@news2.newsguy.com> Message-ID: <962626013.769258863@news.libertysurf.fr> "Alex Martelli" wrote: >These are excellent arguments for always using accessors from OUTSIDE the >class. Jerome, however, was talking about using them from INSIDE the class >as well, which is a different issue. Sure, I'm always using accessors from outside. But from inside the class, I don't know which is the best. I feel like the KISS rule should apply, but what do you OO gurus think of it ? How far encapsulation should go ? Regards, Jerome -- jerome.quelin at insalien.org From gmcm at hypernet.com Mon Jul 3 14:20:35 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 12:20:35 GMT Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> Message-ID: <8F665C79Agmcmhypernetcom@199.171.54.154> Thomas Thiele wrote: >Hallo! > >I have a program running on UNIX(IRIX and LINUX). I now want to port >this >program to Win NT. Is there anybody who have any experience with this? > >The problem is I am using threads, fork and exec. And I want to have the >same behaviour using NT. > >- at first I create a new thread. (so the main thread is ready for >receiving commands) Threads work very well on NT. >- then I fork >in the child I change it's userID (os.setuid()) and replace it by >os.exec() >the parent reads the stderr and stdout from the started program ( like >popen2.popen3() ) You've got both technical and cultural problems here. There is no fork. If you use the Win32 extensions you can change the user id (never done this, so don't ask me for details), but be prepared for the fact that this kind of stuff *means* something different on NT - the models just aren't the same. There's also less reason to need it - between NT and the typical NT configuration, many things that would require setuid on *nix can be done by any wazoo on Windows. >Last but not least I use sockets (a derived server from SocketServer.py) Sockets work fine. Select also works fine, but works *only* on sockets (eg if you're selecting on the pipes returned from popen3, you've got a problem). - Gordon From neilh at scintilla.org Mon Jul 3 14:31:20 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 03 Jul 2000 12:31:20 GMT Subject: Aspect-oriented Python? References: <4.2.0.58.20000703140633.00be3c30@imaphost> <8jpbh5$jim$1@gaia.cdg.acriter.nl> Message-ID: > Thanks :-). Somehow, I always assume I lag behind in discovering new > technologies, especially on a group like this one, which so much > programming language and computer-science related prowess. Seems not > to have been the case this time (or, of course, the subject is genuinly > boring and uninteresting ;-)). Aspect oriented programming and its relative 'acquisition' (as used in ZOPE) was discussed a while back (maybe 18 months ago or so) either on this group or the JPython list. I tried searching for it on Deja but Deja have dropped their older archives so couldn't find anything. Neil From gmcm at hypernet.com Mon Jul 3 14:34:51 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 12:34:51 GMT Subject: slicing string References: <00Jul3.130616eest.119043@sister.tecnomen.fi> Message-ID: <8F665CDFAgmcmhypernetcom@199.171.54.154> Jarkko Veijalainen wrote: >I'm real newbie with Python. I started learnig Python just last week. I >have a problem slicing a string, imported from file. can anyone help me >with simple solution. Input string follows this pattern: > > attr=value , attr2=value2, attr3= , attr4=value2. > >I have made an Object class, where all attributes are class variables. >How can i slice that sring and store those att=value pairs in my object? First part is easy: import string pairs = string.split(s, ',') for pair in pairs: tokens = string.split(pair, '=') if len(tokens) == 2: key = string.strip(tokens[0]) val = string.strip(tokens[1]) # see below else: # not sure what you want to do here If I take you literally, then I would say: Object.key = val but I suspect you want a line at the top: o = Object() and then o.key = val - Gordon From wolfgang.thaemelt at orsoft.de Mon Jul 3 14:41:26 2000 From: wolfgang.thaemelt at orsoft.de (Wolfgang Thaemelt) Date: Mon, 3 Jul 2000 14:41:26 +0200 Subject: lambda requirements Message-ID: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> Running the script: #----------------------------------------- begin of script def SymmetricDifference(list1, list2): # global _list1 # global _list2 _list1 = list1 _list2 = list2 _onlylist1 = filter(lambda x: x not in _list2, _list1) return _onlylist1 if __name__ == '__main__': a = [1,2,3,4,5] b = [3,4,5,6,7] x = SymmetricDifference(a,b) print x #---------------------------------------- end of script gives the error: Traceback (innermost last): File "E:\up\000701\symmdiff.py", line 16, in ? x = SymmetricDifference(a,b) File "E:\up\000701\symmdiff.py", line 9, in SymmetricDifference _onlylist1 = filter(lambda x: x not in _list2, _list1) File "E:\up\000701\symmdiff.py", line 9, in _onlylist1 = filter(lambda x: x not in _list2, _list1) NameError: _list2 If the comment characters "#" are removed from the "global" statements everything works fine. Is there some requirement on a lambda violated in the script? Thanks Wolfgang Thaemelt OR Soft Jaenicke GmbH Geusaer Str., FH Geb. 106 06217 Merseburg Germany ====================================== Email: wolfgang.thaemelt at orsoft.de Voice: +49-3461-549033 Fax: +49-3461-549022 From moshez at math.huji.ac.il Mon Jul 3 14:53:49 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 3 Jul 2000 15:53:49 +0300 (IDT) Subject: Python CGI security In-Reply-To: <39607A22.CA190D70@stroeder.com> Message-ID: On Mon, 3 Jul 2000, Michael [iso-8859-1] Str?der wrote: > Note that I only posted *excerpts* of the ITS4 output. Feel free to > ask if you want the whole output by e-mail (approx. 1000 lines with > a lot of repeated messages). > > > There are a few types of "potential security holes": > > > > -- exposing insecure parts of the API, such as os.system(). These should > > stay, since the user should have those at his disposale > > Would it be possible to provide a secure version in the Python lib > of e.g. os.system() with same function parameters but less unsecure > behaviour instead of just wrapping it 1:1? no: the insecurities are there for a reason: they give more power for local applications Please send to me (personally!) the whole output. I'll have a look at it and try to summarize it. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From thiele at muc.das-werk.de Mon Jul 3 15:06:40 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 15:06:40 +0200 Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> <8F665C79Agmcmhypernetcom@199.171.54.154> Message-ID: <39608FE0.35950741@muc.das-werk.de> > > You've got both technical and cultural problems here. There is no fork. I knew that. But I wonder how to start an other program. In UNIX I used fork() and exec(). Just the same code like in popen2.popen3 but I copied the code and included some costumization. Does popen work on NT? Or is there an other way do get the same result (starting a program and read it's output) > > configuration, many things that would require setuid on *nix can be done by > any wazoo on Windows. > From fdrake at beopen.com Mon Jul 3 15:28:02 2000 From: fdrake at beopen.com (Fred L. Drake, Jr.) Date: Mon, 3 Jul 2000 09:28:02 -0400 (EDT) Subject: Bug in math.frexp? In-Reply-To: <200007031118.NAA22787@centurion.xs4all.nl> References: <20000630221759.A1965@xyz.donetsk.ua> <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> <200007031118.NAA22787@centurion.xs4all.nl> Message-ID: <14688.38114.543936.743938@cj42289-a.reston1.va.home.com> Thomas Wouters writes: > Not sure which version of the Linux manpges you read, but the frexp manpage > that came with RedHat 6.1 more or less exactly mirrors Tim's description: I must have looked at something older when last I updated the frexp() description; my Mandrake 7.0 install agrees with your RedHat manpage. > Solaris 2.5 manpage I have access to is indeed a bit confusing, but does > state the same: 'x' is in the range of [0.5, 1), or 0. That means the > exponent has to be able to be negative, when the original number was > negative. And it's certainly possible I was just confused... numerics are not my area of expertise, and I'll bow to Tim on this stuff regardless. -Fred -- Fred L. Drake, Jr. BeOpen PythonLabs Team Member From richard_chamberlain at my-deja.com Mon Jul 3 15:44:19 2000 From: richard_chamberlain at my-deja.com (richard_chamberlain at my-deja.com) Date: Mon, 03 Jul 2000 13:44:19 GMT Subject: making widgets invisible References: <3960794E.6E2B36E6@muc.das-werk.de> Message-ID: <8jq5bf$h45$1@nnrp1.deja.com> Hi Thomas, I'm sure there's a nicer way to do it (I'll ponder on it), but... from Tkinter import * root=Tk() def hideMe(): myButton.configure(text="",relief=FLAT) myButton=Button(root,text="Hide Me!",command=hideMe) myButton.pack() root.mainloop() You could pass the widget reference to the method so it would be universal - bit of pain to reverse though! Richard In article <3960794E.6E2B36E6 at muc.das-werk.de>, thiele at muc.das-werk.de wrote: > How can I realize that a set of widgets (buttons and entries) > is invisible when I don't need them and visible when I need them? > > One solution is to create a dialog window (or frame) and destroy it > then. > But is there a better one? > > Withdrawn works only with top level widgets. > > Thanks Thomas > Sent via Deja.com http://www.deja.com/ Before you buy. From alan.gauld at gssec.bt.co.uk Mon Jul 3 15:56:47 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Mon, 03 Jul 2000 14:56:47 +0100 Subject: [Tkinter]: Where is a good place to learn how to use this...? References: <20000630211051.11572.qmail@web5301.mail.yahoo.com> Message-ID: <39609B9F.ADFF5512@gssec.bt.co.uk> Dave Williams wrote: > I am fairly new to Python, and I have been reading a > book, and I have checked online for resources. There > is a general "intro to" type off of the python.org There should be two online sources from python.org. One is F/'s reference site which while not complete is very good - due out as a book from O'Reilly sometime... http://www.pythonware.com/library/tkinter/introduction/index.htm The other is the original(and slightly outdated) crash course on Tkinter called the 'Life Preserver' by Matt Conway http://www.python.org/doc/life-preserver/index.html The Mark Lutz book, Programming Python, has a good intro to Tkinter if you have no previous Tcl/Tk experience. John Grayson's book is fairly complete but does rather jump in the deep end. Its fine if you know the basics or if you've already used Tcl/Tk (or perl/Tk I guess) My Python tutor gives a couple of Tkinter examples but they are very basic and only cover enough for the specific programs. They aren't really intended to teach Tkinter. http://www.crosswinds.net/~agauld Look at Event Driven Progranmming and the Case Study Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From "rod" at REMOVETHISinf.bme.hu Mon Jul 3 16:09:25 2000 From: "rod" at REMOVETHISinf.bme.hu (Gabor Papp) Date: Mon, 03 Jul 2000 16:09:25 +0200 Subject: lambda requirements References: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> Message-ID: <39609ea1@news.caere.com> there's a section about this in the FAQ http://www.python.org/doc/FAQ.html#6.10 Gabor From neilh at scintilla.org Mon Jul 3 16:21:26 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 03 Jul 2000 14:21:26 GMT Subject: Is there a searchable archive of c.l.py Message-ID: When the recent thread on Aspect Oriented Programming started, I tried to find some earlier discussion of the subject that I remembered. I knew that Deja had dropped most of its older archives but tried anyway. The Python.org site recommended eGroups but while this has a complete record, searches do not go back very far. Maybe it is only partially indexed. None of the other sources were searchable. And none had a good way to download a large block of the archives so I could run a search on my own machine. Is there a sensibly searchable archive anywhere? In the future we will need this resource. Otherwise how will we know how we beat those nanoviruses back in '97? Neil From aahz at netcom.com Mon Jul 3 16:18:42 2000 From: aahz at netcom.com (Aahz Maruch) Date: 3 Jul 2000 14:18:42 GMT Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> Message-ID: <8jq7c2$2f8$1@slb6.atl.mindspring.net> In article <39606DAC.49A502DB at muc.das-werk.de>, Thomas Thiele wrote: > >The problem is I am using threads, fork and exec. And I want to have the >same behaviour using NT. You'll need to look at the Win32 extensions to do the fork/exec stuff. I've got zero experience with that, but hopefully either the docs are good enough or Mark Hammond will be by shortly. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From michael.husmann at teleatlas.com Mon Jul 3 16:17:35 2000 From: michael.husmann at teleatlas.com (Michael Husmann) Date: Mon, 03 Jul 2000 16:17:35 +0200 Subject: extracting tuples from a list Message-ID: <3960A07F.7240F23B@teleatlas.com> Is there a simple way to extract two elements from a list that has a size of 2n? I going this way: while list: i, k = list.pop(0), list.pop(0) Is there a better solution? Thanks Michael -- Michael Husmann p.A. Tele Atlas Deutschland GmbH, Postfach 77 77 77, D-31132 Hildesheim PHONE: +(49) 5121 49 4876, FAX: +(49) 5121 49 2866 e-mail: Michael.Husmann at teleatlas.com From alan.gauld at gssec.bt.co.uk Mon Jul 3 16:04:06 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Mon, 03 Jul 2000 15:04:06 +0100 Subject: Newbie question re: regsub References: <395fc90a$1_1@huge.aa.net> Message-ID: <39609D56.C710B311@gssec.bt.co.uk> Robert Goto wrote: > I am sure there is a very simple answer to this. > >>> import regsub > >>> fimo = open('fimo.txt') > >>> while 1: > line = fimo.readline() > if not line: break newline = regsub.gsub('orange', 'red', line) print newlineline > getting is both the original string and the changed string?! What you are getting is gsub displaying its output because you haven't assigned it to anything and then you print the original string. Assign the result of gsub() to a variable then print that variable(as shown above). Note that because strings are immutable in Python(ie can't be changed) gsub *returns* the new string it does not(cannot!) change 'line'. Alan g. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From dgoodger at bigfoot.com Mon Jul 3 16:17:07 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Mon, 03 Jul 2000 10:17:07 -0400 Subject: lambda requirements In-Reply-To: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> References: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> Message-ID: Lambda expressions don't have access to the local namespace. Declaring _list2 as global gets around this problem, but in an "unclean" way (note that _list1 doesn't need to be global, as it's not accessed inside the lambda). A cleaner way to implement the lambda (without globals, or "_"-prefixed local variables) is as follows: _onlylist1 = filter(lambda x, l=list2: x not in l, list1) "l" is bound to "list2" when the lambda expression is evaluated (when the local namespace *is* accessible), which carries through to when the resulting anonymous function is executed by filter (when SymmetricDifference's local namespace is *not* accessible). -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) on 2000-07-03 08:41, Wolfgang Thaemelt (wolfgang.thaemelt at orsoft.de) wrote: > Running the script: > > #----------------------------------------- begin of script > def SymmetricDifference(list1, list2): > # global _list1 > # global _list2 > > _list1 = list1 > _list2 = list2 > > _onlylist1 = filter(lambda x: x not in _list2, _list1) > > return _onlylist1 > > if __name__ == '__main__': > a = [1,2,3,4,5] > b = [3,4,5,6,7] > x = SymmetricDifference(a,b) > > print x > #---------------------------------------- end of script > > gives the error: > > Traceback (innermost last): > File "E:\up\000701\symmdiff.py", line 16, in ? > x = SymmetricDifference(a,b) > File "E:\up\000701\symmdiff.py", line 9, in SymmetricDifference > _onlylist1 = filter(lambda x: x not in _list2, _list1) > File "E:\up\000701\symmdiff.py", line 9, in > _onlylist1 = filter(lambda x: x not in _list2, _list1) > NameError: _list2 > > If the comment characters "#" are removed from the "global" statements > everything works fine. > > Is there some requirement on a lambda violated in the script? From matthias.huening at univie.ac.at Mon Jul 3 16:20:47 2000 From: matthias.huening at univie.ac.at (Matthias Huening) Date: Mon, 3 Jul 2000 16:20:47 +0200 Subject: Again: ODBC / Win98 -> crash Message-ID: <8jq7i6$395g$1@www.univie.ac.at> Some days ago I posted a problem with ODBC on my Win98-machine. I thought that it could be the win32-ODBC module that caused the crash I reported, so I switched to Marc-Andre Lemburg's mxODBC module. To keep it simple I give a minimal example (where dsn is a valid dsn): >>> import ODBC.Windows >>> db = ODBC.Windows.Connect(dsn) >>> db.close() Up to here, everything is fine. No problems so far. But when I do it again: >>> db = ODBC.Windows.Connect(dsn) I get an immediate crash of Python. My (German) version of Win98 tells me: PYTHONW verursachte einen Fehler durch eine ung?ltige Seite in Modul ODBCJT32.DLL bei 015f:04c0ac36. It seems like something isn't closed properly when I do db.close(). Any suggestions? Matthias From aahz at netcom.com Mon Jul 3 16:23:31 2000 From: aahz at netcom.com (Aahz Maruch) Date: 3 Jul 2000 14:23:31 GMT Subject: Is there a searchable archive of c.l.py References: Message-ID: <8jq7l3$f1e$1@slb0.atl.mindspring.net> In article , Neil Hodgson wrote: > > Is there a sensibly searchable archive anywhere? In the future we will >need this resource. Otherwise how will we know how we beat those nanoviruses >back in '97? Well, we've got the archive: http://www.python.org/pipermail/python-list/ Unfortunately, it only seems to go back to March '99. Does anyone maintain an older archive? Once we have the archive, making it searchable is a relatively trivial task. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From "rod" at REMOVETHISinf.bme.hu Mon Jul 3 16:24:26 2000 From: "rod" at REMOVETHISinf.bme.hu (Gabor Papp) Date: Mon, 03 Jul 2000 16:24:26 +0200 Subject: tracing a variable References: <395BEC23.9A3097F0@uniserve.com> Message-ID: <3960a227@news.caere.com> there's a trace method of tkinter variables. use like var.trace(ops, callback) 'callback' is called if 'var' is accessed in one of the ways given by ops. operations are the same as in tk ('w', 'r', 'u'). Gabor From gmcm at hypernet.com Mon Jul 3 16:28:21 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 14:28:21 GMT Subject: Memory leaks References: <395F78BF.CBEAA090@synacon.ch> Message-ID: <8F6667253gmcmhypernetcom@199.171.54.154> Ingo Adler wrote: [strange leaks in SWIG'd code] >I have some simple Python-Code which generated memory leaks (ca. 4MB): >(The real code is more complicated, but I could strip it down to this >simple example = the smallest example with the memory leak.) >//--------------------------- >x = X() > >for i in range(100000): > y = x.getY() > y.getNumber() >//--------------------------- Doing things in the "obvious" way from your (snipped) incomplete code, I get no leak when using MSVC 5. - Gordon From aahz at netcom.com Mon Jul 3 16:28:59 2000 From: aahz at netcom.com (Aahz Maruch) Date: 3 Jul 2000 14:28:59 GMT Subject: extracting tuples from a list References: <3960A07F.7240F23B@teleatlas.com> Message-ID: <8jq7vb$qo3$1@nntp9.atl.mindspring.net> In article <3960A07F.7240F23B at teleatlas.com>, Michael Husmann wrote: > >Is there a simple way to extract two elements from a list >that has a size of 2n? I going this way: > >while list: > i, k = list.pop(0), list.pop(0) > >Is there a better solution? How was the list created? Can you create it in such a way that each element is a tuple? Example: list = [] for line in file.readlines() list.append(FunctionThatReturnsATuple(line)) for item in list: (i,k) = item -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From thiele at muc.das-werk.de Mon Jul 3 16:36:03 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 16:36:03 +0200 Subject: making widgets invisible References: <3960794E.6E2B36E6@muc.das-werk.de> <8jq5bf$h45$1@nnrp1.deja.com> Message-ID: <3960A4D3.F45133B4@muc.das-werk.de> No I think this is not sooo nice. Becouse I want to replace the widget with others. mode One | not changing area | -------------------- | Label Entry Button | | | -------------------- and then I want to change the layout into: mode Two | not changing area | -------------------- | Entry Button Entry | | | -------------------- (For instance.) Just like an other dialog but within the mainframe. And I want to switch between the two modes. From gmcm at hypernet.com Mon Jul 3 16:42:32 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 14:42:32 GMT Subject: Again: ODBC / Win98 -> crash References: <8jq7i6$395g$1@www.univie.ac.at> Message-ID: <8F666B563gmcmhypernetcom@199.171.54.154> Matthias Huening wrote: >Some days ago I posted a problem with ODBC on my Win98-machine. I >thought that it could be the win32-ODBC module that caused the crash I >reported, so I switched to Marc-Andre Lemburg's mxODBC module. To keep >it simple I give a minimal example (where dsn is a valid dsn): > >>>> import ODBC.Windows >>>> db = ODBC.Windows.Connect(dsn) >>>> db.close() > >Up to here, everything is fine. No problems so far. >But when I do it again: > >>>> db = ODBC.Windows.Connect(dsn) > >I get an immediate crash of Python. > >My (German) version of Win98 tells me: > > PYTHONW verursachte einen Fehler durch eine ung?ltige Seite > in Modul ODBCJT32.DLL bei 015f:04c0ac36. > >It seems like something isn't closed properly when I do db.close(). >Any suggestions? All this points to it being the driver. That is, your dsn gets looked up, and the driver for the appropriate DB is loaded. Since that's the JET driver (ie, the one that translates ODBC to JET), you can thank your lucky stars that it works at all . Access behaves very poorly through ODBC. If you really have to use Access, you might find ADO more satisfactory. - Gordon From olivierS.dagenaisP at canadaA.comM Mon Jul 3 16:42:00 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 03 Jul 2000 14:42:00 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> Message-ID: How about a batch file called p.bat ? (with optional status messages) -----start p.bat-------- @echo off echo Starting script '%1.py' .... c:\progra~1\Python\python "%1.py" %2 %3 %4 %5 %6 %7 %8 %9 echo Execution complete! ----end p.bat----------- Given you have a script called "spam.py": -----start spam.py------ print "Spam spam spam spam" -----end spam.py-------- Then, you would type: c:\work\python\stuff>p spam Starting script 'spam.py' ... Spam spam spam spam Execution complete! Is that what you wanted?? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neo Brave" wrote in message news:8jp3pt$q7j$1 at nnrp1.deja.com... > In article , > "Mark Hammond" wrote: > > Under Windows NT or Win2k, you can use the PATHEXT environment > > variable. Simply add ".py" to the semi-colon sep'd list of > > extensions, and off you go! > > Great, thats a help for NT, but I also want to do this on Win98 :-). > > > No solution I am aware of for 95, although there are some tricks > > you can pull (Im sure someone else will fill these in for you)! > > Anyone??? > > Neo > -- > Neo Brave > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From kalle at gnupung.net Mon Jul 3 16:28:38 2000 From: kalle at gnupung.net (Kalle Svensson) Date: Mon, 3 Jul 2000 16:28:38 +0200 Subject: Random number generation, simple question. Message-ID: Hello. I have a few questions about the (pseudo) random number generator supplied in the standard library. I need 80 random bits (for a CipherSaber IV) but I hear most RNG's only supply 32 bits or less. My questions are: * How many random bits does whrandom.random() generate? * Suppose I do a loop where I get a byte at a time and then re-seed the generator either with random numbers from the generator or with values from time. Will that improve the randomness? * Are there better alternatives? I understand I could read from /dev/random on Linux, but this isn't portable, and even though I only use GNU/Linux myself, I have friends who don't. If anyone can tip me off about a similar feature in Win32, I could just detect platform and use the appropriate function, of course. I don't think I have to care about Macs or other *NIX dialects. Phew... :) Hope I'm making sense even though I hardly understand what I'm talking about... :) TIA, Kalle Svensson From piet at cs.uu.nl Mon Jul 3 16:50:38 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 03 Jul 2000 16:50:38 +0200 Subject: lambda requirements References: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> Message-ID: >>>>> "Wolfgang Thaemelt" (WT) writes: WT> Running the script: WT> #----------------------------------------- begin of script WT> def SymmetricDifference(list1, list2): WT> # global _list1 WT> # global _list2 WT> _list1 = list1 WT> _list2 = list2 WT> _onlylist1 = filter(lambda x: x not in _list2, _list1) WT> return _onlylist1 WT> if __name__ == '__main__': WT> a = [1,2,3,4,5] WT> b = [3,4,5,6,7] WT> x = SymmetricDifference(a,b) WT> print x WT> #---------------------------------------- end of script WT> gives the error: WT> Traceback (innermost last): WT> File "E:\up\000701\symmdiff.py", line 16, in ? WT> x = SymmetricDifference(a,b) WT> File "E:\up\000701\symmdiff.py", line 9, in SymmetricDifference WT> _onlylist1 = filter(lambda x: x not in _list2, _list1) WT> File "E:\up\000701\symmdiff.py", line 9, in WT> _onlylist1 = filter(lambda x: x not in _list2, _list1) WT> NameError: _list2 WT> If the comment characters "#" are removed from the "global" statements WT> everything works fine. WT> Is there some requirement on a lambda violated in the script? Python has only two scopes: the local variables of the function (which is the lambda in this case) and the global ones of the module. (O.K. the builtins also). There are no intermediate scopes visible, in your case that would be the local variables of SymmetricDifference. The usual trick is to copy these things as additional parameters of the lambda, where you can even use the same name. In your case only list2 has to be copied, there is no need to copy list1. Also the variable for the result is not needed, so this is a compacr definition that works: def SymmetricDifference(list1, list2): return filter(lambda x,_list2=list2: x not in _list2, list1) Using list2 rather than _list2 would also work. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From piet at cs.uu.nl Mon Jul 3 16:52:47 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 03 Jul 2000 16:52:47 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> Message-ID: >>>>> "Alex Martelli" (AM) writes: AM> Don Tuttle wrote in message AM> news:qJ165.8938$nZ5.153196 at typhoon.southeast.rr.com... >> Consider this a heads up NOT a promotion!! AM> Why would the Python community care about a Microsoft-proprietary AM> quasi-Java-clone...? It is not proprietary. They will put the language definition in the public domain. Maybe not the implementation. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From garry at sage.att.com Mon Jul 3 16:42:22 2000 From: garry at sage.att.com (Garry Hodgson) Date: Mon, 3 Jul 2000 14:42:22 GMT Subject: Tutorials at IPC9 References: <39591877.535A96BC@sage.att.com> <9i80ms4tbkjjhp90t55au011qquvmsr456@4ax.com> Message-ID: <3960A64E.E7794249@sage.att.com> Matt wrote: > > On Tue, 27 Jun 2000 21:11:19 GMT, Garry Hodgson > wrote: > > >I'm starting to think about what kinds of tutorials we should have at > >the next Python conference. > > Is there information available on when and where this will be? not yet. -- Garry Hodgson Every night garry at sage.att.com a child is born Software Innovation Services is a Holy Night. AT&T Labs - Sophia Lyon Fahs From gmcm at hypernet.com Mon Jul 3 16:57:28 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 14:57:28 GMT Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> <8F665C79Agmcmhypernetcom@199.171.54.154> <39608FE0.35950741@muc.das-werk.de> Message-ID: <8F666C0AEgmcmhypernetcom@199.171.54.154> Thomas Thiele wrote: >> >> You've got both technical and cultural problems here. There is no >> fork. > >I knew that. But I wonder how to start an other program. In UNIX I used >fork() and exec(). >Just the same code like in popen2.popen3 but I copied the code and >included some costumization. >Does popen work on NT? Or is there an other way do get the same result >(starting a program and >read it's output) All of the c runtime ways of starting processes have problems from annoying to catastrophic on Windows. The best of the lot is probably os.execv. os.popen works between well-behaved console processes on NT. If you want fine-grained control (including dup'ing your file descriptors etc.), use Win32process.CreateProcess from the Win32 extensions. Win32pipe.popen* use it to emulate os.popen*. But the real question is why are you doing this? While it's a common and reasonably efficient way of doing things on *nix, it is both rare and very expensive on Windows. From alex at magenta.com Mon Jul 3 16:43:00 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 16:43:00 +0200 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr><8jhuvn01vs0@news2.newsguy.com> <4.3.1.2.20000630145109.0201d9e0@phear.dementian.com> <8jplru0lfe@news2.newsguy.com> <962626013.769258863@news.libertysurf.fr> Message-ID: <8jq90e014sb@news2.newsguy.com> Jerome Quelin wrote in message news:962626013.769258863 at news.libertysurf.fr... > "Alex Martelli" wrote: > >These are excellent arguments for always using accessors from OUTSIDE the > >class. Jerome, however, was talking about using them from INSIDE the class > >as well, which is a different issue. > Sure, I'm always using accessors from outside. Bravo. One day you'll be happy you did. > But from inside the class, I don't know which is the best. I feel like the KISS > rule should apply, but what do you OO gurus think of it ? How far encapsulation > should go ? "Do the simplest thing that could possibly work". For a class not meant to be inherited from, that implies accessing the attributes directly until and unless very specific reasons emerge such that this "cannot possibly work" any more. It is quite unlikely that such reasons will ever emerge, and, if and when they ever do, then refactoring your program is not going to be a horribly huge cost to pay. 99+% of the time you will enjoy the simplicity and the resulting reduction in hassles, and the price of refactoring is not disproportionate in those cases where it will be needed. (The tradeoffs might be somewhat different in other languages, but dynamic ones such as Python strongly enable this excellent approach). Alex From matthias.huening at univie.ac.at Mon Jul 3 17:25:55 2000 From: matthias.huening at univie.ac.at (Matthias Huening) Date: Mon, 3 Jul 2000 17:25:55 +0200 Subject: Again: ODBC / Win98 -> crash References: <8jq7i6$395g$1@www.univie.ac.at> <8F666B563gmcmhypernetcom@199.171.54.154> Message-ID: <8jqbbn$38cc$1@www.univie.ac.at> Gordon McMillan: >Since that's the JET driver (ie, the one that translates ODBC to >JET), you can thank your lucky stars that it works at all . :-) >Access behaves very poorly through ODBC. If you really have to >use Access, you might find ADO more satisfactory. Well, it has to be Access for this project, but I certainly would like to get suggestions for better alternatives on Windows. (But it has to be as comfortable and simple as Access for my colleagues who only see and work with the database frontend.) Now for a really strange thing: I just moved my script to a different computer (almost identical configuration), and... - everything works just fine! No crashes, no problems whatsoever. I hate computers. Matthias From jerome.quelin at insalien.org Mon Jul 3 17:28:30 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Mon, 3 Jul 2000 17:28:30 +0200 Subject: making widgets invisible References: <3960794E.6E2B36E6@muc.das-werk.de> <8jq5bf$h45$1@nnrp1.deja.com> <3960A4D3.F45133B4@muc.das-werk.de> Message-ID: <962638110.1459980735@news.libertysurf.fr> Thomas Thiele wrote: >No I think this is not sooo nice. Becouse I want to replace the widget >with others. What about the pack_forget method ? -- File pack_forget.py #!/usr/bin/python from Tkinter import * class F(Frame): def __init__(self): Frame.__init__(self) Button(self,text='change', command=self.change).pack() self.f1 = Frame(self) self.f2 = Frame(self) Label(self.f1, text='eggs', bg='red').pack(side=LEFT) Label(self.f1, text='spam', bg='green').pack(side=LEFT) Label(self.f2, text='spam', bg='blue').pack(side=LEFT) Label(self.f2, text='eggs', bg='yellow').pack(side=LEFT) self.f1.pack() self.visible = 1 self.pack() def change(self): if self.visible == 1: self.f1.pack_forget() self.f2.pack() self.visible = 2 else: self.f2.pack_forget() self.f1.pack() self.visible = 1 F().mainloop() -- End of file The beauty of pack_forget is that it just unmaps the specified widget, and keeps the internal layout of the widget. Regards, Jerome -- jerome.quelin at insalien.org From jvickroy at sec.noaa.gov Mon Jul 3 17:37:36 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Mon, 03 Jul 2000 09:37:36 -0600 Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> <8jq7c2$2f8$1@slb6.atl.mindspring.net> Message-ID: <3960B33F.98B23C40@sec.noaa.gov> Mark isn't here yet but his book (Python Programming on Win 32) is and I quote (from page 35): " ... In many cases, the best solution is to rebuild this part of the application for Windows. On a typical Unix machine, creating new processes (as fork() does) is a relatively cheap operation. On Windows, howerver, the overhead of creating a new process is significant, so solutions using this architecture on Windows won't often scale or perform as you would hope. Rewriting this portion of the application to use multiple threads instead of multiple processes is often the best solution for Windows. " Aahz Maruch wrote: > In article <39606DAC.49A502DB at muc.das-werk.de>, > Thomas Thiele wrote: > > > >The problem is I am using threads, fork and exec. And I want to have the > >same behaviour using NT. > > You'll need to look at the Win32 extensions to do the fork/exec stuff. > I've got zero experience with that, but hopefully either the docs are > good enough or Mark Hammond will be by shortly. > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > The best way to get information on Usenet is not to ask a question, > but to post the wrong information. --Aahz From olivierS.dagenaisP at canadaA.comM Mon Jul 3 18:15:48 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 03 Jul 2000 16:15:48 GMT Subject: Random number generation, simple question. References: Message-ID: I'm not sure feeding "random" numbers as the seed will keep producing random numbers. You may want to try scanning different components of the computer, in order to retrieve values that, chances are, will be different from machine to machine and from time to time, like how many files are there on the computer, what the address of the network card is, how long has the machine been running, what keys has the user pressed, how has the mouse or joystick been moved, etc... ??? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Kalle Svensson" wrote in message news:Pine.GSO.4.21.0007031546410.25965-100000 at luna.dsv.su.se... > Hello. > > I have a few questions about the (pseudo) random number generator supplied > in the standard library. I need 80 random bits (for a CipherSaber IV) but > I hear most RNG's only supply 32 bits or less. My questions are: > > * How many random bits does whrandom.random() generate? > > * Suppose I do a loop where I get a byte at a time and then re-seed the > generator either with random numbers from the generator or with values > from time. Will that improve the randomness? > > * Are there better alternatives? I understand I could read from > /dev/random on Linux, but this isn't portable, and even though I only > use GNU/Linux myself, I have friends who don't. If anyone can tip me > off about a similar feature in Win32, I could just detect platform and > use the appropriate function, of course. I don't think I have to care > about Macs or other *NIX dialects. Phew... :) > > Hope I'm making sense even though I hardly understand what I'm talking > about... :) > > TIA, > Kalle Svensson > From Norman_Shelley-RRDN60 at email.sps.mot.com Mon Jul 3 17:58:14 2000 From: Norman_Shelley-RRDN60 at email.sps.mot.com (Norman Shelley) Date: Mon, 03 Jul 2000 08:58:14 -0700 Subject: UserDict and UserList issue (bug?_ References: <395D333D.9240593C@email.sps.mot.com> Message-ID: <3960B816.BC1B6577@email.sps.mot.com> Thomas Wouters wrote: > On Fri, 30 Jun 2000 16:54:37 -0700, Norman Shelley > wrote: > >in UserDict and UserList there is one or more places where a call to > >self's __class__() method is made, e.g. > > > >def __getslice__(self, i, j): > > i = max(i, 0); j = max(j, 0) > > # This class and its subclasses need more arguments then 0 > > userlist = self.__class__() > > .... > > >This blows causes major problems when either of these two classes are > >subclassed and the class which subclasses them requires creation > >arguments. I think maybe a copy of self instead of a __class__() may be > >a more robust solution. > > And how would you get a copy of self without creating a new instance of > self.__class__ ? Simple. import copy ... userlist = copy.copy(self) > You usually create a copy of a list by doing: > > mycopy = mylist[:] > > Which calls __getslice__, which is exactly what you are complaining about > :-) > > If you want to subclass UserList, either make sure you provide defaults for > all arguments to the initializer, or make sure you override all places where > self.__class__() may be called without your required arguments. #1 is > probably the best (and most portable) solution, and not just because of the > above issue: providing defaults for all initializer arguments allows your > object to be pickled, for instance ;) > > But I dont know why you need those arguments, so YMMV. > > Regards, > Thomas. From alex at magenta.com Mon Jul 3 17:31:43 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 17:31:43 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> Message-ID: <8jqbru017gf@news2.newsguy.com> wrote in message news:uhfa7qn9c.fsf at cs.uu.nl... > >>>>> "Alex Martelli" (AM) writes: > > AM> Don Tuttle wrote in message > AM> news:qJ165.8938$nZ5.153196 at typhoon.southeast.rr.com... > >> Consider this a heads up NOT a promotion!! > > AM> Why would the Python community care about a Microsoft-proprietary > AM> quasi-Java-clone...? > > It is not proprietary. They will put the language definition in the public > domain. Maybe not the implementation. OK, let's assume they do. And so...? It's a Java dialect in anything but name, and not a very interesting one either ("Pizza" added much more significant enhancements a LONG time ago, for example). I believe the only relevant issue for the Python community is: C#, like every other Microsoft offering in recent times, will be *STRONGLY* oriented to COM. Every C# object will be a COM object (just like every Java object was one when run under Microsoft's Java VM), etc, etc. So, C#'s possible (unlikely...) emergence as a major language is just the N-plus-1-th motivation for Windows versions of Python to support COM *very, VERY* well. There are many other reasons which apply *right now*, of course. Python's COM support is good, but I think it could be better. Type libraries are no doubt (at some point in the future) going to be obsoleted in favour of other, fuller meta-information, but until that happens I think any enhancement in support for them is going to be a very significant plus for Python, for example. Custom (non-dual) interfaces may be in decline, but, again, there is very substantial need for support for them *today* -- Python supports a lot of them, but, again, I'd like to see more -- more ease in interfacing a given set of interfaces to Python (maybe by autobuilding a .PYD for them?), more ease in generating 'stub' implementations for them to which Python substance can be added, ... Yeah, I know, I should put my coding efforts where my mouth is -- and, having expended substantial efforts doing just this sort of thing for a proprietary scripting language (which I'm pushing _hard_ to be "stabilized" in the future in favour of much better languages such as Python!), I do have the skills and experience... on the COM side of things, at least; haven't really looked at Python's internals yet, and it's been so long since I last programmed in C (as opposed to C++) that I wonder if I still can...:-). But anyway, that's my personal take on the C# "impact" (comparable to that of a goosedown pillow) on Python. Re .NET -- I dunno, and I wish I did! Any relevant URLs will be GRATEFULLY received - I could post a dozen, but I'll do y'all a favour and summarize them into basically two stances: "It's Microsoft and thus evil, vapourware, immoral, and/or fattening" "It's Microsoft and thus good, splendid, progressive, and/or sexy" Nothing REAL, TECHNICAL, DETAILED, nothing one could sink one's teeth into, sigh. Well, apart from XML, and SOAP in particular, but those we already knew as today's silver bullets (and, seriously, they do have real technical substance, of course; the more Microsoft's architectures get "open" by such means, the better -- but Python is already moving fast towards excellent support of XML and even SOAP, so there's no course-change in sight because of those, is there? Just, once again, extra motivation to do what's already being done). I do wonder what other items that have technical reality are in .NET besides C#, XML, and SOAP. If any, that is. Alex From thiele at muc.das-werk.de Mon Jul 3 18:28:55 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 18:28:55 +0200 Subject: making widgets invisible References: <3960794E.6E2B36E6@muc.das-werk.de> <8jq5bf$h45$1@nnrp1.deja.com> <3960A4D3.F45133B4@muc.das-werk.de> <962638110.1459980735@news.libertysurf.fr> Message-ID: <3960BF47.AF251B0B@muc.das-werk.de> > I think this pack_forget methode is what I was looking for. I'll try it. Thanks Thomas From akuchlin at mems-exchange.org Mon Jul 3 18:33:56 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 03 Jul 2000 12:33:56 -0400 Subject: Python CGI security References: Message-ID: <3dr99b5g23.fsf@kronos.cnri.reston.va.us> "E. Jordan Bojar" writes: > I'm interested in running a series of Python scripts via the Apache Python > module, mostly for dynamic content but possibly for password protection as > well. Are there security issues particular to (or common with) Python CGIs, > in the way that buffer overflow is so common to poorly-written Perl? Actually I'd expect that very few Perl security problems stem from buffer overflows, but instead come from improperly screening user input. (Taking the value of a field and blithely opening a file with the same name, for example, which is vulnerable to values such as ../../../etc/passwd.) Similarly, while there may be buffer overflows inside the Python interpreter that should be fixed, I'd be far more worried about the CGI/Apache code itself. --amk From thiele at muc.das-werk.de Mon Jul 3 18:32:17 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 18:32:17 +0200 Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> <8F665C79Agmcmhypernetcom@199.171.54.154> <39608FE0.35950741@muc.das-werk.de> <8F666C0AEgmcmhypernetcom@199.171.54.154> Message-ID: <3960C011.84B3D888@muc.das-werk.de> The program is the front-end of a job - management system. The program has to receive a user - command (via pickling over a tcp-socket connection) and execute a special program and evaluate the output. And this program runs on NT too. And so the starting server has to run on NT too. From jhe at webde-ag.de Mon Jul 3 18:40:25 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Mon, 3 Jul 2000 18:40:25 +0200 Subject: Random number generation, simple question. References: Message-ID: <8jqfis$eak$1@pollux.ip-plus.net> "Kalle Svensson" schrieb im Newsbeitrag news:Pine.GSO.4.21.0007031546410.25965-100000 at luna.dsv.su.se... > * Suppose I do a loop where I get a byte at a time and then re-seed the > generator either with random numbers from the generator or with values > from time. Will that improve the randomness? Certainly not. Seeding is done ONCE, always. What you should do is to call random() 80 times, and use the MSB only, i.e. "bit = random() < 0.5". Ciao, J?rgen -- J?rgen Hermann (jhewebde-ag.de) WEB.DE AG, Amalienbadstr.41, D-76227 Karlsruhe Tel.: 0721/94329-0, Fax: 0721/94329-22 From dpetrov at www.yu Mon Jul 3 18:50:49 2000 From: dpetrov at www.yu (Dean Petrov) Date: Mon, 3 Jul 2000 18:50:49 +0200 Subject: Selling software Message-ID: <8jqge7$irv$1@cer.yubc.net> !!! Software WareHouse !!! We're selling software! Best prices! Under $ 100 free shipping!!! Order today: dpetrov at www.yu From egbert at bork.demon.nl Mon Jul 3 17:17:23 2000 From: egbert at bork.demon.nl (Egbert Bouwman) Date: Mon, 3 Jul 2000 17:17:23 +0200 Subject: Books In-Reply-To: <8jpvhi$jfs$1@newshost.accu.uu.nl>; from Martijn Faassen on Mon, Jul 03, 2000 at 12:05:06PM +0000 References: <8jb1ec$9mh2@news.qualitynet.net> <8jpvhi$jfs$1@newshost.accu.uu.nl> Message-ID: <20000703171722.A7614@bork> On Mon, Jul 03, 2000 at 12:05:06PM +0000, Martijn Faassen wrote: > > I'm not sure how good Learning Python is at teaching OO concepts to people > who don't know about it yet. *Python* would be good though. Any opinions? > The PizzaRobot in Learning Python gave me a better idea what OO in Python is about, and what it can be used for, than anything else I have read so far. But it didn't teach me OO. Either I have to do a lot of thinking and experimenting myself, or I have to wait for a book with more ideas, concepts, design etc, and not in the first place tricks and techniques. Actually a great eye opener was the remark in this list a few days ago, when someone said that you use classes when you have to combine program and data, and functions when you have only program code. Or something like that. For what is a program without data. egbert -- Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991 ======================================================================== From mmorris at mindspring.com Mon Jul 3 18:41:54 2000 From: mmorris at mindspring.com (Mitchell Morris) Date: 3 Jul 2000 16:41:54 GMT Subject: Random number generation, simple question. References: Message-ID: <8F6665DDDbeablebeable@207.211.168.82> kalle at gnupung.net (Kalle Svensson) wrote in : >Hello. > >I have a few questions about the (pseudo) random number generator supplied >in the standard library. I need 80 random bits (for a CipherSaber IV) but >I hear most RNG's only supply 32 bits or less. My questions are: > > * How many random bits does whrandom.random() generate? I don't have the references from whrandom handy, but (a) I can flip through my Knuth book (flip, flip, flip) to see that there are several constants by which you can get an LCM to generate 2^32 values each of which could be 32 bits long, and (b) Wichmann-Hill is rather more advanced than an LCM, so 32 *2^32 should be considered a reasonable lower limit. Since you only need 80 or so, you should be okay. > * Suppose I do a loop where I get a byte at a time and then re-seed the > generator either with random numbers from the generator or with values > from time. Will that improve the randomness? The short answer is (a) no, that won't actually improve anything, and (b) it would be overkill anyway. All you need to do is: >>> import random >>> session_key = [] >>> for i in range(10): ... session_key.append(random.randint(0, 255)) and go about your business normally. The long answer is you can't generate randomness from nothing, which is what you're trying to do by reseeding your generator with output from your generator. If you really need more entropy, you need to find it somewhere else, perhaps by measuring some physical properties. To answer your next question, this is what /dev/random does ... it distills single bits of entropy by measuring a sheaf of physical properties as the system runs, then mixes them with the bits it already has, and doles them out to you when asked. There is a discussion about both of these in the design of Yarrow (http://www.counterpane.com/yarrow-notes.html) which may be of interest to you if you're looking to further your knowledge of your ignorance of generating pseudo-random numbers. > * Are there better alternatives? I understand I could read from > /dev/random on Linux, but this isn't portable, and even though I only > use GNU/Linux myself, I have friends who don't. If anyone can tip me > off about a similar feature in Win32, I could just detect platform and > use the appropriate function, of course. I don't think I have to care > about Macs or other *NIX dialects. Phew... :) > >Hope I'm making sense even though I hardly understand what I'm talking >about... :) > >TIA, > Kalle Svensson It's been a while since I looked at CipherSaber, but as I recall you only need entropy for the session key. You will probably find that almost any silly stupid PRNG will suffice for that, and most operating systems will provide you a silly stupid one. My knee-jerk response is don't use rand()/srand() if random()/srandom() are available. I suspect, and this is completely without analysis, that whrandom.random() will be more than enough for this exercise. If human lives are at stake, however, you really should try to educate yourself further so you can make your own analysis of the risks involved. HTH. HAND. +Mitchell From thor at localhost.localdomain Mon Jul 3 19:08:24 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 3 Jul 2000 17:08:24 GMT Subject: Socket problem Message-ID: I'm doing a game for my University. It's divided into 3 parts ( AI (clips), core(python), GUI(python)) communicated by sockets. I've been running it in Red Hat 4.2 happily. Now, I'm switching to Red Hat 6.0 and the core when trying to access to port 50008 it says: ocket.error: (99, 'Cannot assign requested address') Exception exceptions.AttributeError: 'conn' in ignored Exception exceptions.AttributeError: 'delete non-existing instance attribute' in ignored Where is the fault ? Thanks. -- MGA From montagne at boora.com Mon Jul 3 19:41:51 2000 From: montagne at boora.com (michael montagne) Date: Mon, 3 Jul 2000 10:41:51 -0700 Subject: WinNT User Name Message-ID: First off, I'm a newbie at Python. I'm trying to return the user who is logged on at a PC. What I really need is the login name. How do I do that? Seems like it otta be quite simple but I'm having trouble. -mjm From montagne at boora.com Mon Jul 3 19:47:30 2000 From: montagne at boora.com (michael montagne) Date: Mon, 3 Jul 2000 10:47:30 -0700 Subject: Web server executing Python scripts References: <2B1262E83448D211AE4B00A0C9D61B030130125E@msgeuro1.creo.be> <80EB8C0C818F320D.2A60B0748B6BCCB3.6A1C28BCC752E3D8@lp.airnews.net> Message-ID: How can I do that? I'd like to report on whether certain programs are installed on local PC's. -mjm "Cameron Laird" wrote in message news:80EB8C0C818F320D.2A60B0748B6BCCB3.6A1C28BCC752E3D8 at lp.airnews.net... > In article <2B1262E83448D211AE4B00A0C9D61B030130125E at msgeuro1.creo.be>, > Pieter Claerhout wrote: > >Hello all, > > > >I'm working on a web based system, which consist of a whole > >bunch of Python scripts, which connect to a bunch of machines > >on a network (either using ethernet or dailup networking) and > >execute some to code to for example get things from the > >windows registry of those machines. > > > >What do you think would be the best idea? > >- Use whatever webbrowser with CGI-scripting > >- Use MS IIS with ASP (and Python) > >- Use Zope to build the whole system? > > > >It should also connect to a database running on the host. > > > > > >Pieter > > > > Others have already demonstrated that there's a large > ... situational, if not subjective, component to the > decision about which Web server to use. > > Your first paragraph interests me. Do you realize > that Python can retrieve registry information directly > through your LAN, without a need for installation of > "some to code" on the reporting hosts? > -- > > Cameron Laird > Business: http://www.Phaseit.net > Personal: http://starbase.neosoft.com/~claird/home.html From david_ullrich at my-deja.com Mon Jul 3 19:37:45 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Mon, 03 Jul 2000 17:37:45 GMT Subject: Bug in math.frexp? References: <20000630221759.A1965@xyz.donetsk.ua> <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> Message-ID: <8jqj17$rl0$1@nnrp1.deja.com> In article <14688.12945.528521.351944 at cj42289-a.reston1.va.home.com>, "Fred L. Drake, Jr." wrote: > > Tim Peters writes: > > The docs are wrong. I just checked in a repaired version of mathmodule.c. > > Fred, would you please get the truth into the Library Reference Manual's > > math module docs too? > > --sigh-- > So are the Solaris and Linux man pages wrong, or just confusing? I found some Linux docs on this that said "If the argument x is not zero, the normalized fraction is x times a power of two, and is always in the range 1/2 (inclusive) to 1 (exclusive)." This is not just wrong or confusing, this is _impossible_ if x < 0; a negative number simply is not a power of two times a number in the range [1/2, 1). DU > Ok, I'll have something like your docstring checked in shortly. > > -Fred > > -- > Fred L. Drake, Jr. > BeOpen PythonLabs Team Member > > Sent via Deja.com http://www.deja.com/ Before you buy. From jhylton at my-deja.com Mon Jul 3 19:45:16 2000 From: jhylton at my-deja.com (jhylton at my-deja.com) Date: Mon, 03 Jul 2000 17:45:16 GMT Subject: Random number generation, simple question. References: Message-ID: <8jqjf8$s1t$1@nnrp1.deja.com> In article , Kalle Svensson wrote: > I have a few questions about the (pseudo) random number generator supplied > in the standard library. I need 80 random bits (for a CipherSaber IV) but > I hear most RNG's only supply 32 bits or less. The random number generator in the standard library is not at all suitable for generating a cipher key. In general, cryptography has a crucial requirement for random numbers that most other applications don't: It shouldn't be possible to guess or recover the state of the random number generator. In the case of the random module, if the attacker can guess or recover your inital seed, she can generate the entire sequence of random numbers that you use for your cipher. Bad stuff! I recommend looking at the Yarrow design by Kelsey, Schneier, and Ferguson: http://www.counterpane.com/yarrow.html A Python implementation of Yarrow-160 is included in the Pisces distribution: http://www.cnri.reston.va.us/software/pisces/manual/module-pisces.yarrow.html Jeremy Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Mon Jul 3 20:23:08 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 3 Jul 2000 14:23:08 -0400 Subject: Bug in math.frexp? In-Reply-To: <8jqj17$rl0$1@nnrp1.deja.com> Message-ID: Guys, this is not open to debate. frexp is a std ANSI C function, Python calls the platform frexp directly, and the new docstring I checked in is an exact paraphrase of the std in Pythonic language. I don't care what manpages say. I *would* care if somebody can show an actual example of a Python implementation where the examples posted do not work exactly as shown: that would mean the platform is buggy -- but the new docs are still correct . arrogant-but-with-cause-in-this-case-ly y'rs - tim From m.faassen at vet.uu.nl Mon Jul 3 20:18:22 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Jul 2000 18:18:22 GMT Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> <4.3.1.2.20000630145109.0201d9e0@phear.dementian.com> <8jplru0lfe@news2.newsguy.com> <962626013.769258863@news.libertysurf.fr> Message-ID: <8jqlde$n0e$1@newshost.accu.uu.nl> Jerome Quelin wrote: > "Alex Martelli" wrote: >>These are excellent arguments for always using accessors from OUTSIDE the >>class. Jerome, however, was talking about using them from INSIDE the class >>as well, which is a different issue. > Sure, I'm always using accessors from outside. > But from inside the class, I don't know which is the best. I feel like the KISS > rule should apply, but what do you OO gurus think of it ? How far encapsulation > should go ? I don't recall exactly, but the OO literature on this issue referes to the so-called 'Law of Demeter'. It comes in various weak and strong varieties which differ on this issue. So you may want to do a web-search on that. My personal opinion is that in Python you should not use accessors internally until it turns out to be necessary (which may never be). Python code is easy enough to change, after all. I don't even mind the occasional public use of attributes. Helped by unit tests this kind of thing can be changed to accessors fairly easily if necessary. Or I can of course go the __getattr__/__setattr__ route. I think the Pythonic way to think about this goes a bit like this: * sure, encapsulation is very important in good designs. * but, rapid prototyping is very important in coming up with good designs, as rapid prototyping allows you to change designs which turned out to be not good enough into better ones pretty easily. * good testing is important in any case. * if you have good testing and rapid prototyping, it's better to wait with various incantations (type checking, public/private, accessors) until they appear necessary, instead of doing them up-front and wasting time. It'll be likely you're wasting time as your up-front design will probably not be optimal yet in any case. Your incantations may turn out to be unnecessary in the first place! In my opinion the best solution to attribute access would be to add optional getter/setter methods to Python, much like Delphi's properties, or the facilities Sather and I hear C# provide. Such a facility can provide for a very clean path from direct attribute access to use of getters/setters. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From kmp at atrium.fsnet.co.uk Mon Jul 3 21:44:41 2000 From: kmp at atrium.fsnet.co.uk (Kenneth Payne) Date: Mon, 03 Jul 2000 19:44:41 GMT Subject: Problem Installing PyQt-012 References: <20000702.20095100@linux.local> Message-ID: <20000703.19444100@linux.local> Hi Martin - Well, I didn't run ldconfig, but I had set LD_LIBRARY_PATH. I didn't specify qtdir to the sip configure, but it seemed to find it (it was the X system it couldn't find). Anyway, I've tried both now - and I still have the same error. My commands were : in the sip directory - ./configure --with-qt-dir=/usr/lib/qt --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib make make install in the PyQT directory - ldconfig ./configure --with-qt-dir=/usr/lib/qt --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib make make install This looks suspicious in the sip configure output: . . checking for working aclocal... missing checking for working autoconf... missing checking for working automake... missing checking for working autoheader... missing checking for working makeinfo... found . . . checking for x... no . . Should I be looking to install aclocal, autoconf and automake? Would it be easier to install from rpms? By the way, I was on the noether site recently and was suprised (and pleased) to see my name on the Compuserve kppp script. Thanks. Of course, I'm no longer with compuserve (is anyone?). I've joined you on Freeserve. Best wishes -- Ken >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 02/07/00, 21:06:09, newsbunny at noether.freeserve.co.uk (Martin P Holland) wrote regarding Re: Problem Installing PyQt-012: > On Sun, 02 Jul 2000 20:09:51 GMT, > Kenneth Payne wrote: > >I'm trying to install the Python bindings to Qt/KDE. I've downloaded > >the latest sources for Sip. PyQT and pyKDE. I've compiled and > >installed Sip and compiled PyQT. All seemed to go Ok, though I had to > >fiddle a bit to get them to compile on Suse 6.3. However, on the "make > >install" for PyQt, I get an error when the install routine hits a > >Python script: > > > >Traceback (innermost last): > > File "", line 1, in ? > > File "/usr/lib/python1.5/qt.py", line 16, in ? > > import libqtc > >ImportError: /usr/lib/python1.5/lib-dynload/libqtcmodule.so: undefined > >symbol: __ti8sipProxy > >make[3]: *** [install-data-hook] Error 1 > >make[2]: *** [install-data-am] Error 2 > >make[1]: *** [install-am] Error 2 > >make: *** [install-recursive] Error 1 > Did you run ldconfig after installing sip? > Did you specify the qtdir to ./configure when compiling sip? > atb > Martin > -- > http://www.noether.freeserve.co.uk > http://www.kppp-archive.freeserve.co.uk From richard_chamberlain at ntlworld.com Mon Jul 3 20:52:52 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Mon, 3 Jul 2000 19:52:52 +0100 Subject: WinNT User Name References: Message-ID: Hi Michael, You'll need the win32 extensions - http://starship.python.net/crew/mhammond/ import win32api login=win32api.GetUserName() Richard import win32api michael montagne wrote in message news:Ae485.94210$5k2.194235 at dfw-read.news.verio.net... > First off, I'm a newbie at Python. > I'm trying to return the user who is logged on at a PC. What I really need > is the login name. How do I do that? Seems like it otta be quite simple > but I'm having trouble. > > -mjm > > From paul at prescod.net Mon Jul 3 20:57:14 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 03 Jul 2000 13:57:14 -0500 Subject: OO References: <8jb1ec$9mh2@news.qualitynet.net> <8jpvhi$jfs$1@newshost.accu.uu.nl> <20000703171722.A7614@bork> Message-ID: <3960E20A.4BA7AF49@prescod.net> Egbert Bouwman wrote: > > ... > > Actually a great eye opener was the remark in this list a few days ago, > when someone said that you use classes when you have to combine > program and data, and functions when you have only program code. Let me be more explicit about this. Classes are important when you want behavior to travel *with* the data. Procedural and functional styles are used where you want to impose behavior on "dumb" data. Real programs tend to use both styles. Often a procedural model is used to get data into the program where you combine the data with behavior in objects. When the behavior travels with the data (as methods), you can fiddle with the data without thinking much about its underlying implementation (through the methods). Therefore that underlying implementation can be really, really complex or really really simple and you don't care. It can also change between versions of the module and you still don't care. That's the encapsulation part of OO. You can actually do this pretty easily just with just functions (not methods), using a style of programming like this: obj=CreateNewObject() behavior1( obj, param1, param2, param3, ...) behavior2( obj, param1, param2, param3, ...) behavior2( obj, param1, param2, param3, ...) There are lots of APIs written in this style in non-OO languages. This is encapsulation (whether done in an OO language or not) The "polymorphism" part of OO comes from the fact that once you have an object, you can work on its methods without knowing exactly what kind of object you have. The Python library has lots of good examples of this but here's a beautiful example: class myOutputClass1: def write( self, data ): ...write it to a GUI window.... class myOutputClass2: def write( self, data ): ...write it to a log .... class myOutputClass3: def write( self, data ): ...send it via email to Bill Gates.... Now I can say sys.stdout=myOutputClass1() and hundreds of pieces of code that were supposed to work on the stdout "stream" will magically work on myOutputClass. When they say: sys.stdout.write( "foo" ), it calls the appropriate write method. The fact that it has the right methods is enough to make it "stand in" for a stream. This is much harder in a non-OO language because you have to "fake" the objects carrying around their behavior as methods. I think that polymorphism is really the heart of OO in Python. It's so important that some separate it out from the other OO stuff and just call it "genericity." The third part of OO is most emphasized in most non-Python languages: inheritance. Inheritance is a way of extending existing objects so that you do not have to write all of that code over again. In other languages, inheritance takes on some more mystical properties for the type system, but you could be a decent Python programmer and only use inheritance very, very rarely. According to the powers that be, these are the three main features of OO: encapsulation, polymorphism and inheritance. -- Paul Prescod - Not encumbered by corporate consensus The calculus and the rich body of mathematical analysis to which it gave rise made modern science possible, but it was the algorithm that made the modern world possible. - The Advent of the Algorithm (pending), by David Berlinski From wlfraed at ix.netcom.com Mon Jul 3 20:57:58 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 03 Jul 2000 11:57:58 -0700 Subject: Books References: <8jb1ec$9mh2@news.qualitynet.net> <8jpvhi$jfs$1@newshost.accu.uu.nl> Message-ID: <1ni1msc4fer3u6sm9blvjihql0inv9a1ba@4ax.com> On 3 Jul 2000 12:05:06 GMT, m.faassen at vet.uu.nl (Martijn Faassen) declaimed the following in comp.lang.python: > Dennis Lee Bieber wrote: > > > Beginners in programming; > > I saw others recommend Learning Python; I wouldn't do so for beginners > in programming. The Quick Python book or Python in 24 Hours seem to be > better suited for this. > I'm so far out of that stage I no longer know what I'd recommend -- other than /not/ C, C++, or some variant of BASIC (especially the one M$ is pushing -- seen the recent "learn VB6" books... apparently the "learning edition" of VB6 is too expensive, the books include a "working model" edition, which appears to be strictly an interpreter within the development environment with to capability for stand-alone programs). > > > beginners in OO... > > I'm not sure how good Learning Python is at teaching OO concepts to people > who don't know about it yet. *Python* would be good though. Any opinions? > I'm afraid I'm somewhat biased (and not too skilled in OOP either), but my background leads me to believe one should first learn OO concepts divorced from any particular language -- OO analysis and design -- and then translate the design into the particulars of an implementation language. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From boud at rempt.xs4all.nl Mon Jul 3 21:00:46 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 3 Jul 2000 19:00:46 GMT Subject: Problem Installing PyQt-012 References: <20000702.20095100@linux.local> <20000703.19444100@linux.local> Message-ID: <8jqnsu$m79$1@news1.xs4all.nl> Kenneth Payne wrote: > This looks suspicious in the sip configure output: > . > . > checking for working aclocal... missing > checking for working autoconf... missing > checking for working automake... missing > checking for working autoheader... missing > checking for working makeinfo... found > . > . > . > checking for x... no > . > . > Should I be looking to install aclocal, autoconf and automake? Would > it be easier to install from rpms? Well, I runs Suse 6.3, too (but compiled both KDE and Qt myself), and I have no problems compiling PyQt 0.12 either with Qt 1.44 or Qt 2.1.1, with Python 1.52 or Python 1.6alpha2, and when I compare my config.log with yours, I notice that I _do_ have aclocal, autoconf, automake and autoheader - I'd try installing them, they should be in your distribution. Otherwise, you're the second person I've seen with those errors - maybe it's something for Phil to look at. -- Boudewijn Rempt | http://www.valdyas.org From fplancke at my-deja.com Mon Jul 3 20:59:02 2000 From: fplancke at my-deja.com (Frédéric van der Plancke) Date: Mon, 03 Jul 2000 18:59:02 GMT Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> <962367319.379353174@news.libertysurf.fr> <395D79FE.4E4FDBCE@colconsulting.com> <8jplbd0l5c@news2.newsguy.com> Message-ID: <8jqnpe$vao$1@nnrp1.deja.com> In article <8jplbd0l5c at news2.newsguy.com>, "Alex Martelli" wrote: > Such "prohibition" is not hard at all: > > class dontderive: > def __init__(self): > if self.__class__ != dontderive: > raise "told you not to!" > > class foo(dontderive): > pass > #but... class bypassing_prohibition(dontderive): def __init__(self): pass eh = bypassing_prohibition() #this works because __init__ never automatically calls the __init__ #method of base classes... -- Frederic van der Plancke e-mail address: reverse and add dot-at-dot to: (I don't read regularly.) Sent via Deja.com http://www.deja.com/ Before you buy. From db3l at fitlinxx.com Mon Jul 3 21:20:27 2000 From: db3l at fitlinxx.com (David Bolen) Date: 03 Jul 2000 15:20:27 -0400 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> <395fbcd8$0$5627@wodc7nh0.news.uu.net> Message-ID: "donotspam-jen at personic.com" writes: > I checked out the link, but from what I read, it sounds like this is a > client-side implementation only. Is there more info on this somewhere? > Maybe some examples of how to use this? It can handle both client and server. The package has both the xmprpclib.py module (client) as well as a sample xmlrpcserver.py module (all 50 lines of it, excluding the preface comments). Just "borrow" the server example module, add your methods into the RequestHandler class and you're off. On the client side, it's no more than a single Server() instantiation, e.g.: server = xmlrpclib.Server("http://hostname") and then you can call any method you want directly, e.g.: server.myMethod(myParameters) any exceptions on the server side are trapped and and exception type and value are returned as a "fault" return code. BTW, this isn't much different from the other suggestions to subclass the HTTP server object (in fact that's what RequestHandler in the server example does), but the automatic translation back and forth from any Python objects into XML for transmission/receipt saves a lot of time in actually formatting and processing the request over the stream. -- -- 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 jvickroy at sec.noaa.gov Mon Jul 3 21:00:59 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Mon, 03 Jul 2000 13:00:59 -0600 Subject: WinNT User Name References: Message-ID: <3960E2EB.A5B1B256@sec.noaa.gov> On Windows NT: import os os.environ['USERNAME'] ... provides the information. I do not believe that either Win 95 or 98 has the 'USERNAME' attribute set. michael montagne wrote: > First off, I'm a newbie at Python. > I'm trying to return the user who is logged on at a PC. What I really need > is the login name. How do I do that? Seems like it otta be quite simple > but I'm having trouble. > > -mjm From db3l at fitlinxx.com Mon Jul 3 21:37:35 2000 From: db3l at fitlinxx.com (David Bolen) Date: 03 Jul 2000 15:37:35 -0400 Subject: Traping output from os.system References: <8jn34q$kpn$1@news.lth.se> Message-ID: "Mark Hammond" writes: > You want "popen". For non-windows platforms, "os.popen" is where you can > find it. For Win32 systems, you need the win32 extensions, and > "win32pipe.popen". Any chance that a future update to the extensions will be able to return the result code of the child process on a close(), as os.popen() does? -- -- 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 thomas at xs4all.nl Mon Jul 3 21:52:56 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 3 Jul 2000 19:52:56 GMT Subject: Bug in math.frexp? References: Message-ID: On Mon, 3 Jul 2000 14:23:08 -0400, Tim Peters wrote: >Guys, this is not open to debate. frexp is a std ANSI C function, Python >calls the platform frexp directly, and the new docstring I checked in is an >exact paraphrase of the std in Pythonic language. I don't care what >manpages say. I *would* care if somebody can show an actual example of a >Python implementation where the examples posted do not work exactly as >shown: that would mean the platform is buggy -- but the new docs are still >correct . Yes, yes, you're right. The posting that started this unnecessary discussion was both wrong and mine (I'm sorry, it was late ;P) but in my defense: I had intended to *mail* it to Fred, but my slrn (again) went on and had a life of its own. What I intended to say was 'the manpages I saw concur with Tim's docstringchange', but it 1) came out wrong, and 2) was wrong -- the manpages are confusingly phrased, just as Fred claimed. I had the best of intentions though ;) Apologizing-ly y'rs, From xiarcexml at yahoo.com Mon Jul 3 22:06:27 2000 From: xiarcexml at yahoo.com (Dave Williams) Date: Mon, 3 Jul 2000 13:06:27 -0700 (PDT) Subject: OO Message-ID: <20000703200627.5521.qmail@web5301.mail.yahoo.com> From fplancke at my-deja.com Mon Jul 3 21:59:45 2000 From: fplancke at my-deja.com (Frédéric van der Plancke) Date: Mon, 03 Jul 2000 19:59:45 GMT Subject: compilation References: <8jaht1$rui$5@bmerhc5e.ca.nortel.com> <8jdi5s$om4$1@nnrp1.deja.com> <8jfc7h$so4$1@bmerhc5e.ca.nortel.com> Message-ID: <8jqrb7$216$1@nnrp1.deja.com> In article <8jfc7h$so4$1 at bmerhc5e.ca.nortel.com>, msoulier at nortelnetworks.com wrote: > In article <8jdi5s$om4$1 at nnrp1.deja.com>, Fr?d?ric van der Plancke wrote: > > > >When the interpreter finds a xxx.pyc file on your Python path when > >you type 'import xxx', it loads that directly instead of recompiling > >xxx.py (provided xxx.py is older, and other soundness conditions) > > > >Is that what you want ? > > Umm, sort of. I guess the top-level script still has to be a .py file. I don't think it is needed. Python can check if a .pyc already exists for your top-level script. But I'm not 100% sure... -- Frederic van der Plancke e-mail address: reverse and add dot-at-dot to: (I don't read regularly.) Sent via Deja.com http://www.deja.com/ Before you buy. From montagne at boora.com Mon Jul 3 22:32:48 2000 From: montagne at boora.com (michael montagne) Date: Mon, 3 Jul 2000 13:32:48 -0700 Subject: WinNT User Name References: <3960E2EB.A5B1B256@sec.noaa.gov> Message-ID: thanks to you both..I knew it was easy. -mjm From ekw1 at my-deja.com Mon Jul 3 22:32:13 2000 From: ekw1 at my-deja.com (ekw1 at my-deja.com) Date: Mon, 03 Jul 2000 20:32:13 GMT Subject: mysql module for python under windows Message-ID: <8jqt8d$3do$1@nnrp1.deja.com> Is there a Python MySQL module for use under Windows? All the ones I come across on python.org are for Unix/Linux. Thanks for any info. ekw Sent via Deja.com http://www.deja.com/ Before you buy. From kmp at atrium.fsnet.co.uk Tue Jul 4 00:08:17 2000 From: kmp at atrium.fsnet.co.uk (Kenneth Payne) Date: Mon, 03 Jul 2000 22:08:17 GMT Subject: Problem Installing PyQt-012 References: <20000702.20095100@linux.local> <20000703.19444100@linux.local> <8jqnsu$m79$1@news1.xs4all.nl> Message-ID: <20000703.22081700@linux.local> Boudewijn - Thanks for your interest in my sip problem. I've installed autoconf and automake. This gets rid of all errors except the message about X (if that is an error) but I still get the same probelm on installing pyQT. My configure output for sip now looks like this : loading cache ./config.cache checking for a BSD compatible install... (cached) /usr/bin/ginstall -c checking whether build environment is sane... yes checking whether make sets ${MAKE}... (cached) yes checking for working aclocal... found checking for working autoconf... found checking for working automake... found checking for working autoheader... found checking for working makeinfo... found checking for a BSD compatible install... /usr/bin/ginstall -c checking for gcc... (cached) gcc checking whether the C compiler (gcc ) works... yes checking whether the C compiler (gcc ) is a cross-compiler... no checking whether we are using GNU C... (cached) yes checking whether gcc accepts -g... (cached) yes checking for c++... (cached) c++ checking whether the C++ compiler (c++ ) works... yes checking whether the C++ compiler (c++ ) is a cross-compiler... no checking whether we are using GNU C++... (cached) yes checking whether c++ accepts -g... (cached) yes checking for bison... (cached) bison -y checking how to run the C preprocessor... (cached) gcc -E checking for flex... (cached) flex checking for flex... (cached) flex checking for yywrap in -lfl... (cached) yes checking lex output file root... (cached) lex.yy checking whether yytext is a pointer... (cached) yes checking host system type... i686-pc-linux-gnu checking build system type... i686-pc-linux-gnu checking for ranlib... (cached) ranlib checking for ld used by GCC... (cached) /usr/i486-linux/bin/ld checking if the linker (/usr/i486-linux/bin/ld) is GNU ld... (cached) yes checking for BSD-compatible nm... (cached) /usr/bin/nm -B checking whether ln -s works... (cached) yes loading cache ./config.cache within ltconfig checking whether ln -s works... (cached) yes checking for ranlib... (cached) ranlib checking for strip... (cached) strip checking for objdir... .libs checking for object suffix... (cached) o checking for executable suffix... (cached) no checking for gcc option to produce PIC... (cached) -fPIC checking if gcc PIC flag -fPIC works... (cached) yes checking if gcc static flag -static works... (cached) yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.lo... yes checking if gcc supports -fno-rtti -fno-exceptions ... yes checking if the linker (/usr/i486-linux/bin/ld) is GNU ld... yes checking whether the linker (/usr/i486-linux/bin/ld) supports shared libraries... yes checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking for /usr/i486-linux/bin/ld option to reload object files... -r checking dynamic linker characteristics... Linux ld.so checking command to parse /usr/bin/nm -B output... ok checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes creating libtool loading cache ./config.cache checking for the Qt meta object compiler... /usr/lib/qt/bin/moc checking for the Qt include files... /usr/lib/qt/include checking for the Qt library files... /usr/lib/qt/lib checking for X... no checking for -fno-exceptions... yes checking for Python 1.5 include files... /usr/include/python1.5 creating ./config.status creating Makefile creating sip/Makefile creating siplib/Makefile creating sip.spec creating config.h config.h is unchanged If all this seems correct, perhaps the error is in the configure for the PyQT sources. Should I concentrate on that? By the way, I tried installing the rpm for sip, but it requires a later version of libstdc than mine. I get the error : failed dependencies: libstdc++-libc6.1-2.so.3 is needed by sip-0.12-1 It's at least comforting to know that it is possible to run these python / KDE bindings on SUSE 6.3 Thanks again for your interest. Best wishes -- Ken >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 03/07/00, 19:00:46, boud at rempt.xs4all.nl (Boudewijn Rempt) wrote regarding Re: Problem Installing PyQt-012: > Kenneth Payne wrote: > > This looks suspicious in the sip configure output: > > . > > . > > checking for working aclocal... missing > > checking for working autoconf... missing > > checking for working automake... missing > > checking for working autoheader... missing > > checking for working makeinfo... found > > . > > . > > . > > checking for x... no > > . > > . > > Should I be looking to install aclocal, autoconf and automake? Would > > it be easier to install from rpms? > Well, I runs Suse 6.3, too (but compiled both KDE and Qt myself), > and I have no problems compiling PyQt 0.12 either with Qt 1.44 or Qt > 2.1.1, with Python 1.52 or Python 1.6alpha2, and when I compare my > config.log with yours, I notice that I _do_ have aclocal, autoconf, > automake and autoheader - I'd try installing them, they should be in > your distribution. Otherwise, you're the second person I've seen with > those errors - maybe it's something for Phil to look at. > -- > Boudewijn Rempt | http://www.valdyas.org From dale at out-think.NOSPAMco.uk Mon Jul 3 22:54:14 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 3 Jul 2000 21:54:14 +0100 Subject: Definative Documentation on Objects Message-ID: <8jqui2$9na$1@supernews.com> Where do I look for the definitive statement on object programming in Python? The "Python Reference Manual", as included in the distribution, is particularly hard work. I'm considering "Programming Python" by Mark Lutz but that's four years old. "Learning Python" is more recent but I'm worried that it might be pitched a bit low. I'm an experienced programmer but I need to quickly understand Python object programming. Any pointers to online or paper reference material gratefully received. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants From cut_me_out at hotmail.com Mon Jul 3 23:04:03 2000 From: cut_me_out at hotmail.com (Alex) Date: 03 Jul 2000 17:04:03 -0400 Subject: Definative Documentation on Objects References: <8jqui2$9na$1@supernews.com> Message-ID: Perhaps the tutorial? http://www.python.org/doc/tut/node11.html It all depends on what a definitive statement would be, I guess. Alex. From esko.lehtonen at pp.htv.fi Mon Jul 3 23:11:34 2000 From: esko.lehtonen at pp.htv.fi (Esko Lehtonen) Date: Tue, 04 Jul 2000 00:11:34 +0300 Subject: PyGtk again but with segfault Message-ID: <39610186.36BAFE88@pp.htv.fi> Sunday I asked about PyGTK's draw_array-method a stupid question:-) Now I have another, hopefully a stupid (=and easily solvable) too. from gtk import * from Numeric import * -- win = GtkWindow() darea = GtkDrawingArea() --- HEIGHT = 50 WIDTH = 50 BYTES = 3 rgbbuf = ones([HEIGHT, WIDTH, BYTES], UnsignedInt8) gc = self.win.get_style().white_gc drawable = self.darea.get_window() dither = GDK.RGB_DITHER_NORMAL x = 10 y = 10 rowstride = WIDTH * 3 draw_array(drawable, gc, x, y, dither, rgbbuf) Unfortunataly I got now segmentation fault when the C function is executed. I tried to examine where the problem is. From gdb I got: Program received signal SIGSEGV, Segmentation fault. 0x4039ec58 in gdk_draw_rgb_image () from /usr/lib/libgdk-1.2.so.0 All parameters to C function are correct. I checked it recompiling _gtkmodules.so with many many printf()... (There might be better ways, but I'm not used to debug C programs.) Still gdk_draw_rgb_image() function works well when called from C program. My system is Debian 2.2 potato with Python 1.5 and Gtk+ 1.2. Thank you again... -------------------------------------------------------------------- Esko Lehtonen WYSINWYG - What You See Is Never What You Get From scott at lund.com Mon Jul 3 22:57:04 2000 From: scott at lund.com (Scott Chapman) Date: Mon, 03 Jul 2000 13:57:04 -0700 Subject: Book for sale - Programming Python w/CD $30.00 + Shipping Message-ID: Email scott at lund.com if interested. Payment via PayPal preferred. From jhylton at my-deja.com Mon Jul 3 23:38:28 2000 From: jhylton at my-deja.com (jhylton at my-deja.com) Date: Mon, 03 Jul 2000 21:38:28 GMT Subject: Definative Documentation on Objects References: <8jqui2$9na$1@supernews.com> Message-ID: <8jr14j$69v$1@nnrp1.deja.com> In article <8jqui2$9na$1 at supernews.com>, "Dale Strickland-Clark" wrote: > Where do I look for the definitive statement on object programming in > Python? > > I'm considering "Programming Python" by Mark Lutz but that's four > years old. "Learning Python" is more recent but I'm worried that it\ > might be pitched a bit low. Learning Python has an excellent chapter on classes and object-oriented programming. I think it is your best bet. --Jeremy Hylton Sent via Deja.com http://www.deja.com/ Before you buy. From montagne at boora.com Mon Jul 3 23:51:04 2000 From: montagne at boora.com (michael montagne) Date: Mon, 3 Jul 2000 14:51:04 -0700 Subject: Python Object Browser Message-ID: I'm trying to use makepy on some common objects on my system. Word2000, Excel2000, etc. It doesn't seem to want ot work. When I go to the objects that are having trouble using the Python Object Browser, under the Type Library heading it says "The type info can n..="The type info can not be loaded". Does this mean it is unavailable? How do i fix this? -mjm From dale at out-think.NOSPAMco.uk Tue Jul 4 00:02:59 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 3 Jul 2000 23:02:59 +0100 Subject: Definative Documentation on Objects References: <8jqui2$9na$1@supernews.com> Message-ID: <8jr2iv$cn2$1@supernews.com> Now why didn't I find that! I've been looking all over the place and it was right under my nose. Thanks for the reply! -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Alex wrote in message news:etdu2e7j58c.fsf at w20-575-34.mit.edu... > > Perhaps the tutorial? > > http://www.python.org/doc/tut/node11.html > > It all depends on what a definitive statement would be, I guess. > > Alex. From iain at wombatzone.freeserve.co.uk Tue Jul 4 00:50:44 2000 From: iain at wombatzone.freeserve.co.uk (Iain Calder) Date: Mon, 03 Jul 2000 22:50:44 +0000 Subject: PyGtk again but with segfault References: <39610186.36BAFE88@pp.htv.fi> Message-ID: <396118C4.116790FA@wombatzone.freeserve.co.uk> Esko Lehtonen wrote: > > Sunday I asked about PyGTK's draw_array-method a stupid question:-) Now > I have another, hopefully a stupid (=and easily solvable) too. > > from gtk import * > from Numeric import * > -- > win = GtkWindow() > darea = GtkDrawingArea() > --- > HEIGHT = 50 > WIDTH = 50 > BYTES = 3 > rgbbuf = ones([HEIGHT, WIDTH, BYTES], UnsignedInt8) > > gc = self.win.get_style().white_gc > drawable = self.darea.get_window() > dither = GDK.RGB_DITHER_NORMAL > x = 10 > y = 10 > rowstride = WIDTH * 3 > > draw_array(drawable, gc, x, y, dither, rgbbuf) > > Unfortunataly I got now segmentation fault when the C function is > executed. At startup, before the first call to draw_array, you need to call push_rgb_visual(). HTH Iain Calder From MarkH at ActiveState.com Tue Jul 4 01:22:38 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 03 Jul 2000 23:22:38 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> <8jqbru017gf@news2.newsguy.com> Message-ID: <2f985.6708$Tb7.40527@news-server.bigpond.net.au> "Alex Martelli" wrote in message news:8jqbru017gf at news2.newsguy.com... > I believe the only relevant issue for the Python community > is: C#, like every other Microsoft offering in recent times, > will be *STRONGLY* oriented to COM. Every C# object will be > a COM object (just like every Java object was one when run > under Microsoft's Java VM), etc, etc. Its a little more complicated than that! > So, C#'s possible (unlikely...) emergence as a major language > is just the N-plus-1-th motivation for Windows versions of > Python to support COM *very, VERY* well. And that! > Yeah, I know, I should put my coding efforts where my mouth > is -- and, having expended substantial efforts doing just > this sort of thing for a proprietary scripting language Please do. Typelib work may be kicking off again (if I ever clear my inbox that is - sorry John - I havent forgotten you :-) A framework for calling arbitary vtable interfaces is also in place. So what you will find is that it needs less "framework" code, and more a motivated and skilled person to pull a few of these "late" pieces together. My motivation WRT win32com now is more towards keeping the status-quo - and helping _others_ change it :-) > Re .NET -- I dunno, and I wish I did! All will be revlealed after the PDC; less than 2 weeks. I can safely say (as this is a Python language newgroup and C# is apparently a "competing" language), the Python community will probably be more interested in .NET than in C#. _Quite_ a bit more :-) > I'll do y'all a favour and summarize them into basically > two stances: > "It's Microsoft and thus evil, vapourware, immoral, > and/or fattening" > "It's Microsoft and thus good, splendid, progressive, > and/or sexy" Well put :-) > I do wonder what other items that have technical reality > are in .NET besides C#, XML, and SOAP. If any, that is. There are - and a number of them. Mark. From MarkH at ActiveState.com Tue Jul 4 01:24:31 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 03 Jul 2000 23:24:31 GMT Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> <8jq7c2$2f8$1@slb6.atl.mindspring.net> <3960B33F.98B23C40@sec.noaa.gov> Message-ID: "j vickroy" wrote in message news:3960B33F.98B23C40 at sec.noaa.gov... > Mark isn't here yet but his book (Python Programming on Win 32) is and I quote > (from page 35): And that quote shows why I was staying out of it :-) Mark. From robin at jessikat.demon.co.uk Tue Jul 4 01:23:07 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 4 Jul 2000 00:23:07 +0100 Subject: tkinter hanging References: Message-ID: <+fF0kLAbBSY5Ewaz@jessikat.demon.co.uk> In article , Robin Becker writes >In article , Thomas Wouters > writes >>On Sun, 2 Jul 2000 15:25:21 +0100, Robin Becker >>wrote: >>>I'm having problems with zombie processes under win32 with a tkinter >>>linked against Tk 8.3. I seem to be exiting the mainloop ok and have >>>destroyed all subwindows and then the gui object itself, but >>>occasionally I still generate a zombie. I have checked that my after's >>>are cancelled and debug prints seem to show me exiting the script. >> ... Under Win95 + Python 1.6a2 this code hangs about 1 in 10 times when the gui is killed using the window manager. The output indicates that the mainloop is terminated, afters are cancelled and all the widgets are destroyed. Even so it seems to hang after printing 'sys.exit'. It is using the common Tk idiom of delayed polling with after, but the exit code makes strenuous efforts to remove any pending calls. Can anyone see what I'm doing wrong? #################### from Tkinter import * import string, sys, os, regex, telnetlib import traceback, time class CommandEntry(Entry): def __init__(self, master, partk, **kw): apply(Entry.__init__, (self, master), kw) class Gui: def __init__(self): self.tk = Tk() try: self._build() self._alive = 1 except: traceback.print_exc() self.destroy() def _build(self): self.tk.geometry("800x600") self.tk.title("Client") self.tk.protocol("WM_DELETE_WINDOW", self.close) self.after_id = [] tA = {'fg':'white','bg':'black','state':'disabled','height':20} tC = {'fg':'white','bg':'black','insertbackground':'yellow','insertwidth':2} if os.name != 'posix': # need tcl/tk 8.0 on windows fnt = ("Fixedsys", 12) tA['font'] = fnt tC['font'] = fnt self.txt = Text(self.tk,tA) self.entry = apply(CommandEntry,(self.tk, self), tC) # set up the scrollbar for the txt widget self.scrollVertical = Scrollbar(self.tk,orient=VERTICAL) self.txt.configure(yscrollcommand=self.scrollVertical.set) self.scrollVertical.config(command=self.txt.yview) self.scrollVertical.pack(side=RIGHT, anchor=E, fill=Y) self.entry.pack({'side': 'bottom', 'fill': 'both'}) self.entry.focus_set() self.txt.pack({'side': 'bottom', 'fill': 'both', 'expand': 1}) def mainloop(self): self.after_id.append(self.tk.after(100, self.iterate)) self.tk.mainloop() print 'mainloop end' def destroy(self): self._alive = 0 self.after_cancel() for w in ('scrollVertical','txt','entry','tk'): try: getattr(self,w).destroy() delattr(self,w) print '%s destroyed' % w except: traceback.print_exc() def iterate(self): if self.loop(): self.after_id.append(self.tk.after(50, self.iterate)) else: self.tk.quit() def after_cancel(self): while self.after_id!=[]: id = self.after_id[0] del self.after_id[0] try: self.tk.after_cancel(id) except: traceback.print_exc() def close(self,event=None): self._alive = 0 def loop(self): if not self._alive: return 0 try: pass except: traceback.print_exc() self._alive = 0 return self._alive if __name__ == '__main__': gui = Gui() gui.mainloop() print 'Exiting' gui.destroy() del gui while 1: time.sleep(1) print 'sys.exit' sys.exit() -- Robin Becker From swun at esec.com.au Tue Jul 4 01:51:03 2000 From: swun at esec.com.au (Sam Wun) Date: Tue, 04 Jul 2000 09:51:03 +1000 Subject: how to push data in to ssh in python? References: <395FF2D9.1B46251D@esec.com.au> Message-ID: <396126E7.B10A450B@esec.com.au> Oh yes, I actually print it to the stdout, and intended to use command "ssh -l swun hostname < out.dump" to send out.dump to the "hostname" in "swun" account, but I am not sure how to set up the "swun" account to receive this transaction. Thanks Sam. Thomas Wouters wrote: > On Mon, 03 Jul 2000 11:56:41 +1000, Sam Wun wrote: > > >Thanks > > Your question is incomplete. What do you want to do ? Did you look at > popen(), and is it not what you want ? Does ssh require the input to come > from a pseudo-terminal ? Can't you use a normal shell pipeline and make your > python script just 'print' what you want to output ? Are you encountering > difficulties with any of these ideas, or not finding the right documentation? > > Oh, and it's not necessary to post both in HTML and in plaintext.. Just > plaintext will do just fine ;) > > How-do-I-get-a-zilion-dollars-ly y'rs, > Thomas. -- Sam Wun Firewalls / Security OneGuard Senior Software Engineer Electronic Commerce eSec Limited Phone: +61 3 83715376 mailto:swun at eSec.com.au C++/JAVA/UNIX/OOP/OOD -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-list/attachments/20000704/a2f39ca6/attachment.htm From MarkH at ActiveState.com Tue Jul 4 01:30:34 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 03 Jul 2000 23:30:34 GMT Subject: Traping output from os.system References: <8jn34q$kpn$1@news.lth.se> Message-ID: > Any chance that a future update to the extensions will be able to > return the result code of the child process on a close(), as > os.popen() does? Unlikely that Bill or I will look into this. The problem is that the file object doesnt know anything about the popen child process. Personally, I would prefer to _remove_ win32pipe.popen's implementation, and re-write it in pure-python using the raw win32pipe functions - just to prove we can :-) And also so it would be easier to hack to do this sort of stuff, or cloned for "custom" requirements, etc. Mark. From spamfranke at bigfoot.de Tue Jul 4 02:15:01 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 04 Jul 2000 00:15:01 GMT Subject: mysql module for python under windows References: <8jqt8d$3do$1@nnrp1.deja.com> Message-ID: <39612aaa.15439725@news.btx.dtag.de> On Mon, 03 Jul 2000 20:32:13 GMT, ekw1 at my-deja.com wrote: >Is there a Python MySQL module for use under Windows? All the ones I >come across on python.org are for Unix/Linux. Thanks for any info. > >ekw > > >Sent via Deja.com http://www.deja.com/ >Before you buy. Hmm, dunno where to download it separately, but check out ZMySQLDA-1.2.0.tar.gz on the Zope site (www.zope.org). It contains MySQLdb-0.1.2 with some Windows patches already applied. I run it sucessfully with the lately GPLed MySQL-2.23.19 on Win98. All you need to do is to edit Setup.in, adjust the paths to your local MySQL installation, and run compile.py. If you don't have Visual Studio, mail me personally and I'll send you the files. No-warranties-of-course-ly y'rs Stefan From spamfranke at bigfoot.de Tue Jul 4 02:22:37 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 04 Jul 2000 00:22:37 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> <8jqbru017gf@news2.newsguy.com> <2f985.6708$Tb7.40527@news-server.bigpond.net.au> Message-ID: <39642dc0.16230059@news.btx.dtag.de> On Mon, 03 Jul 2000 23:22:38 GMT, "Mark Hammond" wrote: >A framework for calling arbitary vtable interfaces is also in place. I would *really* appreciate such a thing. Any pointers? Stefan From spamfranke at bigfoot.de Tue Jul 4 02:23:05 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 04 Jul 2000 00:23:05 GMT Subject: Socket problem References: Message-ID: <39652e57.16380596@news.btx.dtag.de> [Might be a repost..] On 3 Jul 2000 17:08:24 GMT, thor at localhost.localdomain (Manuel Gutierrez Algaba) wrote: > >I'm doing a game for my University. It's divided into 3 parts >( AI (clips), core(python), GUI(python)) communicated by sockets. Sorry, no help for your question, but just for interest - how do you interface with clips? Stefan From db3l at fitlinxx.com Tue Jul 4 02:59:27 2000 From: db3l at fitlinxx.com (David Bolen) Date: 03 Jul 2000 20:59:27 -0400 Subject: Traping output from os.system References: <8jn34q$kpn$1@news.lth.se> Message-ID: "Mark Hammond" writes: > > Any chance that a future update to the extensions will be able to > > return the result code of the child process on a close(), as > > os.popen() does? > > Unlikely that Bill or I will look into this. The problem is that the file > object doesnt know anything about the popen child process. Hmm, yeah, but couldn't the win32popen module just pass a different close routine (to PyFile_FromFile()) and then keep track of which file handles were for which pipe? True, it would have to manage that mapping, but could probably just use an internal dictionary for it :-) (Note I haven't actually tried this myself yet - just guessing from a few glances at the source) Ah, well - unfortunately exit codes are key for me, since the gate decisions. So I'll just keep valid consoles around for the moment :-) > Personally, I would prefer to _remove_ win32pipe.popen's implementation, > and re-write it in pure-python using the raw win32pipe functions - just to > prove we can :-) And also so it would be easier to hack to do this sort of > stuff, or cloned for "custom" requirements, etc. Makes sense - I may try that at the point where I need to get rid of thge consoles, although I'm definitely targeted at NT, so I get to avoid all the Win95/98 ugliness I keep hearing about :-) Doing it this way would probably make it easier to return an object that looked like a file object (although it wouldn't really be the actual type) but knew enough about how to access the child process during the close() operation. 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 neo_brave at my-deja.com Tue Jul 4 03:45:38 2000 From: neo_brave at my-deja.com (Neo Brave) Date: Tue, 04 Jul 2000 01:45:38 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> Message-ID: <8jrfjv$geg$1@nnrp1.deja.com> In article , "Olivier Dagenais" wrote: > How about a batch file called p.bat ? (with optional status messages) > > -----start p.bat-------- > @echo off > echo Starting script '%1.py' .... > c:\progra~1\Python\python "%1.py" %2 %3 %4 %5 %6 %7 %8 %9 > echo Execution complete! > ----end p.bat----------- > > Given you have a script called "spam.py": > > -----start spam.py------ > print "Spam spam spam spam" > -----end spam.py-------- > > Then, you would type: > > c:\work\python\stuff>p spam > Starting script 'spam.py' ... > Spam spam spam spam > Execution complete! > > Is that what you wanted?? Thanks. Thats an improvement on what I have been doing till now but its not quite as neat as the WinNT solution (which I've tried on WinNT and it works :-)). Maybe its time I bit the bullet and upgraded to NT. Neo -- Neo Brave Sent via Deja.com http://www.deja.com/ Before you buy. From rurban at sbox.tu-graz.ac.at Tue Jul 4 05:52:50 2000 From: rurban at sbox.tu-graz.ac.at (Reini Urban) Date: Tue, 04 Jul 2000 03:52:50 GMT Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> Message-ID: <39615d75.142572338@news> jhylton at my-deja.com wrote: >I recommend looking at the Yarrow design by Kelsey, Schneier, and >Ferguson: http://www.counterpane.com/yarrow.html If it comes to critical or important data I would NEVER rely on any PRNG ("pseudo is pseudo and never truly random") instead of some inpredictable hardware noise. There were some C libs around dealing with some special PC timer chips which can be abused for exactly that. such as the linux /dev/random pseudodevice or truerand.c "Physically random numbers (very nearly uniform)" by D. P. Mitchell, AT&T. This is portable. But I know only the perl Math::TrueRandom module. -- Reini Urban http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html From jmcbray at carcosa.net Tue Jul 4 05:44:53 2000 From: jmcbray at carcosa.net (Jason F. McBrayer) Date: 03 Jul 2000 23:44:53 -0400 Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> Message-ID: >>>>> "j" == jhylton writes: j> In article , j> Kalle Svensson wrote: >> I have a few questions about the (pseudo) random number generator >> supplied in the standard library. I need 80 random bits (for a >> CipherSaber IV) but I hear most RNG's only supply 32 bits or less. j> The random number generator in the standard library is not at all j> suitable for generating a cipher key. He's not using it to generate a cipher key, just an initialization vector that doesn't have to be too terribly random (its only purpose is to let you reuse the same real key in different messages). As I understand it (and according to the Cypersabre pages), you don't need anything better than the standard library's rng (though it's just as easy, if not easier, to read 10 bytes from /dev/random). -- +-----------------------------------------------------------+ | Jason F. McBrayer jmcbray at carcosa.net | | A flower falls, even though we love it; and a weed grows, | | even though we do not love it. -- Dogen | From MarkH at ActiveState.com Tue Jul 4 08:05:22 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 04 Jul 2000 06:05:22 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> <8jqbru017gf@news2.newsguy.com> <2f985.6708$Tb7.40527@news-server.bigpond.net.au> <39642dc0.16230059@news.btx.dtag.de> Message-ID: "Stefan Franke" wrote in message news:39642dc0.16230059 at news.btx.dtag.de... > On Mon, 03 Jul 2000 23:22:38 GMT, "Mark Hammond" wrote: > >A framework for calling arbitary vtable interfaces is also in place. > I would *really* appreciate such a thing. Any pointers? The extension is called "univgw" - for "Universal Gateway". Greg Stein started the work, and Bill Tutt has done the most recent round. The sources, including the MSVC project file can be found under CVS. The win32com developers list archives are probably a good source, too: http://mailman.pythonpros.com/mailman/listinfo/pycom-dev Further discussion is welcome on that list! Mark. From thomas at xs4all.net Tue Jul 4 08:34:59 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 4 Jul 2000 08:34:59 +0200 Subject: how to push data in to ssh in python? In-Reply-To: <396126E7.B10A450B@esec.com.au>; from swun@esec.com.au on Tue, Jul 04, 2000 at 09:51:03AM +1000 References: <395FF2D9.1B46251D@esec.com.au> <396126E7.B10A450B@esec.com.au> Message-ID: <20000704083459.C283@xs4all.nl> On Tue, Jul 04, 2000 at 09:51:03AM +1000, Sam Wun wrote: > Thomas Wouters wrote: > > > On Mon, 03 Jul 2000 11:56:41 +1000, Sam Wun wrote: > > > > >Thanks > > > > Your question is incomplete. What do you want to do ? Did you look at > > popen(), and is it not what you want ? Does ssh require the input to > > come from a pseudo-terminal ? Can't you use a normal shell pipeline and > > make your python script just 'print' what you want to output ? Are you > > encountering difficulties with any of these ideas, or not finding the > > right documentation? > Oh yes, I actually print it to the stdout, and intended to use command > "ssh -l swun hostname < out.dump" to send out.dump to the "hostname" in > "swun" account, but I am not sure how to set up the "swun" account to > receive this transaction. 'ssh' is 'secure shell'. If you give it no additional arguments, it spawns a new shell for you, on the remote machine. If you do give it more, it'll start that as a program on the remote machine. So, if you want ssh on the remote machine to dump the output to a file, you can probably do ssh -l login machine "cat > outfile.dump" or some such. The quotes are necessary, by the way, to make sure the '>' redirection is passed to ssh, not interpreted by your shell. But if you intend to cat a local file, why not scp the file instead ? scp outfile.dump login at machine: Your question is more of 'how do I use ssh' than 'how do I use python' ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From mtebeka at intel.com Tue Jul 4 08:21:53 2000 From: mtebeka at intel.com (Miki Tebeka) Date: Tue, 4 Jul 2000 09:21:53 +0300 Subject: Using an extention DLL Message-ID: Hello All, Maybe I missed it in the FAQ but: I've downloaded unicode.dll which is a unicode module (suprize, suprize :-) Now, what do I need to do in order to user it from Python? (Where to place it, how to load it, etc.) Thanks. Bye. ------------------------------------------------------------------------------ Smile, damn it, smile. (lambda (msg) (case msg ((name) "Miki Tebeka") ((email) "tebeka at lycosmail.com") ((homepage) "http://www.tebeka.freeservers.com") ((quote) "I don't suffer from insanity, I enjoy every minute of it."))) From dnotspam-jen at personic.com Tue Jul 4 08:58:57 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Mon, 3 Jul 2000 23:58:57 -0700 Subject: Equivalent to ppm for Python? Message-ID: <3961881d$0$20233@wodc7nh6.news.uu.net> Is there anything like PPM for Python? For those who don't know, PPM is the Perl Package Manager (http://www.activestate.com/Support/ActivePerl/PPM.html). PPM is a utility that will go out and download and install packages for you from the Internet (at least on Win32 -- I assume it works elsewhere, too). Jen From horst at proceryon.at Tue Jul 4 09:25:41 2000 From: horst at proceryon.at (Horst Gassner) Date: Tue, 04 Jul 2000 09:25:41 +0200 Subject: Performance Message-ID: <39619175.5F8B503D@proceryon.at> Hi all! I have implemented a tree view with special items (the base for this work was the TreeWidget from IDLE). The performance is not the best and therefore I ran the profiler today. The following function is one of the slower ones and I would be happy if there are any possibilties to speed this thing up. subItems = {} if s.__subList[level] : for key in s.__subList[level].keys (): # root level is special case! # get all sublevels without recognizing id of sublevel if level==0 or string.find(key, id) == 0 : subItems[key] = s.__subList[level][key] The functions looks for all subitems for a given level and a given id. For each level I have pre-built a list that I have just to go through the items of the given level. Thanx in advance Horst From gritsch at iue.tuwien.ac.at Mon Jul 3 12:14:20 2000 From: gritsch at iue.tuwien.ac.at (Markus Gritsch) Date: Mon, 03 Jul 2000 12:14:20 +0200 Subject: Is there no function to convert a hex number to decimal? References: <395DB41F.85E51307@iue.tuwien.ac.at> Message-ID: <3960677C.BED04E21@iue.tuwien.ac.at> Markus Gritsch wrote: > Hi! > > Although there are several built in functions to convert numbers from > decimal to hex or oct, it seems that there is no function which can do > the same in the reverse direction. Of course I can write 0xff, but > what should I do, if I have a string containing a hex value? > Currently I use this brute code: > > hex_dec = {} > for i in range(256): > hex_dec[hex(i)[2:]] = i > > def dec(hex_string): > return hex_dec[string.lower(hex_string)] > > But I am not entirely happy with it, because I have to generate this > clumsy dict, and the function works only for two-digit-hex-numbers. > > Is there really no other way? I found the solution in the string module: atoi (s[, base]) and atol (s[, base]) BTW, these functions will become obsolete in python 2.0, because there will be an optional "base" argument to the built-in functions long() and int() -- |\/\/\/| /------------------------------------------------------------------\ | | | Markus GRITSCH | phone: +43 / 1 / 58801-36015 | | | | Institute for Microelectronics | cellular: +43 / 676 / 4973431 | | (o)(o) | Technical University of Vienna | fax: +43 / 1 / 58801-36099 | C _) | Gusshausstrasse 27-29 / E360 | email: gritsch at iue.tuwien.ac.at | | ,___| | A-1040 Vienna / AUSTRIA | SMS: 436764973431 at max.mail.at | | / \------------------------------------------------------------------/ /____\ / \ "Computers let you make more mistakes faster than any other invention in human history, with the possible exception of handguns and tequila." Mitch Radcliffe From mrinal at my-deja.com Tue Jul 4 09:41:06 2000 From: mrinal at my-deja.com (mrinal at my-deja.com) Date: Tue, 04 Jul 2000 07:41:06 GMT Subject: Worldpilot Message-ID: <8js4ef$v4n$1@nnrp1.deja.com> Hi, Has anybody tried Worldpilot here? I'm having issues with DateTime.py - it doesn't seem to work with my timezone (IST - +05:30). Has anybody worked around this problem? Any patches available for it? Please cc on replies.. -- Mrinal Kalakrishnan mrinal at india.com http://mrinal.dhs.org/ Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Tue Jul 4 09:40:14 2000 From: alex at magenta.com (Alex Martelli) Date: Tue, 4 Jul 2000 09:40:14 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> <8jqbru017gf@news2.newsguy.com> <2f985.6708$Tb7.40527@news-server.bigpond.net.au> Message-ID: <8js4jc09qf@news1.newsguy.com> Mark Hammond wrote in message news:2f985.6708$Tb7.40527 at news-server.bigpond.net.au... > "Alex Martelli" wrote in message > news:8jqbru017gf at news2.newsguy.com... > > > I believe the only relevant issue for the Python community > > is: C#, like every other Microsoft offering in recent times, > > will be *STRONGLY* oriented to COM. Every C# object will be > > a COM object (just like every Java object was one when run > > under Microsoft's Java VM), etc, etc. > > Its a little more complicated than that! Well, there's the "common runtime" library that's apparently going to be shared between all languages, as opposed to C++ having its own MSVCRT.DLL, VB having its own, etc (we did have that on IBM mainframes in the '70s, of course, but that's another issue:-); I guess Python may be able to take advantage of that. But I didn't see it as specifically a "C#" issue. What else...? > > So, C#'s possible (unlikely...) emergence as a major language > > is just the N-plus-1-th motivation for Windows versions of > > Python to support COM *very, VERY* well. > > And that! You mean that it will be COM+-as-originally-promised-lo-that- many-years-ago (with better metadata support, interceptors, etc), as opposed to the "COM+" which actually emerged without any of the really interesting promised features? But even then, again, I don't quite see it as a "C#" issue. What am I missing? > > Yeah, I know, I should put my coding efforts where my mouth > > is -- and, having expended substantial efforts doing just > > this sort of thing for a proprietary scripting language > > Please do. Typelib work may be kicking off again (if I ever clear my > inbox that is - sorry John - I havent forgotten you :-) A framework for > calling arbitary vtable interfaces is also in place. So what you will > find is that it needs less "framework" code, and more a motivated and > skilled person to pull a few of these "late" pieces together. My > motivation WRT win32com now is more towards keeping the status-quo - and > helping _others_ change it :-) Bill Tutt also wrote to me to the same effect, also suggesting I join the win32 com-developers mailing list. Turns out I've been on it for months, but the traffic is so low that I had forgotten. *Sigh* guess I'll have to look into "what do I need for CVS work from a Win32 box" and hope the comments in whatever material I do get from CVS are enough to explain what is it that needs to be done. > > Re .NET -- I dunno, and I wish I did! > > All will be revlealed after the PDC; less than 2 weeks. I can safely say Unfortunately I need to present my take on this to mgmt in just 1 week:-)... what (if any) IS the beef on .NET and what strategy (if any) do we as SW developers need to put in place to be ready (if it makes any difference to our products). Hoped I could find something to use to leverage Python into "major strategic effort" status around here, but, oh well. Guess I'll just keep trying to sneak it in instead (and/or wait for helpful email, if something can be mentioned in email and not on this group yet:-). > (as this is a Python language newgroup and C# is apparently a "competing" > language), the Python community will probably be more interested in .NET > than in C#. _Quite_ a bit more :-) Which at least implies there IS more to .NET than smoke and mirrors (and XML and SOAP) -- good to know. Wish I did know more... > > I'll do y'all a favour and summarize them into basically > > two stances: > > "It's Microsoft and thus evil, vapourware, immoral, > > and/or fattening" > > "It's Microsoft and thus good, splendid, progressive, > > and/or sexy" > > Well put :-) Thanks:-). > > I do wonder what other items that have technical reality > > are in .NET besides C#, XML, and SOAP. If any, that is. > > There are - and a number of them. Good! Now if I only knew what:-). Oh well, guess I'll wing the presentation based on "need to keep flexibility in such times of rapid change and uncertainty" and Python's excellence at such flexibility. Unfortunately our top mgmt is made up of smart guys _and_ they're wise to my ways, so I doubt this will fly (maybe I'd better come clean and confess I know there IS something but I don't know what and will they allow me one more month of research...?-). Alex From piet at cs.uu.nl Tue Jul 4 10:45:24 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 04 Jul 2000 10:45:24 +0200 Subject: Problem with redirection, buffering and chaining scripts. References: <395c3b52.183760656@nntp.interaccess.com> Message-ID: On Windows os.popen is broken. Get the Win32 extensions and use win32pipe.popen. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From gansevle at cs.utwente.nl Tue Jul 4 12:14:08 2000 From: gansevle at cs.utwente.nl (Fred Gansevles) Date: Tue, 04 Jul 2000 10:14:08 GMT Subject: Performance References: <39619175.5F8B503D@proceryon.at> Message-ID: <8jsdd9$51r$1@nnrp1.deja.com> In article <39619175.5F8B503D at proceryon.at>, Horst Gassner wrote: > Hi all! > > I have implemented a tree view with special items (the base for this > work was the TreeWidget from IDLE). > > The performance is not the best and therefore I ran the profiler today. > The following function is one of the slower ones and I would be happy if > there are any possibilties to speed this thing up. > > subItems = {} > if s.__subList[level] : > for key in s.__subList[level].keys (): > # root level is special case! > # get all sublevels without recognizing id of sublevel > if level==0 or string.find(key, id) == 0 : > subItems[key] = s.__subList[level][key] > > The functions looks for all subitems for a given level and a given id. > For each level I have pre-built a list that I have just to go through > the items of the given level. > You can speed things up by putting the special case outside the loop Another speedup is: use slices instead of string.find since you only match the first part of the key subItems={} if s.__subList[level]: if level == 0: # root level is special case subItems = s.__subList[level].copy() else: id_len = len(id) for key in s.__subList[level].keys (): if key[:id_len] == id: subItems[key] = s.__subList[level][key] This might improve things abot 5-10% depending on how often string.find would fail on finding the id. > Thanx in advance > Horst > -- ----------------------------------------------------------------------- ---- Linux/Windows-NT/IntraNetware Administrator ---- -- Whenever it sounds simple, I've probably missed something! ... Me -- ----------------------------------------------------------------------- Sent via Deja.com http://www.deja.com/ Before you buy. From pablo.prieto at dulcesol.es Tue Jul 4 13:41:23 2000 From: pablo.prieto at dulcesol.es (Pablo Prieto) Date: Tue, 04 Jul 2000 12:41:23 +0100 Subject: Equivalent to ppm for Python? References: <3961881d$0$20233@wodc7nh6.news.uu.net> Message-ID: <3961CD63.553F6D46@dulcesol.es> "donotspam-jen at personic.com" escribi?: > > Is there anything like PPM for Python? For those who don't know, PPM is the > Perl Package Manager > (http://www.activestate.com/Support/ActivePerl/PPM.html). PPM is a utility > that will go out and download and install packages for you from the Internet > (at least on Win32 -- I assume it works elsewhere, too). > > Jen Sorry. This is not a reply. Just a request for this question be answered since I'm interested in it too. Have a nice day. Pablo. From thomas at xs4all.net Tue Jul 4 12:46:04 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 4 Jul 2000 12:46:04 +0200 Subject: Is there no function to convert a hex number to decimal? In-Reply-To: <3960677C.BED04E21@iue.tuwien.ac.at>; from gritsch@iue.tuwien.ac.at on Mon, Jul 03, 2000 at 12:14:20PM +0200 References: <395DB41F.85E51307@iue.tuwien.ac.at> <3960677C.BED04E21@iue.tuwien.ac.at> Message-ID: <20000704124603.D283@xs4all.nl> On Mon, Jul 03, 2000 at 12:14:20PM +0200, Markus Gritsch wrote: > Markus Gritsch wrote: > > Although there are several built in functions to convert numbers from > > decimal to hex or oct, it seems that there is no function which can do > > the same in the reverse direction. Of course I can write 0xff, but > > what should I do, if I have a string containing a hex value? > I found the solution in the string module: > atoi (s[, base]) and atol (s[, base]) > BTW, these functions will become obsolete in python 2.0, because there > will be an optional "base" argument to the built-in functions long() and > int() Before we get a long discussion about backwards compatibility ;) I'd like to point out that the string.ato* functions might, in the strict sense, become obsolete, but that doesn't mean they are going to disappear. Rather, the string module is rewritten to use the builtin functionality: string.atoi() becomes a wrapper for int(). I doubt the string module will disappear before Py3K, and probably not until way after Py3K to boot. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From adetalabi at clara.co.uk Tue Jul 4 13:26:23 2000 From: adetalabi at clara.co.uk (Ade Talabi) Date: Tue, 04 Jul 2000 12:26:23 +0100 Subject: Socket problem References: Message-ID: <3961C9DF.6AFF4D3D@clara.co.uk> Manuel Gutierrez Algaba wrote: > > I'm doing a game for my University. It's divided into 3 parts > ( AI (clips), core(python), GUI(python)) communicated by sockets. > I've been running it in Red Hat 4.2 happily. > Now, I'm switching to Red Hat 6.0 and the core when > trying to access to port 50008 it says: > > ocket.error: (99, 'Cannot assign requested address') > Exception exceptions.AttributeError: 'conn' in > > ignored > Exception exceptions.AttributeError: > 'delete non-existing instance attribute' in > ignored > > Where is the fault ? > > Thanks. > > -- > MGA check that /etc/services has got the port set -- We see, whatever we want to see, whether visible or not - AT. June 2000. From m.faassen at vet.uu.nl Tue Jul 4 13:36:02 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jul 2000 11:36:02 GMT Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> Message-ID: <8jsi72$r02$1@newshost.accu.uu.nl> PM wrote: > My head hurts. I'm sorry to hear that. > If I move to Python from Java from RPG from C++ from C from Basic from > 6502, am I really, really, really, really stupid? I was not very good at > -any- of them, but I'm as persistent as a crap dance record on Radio 1. Persistence is important in a good programmer. :) I skipped Java and RPG and 6502 (I did Z80 there), insert some Pascal somewhere in the list and a smattering of other languages, but I don't consider myself stupid and came to Python. > Will this group answer all questions, It's decent at getting questions answered, yes. Not all. > solve life's problems? Unlikely. :) > Can Python kick large bottoms with decent database access - not just SQL > not ODBC, could it go to DB2/400? I don't have any experience with DB2/400, but I would imagine that if someone hadn't whipped something up already, it's possible to do so. > What I liked about good old DOS/basic was the ability to knock-things up > and try things out, now that's what has piqued my interest in Python, > but is it true.... Yes, Python is good for that kind of iterative style of programming; rapid prototyping is easy. Advantage above Basic is that the programming language is actually nice and powerful. > I'll probably waste some time trying to find out, Good -- have fun! > but I'm not 14 years old. Wish I was - and could still drive my Audi. I'm-not-14-years-old-either-and-don't-have-an-Audi-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From thomas at xs4all.net Tue Jul 4 13:55:04 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 4 Jul 2000 13:55:04 +0200 Subject: Equivalent to ppm for Python? In-Reply-To: <3961CD63.553F6D46@dulcesol.es>; from pablo.prieto@dulcesol.es on Tue, Jul 04, 2000 at 12:41:23PM +0100 References: <3961881d$0$20233@wodc7nh6.news.uu.net> <3961CD63.553F6D46@dulcesol.es> Message-ID: <20000704135504.E283@xs4all.nl> On Tue, Jul 04, 2000 at 12:41:23PM +0100, Pablo Prieto wrote: > "donotspam-jen at personic.com" escribi?: > > Is there anything like PPM for Python? For those who don't know, PPM is the > > Perl Package Manager > > (http://www.activestate.com/Support/ActivePerl/PPM.html). PPM is a utility > > that will go out and download and install packages for you from the Internet > > (at least on Win32 -- I assume it works elsewhere, too). > Sorry. This is not a reply. Just a request for this question be answered > since I'm interested in it too. While it's not exactly what you mean (it doesn't (yet) go out and grab packages for you), Distutils, which comes with Python 2.0, is probably what you are looking for. See the Distutils SIG on www.python.org. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From stephen_purcell at yahoo.com Tue Jul 4 14:34:53 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 04 Jul 2000 12:34:53 -0000 Subject: Performance In-Reply-To: <39619175.5F8B503D@proceryon.at> Message-ID: <8jslld+s3p0@eGroups.com> Horst Gassner wrote: > The following function is one of the slower ones and I would be happy if > there are any possibilties to speed this thing up. > > subItems = {} > if s.__subList[level] : > for key in s.__subList[level].keys (): > # root level is special case! > # get all sublevels without recognizing id of sublevel > if level==0 or string.find(key, id) == 0 : > subItems[key] = s.__subList[level][key] How about: subItems = {} if s.__subList[level]: for key,value in s.__subList[level].items(): if not level or not string.find(key,id): subItems[key] = value -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ "Life must be simple if I can do it" -- Me From alexandre.ferrieux at rd.francetelecom.fr Tue Jul 4 14:44:34 2000 From: alexandre.ferrieux at rd.francetelecom.fr (Alexandre Ferrieux) Date: Tue, 04 Jul 2000 14:44:34 +0200 Subject: Cross-frame 'security' (Internet Explorer and Python/COM) References: Message-ID: <3961DC32.2344@rd.francetelecom.fr> Roger Upole wrote: > > Here's a small sample of how to navigate to a URL. > >>> import win32com.client > >>> x=win32com.client.Dispatch('InternetExplorer.Application.1') > >>> x.Visible=1 > >>> x.Navigate('http://www.python.org') I've been doing something similar in some other scripting language (replace Python/win32com by Tcl/Optcl), and it worked quite well, however I've run into a show-stopper, and I would like to gather insights: The so-called cross-frame security issue. Once you've created the automation object x above, you can to some extent walk down the document tree. The problem is, if the page contains a frame which is hosted in some other 'domain' (the last two items in the DNS name), you simply can't access that subtree, even in read-only mode. In my case it was nasty because the sole purpose of the whole stuff was to reuse IE's parsing machinery to extract only text from the page -- a poor man's Lynx in a maximum-reuse context if you prefer. I've seen some explanations on the MS site (security bulletin and so on). The beginning of the story was the possibility for malevolent client-side code to insert its own text input box right on top of the one from a securized credit card number input dialog. This, sure enough, was a critical security hole. However, the counter attack doesn't make sense to me: why bar access to extradomain frames, even readonly, while the real issue was to prevent only *write* access (or visual overlay) of other frames ? Please please somebody enlighten me ! TIA, -Alex From alexandre.ferrieux at rd.francetelecom.fr Tue Jul 4 14:30:48 2000 From: alexandre.ferrieux at rd.francetelecom.fr (Alexandre Ferrieux) Date: Tue, 04 Jul 2000 14:30:48 +0200 Subject: Test results of linuxaudiodev.c References: Message-ID: <3961D8F8.983@rd.francetelecom.fr> Michael Hudson wrote: > > > dsp = linuxaudiodev.open("w") > > dsp.setparameters(au.getframerate(), au.getsampwidth() * 8, > > au.getnchannels(), formats[spec]) > > dsp.write(data) > > dsp.close() > > This doesn't work. I don't really understand why. Can you characterize "doesn't work" ? If by this you mean 'no errors, no sound', then probably the problem is that the close doesn't (by default) linger until all the queued data have been played - in which case success is just one ioctl() away... -Alex From scarblac-spamtrap at pino.selwerd.nl Tue Jul 4 15:15:50 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 4 Jul 2000 13:15:50 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> Message-ID: Neo Brave wrote in comp.lang.python: > In article , > "Mark Hammond" wrote: > > Under Windows NT or Win2k, you can use the PATHEXT environment > > variable. Simply add ".py" to the semi-colon sep'd list of > > extensions, and off you go! > > Great, thats a help for NT, but I also want to do this on Win98 :-). There is another trick (originally by Bruce Eckel). Name your Python file ".bat" instead of ".py" and use the following hack: @echo off rem = """ rem Run python on this bat file. Needs the full path where rem you keep your Python files. The -x causes Python to skip the first rem line of the file: python -x c:\python\\"%0".bat %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofpython rem """ # The Python program goes here: print "hello, python" # For the end of the batch file: rem = """ :endofpython rem """ Or just make a .bat file that goes with your .py file and calls python for it... -- Remco Gerlich, scarblac at pino.selwerd.nl 3:12pm up 120 days, 3:25, 5 users, load average: 0.33, 0.29, 0.20 From aahz at netcom.com Tue Jul 4 16:02:05 2000 From: aahz at netcom.com (Aahz Maruch) Date: 4 Jul 2000 14:02:05 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jqbru017gf@news2.newsguy.com> <2f985.6708$Tb7.40527@news-server.bigpond.net.au> <8js4jc09qf@news1.newsguy.com> Message-ID: <8jsqot$pj2$1@slb0.atl.mindspring.net> In article <8js4jc09qf at news1.newsguy.com>, Alex Martelli wrote: > >Good! Now if I only knew what:-). Oh well, guess I'll wing the >presentation based on "need to keep flexibility in such times of rapid >change and uncertainty" and Python's excellence at such flexibility. >Unfortunately our top mgmt is made up of smart guys _and_ they're wise >to my ways, so I doubt this will fly (maybe I'd better come clean and >confess I know there IS something but I don't know what and will they >allow me one more month of research...?-). Just tell them that a reliable source says that more info will be coming in two weeks and can you please have a three- or four-week extension on your presentation so you can present them with Microsoft's smoke'n'mirrors instead of your faked-up smoke'n'mirrors. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From alex at magenta.com Tue Jul 4 15:42:54 2000 From: alex at magenta.com (Alex Martelli) Date: Tue, 4 Jul 2000 15:42:54 +0200 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> <962367319.379353174@news.libertysurf.fr> <395D79FE.4E4FDBCE@colconsulting.com> <8jplbd0l5c@news2.newsguy.com> <8jqnpe$vao$1@nnrp1.deja.com> Message-ID: <8jsptm0sk7@news2.newsguy.com> Fr?d?ric van der Plancke wrote in message news:8jqnpe$vao$1 at nnrp1.deja.com... > In article <8jplbd0l5c at news2.newsguy.com>, > "Alex Martelli" wrote: > > > Such "prohibition" is not hard at all: > > > > class dontderive: > > def __init__(self): > > if self.__class__ != dontderive: > > raise "told you not to!" > > > > class foo(dontderive): > > pass > > > > #but... > > class bypassing_prohibition(dontderive): > def __init__(self): > pass > > eh = bypassing_prohibition() > > #this works because __init__ never automatically calls the __init__ > #method of base classes... You're perfectly right, of course. It's easy, but it can just as easily be fooled by the would-be-deriver. Python is not about programmers warring with each other, the framework supplier trying to stop things and the framework client finding clever workarounds; look into C++ or Java if you want that:-). If it were, the "if self.__class__" test might be repeated at entry of each method of dontderive, of course:-). This only reinforces my main contention that the best way to stop framework-users from deriving is a line or two to that effect in the documentation!-) Alex From esko.lehtonen at pp.htv.fi Tue Jul 4 16:09:21 2000 From: esko.lehtonen at pp.htv.fi (Esko Lehtonen) Date: Tue, 04 Jul 2000 17:09:21 +0300 Subject: PyGtk again but with segfault References: <39610186.36BAFE88@pp.htv.fi> <396118C4.116790FA@wombatzone.freeserve.co.uk> Message-ID: <3961F011.FFF27BA2@pp.htv.fi> Iain Calder wrote: > > At startup, before the first call to draw_array, you need to call > push_rgb_visual(). Oh. Of course... I should have read better the C example. Now I get my image displayed. Thank you twice! -------------------------------------------------------------------- Esko Lehtonen WYSINWYG - What You See Is Never What You Get From timaratz at lisco.com Tue Jul 4 16:48:12 2000 From: timaratz at lisco.com (Peter Timaratz) Date: Tue, 4 Jul 2000 09:48:12 -0500 Subject: Looking for Python CGI resources In-Reply-To: Message-ID: <000101bfe5c6$e0e73f80$24b745c6@timaratz> I have the book 'Learning Python' and now I'm looking for material oriented towards using Python for CGI. The only book that seems to cover this topic in any depth is 'Internet Programming With Python' and it is out of print. Is there any other CGI material available? From matthias.huening at univie.ac.at Tue Jul 4 16:55:02 2000 From: matthias.huening at univie.ac.at (Matthias Huening) Date: Tue, 4 Jul 2000 16:55:02 +0200 Subject: Looking for Python CGI resources References: <000101bfe5c6$e0e73f80$24b745c6@timaratz> Message-ID: <8jstua$2tk8$1@www.univie.ac.at> Peter Timaratz schrieb in im Newsbeitrag: 000101bfe5c6$e0e73f80$24b745c6 at timaratz... > I have the book 'Learning Python' and now I'm looking for material oriented > towards using Python for CGI. The only book that seems to cover this topic > in any depth is 'Internet Programming With Python' and it is out of print. > Is there any other CGI material available? > > Have a look at the 'Web Programming Topic Guide' http://www.python.org/topics/web/ on the Python-site. Matthias From e.smith at cs.bham.ac.uk Tue Jul 4 17:18:42 2000 From: e.smith at cs.bham.ac.uk (Elliot Smith) Date: Tue, 04 Jul 2000 16:18:42 +0100 Subject: Entry widgets Message-ID: <39620052.53C1@cs.bham.ac.uk> Hello all, I've tried this question before, and got no answer at all, so I thought I'd give it another go as the situation is getting desperate! I can't find any reference to this anywhere. I've been having problems with Entry widgets in Tkinter, running under sunos5. For some reason, when I double click on them, Python closes the whole application and reports 'Bus error'. Any ideas? I've tried overriding the binding for double mouse clicks to no avail. Elliot -- homepage: http://www.cs.bham.ac.uk/~ezs/ "A scholar is just a library's way of making another library" (Richard Dawkins) From cut_me_out at hotmail.com Tue Jul 4 17:41:33 2000 From: cut_me_out at hotmail.com (Alex) Date: 04 Jul 2000 11:41:33 -0400 Subject: Problem with dynamically linked extensions that use Numeric References: Message-ID: Just to follow up here, the problem was pointed out by Paul Dubois in another thread -- I need to do an import_array (); after the Py_InitModule. Alex. From tiddlerdeja at my-deja.com Tue Jul 4 18:07:16 2000 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Tue, 04 Jul 2000 16:07:16 GMT Subject: Java line to JPython (help Obj.class) Message-ID: <8jt239$jb3$1@nnrp1.deja.com> Can anyone help me turn this java line into JPython? URL dtdURL = DOMConfigurator.class.getResource("l"); The problem I'm getting is that DOMConfigurator doesn't seem to have attribute class. Is there a workaround? Any help appreciated. Sent via Deja.com http://www.deja.com/ Before you buy. From thor at localhost.localdomain Tue Jul 4 18:13:05 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 4 Jul 2000 16:13:05 GMT Subject: Socket problem References: <39652e57.16380596@news.btx.dtag.de> Message-ID: On Tue, 04 Jul 2000 00:23:05 GMT, Stefan Franke wrote: >[Might be a repost..] > >On 3 Jul 2000 17:08:24 GMT, thor at localhost.localdomain (Manuel Gutierrez Algaba) wrote: > >> >>I'm doing a game for my University. It's divided into 3 parts >>( AI (clips), core(python), GUI(python)) communicated by sockets. > >Sorry, no help for your question, but just for interest - how do you interface >with clips? expectk BTW, I've solved the problem, /sbin/ifconfig lo 127.0.0.1 did the trick. -- MGA From david_ullrich at my-deja.com Tue Jul 4 19:10:31 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Tue, 04 Jul 2000 17:10:31 GMT Subject: Bug in math.frexp? References: Message-ID: <8jt5ps$lte$1@nnrp1.deja.com> In article , "Tim Peters" wrote: > Guys, this is not open to debate. frexp is a std ANSI C function, Python > calls the platform frexp directly, and the new docstring I checked in is an > exact paraphrase of the std in Pythonic language. I don't care what > manpages say. I *would* care if somebody can show an actual example of a > Python implementation where the examples posted do not work exactly as > shown: that would mean the platform is buggy -- but the new docs are still > correct . Indeed. I haven't seen the new docs except for that docstring you posted - I was gonna suggest that maybe you might even want to be explicit about the fact that the _sign_ of the mantissa is the same as the sign of the argument (if it's already there never mind, all I saw was a statement about abs(mantissa), but I'm know to be sort of blind sometimes.) One might say of course that's what the sign of the mantissa is, what else makes sense. But you may as well be explicit - someone right here seemed to think that the sign of the _exponent_ should be the same as the sign of the argument. > arrogant-but-with-cause-in-this-case-ly y'rs - tim Don't look all that arrogant to me, which probably explains a lot. DU Sent via Deja.com http://www.deja.com/ Before you buy. From aa8vb at yahoo.com Tue Jul 4 20:23:16 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 04 Jul 2000 14:23:16 -0400 Subject: PIL: Can it work with large images? Message-ID: <20000704142316.A909732@vislab.epa.gov> Does PIL support cropping while loading large images? I'd like to pull in small portions of large GeoTIFF images for processing GeoTIFFs can be 100MB - multi-GBs in size. I have one here that's 340MB. Thanks, Randall > tiff_info.py filename : map.tif info : {'compression': 'raw'} mode : P size : (24758, 13716) <-------------------------------------<<< num tiles: 13716 tile #1: ('raw', (0, 0, 24758, 1), 56757, ('L', 0, 1)) tile #2: ('raw', (0, 1, 24758, 2), 81515, ('L', 0, 1)) ... -- Randall Hopper aa8vb at yahoo.com From embed at NOSPAM.geocities.com Tue Jul 4 20:42:18 2000 From: embed at NOSPAM.geocities.com (Warren Postma) Date: Tue, 4 Jul 2000 14:42:18 -0400 Subject: visual C++ giving runtime heap-check error in Py_Finalize(x) Message-ID: I have managed to get a repeatable (on my machine) version of either a reference count or other related kind of nasty bug in my embedded C++ application when I call Py_Finalize. The error I get is when trying to malloc some memory for a new object, the malloc call senses corruption of a previously freed block of memory, after the time it was last freed. here is the trace message that is printed out to the visual C++ output window: I get the following call stack: NTDLL! 77f9f9df() NTDLL! 77fcc8a1() NTDLL! 77f87aa3() NTDLL! 77fb3c33() NTDLL! 77fa7131() NTDLL! 77fca4cb() _free_base(void * 0x005d8a40) line 96 _free_dbg_lk(void * 0x005d8a60, int 0x00000001) line 1116 + 9 bytes _free_dbg(void * 0x005d8a60, int 0x00000001) line 1001 + 13 bytes free(void * 0x005d8a60) line 956 + 11 bytes string_dealloc() line 175 + 9 bytes PyString_Fini() line 1112 + 88 bytes Py_Finalize() line 242 What is happening is this: In PyString_Fini it is freeing the set of characters 0 to 255. When freeing character[17] I trace in, and it is calling the standard C method "free()" to release PyObject characters[17] which is the PyObject (string) memory at 0x5d8a90. As you can see above, some pointer mangling ends up happening. The reference count for the PyObject is 1 already, and the object itself does not appear to be corrupt. I added the line char *c = PyString_FromString( characters[i] ); just to see if I could still get the character values out of the strings, and they are all still there, and this string does not appear corrupt in any way but the heap debug code prints this warning and throws a debug exception: HEAP[myprogram.exe]: HEAP: Free Heap block 5d8a90 modified at 5d8ab8 after it was freed The funny thing is that there are no other threads in there, so if anything is modifying anything, then it's the malloc() code itself doing it. Has anybody else had a problem like this ever? Trick is, it does this both with my custom (statically linked) Python 1.5.2 and with the python15.dll also, so it's either (a) a bug in my code somewhere, probably one of my C extensions somewhere or (b) something weird in Python itself, which my code is causing to happen, but which is definitely a bug in 1.5.2. I am leaning towards (A) because it is 99.9999% of the time always my fault! :-) Warren Postma From dalke at acm.org Tue Jul 4 21:09:21 2000 From: dalke at acm.org (Andrew Dalke) Date: Tue, 4 Jul 2000 13:09:21 -0600 Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> <39615d75.142572338@news> Message-ID: <8jtcid$4um$1@nntp9.atl.mindspring.net> Reini Urban wrote: >There were some C libs around dealing with >some special PC timer chips which can be abused for exactly that. > >such as the linux /dev/random pseudodevice I was looking into this a few weeks ago. I was doing some CGI work in Perl and wanted to make sure the random number I used for the session id was hard to guess. If you call rand without calling srand, Perl will use a combination of the time (in microseconds, if available), PID, current stack size, value of the pointer passed to get the time, and several other values. What I saw, though, was a compile time option to use /dev/random if it exists. I would have thought that would be enabled by default, but it made some comment about how the read will block if there isn't enough entropy in the source pool. Is this ever a problem in real life? Andrew dalke at acm.org From embed at NOSPAM.geocities.com Tue Jul 4 21:34:10 2000 From: embed at NOSPAM.geocities.com (Warren Postma) Date: Tue, 4 Jul 2000 15:34:10 -0400 Subject: visual C++ giving runtime heap-check error in Py_Finalize(x) References: Message-ID: I figured it out. I also found this nifty trick. here it is, in case anyone else needs to track nasty malloc problems in their Visual C++ applications, most especially useful to me while Py_Finalize is running. I call SetSlowButThoroughDebugOptions() before Py_Finalize, and after it, I clear it with SetFastDebugOptions. This may turn out to be handy for anybody writing C extensions or hacking Python internals. Warren Postma ----- ----- ---------------------------------------- ----- ----- // setdebug.c // // set visual C++ runtime library heap-debug options // // see MSDN help topic "Using the Debug Heap from C++" and "Debug Routines" for more help // on the CrtSetDbgFlag and it's functions. // // version 0.1 warren postma // july 4, 2000 #include // Microsoft C Runtime Debug Options header. #ifdef _DEBUG void SetFastDebugOptions(void) { int tmpFlag; // Get the current state of the flag // and store it in a temporary variable tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); // Set the new state for the flag _CrtSetDbgFlag( tmpFlag ); } void SetSlowButThoroughDebugOptions(void) { int tmpFlag; // Get the current state of the flag // and store it in a temporary variable tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); // Always check at every allocation request: tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; // Leak Check Report tmpFlag |= _CRTDBG_LEAK_CHECK_DF; // Set the new state for the flag _CrtSetDbgFlag( tmpFlag ); } #endif ----- ----- ---------------------------------------- ----- ----- From ldwhitley at home.com Tue Jul 4 21:41:30 2000 From: ldwhitley at home.com (Larry Whitley) Date: Tue, 04 Jul 2000 19:41:30 GMT Subject: Python to C++ in a pickle Message-ID: I'd like to pickle an object in python and unpickle it in C++. The object in question is a python dictionary so it will have to go into a C++ map. Has someone done this and is willing to share? Or, is the cPickle source available on the web somewhere? Larry From petersc at stud.ntnu.no Tue Jul 4 23:57:39 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Tue, 04 Jul 2000 21:57:39 +0000 Subject: (s)re module code break Message-ID: <39625DD3.ED9BF9D7@stud.ntnu.no> I just noticed an issue with the new re module. Maybe it is old stuff, I don't know. Just to be sure: using re.compile yields a SRE_Pattern object (as of 2.0b1) whose method demands 3 arguments. There is a lot of code which lives happily just supplying 2 arguments and having count default to 0 (until 1.6a2). I added a 0 as third parameter and my program once again ran happily. Does anyone know if this behaviour of sre will persist? worried-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From jkraska1 at san.rr.com Tue Jul 4 21:58:21 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 04 Jul 2000 19:58:21 GMT Subject: Python to C++ in a pickle References: Message-ID: <396242AB.87D3795B@san.rr.com> Larry Whitley wrote: > > I'd like to pickle an object in python and unpickle it in C++. The object > in question is a python dictionary so it will have to go into a C++ map. > Has someone done this and is willing to share? Or, is the cPickle source > available on the web somewhere? To do this in a general way, you'll have to keep look-aside metadata and make certain that the pickling mechanism complies with the perceived types of information that are expected by your C++ client. I don't know anything about pickling, but I suspect it doesn't do this. Isn't cPickle source part of the python source distribution? I think so.... C/ From azz at gnu.org Tue Jul 4 16:07:08 2000 From: azz at gnu.org (Adam Sampson) Date: 04 Jul 2000 15:07:08 +0100 Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> Message-ID: <87og4eugz7.fsf@cartman.azz.net> Neo Brave writes: > > No solution I am aware of for 95, although there are some tricks > > you can pull (Im sure someone else will fill these in for you)! > Anyone??? How about this, saved in your PATH as hello.bat: rem = """ python wherever\hello.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 exit """ print "hello, world" # more Python code which can then be run by typing "hello"? -- Adam Sampson azz at gnu.org From digitig at cix.co.uk Tue Jul 4 23:23:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Tue, 4 Jul 2000 22:23 +0100 (BST) Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> Message-ID: In article <8jqjf8$s1t$1 at nnrp1.deja.com>, jhylton at my-deja.com () wrote: > In article , > Kalle Svensson wrote: > > > I have a few questions about the (pseudo) random number generator > supplied > > in the standard library. I need 80 random bits (for a CipherSaber IV) > but > > I hear most RNG's only supply 32 bits or less. > > I recommend looking at the Yarrow design by Kelsey, Schneier, and > Ferguson: http://www.counterpane.com/yarrow.html > > A Python implementation of Yarrow-160 is included in the Pisces > distribution: > http://www.cnri.reston.va.us/software/pisces/manual/module-pisces.yarrow > .html Beat me to it! Yes, that's the serious way forward for a crypto application. From NOSPAM_rdrew at cia-group.com Tue Jul 4 23:46:55 2000 From: NOSPAM_rdrew at cia-group.com (Ray Drew) Date: Tue, 4 Jul 2000 22:46:55 +0100 Subject: Can't get pythondoc to work Message-ID: <8jtm0o$6rv$1@soap.pipex.net> I can't get pythondoc to work. I've got pythondoc, pythondoc\formatters and pythondoc\xref in the pythonpath. When I try to run it on the test.py file I get a couple of module not found errors, even though they appear to be in the python path (I can import them interactively in PythonWin). When I try to run python pdoc.py test.py I get this traceback: D:\bin\cpython\Lib\pythondoc>python pdoc.py test.py Warning: Failed to import internalXref (exceptions.ImportError: No module named docobjects) Traceback (innermost last): File "pdoc.py", line 2, in ? import pythondoc.pythondoc File "pythondoc.py", line 81, in ? formatters.init(_options) File "formatters\__init__.py", line 4, in init init(__path__, options) File "formatters\format_init.py", line 25, in init import pythondoc.message ImportError: No module named message The pythonpath is: D:\bin\cpython\Lib\pythondoc>echo %pythonpath% d:\bin\cpython\lib;d:\bin\cpython\lib\Numeric;d:\bin\cpython\lib\htmldoc;d:\ bin\ cpython\lib\pythondoc;d:\bin\cpython\lib\pythondoc\formatters;d:\bin\cpython \lib \pythondoc\xref Python 1.5.2 on Windows 98 Can anyone see what I'm doing wrong? Thanks, Ray From slinkp23 at yahoo.com Tue Jul 4 19:47:28 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 04 Jul 2000 13:47:28 -0400 Subject: Postscript font metrics? Message-ID: <39622330.3732B225@yahoo.com> I need to generate some nice Postscript output from a python script, and I'm finding that I need to get at the font metrics info from the .afm files so I can place things correctly. (Either that or write *everything* in postscript -- no way!!) I can't find anything like this on Parnassus. Anyone ever seen any python code that gets the useful info from .afm files? If not, I might have a go at hacking the relevant parts of the Perl PostScript-Font-1.02 module into Python... but then I'll have to (yuck) read someone else's Perl code, which I haven't done in a looong time and I was never that good at it. -- ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.ulster.net/~abigoo A member of ARMS: http://www.reacharms.com or http://www.mp3.com/arms From wjdandreta at worldnet.att.net Wed Jul 5 02:22:30 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Wed, 05 Jul 2000 00:22:30 GMT Subject: Looking for Python CGI resources References: <000101bfe5c6$e0e73f80$24b745c6@timaratz> Message-ID: Hi Peter, I think I read somewhere that the second edition of IPWP is being worked on and I thought it was to be released this summer. Bill Peter Timaratz wrote in message <000101bfe5c6$e0e73f80$24b745c6 at timaratz>... >I have the book 'Learning Python' and now I'm looking for material oriented >towards using Python for CGI. The only book that seems to cover this topic >in any depth is 'Internet Programming With Python' and it is out of print. >Is there any other CGI material available? > > From chibaA at TinterlogD.Tcom Wed Jul 5 02:24:41 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Wed, 05 Jul 2000 00:24:41 GMT Subject: regex's Message-ID: <39627fa7.705005544@news1.on.sympatico.ca> Hi... I'm having a bit of a brain-tease... I have the following code (example): import re str = '123' if re.compile('1').match(str): print "matched 1" if re.compile('2').match(str): print "matched 2" if re.compile('3').match(str): print "matched 3" ------------------- I would think that this code would print 'matched 1 matched 2 matched 3'... But in this case, it would only printed "matched 1". Any reasons? Is there any way to have it print all three (since the conditions seem to be true)? Thanks in advance! kc. From johannes at zellner.org Wed Jul 5 03:08:26 2000 From: johannes at zellner.org (Johannes Zellner) Date: 5 Jul 2000 01:08:26 GMT Subject: history file Message-ID: Hello, is it possible to read and write a history file (e.g. ~/.python_history) ? -- Johannes From tim.hochberg at ieee.org Wed Jul 5 03:47:49 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 05 Jul 2000 01:47:49 GMT Subject: regex's References: <39627fa7.705005544@news1.on.sympatico.ca> Message-ID: chibaA at TinterlogD.Tcom writes: > Hi... I'm having a bit of a brain-tease... I have the following code > (example): > > import re > > str = '123' > if re.compile('1').match(str): > print "matched 1" > if re.compile('2').match(str): > print "matched 2" > if re.compile('3').match(str): > print "matched 3" > > ------------------- > > I would think that this code would print 'matched 1 matched 2 matched > 3'... But in this case, it would only printed "matched 1". Any > reasons? Is there any way to have it print all three (since the > conditions seem to be true)? re.match matches from the beginning of the string (e.g., re.compile('2').match(str) will only match strings starting with '2'. What you want is re.search. For example: #.... if re.compile('2').search(str): # ... You could also use: #.... if re.search('2', str): # ... However, the former will be faster if you reuse the regular expression since you can compile it once and reuse the compiled version. -tim > Thanks in advance! > > kc. From chibaA at TinterlogD.Tcom Wed Jul 5 03:53:38 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Wed, 05 Jul 2000 01:53:38 GMT Subject: regex's References: <39627fa7.705005544@news1.on.sympatico.ca> Message-ID: <396294ff.710469961@news1.on.sympatico.ca> Perfect! Thanks muchly! kc On Wed, 05 Jul 2000 01:47:49 GMT, Tim Hochberg wrote: >chibaA at TinterlogD.Tcom writes: > >> Hi... I'm having a bit of a brain-tease... I have the following code >> (example): >> >> import re >> >> str = '123' >> if re.compile('1').match(str): >> print "matched 1" >> if re.compile('2').match(str): >> print "matched 2" >> if re.compile('3').match(str): >> print "matched 3" >> >> ------------------- >> >> I would think that this code would print 'matched 1 matched 2 matched >> 3'... But in this case, it would only printed "matched 1". Any >> reasons? Is there any way to have it print all three (since the >> conditions seem to be true)? > >re.match matches from the beginning of the string (e.g., >re.compile('2').match(str) will only match strings starting with >'2'. What you want is re.search. For example: > >#.... >if re.compile('2').search(str): > # ... > >You could also use: > >#.... >if re.search('2', str): > # ... > >However, the former will be faster if you reuse the regular >expression since you can compile it once and reuse the compiled >version. > > >-tim > >> Thanks in advance! >> >> kc. > From stephen_purcell at yahoo.com Wed Jul 5 04:46:49 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 05 Jul 2000 02:46:49 -0000 Subject: Java line to JPython (help Obj.class) In-Reply-To: <8jt239$jb3$1@nnrp1.deja.com> Message-ID: <8ju7ip+ed4s@eGroups.com> tiddlerdeja at m... wrote: > Can anyone help me turn this java line into JPython? > > URL dtdURL = DOMConfigurator.class.getResource("l"); > > The problem I'm getting is that DOMConfigurator doesn't seem to have > attribute class. > > Is there a workaround? How about: dtdURL = DOMConfigurator.getResource('l') If DOMConfigurator is a Java class, then the JPython object 'DOMConfigurator' is equivalent to the 'DOMConfigurator.class' in Java. e.g., >>> import java.lang.Object >>> java.lang.Object -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From olivierS.dagenaisP at canadaA.comM Wed Jul 5 04:52:39 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 02:52:39 GMT Subject: Q: Client-server architecture Message-ID: What modules [or references] are there that explain or implement simultaneous, __secure__ operations on a server? I looked through http://www.python.org/topics/web/ and it seems to only cover HTTP, not HTTPS (using SSL or some other, secure protocol). I want to implement seemingly concurrent, remote database access and if I can queue the requests to the server, the server could then process requests, one at a time, and then "call back" each client with the results. I'm thinking I don't want to write the server side software using a CGI script, since the database package I'm looking into using (Gadfly) isn't designed for concurrent access, unless I don't understand how CGI works and it is synchronous? (I have only written very simple CGI scripts in Perl and C, so I'm sort of new to this) Any help (including corrections in my thinking of CGI or hints on handling many, simultaneous requests) would be appreciated. I'd like to write both the client and the server in Python. Thanks! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From olivierS.dagenaisP at canadaA.comM Wed Jul 5 05:03:01 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 03:03:01 GMT Subject: Q: Concurrent versionning Message-ID: Hi again... I'm looking into implementing a version control system on a database, so that individual rows (of select tables) can be versionned. (ie: make a copy of that row and increment the version field of the new one, then make changes) My question is regarding modules [or resources] that can detect and report line-level or paragraph-level differences between two text files, very much like the windiff tool provides. Are there such things, out there, already available? Not only that, but (as I'm accustomed to the SLM - aka Slime - version control system, the only one I've ever used) also the capability to merge two textfiles and to elegantly report merge conflicts, very much like "ssync" (again, part of SLM) will do. Maybe this is simple enough to implement, and I just need to understand some techniques in concurrent versionning, so any help would be appreciated. Thanks! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From djc at object-craft.com.au Wed Jul 5 05:18:30 2000 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2000 13:18:30 +1000 Subject: Undocumented regex behaviour in re module Message-ID: Consider the following program: - - re_test.py - - - - - - - - - - - - - - - - - - - - - - - - - - import re text = ''' Browse <?table?>

Browse

''' tags = re.compile(r'<\?(\w+)(\s+\w+=\w+)*\?>', re.I | re.M) match = tags.search(text) while match: print text[match.start():match.end()], '=>', match.groups() match = tags.search(text, match.end()) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The idea here is that I want to be able to extract the special tag names and their attributes. Everything work fine, except for tag: The match object only saves the last attr=value matched. The only way that I think of to get all of the attr=value returned is to change the regex to: <\?(\w+)((?:\s+\w+=\w+)*)\?> Unfortunately, that is not as useful as I would like since it returns a string which needs further processing: ' start=0 num=25' Any hint / explanation at this point would be gratefully accepted. - Dave From lull at acm.org Wed Jul 5 06:36:02 2000 From: lull at acm.org (John Lull) Date: 4 Jul 2000 23:36:02 -0500 Subject: Singleton COM local/remote server? Message-ID: <7bd5msssk48km280t9bvds4i3v6hs7r8or@4ax.com> I'm prototyping a DCOM server in Python. The server coordinates access from several clients scattered across a network to multiple devices hung off each of several interface ports. Some or all of it will likely be ported to C once we're satisfied the API is right, and as performance dictates. The server will have a single Coordinator object, a single Port object with its own thread for each port, a single Device object with its own thread for each device, multiple PortAccess objects to provide client access to each port object, and multiple DeviceAccess objects to provide client access to each device. Client programs will get access to the server via win32com.client.Dispatch('MyServer.Coordinator') (or the equivalent in another language), then request PortAccess and DeviceAccess objects from appropriate factory methods. I've got most of the innards worked out, figured out how to register it, wrap the access objects so I can hand out references to clients, etc, but -- Since each port can belong to at most one server, I cannot have multiple servers on the same machine. I can't figure out how to ensure there is only *one* copy of the server started, regardless of how many clients want to use it. Any samples, pointers to documentation, key phrases to search MSDN for, etc. would be *greatly* appreciated. Thank you. Regards, John From moshez at math.huji.ac.il Wed Jul 5 07:08:02 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 5 Jul 2000 08:08:02 +0300 (IDT) Subject: Python to C++ in a pickle In-Reply-To: Message-ID: On Tue, 4 Jul 2000, Larry Whitley wrote: > I'd like to pickle an object in python and unpickle it in C++. The object > in question is a python dictionary so it will have to go into a C++ map. > Has someone done this and is willing to share? Or, is the cPickle source > available on the web somewhere? Why use pickle? XML-RPC seems much better for this purpose. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From ralf.claus at teleatlas.com Wed Jul 5 07:04:31 2000 From: ralf.claus at teleatlas.com (Ralf Claus) Date: Wed, 05 Jul 2000 07:04:31 +0200 Subject: WinNT User Name References: Message-ID: <3962C1DF.43E3EBDB@teleatlas.com> michael montagne wrote: > > First off, I'm a newbie at Python. > I'm trying to return the user who is logged on at a PC. What I really need > is the login name. How do I do that? Seems like it otta be quite simple > but I'm having trouble. > > -mjm ..and finally import getpass username = getpass.getuser() works on both systems (NT,UNIX), if you need. From ralf.claus at teleatlas.com Wed Jul 5 07:07:13 2000 From: ralf.claus at teleatlas.com (Ralf Claus) Date: Wed, 05 Jul 2000 07:07:13 +0200 Subject: WinNT User Name References: Message-ID: <3962C281.405FB34E@teleatlas.com> michael montagne wrote: > > First off, I'm a newbie at Python. > I'm trying to return the user who is logged on at a PC. What I really need > is the login name. How do I do that? Seems like it otta be quite simple > but I'm having trouble. > > -mjm ..and finally import getpass username = getpass.getuser() works on both systems (NT,UNIX), if you need. From wjdandreta at worldnet.att.net Wed Jul 5 07:15:39 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Wed, 05 Jul 2000 05:15:39 GMT Subject: Python and .lib files Message-ID: <%vz85.6488$oh5.499440@bgtnsc04-news.ops.worldnet.att.net> Is it possible to call functions in a .lib file with Python? If so, what is the easiest way to do so? Bill From swun at esec.com.au Wed Jul 5 07:45:56 2000 From: swun at esec.com.au (sss) Date: Wed, 05 Jul 2000 15:45:56 +1000 Subject: DCOracle error Message-ID: <3962CB94.2DDA9AA9@esec.com.au> I don't know why I got this error when I try to install DCOracle in the Linux machine. I've got Oracle sqlplus: SQL*Plus: Release 8.1.5.0.0 Here is the err msg: [oracle at ironfist src]$ make gcc -fPIC -g -O2 -I/usr/include/python1.5 -I/usr/include/python1.5 -DHAVE_CONFIG_H -I/home/oracle/product/8.15/rdbms/demo -I/home/oracle/product/8.15/rdbms/public -I/home/oracle/product/8.15/network/public -I/home/oracle/product/8.15/plsql/public -DDCORACLE8 -c ./oci_.c In file included from ./oci_.c:562: Buffer.h:79: warning: static declaration for `PyImport_Import' follows non-static oci_8.c: In function `Logon': In file included from ./oci_.c:693: oci_8.c:95: warning: passing arg 4 of `OCIHandleAlloc' makes integer from pointer without a cast oci_8.c: In function `newLob': oci_8.c:446: warning: passing arg 4 of `OCIDescriptorAlloc' makes integer from pointer without a cast oci_8.c: In function `initoci_8': oci_8.c:483: warning: passing arg 3 of `OCIEnvInit' makes integer from pointer without a cast ./oci_.c: In function `_wrap_odescr': ./oci_.c:2595: warning: assignment from incompatible pointer type gcc -shared oci_.o -L/home/oracle/product/8.15/lib/ -L/home/oracle/product/8.15/rdbms/lib /home/oracle/product/8.15/rdbms/lib/defopt.o /home/oracle/product/8.15/lib/sscoreed.o /home/oracle/product/8.15/lib/nautab.o /home/oracle/product/8.15/lib/naeet.o /home/oracle/product/8.15/lib/naect.o /home/oracle/product/8.15/lib/naedhs.o -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lmm -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lclient -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lsocket -lnsl -lgen -ldl -lelf -laio -lposix4 -lsql -lm -lm -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lmm -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lclient -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lsocket -lnsl -lgen -ldl -lelf -laio -lposix4 -lsql -lm -lm -o oci_.so /usr/bin/ld: cannot open -lnetv2: No such file or directory collect2: ld returned 1 exit status make: *** [oci_.so] Error 1 [oracle at ironfist src]$ -- Sam Wun Firewalls / Security OneGuard Senior Software Engineer Electronic Commerce eSec Limited Phone: +61 3 83715376 mailto:swun at eSec.com.au C++/JAVA/UNIX/OOP/OOD -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-list/attachments/20000705/183b06d8/attachment.html From jean.hemmi at arakne.com Wed Jul 5 10:02:46 2000 From: jean.hemmi at arakne.com (Jean Hemmi) Date: Wed, 05 Jul 2000 08:02:46 +0000 Subject: JPE: Java - C Python Extension Project Message-ID: <3962EBA5.E461DD4@arakne.com> We need a full-featured C-Python / Java integration! Besides minor functional differences, JPython has the major limitation of not being able to leverage existing Python (binary) extensions. Presently, there is no C-Python extension to Java. We, at Arakne, are annoyed by this situation: We cannot integrate the Python binary extensions we developped with any of the Java SDK's. Python is among the fittest integration tools around today - we should be able to have a seamless integration between Python and Java-. (I'll leave to others the opportunity to elaborate on the consequences of the contact between Python's and Java's rationales, especially if both were tightly bound together...) This would also open a new perspective: at present the "standard" way to develop native web browser plug-in is through the Java plug-in mechanism and Java's JNI C API. At the end of the pipe is the ability to run, within a client web browser Python scripts, just like Javascript; Python bytecode, like a Java applet; or both. Like binary plug-ins, binary python extensions (*.pyd files) could also get downloaded and installed. After a successful experience at integrating two large and complex object-oriented systems into Python, we feel confident at applying the same patterns to a Java integration - after all, Java is just yet another external system to Python... - We are laying out below the requirements to such an integration: - Multithread compatibility (at least when the JVM relies on OS threads) - Access to the Java environment from Python - Seamlessness from both sides - Java objects appearing as native Python objects (resolving overloading) - Extensibility of Java classes into Python - Access to the Python environment from Java - Python objects accessible as Java objects - Extensibility of Python classes within Java - Exception mapping - Python programming on client Web browser, like Javascript - Ability to run Python bytecode files on the client Web browser - Conciliation of security features (adapting Python's restricted execution mode for 'Pylets') Voila! Reactions and comments ? Frederic Giacometti Arakne frederic.giacometti at arakne.com From maxm at normik.dk Wed Jul 5 10:34:15 2000 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Wed, 5 Jul 2000 10:34:15 +0200 Subject: Again: ODBC / Win98 -> crash Message-ID: <7BD10B680501D411B9DF009027E06F32011AE8@EXCHANGE> Fra: Matthias Huening [mailto:matthias.huening at univie.ac.at] >Now for a really strange thing: I just moved my script to a different >computer (almost identical configuration), and... - everything works >just fine! No crashes, no problems whatsoever. I hate computers. Maybe the machine it crashed on had Office 2K installede recently ??? and the one that doesn't crash hasn't or something like that. The combination of Win2k, Office2000/97 has caused me no end of grief. Try installing the newest version of mdac on your machine. (should not be needed on win 2K). Also check your security settings and r/w acces. Combinations of these two has helped me before. Regards Max M From frankn=nuws at cs.vu.nl Wed Jul 5 08:50:41 2000 From: frankn=nuws at cs.vu.nl (Frank Niessink) Date: Wed, 5 Jul 2000 06:50:41 GMT Subject: Entry widgets References: <39620052.53C1@cs.bham.ac.uk> Message-ID: <8juls1$roc@cs.vu.nl> Elliot Smith wrote: > Hello all, > I've tried this question before, and got no answer at all, so I thought > I'd give it another go as the situation is getting desperate! I can't > find any reference to this anywhere. > I've been having problems with Entry widgets in Tkinter, running > under sunos5. For some reason, when I double click on them, Python > closes the whole application and reports 'Bus error'. Any ideas? I've > tried overriding the binding for double mouse clicks to no avail. Well, after your first post I checked your problem with one Tkinter application of my one, but I couldn't reproduce your problem. Maybe you should try to track down the problem to the smallest program that still has that behavior and then post the code... Good luck, Frank -- He learnt to communicate with birds and discovered that their conversation was fantastically boring. It was all to do with wind speed, wing spans, power-to- weight ratios and a fair bit about berries. -- Douglas Adams, 'Life, the Universe, and Everything' From matthias.huening at univie.ac.at Wed Jul 5 10:21:56 2000 From: matthias.huening at univie.ac.at (Matthias Huening) Date: Wed, 5 Jul 2000 10:21:56 +0200 Subject: Undocumented regex behaviour in re module References: Message-ID: <8jur8r$3eqe$1@www.univie.ac.at> What about a simple regex and the use of string.split()? -------------- tags = re.compile(r"<\?(.+)\?>", re.I | re.M) match = tags.search(text) while match: print text[match.start():match.end()], \ '=>', string.split(match.group(1)) match = tags.search(text, match.end()) -------------- Matthias - - - - - matthias.huening at univie.ac.at http://www.ned.univie.ac.at/ From stephen at cerebralmaelstrom.com Wed Jul 5 11:31:24 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Wed, 05 Jul 2000 09:31:24 GMT Subject: Acronyms, Names of Projects, etcetera. OTish. Message-ID: I've been off-and-on working on a pet project for awhile now, that frequently gets started up when I decide I want to learn something new, then gets put away after I learn said something. And as I learn more, it tends to get competely revamped in design and implementation. The only consistant thing that i've had so far is a name 'Pyces', pronounced Pisces. So i'm all happily, idly, coding in a hobby-ish fashion, and come across a post on random numbers..and blam!... I see a projected NAMED Pisces, and..well, obviousely pronounced Pisces. That just won't do. So, I had to come up with a new name -- and a new acronym, of course. Behold the wonder that i've come up with, after spending way more time then I will ever admit to... Pyramid (I don't care if anyone else has something named this!) PYthonic Repository for Advanced Missive Interpretation and Distribution lol. I'm sorry, this is really a pointless message. I just rather proud of my silly acronym. Ten cents to the person who guesses what it is :) (Not that it's that hard.) --Stephen From chwieser at ee.oulu.fi Wed Jul 5 11:33:52 2000 From: chwieser at ee.oulu.fi (Christian Wieser) Date: 5 Jul 2000 09:33:52 GMT Subject: py-libcap Message-ID: <8juve0$n1o$2@ousrvr3.oulu.fi> -- Morning, I am in need of py-libcap. Unfortunally the link at Pamasus is down ;-( http://www.vex.net/parnassus/apyllo.py/126307487.528281449 Can someone please send me the file? And maybe an example? By the way: Is there a wrapper for libnet to inject IP packets too available? Regards, -- Christian Wieser - Oulu Secure Programming Group mailto: chwieser at ee.oulu.fi See my homepage at http://www.ee.oulu.fi/~chwieser for my PGP-Public-Key From shapr at uab.edu Wed Jul 5 11:59:56 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 05 Jul 2000 09:59:56 GMT Subject: GUI framework with TreeView References: <3967f81e.23966859@nntp.interaccess.com> Message-ID: <3963091F.CC541AF@uab.edu> Thaddeus L Olczyk wrote: > > I need a "free" gui framework that runs on both Windows and UNIX > ( so that lets out QT ) and gives me a component similr to Microsofts > TreeView. Does anyone know of such a thing? There's a Tree widget in IDLE that's quite nice looking. -- sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre From jessaustin at SPAMFREE.lucent.com Wed Jul 5 11:48:20 2000 From: jessaustin at SPAMFREE.lucent.com (Jess Austin) Date: Wed, 5 Jul 2000 17:48:20 +0800 Subject: Python COM for Linux? References: <8ja7gv$687$1@nnrp1.deja.com> <3958c185.103629691@news> Message-ID: <8juulj$csu$1@pony.kenan.com> Grant Edwards wrote in message ... > >I have a Python program that fetches mail from MS Exchange >Server using MAPI/COM. I'd dearly love to run it under Linux. >Does anybody have an experience with accessing MS Exchange >Server via COM from Linux? I'd love to take a look at this. I'm always interested in anything that could help me escape the drudgery of Outlook. Can you post a link? thanks, Jess From sean at digitome.com Wed Jul 5 13:01:30 2000 From: sean at digitome.com (Sean Mc Grath) Date: Wed, 05 Jul 2000 11:01:30 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> Message-ID: <39630fdb.148487854@news.iol.ie> Thanks to Christian and Gordon, I think I am well on the way to pickling Pyxie trees. More news anon. regards, Sean McGrath On Sun, 02 Jul 2000 11:51:10 GMT, sean at digitome.com (Sean Mc Grath) wrote: >I have a reproduceable GPF on NT when picking objects of a class >that has a __getattr__ implementation. Take out the __getattr__ and >the pickle works fine. > >Are there ways to implement __getattr__ and yet preserve the ability >to pickle? > >regards, > From aa8vb at yahoo.com Wed Jul 5 13:18:27 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 05 Jul 2000 07:18:27 -0400 Subject: Nth digit of PI In-Reply-To: ; from jmassung@magpiesystems.com on Wed, Jun 21, 2000 at 09:19:17AM -0600 References: <8hogt2$57t$1@nnrp1.deja.com> <8houlu$j9s$1@nntp.itservices.ubc.ca> <394889C3.1ED5@esatclear.ie> Message-ID: <20000705071827.A1015156@vislab.epa.gov> Jeff Massung: |Please, this interests me -- I've had differention equations, but that's as |far as I go. In theory, pi (and e) are infinite, but has that been proven |that there is not end to their decimals? I don't know the mathematically-rigorous answer to your question. But one of the interesting things that you can show with a Fourier integral (possibly other ways too) is that: Pi^2/8 = sum(n=1..inf, 1/(2n-1)^2) You can see that the sum is 1/1 + 1/9 + 1/125 + .... The terms get smaller and smaller, which means making the decimal representation longer and longer. In the limit, the decimal representation is infinitely long because the denominator is infinitely large. Solving for pi: multiplying by 8, you still have infinitely many digits, and taking the square root, you still have infinitely many digits. That's pi. Randall ------------------------------------------------------------------------------ #!/usr/bin/env python # # pi = sqrt( 8 * sum(n=1..inf, 1/(2n-1)^2) ) # Not a realistic way to compute pi; convergence is hideously slow. # But with rational number arithmetic and lots of storage... # import math ITERATIONS = 50000 sum = 0 for v in range(2*ITERATIONS-1,0,-2): sum = sum + 1/v**2.0 print "pi is approx %g (%d iterations)" % ( math.sqrt( sum * 8 ), ITERATIONS ) From scherbi at bam.com Wed Jul 5 13:27:51 2000 From: scherbi at bam.com (Bill Scherer) Date: Wed, 05 Jul 2000 11:27:51 +0000 Subject: DCOracle error References: <3962CB94.2DDA9AA9@esec.com.au> Message-ID: <39631BB7.3641E234@bam.com> Getting those Oracle lib lines correct is a bear. Below is the line from my makefile for DCOracle, built against Oracle 8.0.5. ORACLE_L=-lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lmm -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lclient -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnsl -lgeneric -ldl -lelf -lposix -lsql -lm -lm (that's one line) You'll notice that many of the entries from the stock Makefile ORACLE_L line are missing. Now, I have libnetv2.a in ORACLE_HOME/lib. Possibly you neglected to install some of the Oracle development libs? - Bill Scherer sss wrote: > I don't know why I got this error when I try to install DCOracle in > the Linux machine. > I've got Oracle sqlplus: SQL*Plus: Release 8.1.5.0.0 > > Here is the err msg: > > [oracle at ironfist src]$ make > gcc -fPIC -g -O2 -I/usr/include/python1.5 -I/usr/include/python1.5 > -DHAVE_CONFIG_H -I/home/oracle/product/8.15/rdbms/demo > -I/home/oracle/product/8.15/rdbms/public > -I/home/oracle/product/8.15/network/public > -I/home/oracle/product/8.15/plsql/public -DDCORACLE8 -c ./oci_.c > In file included from ./oci_.c:562: > Buffer.h:79: warning: static declaration for `PyImport_Import' follows > non-static > oci_8.c: In function `Logon': > In file included from ./oci_.c:693: > oci_8.c:95: warning: passing arg 4 of `OCIHandleAlloc' makes integer > from pointer without a cast > oci_8.c: In function `newLob': > oci_8.c:446: warning: passing arg 4 of `OCIDescriptorAlloc' makes > integer from pointer without a cast > oci_8.c: In function `initoci_8': > oci_8.c:483: warning: passing arg 3 of `OCIEnvInit' makes integer from > pointer without a cast > ./oci_.c: In function `_wrap_odescr': > ./oci_.c:2595: warning: assignment from incompatible pointer type > gcc -shared oci_.o -L/home/oracle/product/8.15/lib/ > -L/home/oracle/product/8.15/rdbms/lib > /home/oracle/product/8.15/rdbms/lib/defopt.o > /home/oracle/product/8.15/lib/sscoreed.o > /home/oracle/product/8.15/lib/nautab.o > /home/oracle/product/8.15/lib/naeet.o > /home/oracle/product/8.15/lib/naect.o > /home/oracle/product/8.15/lib/naedhs.o -lnetv2 -lnttcp -lnetwork -lncr > -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lmm > -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnetv2 -lnttcp > -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon > -lgeneric -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lclient > -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 > -lsocket -lnsl -lgen -ldl -lelf -laio -lposix4 -lsql -lm -lm -lnetv2 > -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn > -lcommon -lgeneric -lmm -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 > -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient > -lvsn -lcommon -lgeneric -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 > -lnlsrtl3 -lclient -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 > -lnlsrtl3 -lcore4 -lnlsrtl3 -lsocket -lnsl -lgen -ldl -lelf -laio > -lposix4 -lsql -lm -lm -o oci_.so > /usr/bin/ld: cannot open -lnetv2: No such file or directory > collect2: ld returned 1 exit status > make: *** [oci_.so] Error 1 > [oracle at ironfist src]$ > > > -- > Sam Wun Firewalls / Security > OneGuard Senior Software Engineer Electronic Commerce > eSec Limited Phone: +61 3 83715376 > mailto:swun at eSec.com.au C++/JAVA/UNIX/OOP/OOD > > -- William K. Scherer Sr. Member of Applications Staff Verizon Wireless From roy at popmail.med.nyu.edu Wed Jul 5 13:53:47 2000 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Wed, 05 Jul 2000 07:53:47 -0400 Subject: Nth digit of PI References: <8hogt2$57t$1@nnrp1.deja.com> <8houlu$j9s$1@nntp.itservices.ubc.ca> <394889C3.1ED5@esatclear.ie> <20000705071827.A1015156@vislab.epa.gov> Message-ID: Randall Hopper wrote: > Pi^2/8 = sum(n=1..inf, 1/(2n-1)^2) Interesting, I've never seen that one before. It's not a very efficient way to compute pi (I know, that's not what you were trying to do). A little experimentation shows that 1000 terms only gets you 4 significant digits correct, and 10,000 terms still only had 5! -- Roy Smith New York University School of Medicine From olivierS.dagenaisP at canadaA.comM Wed Jul 5 14:33:02 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 12:33:02 GMT Subject: GUI framework with TreeView References: <3967f81e.23966859@nntp.interaccess.com> Message-ID: <2WF85.39122$W35.856292@news20.bellglobal.com> I was looking for EXACTLY that and I found it, along with a whole lot of other cool stuff: http://www.wxwindows.org and if you're using Python: http://www.wxpython.org There's also a MAC port coming along. It attempts to provide many nice features of the OS GUIs out there, not just a "lowest common denominator". It does so by using native OS components/APIs wherever possible, so the Treeview isn't some re-implementation, it looks and feels just like MS's treeview. Oh, and it's free: http://wxwindows.org/newlicen.htm -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Thaddeus L Olczyk" wrote in message news:3967f81e.23966859 at nntp.interaccess.com... > I need a "free" gui framework that runs on both Windows and UNIX > ( so that lets out QT ) and gives me a component similr to Microsofts > TreeView. Does anyone know of such a thing? From peter at wl.vg Wed Jul 5 14:32:59 2000 From: peter at wl.vg (Peter Halliday) Date: Wed, 05 Jul 2000 08:32:59 -0400 Subject: Redhat and mod_python Message-ID: <39632AFB.8BB36365@wl.vg> I am trying to get mod_python working with Apache's rpm's. I really don't want to have to compile Apache separately. Has anyone got mod_python working under Redhat while keeping the Apache rpms. Thank you. And please if possible could you email your response to my email above (peter at whetstonelogic.com). Thanks. -- Peter Halliday Online Application Developer Whetstone Logic, Inc. http://www.whetstonelogic.com icq#75769411 AIM screen name: hoaggelos From thiele at muc.das-werk.de Wed Jul 5 14:29:32 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Wed, 05 Jul 2000 14:29:32 +0200 Subject: Segmentation fault(LINUX) and no idea why! Message-ID: <39632A2C.E6ABECEB@muc.das-werk.de> Hallo! In my program I create a new thread. In this new thread I fork and replace the child with an other program using excel. Normaly I have up to four threads with this procedure. So I have a number of threads and the same numbers of childs (the called program) The problem is sometimes (relativly seldom, so it's unreproducible ;-( ) I get a segmantation fault and the pytthon interpreter stops. But I if the segmentation fault happens, one of the childs is not running anymore. (I don't know is that the reason or a result) A little testprogram with the same construction shows that if a segmentaltion fault happens in one child, the parant keeps running. I get no traceback from the interpreter. My Question is, where can I look for the problem. Why does the interpreter (-> the whole program) die. What can be the reason? From sholden at bellatlantic.net Wed Jul 5 14:57:52 2000 From: sholden at bellatlantic.net (Steve Holden) Date: Wed, 05 Jul 2000 12:57:52 GMT Subject: Is there a searchable archive of c.l.py References: <8jq7l3$f1e$1@slb0.atl.mindspring.net> Message-ID: <396330BC.DB5DCD00@bellatlantic.net> Deja have "promised" to get the older archives back on line when their new face is up and running. Does anyone have any personal contacts in that organization to ask if we can have the data NOW to put a searchable archive up somewhere else? regards Steve Aahz Maruch wrote: > > In article , > Neil Hodgson wrote: > > > > Is there a sensibly searchable archive anywhere? In the future we will > >need this resource. Otherwise how will we know how we beat those nanoviruses > >back in '97? > > Well, we've got the archive: http://www.python.org/pipermail/python-list/ > > Unfortunately, it only seems to go back to March '99. Does anyone > maintain an older archive? Once we have the archive, making it > searchable is a relatively trivial task. > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > The best way to get information on Usenet is not to ask a question, > but to post the wrong information. --Aahz -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://home.cox.rr.com/sholden/ From brunnsNObrSPAM at beer.com.invalid Wed Jul 5 15:01:13 2000 From: brunnsNObrSPAM at beer.com.invalid (Simon B) Date: Wed, 05 Jul 2000 06:01:13 -0700 Subject: Is there a searchable archive of c.l.py References: Message-ID: <111b2f38.c4458b92@usw-ex0106-045.remarq.com> I don't know just how far back RemarQ goes, but it's probably worth a look. Cheers, Simon B. With Microsoft, failure is not an option. It comes bundled. ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From Ted.Mew at ncmail.net Wed Jul 5 15:11:36 2000 From: Ted.Mew at ncmail.net (Ted Mew) Date: Wed, 05 Jul 2000 09:11:36 -0400 Subject: Compatibility between PythonWin and DISLIN Message-ID: <39633408.80B5DFBC@ncmail.net> Has anyone tried to run the graphing package DISLIN using Mark Hammond's PythonWin 1.5.2? Is DISLIN compatible with PythonWin? DISLIN 7.3 is a high-level and easy to use graphics library with a Python version that runs nicely on a Windows NT platform under Python 1.5.2. This data plotting extension was developed by Helmut Michels of the Max_Planck Institute. It is listed on the Starship at: http://starship.python.net/crew/jhauser/plot-res.html and the binaries can be obtained freely at: http://www.linmpi.mpg.de/dislin/ I have made a cursory attempt to run DISLIN under PythonWin, but crashed in flames, unable to read memory locations. Since PythonWin is MS Windows based, I suspect DISLIN is attempting to run as an independent process or DOS-based program, but have little knowledge in this area. Any insights or experience would be appreciated. -Ted -------------- next part -------------- A non-text attachment was scrubbed... Name: Ted.Mew.vcf Type: text/x-vcard Size: 384 bytes Desc: Card for Ted Mew Url : http://mail.python.org/pipermail/python-list/attachments/20000705/c0e6e170/attachment.vcf From sholden at bellatlantic.net Wed Jul 5 15:08:02 2000 From: sholden at bellatlantic.net (Steve Holden) Date: Wed, 05 Jul 2000 13:08:02 GMT Subject: Definative Documentation on Objects References: <8jqui2$9na$1@supernews.com> Message-ID: <3963331E.D1F756BE@bellatlantic.net> I found "Learning Python" to be quite good enough to allow me to transfer the object-oriented stuff I knew to implementations in Python. It's good value for money, and although I personally found the pizza-robot examples a little unnatural, there is evidence they work for others. regards Steve Dale Strickland-Clark wrote: > > Where do I look for the definitive statement on object programming in > Python? > > The "Python Reference Manual", as included in the distribution, is > particularly hard work. > > I'm considering "Programming Python" by Mark Lutz but that's four years old. > "Learning Python" is more recent but I'm worried that it might be pitched a > bit low. > > I'm an experienced programmer but I need to quickly understand Python object > programming. > > Any pointers to online or paper reference material gratefully received. > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > Business Technology Consultants -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://home.cox.rr.com/sholden/ From claird at starbase.neosoft.com Wed Jul 5 15:09:47 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 5 Jul 2000 08:09:47 -0500 Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> Message-ID: In article <395B2B88.CC3041C1 at memo.volvo.se>, PM wrote: . . . >Can Python kick large bottoms with decent database access - not just SQL >not ODBC, could it go to DB2/400? . . . How are you getting to DB2 over OS/400 if not through SQL? Are you asking for RPG? In general, yes; Python's database access is "decent", and the language has turned up on AS/400 in the past (although I can't attest to its "currency"). -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From fiona at sitegnome.com Wed Jul 5 15:14:23 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 5 Jul 2000 13:14:23 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 5th, 2000 Message-ID: <20000705131423.10879.qmail@synop.com> Hi ! Another instalment of entries into http://python.faqts.com cheers, Fiona Australian - instalment American - installment :-) .. in case you were wondering that I couldn't spell? ## Unanswered Questions ######################################## ------------------------------------------------------------- How do I format my request to get an url/socket when there is a proxy in the middle and Proxy Authentication is required ? http://www.faqts.com/knowledge-base/view.phtml/aid/4182 ------------------------------------------------------------- Guest ## New Entries ################################################# ------------------------------------------------------------- How do I return a user's login name who is logged on at a PC? http://www.faqts.com/knowledge-base/view.phtml/aid/4189 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain, j vickroy, Ralf Claus You'll need the win32 extensions - http://starship.python.net/crew/mhammond/ import win32api login=win32api.GetUserName() --- or --- On Windows NT: import os os.environ['USERNAME'] ... provides the information. I do not believe that either Win 95 or 98 has the 'USERNAME' attribute set. --- or --- import getpass username = getpass.getuser() works on both systems (NT,UNIX), if you need. ------------------------------------------------------------- Can I use Python to run Internet Explorer and control it via COM? http://www.faqts.com/knowledge-base/view.phtml/aid/4191 ------------------------------------------------------------- Fiona Czuczman Roger Upole, Mark Hammond Here's a small sample of how to navigate to a URL. >>> import win32com.client >>> x=win32com.client.Dispatch('InternetExplorer.Application.1') >>> x.Visible=1 >>> x.Navigate('http://www.python.org') If you run makepy on Microsoft Internet Controls, the file generated in Python\win32com\genpy will show all the properties and methods available for this object. This will work fine to control IE. However, look in "win32com\client\__init__.py", and look for the "DispatchWithEvents" docstring - this has an example that uses IE to both control it, and respond to events (such as URL load completed, etc) ------------------------------------------------------------- Is there a Python MySQL module for use under Windows? http://www.faqts.com/knowledge-base/view.phtml/aid/4188 ------------------------------------------------------------- Fiona Czuczman Stefan Franke Check out ZMySQLDA-1.2.0.tar.gz on the Zope site (www.zope.org). It contains MySQLdb-0.1.2 with some Windows patches already applied. I run it sucessfully with the lately GPLed MySQL-2.23.19 on Win98. All you need to do is to edit Setup.in, adjust the paths to your local MySQL installation, and run compile.py. ## Edited Entries ############################################## ------------------------------------------------------------- What is the best way to make multiple replacements of text strings in a file? http://www.faqts.com/knowledge-base/view.phtml/aid/4049 ------------------------------------------------------------- Fiona Czuczman, Thi?baut Champenier, Steve Holden Steve Holden, Steve Nordby,David Goodger, Fredrik Lundh,Thi?baut Champenier You could clean the source up a bit with: foobar = ( ('foo1', 'bar1'), ('foo2', 'bar2'), ('fooN', 'barN') ) source = open(source_file,'r') contents = source.read() source.close() for foo, bar in foobar: contents = replace(contents, foo, bar) dest = open(dest_file, 'w') dest.write(contents10) dest.close() For speedup, you could write the whole loop as a single statement, but it will get horrible quickly: contents = replace( replace( replace(contents, 'fooN', 'barN'), 'foo2', 'bar2'), 'foo1', 'bar1) and, of course, ths code is much less easy to maintain. How about using a dictionary and a loop: replaceme = {'foo1': 'bar1', 'foo2': 'bar2', 'foo3': 'bar3'} for key in replaceme.keys(): srch = key rplc = replaceme[key] contents = string.replace(contents, srch, rplc) ------------------- Perhaps a bit complex for a newbie, but the most definitive answer I've seen so far has been Fredrik Lundh's 2000-04-12 reply to the "Python idiom: Multiple search-and-replace" thread: > Is there a Python feature or standard library API that will get me > less Python code spinning inside this loop? re.multisub or > equivalent? haven't benchmarked it, but I suspect that this approach is more efficient: ... # based on re-example-5.py import re import string symbol_map = { "foo": "FOO", "bar": "BAR" } def symbol_replace(match, get=symbol_map.get): return get(match.group(1), "") symbol_pattern = re.compile( "(" + string.join(map(re.escape, symbol_map.keys()), "|") + ")" ) print symbol_pattern.sub(symbol_replace, "foobarfiebarfoo") ------------------- Thi?baut Champenier has wriiten a string replacement utility, which is available for inspection at: http://tibi.free.fr/repl.py From piet at cs.uu.nl Wed Jul 5 15:12:49 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 05 Jul 2000 15:12:49 +0200 Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> <87og4eugz7.fsf@cartman.azz.net> Message-ID: Note that the trick via a .bat file may cause problems with parameters containing = signs, and with I/O redirections. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From neilh at scintilla.org Wed Jul 5 15:22:24 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 05 Jul 2000 13:22:24 GMT Subject: Is there a searchable archive of c.l.py References: <111b2f38.c4458b92@usw-ex0106-045.remarq.com> Message-ID: > I don't know just how far back RemarQ goes, but it's probably > worth a look. Thanks for the pointer. Remarq only goes back to April with a couple of days in March. I like the way it displays all of a thread if you click on it though. Lots less clicking than Deja. Neil From sholden at bellatlantic.net Wed Jul 5 15:22:37 2000 From: sholden at bellatlantic.net (Steve Holden) Date: Wed, 05 Jul 2000 13:22:37 GMT Subject: Postscript font metrics? References: <39622330.3732B225@yahoo.com> Message-ID: <3963368A.8442AD75@bellatlantic.net> Paul Winkler wrote: > > I need to generate some nice Postscript output from a python script, > and I'm finding that I need to get at the font metrics info from the > .afm files so I can place things correctly. (Either that or write > *everything* in postscript -- no way!!) > > I can't find anything like this on Parnassus. Anyone ever seen any > python code that gets the useful info from .afm files? > > If not, I might have a go at hacking the relevant parts of the Perl > PostScript-Font-1.02 module into Python... but then I'll have to > (yuck) read someone else's Perl code, which I haven't done in a > looong time and I was never that good at it. > > -- > ................. paul winkler .................. > slinkP arts: music, sound, illustration, design, etc. > web page: http://www.ulster.net/~abigoo > A member of ARMS: http://www.reacharms.com > or http://www.mp3.com/arms Have you considered using PIDDLE for your PostScript output? I recently used it to generate PDF files, but PostScript is another possible backend. It's impressive, and will compute string lengths for you to allow "typesetting"-style outputs. Take a look at http://piddle.sourceforge.net Hope this helps. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://home.cox.rr.com/sholden/ From cmfinlay at SPAMmagnet.com.au Wed Jul 5 15:21:03 2000 From: cmfinlay at SPAMmagnet.com.au (cmfinlay at SPAMmagnet.com.au) Date: Wed, 05 Jul 2000 23:21:03 +1000 Subject: "Write to a file" question please? Message-ID: number = 100 print "Number =", number OUT = open("TT.txt","w") OUT.write("Number =", number) # Error OUT.close() The code above gives the error. Traceback (innermost last): File "ttest.py", line 5, in ? OUT.write("Number =", number) TypeError: read-only buffer, tuple OUT.write("Hello World") Works but a number or variable of a number does not. I have been reading documents on Python to no avail this time. I am using Win98 with the latest python for this OS. Any help would be much appreciated E-mail me at cmfinlaySPAM at magnet.com.au or reply here. From brunnsNObrSPAM at beer.com.invalid Wed Jul 5 15:36:27 2000 From: brunnsNObrSPAM at beer.com.invalid (Simon B) Date: Wed, 05 Jul 2000 06:36:27 -0700 Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> Message-ID: <1c934748.cd75dee0@usw-ex0106-045.remarq.com> I've not heard of any way of getting at DB2/400 from Python other than via ODBC. But I'd love to be wrong! If someone were to port JPython to the '400, you would be able to use the AS/400 Toolbox for Java's native DB access APIs, but that would be a pretty major job in itself. BTW, It's nice to know that there are other '400 types looking at Python. I'm hoping to do the JPython port eventually, but I don't know Java yet, so don't hold your breath! Cheers, Simon B. With Microsoft, failure is not an option. It comes bundled. ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From olivierS.dagenaisP at canadaA.comM Wed Jul 5 15:43:16 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 13:43:16 GMT Subject: "Write to a file" question please? References: Message-ID: Make this adjustement: OUT.write ("Number = %d" % number) I just tried it, and it works. My guess is the rules for write are different than for print, so what appears to be a string concatenation in print might just be a sequence type of some sort. (sorry, I learned Python this weekend, that's the best I can do in explaining it) You can also use: OUT.write ("Number =" + str(number)) ...which might be more what you're looking for. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III wrote in message news:tzFjOfN2zOzPHwvl3ncklEAEb+fa at 4ax.com... > number = 100 > print "Number =", number > OUT = open("TT.txt","w") > OUT.write("Number =", number) # Error > OUT.close() > > The code above gives the error. > > Traceback (innermost last): > File "ttest.py", line 5, in ? > OUT.write("Number =", number) > TypeError: read-only buffer, tuple > > OUT.write("Hello World") > > Works but a number or variable of a number does not. > > I have been reading documents on Python to no avail this time. > I am using Win98 with the latest python for this OS. > > Any help would be much appreciated > E-mail me at cmfinlaySPAM at magnet.com.au > or reply here. From mjm at boora.com Wed Jul 5 15:32:09 2000 From: mjm at boora.com (mjm) Date: Wed, 5 Jul 2000 06:32:09 -0700 Subject: Python Object Browser References: Message-ID: Another clue... I don't have the same problem on my win98 box at home. At work, on WinNT, I have a problem. -mjm michael montagne wrote in message news:dU785.94271$5k2.195629 at dfw-read.news.verio.net... > I'm trying to use makepy on some common objects on my system. Word2000, > Excel2000, etc. > It doesn't seem to want ot work. When I go to the objects that are having > trouble using the Python Object Browser, under the Type Library heading it > says > "The type info can n..="The type info can not be loaded". Does this mean it > is unavailable? How do i fix this? > > -mjm > > From tismer at appliedbiometrics.com Wed Jul 5 15:52:00 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 05 Jul 2000 15:52:00 +0200 Subject: Why is Python so slow ?- revisited. References: <394D6579.8B2FF840@appliedbiometrics.com> <8tA35.10459$C44.626417@bgtnsc05-news.ops.worldnet.att.net> Message-ID: <39633D80.27B767E4@appliedbiometrics.com> William Dandreta wrote: > > Hi chris, > > Here is the fastest version of my program. Ok. I was off for a while and did not follow the thread. Some hints may give you a little speedup: Don't work on the global level, but do everything in functions. This gives you a speedup, since local variables are optimized and don't involve dictionary lookups. Further, since you are working on only 6000 lines or so, you can save quite some time by using readlines(),and then iterating over that list. But I don't know if Py1.2 has readlines at all. Here a rough layout, untested of course! ### start of example refactored #corrects Y2K leapyear error and #strips off all the " marks import strop FINNAME = 'lu4.txt' FOUTNAME = 'lu4.new' def process(finn=FINNAME, foutn=FOUTNAME): # caching some funcitons locally: strip = strop.strip splitfields = strop.splitfields atoi = strop.atoi joinfields = strop.joinfields _map = map _tuple = tuple lines = open(finn, 'r').readlines() fout = open(fount, 'wb) write = fout.write for line in lines: fields = splitfields(joinfields(splitfields(line,'"'),''),',') fields[2] = joinfields(splitfields(fields[2],' '),'0') fields = _map(strip,fields) #convert date to YYYYMMDD format if fields[2][-2:] == '00': fields[2] = '2000' + fields[2][-10:-8] + fields[2][-7:-5] else: fields[2] = '19' + fields[2][-2:] + fields[2][-10:-8] + fields[2][-7:-5] #fix date for Y2K leapyear error if fields[2] == '20000301': fields[2] = '20000229' elif fields[2] == '20000401': fields[2] = '20000331' elif '20000301' ---------------------------------------------------------- > #corrects Y2K leapyear error and > #strips off all the " marks > > from strop import strip, splitfields,atoi,joinfields > > lu4 = open('lu4.txt','r') > newlu4 = open('lu4.new','wb') > > while 1: > #for i in range(6000): > line = lu4.readline() > if not line: break > fields = splitfields(joinfields(splitfields(line,'"'),''),',') > fields[2] = joinfields(splitfields(fields[2],' '),'0') > fields = map(strip,fields) > #convert date to YYYYMMDD format > if fields[2][-2:] == '00': > fields[2] = '2000' + fields[2][-10:-8] + fields[2][-7:-5] > else: > fields[2] = '19' + fields[2][-2:] + fields[2][-10:-8] + fields[2][-7:-5] > > #fix date for Y2K leapyear error > if fields[2] == '20000301': > fields[2] = '20000229' > elif fields[2] == '20000401': > fields[2] = '20000331' > elif '20000301' fields[2] = '2000' + fields[2][4:6] + '%02d' % (atoi(fields[2][6:])-1) > > newlu4.write('%-16s,%8s,%8s,%10s,%10s,%-11s,%-11s,%-21s,%-51s\r\n' % > tuple(fields)) > --------------------------------------------------------------------- > Bill > > Christian Tismer wrote in message > <394D6579.8B2FF840 at appliedbiometrics.com>... > >Also feel free to send me your source code for inspection. > > -- > http://www.python.org/mailman/listinfo/python-list -- Christian Tismer :^) Applied Biometrics GmbH : 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 adetalabi at clara.co.uk Wed Jul 5 16:01:08 2000 From: adetalabi at clara.co.uk (Ade Talabi) Date: Wed, 05 Jul 2000 15:01:08 +0100 Subject: Segmentation fault(LINUX) and no idea why! References: <39632A2C.E6ABECEB@muc.das-werk.de> Message-ID: <39633FA4.8EBBE2DB@clara.co.uk> Thomas Thiele wrote: > > Hallo! > > In my program I create a new thread. In this new thread I fork and > replace the child with an other program > using excel. Normaly I have up to four threads with this procedure. So I > have a number of threads and the same numbers of childs (the called > program) > > The problem is sometimes (relativly seldom, so it's unreproducible ;-( ) > I get a segmantation fault and the pytthon interpreter stops. > > But I if the segmentation fault happens, one of the childs is not > running anymore. (I don't know is that the reason or a result) > A little testprogram with the same construction shows that if a > segmentaltion fault happens in one child, the parant keeps running. > I get no traceback from the interpreter. > > My Question is, where can I look for the problem. Why does the > interpreter (-> the whole program) die. What can be the reason? pstack, ptrace or truss the PID -- /--------------------------------------------------------------\ | Ade Talabi | Internet : adetalabi at clara.co.uk | | ::M1ETW:: | Web Page : http://www.net-africa.com | \--------------------------------------------------------------/ From wlav at hpatl26.cern.ch Wed Jul 5 15:43:38 2000 From: wlav at hpatl26.cern.ch (Wim Lavrijsen) Date: 5 Jul 2000 13:43:38 GMT Subject: "Write to a file" question please? References: Message-ID: <8jve2a$hg3$1@sunnews.cern.ch> cmfinlay at SPAMmagnet.com.au writes: >number = 100 >print "Number =", number >OUT = open("TT.txt","w") >OUT.write("Number =", number) # Error 'write' expects only 1 argument. You should build a string to hand to write. Something like: OUT.write( 'Number = %d' % number + '\n' ) Best regards, Wim Lavrijsen From alex at magenta.com Wed Jul 5 13:14:41 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 5 Jul 2000 13:14:41 +0200 Subject: Singleton COM local/remote server? References: <7bd5msssk48km280t9bvds4i3v6hs7r8or@4ax.com> Message-ID: <8jvad40s00@news1.newsguy.com> John Lull wrote in message news:7bd5msssk48km280t9bvds4i3v6hs7r8or at 4ax.com... > I'm prototyping a DCOM server in Python. The server coordinates [snip] > Since each port can belong to at most one server, I cannot have > multiple servers on the same machine. I can't figure out how to > ensure there is only *one* copy of the server started, regardless of > how many clients want to use it. > > Any samples, pointers to documentation, key phrases to search MSDN > for, etc. would be *greatly* appreciated. I'm not sure how this translates to Python's implementation of COM, but, at a lower abstraction level, this is exactly what is accomplished by passing the REGCLS_MULTIPLEUSE value as the "flags" parameter in the CoRegisterClassObject calls that an .EXE does, at startup, to let the Service Control Manager of COM know about its class-objects (IClassFactory instances). When such a call is made, and, later, another instance of the object is required, the SCM won't start another process, but rather re-use the class-factory it knows is already active (and which, it has been informed, is OK for multiple use). You can take further precautions to check that this is indeed working as designed, but they should not be needed. Now, there remains the issue of, how to control the flags used on CoRegisterClassObject by pythonw.exe...? I can't find it in the docs (which doesn't mean it isn't there... it just says I can't find it). Maybe we need to look at the sources...? Alex From samschul at pacbell.net Wed Jul 5 16:18:06 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Wed, 05 Jul 2000 14:18:06 GMT Subject: ANS: ASPIPython update on Starship Message-ID: <8jvg2d$8q5$1@nnrp1.deja.com> I have made some corrections to ASPIPython, that correct memory leaks found in aspi.dll. ASPIPython is a open source python interface to the (A)dvanced (S) system (P)programming (I)nterface for SCSI devices developed by Adaptec Corp. This interface allows for the development of tests under Python for SCSI disk drives. These routines can be found at http://starship.python/crew/schulen Sam Schulenburg Sent via Deja.com http://www.deja.com/ Before you buy. From usenet at foreignkey.com Wed Jul 5 16:32:57 2000 From: usenet at foreignkey.com (Paul Jensen) Date: Wed, 05 Jul 2000 14:32:57 GMT Subject: "Write to a file" question please? References: Message-ID: cmfinlay at SPAMmagnet.com.au writes: > number = 100 > print "Number =", number > OUT = open("TT.txt","w") > OUT.write("Number =", number) # Error > OUT.close() The problem is that 'print' is a statement, but the write() function wants an expression, so you use the "%" operator to substitute values into the string printf() style, like: OUT.write("Number = %d" % number) I wanted to include a reference to the "%" operator in the online docs, but interestingly couldn't find one. Anyone know offhand where "%" is covered in the docs? Cheers, -- Paul Jensen From akuchlin at mems-exchange.org Wed Jul 5 16:34:19 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 05 Jul 2000 10:34:19 -0400 Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> <39615d75.142572338@news> <8jtcid$4um$1@nntp9.atl.mindspring.net> Message-ID: <3dhfa4lk7o.fsf@kronos.cnri.reston.va.us> "Andrew Dalke" writes: > What I saw, though, was a compile time option to use /dev/random if > it exists. I would have thought that would be enabled by default, but > it made some comment about how the read will block if there isn't enough > entropy in the source pool. Is this ever a problem in real life? Yes, because the entropy pool is only 4096 bits, and entropy is added fairly slowly, since an interrupt or other event only adds a few bits of entropy. A different device, /dev/urandom, never blocks, so you can read enough data to theoretically compute the initial state of the pool. For generating a long-term thing like an RSA key, this would matter (or least be psychologically unsettling); for an IV, I think /dev/urandom would be fine. --amk From tismer at appliedbiometrics.com Wed Jul 5 16:41:35 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 05 Jul 2000 16:41:35 +0200 Subject: Compatibility between PythonWin and DISLIN References: <39633408.80B5DFBC@ncmail.net> Message-ID: <3963491F.70F3188D@appliedbiometrics.com> Ted Mew wrote: > > Has anyone tried to run the graphing package DISLIN using > Mark Hammond's PythonWin 1.5.2? Is DISLIN compatible with > PythonWin? No. I just tried it; they appear to have some different ideas about event handling. But this can't be too hard to solve. ... > I have made a cursory attempt to run DISLIN under PythonWin, > but crashed in flames, unable to read memory locations. > Since PythonWin is MS Windows based, I suspect DISLIN is > attempting to run as an independent process or DOS-based > program, but have little knowledge in this area. With Py1.5.2 and Win2000, it doesn't crash. I tried the CURVE demo. It works fine in a shell, showing its own DISLIN window. In PythonWin, the window is created, but then both pyWin and the new window seem to be waiting on each other. No, DISLIN does not try to be a main program, but it maybe makes some assumptions about event loops. I'll look into the code if I find time. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : 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 paul.robinson at quantisci.co.uk Wed Jul 5 16:52:47 2000 From: paul.robinson at quantisci.co.uk (Paul Robinson) Date: Wed, 05 Jul 2000 15:52:47 +0100 Subject: "Write to a file" question please? References: Message-ID: <39634BBF.5EFFC493@quantisci.co.uk> Paul Jensen wrote: > I wanted to include a reference to the "%" operator in the online > docs, but interestingly couldn't find one. Anyone know offhand where > "%" is covered in the docs? http://www.python.org/doc/current/lib/typesseq-strings.html#SECTION004151000000000000000 [Thats library reference - 2.1.5.1 More String Operations] ...although if you didn't know what an "sprintf() format string" was then the probability of understanding this particular section is low. Paul ----------------------------------- Business Collaborator Team Enviros Software Solutions http://www.businesscollaborator.com ----------------------------------- From nhv at cape.com Wed Jul 5 16:38:53 2000 From: nhv at cape.com (Norman Vine) Date: Wed, 5 Jul 2000 10:38:53 -0400 Subject: "Write to a file" question please? References: Message-ID: <8jvh9i$del$1@newsie2.cent.net> > number = 100 > print "Number =", number > OUT = open("TT.txt","w") > OUT.write("Number =", number) # Error > OUT.close() > > The code above gives the error. > > Traceback (innermost last): > File "ttest.py", line 5, in ? > OUT.write("Number =", number) > TypeError: read-only buffer, tuple > > OUT.write("Hello World") > > Works but a number or variable of a number does not. > > I have been reading documents on Python to no avail this time. > I am using Win98 with the latest python for this OS. > Try OUT.write("Number=%d"%(number)) see Python\Doc\tut\formatting.html Norman From samschul at pacbell.net Wed Jul 5 16:24:06 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Wed, 05 Jul 2000 14:24:06 GMT Subject: Corrected URL http://starship.python/crew/samschul References: <8jvg2d$8q5$1@nnrp1.deja.com> Message-ID: <8jvgdi$95f$1@nnrp1.deja.com> The corrected URL is: http://starship.python/crew/samschul In article <8jvg2d$8q5$1 at nnrp1.deja.com>, Sam Schulenburg wrote: > I have made some corrections to ASPIPython, that correct memory leaks > found in aspi.dll. > > ASPIPython is a open source python interface to the (A)dvanced (S) > system (P)programming (I)nterface for SCSI devices developed by Adaptec > Corp. This interface allows for the development of tests under Python > for SCSI disk drives. These routines can be found at > http://starship.python/crew/schulen > > Sam Schulenburg > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From Jelske.Kloppenburg at gmd.de Wed Jul 5 16:51:31 2000 From: Jelske.Kloppenburg at gmd.de (Jelske.Kloppenburg at gmd.de) Date: 5 Jul 2000 14:51:31 GMT Subject: Compiler switches for install Message-ID: <8jvi1j$412$1@hop.gmd.de> In the Python-1.5.2/README under Configuring threads I read "Unfortunately, on some platforms, additional compiler and/or linker options are required." Where - configure, configure.in, Makefile, Makefile.in, Modules/Makefile.pre.in, ...? how - CFLAGS=, OPTS=, MY_CFLAGS= ...? and when - before configure, before make, ...? can I set the options? I repeat the question (until now nobody seems to understand me): Where, how and when can I set the options? -- Jelske Kloppenburg, +49 2241 14-2433, GMD - German National Research Center for Information Technology From kpmurphy at my-deja.com Wed Jul 5 16:35:39 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Wed, 05 Jul 2000 14:35:39 GMT Subject: backslash in regular expression problem References: <394A55BA.69269793@wolfson.co.uk> <02de01bfd826$cf05bd80$6401a8c0@home> <8jivfr$qc2$1@nnrp1.deja.com> Message-ID: <8jvh3p$9mg$1@nnrp1.deja.com> how does re.escape help? >>> str = '\\\hi' >>> str '\\\\hi' >>> print str \\hi >>> import re >>> x = re.escape(str) >>> x '\\\\\\\\hi' >>> print x \\\\hi >>> i want to display the actual string, and also be able to write it to a file... thanks, keith In article , Michael Hudson wrote: > Keith Murphy writes: > > > what if instead of having '\\stuff' you have a str = '\\stuff' ? > > > > i know that you can print r'\\stuff' but you can't print rstr... > > > > how do you use the raw with a variable? > > You don't. You do know about re.escape? Asking that question > suggests you might not... > > Cheers, > M. > > -- > I saw `cout' being shifted "Hello world" times to the left and > stopped right there. -- Steve Gonedes > Sent via Deja.com http://www.deja.com/ Before you buy. From mark at intrepid.net Wed Jul 5 16:51:42 2000 From: mark at intrepid.net (Mark Conway Wirt) Date: Wed, 05 Jul 2000 14:51:42 GMT Subject: Help: Python dumping core Message-ID: I'm working on a python script, and the interpreter keeps dumping core. I can't get much information from the core file, as python (and the module it calls: wxPython) where not compiled with debugging symbols included. All I have is really the stack trace: #0 0x281a7b7d in _atomic_lock () from /usr/lib/libc_r.so.4 #1 0x281a6033 in _spinlock_debug () from /usr/lib/libc_r.so.4 #2 0x281a9520 in pthread_mutex_lock () from /usr/lib/libc_r.so.4 #3 0x2869be52 in wxMutex::Lock () from /usr/X11R6/lib/libwx_gtk.so #4 0x28528da5 in wxEvtHandler::ProcessPendingEvents () from /usr/X11R6/lib/libwx_gtk.so #5 0x284fe831 in wxAppBase::ProcessPendingEvents () from /usr/X11R6/lib/libwx_gtk.so #6 0x284af1bb in wxApp::OnIdle () from /usr/X11R6/lib/libwx_gtk.so #7 0x28529044 in wxEvtHandler::SearchEventTable () from /usr/X11R6/lib/libwx_gtk.so etc. If I'm reading the trace correctly, it looks like the problem is somewhere in wxMutex::Lock. I have a few questions: 1) Such a core dump points to a problem at a lower level than the particular script I'm working on, correct? It seems to me that even if I have a mistake in the python code, python itself shouldn't dump core. 2) Short or recompiling wxWindows (and perhaps wxPython and perhaps python itself...) with debugging symbols, is there anything I can do track the problem? If my code is doing something stupid to cause the crash, how can I trace the problem if, by dumping core, python won't give me a stack trace? I'm at a bit of a loss. The reason that I like using tools like python is to avoid lower-level debugging like this :-) Thanks in advance! --Mark From alex at magenta.com Wed Jul 5 16:23:28 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 5 Jul 2000 16:23:28 +0200 Subject: "Write to a file" question please? References: Message-ID: <8jvgk9012ca@news1.newsguy.com> [posted and mailed] wrote in message news:tzFjOfN2zOzPHwvl3ncklEAEb+fa at 4ax.com... > number = 100 > print "Number =", number > OUT = open("TT.txt","w") > OUT.write("Number =", number) # Error > OUT.close() The write method accepts one string argument. You can make a string argument as you seem to desire with the %-operator: OUT.write("Number = %d\n" % (number,)) I added the \n line terminator to the string, because it's not implicit (in print, it IS implicit, but not in .write). Another alternative: import sys sys.stdout = OUT print "Number =", number sys.stdout = sys.__stdout__ OUT.close() By assigning an opened file to sys.stdout you temporarily "redirect" the output of normal "print" to that file; you can then go back to normal using sys.__stdout__, which keeps the ORIGINAL value. Not worth it for writing just a few things, but fine if you have some function doing a lot of output with print, for example. Alex From ge at nowhere.none Wed Jul 5 17:34:18 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 05 Jul 2000 15:34:18 GMT Subject: Python COM for Linux? References: <8ja7gv$687$1@nnrp1.deja.com> <3958c185.103629691@news> <8juulj$csu$1@pony.kenan.com> Message-ID: <_zI85.3060$iN5.739427@ptah.visi.com> In article <8juulj$csu$1 at pony.kenan.com>, Jess Austin wrote: >>I have a Python program that fetches mail from MS Exchange >>Server using MAPI/COM. I'd dearly love to run it under Linux. >>Does anybody have an experience with accessing MS Exchange >>Server via COM from Linux? > >I'd love to take a look at this. I'm always interested in anything that >could help me escape the drudgery of Outlook. Can you post a link? Sure: ftp://ftp.visi.com/users/grante/stuff/mfetch.py ftp://ftp.visi.com/users/grante/stuff/mfetch.bat shows invokation Disclaimer: There's some hard-wired logic in one of the methods that convertes Outlook addresses to SMTP addresses -- grep for "comtrol". It only fetches mail -- I send mail using ssmtp with and the Exchange's SMTP server. -- Grant Edwards grante Yow! This is PLEASANT! at visi.com From alex at magenta.com Wed Jul 5 16:56:38 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 5 Jul 2000 16:56:38 +0200 Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> <1c934748.cd75dee0@usw-ex0106-045.remarq.com> Message-ID: <8jvii30149t@news1.newsguy.com> Simon B wrote in message news:1c934748.cd75dee0 at usw-ex0106-045.remarq.com... > I've not heard of any way of getting at DB2/400 from Python > other than via ODBC. But I'd love to be wrong! > > If someone were to port JPython to the '400, you would be able > to use the AS/400 Toolbox for Java's native DB access APIs, but > that would be a pretty major job in itself. Why would JPython have to be "ported" at all? Doesn't it "just run" with any common-or-garden Java Virtual Machine? Alex From Armin at Steinhoff.de Wed Jul 5 17:13:51 2000 From: Armin at Steinhoff.de (Armin Steinhoff) Date: 5 Jul 2000 08:13:51 -0700 Subject: PyObject_GetAttr(String) ... Message-ID: <8jvjbf$1eus@drn.newsguy.com> Hi all, a question for the gurus: what is the difference between the calls - PyObject_GetAttr and - PyObject_GetAttrString ?? Both have the same 'documented' semantic ... but they are magically different. Regards Armin From jerry_spicklemire at my-deja.com Wed Jul 5 17:48:39 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Wed, 05 Jul 2000 15:48:39 GMT Subject: Postscript font metrics? References: <39622330.3732B225@yahoo.com> Message-ID: <8jvlcg$d1p$1@nnrp1.deja.com> In article <39622330.3732B225 at yahoo.com>, Paul Winkler wrote: > I might have a go at hacking the relevant parts of the Perl > PostScript-Font-1.02 module into Python... but then I'll have to > (yuck) read someone else's Perl code, which I haven't done in a > looong time and I was never that good at it. > If you already have a notion of how to go about this with the Perl module, you might look at Minotaur http://mini.net/pub/ts2/minotaur.html to call the Perl functions from Python. Good luck, Jerry S. Sent via Deja.com http://www.deja.com/ Before you buy. From thomas at xs4all.net Wed Jul 5 18:12:44 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 5 Jul 2000 18:12:44 +0200 Subject: PyObject_GetAttr(String) ... In-Reply-To: <8jvjbf$1eus@drn.newsguy.com>; from Armin@Steinhoff.de on Wed, Jul 05, 2000 at 08:13:51AM -0700 References: <8jvjbf$1eus@drn.newsguy.com> Message-ID: <20000705181243.B13478@xs4all.nl> On Wed, Jul 05, 2000 at 08:13:51AM -0700, Armin Steinhoff wrote: > a question for the gurus: > what is the difference between the calls > > - PyObject_GetAttr and > - PyObject_GetAttrString ?? > Both have the same 'documented' semantic ... but they are magically > different. Actually, no, they aren't the same. PyObject_GetAttrString takes a PyObject pointer and a char pointer, whereas PyObject_GetAttr takes two PyObject pointers: the second argument should be a PyString, which is then turned into a char pointer (using PyString_AS_STRING) and passed to PyObject_GetAttrString. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jerry_spicklemire at my-deja.com Wed Jul 5 18:04:21 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Wed, 05 Jul 2000 16:04:21 GMT Subject: JPE: Java - C Python Extension Project References: <3962EBA5.E461DD4@arakne.com> Message-ID: <8jvm9o$dtj$1@nnrp1.deja.com> Cool! Might the work already done with Pyro serve as a jump-start? http://www.xs4all.nl/~irmen/python.html In article <3962EBA5.E461DD4 at arakne.com>, Jean Hemmi wrote: > We need a full-featured C-Python / Java integration! > We are laying out below the requirements to such an integration: > - Multithread compatibility (at least when the JVM relies on OS threads) > > - Access to the Java environment from Python > - Seamlessness from both sides > - Java objects appearing as native Python objects (resolving > overloading) > - Extensibility of Java classes into Python > - Access to the Python environment from Java > - Python objects accessible as Java objects > - Extensibility of Python classes within Java > - Exception mapping > - Python programming on client Web browser, like Javascript > - Ability to run Python bytecode files on the client Web browser > - Conciliation of security features (adapting Python's restricted > execution mode for 'Pylets') > Sent via Deja.com http://www.deja.com/ Before you buy. From dalke at acm.org Wed Jul 5 18:29:28 2000 From: dalke at acm.org (Andrew Dalke) Date: Wed, 5 Jul 2000 10:29:28 -0600 Subject: Nth digit of PI References: <8hogt2$57t$1@nnrp1.deja.com> <8houlu$j9s$1@nntp.itservices.ubc.ca><394889C3.1ED5@esatclear.ie> <20000705071827.A1015156@vislab.epa.gov> Message-ID: <8jvni0$amr$1@slb3.atl.mindspring.net> Randall Hopper >But one of the interesting things that you can show with a Fourier >integral (possibly other ways too) is that: > > Pi^2/8 = sum(n=1..inf, 1/(2n-1)^2) > >You can see that the sum is 1/1 + 1/9 + 1/125 + .... The terms get smaller >and smaller, which means making the decimal representation longer and >longer. In the limit, the decimal representation is infinitely long >because the denominator is infinitely large. I've seen the proof that e is irrational, but don't recall the details. The sketch you outlined isn't sufficient. Consider sum(n=1..inf, 1/n^2) = 1 + 1/2 + 1/4 + 1/8 + ... = 2 For any finite N in the sum 1..N, the denominator is infinitely large, but the infinite sum is an integer. Andrew dalke at acm.org From vxgvxg at my-deja.com Wed Jul 5 18:27:01 2000 From: vxgvxg at my-deja.com (vxgvxg at my-deja.com) Date: Wed, 05 Jul 2000 16:27:01 GMT Subject: Telnetlib Message-ID: <8jvnjs$f2l$1@nnrp1.deja.com> Hi, When using any of the telnetlib read functions (such as read_all(), read_until(), etc.), the 0x00's seem to be dropped from the data stream. Any ideas? Sent via Deja.com http://www.deja.com/ Before you buy. From heath7952 at my-deja.com Wed Jul 5 18:29:51 2000 From: heath7952 at my-deja.com (heath7952 at my-deja.com) Date: Wed, 05 Jul 2000 16:29:51 GMT Subject: Wanted: compile.py Message-ID: <8jvnp5$f4r$1@nnrp1.deja.com> Does anyone have a copy of compile.py referred to in the "Python Building C/C++ extensions documentation". I can't reach the website, or find it elsewhere. Thanks in advance. Heath. Sent via Deja.com http://www.deja.com/ Before you buy. From nolan_d at bigfoot.com Wed Jul 5 18:53:02 2000 From: nolan_d at bigfoot.com (Nolan Darilek) Date: Wed, 05 Jul 2000 11:53:02 -0500 Subject: Nonblocking IO? Message-ID: I'm trying to do nonblocking IO in a client application which I'm writing. The client is text-based and line-oriented, and the cmd.Cmd class does exactly what I want. (Well, almost exactly.) The class uses raw_input(), which appears to block. I also moved the code which reads from the connection into a thread, but this introduces a few more problems; the output is intermingled with the input. The most obvious solution is to use curses, but this makes my program much more complex than it needs to be. Since cmd does almost exactly what I want it to do, I'd much rather change the Cmd class than add curses. I've seen code written in C which does what I'd like to do (Micq, for example, has the interface which I'm aiming for, yet it doesn't use curses/ncurses.) So, is it somehow possible to either a) make raw_input nonblocking or b) use some other nonblocking IO method? And, is it then possible to ensure that the output from the socket isn't intermingled with the input? If I do nonblocking IO, I'm assuming that it's simply a matter of printing a newline, my message, and then reprinting the prompt while stuffing the existing input back into the input buffer. (Of course, I'd rather delete the existing line first to ensure that the app scrolls cleanly, but getting nonblocking input to work would be a great step in that direction. :) Can anyone offer any suggestions? Please CC me with any replies; I'm currently not subscribed to this list, and I don't have usenet access for another week. Thanks. From alex at magenta.com Wed Jul 5 17:49:14 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 5 Jul 2000 17:49:14 +0200 Subject: "Write to a file" question please? References: Message-ID: <8jvllp017g1@news1.newsguy.com> Paul Jensen wrote in message news:u7lb07is1.fsf at foreignkey.com... [snip] > I wanted to include a reference to the "%" operator in the online > docs, but interestingly couldn't find one. Anyone know offhand where > "%" is covered in the docs? http://www.python.org/doc/tut/node9.html It might be nice to be able to point more precisely by adding a "#something", but it seems the tutorial has no such anchors within chapters; so, one just says "about midway through the chapter", I guess. Alex From olivierS.dagenaisP at canadaA.comM Wed Jul 5 18:56:38 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 16:56:38 GMT Subject: Client-server architecture References: Message-ID: Yes, I'm answering my own post, but it's more of an FYI that might be nice in the FAQ, if it isn't, already... Anyway, I found this, after a long, long search: http://www.nightmare.com/medusa/index.html It seems to do a lot of what I was asking. The main page is rather sketchy, but the documentation provided helps illustrate a bit more how it works, at the high level. (esp. data_flow.html) I also found something else, called "WebDav", but I don't think it would suit my purposes all that much. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Olivier Dagenais" wrote in message news:Xpx85.37285$W35.821323 at news20.bellglobal.com... > What modules [or references] are there that explain or implement > simultaneous, __secure__ operations on a server? > > I looked through http://www.python.org/topics/web/ and it seems to only > cover HTTP, not HTTPS (using SSL or some other, secure protocol). > > I want to implement seemingly concurrent, remote database access and if I > can queue the requests to the server, the server could then process > requests, one at a time, and then "call back" each client with the results. > > I'm thinking I don't want to write the server side software using a CGI > script, since the database package I'm looking into using (Gadfly) isn't > designed for concurrent access, unless I don't understand how CGI works and > it is synchronous? (I have only written very simple CGI scripts in Perl and > C, so I'm sort of new to this) > > Any help (including corrections in my thinking of CGI or hints on handling > many, simultaneous requests) would be appreciated. I'd like to write both > the client and the server in Python. > > Thanks! > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > From samschul at pacbell.net Wed Jul 5 18:47:29 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Wed, 05 Jul 2000 16:47:29 GMT Subject: Corrected URL http://starship.python.net/crew/samschul References: <8jvg2d$8q5$1@nnrp1.deja.com> <8jvgdi$95f$1@nnrp1.deja.com> Message-ID: <8jvoqr$g18$1@nnrp1.deja.com> The corrected URL ( I'll get it right yet) http://starship.python.net/crew/samschul Sent via Deja.com http://www.deja.com/ Before you buy. From R.Brodie at rl.ac.uk Wed Jul 5 19:01:24 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Wed, 5 Jul 2000 18:01:24 +0100 Subject: Telnetlib References: <8jvnjs$f2l$1@nnrp1.deja.com> Message-ID: <8jvpl5$va4@newton.cc.rl.ac.uk> wrote in message news:8jvnjs$f2l$1 at nnrp1.deja.com... > When using any of the telnetlib read functions (such as read_all(), > read_until(), etc.), the 0x00's seem to be dropped from the data > stream. Any ideas? You are aware of the NVT transformations TELNET uses, e.g. replacing CR/NL by NL? From DavidA at ActiveState.com Wed Jul 5 19:22:51 2000 From: DavidA at ActiveState.com (David Ascher) Date: Wed, 5 Jul 2000 10:22:51 -0700 Subject: Wanted: compile.py In-Reply-To: <8jvnp5$f4r$1@nnrp1.deja.com> Message-ID: > Does anyone have a copy of compile.py referred to in the "Python > Building C/C++ extensions documentation". I can't reach the website, or > find it elsewhere. Apologies that the site is still broken. Please find it attached. --david ascher -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: compile.py Url: http://mail.python.org/pipermail/python-list/attachments/20000705/5c22e1bc/attachment.asc From invalid.address at 127.0.0.1 Wed Jul 5 19:32:27 2000 From: invalid.address at 127.0.0.1 (David) Date: Wed, 05 Jul 2000 17:32:27 GMT Subject: Python 2.0? References: <8jvgdi$95f$1@nnrp1.deja.com> Message-ID: <396370ab.10899776@news.telus.net> I've read that CNRI is giving the newly-formed PythonLabs a hard time about the release of Python v2.0. What's up with that? Isn't Python's license a completely free and clear one, such that no one can limit its distribution or use? More importantly, what can the public community do to support Guido 'n da boyz? CNRI can't be allowed to bugger up Python's future! From invalid.address at 127.0.0.1 Wed Jul 5 19:44:57 2000 From: invalid.address at 127.0.0.1 (David) Date: Wed, 05 Jul 2000 17:44:57 GMT Subject: GUI framework with TreeView References: <3967f81e.23966859@nntp.interaccess.com> Message-ID: <3965740e.11766815@news.telus.net> On Wed, 05 Jul 2000 08:56:09 GMT, olczyk at interaccess.com (Thaddeus L Olczyk) wrote: >I need a "free" gui framework that runs on both Windows and UNIX >( so that lets out QT ) and gives me a component similr to Microsofts >TreeView. Does anyone know of such a thing? wxPython/wxWindows. From stephen at cerebralmaelstrom.com Wed Jul 5 19:45:27 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Wed, 05 Jul 2000 17:45:27 GMT Subject: "Write to a file" question please? References: Message-ID: I *think*... Print is a statement that lets you print out multiple things using the comma, the 'write' function does not work the same way. It takes a string argument and writes it out to the file. To accomplish what you want, you can use the module operator (there's other ways too, but its my favorite :)) number = 100 print "Number = %s" % number OUT = open("TT.txt",'w') OUT.write("Number = %s" % number) OUT.close() If you have more then one number you're writing out, make the right-operand of the modulo operator a tuple.. E.g. num1 = 100 num2 = 500 print "Number 1 = %s and Number 2 = %s" % (num1,num2) See? :) --Stephen wrote in message news:tzFjOfN2zOzPHwvl3ncklEAEb+fa at 4ax.com... > number = 100 > print "Number =", number > OUT = open("TT.txt","w") > OUT.write("Number =", number) # Error > OUT.close() > > The code above gives the error. > > Traceback (innermost last): > File "ttest.py", line 5, in ? > OUT.write("Number =", number) > TypeError: read-only buffer, tuple > > OUT.write("Hello World") > > Works but a number or variable of a number does not. > > I have been reading documents on Python to no avail this time. > I am using Win98 with the latest python for this OS. > > Any help would be much appreciated > E-mail me at cmfinlaySPAM at magnet.com.au > or reply here. From stephen at cerebralmaelstrom.com Wed Jul 5 19:46:35 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Wed, 05 Jul 2000 17:46:35 GMT Subject: "Write to a file" question please? References: Message-ID: <%vK85.115476$WS3.978721@typhoon.we.rr.com> Oops. Replace my %s's with %d's. --S Stephen Hansen wrote in message news:XuK85.115473$WS3.978541 at typhoon.we.rr.com... > I *think*... > Print is a statement that lets you print out multiple things using the > comma, the 'write' function does not work the same way. It takes a string > argument and writes it out to the file. > > To accomplish what you want, you can use the module operator (there's other > ways too, but its my favorite :)) > > number = 100 > print "Number = %s" % number > OUT = open("TT.txt",'w') > OUT.write("Number = %s" % number) > OUT.close() > > If you have more then one number you're writing out, make the right-operand > of the modulo operator a tuple.. E.g. > > num1 = 100 > num2 = 500 > print "Number 1 = %s and Number 2 = %s" % (num1,num2) > > See? :) > > --Stephen > > > > wrote in message > news:tzFjOfN2zOzPHwvl3ncklEAEb+fa at 4ax.com... > > number = 100 > > print "Number =", number > > OUT = open("TT.txt","w") > > OUT.write("Number =", number) # Error > > OUT.close() > > > > The code above gives the error. > > > > Traceback (innermost last): > > File "ttest.py", line 5, in ? > > OUT.write("Number =", number) > > TypeError: read-only buffer, tuple > > > > OUT.write("Hello World") > > > > Works but a number or variable of a number does not. > > > > I have been reading documents on Python to no avail this time. > > I am using Win98 with the latest python for this OS. > > > > Any help would be much appreciated > > E-mail me at cmfinlaySPAM at magnet.com.au > > or reply here. > > From ssthapa at midway.uchicago.edu Wed Jul 5 20:22:43 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Wed, 05 Jul 2000 18:22:43 GMT Subject: Random number generation, simple question. References: Message-ID: Kalle Svensson wrote: >Hello. > >I have a few questions about the (pseudo) random number generator supplied >in the standard library. I need 80 random bits (for a CipherSaber IV) but >I hear most RNG's only supply 32 bits or less. My questions are: > > * How many random bits does whrandom.random() generate? > > * Suppose I do a loop where I get a byte at a time and then re-seed the > generator either with random numbers from the generator or with values > from time. Will that improve the randomness? This may not be entirely wise. An psuedo-random number generator eventually cycles and starts repeating. The problem is that the seed supplied to the prng affects how quickly it loops and the distribution of the numbers the prng generates. If you feed random numbers into the prng youo could end up with weaker encryption than you think. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From just at letterror.com Wed Jul 5 21:22:05 2000 From: just at letterror.com (Just van Rossum) Date: Wed, 05 Jul 2000 20:22:05 +0100 Subject: Postscript font metrics? References: <39622330.3732B225@yahoo.com> <3963368A.8442AD75@bellatlantic.net> Message-ID: <39638AA5.7C36FD77@letterror.com> Paul Winkler wrote: > > I need to generate some nice Postscript output from a python script, > and I'm finding that I need to get at the font metrics info from the > .afm files so I can place things correctly. (Either that or write > *everything* in postscript -- no way!!) > > I can't find anything like this on Parnassus. Anyone ever seen any > python code that gets the useful info from .afm files? My (hardly advertized, but free) FontTools package contains an AFM parser: http://www.petr.nl/just/FontTools.tar.gz Sorry, the doco is, erm, somewhat limited ;-) Just From morganea at bellatlantic.net Wed Jul 5 20:26:41 2000 From: morganea at bellatlantic.net (Michel Orengo) Date: Wed, 05 Jul 2000 18:26:41 GMT Subject: [ANN]pre-release DBAPI2.0 for ADO Message-ID: Hi all, I enclosed a very preliminary version of the DBAPI 2.0 for ADO (Microsoft Active X Data Object) - ADODBpy. It is built on top of another module called ADOpy which give a more "pythonic" interface to ADO (I've posted this module few days ago) ADODBpy is still largely incomplete (does not deal with exceptions for instance). It is released to get a feedback from the python community. Some examples to get you started: import ADODBpy db = ADODBpy.connect('MyDB', 'MyUser', 'MyPassword') cur = db.cursor() cur.execute('select * from mytable') tup = cur.fetchone() #now because it is build on top of ADOpy, we can access also the properties/methods of the #underlying ADOobject print db.provider print cur.fields.Item('col').Value # or better: print cur['col'] Hope this help. Cheers, Michel begin 666 ADODBpy.zip M4$L#!!0``@`(`%QOW"@DOGOS3 0``(P-```(````041/<'DN<'G-5LUNXS80 MO@?(.TR=@^3&$;+;4X.F11JG0 Y)C'3;+1H8`DV-8VYE4B#I.%KTF?H0^V0[ M)!69EI5NVAQ:(0ADSO_WS0QU`$=?>O;W#N!L?%/5)W#!3 V7TJ*>,XXP5]I) MG,)+O#B]]UI8BQ)F-5P)OL 2;C3*>Y7!9#4K!8>Q6C(A,Z=[K>!<5;46]PL+ M(Y *;MVK at 5LTJ!^P& &3A3M_S[1FT at HTL%XP:Q0^H,Z:D/1JA))PG+W=WZ.# M`WBW$ :6JEB5"(*JD84!JZ#2ZD$4"(QD&F%0U7:AI. #KQ1*)K50L<<$3ET5 M6ADUMY_^@C-NQ0/^1F]C9AG2TNA(LK$P%;-\D2:4YOC'[%Q) M2O M-*'NI$UJVU9!NF/E+:_5>@1V at 6"H;N+"+IJ)BV&JFTD8&&LQ-PI MU+!&&EAC:8IBK88;2^SUN2"3`@F0PDT at +0@7:C )2T /LF9NR;O39)R2-6+F M!K?VJE1U&9@#Y2<]:G2W:/;W&N*-)5#N1Z"Q/6H'O3W9&>W]O=R1:!S(F)&D M$B5QDOXP^6Y=?']W=O3[U/\[_#.\LZ./QT??3@^'KB_W]WA)70`YP>W?J!.! MG at +GD.?W2$A9G>6%UDIW M at G72_:"$3 -VV5S(@I5E&@*.$D at Z47=3C]/?3CM>9,%A6!2[]OVU1/6T_#MB M<^PIRKMAPF"G]C2"+K!I>M@"&[S_,[YGFY[]?QP1E=&8*9-*N9EVTO2ZB33L)[#K\[X"HO+EO _L(X= M-LUWWJZG2U+N4$9WF+.*-D5T#[5+8[BU-804MHW9?"OITR1Y<3'/?J,,NM\H M at XAH6O%/P> KNM&2G9[LTAUT3UNSN,CEDNZ7%U78NCR]5G)KDBBC5NB^Z9R\ M+ZE_CX//, at 8!2],?PG?7IJ\VI6ZN]/]WL6V>KRNWT^VOJ_F96-'*;==MS^"9 MG049-LXP+B=8;9?X&5!+`P04``(`" !K8N4H!G'^:A\'``!O% ``"@```$%$ M3T1"<'DN<'FU5VU/X\86_ at P2_^&4B.+T>JV$95^*RI5@`[V1N@$!V]6JJJ*) M/4GFKNWQSHQATU_?_#B>S][NSTX&UV-SJ\_ MG<"(&39CFL/9]1B.D@',I2(N at 9XCB7 ?E3"&ES!;P7N1+GD.5XJ7"YG =3W+ M10HC63!1)H2=2'@GJY42BZ6!&$H)-_2HX89KKNYY%@,K,Z)_9$JQT at BNX6') MC);\GJND48F/6L at 2!LEP;W=O5Q255(;LKE;0$Z7A:LY2#@_"+)TW#<*L*JYC M\IK?B8)#C]R=B3(3Y<(J3F5I5)T:J30)WMLU2\59IMF%-HRG)Q' M<1U&H.^;X"[7A3'C8=O->38_*9I9PWFHQ:A3#D(H/. M?TUY94+61);C[GRE'3G&D-MP83A:GL0BFIH at LK!7/1ZJH0 MX'&8P"6F5=3!;Z&;Y//[IGN4UURX]B9(X`N:'>VA/I47E#TFSY$XG);M]`U%"<-SR M?/(-.L!?OHD;TDN;^Y[ZPO;!V[N;\>17JL>N5Y&%X@\,CWZ.H<>R=TNF6N+1 M8&B)O\ER\3M3'=[;&(!XYRB[);XYBBWQUP_CT5KTP!%MK /9+T/9'SO"AR\' M]DB7BL5Y/IZ"BSLF']^<7-T_J/'8> MCG at J"I:W]%=-C$82YQUOR2\;LBT/'G@]=&+.IM\PUT`)NZ,?"CL[N+N_'[BZ="_\:'V$["-BXNMT;G&^3CANPF M9$M^%9!OW71L>/#ZV(J_Q(G=.01DX,W5Q_'H*>M0]NNFJBKL;K at Y@=T2I%L4 MV$S6QJT+.&&2)/$'^V$GPA6 at 1*G8=2.[R"1K0M^WI=217(.!3).O)()?-\QM+/FUA/[Z+36FELO<[$ MDA7\]! '.] I9&$8WSD`L?H--6'HYSU?>XPPJP(C(6VP at S&-^"!J3IB/6%'@ M((W=VPU/T5W-3?_QKKXVCH1W)"0=9!_OENZ/PXPO! UU$.90`[,Q1'C3NDD> M_' *AX>N-UL/+/'4\MK T6J[TN(O8 at Q;:L9UJD35N.^6D3;2#ZFL2X-TZO0N MSEAIN&VFC3/T2$IB^,FNF1P3,9Q8_"M/:\.C-6X-B^'8WYZ'.:'2+P(A^O2/ M/V/O.57#Z7 C?XC.OY*Q[?DM/IY#?O#F+MC>&#+\-+3;VMH=^"\,7&S71$07 MK(K<=AG:V7<#4B.Q$\38QG8KPY*+QO7&BBU1P=#=DOE=:?W&(3R:7 J>9QIS MC0YBO at R:;QYCN1=7ET'Z3%.F381T3,*)?,#$PR3$L'%*/^4SW.+]HKN=,^[= M at JU2BPKVWYUF+=K9SD2\;$NG[QM!^PO6^L*E1S(/_. at W@BS-JVP`8\.+2+CK MV&GJP;*2"?.]EK[,IJG,^"-]UF&)T,C(A*YRMIHV)>3X(SX7-(&0YE"BV32[ ML+/4U"Q?HRJ,B]"NYASBVE.:8&*A!1:[&7Q+Q,:A.L^G\O-:`7[3B!E>O88? M8?#U:& '2YZ-]021K-T0-B.=L H[=A9%KCK;@&"?#]R-H>-6[$>)G4.M+YB= M9""V.&=A6VR6N^9>IG$_#OO"OE+E%H*VHB&>^!6[4/N5;4.-V<=ZP M+JB29Q>Q_0[E)EUB!PC&65LZ6*%6(!4A=#X+NP6SPS[!<-LYZ_6;NLIY1)(ZS at 772TER.F@_0UPI8(Q/ MFD?H#J0M9X2_$&PG;5G[`%I3'I:X-$%$?%QPJ(M15/JVIT6"OF10[B,^XP%7 MSJ1"P']<&GQ;C_]^1Q&AKS@%@XOLV/X=DS2ZS]KPR41=S_< M;F+:_NB_W__\QI.6U/*"K;/OB$EP_K'=T6]A)5;[WU!+`0(4`!0``@`(`%QO MW"@DOGOS3 0``(P-```(``````````$```"V at 0````!!1$]P>2YP>5!+`0(4 M`!0``@`(`&MBY2@& Message-ID: <39637f28@news.xtml.co.uk> "Thaddeus L Olczyk" wrote in message news:3967f81e.23966859 at nntp.interaccess.com... > I need a "free" gui framework that runs on both Windows and UNIX > ( so that lets out QT ) and gives me a component similr to Microsofts > TreeView. Does anyone know of such a thing? Python Mega widgets adds tree view to tkInter I believe. wxPython and pyFltk are 2 window system with Python bindings. wxPython certainly has a tree view. From olivierS.dagenaisP at canadaA.comM Wed Jul 5 20:56:47 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 18:56:47 GMT Subject: [ANN]pre-release DBAPI2.0 for ADO References: Message-ID: Hey, this announcement made me think of a question concerning databases: is the DBAPI designed for exchanging recordsets between databases opened by two different implementations? For example, could I take your ADO cursor and assign it to a database opened with, say, Gadfly? (supposing they had the same table definitions) Thanks! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Michel Orengo" wrote in message news:B5L85.2924$EV6.75523 at typhoon1.ba-dsg.net... > Hi all, > I enclosed a very preliminary version of the DBAPI 2.0 for ADO (Microsoft > Active X Data Object) - ADODBpy. It is built on top of another module called > ADOpy which give a more "pythonic" interface to ADO (I've posted this module > few days ago) > > ADODBpy is still largely incomplete (does not deal with exceptions for > instance). It is released to get a feedback from the python community. > > Some examples to get you started: > > import ADODBpy > > db = ADODBpy.connect('MyDB', 'MyUser', 'MyPassword') > cur = db.cursor() > cur.execute('select * from mytable') > tup = cur.fetchone() > > #now because it is build on top of ADOpy, we can access also the > properties/methods of the > #underlying ADOobject > print db.provider > print cur.fields.Item('col').Value > # or better: > print cur['col'] > > Hope this help. > Cheers, > Michel > > > From embed at NOSPAM.geocities.com Wed Jul 5 20:58:43 2000 From: embed at NOSPAM.geocities.com (Warren Postma) Date: Wed, 5 Jul 2000 14:58:43 -0400 Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> Message-ID: "Gordon McMillan" wrote in message news:8F655BA3Egmcmhypernetcom at 199.171.54.154... > [posted and mailed] > C'mon Sean! You've been around a while. You know when __getattr__ hacks go > bad it's because they go recursive. (And the stack size on Windows is off > by some tiny amount, so it GPFs instead of traps.) That kinda says (a) Windows Sucketh, and (b) surely there must be a workaround for the Infinite-Recursion-Crash bug? Oh yeah, there is, .... It's called Christian Tismer's Stackless Python. Hope that stackless makes it into the official python, by 1.7, or if not, there's always 3000. Here's hoping. Warren From scorder at incigna.com Wed Jul 5 21:22:59 2000 From: scorder at incigna.com (Sam Corder) Date: Wed, 5 Jul 2000 15:22:59 -0400 Subject: Ado stored procs with parameters Message-ID: I'm having a bit of trouble using a stored proc on MSSQL that takes parameters. I create a command object and then append the parameters to it. Then I create a recordset object and use the open method passing the command object and a few other parameters. Unfortunately I get an error saying that the stored proc requires The same parameter that I just added. Below is the code I'm using. Any ideas? Sam Corder import win32com.client constants = win32com.client.constants class dbcon: def __init__ (self, connect = None): self.connectstr = connect def runSQLReturnRS(self, sql, params = None): if self.connectstr == None: return None else: rs = win32com.client.Dispatch('ADODB.Recordset') cmd = win32com.client.Dispatch('ADODB.Command') cmd.ActiveConnection = self.connectstr cmd.CommandText = sql if params != None: for parm in params: cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1], constants.adParamInput, parm[2], parm[3])) rs.Open(cmd, CursorType = constants.adOpenForwardOnly, LockType = constants.adLockReadOnly) return rs def __AddParams(self, cmd, params): for parm in params: cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1], constants.adParamInput, parm[2], parm[3])) if __name__ == '__main__': db = dbcon("Provider=SQLOLEDB;Data Source=s-incigna2k;User Id=msl_login;Password=***;Connect Timeout=5;network library=dbmssocn;Initial Catalog=msl;") params = ("ExpJobID", constants.adInteger, 4, 11), rs = db.runSQLReturnRS("ExpConfig_Get", params) print rs.Fields.Count From kpmurphy at my-deja.com Wed Jul 5 21:08:51 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Wed, 05 Jul 2000 19:08:51 GMT Subject: Grid Geometry Manager and grouping? Message-ID: <8k013q$lon$1@nnrp1.deja.com> i've found that i like grid the best. is there a way to group sections of the window together... like the left side is for one purpose and the right for another? I have been playing with frames to no avail. i really appreciate all the help this ng has given me thus far in learning python. kudos to all of you! -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From jamarijr at hotmail.com Wed Jul 5 21:42:28 2000 From: jamarijr at hotmail.com (Arinté) Date: Wed, 05 Jul 2000 19:42:28 GMT Subject: Embedded apps and range??? Message-ID: <8k0331$n7d$1@nnrp1.deja.com> I am trying to use a range in a for loop for i in range(-1,sz): devlist[0] = PossDevice.PossArg(resource,i) devlist[0].setValue(i) ret = diz.set(devlist) diz.ioctl("POS_SYS_GET_VALUES",devlist) if i not in _range: print "Checking for errors " + str(ret) checkForErr(ret,error) I am getting the good old "TypeError: len() of unsized object" error, problem is when I use range(sz) or range(1,sz) I don't get the error??? Sent via Deja.com http://www.deja.com/ Before you buy. From jtravis at cse.unl.edu Wed Jul 5 22:07:59 2000 From: jtravis at cse.unl.edu (Jon Travis) Date: 5 Jul 2000 20:07:59 GMT Subject: BUG: profile.py Message-ID: <8k04iv$meo$1@unlnews.unl.edu> There is a small bug while running some of the profiling code from within the profiler. Specifically: import profile x = profile.Profile() x.run("x.dump_stats('/tmp/foo')") I have a small 2 liner fix, but I doubt it is correct, merely a band-aid, so I won't post it. -- Jon From johannes at zellner.org Wed Jul 5 22:24:15 2000 From: johannes at zellner.org (Johannes Zellner) Date: Wed, 5 Jul 2000 22:24:15 +0200 (CEST) Subject: readline.c & more Message-ID: Hello, I just compiled python 2 from CVS. ?) I had to modify Objects/fileobject.c because there was a name clash between `getline' there and in /usr/include/stdio.h (as it comes with the latest debian potato). I replaced `getline' with `file_getline' in Objects/fileobject.c. ?) I modified Modules/readline.c so that it allows reading and writing of a history file. I also plan to implement readline functions as `stifle history'. Eventually I'd also add the possiblity to register a script completer which would be called before the builtin completers. My question about this: where would I post patches ? -- I've an account on SF for other projects, but as this is my first mail to the list I'd understand if you won't trust me ;-) ?) Is there a forum for developers? This list seems more for users isn't it ? greetings, -- Johannes From richard_chamberlain at ntlworld.com Wed Jul 5 22:30:06 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Wed, 5 Jul 2000 21:30:06 +0100 Subject: Embedded apps and range??? References: <8k0331$n7d$1@nnrp1.deja.com> Message-ID: <6UM85.860$dL5.16129@news6-win.server.ntlworld.com> What is sz assigned to? >>> sz=3 >>> for i in range(sz): ... print i ... 0 1 2 >>> for i in range(1,sz): ... print i ... 1 2 An integer works fine. Richard Arint? wrote in message news:8k0331$n7d$1 at nnrp1.deja.com... > I am trying to use a range in a for loop > for i in range(-1,sz): > devlist[0] = PossDevice.PossArg(resource,i) > devlist[0].setValue(i) > ret = diz.set(devlist) > diz.ioctl("POS_SYS_GET_VALUES",devlist) > if i not in _range: > print "Checking for errors " + str(ret) > checkForErr(ret,error) > > I am getting the good old "TypeError: len() of unsized object" error, > problem is when I use range(sz) or range(1,sz) I don't get the error??? > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From digitig at cix.co.uk Wed Jul 5 22:29:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Wed, 5 Jul 2000 21:29 +0100 (BST) Subject: [FAQTS] Python Knowledge Base Update -- July 1st, 2000 References: <20000702031926.7937.qmail@synop.com> Message-ID: In article <20000702031926.7937.qmail at synop.com>, fiona at sitegnome.com (Fiona Czuczman) wrote: > On Windows 9x systems, you may also use the COM interface. We have > recently used PythonWin to (what else?) spam a number of recipients > over Novell GroupWise. It took very little time to work this out. Ah, that's useful -- I sometimes use Python to parse text into an Access 97 DB, and at the moment I do it via CSV's. Where do I find info on the COM interface? With that I should be able to poke it in directly. From gmcm at hypernet.com Wed Jul 5 22:39:50 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 05 Jul 2000 20:39:50 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> Message-ID: <8F68A4032gmcmhypernetcom@199.171.54.194> Warren Postma wrote: > >"Gordon McMillan" wrote in message >news:8F655BA3Egmcmhypernetcom at 199.171.54.154... >> [posted and mailed] >> C'mon Sean! You've been around a while. You know when __getattr__ >> hacks go bad it's because they go recursive. (And the stack size on >> Windows is off by some tiny amount, so it GPFs instead of traps.) > > >That kinda says (a) Windows Sucketh, and (b) surely there must be a >workaround for the Infinite-Recursion-Crash bug? Well, (a) is your own conclusion, not mine; and Christian also has a tiny little patch that fixes (b) for standard Python on Windows (it's a miscalculation in Python's config that doesn't leave enough stack space for handling the traceback). I don't use it, because I know the symptoms, and can usually fix the problem before the stack trace finishes printing. >Oh yeah, there is, .... It's called Christian Tismer's Stackless Python. >Hope that stackless makes it into the official python, by 1.7, or if >not, there's always 3000. Here's hoping. I love it too, but it gives you a whole bunch of entertaining new ways to get into infinite recursions. - Gordon From richard_chamberlain at ntlworld.com Wed Jul 5 22:44:31 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Wed, 5 Jul 2000 21:44:31 +0100 Subject: Grid Geometry Manager and grouping? References: <8k013q$lon$1@nnrp1.deja.com> Message-ID: Hi Keith, For what purpose do you want to group the areas? An example of frames: from Tkinter import * root=Tk() frame1=Frame(root,relief=GROOVE,borderwidth=3) frame2=Frame(root,relief=GROOVE,borderwidth=3) for i in range(1,9): Label(frame1,text="Frame: 1 - Label: %d" %i).pack() Label(frame2,text="Frame: 2 - Label: %d" %i).pack() frame1.pack(side=LEFT,fill=BOTH,expand=1) frame2.pack(side=LEFT,fill=BOTH,expand=1) root.mainloop() Pmw has got Pmw.Group, a framed widget on which you can have a label or other widget in the frame and then a number of widgets within the frame. Give me an example of what you want to achieve and I'll have a go. Richard Keith Murphy wrote in message news:8k013q$lon$1 at nnrp1.deja.com... > i've found that i like grid the best. is there a way to group sections > of the window together... like the left side is for one purpose and the > right for another? I have been playing with frames to no avail. > > i really appreciate all the help this ng has given me thus far in > learning python. kudos to all of you! > > -->keith > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From smoriano at sicon.net Tue Jul 4 14:00:18 2000 From: smoriano at sicon.net (sergio) Date: Tue, 04 Jul 2000 14:00:18 +0200 Subject: PROCESS QUESTION Message-ID: <3961D1D2.9C66B425@sicon.net> Hi all, I'm working in NT SERVER 4.0 How can i search the id of a process running, searching it by the name? Thanks for all your responses From no_spam at umich.edu Wed Jul 5 22:59:56 2000 From: no_spam at umich.edu (Jeff) Date: Wed, 5 Jul 2000 13:59:56 -0700 Subject: Overloaded Operators allowed??? Message-ID: <8k07ke$j0r@news.or.intel.com> Can you overload operators as you can in other languages? For example, can I make "&" give the address of something as in C++? Or can I only overload things like the cmp operator? i.e. I want to say &string and get the address of string. thanks From bjorn at roguewave.com Wed Jul 5 23:38:35 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 05 Jul 2000 15:38:35 -0600 Subject: Overloaded Operators allowed??? References: <8k07ke$j0r@news.or.intel.com> Message-ID: <3963AADB.25A6776E@roguewave.com> Jeff wrote: > > Can you overload operators as you can in other languages? For example, can > I make "&" give the address of something as in C++? Or can I only overload > things like the cmp operator? i.e. I want to say &string and get the > address of string. Since "&string" is illegal syntactically in Python it wouldn't make sense to let you overload on it. It would be like saying "I want to overload @ in C++ so I can use it to append lists, like list1 @ list2..." Besides, you really don't want the address of the string (trust me ). -- bjorn From johannes at zellner.org Wed Jul 5 23:28:10 2000 From: johannes at zellner.org (Johannes Zellner) Date: Wed, 5 Jul 2000 23:28:10 +0200 (CEST) Subject: cleanup order Message-ID: Hi, suppose I've # fred provides `fun' import fred class Lola: def __init__(self, x): self.x = x def __del__(self): fred.fun(self.x) x = Lola('hello') # end of script this doesn't work, because fred is not present any more when x is destroyed. I don't know anything about python's internals, but I guess the dynamical loaded shared object's function table is destroyed (somehow) before x is destroyed. Any comments ? (or even workarounds ?) -- Johannes From darrell at dorb.com Thu Jul 6 02:38:34 2000 From: darrell at dorb.com (Darrell Gallion) Date: Wed, 5 Jul 2000 17:38:34 -0700 Subject: ASPIPython update on Starship References: <8jvg2d$8q5$1@nnrp1.deja.com> Message-ID: <029c01bfe6e2$84dff390$6401a8c0@home> From: "Sam Schulenburg" > I have made some corrections to ASPIPython, that correct memory leaks > found in aspi.dll. > > ASPIPython is a open source python interface to the (A)dvanced (S) > system (P)programming (I)nterface for SCSI devices developed by Adaptec > Corp. This interface allows for the development of tests under Python > for SCSI disk drives. These routines can be found at > http://starship.python/crew/schulen > This link worked better for me :) http://starship.python.net/crew/samschul/ --Darrell Gallion From cut_me_out at hotmail.com Wed Jul 5 23:38:53 2000 From: cut_me_out at hotmail.com (Alex) Date: 5 Jul 2000 22:38:53 +0100 Subject: Python Module for sequence alignments. Message-ID: Hi. I made a python module that does simple sequence alignments. If there is enough interest, I may make it a little more elaborate. You can get it from http://puffin.lcs.mit.edu:8080/align.tgz To use it on linux tar zxf align.tgz cd align make and make the align directory accessible to python, with a command like setenv PYTHONPATH `pwd`:${PYTHONPATH} It needs the Numeric extension. Here's an example of how it works from the command line: >>> import align >>> align.align ('aneotuhaneot', 'asneouhoteuh')[0][0][:3] ('neotuhane', 'sneouhote', '----uh--e') The second element of the tuple it returns is the matrices used to calculate the optimal alignments. I don't really care how you use or change this, nor will I assume any legal culpability for problems arising from its use. For instance, if a bug in this code tricks you into genetically engineering Giant Super-Intelligent Man-Eating Lizards, I may cackle evilly, but I won't explicitly own up. I may take on the care and feeding of one or two of them if you can prove they will co-exist peacefully with my cat, but that's definitely as far as it goes. But please do let me know of any problems with it, or any suggestions you have about how I could improve it. If you make any use or improvements to it yourself, I would love to hear about them. Alex. From petersc at stud.ntnu.no Thu Jul 6 01:44:29 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Wed, 05 Jul 2000 23:44:29 +0000 Subject: readline.c & more References: Message-ID: <3963C85D.3924126C@stud.ntnu.no> Johannes Zellner wrote: > > ?) I had to modify Objects/fileobject.c because there was a > name clash between `getline' there and in /usr/include/stdio.h > (as it comes with the latest debian potato). I replaced > `getline' with `file_getline' in Objects/fileobject.c. as far as I can see this has been fixed today. look for revision 2.78 in the CVS repository (or better yet, update). > ?) I modified Modules/readline.c so that it allows reading and > writing of a history file. I also plan to implement readline > functions as `stifle history'. Eventually I'd also add the > possiblity to register a script completer which would be > called before the builtin completers. My question about > this: where would I post patches ? -- I've an account on > SF for other projects, but as this is my first mail to the > list I'd understand if you won't trust me ;-) mailto:patches at python.org for more details check out http://www.python.org/patches > ?) Is there a forum for developers? This list seems more for > users isn't it ? there is. but it's hard to get in (still trying). the mailing list python-dev is probably what you are looking for. better-history-means-less-typing-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From bjorn at roguewave.com Thu Jul 6 00:05:50 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 05 Jul 2000 16:05:50 -0600 Subject: cleanup order References: Message-ID: <3963B13E.8E77CC19@roguewave.com> Johannes Zellner wrote: > > Hi, > > suppose I've > > # fred provides `fun' > import fred > > class Lola: > def __init__(self, x): > self.x = x > def __del__(self): > fred.fun(self.x) > > x = Lola('hello') > # end of script > > this doesn't work, because fred is not present any more > when x is destroyed. I don't know anything about python's > internals, but I guess the dynamical loaded shared object's > function table is destroyed (somehow) before x is destroyed. > > Any comments ? (or even workarounds ?) This should work: ... def __del__(self, fun=fred.fun): fun(self.x) it's using a default argument to make sure the reference count to fred.fun doesn't reach zero until the Lola instance is deleted. -- bjorn From ram_garapaty at spk.agilent.com Wed Jul 5 23:57:40 2000 From: ram_garapaty at spk.agilent.com (Ram Garapaty) Date: Wed, 05 Jul 2000 14:57:40 -0700 Subject: serial communication in python..?? Message-ID: <3963AF53.F16F9CAA@spk.agilent.com> Hi! i am new to python and would like to know whether python would be any assistance to my situation as described below: i got a testing box which send s out the data through a serial port, i would like to capture that data through GUI window in PYTHON . Is this possible in python if soo please suggest me the right topics in python and right material to go through python asap. thanks in advance ram From ge at nowhere.none Thu Jul 6 00:04:57 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 05 Jul 2000 22:04:57 GMT Subject: MAPI/COM: where is the server? Message-ID: My MAPI/COM e-mail fetcher (running under win95) does this: self.session = win32com.client.Dispatch("MAPI.Session") self.session.Logon("MS Eschange Settings") [message fetching code left as an exercise for the reader] This was all developed without any basic understanding of DCOM or MAPI by copying other people's examples and semi-random trial-and-error. Question: Is it talking to Exchange server (which runs on a remote machine), or is it talking to a local copy of MS Outlook which is then acting as an intermediary? If it's talking directly to Exchange server, then there's a possibility I could do the same thing from Linux using either Software AG's product or GCOM. If my program is just talking to the local copy of MS Outlook, then running the program under Linux isn't very useful, since I still have to run that win95 machine that's sitting over in the corner. -- Grant Edwards grante Yow! I have the power at to HALT PRODUCTION on all visi.com TEENAGE SEX COMEDIES!! From thomas at xs4all.net Thu Jul 6 00:13:48 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 6 Jul 2000 00:13:48 +0200 Subject: __getattr__ and pickle In-Reply-To: ; from embed@NOSPAM.geocities.com on Wed, Jul 05, 2000 at 02:58:43PM -0400 References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> Message-ID: <20000706001348.E13478@xs4all.nl> On Wed, Jul 05, 2000 at 02:58:43PM -0400, Warren Postma wrote: > "Gordon McMillan" wrote in message > news:8F655BA3Egmcmhypernetcom at 199.171.54.154... > > C'mon Sean! You've been around a while. You know when __getattr__ hacks go > > bad it's because they go recursive. (And the stack size on Windows is off > > by some tiny amount, so it GPFs instead of traps.) > That kinda says (a) Windows Sucketh, and (b) surely there must be a > workaround for the Infinite-Recursion-Crash bug? Well, there is. There's this little counter that keeps track, but the recursion counter is set too high for Windows, apparently, so it chooses to crash before Python stops itself. > Oh yeah, there is, .... It's called Christian Tismer's Stackless Python. > Hope that stackless makes it into the official python, by 1.7, or if not, > there's always 3000. Here's hoping. There is no 1.7, the next release is going to be 2.0, not 1.6 ;) At least, that's what the CVS tree is calling itself. As for Stackless, I agree it's a thing of coolness, but it won't help you out in infinite recursion; it's stackless, not limitless. You'll run out of memory eventually. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From billtut at microsoft.com Thu Jul 6 00:13:46 2000 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 5 Jul 2000 15:13:46 -0700 Subject: MAPI/COM: where is the server? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD26F@RED-MSG-50> Its talking to the local MAPI COM object that talks to the Exchange MAPI provider which uses whatever method it wants to communicate with the Exchange server. I believe it uses Win32 RPC. Cute diagram: +---------------------+ | MAPI.Session | | COM Object | +---------------------+ | Core MAPI | | Code | +---------------------+ | Exchange MAPI | | Provider | +---------------------+ | Win32/DCE RPC | +---------------------+ | Network | +---------------------+ | Exchange Server | +---------------------+ Bill -----Original Message----- From: ge at nowhere.none [mailto:ge at nowhere.none] Sent: Wednesday, July 05, 2000 3:05 PM To: python-list at python.org Subject: MAPI/COM: where is the server? My MAPI/COM e-mail fetcher (running under win95) does this: self.session = win32com.client.Dispatch("MAPI.Session") self.session.Logon("MS Eschange Settings") [message fetching code left as an exercise for the reader] This was all developed without any basic understanding of DCOM or MAPI by copying other people's examples and semi-random trial-and-error. Question: Is it talking to Exchange server (which runs on a remote machine), or is it talking to a local copy of MS Outlook which is then acting as an intermediary? If it's talking directly to Exchange server, then there's a possibility I could do the same thing from Linux using either Software AG's product or GCOM. If my program is just talking to the local copy of MS Outlook, then running the program under Linux isn't very useful, since I still have to run that win95 machine that's sitting over in the corner. -- Grant Edwards grante Yow! I have the power at to HALT PRODUCTION on all visi.com TEENAGE SEX COMEDIES!! -- http://www.python.org/mailman/listinfo/python-list From arnold at dstc.monash.edu.au Thu Jul 6 00:18:44 2000 From: arnold at dstc.monash.edu.au (David Arnold) Date: Thu, 06 Jul 2000 08:18:44 +1000 Subject: MAPI/COM: where is the server? In-Reply-To: Your message of "Wed, 05 Jul 2000 22:04:57 GMT." Message-ID: <200007052218.IAA26977@xevious.dstc.monash.edu.au> -->"Grant" == Grant Edwards writes: Grant> If it's talking directly to Exchange server, then there's a Grant> possibility I could do the same thing from Linux using either Grant> Software AG's product or GCOM. what's GCOM? (sorry, google reveals nothing useful ...) d From thomas at xs4all.net Thu Jul 6 00:25:11 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 6 Jul 2000 00:25:11 +0200 Subject: readline.c & more In-Reply-To: <3963C85D.3924126C@stud.ntnu.no>; from petersc@stud.ntnu.no on Wed, Jul 05, 2000 at 11:44:29PM +0000 References: <3963C85D.3924126C@stud.ntnu.no> Message-ID: <20000706002510.F13478@xs4all.nl> On Wed, Jul 05, 2000 at 11:44:29PM +0000, Peter Schneider-Kamp wrote: > Johannes Zellner wrote: > > ?) I modified Modules/readline.c so that it allows reading and > > writing of a history file. I also plan to implement readline > > functions as `stifle history'. Eventually I'd also add the > > possiblity to register a script completer which would be > > called before the builtin completers. My question about > > this: where would I post patches ? -- I've an account on > > SF for other projects, but as this is my first mail to the > > list I'd understand if you won't trust me ;-) > mailto:patches at python.org > for more details check out http://www.python.org/patches Actually, SourceForge is now preferred over patches at python.org. http://www.python.org/patches also reflects this, by the way ;) Looking at the number of patches that were submitted (mostly backlog) and processed, I believe the SF patch manager is working out reasonably OK, even if it has some oddities. Then again, I only submit the odd patch, dont apply them myself ;) Additionally, I think Skip Montanaro (skip at mojam.com) is also working on making readline/rlcompleter write a history file, though I don't know if calling external scripts is on his wishlist. You might want to coordinate with him. > > ?) Is there a forum for developers? This list seems more for > > users isn't it ? > there is. but it's hard to get in (still trying). the mailing > list python-dev is probably what you are looking for. python-dev at python.org and patches at python.org are both invite-only, but the archives are public (and they're up to date again, too :): http://www.python.org/pipermail/python-dev http://www.python.org/pipermail/patches If you want to talk shop about a patch you wrote, and you don't feel confident enough to upload it to SourceForge, python-dev at python.org is the right email address. Unless there is an active SIG or such on the subject, of course. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From thomas at xs4all.net Thu Jul 6 00:46:46 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 6 Jul 2000 00:46:46 +0200 Subject: Overloaded Operators allowed??? In-Reply-To: <8k07ke$j0r@news.or.intel.com>; from no_spam@umich.edu on Wed, Jul 05, 2000 at 01:59:56PM -0700 References: <8k07ke$j0r@news.or.intel.com> Message-ID: <20000706004646.G13478@xs4all.nl> On Wed, Jul 05, 2000 at 01:59:56PM -0700, Jeff wrote: > Can you overload operators as you can in other languages? For example, can > I make "&" give the address of something as in C++? Or can I only overload > things like the cmp operator? i.e. I want to say &string and get the > address of string. Well, you have two issues here. There is no 'address-of' operator in Python, so there is nothing to overload. Secondly, overloading in python is more like overloading _behaviour_ than actually writing your own entirely different operators. You can overload a number of operations, but you won't be able to tell in what context they were called. For instance, if you define a __pow__ overloader, it can be called by 'x ** y' or by 'pow(x,y)', or by 'pow(x,y,z)'. Also, because Python doesn't have augmented assignment (+=, >>=, etc) your overloaders always have to return a new result object, instead of modifying themselves in-place. So it's theoretically possible to make a file object that takes arguments like the C++ I/O mechanisms: x << "spam" But because << is right-associative, you can't do something like: x << "spam" << int(count) << "eggs" unless you provide wrapper objects for all arguments that provide proper __lshift__ methods ;-P As for augmented assignments, I've written a patch for that, but it won't be going into Python for a while, if ever. See http://www.xs4all.nl/~thomas/python/ This isn't really a problem, though, even in large programs: If what you want to overload an operator with isn't really the same as the operator was intended for, you shouldn't use an operator, you should use a method. I remember how scared I was when I read about C++'s operator->*() ;-P The 'special method names' are explained in the Language Reference: http://www.python.org/doc/current/ref/specialnames.html This includes operator overloading, indexing, etcetera. The part about the methods that overload the usual operators is: http://www.python.org/doc/current/ref/numeric-types.html One thing that is missing from Python 1.5.2 is the ability to override the 'in' operator. That's added in Python 2.0 though, using __contains__. In Python 1.5.2 and earlier, and in Python 2.0 when there is no __contains__ method, 'in' works by repeatedly calling '__getitem__'. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aaron.ginn at motorola.com Thu Jul 6 00:09:24 2000 From: aaron.ginn at motorola.com (Aaron Ginn) Date: 05 Jul 2000 15:09:24 -0700 Subject: Two Tkinter questions (long) Message-ID: I have two questions about Tkinter. First, how do you supress a command that is executed by a button when a widget is created? I'm trying to create a file browser with three buttons, an OK button which applies the selection, a filter button which filters the current directory for a matching pattern and a cancel button which does the obvious. The problem is that when I create the file browser in a toplevel widget, the command that my buttons are supposed to execute are executed immediately. For instance, here's a portion of code: class FileBrowser: def __init__(self, obj, dir): self.list_of_files = [] self.list_of_dirs = [] # Set the default directory to dir. self.filter_directory = StringVar() self.filter_directory.set(dir) # Set defualt filter value to all files in dir. self.filter_pattern = StringVar() self.filter_pattern.set('*') self.selection_value = StringVar() self.selection_value.set('None') self.top = Toplevel() < SNIP a lot of wigdets for brevity > self.Filter = Button(self.button_frame, text = 'Filter', \ command = self.do_filter()) self.Filter.pack(side = LEFT, padx = 10) The filter button is bound to a method called do_filter which is as follows: def do_filter(self): """ Method that generates a list of files and a list of directories in a directory given a filter pattern, and add them to a listbox for each. """ filter_path = '%s/%s' %(self.filter_directory.get(), self.filter_pattern.get()) files_matching_pattern = glob.glob(filter_path) # Clear the listboxes self.filelist.delete(0,END) self.dirlist.delete(0,END) # Add . and .. to list of directories. self.dirlist.insert(END, '.') self.dirlist.insert(END, '..') # Fill the listboxes for file in files_matching_pattern: [head, tail] = os.path.split(file) if os.path.isfile(file): self.filelist.insert(END, tail) self.list_of_files.append(tail) elif os.path.isdir(file): self.dirlist.insert(END, tail) self.list_of_dirs.append(tail) This works fine, but the command is executed as soon as the widget is created, and then I can't execute it again. It is as if the script has been executed and terminated but the GUI still exists. Why is the command that button is bound to executing before I invoke the button? This leads to my second question. I put the command in a lambda statement to supress it's execution. When I do this the filter function works great, and I can execute it multiple times. However, when I try to bind the method do_filter to an Event, the event fails with the following error: coronado <189> semiDRC.gui -gui Exception in Tkinter callback Traceback (innermost last): File "/home/ginn/python_tk/lib/python1.5/lib-tk/Tkinter.py", line 764, in __call__ return apply(self.func, args) File "/home/ginn/bin/semiDRC.gui", line 450, in self.filter_entry.bind('', lambda s=self: s.do_filter()) AttributeError: do_filter The bind statement is self.filter_entry.bind('', lambda s=self: s.do_filter()) Is there a problem with binding an event to a lambda function? How do you do this? I'm very confused right now! Aaron -- Aaron J. Ginn Motorola SPS Phone: (480) 814-4463 SemiCustom Solutions Fax: (480) 814-4058 1300 N. Alma School Rd. mailto:aaron.ginn at motorola.com Chandler, AZ 85226 From ge at nowhere.none Thu Jul 6 00:49:20 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 05 Jul 2000 22:49:20 GMT Subject: Two Tkinter questions (long) References: Message-ID: In article , Aaron Ginn wrote: >The problem is that when I create the file browser in a >toplevel widget, the command that my buttons are supposed to execute >are executed immediately. For instance, here's a portion of code: > >class FileBrowser: > > def __init__(self, obj, dir): > >< SNIP a lot of wigdets for brevity > > > self.Filter = Button(self.button_frame, text = 'Filter', \ > command = self.do_filter()) self.Filter = Button(self.button_frame, text = 'Filter', \ command = self.do_filter) >self.filter_entry.bind('', lambda s=self: s.do_filter()) Functions bound to events need to take an event as a parameter (if you don't want the event, you can use lambda to discard it): self.filter_entry.bin('', labda event: self.do_filter()) or you can define another function that will accept an event parameter: def do_filter(self, *args) Now you can just do self.filter_entry.bin('', self.do_filter) >Is there a problem with binding an event to a lambda function? No. The problem is that normal button command functions are passed 0 arguments and event functions are passed one argument (the event). -- Grant Edwards grante Yow! I am a traffic light, at and Alan Ginzberg kidnapped visi.com my laundry in 1927! From tim.hochberg at ieee.org Thu Jul 6 01:06:17 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 05 Jul 2000 23:06:17 GMT Subject: Two Tkinter questions (long) References: Message-ID: "Grant Edwards" wrote in message news:QXO85.3118$iN5.767799 at ptah.visi.com... > In article , Aaron Ginn wrote: [SNIP] > Functions bound to events need to take an event as a parameter > (if you don't want the event, you can use lambda to discard it): > > self.filter_entry.bin('', labda event: self.do_filter()) You still needs to bind self to a default variable in order for it to be accesible inside the lambda, e.g, self.filter_entry.bin('', lambda event, self=self : self.do_filter()) (I suspect this is just a typo on Grant's part, but I figure I'd clarify it for Aaron...) -tim From kellyk at my-deja.com Thu Jul 6 00:57:39 2000 From: kellyk at my-deja.com (kellyk at my-deja.com) Date: Wed, 05 Jul 2000 22:57:39 GMT Subject: Accessing ASP-IIS objects in modules Message-ID: <8k0egu$ujn$1@nnrp1.deja.com> I am using Python in ASP under Microsoft IIS. I can use the IIS objects like Server, Request and Response easily in my ASP script but cannot access them from a module. For example I want to use Response.Write("blah") from within a module (called from an ASP script) but Reponse is not a known object from there. Any ideas? Sent via Deja.com http://www.deja.com/ Before you buy. From tim.hochberg at ieee.org Thu Jul 6 01:11:22 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 05 Jul 2000 23:11:22 GMT Subject: Two Tkinter questions (long) References: Message-ID: "Aaron Ginn" wrote in message news:sn66qkgrfv.fsf at motorola.com... > > I have two questions about Tkinter. First, how do you supress a > command that is executed by a button when a widget is created? I'm > trying to create a file browser with three buttons, an OK button which > applies the selection, a filter button which filters the current > directory for a matching pattern and a cancel button which does the > obvious. The problem is that when I create the file browser in a > toplevel widget, the command that my buttons are supposed to execute > are executed immediately. For instance, here's a portion of code: [SNIP] > self.Filter = Button(self.button_frame, text = 'Filter', \ > command = self.do_filter()) Changing this to: self.Filter = Button(self.button_frame, text = 'Filter', # Backslash is not nesc. here. command = self.do_filter) # Note no () should go a long way toward fixing your problem. What you were doing was setting command to the result of a call of the function do_filter which returnd None. Thus the function is executed once when this line is first executed, but then never again since it is not bound to command, None is. [SNIP] -tim From cjensen at bioeng.ucsd.edu Thu Jul 6 01:19:58 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 05 Jul 2000 16:19:58 -0700 Subject: Hello Word in CGI Message-ID: <3963C29E.76211EB7@bioeng.ucsd.edu> We get this error in our server log: Wed Jul 5 16:12:52 2000] [error] [client 132.239.236.47] Premature end of script headers: /usr/local/httpd/cgi-bin/test_jmsun/cont_forms/helloworld.py The browser gives us this error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster at bioeng.ucsd.edu and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache/1.3.6 Server at cmrg.ucsd.edu Po