From m.faassen at vet.uu.nl Thu Jun 15 08:07:31 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2000 12:07:31 GMT Subject: Does Python help with the no-Unix handicap? References: <8i39ll$93f$1@slb3.atl.mindspring.net> <3947A59F.5016D9F0@sage.att.com> Message-ID: <8iagu3$ici$1@newshost.accu.uu.nl> Garry Hodgson wrote: > Aahz Maruch wrote: >> Like Grant, I've been using Unix about fifteen years, and I find Perl >> bizarre and difficult. > after reading several responses like this, i wonder if perl > is particularly irritating to old timers. I'm definitely not an old timer and it's frustrating to me too. (Gordon McMillan makes comments like "Even Martijn knows it, and he's young" :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From sjuranic at condor.ee.washington.edu Wed Jun 28 14:02:37 2000 From: sjuranic at condor.ee.washington.edu (Steve Juranich) Date: Wed, 28 Jun 2000 11:02:37 -0700 Subject: Python design philosophy Message-ID: I am *brand* new to python (as of Sunday), and I just got to the section in the tutorial about classes. I was wondering why there really isn't such an idea as a "private" member of classes? I understand that members can be hidden, but not really protected from the user. I was wondering what the benefit of this would be? Wouldn't it open the possibility of security holes? Also, what benefit is gained by allowing a user to add/delete members from existing classes? Wouldn't it be more desirable to create his/her own derived class? Please understand, I am not attempting to start a flame war. These are all questions asked in sincerity. Thanks in advance. --------------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee.washington.edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://truk.ee.washington.edu/ssli From thomas at xs4all.net Fri Jun 16 07:33:55 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 16 Jun 2000 13:33:55 +0200 Subject: Python segfault In-Reply-To: <3949C958.D3AA1F4@stud.ntnu.no>; from petersc@stud.ntnu.no on Fri, Jun 16, 2000 at 08:29:44AM +0200 References: <3949C958.D3AA1F4@stud.ntnu.no> Message-ID: <20000616133354.N26436@xs4all.nl> On Fri, Jun 16, 2000 at 08:29:44AM +0200, Peter Schneider-Kamp wrote: > > I don't know if anyone has seen this, but python segfaults when given a > > rather large input. > > [pat at perly pat]$ perl -e "print '2+2+' x 10000" > input > > [pat at perly pat]$ python < input > Strange. Looks like the limit is exactly at 8192. That makes 16384 > operations the parser (or whatever crashes) can hold. > Not that the problem is not the length of the input itself: > $ perl -e "print '22222222 ' x 200000 > input > $ python < input > works just fine. I think the problem is the add (or mul) operation. > So the problem might be in the expression parser. > Is there anyone with some more insight around? The problem is not the length of the expression, nor the 'depth' of the expression (as someone else suggested), but the 'width' of the expression. Each expression (a 'node') is parsed into X different expressions (also nodes) which are the 'children' of the current node. And each of those nodes is parsed just like the first one, and so on. So, the expression '2 + 2 + 2 + 2' is parsed somewhat like this: '2+2+2+2' /|\ / | \ / /|\ \ / / | \ \ / / /|\ \ \ / / / | \ \ \ 2 + 2 + 2 + 2 (actual operation to perform ommited, obviously) Whereas '(2 + 2) + 2 + 2' is parsed like this: '(2+2)+2+2' |\ /| \ / | |\ / | | \ (2+2) 2 + 2 /|\ / | \ 2 + 2 The problem is not the 'height' of this graph, or the total number of 'nodes' (which is limited only by memory), but the 'width' of the first tree. The 'node' struct is defined like this: typedef struct _node { short n_type; char *n_str; short n_lineno; short n_nchildren; struct _node *n_child; } node; and the 'n_nchildren' member is the number of immediate subexpressions (not grandchildren, only children) -- and it is limited to a short, which is 16 bits on most systems. And the short is signed, which means the maximum number of children is 32767. This includes the operators itself, so you can operate on just 16384 items in a single expression. If you try to operate on more, the short wraps, and the parser tries to index node->n_child[-32768], which usually segfaults. If you really hit this limit, you can add a couple of parentheses to solve the problem ;) But I agree the segfault is not very nice. There should probably be an overflow detection somewhere in node.c, but I'm not sure what kind of error it should generate. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From drew.csillag at starmedia.net Fri Jun 9 14:23:42 2000 From: drew.csillag at starmedia.net (Drew Csillag) Date: Fri, 9 Jun 2000 14:23:42 -0400 (EDT) Subject: Python Productivity over C++ In-Reply-To: Message-ID: On Fri, 9 Jun 2000, Mike Fletcher wrote: > Just a minor note, having spent all of last night (unsuccessfully) trying to > track down a memory leak. Yes, memory leak tools would be nice to have in > Python. Hidden memory leaks (cycles) are rare, but when they happen in a > complex project they are often a nightmare to track down. An optional > garbage collector with a debug mode saying "hey, I found a cycle that wasn't > cleaned up, the objects were: object types, object cycle description" would > be really cool. Yes, I'd probably remove it for the final proggy, but as a > development tool it would be very, very, useful, and is currently (to my > memory), not available. Good point. But there are actually two cycle detectors (one may or may not be derived from the other) that I know of: plumbo and Cyclops (I've used both). I believe (I may be totally wrong on this) that one of them will be included with 1.6. > > 0.02 > Mike(y) > > -----Original Message----- > From: Drew Csillag [mailto:drew.csillag at starmedia.net] > Sent: Friday, June 09, 2000 1:07 PM > To: Steve Mullarkey > Cc: python-list at python.org > Subject: Re: Python Productivity over C++ > > > > > On Fri, 9 Jun 2000, Steve Mullarkey wrote: > ... > > Python's tools are very good (and don't need them a lot of the time > anyhow). The main thing missing is a GUI builder (but glade and PyGlade > are getting there quickly). Memory leak tools just don't apply (Python > has reference counted garbage collection). Programmers editors are > numerous and one is included (IDLE). > > ... > -- print(lambda(q,p):'pmt:$%0.2f'%(q*p/(p-1)))((lambda(a,r,n),t:(a*r/ t,pow(1+r/t,n*12)))(map(input,('amt:','%rate:','years:')),1200.0)) From jkraska1 at san.rr.com Sat Jun 10 17:14:49 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 10 Jun 2000 21:14:49 GMT Subject: Case-sensitivity: why -- or why not? (was Re: Damnation!) References: <392456A9.993FB15C@concentric.net> <39245ED7.9C3A4FAB@prescod.net> <8g58j4$11ei$2@thoth.cts.com> <8g6abe$s5m$17$1@news.t-online.com> <87em66owf6.fsf@globalreach.net> <39420BAF.D86DA2BF@stud.ntnu.no> Message-ID: <3942B05F.47FDBC0A@san.rr.com> > if you write in lower-/mixed-case you see some letters sticking > out of the top or the bottom. Studies have shown that words are > not recognized letter by letter but as a complete pattern. Studies have furthermore shown that you are correct: the variety in size of the symbols eases the task of reading. C/ (who once majored in cognitive science, which studies such things) From gmcm at hypernet.com Wed Jun 7 15:58:48 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 07 Jun 2000 19:58:48 GMT Subject: Gordon M's Installer- Missing DLL References: <01bfd08e$d36f8da0$0100007f@Cyberus> Message-ID: <8F4CA44E5gmcmhypernetcom@199.171.54.195> g_will at cyberus.ca (Gordon Williams) wrote: >I am trying to distribute a program that I have packaged into a >standalone. > The package is installing ok but I am getting a report back that a dll > is >not loading when I run the standalone. > >C:\Scopal>scopal03b.exe >Traceback (innermost last): > File "", line 1, in ? [snip] > File "E:\Program Files\Python\wxPython\__init__.py", line 20, in ? > import wxc > File "E:\Program > Files\Python\Installer_3f\Installer\support\imputil.py", >line > 54, in _import_hook > return self.__chain_import(name, globals, locals, fromlist) >ImportError: DLL load failed: One of the library files needed to run >this applic >ation cannot be found. Python is reporting an error that Windows gave it when it tried to load wxc.pyd. The missing dll is almost certainly wx21_13.dll (maybe a different verion embedded in the name) which is in your system directory. - Gordon From thomas at cintra.no Wed Jun 14 03:11:15 2000 From: thomas at cintra.no (Thomas Weholt) Date: Wed, 14 Jun 2000 07:11:15 GMT Subject: Which linux distros have Python by default? References: Message-ID: <394a2fed.280565932@news.online.no> Mandrake 7.0 and 7.1 has it installed, and 7.1 has PIL included too. A very good distro. Thomas On Tue, 13 Jun 2000 15:49:46 GMT, ge at nowhere.none (Grant Edwards) wrote: >I've got a Tkinter-based GUI interface used to do >administrative stuff for a device driver under Linux. I know >RedHat installs Python and Tkinter by default. Is there a >handy list somewhere of which Linux distributions can be >expected to have Tkinter installed? > >I know it's available on almost all of the distributions, but >I'd like to know which ones install it in the "normal" >configuration that joe-windows-user is going to get if he does >a default workstation or server install. > >Had I the spare time and disk space I'd love to install a half >dozen distributions, but resources don't permit that at the >moment. From gansevle at cs.utwente.nl Wed Jun 28 07:07:57 2000 From: gansevle at cs.utwente.nl (Fred Gansevles) Date: Wed, 28 Jun 2000 11:07:57 GMT Subject: SystemError: bad argument to internal function References: <8jcltq$1li$1@nnrp1.deja.com> Message-ID: <8jcma6$1v2$1@nnrp1.deja.com> I forgot to mention: python.exe: sys.version: '1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)]' sys.platform: 'win32' os.name: 'nt' also installed: win32all-129.exe win32all-129-update.exe -- ----------------------------------------------------------------------- ---- 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 eviltofu at rocketmail.com Sat Jun 10 12:07:41 2000 From: eviltofu at rocketmail.com (Jerome Chan) Date: Sat, 10 Jun 2000 16:07:41 GMT Subject: namespace question Message-ID: If I do the following: import socket socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) how do I call a function from the socket module later on? From wlav at hpatl26.cern.ch Wed Jun 14 04:23:08 2000 From: wlav at hpatl26.cern.ch (Wim Lavrijsen) Date: 14 Jun 2000 08:23:08 GMT Subject: Python Productivity over C++ References: <65118AEEFF5AD3118E8300508B1248774CB334@ALTNET> Message-ID: <8i7fdc$nti$1@sunnews.cern.ch> Mike Steed writes: >> From: wlav at atlas03.cern.ch [mailto:wlav at atlas03.cern.ch] >> All that STL containers require is that your dtor and copy assignment >> don't throw. The compiler generated members fullfill that requirement. >True. And although it's not required, it *is* a good idea to make sure that >each class's copy constructor and assignment operator behave properly. For that matter, it *is* a good idea to make sure that all your code behaves properly. So? >The default copy ctor often does not do what you want, e.g., if your class >contains pointers to other objects. If generated members are 'often' not good enough, then all red lights should start flashing, as you have a design flaw. It is extremely hard to make such code exception safe. Instead, you should encapsulate the code that needs a specialized cctor and use it as member or private base. I've done a quick scan through some of my code base and I have found 2 classes that need an explicit cctor. >> Please inform yourself better before making such statements. Blindlessy >> drawing conclusions based on the C++ implementation of one particular >> vendor from Redmond isn't good for your credability. >And assuming that I'm blindlessly drawing conclusions based on Microsoft's >compiler is not good for your credibility. It is the only compiler that comes with an STL that beeps at you when you don't provide said members. If I may ask then, where did you find your enligntment? >The default copy ctor (regardless of the compiler) simply does a >member-by-member copy, which is often the wrong thing to do. Again, I strongly disagree with your 'often'. >The point is that, even if the default is >acceptable, the C++ programmer has to (or should) think about it. There is such a thing as 'second nature'. >This discussion illustrates the original point: these are details that the >Python programmer does not need to deal with. I fully agree that Python is far simpler, but STL is not so complex as you seem to want it to be. Best regards, Wim Lavrijsen From moshez at math.huji.ac.il Sat Jun 10 01:33:33 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 10 Jun 2000 08:33:33 +0300 (IDT) Subject: Gnome Applets and Python In-Reply-To: <39416F2B.96AD2322@oreilly.com> Message-ID: On Fri, 9 Jun 2000, Stephen R. Figgins wrote: > Any good suggestions on Gnome Applets and Python information? There's a clock-applet.py example in the gnome-python module on the GNOME cvs archive. Very cut-n-pastable -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From mfletch at tpresence.com Thu Jun 8 14:37:01 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Thu, 8 Jun 2000 14:37:01 -0400 Subject: setblocking in Win32 Message-ID: Non-blocking ports most definitely work on win32 (almost everything I write uses them). The EWOULDBLOCK (10035) error is thrown only when you're in non-blocking mode (otherwise the call would just wait until it could accept before returning). See asyncore.py for examples of how to work with non-blocking sockets (mostly just catch the socket.error and see if the first argument is 10035, if so, go about your other business, else re-raise the error). Congrats, you're non-blocking :) . Mike -----Original Message----- From: jkingry at my-deja.com [mailto:jkingry at my-deja.com] Sent: Thursday, June 08, 2000 1:57 PM To: python-list at python.org Subject: setblocking in Win32 Hi, I think I'm going to be told what I don't what to hear, but from the error below, I think I have surmised that trying to set non- blocking on a socket in a Win32 environment doesn't work. Are there any work arounds? Joe Traceback (innermost last): File "D:\Prog\Python\Lib\threading.py", line 376, in __bootstrap self.run() File "D:\Prog\Python\Lib\threading.py", line 364, in run apply(self.__target, self.__args, self.__kwargs) File "io.py", line 80, in run sock,(address,port) = server.accept() File "D:\Prog\Python\Lib\plat-win\socket.py", line 36, in accept sock, addr = self._sock.accept() error: (10035, 'winsock error') Sent via Deja.com http://www.deja.com/ Before you buy. -- http://www.python.org/mailman/listinfo/python-list From gregm at iname.com Mon Jun 12 09:36:45 2000 From: gregm at iname.com (Greg McFarlane) Date: Mon, 12 Jun 2000 23:36:45 +1000 Subject: Tkinter: disable a item in a Menubar In-Reply-To: <393E114E.1F59AD44@teleatlas.com>; from Klaus Bruns on 07 Jun 2000 at 11:09:34AM References: <393E114E.1F59AD44@teleatlas.com> Message-ID: <20000612233645.02575@nms.otc.telstra.com.au> It is possible to do what you are trying to do. To work out how to do it, you need to carefully study the Tkinter and Pmw reference manuals. There you will discover that: 1) The Pmw.MenuBar addmenu() method creates a menu component. In this case, the name of the menu component is 'FILE-menu'. 2) Pmw allows you to access the components of a megawidget, using the component() method. 3) To configure a Tk menu item, use the entryconfigure() method. 4) To disable a Tk menu item, set the 'state' option to 'disabled' and to enable it, set it to 'normal'. Putting this all together: def open_file(self): ## change the state of 'open' to DISABLED fileMenu = self.menuBar.component('FILE-menu') fileMenu.entryconfigure('open', state = 'disabled') def save_file(self): ## change the state of 'save' to DISABLED and 'open' to Normal fileMenu = self.menuBar.component('FILE-menu') fileMenu.entryconfigure('open', state = 'normal') fileMenu.entryconfigure('save', state = 'disabled') Greg On 7 Jun, Klaus Bruns wrote: > Hi all, > > I want to change the state of an item in a Menubar, but I don't now how > to do. > For example: in the Menu 'File' there is a funktion to open and save a > file. After using the 'open' funktion this funktion is disable till > using the 'save' funktion. > > I use Pmw for creating the Menubar: > > import Pmw > from Tkinter import * > > class mymenu: > def __init__(root): > Pmw.initialise(root) > self.balloon=Pmw.Balloon(root) > self.menuBar=Pmw.MenuBar(root,hull_relief=RAISED,hull_borderwidth=1, > balloon=self.balloon) > self.menuBar.pack(fill=X) > self.menuBar.addmenu('FILE','open and save files') > self.menuBar.addmenuitem('FILE','command','open a file',label='open', > command=self.open_file) > self.menuBar.addmenuitem('FILE','command',save a file',label='save', > command=self.save_file) > > def open_file(self): > file = open(filename) > ## here I want to change the state of 'open' to DISABLED > > def save_file(self): > ## do something to save the file > ## and change the state of 'save' to DISABLED and 'open' to Normal > > root = TK() > mymenu(root) > root.mainloop() > > Can anyone help me? > > Klaus > -- > http://www.python.org/mailman/listinfo/python-list > -- Greg McFarlane INMS Telstra Australia gregm at iname.com From nascheme at enme.ucalgary.ca Wed Jun 21 14:27:14 2000 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Wed, 21 Jun 2000 18:27:14 GMT Subject: Why whitespace denotation of blocks doesn't work. References: <394ac7ea.609024015@nntp.interaccess.com> <02b001bfd885$fbefa5e0$1906a8c0@fc.fenx.com> <20000619112509.A20245@fangorn.csse.monash.edu.au> <39505457.5223ADC5@san.rr.com> <20000621155338.C11308@fangorn.csse.monash.edu.au> Message-ID: Toby J Sargeant wrote: >:set lcs=tab:?\ >:set list Unfortunately both those settings are global instead of per buffer. I guess you could hack some macro to change them when you enter a .py buffer. Neil -- "Reliability means never having to say you're sorry." -- D. J. Bernstein From herzog at online.de Thu Jun 29 08:02:40 2000 From: herzog at online.de (Bernhard Herzog) Date: 29 Jun 2000 14:02:40 +0200 Subject: (Serious?) package namespace problem (and a proposal) References: <8F61BBD91gmcmhypernetcom@199.171.54.194> <8F61DA247gmcmhypernetcom@199.171.54.194> Message-ID: gmcm at hypernet.com (Gordon McMillan) writes: > Lets say you have a (gag) 2,000 line module: foo.py. To speed things up > (avoid the compile), you write a 2nd script: > ------ > import foo > foo.main() > ------ > > You shouldn't have to add the directory this is in to PYTHONPATH for this > to work. (This being why "." *should* be on the path.) That has nothing to do with '.' being in sys.path. The directory that has to be in the path is not usually the cwd, it's the directory where the script is. Python automatically prepends that directory to the path, and it even follows symlinks to find it. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From jerome.quelin at insalien.org Thu Jun 15 18:11:52 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Fri, 16 Jun 2000 00:11:52 +0200 Subject: How Fast Does Python Run? References: <8ib1bs$1pv@autodesk.autodesk.com> Message-ID: <961107112.124995831@news.libertysurf.fr> Hello, >> I wonder if Python runs faster than Perl. >Check out: > http://wwwipd.ira.uka.de/%7Eprechelt/documents/jccpp_tr.pdf >Which somebody posted here recently. Where the best Python was shown to >run faster than the best Perl, and the worst Python was shown to run a >/lot/ faster than the worst Perl. In this report, it is stated as one final conclusion that Python and Perl are equivalent, with maybe an advantage for Perl : [snip] Within the script langages, Python and in particular Perl are faster than Rexx and Tcl [snip] But the report also states that you can't issue conclusions on language speed, advantages and drawbacks : [snip] For all program aspects investigated, the performance variability due to different programmers (as described by the bad/good ratios) is about as large or even larger than the variability due to different languages on average. [snip] So you can't tell which is faster between Perl or Python. Let's just stop those flamewars. I just would like say that I'm fond of Perl since a long long time, and if I went to Python, it's mainly because I got frustrated with it when dealing with larger applications. I currently consider myself in a learning phase (even if I've already read some books and tutorials on Python, and experienced a little with the interpreter and made some very little scripts) since I have not applied it on medium-size examples or on a real-world problem (in fact, I'm looking for an idea of program I could work on, if you have any idea/suggestions...). This to say that my opinion on Python may be a little inaccurate, but I hope it's not too far from reality. The point I wanted to underline is that different languages have different scopes. And even if Perl and Python are really close, this doesn't mean they are interchangeable. I won't use Python for some tasks where Perl is (in my mind) the best suited. For example, I think text processing is by far best handled by Perl with all its text-oriented features (its native regular expression integration, the facilities to handle files opening, reading and parsing, etc...) and the short-cuts it provides (the Perl motto TIMTOWTDI). And despite the fact I'm Perl addicted, I consider Python a lot better for larger applications (and especially with GUI, since Perl/Tk isn't really easy to handle - believe me ;-) ), due to its syntax, its OO model and the readibility it procures. But not for any kind of applications : you are to be clever enough to turn yourself to C/C++ (or even ASM) if you need to perform low-levels operations on your system, or to speed up your code. Unless you are to develop a 1'000'000+ lines applications ? Then choose ADA or another language that will allow you to manage your code efficiently... Do not blindly choose Python just because you're Python addicted. Make your choice with clever information. And if finally it appears that Python is the best suited for the problem you want to solve, you will have the satisfaction to know why (Q: "Why are you coding in Python ?" A: "Because it's the best." Q: "And why is it the best ?" A: "Hermm...."). Sincerely, Jerome -- jerome.quelin at insalien.org From gmcm at hypernet.com Fri Jun 30 08:59:36 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 30 Jun 2000 12:59:36 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: <8F6354CB4gmcmhypernetcom@199.171.54.154> claird at starbase.neosoft.com (Cameron Laird) wrote in : >In article <8F62C20E2gmcmhypernetcom at 199.171.54.154>, >Gordon McMillan wrote: > . > . > . >>The whole inode thing in that code is because it is a common Linux >>idiom to rely on the fact that once a process has opened a file, said >>file can be deleted by another process without the reading process >>noticing. >> >>This idiom is completely impossible on Windows, so there's no sense in >>checking whether a new file with the same name has now been created. >> >>So what'll it be - a portable version that's useless on Linux, or one >>that spends half it's time checking for something that can't occur on >>Windows >>? >> >>on-Windows-once-you've-grabbed-the-tail- >> you've-got-the-whole-damn-dog-ly y'rs >> >>- Gordon (who never uses popen on Windows anyway) > >It's a good question. > >Is tail(1) in POSIX? I'm out of copies of POSIX documentation >again ... Apparently not... >It's never been a difficult question for me. I've ended up >coding different tail functions (methods) for different pro- >jects. Am I committing redundancy in my coding? Barely, >and at a level with which I'm comfortable. The general cat- >egory here is, "ambiguously defined stuff where the ideas >are so clear it's easier recoding them than trying to merge >conflicting requirements/definitions." I'll agree with that. And I'll point out that I wrote the [long ago snipped] code *instead* of using os.popen("tail -f...."), because I really didn't want yet another shell running, and because I would still have had to deal with the writing process moving on to a new inode. >I most often need such a tail for log-scraping, and part of >my tail implementations generally is *not* to do what you >describe, but to stop reading the mv-ed i-node and pick up >with a newly-created file (a log, in my case). This illu- >strates the ambiguity in tail's semantics. I repeat: I >resolve the ambiguity by my knowledge of requirements spe- >cific to a project. Hmmm. We definitely are having a problem in communicating. That was the whole reason for the inode checking - so the "tail"ing process could move on to the new file. >You and I might have a slight vocabulary clash. My code >often involves tests of os.name. I think of the results >as "a portable version", without embarrassment. Perhaps >your habit is to regard the same as *not* "pure" Python, >and correspondingly "importable". Oh no, I have no problem with that. I was just pointing out that besides the platform syntactic differences, there are also platform semantic differences (i.e., yet more ambiguity). C'mon, Cameron. You *know* if we disagree, at least one of us has misunderstood ;-). - Gordon From jvickroy at sec.noaa.gov Mon Jun 12 12:29:16 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Mon, 12 Jun 2000 10:29:16 -0600 Subject: enabling threads on HP-UX Message-ID: <39450FDB.F5998449@sec.noaa.gov> Hello, Our systems administrator has installed Python 1.5.2 (downloaded from www.python.org) on an HP-UX (v 11) OS with threads enabled. File ./configure was run with the '--with-thread' option. The following is a sample session illustrating the problem: $ python Python 1.5.2 (#1, Jun 9 2000, 14:42:40) [GCC 2.95.2 19991024 (release)] on hp-uxB Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> def count(): ... for i in range(1,10): print i ... >>> count() 1 2 3 4 5 6 7 8 9 >>> import thread >>> thread .start_new_thread (count, () ) Traceback (innermost last): File "", line 1, in ? thread.error: can't start new thread Any ideas about what we have done incorrectly? Thanks for your time. From invalid at dev.null Fri Jun 30 01:35:54 2000 From: invalid at dev.null (Alexander K) Date: Fri, 30 Jun 2000 05:35:54 GMT Subject: command-line history in win Message-ID: <395c304e.1224185@news.student.lu.se> aloha! i did a backsearch for this on deja. found a question but no answers. and the question is: isnt there a historyfunction in the python command-line interpreter for win?. you know, the bash-kinda thing. thanks in adv. / alex k From sdhyok at email.unc.edu Sat Jun 17 16:53:38 2000 From: sdhyok at email.unc.edu (Daehyok Shin) Date: Sat, 17 Jun 2000 13:53:38 -0700 Subject: Python vs. Matlab References: <724s6sa0k5.fsf@rogn.ii.uib.no> Message-ID: <8ige1a$5gp$1@slb2.atl.mindspring.net> One problem of Matlab I found is that there is no explicit control in reference copying. As soon as you change an element of a huge array in a function, Matlab copies all the elements into a new array. This has a significant effect on performance in s/w of large scale. In Numpy, you have the perfect control in copying array , as well as its source. Peter Helge Avlesen wrote in message news:724s6sa0k5.fsf at rogn.ii.uib.no... > > I have become almost addicted to Matlab after using it extensively for > some years, however, the licencing feels very strict after getting > used to free and very good quality software like Emacs, Linux, etc. > > My main use of Matlab is reading in large binary files into > arrays(output from simulations), do some processing with various > matrix routines, then extract sections of the 3D arrays for plotting. > > Spotted Python some months ago, and liked it! Can Python, Numpy and > the many plotting extensions be used as a replacement for Matlab, is > Python slower/faster etc.? > > It would be nice to hear some experiences! > > -- > Helge Avlesen From r2d2 at mao.acc.umu.se Thu Jun 15 03:13:47 2000 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: 15 Jun 2000 07:13:47 GMT Subject: Piping output to a web browser... References: <8i8moh0q8l@enews3.newsguy.com> Message-ID: >A while back I saw a thread about keeping a web coonection alive (too bad I >saw it 4 hours AFTER I came up with the same general plan). But I am still >struggling with how I can pipe the output to the screen on a streaming >basis. The code I have seems to cache it all up and pushes it to the screen >all at once once I return out of the function. Any ideas? > > print "Content-type: text/html" > print > sys.stdout.flush() Flushing stdout may not help in a CGI program, because your output is not sent directly to the user, it is sent to the web server and from there it is relayed to the user. The web server keeps its own buffers and your output might get stuck there. What you need to do is tell the web server to use unbuffered output, or that you want to send your output directly to the user. How you do this differs from web server to web server. In Apache you specify that you want a direct communication line with the user by making sure that your script name starts with "nph-" for non-parsed headers (it is a strange solution, I know). You must also change your program so that it writes a complete HTTP header starting with HTTP/1.1 200 OK (this is normally added by the server, since you bypass the server you have to write it yourself) // Niklas From kens at sightreader.com Fri Jun 16 01:23:36 2000 From: kens at sightreader.com (Ken Seehof) Date: Fri, 16 Jun 2000 01:23:36 -0400 Subject: Waffling between Python and Ruby References: <8i8bi2$1s8$1@news.wrc.xerox.com> Message-ID: <642A954DD517D411B20C00508BCF23B001296E27@mail.sauder.com> It's happened to me many times. Usually when cutting and pasting from other peoples code (the other code having tabs, where my code does not). Over the past two years this has cost me at least 80 to 90 seconds of development time. The solution is simple: make tabs illegal. The biggest time saver, of course, is that it would stop this utterly rediculous whitespace debate. In any case, indentation/block rules don't seem to be the most important issue when selecting a language for a task. Mark Jackson wrote: > "Warren Postma" writes: > > > Having something > > look correct on the screen, but not work because of misuse of tabs versus > > spaces, or incorrect indentation, is something that still continues to bug > > me. > > Indulge my curiosity - how many times has this actually happened in > your six months of using Python? > > -- > Mark Jackson - http://www.alumni.caltech.edu/~mjackson > You can never solve all difficulties at once. > - Paul Dirac -- Ken Seehof kens at sightreader.com starship.python.net/crew/seehof Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- A non-text attachment was scrubbed... Name: kens.vcf Type: text/x-vcard Size: 343 bytes Desc: Card for Ken Seehof URL: From db3l at fitlinxx.com Wed Jun 21 18:00:59 2000 From: db3l at fitlinxx.com (David Bolen) Date: 21 Jun 2000 18:00:59 -0400 Subject: Frozen socket. References: Message-ID: "C. Porter Bassett" writes: > I made two small programs, a server and a client, and I got the client to > "freeze" in the exact same way. My test server accepts three messages, > but after that, it freezes. For some reason that I don't understand, the > client keeps sending messages (about 1000 of them, just like before), even > though the server is not receiving any. After about 1000 messages, it > freezes, just like the program I am debugging. Um, right - this pretty much maps to the behavior I mentioned in the last response. If your server is not actively receiving data, then it will begin to back up within the queues within the system. There is some amount of data that may be held on the server's receiving end (within the networking kernel buffers), and data in networking queues on the sending end. There's also some data in transit in the network - while that's not normally additive to the overall queue size as perceived by the application. > Why is the client able to keep sending messages if the server is not > receiving them? Because the messages are being queued up (either on the client or server end) until you max out the internal network queues provided by the systems involved. Queue sizes may also be configured for a given socket or default values via network kernel configuration. When you use send() you are handing off your data to the network kernel, and in particular the TCP protocol. That protocol queues up the data to be transmitted as soon as possible, but there might be some earlier data that TCP is still working on, so it understands how to hold onto your data. It's these internal buffers that provide the "elasticity" you are seeing. You aren't actually transmitting data with send() - you are just passing it off to be transmitted by the underlying network layers. > In short, what is really happening, and how do I safeguard against it? Well, it's working as designed, so I'm not entirely sure what you are trying to safeguard against. TCP works as a stream protocol - you send it any amount of data and it'll consider it a stream of bytes that need to get to the other side eventually. Since TCP is in complete control of the transmission, eventually might take a long time - in this case your eventual blocked send() could wait for a long time unless the server shuts down the connection - but if the server starts reading again, everything will immediately pick up again. So in one respect, this is the simplest behavior for the application. You just keep using send() and you know you're data will get to the other end, or eventually you'll get an error from send(). You don't really care if it blocks because it'll eventually start up again when the server is ready for more data. If you need different behavior, then you have to design it into your application protocol, and TCP may or may not be the appropriate underlying network protocol to use. For example, if you want to be sure that your information is getting through, you could do a simple ACK/NAK sort of setup where the server sends a response to the client for each transmission. This would let the client know for sure the information is received before trying to send again. But without knowing the semantics you are looking for at the application level, it's hard to say what else you might want to do. But in this particular scenario you are testing here, things are pretty much working as designed, so it may be a mismatch between your expectations and the design, or just that you need to consider the ramifications of a real, variable network in the middle of your two apps :-) -- -- 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 Jun 26 07:09:04 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 26 Jun 2000 11:09:04 GMT Subject: SuSE Linux, python and setgid References: <8j72mh$7q0$1@sun27.hrz.tu-darmstadt.de> Message-ID: On Mon, 26 Jun 2000 10:04:01 +0200, Thomas Leonhardt wrote: >I have got the problem that I should install a script on our server >which was written in python. The problem is that the script checks >wether the group id was set as specified by the file permissions. >But somehow the gid is not set when I execute the script. Is there >something like suidperl for python or smoethingelse special with >SuSE linux which causes the gid not beeing set?? It isn't SuSE specific, nor Python specific: scripts (interpreted files) can't be setuid or setgid, under most UNIX systems, for reasons of security. You'll have to create a wrapper (in C or another non-interpreted language) that takes the proper gid, and then executes the python interpreter for you. Take a look at Misc/setuid-prog.c, in the Python source tree. Secure-ly y'rs, Thomas. From hungjunglu at hotmail.com Fri Jun 9 14:54:50 2000 From: hungjunglu at hotmail.com (Hung Jung Lu) Date: Fri, 09 Jun 2000 11:54:50 PDT Subject: Python Productivity over C++ Message-ID: <20000609185450.91797.qmail@hotmail.com> --- In python-list at egroups.com, "M.-A. Lemburg" wrote: >Steve Mullarkey wrote: > > 3. I use incremental compiling and linking. This reduces wait times to > > very small amounts. > > > 4. I can also use background compiling and linking. > >Python compiles on-the-fly at run-time and only if needed. >You can even program interactively and have the program >compile its own code. I really have to raise my voice here: in Python, running means also compiling. Steve: sorry to point this out to you, but you really ought to take a look at dynamical reloading of modern script languages like Python. To me, that's the biggest advantage of modern script languages. In Python, there are no separate commands for compiling and running. And you can reload a Python module on the fly. Do you understand that? For many applications (like webservers), it is absolutely crucial that the main application keeps running while you are adding/modifying part of the program. That's an area where C++ can not do well. In Python, I often have programs running, and then I need to modify part of the program. I go ahead and modify the module, and since I have designed the main program to reload the submodules, I never have to stop the main application, this even if there are compiling/runtime errors from the submodule. Doing that in C++ is an absolute nightmare. Python not only does incremental compiling and linking, it does it in REAL TIME. You can modify your program while it is running. This is absolutely critical for applications like webservers: you don't want to stop the main application because you want to change one line of code. This is a tremendous time saving over the traditional compile-run-debug, compile-run-debug, compile-run-debug,... cycles. In Python, it was more like: debug-click, debug-click, debug-click,... cycle. I just can't imagine how I was going to do the same thing in C++ within the same time frame. I would say that 10 times shorter development time is probably an understatement in that particular case. In my case, it was between a possible project and an impossible project. The biggest advatages of script languages are that they make dynamic reloading easier and they offer reflection (or introspection): the language is capable of looking into itself, and even perform meta-programming. I know you can make your C++ program to do this kinds of things, but you have to spend a tremendous amount of development time before you can reach some minimum features of dynamic reloading and reflection. (I have also used Java reflection features, but Python's reflection is way simpler and superior.) When you have dynamic reloading, designing GUI in Python is still not as comfortable as in Visual Basic, but darn close. I worked for a multimedia CD-ROM game company before, and it really sucked to use C++ or Java because of the lack of dynamic reloading. Programmers waste too much time in the compiling process. With Python, you can have the application running, find out the bug, fix it, and all while the game is still running. Too bad I already changed job. Hung Jung ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com From rod at inf.bme.hu Fri Jun 9 03:38:52 2000 From: rod at inf.bme.hu (Gabor Papp) Date: Fri, 09 Jun 2000 09:38:52 +0200 Subject: where is PyOpenGL? Message-ID: <39409F0C.8935C54F@inf.bme.hu> Where can I download PyOpenGL for win32 from? I've tried the following: http://starship.python.net/~da - the link seems to be broken http://PyOpenGL.sourceforge.net/ - it's empty thanks in advance, Gabor Papp From long_way_home at my-deja.com Wed Jun 7 19:42:19 2000 From: long_way_home at my-deja.com (long_way_home at my-deja.com) Date: Wed, 07 Jun 2000 23:42:19 GMT Subject: numpy installation woes Message-ID: <8hmmko$qd3$1@nnrp1.deja.com> Hi. I am new to pyhton and have tried to install numpy, but the darn thing doesn't recognise it's existence. I have also installed MatPy and that works fine. When I try to import it I get the message >>> from Numeric import * Traceback (innermost last): File "", line 1, in ? ImportError: No module named Numeric although the directory is there. I am using an SGI O2 and have compiled with the SGI compilers, will python complain about the .so suffix. I'm buggered if I know how to fix this and would really appreciate some help, for the NumPy manual has no more useful info. Cheers Geoff -- Geoff Low "I am the king of all I see, my kingdom for a voice" Sent via Deja.com http://www.deja.com/ Before you buy. From scherbi at bam.com Thu Jun 29 12:40:41 2000 From: scherbi at bam.com (Bill Scherer) Date: Thu, 29 Jun 2000 16:40:41 +0000 Subject: Text in Tables References: Message-ID: <395B7C09.EB1EBB9A@bam.com> Sorry I can't really answer your question, but are you using Report Lab's pdflib? If not you might want to look into it: http://www.reportlab.com Mike Welch wrote: > Hello, I'm a software developer trying to learn Python to generate > PDF files from ASP pages. One problem I'm having with tables in my > PDF files are that cells do not word wrap. This would not be a > problem if I knew how to put a line break (or new line) in my text. > In the docs it says \n works for new lines, but this does not work in > tables. Can someone please tell me how this is accomplished in > tables? > > Thanks! > > _________________________________________________ > Michael B. Welch > Software Developer > Incigna, Inc. > 424 East 4th Street > Cincinnati, Ohio 45202 > E-mail: mwelch at incigna.com > Office: (513) 333-0313 Ext. 14 > Fax: (513) 333-0413 > > "Your eSolutions Company" > > -- > http://www.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff Verizon Wireless From dimus63 at my-deja.com Thu Jun 22 19:55:15 2000 From: dimus63 at my-deja.com (dimus63 at my-deja.com) Date: Thu, 22 Jun 2000 23:55:15 GMT Subject: Using anydbm. References: <63c9jscp2qeratnaa1r3rgivh36l92g186@4ax.com> Message-ID: <8iu90t$urg$1@nnrp1.deja.com> It is fixed already. Take whichdb.py from http://www.musi-cal.com/~skip/python/Python/Lib/whichdb.py Everything should work after that In article <63c9jscp2qeratnaa1r3rgivh36l92g186 at 4ax.com>, Tim Roberts wrote: > Jordan Katz wrote: > > > >I'm having trouble getting anydbm to work correctly. For example, > > > > >>> import anydbm > > >>> db = anydbm.open('foo', 'c') > > >>> db['bar'] = 'baz' > > >>> db['bar'] > > 'baz' > > > >Works fine, but if I try to execute it again after restarting python, > >I get the error: > > > > Traceback (innermost last): > > File "", line 1, in ? > > File "/usr/lib/python1.5/anydbm.py", line 83, in open > > raise error, "db type could not be determined" > > anydbm.error: db type could not be determined > > Good question; I have exactly the same problem. I replaced "anydbm" with > "dumbdbm" and it worked fine, but I expected "anydbm" to work. If you get > an answer privately, please post it for me. > -- > - Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > Sent via Deja.com http://www.deja.com/ Before you buy. From none at none.com Mon Jun 19 14:28:10 2000 From: none at none.com (none) Date: Mon, 19 Jun 2000 20:28:10 +0200 Subject: bl Message-ID: <6E528A6CBCFED311A7C1009027B721F92B89F9@hermes.demogr.mpg.de> From PClaerhout at CREO.BE Thu Jun 22 08:28:04 2000 From: PClaerhout at CREO.BE (Pieter Claerhout) Date: Thu, 22 Jun 2000 14:28:04 +0200 Subject: CurrentUser for remote machine under NT Message-ID: <2B1262E83448D211AE4B00A0C9D61B0301301217@msgeuro1.creo.be> > Hello, > > how can you get the current logged in user for a remote nt system using Python? > > Pieter From robin at reportlab.com Tue Jun 20 11:40:43 2000 From: robin at reportlab.com (Robin Becker) Date: Tue, 20 Jun 2000 16:40:43 +0100 Subject: Roman Number Representation Message-ID: I could have sworn I had seen a discussion of Roman Numbers somewhere on clp, but can't find it. Anyone got any clues? -- Robin Becker From JoeSmith at bogusaddress.com Sat Jun 3 16:18:24 2000 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Sat, 03 Jun 2000 20:18:24 GMT Subject: Python GUI requires tcl? References: <8hbeol$obo$1@samba.rahul.net> <8hbjl0$611$1@news1.xs4all.nl> Message-ID: <393968C8.CBFAAF1@bogusaddress.com> An HTML attachment was scrubbed... URL: From bragib at my-deja.com Mon Jun 19 21:01:48 2000 From: bragib at my-deja.com (bragib at my-deja.com) Date: Tue, 20 Jun 2000 01:01:48 GMT Subject: Help with telnet... Message-ID: <8imfpo$bmj$1@nnrp1.deja.com> This is a repost as I am still clueless! Bragi I am trying to telnet from a UNIX box to an NT to get the doskeys. The NT that I login to runs a couple of .bat scripts which clear the screen set up some stuff etc. When I try to do a read_all() it fails the first time with the exception: Traceback (innermost last): File "telnet.py", line 17, in ? tn.read_all() File "/usr/abaqus60/5-0_copy/source/Python/Lib/telnetlib.py", line 229, in read_all self.fill_rawq() File "/usr/abaqus60/5-0_copy/source/Python/Lib/telnetlib.py", line 367, in fill_rawq buf = self.sock.recv(50) socket.error: (131, 'Connection reset by peer') That is why I put the first try in a try: except: clause. The second time I try to do a read_all() it works fine but I don't get all the keys I am missing some of the first keys. I assume that the first read_all() actually did read some stuff and then the second read got the rest. Can anyone see anything obviously wrong with this. Thanks, Bragi import sys import telnetlib HOST = 'shadow' USER = 'bragi' tn = telnetlib.Telnet() tn.open(HOST) tn.read_until("login: ") tn.write(USER+'\r') tn.read_until("password: ") tn.write('my_password\r') tn.write('doskey /macros\r') tn.write('exit\r') print 'done' try: all1 = tn.read_all() except: pass all = tn.read_all() print all Sent via Deja.com http://www.deja.com/ Before you buy. From kens at sightreader.com Tue Jun 13 08:03:59 2000 From: kens at sightreader.com (Ken Seehof) Date: Tue, 13 Jun 2000 05:03:59 -0700 Subject: can python do this? References: <3945D0AA.E8F51A9C@san.rr.com> <3945d426$0$492$7f31c96c@news01.syd.optusnet.com.au> <3946dc6b.193651816@news.online.no> Message-ID: <3946232F.61B28793@sightreader.com> Thomas Weholt wrote: > On Tue, 13 Jun 2000 16:39:23 +1000, "Jason" > wrote: > > >> import string > >> file = open ("file") > >> lines = file.readlines() > >> for line in lines: > >> pair = string.split(line,":") > >> print pair[0] +": "+ `string.split(string.strip(pair[1]),",")` > >> file.close() > > The line : > > file = open("file") > > change "file" to the complete path of your text-file, like if your > file resides in c:\temp\music.txt, change it to : > > file = open("c:\\temp\\music.txt") > > And YES, the double backslashes are needed, or the \t in \temp is > interpreted as TAB. Just change that and run the script from PythonWin > or IDLE. They both come with Python, or eh ... at least IDLE does. > > Thomas Or put an r before the string to neutralize the backslashes: file = open(r"c:\temp\music.txt") BTW, you can use forward slashes instead of backslashes if you want. file = open("c:/temp/music.txt") This is a portability feature. I'm pretty sure the converse, backslashes in unix, works too. -- Ken Seehof kens at sightreader.com starship.python.net/crew/seehof Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- A non-text attachment was scrubbed... Name: kens.vcf Type: text/x-vcard Size: 343 bytes Desc: Card for Ken Seehof URL: From bgrigsds at khsdfklsf.com Thu Jun 15 19:24:56 2000 From: bgrigsds at khsdfklsf.com (news-server.austin.rr.com) Date: Thu, 15 Jun 2000 23:24:56 GMT Subject: Python in home automation References: Message-ID: Sounds like an opportunity to me. A good start would be to develop some low -level classes to control the more common devices. That would simple enough... A MisterHouse type project would require substantial effort though. "Frank Steele" wrote in message news:fsteele-E5789E.13533715062000 at news.inet-systems.net... > I'm beginning to think about extending the home network to include some > simple home automation/X10 functions. I've started looking around at > products and software, and even went so far as to pick up the latest > copy of The P*&l Journal, which has a > lengthy story on MisterHouse. > > MisterHouse is a cross-platform system, all in P*&l, that allows voice > and web control of X10 components, and uses text-to-speech to > communicate alerts to the home occupants. > > Here's the problem/question -- if it's my system, I don't want it in > P*&l. I would prefer to stick to the Python world. Unfortunately, in a > quick sweep through the Vaults of Parnassus, The Daily-URL, > Python.FAQts, and the O'Reilly Python dev-center, I don't see any > modules, extensions, or projects on this. > > So, is anyone aware of Python modules or extensions to do X10 home > automation? I'm interested hearing about them on _any_ platform, but I > intend to implement on Linux and MacOS.... > > Thanks, > Frank > fsteele at mindspring.com From bjorn at roguewave.com Wed Jun 28 20:57:34 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 28 Jun 2000 18:57:34 -0600 Subject: ?Does Python have sorting via "Dictionary Order"? References: <395A92D0.65A205B1@email.sps.mot.com> Message-ID: <395A9EFE.5422BA4F@roguewave.com> Norman Shelley wrote: > > Does Python have sorting via "Dictionary Order"? This would be a very > handy addition as an option to list's sort() function. > > This is defined by D. Richard Hipp as: > "The case of alphabetic characters is ignored, except to break ties. > Thus "B" > comes before "b" but after "a". Also, integers embedded in the strings > compare > in numerical order. In other words, "x10y" comes after "x9y", not > before it as > it would when using strcmp(). Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> print [].sort.__doc__ L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1 >>> i.e. for a given list L, you can say "L.sort(f)" where f is a function taking two arguments (a,b) and returns -1, 0, 1 if ab respectively. So all you have to do is implement f to compare two items by Dictionary Order and you're done. -- bjorn From e.smith at cs.bham.ac.uk Wed Jun 28 12:23:28 2000 From: e.smith at cs.bham.ac.uk (Elliot Smith) Date: Wed, 28 Jun 2000 17:23:28 +0100 Subject: Tkinter widgets problem Message-ID: <395A2680.3E33@cs.bham.ac.uk> Hello all, I've been having slight 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. Thanks in advance, Elliot -- email: e.smith at cs.bham.ac.uk homepage: http://www.cs.bham.ac.uk/~ezs/ "A scholar is just a library's way of making another library" (Richard Dawkins) From MarkH at ActiveState.com Mon Jun 19 20:08:12 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 20 Jun 2000 00:08:12 GMT Subject: Python Programmer wanted. Sydney Australia References: <8ik45k$rd0$1@nnrp1.deja.com> Message-ID: "Brad Clements" wrote in message news:dQq35.29$pa6.2496 at news.clarkson.edu... > > considered. Come to the city of which Lonely Planet says ".you would > > have to die and go to heaven before you see a more spectacular setting > > for a city." Please send r?sum?s to jobs at memetrics.com. > That sounds like something Ian Wright would say. Its certainly not something that a Melbournite would say (even if it _is_ true :-) Mark (in Melbourne :-) From pehr at pehr.net Tue Jun 27 23:38:25 2000 From: pehr at pehr.net (pehr anderson) Date: Wed, 28 Jun 2000 03:38:25 GMT Subject: Need help: Python and Oracle on Linux x86 References: Message-ID: <39597329.CE225BD2@pehr.net> Dear Dan, We got this to work here at Eink. The DCOracle database driver for python is very good and does exacly what we need. My understanding is that every version of Oracle has libraries that behave somewhat differently so sometimes you need to fix little things like file order to make it all work. Could you post your exact compliation trace so that I and others can look it over? Also let us know which version of Oracle you are using. Thanks, pehr anderson Dan Grassi wrote: > > I am trying to use Python on a Linux system but need Oracle DB access. I > have tried compiling the DCOracle interface with no success, there are > compile errors. > > I am trying to replace the Perl that is used with python but the DB access > issue is a killer. Can anyone help? > > Thanks, > > Dan From rmartin at objectmentor.com Sun Jun 18 21:07:21 2000 From: rmartin at objectmentor.com (Robert C. Martin) Date: Sun, 18 Jun 2000 20:07:21 -0500 Subject: ?Extreme Programming in Python? References: Message-ID: Jerome Chan wrote in message news:eviltofu-A13457.22304614062000 at news.earthlink.net... > Has anyone done any extreme programming in python? Care to share your > experiences? > > http://www.egroups.com/group/extremeprogramming/ We've been doing XP in Python for the last couple of months. It's been working very well. We use a wiki to post user stories; and do iteration plans on special wiki pages. It all works like a charm. -- 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 shan_mu Tue Jun 20 21:18:51 2000 From: shan_mu (Aeneas) Date: Tue, 20 Jun 2000 21:18:51 -0400 Subject: Current date and time References: <20000620010356.A892@better.net> Message-ID: <395017fb@newsprime.tidalwave.net> How do you format the result as-- "Tuesday 20 June 2000 21:18hr" ? Thanks. "William Park" wrote in message news:20000620010356.A892 at better.net... > On Tue, Jun 20, 2000 at 04:54:35AM +0000, dsavitsk wrote: > > what is the easiest way to get the current date and or time? > > something like > > >>> print Now() > > is what i am hoping to find. > > thanks > > doug > > >>> import time > >>> time.ctime(time.time()) > 'Tue Jun 20 01:02:03 2000' > > --William > From 12klat at sightreader.com Tue Jun 6 18:32:29 2000 From: 12klat at sightreader.com (Ken Seehof) Date: Tue, 06 Jun 2000 15:32:29 -0700 Subject: Python to call commands, e.g. "find , perl scripts , nmap , and others" is this possible? References: <393692FB.8610EBCA@dallas.net> <007901bfcbf2$c3b4e680$1906a8c0@fc.fenx.com> <3936FEFB.BA248CA3@sightreader.com> <003301bfcc30$57851820$1906a8c0@fc.fenx.com> Message-ID: <393D7BFD.F50F9932@sightreader.com> I'm running PythonWin I tried python from the command line. The process hangs. >>> import os >>> os.popen('dir').readlines() (hangs . . .) IDLE gives the same results as PythonWin: >>> import os >>> os.popen('dir').readlines() Traceback (innermost last): File "", line 1, in ? os.popen('dir').readlines() OSError: (0, 'Error') Apparently you are right about Window pipes. Not surprising. Microsoft would probably get rid of the command line completely if not for its legacy value. It's hard to control the world when the prolls have access to a usable command shell. :-) -- Ken Seehof kens at sightreader.com starship.python.net/crew/seehof Hi! I'm a .signature virus! copy me into your .signature file to help me spread! Emile van Sebille wrote: > Ken, Are you trying this in IDLE? I get the same error there.If so, > try starting python from within a dos window andsee if that makes a > difference. Pipes in winxx are somewhatflakey as I understand. > Emile van Sebille > emile at fenx.com > ------------------- > ----- Original Message ----- > From: Ken Seehof > To: Emile van SebilleCc: python-list at python.orgSent: Thursday, June > 01, 2000 5:25 PMSubject: Re: Python to call commands, e.g. "find , > perl scripts , nmap , and others" is this possible? > On NT I get: > > >>> mylist = os.popen('dir').readlines() > Traceback (innermost last): > File "", line 1, in ? > OSError: (0, 'Error') > > (same thing with any command) > > popen (command[, mode[, bufsize]]) > Open a pipe to or from command. The return value is an open > file object connected to the pipe, which can be read or written > depending on whether mode is 'r' (default) or 'w'. The bufsize > argument has the same meaning as the corresponding argument > to the built-in open() function. The exit status of the command > (encoded in the format specified for wait()) is available as the > return value of the close() method of the file object, except that > > when the exit status is zero (termination without errors), None is > > returned. Availability: Unix, Windows. > > - Ken Seehof > > Emile van Sebille wrote: > >> Jim, Take a look at os.popen, as in: import osmylist = >> os.popen('locate myname').readlines()for eachfile in mylist: do >> something with eachfileHTH, >> Emile van Sebille >> emile at fenx.com >> ------------------- >> ----- Original Message ----- >> From: Jim >> To: python-list at python.orgSent: Thursday, June 01, 2000 9:44 >> AMSubject: Python to call commands, e.g. "find , perl scripts , nmap >> , and others" is this possible? >> Dear list, >> >> I'm new to Python, and I'm sorry if I'm asking about anything that >> has been >> already discussed. >> >> I would like to use Python to call commands, e.g. "find , perl >> scripts , nmap , and others" is this possible? >> >> I do not need GUI. All I need is to link the out put and work with >> it. Is perl or shell scripts my only >> answer? >> >> jim >> >> -- >> Proprietary & Confidential. The information transmitted is intended only for the person or entity to whom it is addressed and may >> contain confidential and/or privileged material. Any review, retransmission, dissemination, or other use of, or taking of any >> action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please >> contact the sender and delete the material from any computer. >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 12klat.vcf Type: text/x-vcard Size: 343 bytes Desc: Card for Ken Seehof URL: From root at rainerdeyke.com Mon Jun 19 19:36:47 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 19 Jun 2000 23:36:47 GMT Subject: {Q} OOP Animal class. References: <8iluf0$le$1@nnrp1.deja.com> Message-ID: wrote in message news:8iluf0$le$1 at nnrp1.deja.com... > I want to make sure I understand the sequence of events right: > > 1. I call the method reply() > 2. The interperter sees reply() does not exist in class Hacker > 3. It goes one class up the hierarchy to class Primate > 4. reply() doesn't exist in class Primate > 5. It goes one class up the hierarchy to class Mammal > 6. reply() doesn't exist in class Mammal either > 7. It goes one class up the hierarchy to class Animal > 8. reply() exists in class Animal, it calls it, and self.reply() gets > translated to `Primate.reply()' since Hacker is of type Primate > 9. Primate.reply() is called > 10. `Hello world!' is printed You missed a couple of steps. Here's my interpretation of what happened. Note that this is fairly specific to Python. Most OO languages work differently. 1. You try to access data.reply. 2. data.reply does not exist as an instance variable, so look for Hacker.reply. 3. Hacker.reply does not exist, so look for Primate.reply. 4. Primate.reply does not exist, so look for Mammal.reply. 5. Mammal.reply does not exist, so look for Animal.reply. 6. Animal.reply exists, and is a function, so a bound method is created. 7. You call the bound method with no argument. 8. The call to to the bound method is translated into a call to Animal.reply with the argument data. 9. Within Animal.reply, you try to access self.speak. 10. self.speak does not exist as an instance variable, so look for Hacker.speak. 11. Hacker.speak exists, and is a function, so a bound method is created. 12. You call the bound method with no argument. 13. The call to the boundmethod is translated into a call to Hacker.speak with argument self. 14. Within Hacker.speak, 'Hello World!' is printed. -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From srn at fn.com.au Sun Jun 11 19:39:07 2000 From: srn at fn.com.au (Stephen Robert Norris) Date: Sun, 11 Jun 2000 23:39:07 GMT Subject: time.clock() always returns 0? References: Message-ID: In article , "Doug Fort" wrote: > On my system (RedHat Linux 6.2 Python 1.5.2 as shipped with RedHat) > time.clock() always returns 0. time.time() returns a good value. Is > this known behavior? Am I doing something wrong? time.clock() returns the amount of CPU time consumed since startup or the last time.clock() call, not anything to do with the current time. >>> print time.clock.__doc__ clock() -> floating point number Return the CPU time or real time since the start of the process or since the first call to clock(). This has as much precision as the system records. However, on my RH6.2 machine, the first call gave me: >>> import time >>> time.clock() 0.05 This is on a PIII 533, so unless your CPU is _really_ fast, you should get some CPU usage! Stephen From thomas at cintra.no Wed Jun 28 05:01:00 2000 From: thomas at cintra.no (Thomas Weholt) Date: Wed, 28 Jun 2000 09:01:00 GMT Subject: XML-code examples - mini-review of Python XML References: <394f7bc2.365514882@news.online.no> <00062201025104.08285@quadra.teleo.net> <8jbteo$q3v$1@netnews.upenn.edu> Message-ID: <395ebd37.180924415@news.online.no> Hmmm .. I just ordered it. It should give me something to get started with and I`ll take it from there. At least I`m giving something back to a writer of Python literature, by buying his book. Perhaps his next project will be more usefull if he gets some support or feedback. I`ll get back with some comments when I`ve read thru it. On Wed, 28 Jun 2000 00:03:27 -0400, "Andrew Diller" wrote: >His book is out there! We got ours last week. > >I like the book, but I also found it dissapointing. Most of it is an intro >into the Python language itself. What's left was mostly about his Pyxie and >PYX. I'm not sure why I'd want to learn PYX, when what I want is a solid >book on manipulating XML with python. > >I didn't think I got that. I'm interested in learning about DOMs, SAX and >things that I'm reading and hearing about. PYX seems like a bizzare >off-shoot. > >As for the into to Python part of the book (about 3/4 of it) that was a good >intro if you've never used python. > >-andy diller From garry at sage.att.com Thu Jun 1 10:40:03 2000 From: garry at sage.att.com (Garry Hodgson) Date: Thu, 1 Jun 2000 14:40:03 GMT Subject: Using python (or Tcl) on the web References: <8h4eeu$bpg$1@saltmine.radix.net> Message-ID: <393675C3.88BB0DBB@sage.att.com> Cary O'Brien wrote: > Python has got mod_python and pyapache. does anyone have any insight about which of these to use? -- 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 digitig at cix.co.uk Thu Jun 15 15:28:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Thu, 15 Jun 2000 20:28 +0100 (BST) Subject: How Fast Does Python Run? References: <8ib1bs$1pv@autodesk.autodesk.com> Message-ID: In article <8ib1bs$1pv at autodesk.autodesk.com>, akira.kiyomiya at autodesk.com (Akira Kiyomiya) wrote: > I wonder if Python runs faster than Perl. > > Could someone give me some comparison and contrast with some languages > such > as Perl, Tcl, JavaScript, etc? > > I am just curious. Check out: http://wwwipd.ira.uka.de/%7Eprechelt/documents/jccpp_tr.pdf Which somebody posted here recently. Where the best Python was shown to run faster than the best Perl, and the worst Python was shown to run a /lot/ faster than the worst Perl. Only on one task, admittedly, but one that Perl should have been good at... From aahz at netcom.com Fri Jun 16 15:23:45 2000 From: aahz at netcom.com (Aahz Maruch) Date: 16 Jun 2000 19:23:45 GMT Subject: Lot's of one-time-pads available for $15 each! [was: Nth digit of PI] References: Message-ID: <8idus1$enb$1@slb3.atl.mindspring.net> In article , Steven D. Majewski wrote: > >Only problems is that encryption based on a physical artifact is >vulnerable to physical snooping: someone dressed in black breaks into >your house in the middle of the night and catalogs your CD collection >( or if you're not too smart, finds the one left sitting next to the >computer! ) Books used to be used as one time pads, and they had the >same vulnerability -- sometimes it was possible, by close inspection, >to tell where the book had been frequently left open. ( The Bible >was a popular choice, as there were reasons to make carrying one >around constantly not be considered suspicious behaviour. ) Close, but no cigar. What you're describing that's vulnerable is the use of a book as an encryption key rather than a one-time pad. If it were literally a one-time pad, there'd be no particular physical marks. Of course, I don't think the concept of a one-time pad existed as such back then. -- --- 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 only problem with Microsoft is they just have no taste." --Steve Jobs (From _Triumph of the Nerds_ PBS special) From emile at fenx.com Mon Jun 5 19:38:36 2000 From: emile at fenx.com (Emile van Sebille) Date: Mon, 5 Jun 2000 16:38:36 -0700 Subject: operator overloading References: <0bbb01bfcf2a$bc5c39c0$1906a8c0@fc.fenx.com> <393C2386.307A160D@sightreader.com> Message-ID: <0c2a01bfcf47$32b1bd40$1906a8c0@fc.fenx.com> Ken, You missed my point, while your point is taken. My point, if I understood the question, was how could one overload the less than operator. In absence of an example, I took that to mean how could one change the behavior of the less than symbol. Which needs to happen in a class definition, which then allows the class to decide what less than means. So I provided an example that showed changed behavior for less than. ;-) Of course, only the class can know how two instances should compare, and it should then return an appropriate value. That the example should have fully shown that return values can be negative, zero, or positive, indicating less than, equals, and greater than respectively, is of course my fault. What-if-a-six-turned-out-to-be-nine-ly y'rs Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Ken Seehof Newsgroups: comp.lang.python To: python-list at python.org Sent: Monday, June 05, 2000 3:02 PM Subject: Re: operator overloading Emile van Sebille wrote: Here's a quick example of using __cmp__ >>> class Test: def __init__(self,a): self.a = a def __cmp__(self,other): return self.a < other.a >>> a = Test(3) >>> b = Test(4) >>> print a>> print a>b 1 HTH, Emile van Sebille emile at fenx.com ------------------- Um. No. Not exactly. Usually 1 designates "true" and 0 designates "false" unless I'm mistaken. Also IMHO, > means "greater than" and < means "less than". BTW there is yet another comparison operator == than means "equal to". :-) The return value of __cmp__ should be -1, 0, 1 for <, ==, >, respectively. The following more closely conforms to these conventions: >>> class Test: ... def __init__(self,a): ... self.a = a ... def __cmp__(self,other): ... if self.a == other.a: ... return 0 ... elif self.a < other.a: ... return -1 ... else: ... return 1 ... >>> a = Test(1) >>> b = Test(2) >>> c = Test(2) >>> ab, a==b, a!=b (1, 0, 0, 1) >>> b==c, b Newsgroups: comp.lang.python To: Sent: Monday, June 05, 2000 1:01 PM Subject: operator overloading > Hello > > How can I overload the less than operator? > learning python did mention something about __cmp__ but did > not provide any examples. > > > Thanks in advance > > Erling > -- -------------- next part -------------- An HTML attachment was scrubbed... URL: From sabren at manifestation.com Sat Jun 17 18:09:13 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sat, 17 Jun 2000 18:09:13 -0400 (EDT) Subject: Why whitespace denotation of blocks doesn't work. In-Reply-To: <394ac7ea.609024015@nntp.interaccess.com> Message-ID: On Sat, 17 Jun 2000, Thaddeus L. Olczyk wrote: > Emacs also doesn't reindent correctly. So I have to go through the Huh? Well, not if you use the tab key, I guess.. But "C-c >" and "C-c <" seem to work just fine for me, using python-mode. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From hanche at math.ntnu.no Fri Jun 2 09:59:12 2000 From: hanche at math.ntnu.no (Harald Hanche-Olsen) Date: 02 Jun 2000 09:59:12 -0400 Subject: Bad Math Module Notation re: atan2 References: <010620001459577031%pecora@anvil.nrl.navy.mil> Message-ID: + Lou Pecora : | Maybe you've all kicked this around before, but I've just picked up | Python in the last month or so. The notation for atan2(x,y) is | | atan2(x,y)= arctangent( x/y) | | Given the usual association of x with the abscissa and y with the | ordinate in mathematics, science and engineering it is easy to mistake | atan2(x,y) as arctangent (y/x) (x and y reversed!). Or in another | view, according to the majority of mathematically trained people | atan2(x,y) as defined appears to deliver the arccotangent. | | Am I mising something? Yes. The documentation (meaning the library reference) is wrong, but the implementation is right: >>> math.atan2(0,1) 0.0 >>> math.atan2(1,0) 1.57079632679 In fact, even the function's doc string is right (Py 1.5.2): >>> print math.atan2.__doc__ atan2(y, x) Return atan(y/x). you-should-listen-to-what-they-do-but-not-what-they-say-ly y'rs, -- * Harald Hanche-Olsen - "There arises from a bad and unapt formation of words a wonderful obstruction to the mind." - Francis Bacon From millja at wwc.edu Tue Jun 13 17:06:18 2000 From: millja at wwc.edu (millja) Date: Tue, 13 Jun 2000 14:06:18 -0700 Subject: ASP, Python, VBScript and sharing like friends Message-ID: <0a9f5150.911771a5@usw-ex0109-068.remarq.com> I?ffffc3?ffffa2?ffffe2?ffff82?ffffac?ffffe2?ffff84?ffffa2m having a bit of an issue. My current situation is that I?ffffc3?ffffa2?ffffe2?ffff82?ffffac?ffffe2?ffff84?ffffa2m able to use Python with ASP and I?ffffc3?ffffa2?ffffe2?ffff82?ffffac?ffffe2?ffff84?ffffa2m able to use VBScript with ASP. However, I?ffffc3?ffffa2?ffffe2?ffff82?ffffac?ffffe2?ffff84?ffffa2m still trying to figure out how to use the two together. What is occurring is that I?ffffc3?ffffa2?ffffe2?ffff82?ffffac?ffffe2?ffff84?ffffa2m working on a website, most of which is already written with VBScript. I have a rather large function that I would like to integrate. Is there some way to call this function from within the VBScript? Or, it would work if I can get numbers, generated by the VBScript, into the Python function and the results of this function back to the VBScript. Thanks for you time. jason milliron * Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful From lk at veriomail.com Fri Jun 9 02:18:26 2000 From: lk at veriomail.com (Lawrence Kesteloot) Date: Thu, 8 Jun 2000 23:18:26 -0700 Subject: = vs. == in Py3k Message-ID: If one of the goals of Python 3000 is to make it easy for new programmers to learn, how about removing the distinction between = and ==? The only kinds of examples I can think of where this is useful is something like: a = b = 5 vs. a = b == 5 But this isn't worth the trouble it gives new programmers. The syntax could be changed to make = and == equivalent tokens and have the parser figure out which is meant from the context, just as it's done in Basic. The documentation would only ever mention =, but the language would support == for backward compatibility. (One problem I can see with this proposal is that "a = b = 5" would probably mean "set A to whether B is equal to 5 or not", and this is the less useful of the two interpretations. I guess the parser could be written to use the other. Or the whole construct could be disallowed since it's not terrifically useful anyway.) (Um, the other problem is named arguments to functions. I'm not sure how to get around that. Any suggestions? That might be enough to justify not doing this...) Lawrence From neilh at scintilla.org Wed Jun 28 20:20:07 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 29 Jun 2000 00:20:07 GMT Subject: native Python text editor with Hebrew support? References: <395A0B71.918A6673@nih.gov> Message-ID: > I realize that this is getting a bit specialized, but I am looking for a > text editor written in Python which can handle some rudimentary facets > of Hebrew; namely, writing right-to-left and the Hebrew fonts (e.g., ISO > 8859). > > Ah, yes, I need the source code so that I can make some changes, and it > must run on Windoze. > > Is anything available? I have looked through Parnassus, and realize > that Scintilla and PythonWin might be candidates. While Scintilla/SciTE/PythonWin currently support Unicode and allow the use of Hebrew characters they do not have bidi capability and so do not layout Hebrew correctly. This is 'planned' for future implementation but so far there has been little demand so it is quite a way off. Because there is also a GTK+ version of Scintilla, more Unicode functionality will be worked on when GTK+ 1.4 which includes the Pango international text module is released. Then I can see how to approach these issues in a portable way. For performance, Python oriented editors are mostly written on two levels with the basic editing widget written in C/C++ and Python used for higher level control. On Windows, the rich text edit control can be used for international text and I think this includes Hebrew. You should be able to use Richedit from within PythonWin fairly easily. Before Scintilla, it used to be used for all source editing within PythonWin. Neil From sdm7g at virginia.edu Fri Jun 16 14:46:18 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Fri, 16 Jun 2000 14:46:18 -0400 (EDT) Subject: Lot's of one-time-pads available for $15 each! [was: Nth digit of PI] In-Reply-To: <394a5109.80394991@10.1.1.28> Message-ID: On Fri, 16 Jun 2000, Tim Dixon wrote: > The strongest possible encryption is a secret key one time pad. A one > time pad is an encryption method by which each byte (or couple bytes) > is encrypted using a different key which is discarded and not used > again. > > There are two problems: one is that it's a secret key system and not > a public key system, so it's not useful for many applications. It > doesn't work for something like SSL or PGP, for instance. This is a > characteristic of secret key systems. > > The second is the enormous effort involved in producing one time pads. > You need enough bits in your pad to encrypt the entire message; > essentially for a 16K message, your key would have to be 16K long as > well. Naturally, you need to get the key to the recipient via some > secure means and communicate what portion of the pad is used by a > particular message. Nowadays, Music CDs and DVDs are an easily available source of a stream of bits. All you have to do is secretly agree upon a disk, and maybe a starting track or location in the stream. ( There's also an infinite set of algorithms to agree to run that stream thru. For example: break the stream into 3-bit chunks, take a group of 7 chunks and drop all but the first and last, concatenate them all and rechunk them into 8-bit bytes, and XOR them with the data stream. That's not too complicated for someone to memorize. ) Only problems is that encryption based on a physical artifact is vulnerable to physical snooping: someone dressed in black breaks into your house in the middle of the night and catalogs your CD collection ( or if you're not too smart, finds the one left sitting next to the computer! ) Books used to be used as one time pads, and they had the same vulnerability -- sometimes it was possible, by close inspection, to tell where the book had been frequently left open. ( The Bible was a popular choice, as there were reasons to make carrying one around constantly not be considered suspicious behaviour. ) --- Steve Majewski Chop wood, carry water. From andre at beta.telenordia.se Tue Jun 13 10:21:55 2000 From: andre at beta.telenordia.se (=?iso-8859-1?Q?Andr=E9_Dahlqvist?=) Date: Tue, 13 Jun 2000 16:21:55 +0200 Subject: importing module through variable In-Reply-To: <20000613160606.W20700@xs4all.nl>; from thomas@xs4all.net on Tue, Jun 13, 2000 at 04:06:06PM +0200 References: <8i5e9p$nm0$1@zingo.tninet.se> <20000613160606.W20700@xs4all.nl> Message-ID: <20000613162155.A12328@beta.telenordia.se> > You want the __import__ function: > > module = __import__(var) I misphrased the question. Inside my module I have a dictionary that I need to access. And the name of this dictionary is stored in a variable. If I do: import the_module How can I then access the dictionary inside this module, if the name of the dictionary is stored in a variable? Or is there some equivalence to "from the_module import the_dictionary" when you're using __import__? -- // Andr? From wjdandreta at worldnet.att.net Thu Jun 29 11:39:46 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Thu, 29 Jun 2000 15:39:46 GMT Subject: PyType_Type? References: Message-ID: <65K65.22276$pu6.502892@bgtnsc06-news.ops.worldnet.att.net> Hi Thomas, >Hm. I don't have the vaguest idea what 'overlays' are, nor how to compile >for DOS, with or without DOS extenders ;-) But I can tell you where to find >the symbols. Overlays are used in DOS because of the 640K memory limit. You create a base exe that has all the common stuff and break up the rest of the .c files into smaller pieces called overlays that get swapped in and out of memory. For example, let's say the base exe takes 256K of ram, you allocate 128K for the overlays, that leaves 256K for the heap. This will be the first time I have tried to use overlays. >This is the 'initstruct' function from the struct module. You don't seem to >compile the struct module (it isn't in the list of compiled C files you >included) so you might want to comment this out. Wether this'll result in a >working Python is something else, I don't know what uses the struct module. > There are 2 similarly named modules structmodule.c and structmember.c. The DOS name for these modules is struct~1. Since they are in different directories, there shouldn't be a conflict but since all the .obj files are in the same directory, one would over write the other. So compiling with one, the other or both all caused errors. By naming the files differently and including both, the related errors disappeared. >The signal module. Same story as above, I guess, though I assume signals >are entirely different under native DOS. Signals might live in an entirely >different file, or they might be nonexistant. I do not know wether you need >this module or not. > I had eliminated the signalmodule because it did not look like I needed it, I needed to use compiler directives in config.c to eliminate the _initsignal function. It now all compiles and links without errors and I am ready to start on the overlay part. Thanks for the help. Bill From petersc at stud.ntnu.no Fri Jun 2 21:22:10 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Sat, 03 Jun 2000 03:22:10 +0200 Subject: ANNOUNCEMENT: Python Development Team Moves to Dutch References: <200005301905.OAA07357@cj20424-a.reston1.va.home.com> <3935937F.CCF87258@stud.ntnu.no> <39361400.5E86F678@ecs.soton.ac.uk> <8h6pa1$ecq$2@newshost.accu.uu.nl> <393793B0.83E25F53@ecs.soton.ac.uk> <8h8ej8$7c0$2@newshost.accu.uu.nl> <3937D345.CC0935D5@uab.edu> Message-ID: <39385DC2.BC0B4853@stud.ntnu.no> Shae Erisson wrote: > > Martijn Faassen wrote: > > > ja, maar is het niet vanzelfsprekend dat alleen mensen die Nederlands > spreken zich voor Python interesseren? Maar alle mensen die Nederlands spreken horen Python liefhebben! > or-at-least-lives-with-someone-who-speaks-dutch-ly y'rs actually-being-a-german-living-near-the-dutch-border-and-so- understanding-some-dutch-but-right-now-studying-in-norway- and-having-a-belgium-dutch-speaking-friend-who-did-not- help-me-with-this-one-so-excuse-any-errors-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 michael at stroeder.com Wed Jun 14 14:41:36 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 14 Jun 2000 20:41:36 +0200 Subject: Which linux distros have Python by default? References: <8i86sf$e7c$0@216.39.141.36> <1VO15.607$i06.193222@ptah.visi.com> Message-ID: <3947D1E0.8AFB0975@stroeder.com> Grant Edwards wrote: > > I doubt that anybody > is going to install Python just to run this program. That's the whole point. Download hits went up on my site when I mentioned on the web site that the required software is present in Linux distributions as pre-packaged RPMs etc. Ciao, Michael. From hjwidmai at foxboro.com Thu Jun 15 06:24:52 2000 From: hjwidmai at foxboro.com (Hans-Joachim Widmaier) Date: Thu, 15 Jun 2000 12:24:52 +0200 Subject: Entry widget with history/completion, again Message-ID: <20000615122452.A4014@foxboro.com> After digging in Tk docs for some time I've finally found how to get the current index of the insertion character in an Entry widget: self.index("insert") will do the trick. Fair enough, "insert" isn't listed in the INDICES section, just in a note (in the Text widget man page). Or is "insert" a predifined mark? Anyway, now that the biggest obstacle is out of the way, I can actually begin implementing it. -- Hans-Joachim Widmaier From dana at mmi.oz.net Wed Jun 14 16:00:11 2000 From: dana at mmi.oz.net (Dana Booth) Date: 14 Jun 2000 20:00:11 GMT Subject: Does Python help with the no-Unix handicap? References: <8i39ll$93f$1@slb3.atl.mindspring.net> <3947A59F.5016D9F0@sage.att.com> <85em60nozb.fsf@one.net.au> Message-ID: <8i8o8b$83i$0@216.39.141.36> Neurocrat wrote: >> i find i'm more enamored of elegance these days. N: Me too. N: Now if only I could find it in an OS ... TRS-DOS or NEW-DOS? :) -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From tim at paradise.net.nz Sat Jun 24 21:12:53 2000 From: tim at paradise.net.nz (Tim Evans) Date: Sun, 25 Jun 2000 01:12:53 GMT Subject: tkinter, grid and resize References: <39550101.AD8C7956@uniserve.com> Message-ID: <878zvuwokq.fsf@cassandra.evansnet> Bob van der Poel writes: > I'm having a problem getting widgets managed by grid to resize > themselves when the screen size changes. This is easy to do using the > pack manager and 'expand', however 'expand' doesn't exist in grid and > the docs seem to indicate that the 'news' sticky option should do the > same. The following snippet creates a text widget with scrollbars. If > you resize the main window, the widgets do not resize.... > You need to use the grid_rowconfigure and grid_columnconfigure methods of the containing frame, specifically the 'weight=' option. > from Tkinter import * > > root=Tk() > > ys = Scrollbar(root) > xs = Scrollbar(root) > > dsp = Text(root, yscrollcommand=ys.set, xscrollcommand=xs.set) > xs.config(orient='hor', command=dsp.xview) > ys.config(orient='vert', command=dsp.yview) > xs.grid(row=1, column=1, sticky=E+W) > ys.grid(row=0, column=0, sticky=N+S) > dsp.grid(row=0, column=1, sticky=N+S+E+W) root.grid_rowconfigure(0, weight=1) root.grid_columnconfigure(1, weight=1) > > root.mainloop() > > What am I don't wrong? I've tried to insert columnspan stuff and played > with the weight options--but I don't seem to be getting it. > > Thanks. See the Tcl/Tk documentation under 'grid' for more information, including other useful options for the rowconfigure and columnconfigure methods. -- Tim Evans From claird at starbase.neosoft.com Wed Jun 28 17:32:43 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Jun 2000 16:32:43 -0500 Subject: Following a file, or cloning tail References: <8jdj3t$or4$1@news1.xs4all.nl> Message-ID: <56086CBD66F65B5B.564A00DC35DF4777.AC9C6557FC26BA58@lp.airnews.net> In article <8jdj3t$or4$1 at news1.xs4all.nl>, Boudewijn Rempt wrote: >I'm trying to write an application that follows the output of another >app, analyzes it, and serves it up as html. Kind of filtering tail, >really. Is there any accepted 'best' way of 'tailing' a file? > >I thought about having two threads, one doing the tailing, one >doing the servering (instantiating new threads as needed), but I >can't even get the tailing right! . . . This is the platform-neutral way to do it: open the file for reading. Read to the end. Idle (whether by an event- or thread-oriented mechanism). Poll for new content, as explained below. Read to end (possibly with some seek()ing and find()ing, depending on details of your algorithm). Idle. Repeat. Some observers gag at the thought of polling. That's part of the robustness of our contemporary file-systems, though: the reliable way to find out what's in them is to ask. How do you check for new content? Among the possibilities are 1. Read to end. You're polling anyway (presumably at a frequency of a few hertz), so there's no particular harm in this. 2. Check the size of the file for a change. Do you want code, also? I assume that, if I'm only available for one of them today, you'd prefer the *idea*. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From jblazi at netsurf.de Fri Jun 16 15:42:10 2000 From: jblazi at netsurf.de (Janos Blazi) Date: Fri, 16 Jun 2000 21:42:10 +0200 Subject: initializing a class References: <3948a566_5@goliath.newsfeeds.com> <8iajn1$aib$1@slb6.atl.mindspring.net> Message-ID: <394a8298_1@goliath.newsfeeds.com> > Well, I'm not going to address the issue of "return z(y.x)", because > that gets into metaclass issues I'm not comfortable with. However, I'm > pretty sure you meant to type > > self.t = a.t1 + a.t2 > Yes, of course you are right. J.B. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From andres at mail.mamey.com Mon Jun 26 21:59:51 2000 From: andres at mail.mamey.com (Andres Corrada-Emmanuel) Date: Mon, 26 Jun 2000 21:59:51 -0400 Subject: Controlling Acrobat Reader with COM Message-ID: <200006262159.AA3991339306@mail.mamey.com> Hi, I'm trying to develop an application that will print (as in a paper copy) a PDF file automatically on Win32. I've used Mark Hammond's genpy utility to create a wrapper around "Acrobat Control for ActiveX". I'm able to get a handle on Acrobat but cannot execute any of its registered methods: >>> from win32com.client import Dispatch >>> acro = Dispatch('PDF.PdfCtrl.1') >>> acro.LoadFile(fileName='C:\Temp\ReadMe.pdf') Traceback (innermost last): File "", line 1, in ? File "C:\Program Files\Python\win32com\gen_py\CA8A9783-280D-11CF-A24D-444553540000x0x1x3.py", line 30, in LoadFile return self._oleobj_.InvokeTypes(0x2, LCID, 1, (11, 0), ((8, 0),),fileName) com_error: (-2147418113, 'Unexpected failure', None, None) I'm very much a COM newbie, so this traceback means very little to me. Could someone enlighten me on what is going wrong in this case? I have no problem controlling Word with my setup so I'm stumped on this one. Andres Corrada From redaelli at inc.it Sun Jun 4 11:20:45 2000 From: redaelli at inc.it (Paolo Redaelli) Date: Sun, 04 Jun 2000 17:20:45 +0200 Subject: GTK broke things! Re: float does not parse '0.000000E+00' References: <39396D65.D2196E66@inc.it> <04ce01bfcdbd$1fa80000$6401a8c0@home> <39397FD4.67C7FD73@inc.it> <867lc64a47.fsf@g.local> <393A2B6D.4B33A5C8@inc.it> <393A3902.F67CD1F8@stud.ntnu.no> Message-ID: <393A73CD.4EAAB457@inc.it> I was WRONG! GTK broke things in a way I can't even wonder HOW.... I attack here two version. One functions and the other not. Little problem. The ONLY difference detween them is a "import gtk" at the beginning. Delete this line and it functions!!!! I wonder WHY? It should create a "namespace" gtk.something ================= [paolo at aldebaran Telaio]$ python pyplot.working.py Processing ['LCASE.001'] Case 1 Trying to parse '1' '0.000000E+00' '0.000000E+00' Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43, 48, 48] Parsed to '1' '0.0' '0.0' Trying to parse '2' '0.000000E+00' '0.300000E+03' Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43, 48, 48] Parsed to '2' '0.0' '300.0' Trying to parse '3' '0.500000E+03' '0.300000E+03' Look for strange characthers [48, 46, 53, 48, 48, 48, 48, 48, 69, 43, 48, 51] Parsed to '3' '500.0' '300.0' Trying to parse '4' '0.500000E+03' '0.000000E+00' Look for strange characthers [48, 46, 53, 48, 48, 48, 48, 48, 69, 43, 48, 51] Parsed to '4' '500.0' '0.0' Traceback (innermost last): File "pyplot.working.py", line 85, in ? c = CanvasExample() NameError: CanvasExample [paolo at aldebaran Telaio]$ python pyplot.working.py Processing ['LCASE.001'] Case 1 Trying to parse '1' '0.000000E+00' '0.000000E+00' Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43, 48, 48] Parsed to '1' '0.0' '0.0' Trying to parse '2' '0.000000E+00' '0.300000E+03' Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43, 48, 48] Parsed to '2' '0.0' '300.0' Trying to parse '3' '0.500000E+03' '0.300000E+03' Look for strange characthers [48, 46, 53, 48, 48, 48, 48, 48, 69, 43, 48, 51] Parsed to '3' '500.0' '300.0' Trying to parse '4' '0.500000E+03' '0.000000E+00' Look for strange characthers [48, 46, 53, 48, 48, 48, 48, 48, 69, 43, 48, 51] Parsed to '4' '500.0' '0.0' [paolo at aldebaran Telaio]$ python pyplot.py Processing ['LCASE.001'] Case 1 Trying to parse '1' '0.000000E+00' '0.000000E+00' Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43, 48, 48] Traceback (innermost last): File "pyplot.py", line 86, in ? t = Telaio() File "pyplot.py", line 78, in __init__ x = string.atof(x) ValueError: invalid literal for atof(): 0.000000E+00 [paolo at aldebaran Telaio]$ diff pyplot.working.py pyplot.py 10a11 > import gtk 80a82 > ## End reading rods [paolo at aldebaran Telaio]$ ============================= -- ______________________________ / Paolo Redaelli \ | redaelli at inc.it | | http://gnupaghe.netpedia.net | \------------------------------/ -------------- next part -------------- 1 4 3 1 0.000000E+00 0.000000E+00 2 0.000000E+00 0.300000E+03 3 0.500000E+03 0.300000E+03 4 0.500000E+03 0.000000E+00 1 1 2 2 2 3 3 3 4 1 0.300000E+03 0.000000E+00 0.100000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.250000E+04 -.146922E+03 0.652654E+04 0.150000E+02 0.478073E-01 -.395235E-04 0.250000E+04 -.146922E+03 0.668798E+04 0.300000E+02 0.956146E-01 -.174419E-03 0.250000E+04 -.146922E+03 0.720229E+04 0.450000E+02 0.143422E+00 -.429172E-03 0.250000E+04 -.146922E+03 0.806948E+04 0.600000E+02 0.191229E+00 -.828271E-03 0.250000E+04 -.146922E+03 0.928954E+04 0.750000E+02 0.239036E+00 -.139620E-02 0.250000E+04 -.146922E+03 0.108625E+05 0.900000E+02 0.286844E+00 -.215745E-02 0.250000E+04 -.146922E+03 0.127883E+05 0.105000E+03 0.334651E+00 -.313651E-02 0.250000E+04 -.146922E+03 0.150670E+05 0.120000E+03 0.382458E+00 -.435786E-02 0.250000E+04 -.146922E+03 0.176985E+05 0.135000E+03 0.430266E+00 -.584599E-02 0.250000E+04 -.146922E+03 0.206830E+05 0.150000E+03 0.478073E+00 -.762539E-02 0.250000E+04 -.146922E+03 0.240203E+05 0.165000E+03 0.525880E+00 -.972055E-02 0.250000E+04 -.146922E+03 0.277105E+05 0.180000E+03 0.573687E+00 -.121559E-01 0.250000E+04 -.146922E+03 0.317535E+05 0.195000E+03 0.621495E+00 -.149561E-01 0.250000E+04 -.146922E+03 0.361495E+05 0.210000E+03 0.669302E+00 -.181454E-01 0.250000E+04 -.146922E+03 0.408983E+05 0.225000E+03 0.717109E+00 -.217484E-01 0.250000E+04 -.146922E+03 0.460000E+05 0.240000E+03 0.764916E+00 -.257897E-01 0.250000E+04 -.146922E+03 0.514546E+05 0.255000E+03 0.812724E+00 -.302936E-01 0.250000E+04 -.146922E+03 0.572620E+05 0.270000E+03 0.860531E+00 -.352846E-01 0.250000E+04 -.146922E+03 0.634223E+05 0.285000E+03 0.908338E+00 -.407874E-01 0.250000E+04 -.146922E+03 0.699355E+05 0.300000E+03 0.956146E+00 -.468262E-01 0.250000E+04 -.146922E+03 0.768016E+05 2 0.500000E+03 0.100000E+01 0.000000E+00 0.000000E+00 -.956146E+00 0.105359E+06 0.000000E+00 -.810241E-12 0.118531E+15 0.250000E+02 -.956146E+00 0.354593E+09 0.000000E+00 -.250000E+03 0.118531E+15 0.500000E+02 -.956146E+00 0.553234E+09 0.000000E+00 -.500000E+03 0.118531E+15 0.750000E+02 -.956146E+00 0.615784E+09 0.000000E+00 -.750000E+03 0.118531E+15 0.100000E+03 -.956146E+00 0.561998E+09 0.000000E+00 -.100000E+04 0.118531E+15 0.125000E+03 -.956146E+00 0.411631E+09 0.000000E+00 -.125000E+04 0.118531E+15 0.150000E+03 -.956146E+00 0.184438E+09 0.000000E+00 -.150000E+04 0.118531E+15 0.175000E+03 -.956146E+00 -.998256E+08 0.000000E+00 -.175000E+04 0.118531E+15 0.200000E+03 -.956146E+00 -.421405E+09 0.000000E+00 -.200000E+04 0.118531E+15 0.225000E+03 -.956146E+00 -.760544E+09 0.000000E+00 -.225000E+04 0.118531E+15 0.250000E+03 -.956146E+00 -.109749E+10 0.000000E+00 -.250000E+04 0.118531E+15 0.275000E+03 -.956146E+00 -.141248E+10 0.000000E+00 -.275000E+04 0.118531E+15 0.300000E+03 -.956146E+00 -.168578E+10 0.000000E+00 -.300000E+04 0.118531E+15 0.325000E+03 -.956146E+00 -.189761E+10 0.000000E+00 -.325000E+04 0.118531E+15 0.350000E+03 -.956146E+00 -.202822E+10 0.000000E+00 -.350000E+04 0.118531E+15 0.375000E+03 -.956146E+00 -.205787E+10 0.000000E+00 -.375000E+04 0.118531E+15 0.400000E+03 -.956146E+00 -.196678E+10 0.000000E+00 -.400000E+04 0.118531E+15 0.425000E+03 -.956146E+00 -.173522E+10 0.000000E+00 -.425000E+04 0.118531E+15 0.450000E+03 -.956146E+00 -.134343E+10 0.000000E+00 -.450000E+04 0.118531E+15 0.475000E+03 -.956146E+00 -.771639E+09 0.000000E+00 -.475000E+04 0.118531E+15 0.500000E+03 -.956146E+00 -.105359E+06 0.000000E+00 -.500000E+04 0.118531E+15 3 0.300000E+03 0.000000E+00 -.100000E+01 0.000000E+00 0.000000E+00 -.129038E+07 0.000000E+00 0.000000E+00 0.000000E+00 0.150000E+02 0.000000E+00 -.156394E+10 0.000000E+00 0.000000E+00 0.161438E+03 0.300000E+02 0.000000E+00 -.243946E+10 0.000000E+00 0.000000E+00 0.675750E+03 0.450000E+02 0.000000E+00 -.271495E+10 0.000000E+00 0.000000E+00 0.154294E+04 0.600000E+02 0.000000E+00 -.247753E+10 0.000000E+00 0.000000E+00 0.276300E+04 0.750000E+02 0.000000E+00 -.181429E+10 0.000000E+00 0.000000E+00 0.433594E+04 0.900000E+02 0.000000E+00 -.812342E+09 0.000000E+00 0.000000E+00 0.626175E+04 0.105000E+03 0.000000E+00 0.441215E+09 0.000000E+00 0.000000E+00 0.854044E+04 0.120000E+03 0.000000E+00 0.185928E+10 0.000000E+00 0.000000E+00 0.111720E+05 0.135000E+03 0.000000E+00 0.335473E+10 0.000000E+00 0.000000E+00 0.141564E+05 0.150000E+03 0.000000E+00 0.484049E+10 0.000000E+00 0.000000E+00 0.174938E+05 0.165000E+03 0.000000E+00 0.622943E+10 0.000000E+00 0.000000E+00 0.211839E+05 0.180000E+03 0.000000E+00 0.743446E+10 0.000000E+00 0.000000E+00 0.252270E+05 0.195000E+03 0.000000E+00 0.836847E+10 0.000000E+00 0.000000E+00 0.296229E+05 0.210000E+03 0.000000E+00 0.894436E+10 0.000000E+00 0.000000E+00 0.343718E+05 0.225000E+03 0.000000E+00 0.907502E+10 0.000000E+00 0.000000E+00 0.394735E+05 0.240000E+03 0.000000E+00 0.867335E+10 0.000000E+00 0.000000E+00 0.449280E+05 0.255000E+03 0.000000E+00 0.765225E+10 0.000000E+00 0.000000E+00 0.507355E+05 0.270000E+03 0.000000E+00 0.592461E+10 0.000000E+00 0.000000E+00 0.568958E+05 0.285000E+03 0.000000E+00 0.340332E+10 0.000000E+00 0.000000E+00 0.634090E+05 0.300000E+03 0.000000E+00 0.129038E+07 0.000000E+00 0.000000E+00 0.702750E+05 -------------- next part -------------- #!/usr/bin/env python ## pyplot ## program to plot'n'show the results of "telaio", a fortran program ## # Author: Jesper Skov # A rewite of the C canvas example in the GNOME Developer's Information ## Importing GUI specific stuffs import GDK import gtk import glob # to look for all LCASE.* files import string ## to process informations from UserList import UserList ## to create lists that starts counting from 1 class Node: def __init__(self,number,x,y): self.number = number self.x = x self.y = y class Rod: def __init__(self, number, node1, node2): self.number = number self.node1 = node1 self.node2 = node2 self.sections = range(0,21) ## list of sections. Each section will be a list containg [position, u displacement, v displacement, n, t, m]. From index 0 to index 20 ## Lista is a list with preallocated length that starts counting from 1. This is useful to avoid unnecessary mess within file processing expecially regarding the rods and nodes lists class Lista(UserList): def __init__(self): UserList.__init__(self) self.data = [] def __setattr__(self, attr, value): if attr == "size" and value>0: self.data = [None]*value else: self.__dict__[attr] = value def __getitem__(self,index): if index > 0: return self.data[index-1] else: raise IndexError def __setitem__(self,index,value): self.data[index-1] = value class LoadCase: def __init__(self): self.nodes = Lista() ## the list of nodes self.rods = Lista() ## the list of rods class Telaio: def __init__(self): ## Loading all the load cases ## Looking for all LCASE.xxx files self.filelist = glob.glob("LCASE*") self.load_cases = [None] * len(self.filelist) for filename in self.filelist: print "Processing %s" % [filename] file = open(filename) case_n = int( string.split(filename,".")[1] ) print "Case",case_n ## Reading the trailing 1 file.readline() ## read nodes and rods numbers number_list = string.split( file.readline() ) numbers = map(int, number_list) nodes_n = numbers[0] rods_n = numbers[1] for node_i in range(0,nodes_n): [node, x, y] = string.split( file.readline() ) node = int(node); print "Trying to parse '%s' '%s' '%s'" % (node,x,y) #print "Looking for strange characters:",map(ord,x) print "Look for strange characthers",map(ord,x) x = string.atof(x) y = float(y) print "Parsed to '%s' '%s' '%s'" % (node,x,y) ## Note: node_i is NOT used! ## End reading rods ## End reading files. if __name__ == '__main__': t = Telaio() -------------- next part -------------- #!/usr/bin/env python ## pyplot ## program to plot'n'show the results of "telaio", a fortran program ## # Author: Jesper Skov # A rewite of the C canvas example in the GNOME Developer's Information ## Importing GUI specific stuffs import GDK import glob # to look for all LCASE.* files import string ## to process informations from UserList import UserList ## to create lists that starts counting from 1 class Node: def __init__(self,number,x,y): self.number = number self.x = x self.y = y class Rod: def __init__(self, number, node1, node2): self.number = number self.node1 = node1 self.node2 = node2 self.sections = range(0,21) ## list of sections. Each section will be a list containg [position, u displacement, v displacement, n, t, m]. From index 0 to index 20 ## Lista is a list with preallocated length that starts counting from 1. This is useful to avoid unnecessary mess within file processing expecially regarding the rods and nodes lists class Lista(UserList): def __init__(self): UserList.__init__(self) self.data = [] def __setattr__(self, attr, value): if attr == "size" and value>0: self.data = [None]*value else: self.__dict__[attr] = value def __getitem__(self,index): if index > 0: return self.data[index-1] else: raise IndexError def __setitem__(self,index,value): self.data[index-1] = value class LoadCase: def __init__(self): self.nodes = Lista() ## the list of nodes self.rods = Lista() ## the list of rods class Telaio: def __init__(self): ## Loading all the load cases ## Looking for all LCASE.xxx files self.filelist = glob.glob("LCASE*") self.load_cases = [None] * len(self.filelist) for filename in self.filelist: print "Processing %s" % [filename] file = open(filename) case_n = int( string.split(filename,".")[1] ) print "Case",case_n ## Reading the trailing 1 file.readline() ## read nodes and rods numbers number_list = string.split( file.readline() ) numbers = map(int, number_list) nodes_n = numbers[0] rods_n = numbers[1] for node_i in range(0,nodes_n): [node, x, y] = string.split( file.readline() ) node = int(node); print "Trying to parse '%s' '%s' '%s'" % (node,x,y) #print "Looking for strange characters:",map(ord,x) print "Look for strange characthers",map(ord,x) x = string.atof(x) y = float(y) print "Parsed to '%s' '%s' '%s'" % (node,x,y) ## Note: node_i is NOT used! ## End reading files. if __name__ == '__main__': t = Telaio() From bjorn at roguewave.com Thu Jun 8 17:42:37 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 08 Jun 2000 15:42:37 -0600 Subject: Obscure Exception message References: <75F7304BB41CD411B06600A0C98414FC0A418B@ORSMSX54> Message-ID: <3940134D.22284249@roguewave.com> "Daley, MarkX" wrote: > > Hi, all! > > I'm still trying to catch up on my Python reading (>50 messages!), but I > have a problem with a while loop I'm using. Hope someone can help. > > alphadict = {} > for i in range(len(result)): > c = 1 > serialnum = result[i][6] > try: > while serialnum in alphadict[c]: > c = c + 1 > alphadict[c] = alphadict[c] + [serialnum] > except KeyError: > alphadict[c] = serialnum > print len(alphadict) > > The print len(alphadict) is there to let me know if it has done the job or > not. Basically, I anticipate the length being >1. Here is the exception > message. > > Traceback (innermost last): > File "C:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py", > line 237, in RunScript > exec codeObject in __main__.__dict__ > File "C:\Program Files\Python\cit.py", line 63, in ? > while `serialnum` in alphadict[c]: > TypeError: string member test needs char left operand > > I have no idea what this is telling me, although the 'char' comment makes me > wish I had a flamethrower! It seems to be telling you that serialnum (or is it really `serialnum` as in the errormessage) is not a single character. I.e. you can't do something like "if 'bar' in 'foo bar baz'" (you'll need string.index for that). hth, -- bjorn From M.Vitecek at sh.cvut.cz Thu Jun 15 13:50:14 2000 From: M.Vitecek at sh.cvut.cz (Michal Vitecek) Date: Thu, 15 Jun 2000 19:50:14 +0200 Subject: Python Productivity over C++ In-Reply-To: <39491494.671DC3D9@sightreader.com>; from kens@sightreader.com on Thu, Jun 15, 2000 at 10:38:28AM -0700 References: <3948745B.941@esatclear.ie> <394875B7.CAAA3C1F@san.rr.com> <3948B766.4C256CAE@colconsulting.com> <39491494.671DC3D9@sightreader.com> Message-ID: <20000615195014.A12612@fuf.sh.cvut.cz> Ken Seehof wrote: >Encapsulation, access control and type strictness are often erroneously >referred to as if they were features. They aren't. They are aspects of a >design philosophy. To make a system less error prone, constrain the programmer >in order to prevent the programmer from writing bugs. Of course, that's >impossible, since it is always possible to write bugs anyway. Because C/C++ >are extremely error-prone languages, they need stuff like encapsulation, >access, control and type strictness. Because python is less error prone, it >doesn't need these "features". Python is based on different philosophy: To >make a system less error prone, make it simple. > >You have to ask, "what is the actual value of these features?" The answer is >that they prevent certain kinds of bugs from appearing. Now ask, "what bugs >would a C++ programmer encounter if encapsulation, access, control and type >strictness were removed from C++." Undoubtedly it would be a mess. Get a >picture in your mind of these bugs. Now ask a python programmer how often >these kinds of bugs come up. Answer: "can't remember that ever happenning!" > >Look at the big picture. Do encapsulation, access control and type strictness >really make C++ really less error prone than python? > >I think not. but what are the method names with '_' at the beginning in modules for? aren't they there as a kind of hack to implement some way of access control? -- fuf ------------------------------ na IRC ------------------------------------- BillGates [bgates at www.microsoft.com] has joined #LINUX ... mode/#linux [+b BillGates!*@*] by DoDad BillGates was kicked off #linux by DoDad (banned: We see enough of Bill Gates already.) From jin.choung at gte.net Thu Jun 15 01:30:04 2000 From: jin.choung at gte.net (jin choung) Date: Thu, 15 Jun 2000 05:30:04 GMT Subject: python is hard to learn without c References: <7QG15.2637$sI4.335806@dfiatx1-snr1.gtei.net> <8i9cdf$t1c$1@ionews.ionet.net> Message-ID: thanks for the links. will follow up on them. happy hunting to you as well! jin From ge at nowhere.none Mon Jun 26 11:08:50 2000 From: ge at nowhere.none (Grant Edwards) Date: Mon, 26 Jun 2000 15:08:50 GMT Subject: smtplib References: <001501bfdf74$6dff1fe0$14b745c6@timaratz> Message-ID: <6mK55.1713$iN5.345307@ptah.visi.com> In article <001501bfdf74$6dff1fe0$14b745c6 at timaratz>, Peter Timaratz wrote: >Yes, I figured out that smtplib requires the subject and >headers to be imbedded in the message. I'm new to Python and I >love the language. But I think that the design of this module >reflects poorly upon Python. The module impliments SMTP, hence the name. SMTP does not concern itself with message contents. Writing smtplib to make certain assumptions or force certain conventions regarding message content would be just plain incorrect. >Almost every CGI programmer who looks at Python will want to >use this module. It would only take a few lines of code to make >it much more usable. Maybe you should write a higher level e-mail module that does what you are requesting. It does not belong in smtplib. >I'm saying this not to flame Python, but to encourage those >responsible for it's distribution to look more critically at >what they are putting out. Perhaps you should look more critically at what you expect from a library that claims only to impliment SMTP. If you want a layer of functionality on _top_ of SMTP, then that's something another module can impliment. >I hope that this module is atypical of the quality of this >product. I'd like to see Python become more popular. There are >many factors involved in that, but the quality of the modules >is certainly one of them. There is nothing wrong with smtplib. You seem to be expecting it to do things other than SMTP. -- Grant Edwards grante Yow! I'm an East Side at TYPE... visi.com From jbower at lims.com Wed Jun 14 07:41:31 2000 From: jbower at lims.com (Jim Bower) Date: Wed, 14 Jun 2000 11:41:31 GMT Subject: Python and Windows Scripting Host References: <9Ov15.1411$vM.56343@typhoon1.ba-dsg.net> <39y15.839$Zh1.63369@news.easynews.com> Message-ID: Thanks, Roger. There is a test script (D:\Python\win32comext\axscript\test\test.pys) which came from the Win32All distribution. It also fails, and also contains wscript directly as a Python variable. Did I miss something in the documentation? Thanks, "Jim Bower" "Roger Upole" wrote in message news:39y15.839$Zh1.63369 at news.easynews.com... > The Wscript object is not referenced directly as a Python variable. > You create it via win32com.client.Dispatch: > import win32com.client > wsh=win32com.client.Dispatch('Wscript.Shell') > wnt =win32com.client.Dispatch('Wscript.Network') > ... > Then you can use the their functions as > wsh.somefunction() > wnt.somefunction() > ... > From Pythonwin, if you first run the makepy utility from the tools menu > and select Windows Scripting Host, autocomplete will magically show > you what functions are available. > HTH > Roger Upole > > "Jim Bower" wrote in message > news:9Ov15.1411$vM.56343 at typhoon1.ba-dsg.net... > > Just getting started with Python. Downloaded the basic distribution and > the > > Win32All distribution. Python appears to register OK (ran pyscript.py > > separately just to verify). > > > > However, I am getting "NameError: wscript" anywhere the wscript object is > > mentioned. Have I missed something in the install? > > > > Jim Bower jbower at lims.com > > > > > > > > From djc at itga.com.au Tue Jun 6 20:17:42 2000 From: djc at itga.com.au (Dave Cole) Date: 07 Jun 2000 10:17:42 +1000 Subject: drawing graphs in python References: <393d0c07$0$17334@news.denver1.Level3.net> Message-ID: <87em6as5sp.fsf@heresy.itga.com.au> >>>>> "Drew" == Drew Fisher writes: Drew> Hello. I am still learning Python, but I came across a need for Drew> generating dynamic graphs (network load average, uptime, boring Drew> stuff like this :). Drew> Is the a module in Python that allows this? If so, could Drew> someone point me to it? I started to write a module that would be used for the basis of a nice graphing module. It uses libart, freetype, and libpng. You can see where I even started documenting it here: http://www.object-craft.com.au/paint_doc.html It is not complete, but it does work. The source code is here: http://www.object-craft.com.au/paint.tar.gz Object Craft is a very small consulting business that my friend and I have just started. I start fulltime next week. We are looking for work (hint). - Dave From ehagemann at home.com Sun Jun 4 11:56:17 2000 From: ehagemann at home.com (Eric Hagemann) Date: Sun, 04 Jun 2000 15:56:17 GMT Subject: win32com and Excel References: <3939D364.2EF22B13@zebrasoft.co.nz> Message-ID: Matthew, Read Hammonds "Programming Python in Win32". There is a very good headstart there with an example of a class that eases the interaction w/Excel via COM. Next get "Writing Excel Macros" by O'Reilly. It is all about how to program Excel via Visual Basic but translates very well into Python COM. Cheers Eric Hagemann "Matthew Miller" wrote in message news:3939D364.2EF22B13 at zebrasoft.co.nz... > hi everyone, > > A couple o0f questions:- > 1) > can you access an excel (.xls) file via com without having excel loaded > on that machine? > 2) > once you've done:- > blah = win32com.client.Dispatch("Excel.Application") > can anyone give details of > a) howto open a particular s/s in the current directory > and > b) howto access particular cells in that particular s/s > and > c) howto close that s/s > > I have to admit that I'm hoping some kind soul will help before I'm > consigned to grappling with what looks like grooling documentation! > thanks alot matthew. From aahz at netcom.com Thu Jun 29 11:00:00 2000 From: aahz at netcom.com (Aahz Maruch) Date: 29 Jun 2000 15:00:00 GMT Subject: exiting threads References: <8jfcf9$2rp$1@nnrp1.deja.com> <8jfiuj$lf1$1@slb1.atl.mindspring.net> <8jfmdf$ah6$1@nnrp1.deja.com> Message-ID: <8jfo9g$2fu$1@slb1.atl.mindspring.net> In article <8jfmdf$ah6$1 at nnrp1.deja.com>, Dale Burnett wrote: >In article <8jfiuj$lf1$1 at slb1.atl.mindspring.net>, > aahz at netcom.com (Aahz Maruch) wrote: >> In article <8jfcf9$2rp$1 at nnrp1.deja.com>, >> Dale Burnett wrote: >>> >>>I am using thread.start_new_thread(self.foo,(x,y)) >>> >>>Do I have to explicitly exit the thread or does it automatically exit >>>when foo returns? >> >> I believe it does, but I strongly recommend that you subclass >> threading.Thread instead. > >why? because of the greater functionality of threading or is there >something wrong with thread? Because if you want to use *any* of the functionality of threading (e.g. the queue class or semaphore), your threads need to be a subclass of threading.Thread. Sure, you say now that you don't need those features, but why take chances? threading just makes your life easier. As a side note, the threading module emulates the Java model fairly closely, so it helps if there's ever any chance you might use Java. -- --- 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 al at servana.com Tue Jun 6 17:52:48 2000 From: al at servana.com (al at servana.com) Date: Tue, 06 Jun 2000 21:52:48 -0000 Subject: DEBUGGER question Message-ID: <8hjrrg+tc6s@eGroups.com> Hello! I have read the pdb docs and can use PDB with python script functions just fine. But, how do you use PDB with an 'executable' python script which uses a MAIN()? When I have a script with N functions, I can use pdb.run to debug any of the functions separately. When I have a script with a MAIN that is envoked when you 'execute the script' (like: python scriptname.py -a -b -c arg1 arg2) I cannot find a way to get it 'in' to PDB. If I try pdb.run('scriptname.main()') it does not actually execute the script. I tried pdb.runcall also, and also used the __main__ notataion - still no go. If you look at the WEBCHECKER scripts which come with python, you can see scripts which are setup to be 'executed'. I really want to peek inside some functions while running the script to see what is going on. (like 'addroot' in the Checker class of WEBCHECKER) Any help would be appreciated, Al G From philippe.possemiers at the-ecorp.com Mon Jun 26 04:43:54 2000 From: philippe.possemiers at the-ecorp.com (Philippe Possemiers) Date: Mon, 26 Jun 2000 10:43:54 +0200 Subject: ppp-script References: <39570BCE.5E5DEF97@the-ecorp.com> Message-ID: <395717CA.BED460CD@the-ecorp.com> Thanks, it works perfectly. Actually, I wonder why I haven't tried os.system() yet. I guess I was too busy trying to alter the ppp script (and even trying to rewrite it in python) to read the doc more carefully... Philippe Thomas Wouters wrote: > On Mon, 26 Jun 2000 09:52:46 +0200, Philippe Possemiers > wrote: > > >My platform is Linux and I use a modem to dial my ISP. Therefore, I use > >os.exec* in my script to activate /etc/ppp/ppp-on. The question is : how > >do I return to my python script? From the moment I call 'ppp-on', I seem > >to lose all control and cannot return to the python interpreter. > > os.exec*() replace the currently executing process, instead of creating a > new process and waiting for it to finish (which is what you want, I > assume.) > > You are looking for os.system(). It takes a single string as argument, which > should be the command and any argument, just like you type them on the > shell. (In fact, os.system() just spawns a shell and passes it the string ;) > > Alternatively, you can use os.fork() and os.exec*(), and then os.waitpid() > for the child to finish, but that's only necessary if you want to do things > while waiting, or if you want to avoid using the shell (because you want to > fiddle with ARGV, or some such.) > > Argh-argv-argc-ly y'rs, > Thomas. From emile at fenx.com Thu Jun 22 17:32:58 2000 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Jun 2000 14:32:58 -0700 Subject: boolean true and false values. References: <000d01bfdc23$c8aefae0$f0c809c0@lslp7o.lsl.co.uk> <0b0801bfdc5f$b3cca3c0$1906a8c0@fc.fenx.com> <395280DF.7C76C1A4@stud.ntnu.no> Message-ID: <0cbe01bfdc91$7c123580$1906a8c0@fc.fenx.com> Of course you're right on 125 vs 122 octal. My personal problem with hex is that the 'high order' values (08x-0Fx) have never been obvious without some mental gymnastics, whereas with octal it's always been easy. Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: "Peter Schneider-Kamp" To: "Emile van Sebille" Cc: Sent: Thursday, June 22, 2000 2:10 PM Subject: Re: boolean true and false values. > Emile van Sebille wrote: > > > > Only when I want to know about the bits. It's so > > much easier to recognize 122 octal as having > > alternate bits set than the equivalent in decimal > > or hex. > > much easier than decimal - of course! But what is > wrong about 52? By the way 122 is not alternating... > 125 is. But then 55 is probably much better to read. > > or-did-you-mean-something-else-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 > > -- > http://www.python.org/mailman/listinfo/python-list > From cut_me_out at hotmail.com Tue Jun 13 21:18:18 2000 From: cut_me_out at hotmail.com (Alex) Date: 13 Jun 2000 21:18:18 -0400 Subject: tuple creation in C extensions References: <3942AFEE.5155481@stud.ntnu.no> <3942B267.C769395@stud.ntnu.no> <110620000925578570%pecora@anvil.nrl.navy.mil> Message-ID: Wow, thanks for looking that code over, Bernhard. What a horrible bunch of holes. Alex. From richard_chamberlainNOriSPAM at ntlworld.com.invalid Wed Jun 21 17:41:20 2000 From: richard_chamberlainNOriSPAM at ntlworld.com.invalid (Richard Chamberlain) Date: Wed, 21 Jun 2000 14:41:20 -0700 Subject: Tkinter - image not found. References: Message-ID: <02c98a88.6ea91b1a@usw-ex0106-045.remarq.com> Hi Grzegorz, There's a kind of quirky thing that causes images to disappear depending if the reference you have isn't a global one. Search comp.lang.python for 'unsettling tkinter bug' and you should find some responses. Richard Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From gmcm at hypernet.com Thu Jun 29 19:28:56 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 29 Jun 2000 23:28:56 GMT Subject: Following a file, or cloning tail References: <8F62AF73Egmcmhypernetcom@199.171.54.194> <36D5F4DFCA9BCA46.B5AE15F2F19F393C.28F9B766F10B5E23@lp.airnews.net> Message-ID: <8F62C20E2gmcmhypernetcom@199.171.54.154> [posted and mailed] Cameron Laird gets his tail in a knot: >Gordon McMillan wrote: >>Um, you said you had to be portable. Not only is tail not standard on >>Windows, but os.popen is flaky there too (depending on circumstances >>too painful to enumerate). >I think I'm going to start growling every time >I hear that. To be precise: popen* flakiness >is one of the chief discouragements in my use >of Python (which is, I recognize, slightly >skewed from other's). 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). >>However, tail (usually - some implementations differ) does almost what >>the following code does. Note that even this isn't portable, because >>Windows doesn't have ino's to check. I have the code this is extracted >>from 7x24 >Guys, guys: there are enough seriously hard >problems in the world. Don't make this one. > >Win* FSs don't have i-nodes. So a portable >formulation of the requirements shouldn't >involve i-node. That's OK. Just poll for >either readability or file size. While I >confess I haven't verified that Py-built-ins >for these are properly portable, they REALLY >need to be if they aren't already, and I'm >willing to write test drivers and demonstra- >tions if these remain in doubt for one more >round of c.l.p dialogue. The whole inode thing in that code is because it is a common Linux idiom to rely on the fact that once a process has opened a file, said file can be deleted by another process without the reading process noticing. This idiom is completely impossible on Windows, so there's no sense in checking whether a new file with the same name has now been created. So what'll it be - a portable version that's useless on Linux, or one that spends half it's time checking for something that can't occur on Windows ? on-Windows-once-you've-grabbed-the-tail- you've-got-the-whole-damn-dog-ly y'rs - Gordon (who never uses popen on Windows anyway) From moshez at math.huji.ac.il Fri Jun 9 14:05:35 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 9 Jun 2000 21:05:35 +0300 (IDT) Subject: readlines() question In-Reply-To: <8hrapd$e2g$1@nntp9.atl.mindspring.net> Message-ID: [About...] > >contents = open('file').readlines() > > > >is 'file' closed after readlines() finishes? If not, is it possible to > >somehow get either the file descriptor or the file object of the opened > >file? Thanks, [Aahz] > Yes, it's closed. The anonymous object created by open() gets > deallocated after the assignment; part of the cleanup is to silently > call close(). While what Aahz said can't be said to be untrue, it's hard to call it true, either. That is what happens in the *current* *CPython* implementation. In no way does the language require it, and specifically, for JPython, it is not true. just-picking-nits-here-people-ly y'rs, Z. -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From etoffi at softhome.net Mon Jun 19 04:00:23 2000 From: etoffi at softhome.net (Aluo Nowu) Date: Mon, 19 Jun 2000 04:00:23 -0400 Subject: New filemanager needs people with files Message-ID: <4.3.2.7.0.20000619035545.00aa1d10@pop.softhome.net> I am going to be hosting a project on sourceforge called Newfie. Tell you the truth I'm not good at naming things. (If I got a dog, I would name it "dog". I'd rather not waste time thinking up names for filemanagers). On to more important things, it is currently in the planning stage right now. If you ever had a wish for a file manager, feel free to tell me. Python scripting will more than likely be included. All ideas will be evaluated. You wont be sorry (unless you're stuck on Explorer). The main site is: http://sourceforge.net/projects/newfie/ The web site is: http://newfie.sourceforge.net The mailing list is: mailto://newfie-devel at lists.sourceforge.com The other mailing list is: mailto://newfie-wishlist at lists.sourceforge.com --- Original Text --- Subject: New filemanager needs people with files From: etoffi Date: 2000-Jun-16 (1600) -0400 Ha ha ha. Newfie (got a better name?) is a project which will be used to surpass "* Commander" filemanagers. It will have an extensible, pluggable architecture, be crossplatform, among other great buzzword-type things. Any resources (suggestions, screenshots, sourcecode) are welcome. From sdhyok at email.unc.edu Wed Jun 14 21:43:14 2000 From: sdhyok at email.unc.edu (Daehyok Shin) Date: Wed, 14 Jun 2000 21:43:14 -0400 Subject: How to prevent illegal definition of a variable in objects? References: <8i8ujt$hop$1@news2.isis.unc.edu> <20000614155102.E16232@freei.com> Message-ID: <8i9cbh$mev$1@news2.isis.unc.edu> Even though I corrected minor errors, it does not work. Refer to the following comments. >> class A: > > def __init__(self): > > self.x = 1 # this code calls __setattr__ # when I change it into self.__x = 1, it raised AttributeError in __setattr__ > > > > def __setattr__(self, name, value): > > if name == "x": > > self.x = value # this code calls __setattr__ recursively > > else: > > raise AttributeError > > > > def __getattr__(self, name): > > if name == "x": > > return self.x > > else: > > raise AttributeError I found one solution, but expect better one. -------------- Solution, but not good ------------------ class A: def __init__(self): self.__dict__["x"]=1 def __setattr__(self, name, value): if not self.__dict__.has_key(name): raise AttriubuteError else: self.__dict__[name] = value def __getattr__(self, name): if not self.__dict__.has_key(name): raise AttriubuteError else: return self.__dict__[name] "Sean Blakey" wrote in message news:20000614155102.E16232 at freei.com... > On Wed, Jun 14, 2000 at 05:48:45PM -0400, Daehyok Shin wrote: > > How can I prevent illegal definition of a variable to an object? > > For instance, > > > > class A: > > __init__(self): > > self.x = 1 > > > > __setattr__(self, name, value): > > if name == "x": > > self.x = value > > else: > > raise AttributeException > > > > __getattr__(self, name): > > if name == "x": > > return self.x > > else: > > raise AttributeException > > > > >>> a = A() > > >>> a.x = 10 > > >>> a.y = 20 # I want to raise an AttributeException. > > > > Peter > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > The code you posted seems to do what you want, provided you > a)add the 'def' keyword to your function definitions > and > b) define AttributeException (perhaps you meant AttributeError?) > > -- > Sean Blakey, sblakey at freei.com > Software Developer, FreeInternet.com > (253)796-6500x1025 > "Uncle Cosmo ... why do they call this a word processor?" > "It's simple, Skyler ... you've seen what food processors do to food, > right?" > -- MacNelley, "Shoe" > From bjrubble at shell16.ba.best.com Wed Jun 28 19:04:42 2000 From: bjrubble at shell16.ba.best.com (Adam Clark) Date: 28 Jun 2000 23:04:42 GMT Subject: in xml.dom.HtmlBuilder? It looks like the problem is that