From sheila@thinkspot.net Sun Apr 1 00:20:12 2001 From: sheila@thinkspot.net (Sheila King) Date: Sat, 31 Mar 2001 16:20:12 -0800 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <LNBBLJKPBEHFEDALKOLCIEIAJJAA.tim.one@home.com> References: <5F0FF742F1D@kserver.org> <LNBBLJKPBEHFEDALKOLCIEIAJJAA.tim.one@home.com> Message-ID: <738F32F4A49@kserver.org> On Sat, 31 Mar 2001 14:52:00 -0500, "Tim Peters" <tim.one@home.com> wrote about RE: [Tutor] Still confused about Python references/objects: :[Sheila King] :> ... :> However, just for illustration, I was trying to write a swap :> function. And, I thought that all parameters were passed by reference. : :"by reference" isn't really a useful concept in Python. People bring that :with them from other languages, and get into all sorts of trouble trying to :force it to fit. You're telling me! (I bring background experience from a few different languages: Pascal, Fortran, VB, C++, and they ALL behaved that way! It is so difficult to get used to this new way of thinking.) : Python is *simpler* than that. It's easier (in the end :<wink>) to think of argument-passing in Python as being "pass by object": :don't think of passing names, or pointers, or references, or even values, but :think of passing objects directly. OK... ...<snipped>... :The other half of the story is that a statement of the form : : x = y : :is *not* an operation on objects, it's an operation on namespaces, and all it :means is "whatever object the name 'y' refers to at this moment, also give :that object the name 'x' (and in the local namespace, provided 'x' hasn't :been declared global)". : :Argument passing is exactly like : : x = y : :in all respects: the objects in the argument list are merely given names in :the called function's local namespace. The names they're given are, of :course, the function's formal argument names. ...<very good explanation snipped>... OK, so I think I get what you're saying. It sounds like, in order to have a function modify an object in the calling functions space, either it has to be a mutable object, or else I would (I think?) have to return the new version I want, and assign it to a name in the calling function's namespace ??? Does this sound right? So, now I think I know what I'm doing, and I try this: >>> def swap(two_tuple): x,y = two_tuple return y, x >>> a = 2 >>> b = 3 >>> print a, " ", b 2 3 >>> a,b = swap((a,b)) >>> print a, " ", b 3 2 >>> OK, I think I got it. The only way to think of a function as modifying something in the calling namespace, is either if it is a mutable object, or else it has to return the new object that I want to reference. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dyoo@hkn.eecs.berkeley.edu Sun Apr 1 04:37:05 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 31 Mar 2001 19:37:05 -0800 (PST) Subject: [Tutor] Timer? In-Reply-To: <3AC60E1A.4D6A1EC2@lindbergs.org> Message-ID: <Pine.LNX.4.21.0103311931520.7013-100000@hkn.eecs.berkeley.edu> On Sat, 31 Mar 2001, VanL wrote: > > > > ### > > from Tkinter import * > > > > class BlinkingButton(Button): > > def __init__(self, master, **kwargs): > > Button.__init__(self, master, **kwargs) > > self.blinkerson = 1 > > self.blink() > > > > def blink(self): > > if self.blinkerson: > > self.flash() > > self.after(1000, self.blink) > > > > if __name__ == '__main__': > > root = Tk() > > BlinkingButton(root, text="Blinking Button!").pack() > > mainloop() > > ### > > I was testing out what you said and this code didn't work for me. It created a > button, but it didn't blink. > Do you know why? Hmm... the code is Python 2.0 specific, since I'm doing the call: Button.__init__(self, master, **kwargs) If this is what's causing problems, then let's replace it with something more compatible: apply(Button.__init__, [self, master], kwargs) They both do the same thing: they call the Button.__init__ function while giving the user lots of freedom to specify keyword arguments. However, I've only been able to test this on my Linux computer; has anyone else had success with this? From dyoo@hkn.eecs.berkeley.edu Sun Apr 1 04:45:36 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 31 Mar 2001 19:45:36 -0800 (PST) Subject: [Tutor] Scripts In-Reply-To: <005C01D254FAD411BF8800B0D03E0AB632F81D@MICROPHONE> Message-ID: <Pine.LNX.4.21.0103311939130.7013-100000@hkn.eecs.berkeley.edu> On Fri, 30 Mar 2001, Larry Lam wrote: > How can I call and receive phone calls thru a modem using python scripts? > How to kill a telnet section with python? On a Unix computer, the modem is a serial device that can be opened like a file. On my system, it's '/dev/cua1' (COM2), so one way to send commands to the modem would be: ### modem = open('/dev/cua1', 'w') modem.write('ATZ\n') ### However, I don't have a modem anymore, so I'm unable to test any modem-like stuff at the moment. Windows, too, has support for serial-port communications, and there are a few modules available that might be helpful for you: http://www.vex.net/parnassus/apyllo.py?i=15173005 http://starship.python.net/crew/roger/ About closing a telnet session: assuming that the session was opened with telnetlib, you should be able to simply close() the connection, according to: http://python.org/doc/current/lib/telnet-objects.html Good luck to you! From tim.one@home.com Sun Apr 1 04:51:39 2001 From: tim.one@home.com (Tim Peters) Date: Sat, 31 Mar 2001 22:51:39 -0500 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <738F32F4A49@kserver.org> Message-ID: <LNBBLJKPBEHFEDALKOLCKEIPJJAA.tim.one@home.com> [Sheila King, on trying to understand Python via reference semantics] > You're telling me! (I bring background experience from a few different > languages: Pascal, Fortran, VB, C++, and they ALL behaved that > way! It is so difficult to get used to this new way of thinking.) If it's any consolation, those to whom Python is a first language have no trouble at all with it, and probably suffer even greater trying to keep track of the new mysteries that pop up when they move to other languages. The eff-bot (Fredrik Lundh) wrote a very nice and tiny intro, here: http://w1.132.telia.com/~u13208596/guides/python-objects.htm Check it out! The first instruction is vital, though: "Reset your brain.". Once you do, "the rules" are short and sweet (his writeup is less than one page of text, including examples). > ... > OK, so I think I get what you're saying. It sounds like, in order to > have a function modify an object in the calling functions space, either > it has to be a mutable object, or else I would (I think?) have to > return the new version I want, and assign it to a name in the calling > function's namespace ??? Yup! Note too that module-global objects are visible from *all* function and method namespaces, so that's another possibility: def f(): global x x = 42 y = 42 g(y) print x # happens to prints 666 print y # prints 42, and no matter *what* g() does def g(a): global x x = 666 f() But heavy use of globals is bad practice, in part precisely *because* any call can change global bindings at any time. You can see this in the body of f: you can't possibly guess what "print x" is going to do without tracking down and studying the source code for g, but you can be certain that "print y" will print 42 without looking at g. This makes the use of y much easier to understand in isolation, and the larger your programs get, the more valuable it is to limit the amount of code you need to examine. Local names and immutable objects can both help with that. > ... > So, now I think I know what I'm doing, and I try this: > > >>> def swap(two_tuple): > x,y = two_tuple > return y, x > > >>> a = 2 > >>> b = 3 > >>> print a, " ", b > 2 3 > >>> a,b = swap((a,b)) > >>> print a, " ", b > 3 2 > >>> Little-known feature: just like you can do x, y = two_tuple and Python will "magically" unpack the two_tuple into x and y, you can also do that in formal argument lists. So def swap((x, y)): return y, x also works. > OK, I think I got it. The only way to think of a function as modifying > something in the calling namespace, is either if it is a mutable > object, or else it has to return the new object that I want to > reference. Yes, and because (1) the called function simply has no access to its caller's namespace, and (2) there is no pointer type in Python, so you *can't* pass "a reference" to an object (btw, I think *that's* the fundamental reason why trying to think about Python in "call by reference" terms ends up confusing people: Python simply doesn't have references in that sense; I call it "call by object" to force people to break out of inappropriate mental models). you're-well-on-the-road-to-a-full-recovery<wink>-ly y'rs - tim From syrinx@simplecom.net Sun Apr 1 04:52:47 2001 From: syrinx@simplecom.net (Scott) Date: Sat, 31 Mar 2001 21:52:47 -0600 Subject: [Tutor] valid filenames Message-ID: <0c9dctsgsj3mcgvt0c0gubnjb6s7soo3k4@4ax.com> Is there a Python module that contains a function that determines if a string is a valid filename? If not, can someone refresh my memory; what is a valid filename in Unix? I think it can be up to 255 characters, but which characters are disallowed? From dkstewaP@netscape.net Sun Apr 1 08:41:26 2001 From: dkstewaP@netscape.net (dkstewaP@netscape.net) Date: Sun, 01 Apr 2001 03:41:26 -0400 Subject: [Tutor] Help passing parameters to cancel callback (after_cancel) Message-ID: <26630645.5B2F134B.00978E7F@netscape.net> I am trying to build a demonstration/test module for process control application using Tkinter. I want to include a clock updating in one second intervals that can be started and stopped by the user (effictively a stop watch type application). My previous programming experience has been in various flavours of basic including VBA for quite complex applications in msWord and Excel. I am very confused as to how I pass the id parameter from the call to after() to the after_cancel() function. I think my problems are related to the scope of variables (namespaces in python) and how to refer to the variable in the various namespaces. The combination of using a class to define my functions and having to pass additional namespace info to Tkinter has really got me beat. My sample code follows (adapted from the hello word example in "An Introduction to Tkinter"). Any help to fix the code and to help me understand Python would be gratefully appreciated. David Brisbane, Australia # File: hello2.py """Display System Time String - potential GUI for stop watch or similar module Stop button should cleanly break out of the polling loop""" from Tkinter import * from time import * class App: def __init__(self, master): self.idn = 0 self.master = master frame = Frame(master, width = 512 , height = 256,) frame.pack() self.label = Label(frame, text="The system time is") self.label.place(relx=0.1, rely=0.2) self.label2 = Label(frame, text=" ", width = 36 , height = 1, relief=RAISED) self.label2.place(relx=0.5, rely=0.2) self.button = Button(frame, text="STOP", fg="red", command=self.stop(self.idn)) self.button.place(relx=0.5, rely=0.8) self.hi_there = Button(frame, text="Quit", command=sys.exit) self.hi_there.place(relx=0.7, rely=0.8) self.idn = self.poll() # start polling def stop(self, idn): self.master.after_cancel(idn) def poll(self): count = time() self.label2.configure(text=str(count)) nn = self.master.after(1000, self.poll) return nn root = Tk() app = App(root) root.mainloop() __________________________________________________________________ Get your own FREE, personal Netscape Webmail account today at http://webmail.netscape.com/ From deirdre@deirdre.net Sun Apr 1 08:53:18 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sat, 31 Mar 2001 23:53:18 -0800 (PST) Subject: [Tutor] Is There a Bugtracking tool written in Python In-Reply-To: <20010331102136.D4184@gandalf> Message-ID: <Pine.LNX.4.31.0103312350190.28428-100000@emperor.deirdre.org> On Sat, 31 Mar 2001, Aaron Mathews wrote: > On Fri, Mar 30, 2001 at 09:38:49AM -0500, Scott Ralph Comboni wrote: > > Does anyone now if there is a bugtracking tool like bugzilla written in > > Python? > > Not that I know of. Bugzilla is one on a *very* short list of open > source bugtracking systems. I personally would love to see bugzilla > reimplemented in python, it would be a heck of a lot easier to > customize (which I unfortunately have had to do during the last few > weeks). Modifying squirrely perl code is not exactly my idea of fun. > But then again, bugzilla works better than any of the alternatives > I've seen, so that's the way it goes. Actually, that's what HellDesk was, but it was never released. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From pdiaz88@terra.es Sun Apr 1 13:18:06 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Sun, 1 Apr 2001 14:18:06 +0200 Subject: [Tutor] installing python 2.0 on redhat 7.0 In-Reply-To: <000b01c0b9b0$b4aea160$7001a8c0@sagga> References: <000b01c0b9b0$b4aea160$7001a8c0@sagga> Message-ID: <01040114180600.01550@tajo> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday 31 March 2001 09:03, Steve A. wrote: > Hello. > > Seems that to install python 2.0 on redhat 7 I'll need to reinstall > glibc.. well, basically, considering all the file dependencies, it's just > not worth it. I'm wondering if anyone has installed python 2.0 or 2.1 on > redhat 7, and if there are any RPMS out there to make it a relatively > painless process. Otherwise it looks like I'm going to have to go back to > 6.2. argh! > > -Steve Well, in a normal situation I would advice you to compile the sources (not too dificult) but considering that RH 7.0 has an almost broken compiler and other security flaws, I think It would be better for you to go back to 6.2 or switch to another distro Cheers Pedro - ---------------------------------------- Content-Type: text/html; charset="iso-8859-1"; name="Attachment: 1" Content-Transfer-Encoding: quoted-printable Content-Description: - ---------------------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6xxyQnu53feEYxlERAkNAAJ9GfYrjULCJQ6NEuSheBi/RAywmbQCfVTsG fxXMyUisoZey4RTC9idrtG8= =Ubwv -----END PGP SIGNATURE----- From arcege@dsl254-114-246.nyc1.dsl.speakeasy.net Sun Apr 1 13:45:35 2001 From: arcege@dsl254-114-246.nyc1.dsl.speakeasy.net (Michael P. Reilly) Date: Sun, 1 Apr 2001 08:45:35 -0400 (EDT) Subject: [Tutor] valid filenames In-Reply-To: <0c9dctsgsj3mcgvt0c0gubnjb6s7soo3k4@4ax.com> from "Scott" at Mar 31, 2001 09:52:47 PM Message-ID: <200104011245.f31CjZs08501@dsl254-114-246.nyc1.dsl.speakeasy.net> Scott wrote > Is there a Python module that contains a function that determines if a > string is a valid filename? If not, can someone refresh my memory; > what is a valid filename in Unix? I think it can be up to 255 > characters, but which characters are disallowed? Not one to say if a pathname/filename is "valid" specifically, but there is one to test if a file exists ('os.path.exists'). Filenames may contain any character except the slash (/, '\057\) and the null character ('\000'). Name components in a full pathname to a file are seperated by slashes (e.g. "/home/arcege/.login"). And in the language C, strings are terminated by the null character; an embedded null character would mean that most every program in UNIX would see a shortened filename. A UNIX filename can be just about anything, UNIX won't really care. Some utilities and scripting languages will have problems tho. Python will take "weird" filename as just another string and use it without problems (except that Python can embedded null characters). But in general, filenames can be kept to lower-case and upper-case characters, numerals and punctuation. You might want to look into the fnmatch module. :OT: There was a recent thread here about the "disadvantages of UNIX not evaluating filename extentions". UNIX evaluates nothing - a filename can be anything. It is up to the application to handle the file. There are utilities to determine file type (for example, file(1)), having the operating system determine this is detrimental to the power of UNIX. :OT: -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From rick@niof.net Sun Apr 1 15:18:32 2001 From: rick@niof.net (Rick Pasotto) Date: Sun, 1 Apr 2001 10:18:32 -0400 Subject: [Tutor] Help passing parameters to cancel callback (after_cancel) In-Reply-To: <26630645.5B2F134B.00978E7F@netscape.net>; from dkstewaP@netscape.net on Sun, Apr 01, 2001 at 03:41:26AM -0400 References: <26630645.5B2F134B.00978E7F@netscape.net> Message-ID: <20010401101832.Q26119@tc.niof.net> On Sun, Apr 01, 2001 at 03:41:26AM -0400, dkstewaP@netscape.net wrote: > I am trying to build a demonstration/test module for process control > application using Tkinter. I want to include a clock updating in one > second intervals that can be started and stopped by the user > (effictively a stop watch type application). My previous programming > experience has been in various flavours of basic including VBA for > quite complex applications in msWord and Excel. > > I am very confused as to how I pass the id parameter from the call to > after() to the after_cancel() function. I think my problems are > related to the scope of variables (namespaces in python) and how to > refer to the variable in the various namespaces. The combination of > using a class to define my functions and having to pass additional > namespace info to Tkinter has really got me beat. Your class is a namespace. Each instance of the class is a namespace. The easiest way to do what you want is to save the return value in self.return_value. Following is my version of a program that does what you want (and a little more). I've interspersed some comments. Note that you can't pass a parameter to a function specified in a 'command =' parameter. (At least not directly. You can fudge it with a lambda.) The reason is that 'command =' takes the *name* of a function not the function itself - thus there are no parens. #!/usr/bin/evn python from Tkinter import * import time # avoid possible name collisions class Main: def __init__(self,win): self.win = win self.lbl = Label(self.win,width=40,height=3,bg='lightpink') self.lbl.pack(padx=5,pady=5) frm = Frame(self.win) self.start = Button(frm,text='Start',command=self.do_start) self.start.pack(side=LEFT,padx=15,pady=5) self.stop = Button(frm,text='Stop',command=self.do_stop) self.stop.pack(side=LEFT,padx=15,pady=5) frm.pack() self.go = 0 # set a global to know whether or not the clock is running def do_start(self): if not self.go: self.go = 1 self.set_time() def set_time(self): self.lbl.config(text="\n%s" % time.ctime(time.time())) # time.time() returns the number of seconds since the epoch # formatting it looks nicer self.rtn = self.win.after(1000,self.set_time) print self.rtn # notice that the return value is different every time def do_stop(self): if self.go: self.go = 0 self.win.after_cancel(self.rtn) if __name__ == '__main__': root = Tk() main = Main(root) root.mainloop() > My sample code follows (adapted from the hello word example in "An > Introduction to Tkinter"). Any help to fix the code and to help me > understand Python would be gratefully appreciated. > > David > Brisbane, Australia > > # File: hello2.py > """Display System Time String - potential GUI for stop watch or similar module > > Stop button should cleanly break out of the polling loop""" > > from Tkinter import * > from time import * > > class App: > > def __init__(self, master): > > self.idn = 0 > self.master = master > frame = Frame(master, width = 512 , height = 256,) > frame.pack() > > self.label = Label(frame, text="The system time is") > self.label.place(relx=0.1, rely=0.2) > > self.label2 = Label(frame, text=" ", width = 36 , height = 1, relief=RAISED) > self.label2.place(relx=0.5, rely=0.2) > > self.button = Button(frame, text="STOP", fg="red", command=self.stop(self.idn)) > self.button.place(relx=0.5, rely=0.8) > > self.hi_there = Button(frame, text="Quit", command=sys.exit) > self.hi_there.place(relx=0.7, rely=0.8) > > self.idn = self.poll() # start polling > > def stop(self, idn): > self.master.after_cancel(idn) > > def poll(self): > count = time() > self.label2.configure(text=str(count)) > nn = self.master.after(1000, self.poll) > return nn > > root = Tk() > app = App(root) > root.mainloop() -- "Prohibition...goes beyond the bounds of reason in that it attempts to control a man's appetite by legislation and makes a crime out things that are not crimes. A prohibition law strikes a blow at the very principles upon which our government was founded." -- Abraham Lincoln, Dec. 1840 Rick Pasotto email: rickp@telocity.com From lumbricus@gmx.net Sun Apr 1 16:02:57 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Sun, 1 Apr 2001 17:02:57 +0200 Subject: [Tutor] valid filenames In-Reply-To: <200104011245.f31CjZs08501@dsl254-114-246.nyc1.dsl.speakeasy.net>; from arcege@dsl254-114-246.nyc1.dsl.speakeasy.net on Sun, Apr 01, 2001 at 08:45:35AM -0400 References: <0c9dctsgsj3mcgvt0c0gubnjb6s7soo3k4@4ax.com> <200104011245.f31CjZs08501@dsl254-114-246.nyc1.dsl.speakeasy.net> Message-ID: <20010401170257.B5874@Laplace.localdomain> Hi all!!! > But in general, filenames can be kept to lower-case and upper-case > characters, numerals and punctuation. You might want to look into the > fnmatch module. > U can avoid by not using names like -anything ^ names containing whitespace (this goes to m$-windoze and mac especially *grrrrrr*) and other special characters all allowed in UNIX but generally a bad idea. grreetings!! From lumbricus@gmx.net Sun Apr 1 15:44:45 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Sun, 1 Apr 2001 16:44:45 +0200 Subject: [Tutor] Scripts In-Reply-To: <Pine.LNX.4.21.0103311939130.7013-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Sat, Mar 31, 2001 at 07:45:36PM -0800 References: <005C01D254FAD411BF8800B0D03E0AB632F81D@MICROPHONE> <Pine.LNX.4.21.0103311939130.7013-100000@hkn.eecs.berkeley.edu> Message-ID: <20010401164445.A5874@Laplace.localdomain> Hello!!! > > > How can I call and receive phone calls thru a modem using python scripts? > > How to kill a telnet section with python? > > On a Unix computer, the modem is a serial device that can be opened like a > file. On my system, it's '/dev/cua1' (COM2), so one way to send commands ^^^^^^^^^^^ don't use this anymore (baeh bah !!! ;-)) Use /dev/ttyS<n> (/dev/ttyS1 for com2) because cua<n> can be more easyly tricked to dial out even when DCD control signal sez not to. that's why in former times programmers used cua<n> for dialing out and ttyS<n> for in since kernel 2.2 you get a warning in the logs when you use cua. just my 0.02 $ grrrrreetings jö! From scarblac@pino.selwerd.nl Sun Apr 1 16:17:44 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 1 Apr 2001 17:17:44 +0200 Subject: [Tutor] valid filenames In-Reply-To: <0c9dctsgsj3mcgvt0c0gubnjb6s7soo3k4@4ax.com>; from syrinx@simplecom.net on Sat, Mar 31, 2001 at 09:52:47PM -0600 References: <0c9dctsgsj3mcgvt0c0gubnjb6s7soo3k4@4ax.com> Message-ID: <20010401171744.A2066@pino.selwerd.nl> On Sat, Mar 31, 2001 at 09:52:47PM -0600, Scott wrote: > Is there a Python module that contains a function that determines if a > string is a valid filename? If not, can someone refresh my memory; > what is a valid filename in Unix? I think it can be up to 255 > characters, but which characters are disallowed? '/' is disallowed, and '\0' (null). -- Remco Gerlich From sheila@thinkspot.net Sun Apr 1 17:08:46 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 01 Apr 2001 09:08:46 -0700 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <LNBBLJKPBEHFEDALKOLCKEIPJJAA.tim.one@home.com> References: <738F32F4A49@kserver.org> <LNBBLJKPBEHFEDALKOLCKEIPJJAA.tim.one@home.com> Message-ID: <2A5D2F922F0@kserver.org> On Sat, 31 Mar 2001 22:51:39 -0500, "Tim Peters" <tim.one@home.com> wrote about RE: [Tutor] Still confused about Python references/objects: :[Sheila King, on trying to understand Python via reference semantics] :> You're telling me! (I bring background experience from a few different :> languages: Pascal, Fortran, VB, C++, and they ALL behaved that :> way! It is so difficult to get used to this new way of thinking.) : :If it's any consolation, those to whom Python is a first language have no :trouble at all with it, and probably suffer even greater trying to keep track :of the new mysteries that pop up when they move to other languages. Well, that's why I was wondering about whether Python is really a good first language. It seems to me, it would be much more difficult to get used to strongly typed languages and references/values/pointers after using Python first. Dunno. :The eff-bot (Fredrik Lundh) wrote a very nice and tiny intro, here: : : http://w1.132.telia.com/~u13208596/guides/python-objects.htm : :Check it out! Been there, done that. I'm one of the types that has to go over an idea many times until it sinks in. ...<snipped>... :Yup! Note too that module-global objects are visible from *all* function and :method namespaces, so that's another possibility: I haven't messed with the global module, yet. ...<examples snipped>... :But heavy use of globals is bad practice, in part precisely *because* any :call can change global bindings at any time. Yes, I teach C++ programming and I tell my students: global constants = good global variables = bad And usually they are not allowed to use global variables in their programs, precisely because of the reasons you mention below. I think that we did some stuff with graphics/gui windows once, and IIRC the main window had to be a global variable in order for the program to work correctly. : You can see this in the body of :f: you can't possibly guess what "print x" is going to do without tracking :down and studying the source code for g, but you can be certain that "print :y" will print 42 without looking at g. This makes the use of y much easier :to understand in isolation, and the larger your programs get, the more :valuable it is to limit the amount of code you need to examine. Local names :and immutable objects can both help with that. ...<my sample snipped>... :Little-known feature: just like you can do : : x, y = two_tuple : :and Python will "magically" unpack the two_tuple into x and y, you can also :do that in formal argument lists. So : :def swap((x, y)): : return y, x : :also works. OK, cool. I almost tried that. :you're-well-on-the-road-to-a-full-recovery<wink>-ly y'rs - tim <snort> -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sheila@thinkspot.net Sun Apr 1 17:24:06 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 01 Apr 2001 09:24:06 -0700 Subject: [Tutor] valid filenames In-Reply-To: <20010401170257.B5874@Laplace.localdomain> References: <0c9dctsgsj3mcgvt0c0gubnjb6s7soo3k4@4ax.com> <200104011245.f31CjZs08501@dsl254-114-246.nyc1.dsl.speakeasy.net> <20010401170257.B5874@Laplace.localdomain> Message-ID: <2B3C91C4233@kserver.org> On Sun, 1 Apr 2001 17:02:57 +0200, lumbricus@gmx.net wrote about Re: [Tutor] valid filenames: :U can avoid by not using :names like -anything : ^ The hyphen is not that uncommon in file names on Unix. For example, Qmail expects hyphens in the .qmail filenames that can be used for filtering email on the RCPT field of the email envelope, and from there invoking scripts or forwarding to other addresses or whatever. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From rick@niof.net Sun Apr 1 17:37:24 2001 From: rick@niof.net (Rick Pasotto) Date: Sun, 1 Apr 2001 12:37:24 -0400 Subject: [Tutor] valid filenames In-Reply-To: <2B3C91C4233@kserver.org>; from sheila@thinkspot.net on Sun, Apr 01, 2001 at 09:24:06AM -0700 References: <0c9dctsgsj3mcgvt0c0gubnjb6s7soo3k4@4ax.com> <200104011245.f31CjZs08501@dsl254-114-246.nyc1.dsl.speakeasy.net> <20010401170257.B5874@Laplace.localdomain> <2B3C91C4233@kserver.org> Message-ID: <20010401123724.R26119@tc.niof.net> On Sun, Apr 01, 2001 at 09:24:06AM -0700, Sheila King wrote: > On Sun, 1 Apr 2001 17:02:57 +0200, lumbricus@gmx.net wrote about Re: > [Tutor] > valid filenames: > > :U can avoid by not using > :names like -anything > : ^ > > The hyphen is not that uncommon in file names on Unix. For example, > Qmail expects hyphens in the .qmail filenames that can be used for > filtering email on the RCPT field of the email envelope, and from > there invoking scripts or forwarding to other addresses or whatever. The only problem with a hyphen is when it's the first character of the file name. Doing that causes many commands to confuse it with an option and special steps have to be taken to get around that. -- "A man who has nothing he is willing to fight for, nothing which he cares more about than he does his own personal safety, is a miserable creature, who has no chance of being free unless made and kept so by the exertions of men better than himself. As long as justice and injustice have not terminated their ever- renewing fight...human beings must be willing...to do battle for the one against the other." -- John Stuart Mill Rick Pasotto email: rickp@telocity.com From lumbricus@gmx.net Sun Apr 1 17:49:45 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Sun, 1 Apr 2001 18:49:45 +0200 Subject: [Tutor] Re: filename troubles Message-ID: <20010401184945.A6288@Laplace.localdomain> > > > > :U can avoid by not using > > :names like -anything > > : ^ > > > > The hyphen is not that uncommon in file names on Unix. For example, > > Qmail expects hyphens in the .qmail filenames that can be used for > > filtering email on the RCPT field of the email envelope, and from > > there invoking scripts or forwarding to other addresses or whatever. > > The only problem with a hyphen is when it's the first character of the > file name. Doing that causes many commands to confuse it with an option > and special steps have to be taken to get around that. > thats exactly what i wanted to say ;-) thx Jö! From Aaron.Mathews@Gentner.COM Sun Apr 1 11:04:15 2001 From: Aaron.Mathews@Gentner.COM (Aaron Mathews) Date: Sun, 1 Apr 2001 04:04:15 -0600 Subject: [Tutor] Is There a Bugtracking tool written in Python In-Reply-To: <Pine.LNX.4.31.0103312350190.28428-100000@emperor.deirdre.org>; from deirdre@deirdre.net on Sat, Mar 31, 2001 at 11:53:18PM -0800 References: <20010331102136.D4184@gandalf> <Pine.LNX.4.31.0103312350190.28428-100000@emperor.deirdre.org> Message-ID: <20010401040415.G4184@gandalf> On Sat, Mar 31, 2001 at 11:53:18PM -0800, Deirdre Saoirse wrote: > > > Actually, that's what HellDesk was, but it was never released. > Oh really? Whose project was that? A released python bug/helpdesk tracker system would make my consulting life a *lot* easier :) -- Aaron Mathews work: Aaron.Mathews@Gentner.COM - http://gentner.com/ play: Aaronm@Hobbiton.ORG - http://pukka.dyndns.org/ From scarblac@pino.selwerd.nl Sun Apr 1 20:06:23 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 1 Apr 2001 21:06:23 +0200 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <738F32F4A49@kserver.org>; from sheila@thinkspot.net on Sat, Mar 31, 2001 at 04:20:12PM -0800 References: <5F0FF742F1D@kserver.org> <LNBBLJKPBEHFEDALKOLCIEIAJJAA.tim.one@home.com> <738F32F4A49@kserver.org> Message-ID: <20010401210623.A2325@pino.selwerd.nl> On Sat, Mar 31, 2001 at 04:20:12PM -0800, Sheila King wrote: > On Sat, 31 Mar 2001 14:52:00 -0500, "Tim Peters" <tim.one@home.com> wrote > about RE: [Tutor] Still confused about Python references/objects: > > :[Sheila King] > :> ... > :> However, just for illustration, I was trying to write a swap > :> function. And, I thought that all parameters were passed by reference. > : > :"by reference" isn't really a useful concept in Python. People bring that > :with them from other languages, and get into all sorts of trouble trying to > :force it to fit. > > You're telling me! (I bring background experience from a few different > languages: Pascal, Fortran, VB, C++, and they ALL behaved that way! It is so > difficult to get used to this new way of thinking.) This point may be hard to get at first, but luckily it's one of the few things! I think once you understand: 1 Everything is by reference 2 Some objects can be changed, some can't - but no changes are made by simple assignment to a name. 3 Namespaces - everything is just a name for some object, even functions, modules, the results of import, etc - is this a special case of 1 and 2? 4 A variable is global if it's not assigned to here or if there is a "global x" statement nearby - otherwise it's local*. 5 Things like "def" happen at runtime (almost everything does*) 6 Calling a method on some instance passes "self" as 1st argument Then you understand all of the key points of the language Python (what did I forget?). I don't think I missed much. This list is enormously smaller than for other languages. Unfortunately the * things become a tiny bit more complex in versions in the near future. > OK, so I think I get what you're saying. It sounds like, in order to have a > function modify an object in the calling functions space, either it has to be > a mutable object, or else I would (I think?) have to return the new version I > want, and assign it to a name in the calling function's namespace ??? In order to have a function modify an object, to object has to be modifyable (mutable). Or, the function could return something, and the caller's code can keep it around, like binding some name to it. So yes :) > Does this sound right? > > So, now I think I know what I'm doing, and I try this: > > >>> def swap(two_tuple): > x,y = two_tuple > return y, x > > >>> a = 2 > >>> b = 3 > >>> print a, " ", b > 2 3 > >>> a,b = swap((a,b)) > >>> print a, " ", b > 3 2 > >>> Yes. Simpler would be a, b = b, a :) -- Remco Gerlich From deirdre@deirdre.net Sun Apr 1 20:08:06 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sun, 1 Apr 2001 12:08:06 -0700 (PDT) Subject: [Tutor] Is There a Bugtracking tool written in Python In-Reply-To: <20010401040415.G4184@gandalf> Message-ID: <Pine.LNX.4.31.0104011207340.13814-100000@emperor.deirdre.org> On Sun, 1 Apr 2001, Aaron Mathews wrote: > > Actually, that's what HellDesk was, but it was never released. > > Oh really? Whose project was that? A released python bug/helpdesk > tracker system would make my consulting life a *lot* easier :) Mine, among others. It was mostly done when several of us left Linuxcare, but was dropped immediately thereafter. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From sheila@thinkspot.net Sun Apr 1 22:08:05 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 01 Apr 2001 14:08:05 -0700 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <20010401210623.A2325@pino.selwerd.nl> References: <5F0FF742F1D@kserver.org> <LNBBLJKPBEHFEDALKOLCIEIAJJAA.tim.one@home.com> <738F32F4A49@kserver.org> <20010401210623.A2325@pino.selwerd.nl> Message-ID: <3B5AFA51A7A@kserver.org> On Sun, 1 Apr 2001 21:06:23 +0200, Remco Gerlich <scarblac@pino.selwerd.nl> wrote about Re: [Tutor] Still confused about Python references/objects: :On Sat, Mar 31, 2001 at 04:20:12PM -0800, Sheila King wrote: :> On Sat, 31 Mar 2001 14:52:00 -0500, "Tim Peters" <tim.one@home.com> wrote :> about RE: [Tutor] Still confused about Python references/objects: :> :> :"by reference" isn't really a useful concept in Python. People bring that :> :with them from other languages, and get into all sorts of trouble trying to :> :force it to fit. :> :> You're telling me! (I bring background experience from a few different :> languages: Pascal, Fortran, VB, C++, and they ALL behaved that way! It is so :> difficult to get used to this new way of thinking.) : :This point may be hard to get at first, but luckily it's one of the few :things! : :I think once you understand: :1 Everything is by reference No, your point number one is not really useful (at least for me). I had read remarks like that already in the comp.lang.python newsgroup and here on the tutor mailing list. And that's why I was thinking that if I wrote a function like: def swap( a, b): <stuff> That the function swap could affect the objects that were passed to a and b. But, unless a and b are mutable objects, it can't. So saying "everything is by reference" is actually confusing and misleading. I like what Tim suggested, saying that it is "by object". Anyhow, now I get it. It just took a few times to get it through my thick head. That is the usual way with me. My thesis advisor has basically said the same thing about me. :2 Some objects can be changed, some can't - but no changes are made by : simple assignment to a name. :3 Namespaces - everything is just a name for some object, even functions, : modules, the results of import, etc - is this a special case of 1 and 2? :4 A variable is global if it's not assigned to here or if there is a : "global x" statement nearby - otherwise it's local*. :5 Things like "def" happen at runtime (almost everything does*) :6 Calling a method on some instance passes "self" as 1st argument Thanks for this list. I will go over it again and again, until it all makes sense to me. :Then you understand all of the key points of the language Python (what did I :forget?). I don't think I missed much. This list is enormously smaller than :for other languages. : :Unfortunately the * things become a tiny bit more complex in versions in the :near future. Er, can't say I'm looking forward to that. I hope it doesn't create compatibility issues. My web host is still running 1.5.1, and I daresay a lot of people are still using 1.5.2, and not likely to upgrade any time soon. ...<snippage>... :> So, now I think I know what I'm doing, and I try this: :> :> >>> def swap(two_tuple): :> x,y = two_tuple :> return y, x :> :> >>> a = 2 :> >>> b = 3 :> >>> print a, " ", b :> 2 3 :> >>> a,b = swap((a,b)) :> >>> print a, " ", b :> 3 2 :> >>> : :Yes. : :Simpler would be : :a, b = b, a I already knew about that and posted it in my original question. This was a study in passing parameters, so I picked an example I knew how to do without a function that was familiar to me. I thought that was a good choice. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From scarblac@pino.selwerd.nl Sun Apr 1 22:19:26 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 1 Apr 2001 23:19:26 +0200 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <3B5AFA51A7A@kserver.org>; from sheila@thinkspot.net on Sun, Apr 01, 2001 at 02:08:05PM -0700 References: <5F0FF742F1D@kserver.org> <LNBBLJKPBEHFEDALKOLCIEIAJJAA.tim.one@home.com> <738F32F4A49@kserver.org> <20010401210623.A2325@pino.selwerd.nl> <3B5AFA51A7A@kserver.org> Message-ID: <20010401231926.A2520@pino.selwerd.nl> On Sun, Apr 01, 2001 at 02:08:05PM -0700, Sheila King wrote: > On Sun, 1 Apr 2001 21:06:23 +0200, Remco Gerlich <scarblac@pino.selwerd.nl> > wrote about Re: [Tutor] Still confused about Python references/objects: > > :On Sat, Mar 31, 2001 at 04:20:12PM -0800, Sheila King wrote: > :> On Sat, 31 Mar 2001 14:52:00 -0500, "Tim Peters" <tim.one@home.com> wrote > :> about RE: [Tutor] Still confused about Python references/objects: > :> > :> :"by reference" isn't really a useful concept in Python. People bring that > :> :with them from other languages, and get into all sorts of trouble trying to > :> :force it to fit. > :> > :> You're telling me! (I bring background experience from a few different > :> languages: Pascal, Fortran, VB, C++, and they ALL behaved that way! It is so > :> difficult to get used to this new way of thinking.) > : > :This point may be hard to get at first, but luckily it's one of the few > :things! > : > :I think once you understand: > :1 Everything is by reference > > No, your point number one is not really useful (at least for me). I had read > remarks like that already in the comp.lang.python newsgroup and here on the > tutor mailing list. And that's why I was thinking that if I wrote a function > like: > > def swap( a, b): > <stuff> > > That the function swap could affect the objects that were passed to a and b. Ah yes, I forgot the meaning of 'by reference' in other languages. I meant 1) *Everything* is by reference. Including the assignments you did in the function, so they didn't have an effect... > But, unless a and b are mutable objects, it can't. So saying "everything is by > reference" is actually confusing and misleading. I like what Tim suggested, > saying that it is "by object". Anyhow, now I get it. It just took a few times > to get it through my thick head. That is the usual way with me. My thesis > advisor has basically said the same thing about me. > > :2 Some objects can be changed, some can't - but no changes are made by > : simple assignment to a name. > :3 Namespaces - everything is just a name for some object, even functions, > : modules, the results of import, etc - is this a special case of 1 and 2? > :4 A variable is global if it's not assigned to here or if there is a > : "global x" statement nearby - otherwise it's local*. > :5 Things like "def" happen at runtime (almost everything does*) > :6 Calling a method on some instance passes "self" as 1st argument > > Thanks for this list. I will go over it again and again, until it all makes > sense to me. Wait until others give their corrections, I tend to make mistakes... > :Then you understand all of the key points of the language Python (what did I > :forget?). I don't think I missed much. This list is enormously smaller than > :for other languages. > : > :Unfortunately the * things become a tiny bit more complex in versions in the > :near future. > > Er, can't say I'm looking forward to that. I hope it doesn't create > compatibility issues. My web host is still running 1.5.1, and I daresay a lot > of people are still using 1.5.2, and not likely to upgrade any time soon. Not that much is changing. "from __future__ import nested_scopes" acts at compile time, but you don't have to use it, ignore. The nested scopes themselves will become mandatory in 2.2 or so. Then the simple rule becomes something like: x) If you use a name that isn't assigned to in this scope, it is looked up (recursively) in the scope above this one. Which will be *very* cool for the simplified lambdas alone. > :a, b = b, a > > I already knew about that and posted it in my original question. This was a > study in passing parameters, so I picked an example I knew how to do without a > function that was familiar to me. I thought that was a good choice. I know now, but I had been away for a few days and was reading mail new-to-old... -- Remco Gerlich From tim.one@home.com Mon Apr 2 00:51:18 2001 From: tim.one@home.com (Tim Peters) Date: Sun, 1 Apr 2001 19:51:18 -0400 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <2A5D2F922F0@kserver.org> Message-ID: <LNBBLJKPBEHFEDALKOLCIELCJJAA.tim.one@home.com> [Sheila King] > Well, that's why I was wondering about whether Python is really a > good first language. It seems to me, it would be much more difficult > to get used to strongly typed languages and references/values/pointers > after using Python first. Dunno. I'd say this depends on what you consider to be the *goals* of a first language. Python, like ABC before it, thinks newcomers should be able to do "interesting" things their first day. If newbies aren't to spend their entire time wrestling with the tool instead of with the problems they set out to solve, their first language should hide as much artificial complexity as possible. Things like worrying about how to allocate memory, or the differences between objects and pointers to objects and pointers to pointers to etc, are artifacts of using low-level ("close to the hardware") languages, not inherent characteristics of interesting problem domains. It so happens I learned assembly language first, as close to the hardware as things get. And I recommend that everyone learn assembler first too -- provided they intend to make a career of writing compilers, which I intended at the time <wink>. For everyone else, the higher level the better, lest they give up in frustration the first week. It's quite possible they never need to learn another language, in which case Python is a fine place to stop as well as to start. If they need to learn C or C++ or Java or ... too, the maze of new rules and requirements will drive them mad, *until* they learn something about how computers work internally. Without learning the latter, the *purpose* of all those low-level restrictions will never make good sense to them. They may learn them by rote, but they'll never achieve true skill before understanding the machine-level purposes behind having 16-bit ints *and* 32-bit ints *and* confusing pointers with arrays *and* confusing characters with little integers *and* etc etc. That stuff is all driven by what's easiest for the *hardware* to do. In Python's view, you simply don't need to worry about all that at the start (or, if you're lucky, ever!). BTW, Python is more strongly typed than C or C++: Python *never* lets you get away with a type-unsafe operation. I expect you have in mind that Python isn't *statically* typed (Python delays type checks until runtime). Static typing can also be hard to get used to, in large part because it's yet another little sub-language with its own arcane rules to trip over. If the purpose of a first language is to teach people that programming languages are a veritable minefield of inconsistent little gotchas, ya, Python is a rotten first language <wink>. let-'em-taste-success-today-and-tomorrow-is-time-enough-for-failure-ly y'rs - tim From syrinx@simplecom.net Mon Apr 2 01:38:12 2001 From: syrinx@simplecom.net (Scott) Date: Sun, 01 Apr 2001 19:38:12 -0500 Subject: [Tutor] upgrading to 2.0 on Redhat Message-ID: <j3ifct47u2k43581grjgj5b0kbnk83hoh7@4ax.com> This is only tangentially on topic, I hope it's OK to ask. I've got Redhat 7.0, which includes python-1.5.2-27. I downloaded and installed BeOpen-Python-2.0-1. Is it possible/advisable to get rid of the old version with '--nodeps' or something. Or will this break the dependencies? It seems to be a waste of disk space, as well as a bit cluttered and confusing to keep both versions, but I don't want to break my system. Thanks. Scott Tullos From kstoner@netins.net Mon Apr 2 02:58:49 2001 From: kstoner@netins.net (Katharine Stoner) Date: Sun, 1 Apr 2001 20:58:49 -0500 Subject: [Tutor] arrays Message-ID: <000801c0bb18$78287360$e152b1cf@oemcomputer> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C0BAEE.8C9A9E60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, Can you put an array inside of another array? -Cameron ------=_NextPart_000_0005_01C0BAEE.8C9A9E60 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Can you put an array inside of another=20 array?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-Cameron</FONT></DIV></BODY></HTML> ------=_NextPart_000_0005_01C0BAEE.8C9A9E60-- From tescoil@irtc.net Mon Apr 2 02:37:20 2001 From: tescoil@irtc.net (Tesla Coil) Date: Sun, 01 Apr 2001 21:37:20 -0400 Subject: [Tutor] upgrading to 2.0 on Redhat References: <j3ifct47u2k43581grjgj5b0kbnk83hoh7@4ax.com> Message-ID: <3AC7D7D0.9D902CB5@irtc.net> On 1 Apr 2001, Scott wrote: > This is only tangentially on topic, I hope it's > OK to ask. I hope so too--it's a good question. > I've got Redhat 7.0, which includes python-1.5.2-27. > I downloaded and installed BeOpen-Python-2.0-1. > Is it possible/advisable to get rid of the old > version with '--nodeps' or something. Or will > this break the dependencies? Possible that installing 2.0 breaks dependencies itself, whether you uninstall 1.5.2 or not. The BeOpen-Python-2.0-1.i386.rpm will put Python 2.0 answering calls for python even as 1.5.2 remains on board. Do an 'rpm -q --whatrequires python' and everything listed probably expects 1.5.2... From Aaron.Mathews@Gentner.COM Sun Apr 1 21:08:22 2001 From: Aaron.Mathews@Gentner.COM (Aaron Mathews) Date: Sun, 1 Apr 2001 14:08:22 -0600 Subject: [Tutor] Is There a Bugtracking tool written in Python In-Reply-To: <Pine.LNX.4.31.0104011207340.13814-100000@emperor.deirdre.org>; from deirdre@deirdre.net on Sun, Apr 01, 2001 at 12:08:06PM -0700 References: <20010401040415.G4184@gandalf> <Pine.LNX.4.31.0104011207340.13814-100000@emperor.deirdre.org> Message-ID: <20010401140822.I4184@gandalf> On Sun, Apr 01, 2001 at 12:08:06PM -0700, Deirdre Saoirse wrote: > On Sun, 1 Apr 2001, Aaron Mathews wrote: > > > > Actually, that's what HellDesk was, but it was never released. > > > > Oh really? Whose project was that? A released python bug/helpdesk > > tracker system would make my consulting life a *lot* easier :) > > Mine, among others. It was mostly done when several of us left Linuxcare, > but was dropped immediately thereafter. Too bad it didn't make it out of Linuxcare alive. Looks like I'll have to build a new toolkit myself ;) -- Aaron Mathews work: Aaron.Mathews@Gentner.COM - http://gentner.com/ play: Aaronm@Hobbiton.ORG - http://pukka.dyndns.org/ From kalle@gnupung.net Mon Apr 2 04:17:05 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Mon, 2 Apr 2001 05:17:05 +0200 Subject: [Tutor] arrays In-Reply-To: <000801c0bb18$78287360$e152b1cf@oemcomputer>; from kstoner@netins.net on Sun, Apr 01, 2001 at 08:58:49PM -0500 References: <000801c0bb18$78287360$e152b1cf@oemcomputer> Message-ID: <20010402051705.A20273@father> Sez Katharine Stoner: > Hi all, > > Can you put an array inside of another array? Do you mean Python lists (builtin), NumPy Arrays or something else? If you mean lists, the answer is yes: >>> l = ["a", ["nested"], "list"] >>> l.append(["another", ["nested", "list"]]) >>> l ['a', ['nested'], 'list', ['another', ['nested', 'list']]] >>> Otherwise, the answer is "Maybe, I don't know". Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From DOUGS@oceanic.com Mon Apr 2 04:26:09 2001 From: DOUGS@oceanic.com (Doug Stanfield) Date: Sun, 1 Apr 2001 17:26:09 -1000 Subject: [Tutor] arrays Message-ID: <8457258D741DD411BD3D0050DA62365907A721@huina.oceanic.com> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C0BB24.A943BF20 Content-Type: text/plain; charset="iso-8859-1" I don't know, what's an array? ;-) Seriously, 'array' as such isn't a basic Python data type, so you may need to better define what you're trying to do. I'll take a stab at being psychot^h^hic and guessing what you mean. I'll assume you're trying to use lists and play around in the interpreter: [dougs@lawehana dougs]$ python Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> one = ['this','and','that'] >>> two = ['the','other'] >>> spam = [one,two] >>> spam [['this', 'and', 'that'], ['the', 'other']] >>> eggs = [spam[0],'and',spam[1]] >>> eggs [['this', 'and', 'that'], 'and', ['the', 'other']] >>> eggs[0][1] == eggs[1] >>> HTH -Doug- -----Original Message----- From: Katharine Stoner [mailto:kstoner@netins.net] Sent: Sunday, April 01, 2001 3:59 PM To: python tutor Subject: [Tutor] arrays Hi all, Can you put an array inside of another array? -Cameron ------_=_NextPart_001_01C0BB24.A943BF20 Content-Type: text/html; charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META content="MSHTML 5.50.4522.1800" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2>I don't know, what's an array? ;-)</FONT></SPAN></DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2>Seriously, 'array' as such isn't a basic Python data type, so you may need to better define what you're trying to do. I'll take a stab at being psychot^h^hic and guessing what you mean.</FONT></SPAN></DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2>I'll assume you're trying to use lists and play around in the interpreter:</FONT></SPAN></DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2>[dougs@lawehana dougs]$ python<BR>Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2<BR>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam<BR>>>> one = ['this','and','that']<BR>>>> two = ['the','other']<BR>>>> spam = [one,two]<BR>>>> spam<BR>[['this', 'and', 'that'], ['the', 'other']]<BR>>>> eggs = [spam[0],'and',spam[1]]<BR>>>> eggs<BR>[['this', 'and', 'that'], 'and', ['the', 'other']]<BR>>>> eggs[0][1] == eggs[1]</FONT></SPAN></DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2>>>> </FONT></SPAN></DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2>HTH</FONT></SPAN></DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=314472603-02042001><FONT face=Arial color=#0000ff size=2>-Doug-</FONT></SPAN></DIV> <BLOCKQUOTE dir=ltr style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"> <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> Katharine Stoner [mailto:kstoner@netins.net]<BR><B>Sent:</B> Sunday, April 01, 2001 3:59 PM<BR><B>To:</B> python tutor<BR><B>Subject:</B> [Tutor] arrays<BR><BR></FONT></DIV> <DIV><FONT face=Arial size=2>Hi all,</FONT></DIV> <DIV> </DIV> <DIV><FONT face=Arial size=2>Can you put an array inside of another array?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=Arial size=2>-Cameron</FONT></DIV></BLOCKQUOTE></BODY></HTML> ------_=_NextPart_001_01C0BB24.A943BF20-- From Aaron.Mathews@Gentner.COM Sun Apr 1 23:06:21 2001 From: Aaron.Mathews@Gentner.COM (Aaron Mathews) Date: Sun, 1 Apr 2001 16:06:21 -0600 Subject: [Tutor] Is There a Bugtracking tool written in Python In-Reply-To: <Pine.LNX.4.31.0104012007410.18110-100000@emperor.deirdre.org>; from deirdre@deirdre.net on Sun, Apr 01, 2001 at 08:08:35PM -0700 References: <20010401140822.I4184@gandalf> <Pine.LNX.4.31.0104012007410.18110-100000@emperor.deirdre.org> Message-ID: <20010401160621.J4184@gandalf> On Sun, Apr 01, 2001 at 08:08:35PM -0700, Deirdre Saoirse wrote: > > That's, in part, because I almost didn't make it out alive -- a very bad > kidney infection that I contracted when I was fired nearly killed me. > Bleeding from the kidneys is NOT good. > > Thus, I just haven't worked on it. Sorry to hear about your infection. It seems that bad things come in pairs these days :( I'm sure you could find a nice home for the code, helldesk.sourceforge.net anyone? ;-) -- Aaron Mathews work: Aaron.Mathews@Gentner.COM - http://gentner.com/ play: Aaronm@Hobbiton.ORG - http://pukka.dyndns.org/ From kstoner@netins.net Mon Apr 2 13:54:12 2001 From: kstoner@netins.net (Katharine Stoner) Date: Mon, 2 Apr 2001 07:54:12 -0500 Subject: [Tutor] Re arrays Message-ID: <001801c0bb74$04b5d600$dc52b1cf@oemcomputer> This is a multi-part message in MIME format. ------=_NextPart_000_0015_01C0BB4A.1B48BE20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable What I mean is can you take an array full of some thing and put it into = another section of an array. 1st array J1 J2 J3 J4 J5=20 2nd array H1 H2 H3 H4 H5=20 Can you put the 2nd array in the 1st array's J1. I don't mean lists = either. Perhaps you would have to write a function maybe to do this? -Cameron ------=_NextPart_000_0015_01C0BB4A.1B48BE20 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>What I mean is can you take an array = full of some=20 thing and put it into another section of an array.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>1st array J1 J2 J3 J4 J5 </FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>2nd array H1 H2 H3 H4 H5 </FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Can you put the 2nd array in the 1st = array's=20 J1. I don't mean lists either. Perhaps you would have to = write a=20 function maybe to do this?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-Cameron</FONT></DIV></BODY></HTML> ------=_NextPart_000_0015_01C0BB4A.1B48BE20-- From Rob Andrews" <rob@jam.rr.com Mon Apr 2 14:59:27 2001 From: Rob Andrews" <rob@jam.rr.com (Rob Andrews) Date: Mon, 2 Apr 2001 08:59:27 -0500 Subject: [Tutor] posting scripts References: <Pine.LNX.4.21.0103302133260.18723-100000@hkn.eecs.berkeley.edu> Message-ID: <000901c0bb7d$22279760$9600a8c0@Planhouse5> As the maintainer of Useless Python, I'd like to say *Thanks* to Danny for mentioning Useless, and re-invite anyone interested to fire off code to me at rob@jam.rr.com. (And it doesn't really have to be useless!) Rob rob@jam.rr.com ----- Original Message ----- From: "Daniel Yoo" <dyoo@hkn.eecs.berkeley.edu> To: "Scott" <syrinx@simplecom.net> Cc: <tutor@python.org> Sent: Saturday, March 31, 2001 12:41 AM Subject: Re: [Tutor] posting scripts > On Fri, 30 Mar 2001, Scott wrote: > > > If I had a script that I wanted to get feedback on, would it be okay > > to post it here? How long of one could I get away with? I just don't > > want to annoy anyone x days in the future... > > It's perfectly ok to post it up, as long as it isn't too long. *grin* > Feel free to post it up! > > A "long" script would probably be more that 2 pages, just because many > people like to look at code that fits on one screen. For long scripts, > you can submit your script to Useless Python: > > http://www.lowerstandard.com/python/pythonsource.html > > and point people to the url where your script is located. Useless Python > is set up so that you can share your scripts with others, so it's a good > resource to use. > > In any event, don't worry about "annoying" us; we're here to help and > learn. Good luck! > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor From alan.gauld@bt.com Mon Apr 2 15:22:43 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 2 Apr 2001 15:22:43 +0100 Subject: [Tutor] Still confused about Python references/objects Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D694@mbtlipnt02.btlabs.bt.co.uk> > I'd say this depends on what you consider to be > the *goals* of a first language. I agree. If you want to teach the basic concepts of programming: sequences, loops, branching, variables etc. then static typing just gets in the way. Python is great for that. If you want to teach how computers work the Python is not so good, C is better (assembler better still but just toooo painful :-) > It so happens I learned assembly language first, as close to > the hardware as things get. And I recommend that everyone learn > assembler first too -- provided they intend to make a career > of writing compilers, Or are actually interested inbuilding hardware - interface cards etc. Thats why I learned assembler first I actually wanted to know what was happening at bit level so that I could build interfaces to it. > It's quite possible they never need to learn another > language, Possible but unlikely. In my experience most real world projects use multiple languages. (I think my maximum was 12!) The average for most projects has been about 5 or 6 languages (if you include SQL and HTML as languages :-) > or C++ or Java or ... too, the maze of new rules and > requirements will drive them mad, *until* they learn > something about how computers work internally. And this raises an interesting point. Recently my company took on some MSc students who got their MSc as a 1 year conversion course from Arts subjects (rather than by specialising in an advance CS/Engineering topic) While they can all do the basics and write programs (in Java) to a spec they are without exception ignorant of how the computer actiually works. This in turn limits them in all sorts of ways (performance tuning is a complete mystery for example). We are now trying (so far in vain) to find some kind of training course which covers computer architectures etc. One of the nice things about Python is that while you can start at a purely abstract level you can also delve into the guts fairly easily through the wrapper modules available. Alan G/ From alan.gauld@bt.com Mon Apr 2 15:31:01 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 2 Apr 2001 15:31:01 +0100 Subject: [Tutor] arrays Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D695@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0BB81.8A6FC550 Content-type: text/plain; charset="iso-8859-1" Can you put an array inside of another array? Usually, it depends on the language. Since Python doesn't have arrays you need to use lists and yes you can put a list inside amnother list: >>> L1 = [1,2,3] >>> L2 = ['a','b','c'] >>> L3 = [L1,L2] # create nested lists >>> print L3 [ [1, 2, 3], ['a', 'b', 'c'] ] >>> print L3[1][1] # how to access members b >>> L1.append(L2) # another way of nesting lists >>> print L1 [1, 2, 3, ['a', 'b', 'c'] ] HTH, Alan G ------_=_NextPart_001_01C0BB81.8A6FC550 Content-type: text/html; charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META content="MSHTML 5.00.3013.2600" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"> <DIV><FONT size=2><FONT face=Arial>Can you put an array inside of another array?<FONT color=#0000ff><SPAN class=730512614-02042001> </SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001></SPAN></FONT></FONT></FONT> </DIV></BLOCKQUOTE> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>Usually, it depends on the language.</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>Since Python doesn't have arrays you need to use lists and</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>yes you can put a list inside amnother list:</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001></SPAN></FONT></FONT></FONT> </DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>>>> L1 = [1,2,3]</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>>>> L2 = ['a','b','c']</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>>>> L3 = [L1,L2] # create nested lists</SPAN></FONT></FONT></FONT></DIV><SPAN class=730512614-02042001> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=730512614-02042001>>>> print L3</SPAN></FONT></DIV> <DIV><FONT size=2><FONT color=#0000ff><FONT face=Arial><SPAN class=730512614-02042001>[ [1, 2, 3], ['a', 'b', 'c'] ]</SPAN></FONT></FONT></FONT></DIV></SPAN> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>>>> print L3[1][1] # how to access members</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>b</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>>>> L1.append(L2) # another way of nesting lists</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>>>> print L1</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>[1, 2, 3, ['a', 'b', 'c'] ]</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001></SPAN></FONT></FONT></FONT> </DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>HTH,</SPAN></FONT></FONT></FONT></DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001></SPAN></FONT></FONT></FONT> </DIV> <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff><SPAN class=730512614-02042001>Alan G</SPAN></FONT></FONT></FONT></DIV> <BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"> <DIV> </DIV></BLOCKQUOTE></BODY></HTML> ------_=_NextPart_001_01C0BB81.8A6FC550-- From bdupire@seatech.fau.edu Mon Apr 2 16:58:48 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Mon, 02 Apr 2001 11:58:48 -0400 Subject: [Tutor] arrays References: <5104D4DBC598D211B5FE0000F8FE7EB20751D695@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <3AC8A1B8.2738BE5A@seatech.fau.edu> Maybe Katharine means she wants to use the array module ??? From ium@micromuse.com Mon Apr 2 17:55:49 2001 From: ium@micromuse.com (ibraheem umaru-mohammed) Date: Mon, 2 Apr 2001 17:55:49 +0100 Subject: [Tutor] Re arrays In-Reply-To: <001801c0bb74$04b5d600$dc52b1cf@oemcomputer>; from kstoner@netins.net on Mon, Apr 02, 2001 at 07:54:12AM -0500 References: <001801c0bb74$04b5d600$dc52b1cf@oemcomputer> Message-ID: <20010402175549.A3747@ignoramus> [Katharine Stoner wrote...] > What I mean is can you take an array full of some thing and put it into a= nother section of an array. >=20 > 1st array J1 J2 J3 J4 J5=20 >=20 > 2nd array H1 H2 H3 H4 H5=20 >=20 > Can you put the 2nd array in the 1st array's J1. I don't mean lists eith= er. Perhaps you would have to write=20 > a function maybe to do this? >=20 If that is the case, then "no", I don't think you can do this. An array is = used to hold items of the same type. -- Kindest regards, --ibs. -------------------------- Ibraheem Umaru-Mohammed ----------------------= ----- -- Email:ium@micromuse.com -- -- Micromuse Ltd, Disraeli House, 90 Putney Bridge Road, London SW18 1DA -- -- http://www.micromuse.com -- =09 --=20 From Rob Andrews" <rob@jam.rr.com Mon Apr 2 18:33:21 2001 From: Rob Andrews" <rob@jam.rr.com (Rob Andrews) Date: Mon, 2 Apr 2001 12:33:21 -0500 Subject: [Tutor] Is Parrot an April Fool's joke? Message-ID: <001101c0bb9b$042c21e0$9600a8c0@Planhouse5> According to several articles found on the web (all dated the 1st of April) in places like perl.com, python.org, and oreilly.com, Parrot is a language in development intended to merge Python and Perl. Does anyone know what the story is? http://www.perl.com/pub/2001/04/01/parrot.htm Rob From jthing@frisurf.no Mon Apr 2 18:58:26 2001 From: jthing@frisurf.no (John Thingstad) Date: Mon, 02 Apr 2001 19:58:26 +0200 Subject: [Tutor] distutils with Borland compiler Message-ID: <200104021803.UAA28513@mail44.fg.online.no> I am using a Win98 machine for running Python. It has a Borland C++ 5.1 compiler but no Microsoft compiler. How can I setup the distutils package to use this instead? I have looked at the distutils source and see that there is even a Borland compiler module , but try as I may I can't find and informations of how to setup default compiler environment for a system. From kstoner@netins.net Mon Apr 2 21:26:45 2001 From: kstoner@netins.net (Katharine Stoner) Date: Mon, 2 Apr 2001 15:26:45 -0500 Subject: [Tutor] i'm a guy Message-ID: <001101c0bbb3$3d5e3c60$3e52b1cf@oemcomputer> This is a multi-part message in MIME format. ------=_NextPart_000_000E_01C0BB89.53F12480 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Dear python people, I'm a guy named Cameron. Katharine is my mom. I'm just using her = account. -Cameron ------=_NextPart_000_000E_01C0BB89.53F12480 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Dear python people,</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>I'm a guy named Cameron. = Katharine is my=20 mom. I'm just using her account.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-Cameron</FONT></DIV></BODY></HTML> ------=_NextPart_000_000E_01C0BB89.53F12480-- From deirdre@deirdre.net Mon Apr 2 21:36:57 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 2 Apr 2001 13:36:57 -0700 (PDT) Subject: [Tutor] i'm a guy In-Reply-To: <001101c0bbb3$3d5e3c60$3e52b1cf@oemcomputer> Message-ID: <Pine.LNX.4.31.0104021336410.27287-100000@emperor.deirdre.org> On Mon, 2 Apr 2001, Katharine Stoner wrote: > I'm a guy named Cameron. Katharine is my mom. I'm just using her > account. Works for us. Just remind us from time to time if we forget. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From pdiaz88@terra.es Mon Apr 2 21:40:49 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Mon, 2 Apr 2001 22:40:49 +0200 Subject: [Tutor] Is Parrot an April Fool's joke? In-Reply-To: <001101c0bb9b$042c21e0$9600a8c0@Planhouse5> References: <001101c0bb9b$042c21e0$9600a8c0@Planhouse5> Message-ID: <01040222404900.04659@tajo> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Pretty sure is a joke. Was on the april fool's series in slashdot Cheers Pedro On Monday 02 April 2001 19:33, Rob Andrews wrote: > According to several articles found on the web (all dated the 1st of April) > in places like perl.com, python.org, and oreilly.com, Parrot is a language > in development intended to merge Python and Perl. Does anyone know what the > story is? > > http://www.perl.com/pub/2001/04/01/parrot.htm > > Rob > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6yOPZnu53feEYxlERAl8jAJ93Ys/SVgfjl1Eu7LaX/GBKAo/ZfACZAYob 6e0EWaV80pMiT4qvEgWucTI= =R6bD -----END PGP SIGNATURE----- From bdupire@seatech.fau.edu Mon Apr 2 21:52:30 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Mon, 02 Apr 2001 16:52:30 -0400 Subject: [Tutor] i'm a guy References: <001101c0bbb3$3d5e3c60$3e52b1cf@oemcomputer> Message-ID: <3AC8E68E.60D46CEE@seatech.fau.edu> Got too many chat propositions ??? :))))))))))) (Just kidding!) ooops! yes, I wrote something like 'she' in my post.... sorry! Just to go back to the issue, the 'Array' module defines a new object type which can efficiently represent an array of basic values: characters, integers, floating point numbers. Arrays are sequence types and behave very much like lists, except that the type of objects stored in them is constrained. You can concatenate 2 arrays like this... >>> import array >>> a= array.array('I', [11, 32, 35, 1, 5]) >>> b= array.array('I', [8, 11, 12]) >>> a[0:0]=b >>> print a array('I', [8L, 11L, 12L, 11L, 32L, 35L, 1L, 5L]) >>> c=a.tolist() >>> print c [8L, 11L, 12L, 11L, 32L, 35L, 1L, 5L] The tolist() method converts it to a list.... it's just an optimization. Look at: http://www.python.org/doc/current/lib/module-array.html Katharine Stoner wrote: > Dear python people, I'm a guy named Cameron. Katharine is my mom. > I'm just using her account. -Cameron -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From Rob Andrews" <rob@jam.rr.com Mon Apr 2 22:03:28 2001 From: Rob Andrews" <rob@jam.rr.com (Rob Andrews) Date: Mon, 2 Apr 2001 16:03:28 -0500 Subject: [Tutor] Is Parrot an April Fool's joke? References: <001101c0bb9b$042c21e0$9600a8c0@Planhouse5> <01040222404900.04659@tajo> Message-ID: <004701c0bbb8$5e33bf00$9600a8c0@Planhouse5> I've assumed it's just a prank, but the idea is so freakish that some of the people here in the office claim to like the prospect. Aside from the fact that the articles were all dated Apr 1, the code snippets they provided were just implausible. (Using closing curly braces to end nested blocks?! Hardly.) Rob > Pretty sure is a joke. Was on the april fool's series in slashdot > > Cheers > Pedro > > On Monday 02 April 2001 19:33, Rob Andrews wrote: > > According to several articles found on the web (all dated the 1st of April) > > in places like perl.com, python.org, and oreilly.com, Parrot is a language > > in development intended to merge Python and Perl. Does anyone know what the > > story is? > > > > http://www.perl.com/pub/2001/04/01/parrot.htm > > > > Rob > > > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.4 (GNU/Linux) > Comment: For info see http://www.gnupg.org > > iD8DBQE6yOPZnu53feEYxlERAl8jAJ93Ys/SVgfjl1Eu7LaX/GBKAo/ZfACZAYob > 6e0EWaV80pMiT4qvEgWucTI= > =R6bD > -----END PGP SIGNATURE----- > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor From dyoo@hkn.eecs.berkeley.edu Mon Apr 2 22:03:11 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 2 Apr 2001 14:03:11 -0700 (PDT) Subject: [Tutor] Is Parrot an April Fool's joke? In-Reply-To: <001101c0bb9b$042c21e0$9600a8c0@Planhouse5> Message-ID: <Pine.LNX.4.21.0104021358040.31801-100000@hkn.eecs.berkeley.edu> On Mon, 2 Apr 2001, Rob Andrews wrote: > According to several articles found on the web (all dated the 1st of April) > in places like perl.com, python.org, and oreilly.com, Parrot is a language > in development intended to merge Python and Perl. Does anyone know what the > story is? > > http://www.perl.com/pub/2001/04/01/parrot.htm It's a joke. Read the example source code that GvR and LR show: it's hilarious because it's so clunky and shows precisely what might happen in a committee-driven language. ### GvR: Obviously there aren't any full-size Parrot programs available at the moment, just pieces of example code. This is an example written by Tim Peters: # copy stdin to stdout, except for lines starting with # while left_angle_right_angle: if dollar_underscore[0] =eq= "#": continue_next; } print dollar_underscore; } LW: I think this shows exactly what we were trying to achieve: it's immediately obvious to both Perl and Python programmers what that does. We've got a great compromise between Perl's brace-structured blocks and Python's white-space blocks; we've merged the names of language keywords in an elegant way; we've kept the idea of Perl's shortcut variables, but we've combined that with Python's readability. GvR: Of course, this is just one way you could write that program. There's more than one way to do it, right, Larry? LW: Sure. I'd probably write the program something like this: while(@line = Sys::Stdin->readline()): continue_next if $line[0] =eq= "#": print @line; } ### From dyoo@hkn.eecs.berkeley.edu Mon Apr 2 22:11:02 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 2 Apr 2001 14:11:02 -0700 (PDT) Subject: [Tutor] Re arrays In-Reply-To: <001801c0bb74$04b5d600$dc52b1cf@oemcomputer> Message-ID: <Pine.LNX.4.21.0104021405070.31801-100000@hkn.eecs.berkeley.edu> On Mon, 2 Apr 2001, Katharine Stoner wrote: > What I mean is can you take an array full of some thing and put it > into another section of an array. > > 1st array J1 J2 J3 J4 J5 > > 2nd array H1 H2 H3 H4 H5 > > Can you put the 2nd array in the 1st array's J1. I don't mean lists > either. Perhaps you would have to write a function maybe to do this? Can you show us an example of how you'd use this? (Just to make sure I'm understanding what's happening.) There's a way to "squeeze" the second array into the first: ### >>> x = ['j1', 'j2', 'j3', 'j4', 'j5'] >>> y = ['h1', 'h2', 'h3', 'h4', 'h5'] >>> x[0:0] = y >>> x ['h1', 'h2', 'h3', 'h4', 'h5', 'j1', 'j2', 'j3', 'j4', 'j5'] ### but I'm pretty sure that this isn't what you're looking for. There are so many ways to "put" something into another, so we might be maddeningly off the mark for a while. Hope you find what you're looking for! From dyoo@hkn.eecs.berkeley.edu Mon Apr 2 22:17:17 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 2 Apr 2001 14:17:17 -0700 (PDT) Subject: [Tutor] Help passing parameters to cancel callback (after_cancel) In-Reply-To: <26630645.5B2F134B.00978E7F@netscape.net> Message-ID: <Pine.LNX.4.21.0104021412530.31801-100000@hkn.eecs.berkeley.edu> On Sun, 1 Apr 2001 dkstewaP@netscape.net wrote: > I am very confused as to how I pass the id parameter from the call to > after() to the after_cancel() function. I think my problems are > related to the scope of variables (namespaces in python) and how to > refer to the variable in the various namespaces. The combination of > using a class to define my functions and having to pass additional > namespace info to Tkinter has really got me beat. One way that you can do this is to store the id into your "self". def poll(self): count = time() self.label2.configure(text=str(count)) nn = self.master.after(1000, self.poll) self.nn = nn The reason this is useful is because the after_cancel() method has access to its "self", so it can lookup "self.nn" too: def stop(self): self.master.after_cancel(self.nn) Use your instance to store the kind of state that needs to be passed between your functions. If you have more questions, feel free to ask us. Good luck to you! From dyoo@hkn.eecs.berkeley.edu Mon Apr 2 22:21:43 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 2 Apr 2001 14:21:43 -0700 (PDT) Subject: [Tutor] upgrading to 2.0 on Redhat In-Reply-To: <j3ifct47u2k43581grjgj5b0kbnk83hoh7@4ax.com> Message-ID: <Pine.LNX.4.21.0104021418500.31801-100000@hkn.eecs.berkeley.edu> On Sun, 1 Apr 2001, Scott wrote: > This is only tangentially on topic, I hope it's OK to ask. > > I've got Redhat 7.0, which includes python-1.5.2-27. I downloaded and > installed BeOpen-Python-2.0-1. Is it possible/advisable to get rid of > the old version with '--nodeps' or something. Or will this break the > dependencies? It seems to be a waste of disk space, as well as a bit > cluttered and confusing to keep both versions, but I don't want to > break my system. Thanks. You might want to keep it; I know that Red Hat depends on Python for a lot of its system scripting; it will probably break your dependencies. Red Hat added a bunch of extensions that only work with Python 1.52, so I'm not sure what the upgrade path is like. For me, I've installed Python 2.0 in /usr/local/python2.0. Also, I've made it so PATH looks at /usr/local/bin first; for the most part, this should be safer, since it leaves the system alone, but allows you to work with Python 2.0. Good luck to you. From dyoo@hkn.eecs.berkeley.edu Mon Apr 2 22:24:32 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 2 Apr 2001 14:24:32 -0700 (PDT) Subject: [Tutor] Is Parrot an April Fool's joke? In-Reply-To: <Pine.LNX.4.21.0104021358040.31801-100000@hkn.eecs.berkeley.edu> Message-ID: <Pine.LNX.4.21.0104021423470.32739-100000@hkn.eecs.berkeley.edu> On Mon, 2 Apr 2001, Daniel Yoo wrote: > On Mon, 2 Apr 2001, Rob Andrews wrote: > > > According to several articles found on the web (all dated the 1st of April) > > in places like perl.com, python.org, and oreilly.com, Parrot is a language > > in development intended to merge Python and Perl. Does anyone know what the > > story is? > > > > http://www.perl.com/pub/2001/04/01/parrot.htm > > It's a joke. Read the example source code that GvR and LR show: it's ^^ Waaa.. I'm reading too much into LR parsing... meant to say Larry Wall. Sorry about that. From dsh8290@rit.edu Mon Apr 2 22:26:35 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 2 Apr 2001 17:26:35 -0400 Subject: [Tutor] valid filenames In-Reply-To: <20010401123724.R26119@tc.niof.net>; from rick@niof.net on Sun, Apr 01, 2001 at 12:37:24PM -0400 References: <0c9dctsgsj3mcgvt0c0gubnjb6s7soo3k4@4ax.com> <200104011245.f31CjZs08501@dsl254-114-246.nyc1.dsl.speakeasy.net> <20010401170257.B5874@Laplace.localdomain> <2B3C91C4233@kserver.org> <"from sheila"@thinkspot.net> <20010401123724.R26119@tc.niof.net> Message-ID: <20010402172634.A23334@harmony.cs.rit.edu> On Sun, Apr 01, 2001 at 12:37:24PM -0400, Rick Pasotto wrote: | On Sun, Apr 01, 2001 at 09:24:06AM -0700, Sheila King wrote: | > On Sun, 1 Apr 2001 17:02:57 +0200, lumbricus@gmx.net wrote about Re: | > [Tutor] | > valid filenames: | > | > :U can avoid by not using | > :names like -anything | > : ^ | > | > The hyphen is not that uncommon in file names on Unix. For example, | > Qmail expects hyphens in the .qmail filenames that can be used for | > filtering email on the RCPT field of the email envelope, and from | > there invoking scripts or forwarding to other addresses or whatever. | | The only problem with a hyphen is when it's the first character of the | file name. Doing that causes many commands to confuse it with an option | and special steps have to be taken to get around that. For example, try to remove that file : $ rm -anything rm: illegal option -- a rm: illegal option -- n rm: illegal option -- y rm: illegal option -- t rm: illegal option -- h rm: illegal option -- n rm: illegal option -- g usage: rm [-fiRr] file ... It wasn't even able to tell me the file DNE. -D From bdupire@seatech.fau.edu Mon Apr 2 22:36:43 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Mon, 02 Apr 2001 17:36:43 -0400 Subject: [Tutor] Is Parrot an April Fool's joke? References: <Pine.LNX.4.21.0104021423470.32739-100000@hkn.eecs.berkeley.edu> Message-ID: <3AC8F0EB.D7AA0218@seatech.fau.edu> Daniel Yoo wrote: > On Mon, 2 Apr 2001, Daniel Yoo wrote: > > > On Mon, 2 Apr 2001, Rob Andrews wrote: > > > http://www.perl.com/pub/2001/04/01/parrot.htm > > > > It's a joke. Read the example source code that GvR and LR show: it's > ^^ > > Waaa.. I'm reading too much into LR parsing... meant to say Larry Wall. > Sorry about that. I would be interested to know how LR parsing works... I don't want to take much of your time, it's slightly off context... If you could explain it very briefly.. thanks.. Benoit From dsh8290@rit.edu Mon Apr 2 22:44:43 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 2 Apr 2001 17:44:43 -0400 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D694@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Mon, Apr 02, 2001 at 03:22:43PM +0100 References: <5104D4DBC598D211B5FE0000F8FE7EB20751D694@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <20010402174443.B23334@harmony.cs.rit.edu> On Mon, Apr 02, 2001 at 03:22:43PM +0100, alan.gauld@bt.com wrote: | > I'd say this depends on what you consider to be | > the *goals* of a first language. | | I agree. If you want to teach the basic concepts of | programming: sequences, loops, branching, variables | etc. then static typing just gets in the way. | Python is great for that. Ditto. Actually, (IMO) static typing gets in the way most of the time. That's pretty much how I feel when I use Java. | If you want to teach how computers work the Python | is not so good, C is better (assembler better still | but just toooo painful :-) Did you learn x86 assembly? I learned m68k assembly (required class for my major) after Eiffel, C++, Java, and C (ok, so I didn't know Java real well, and I had only read through a C tutorial but not actually used it) and found it to be quite painful. The prof then spent a day giving an introduction to x86 assembly and its architecture. It looked many times more painful than the m68k was. I remember spending several hours getting 10.0 + 5.0 to yield 15.0 (the m68k has no fpu so one lab was to implement IEEE floating point in software -- ugh!). | While they can all do the basics and write programs | (in Java) to a spec they are without exception ignorant | of how the computer actiually works. This in turn limits | them in all sorts of ways (performance tuning is a | complete mystery for example). We are now trying (so | far in vain) to find some kind of training course which | covers computer architectures etc. Would a college course be an option? If you are in western new york, RIT has a good "Introcudtion to Assembly Language Programming" course that basically covers the architecture as well. The prof even gave an example (simlified!) cpu and went over the various components and how they work with the clock cycles, stepping through a couple of instructions cycle-by-cycle. -D (who is very glad the bird didn't kill the snake) From dsh8290@rit.edu Mon Apr 2 22:48:12 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 2 Apr 2001 17:48:12 -0400 Subject: [Tutor] Is Parrot an April Fool's joke? In-Reply-To: <3AC8F0EB.D7AA0218@seatech.fau.edu>; from bdupire@seatech.fau.edu on Mon, Apr 02, 2001 at 05:36:43PM -0400 References: <Pine.LNX.4.21.0104021423470.32739-100000@hkn.eecs.berkeley.edu> <3AC8F0EB.D7AA0218@seatech.fau.edu> Message-ID: <20010402174812.C23334@harmony.cs.rit.edu> On Mon, Apr 02, 2001 at 05:36:43PM -0400, Benoit Dupire wrote: | Daniel Yoo wrote: | > Waaa.. I'm reading too much into LR parsing... meant to say Larry Wall. | > Sorry about that. | | I would be interested to know how LR parsing works... | I don't want to take much of your time, it's slightly off context... slightly ot, maybe, but interesting nonetheless (I suppose, I find most comp sci type things interesting) | If you could explain it very briefly.. thanks.. If so, on-list please ... (is it related to yacc at all? I used lex/yacc for a small project once. Many times easier than writing the whole thing in C++ from the ground up (in an earlier course)) -D From scarblac@pino.selwerd.nl Mon Apr 2 22:50:52 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Mon, 2 Apr 2001 23:50:52 +0200 Subject: [Tutor] Is Parrot an April Fool's joke? In-Reply-To: <3AC8F0EB.D7AA0218@seatech.fau.edu>; from bdupire@seatech.fau.edu on Mon, Apr 02, 2001 at 05:36:43PM -0400 References: <Pine.LNX.4.21.0104021423470.32739-100000@hkn.eecs.berkeley.edu> <3AC8F0EB.D7AA0218@seatech.fau.edu> Message-ID: <20010402235052.A4659@pino.selwerd.nl> On Mon, Apr 02, 2001 at 05:36:43PM -0400, Benoit Dupire wrote: > Daniel Yoo wrote: > > > On Mon, 2 Apr 2001, Daniel Yoo wrote: > > > > > On Mon, 2 Apr 2001, Rob Andrews wrote: > > > > http://www.perl.com/pub/2001/04/01/parrot.htm > > > > > > It's a joke. Read the example source code that GvR and LR show: it's > > ^^ > > > > Waaa.. I'm reading too much into LR parsing... meant to say Larry Wall. > > Sorry about that. > > I would be interested to know how LR parsing works... > I don't want to take much of your time, it's slightly off context... > If you could explain it very briefly.. thanks.. I think this is really too off-topic for the list, it takes quite some explaining. It typed "lr parsing" into Google though, and the first link is to "PyLR - fast LR parsing in Python" at http://starship.python.net/crew/scott/PyLR.html The only introduction I see is at http://cs.wwc.edu/~aabyan/464/BUP.html , but that's still far from easy. Try some other links :) There are several ways to go from a BNF grammar notation to a working parser for that language, they result in different types of parser. An LR parser is one type. If you are currently learning Assembler because Tim Peters told you that you had to do that if you wanted to find a job building compilers, you also want to learn all about LL, LR, LALR etc parsers... I learned about it at the uni from the book "Crafting a Compiler", which is quite thorough. But no fun :) -- Remco Gerlich From pdiaz88@terra.es Mon Apr 2 23:18:17 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Tue, 3 Apr 2001 00:18:17 +0200 Subject: [Tutor] Is Parrot an April Fool's joke? In-Reply-To: <004701c0bbb8$5e33bf00$9600a8c0@Planhouse5> References: <001101c0bb9b$042c21e0$9600a8c0@Planhouse5> <01040222404900.04659@tajo> <004701c0bbb8$5e33bf00$9600a8c0@Planhouse5> Message-ID: <01040300181701.04659@tajo> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Yeah, I saw the code. In one word: Joke for the people who didn't saw it, it was something like: function open_curly_brace if dolar_sign_A == "some text" open_curly_brace .... close_curly_brace close_curly_brace hah! Cheers Pedro On Monday 02 April 2001 23:03, Rob Andrews wrote: > I've assumed it's just a prank, but the idea is so freakish that some of > the people here in the office claim to like the prospect. Aside from the > fact that the articles were all dated Apr 1, the code snippets they > provided were just implausible. (Using closing curly braces to end nested > blocks?! Hardly.) > > Rob > > > Pretty sure is a joke. Was on the april fool's series in slashdot > > > > Cheers > > Pedro > > > > On Monday 02 April 2001 19:33, Rob Andrews wrote: > > > According to several articles found on the web (all dated the 1st of > > April) > > > > in places like perl.com, python.org, and oreilly.com, Parrot is a > > language > > > > in development intended to merge Python and Perl. Does anyone know what > > the > > > > story is? > > > > > > http://www.perl.com/pub/2001/04/01/parrot.htm > > > > > > Rob > > > > > > > > > _______________________________________________ > > > Tutor maillist - Tutor@python.org > > > http://mail.python.org/mailman/listinfo/tutor > > > > -----BEGIN PGP SIGNATURE----- > > Version: GnuPG v1.0.4 (GNU/Linux) > > Comment: For info see http://www.gnupg.org > > > > iD8DBQE6yOPZnu53feEYxlERAl8jAJ93Ys/SVgfjl1Eu7LaX/GBKAo/ZfACZAYob > > 6e0EWaV80pMiT4qvEgWucTI= > > =R6bD > > -----END PGP SIGNATURE----- > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6yPqqnu53feEYxlERAhZHAKDHw8VXuRTdB5hpemjj+wIHcNAgiwCgruON /2WHRvhRuj6gBUL8OsTds2o= =0kVx -----END PGP SIGNATURE----- From bsass@freenet.edmonton.ab.ca Mon Apr 2 23:14:32 2001 From: bsass@freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 2 Apr 2001 16:14:32 -0600 (MDT) Subject: [Tutor] valid filenames In-Reply-To: <20010402172634.A23334@harmony.cs.rit.edu> Message-ID: <Pine.LNX.4.33.0104021603440.11179-100000@bms> On Mon, 2 Apr 2001, D-Man wrote: <...> > | The only problem with a hyphen is when it's the first character of the > | file name. Doing that causes many commands to confuse it with an option > | and special steps have to be taken to get around that. > > For example, try to remove that file : > > $ rm -anything <...> rm -- -anything (as per "info rm" ;) - Bruce From rear@sirius.com Mon Apr 2 23:42:38 2001 From: rear@sirius.com (Bob Rea) Date: Mon, 02 Apr 2001 15:42:38 -0700 Subject: [Tutor] where is IDLE in 2.0 Message-ID: <3AC9005E.2080000@sirius.com> the site says there is a new idle 6 with 2.0 where is is located? -- Bob Rea Freedom is only privilege extended unless enjoyed by one and all --Billy Bragg rear@sirius.com http://www.sirius.com/~rear From lha2@columbia.edu Mon Apr 2 23:50:15 2001 From: lha2@columbia.edu (Lloyd Hugh Allen) Date: Mon, 02 Apr 2001 18:50:15 -0400 Subject: [Tutor] valid filenames References: <E14kC9I-0001dl-00@mail.python.org> Message-ID: <3AC90227.5CFB23FE@mail.verizon.net> > Message: 15 > Date: Mon, 2 Apr 2001 17:26:35 -0400 > From: D-Man <dsh8290@rit.edu> > To: tutor@python.org > Subject: Re: [Tutor] valid filenames > > On Sun, Apr 01, 2001 at 12:37:24PM -0400, Rick Pasotto wrote: > | On Sun, Apr 01, 2001 at 09:24:06AM -0700, Sheila King wrote: > | > On Sun, 1 Apr 2001 17:02:57 +0200, lumbricus@gmx.net wrote about Re: > | > [Tutor] > | > valid filenames: > | > > | > :U can avoid by not using > | > :names like -anything > | > : ^ > | > > | > The hyphen is not that uncommon in file names on Unix. For example, > | > Qmail expects hyphens in the .qmail filenames that can be used for > | > filtering email on the RCPT field of the email envelope, and from > | > there invoking scripts or forwarding to other addresses or whatever. > | > | The only problem with a hyphen is when it's the first character of the > | file name. Doing that causes many commands to confuse it with an option > | and special steps have to be taken to get around that. > > For example, try to remove that file : > > $ rm -anything > > rm: illegal option -- a > rm: illegal option -- n > rm: illegal option -- y > rm: illegal option -- t > rm: illegal option -- h > rm: illegal option -- n > rm: illegal option -- g > usage: rm [-fiRr] file ... > > It wasn't even able to tell me the file DNE. I was going to write that it would be a really bad idea to name a file '-rf ~&', but then I was afraid that someone would actually try it. A friend from undergrad used to have the .finger file [10] rm -rf ~ done or however it would look (don't have access to unix at the moment). From dsh8290@rit.edu Mon Apr 2 23:58:47 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 2 Apr 2001 18:58:47 -0400 Subject: [Tutor] valid filenames In-Reply-To: <3AC90227.5CFB23FE@mail.verizon.net>; from vze2f978@mail.verizon.net on Mon, Apr 02, 2001 at 06:50:15PM -0400 References: <E14kC9I-0001dl-00@mail.python.org> <3AC90227.5CFB23FE@mail.verizon.net> Message-ID: <20010402185846.A23622@harmony.cs.rit.edu> On Mon, Apr 02, 2001 at 06:50:15PM -0400, Lloyd Hugh Allen wrote: | I was going to write that it would be a really bad idea to name a file | '-rf ~&', but then I was afraid that someone would actually try it. A That's a good one <grin>. I wouldn't have tried that ;-). -D From bdupire@seatech.fau.edu Mon Apr 2 23:54:00 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Mon, 02 Apr 2001 18:54:00 -0400 Subject: [Tutor] converting a Python var to a C-type Message-ID: <3AC90307.2A184EEF@seatech.fau.edu> My problem consists of storing a variable X in a structure (in an init phase) so that i can pass it to a C-extension module later on (at run-time). # init time my_dictionary['X']=value # at run time cmodule.load( my_dictionary['X']) I would like to make sure at init-time that the value I pass to the C side at run-time will 'fit' the C variable, without raising an exception. the type the C side would accept is contained in a Python string variable: examples: "int", "short", "double", "float", "ulong", "uint", "ushort", "ubyte", "char".. Is there an easy way to make sure that the Python variable will fit the C format ? The intuitive (and tedious) way to do it would be: value= -3.14 if desired_type="int": # convert value to -3 if desired_type ="ushort": # raise ValueError Another way to do it would be another C-extension just to test whether it fits.. and then Python would take care of raising the exception if it does not work... So i will have (on the C-side) several functions which would only be 'stubs', and would return either an exception or the 'casted' variable if the variable can 'fit'. static PyObject * wrap_try_float (PyObject * self, PyObject * args) {<...>} static PyObject * wrap_try_unsigned_int ( PyObject * self, PyObject * args) {<...>} etc... Does anyone know a 'better' way ? Thanks !!!! -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From dsh8290@rit.edu Mon Apr 2 23:59:57 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 2 Apr 2001 18:59:57 -0400 Subject: [Tutor] Is Parrot an April Fool's joke? In-Reply-To: <20010402235052.A4659@pino.selwerd.nl>; from scarblac@pino.selwerd.nl on Mon, Apr 02, 2001 at 11:50:52PM +0200 References: <Pine.LNX.4.21.0104021423470.32739-100000@hkn.eecs.berkeley.edu> <3AC8F0EB.D7AA0218@seatech.fau.edu> <"from bdupire"@seatech.fau.edu> <20010402235052.A4659@pino.selwerd.nl> Message-ID: <20010402185957.B23622@harmony.cs.rit.edu> On Mon, Apr 02, 2001 at 11:50:52PM +0200, Remco Gerlich wrote: | On Mon, Apr 02, 2001 at 05:36:43PM -0400, Benoit Dupire wrote: | > Daniel Yoo wrote: | > | > I would be interested to know how LR parsing works... | > I don't want to take much of your time, it's slightly off context... | > If you could explain it very briefly.. thanks.. | | I think this is really too off-topic for the list, it takes quite some ... ok, thanks for that much of an intro -D From dsh8290@rit.edu Tue Apr 3 00:03:56 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 2 Apr 2001 19:03:56 -0400 Subject: [Tutor] Is There a Bugtracking tool written in Python In-Reply-To: <200103301436.JAA23470@scott.zenplex.com>; from scott@zenplex.com on Fri, Mar 30, 2001 at 09:38:49AM -0500 References: <200103301436.JAA23470@scott.zenplex.com> Message-ID: <20010402190356.C23622@harmony.cs.rit.edu> On Fri, Mar 30, 2001 at 09:38:49AM -0500, Scott Ralph Comboni wrote: | Does anyone now if there is a bugtracking tool like bugzilla written in | Python? For those who don't follow python-list (comp.lang.python) as well, Moshe Zadka mentioned Roundup by Ka-Ping Yee. http://www.lfw.org/ping/roundup.html -D From bsass@freenet.edmonton.ab.ca Tue Apr 3 00:02:38 2001 From: bsass@freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 2 Apr 2001 17:02:38 -0600 (MDT) Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <20010402174443.B23334@harmony.cs.rit.edu> Message-ID: <Pine.LNX.4.33.0104021622000.11179-100000@bms> On Mon, 2 Apr 2001, D-Man wrote: > On Mon, Apr 02, 2001 at 03:22:43PM +0100, alan.gauld@bt.com wrote: > | If you want to teach how computers work the Python > | is not so good, C is better (assembler better still > | but just toooo painful :-) > > Did you learn x86 assembly? I learned m68k assembly (required class > for my major) after Eiffel, C++, Java, and C (ok, so I didn't know > Java real well, and I had only read through a C tutorial but not > actually used it) and found it to be quite painful. The prof then > spent a day giving an introduction to x86 assembly and its > architecture. It looked many times more painful than the m68k was. I > remember spending several hours getting 10.0 + 5.0 to yield 15.0 (the > m68k has no fpu so one lab was to implement IEEE floating point in > software -- ugh!). Although I would assert that assembler (or even machine language) is the best introduction to computing you can get, I would have to qualify it by saying that x86, m68k, or even Z80 (8-bit), is too much. Something with a really basic instruction set and few registers, like the 6502, and a crash course in making data structures out of the various addressing modes, would let beginners see what is at the basis of all languages... learning a new language is then a matter of figuring out how the semantics relate to the basic operations CPUs do. - Bruce From lumbricus@gmx.net Tue Apr 3 00:21:46 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Tue, 3 Apr 2001 01:21:46 +0200 Subject: [Tutor] valid filenames In-Reply-To: <Pine.LNX.4.33.0104021603440.11179-100000@bms>; from bsass@freenet.edmonton.ab.ca on Mon, Apr 02, 2001 at 04:14:32PM -0600 References: <20010402172634.A23334@harmony.cs.rit.edu> <Pine.LNX.4.33.0104021603440.11179-100000@bms> Message-ID: <20010403012146.A2185@Laplace.localdomain> > > rm -- -anything > > (as per "info rm" ;) > or the less elegant way: $ rm ./-anything ;-) sorry-if-that-gets-double-posted-but-i-hit-a-wrong-key-with-my-new-mail-reader-grrrrreeetings Jö! From tbrauch@mindless.com Tue Apr 3 00:36:01 2001 From: tbrauch@mindless.com (Timothy M. Brauch) Date: Mon, 02 Apr 2001 19:36:01 -0400 Subject: [Tutor] Python In The Wild Message-ID: <3AC90CE1.58996CC8@mindless.com> I just noticed that on Yahoo!'s maps page, <http://maps.yahoo.com/py/maps.py> they seem to be using a Python script. Just thought you might like to know I had a Python siting in the the wild. - Tim From lumbricus@gmx.net Tue Apr 3 00:39:31 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Tue, 3 Apr 2001 01:39:31 +0200 Subject: [Tutor] valid filenames In-Reply-To: <20010402185846.A23622@harmony.cs.rit.edu>; from dsh8290@rit.edu on Mon, Apr 02, 2001 at 06:58:47PM -0400 References: <E14kC9I-0001dl-00@mail.python.org> <3AC90227.5CFB23FE@mail.verizon.net> <20010402185846.A23622@harmony.cs.rit.edu> Message-ID: <20010403013931.A2252@Laplace.localdomain> > | I was going to write that it would be a really bad idea to name a file > | '-rf ~&', but then I was afraid that someone would actually try it. A > Oh damn *shudder* actually you can try it by locking that beast up in backtics and using echo ? $ echo `rm -rfvv ~` ^^ to get some output grrrrrrreetings-to-all-the-m$-windoze-users-on-this-list-who-are-bored by-this-thread*wink* Jö! From lumbricus@gmx.net Tue Apr 3 01:12:55 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Tue, 3 Apr 2001 02:12:55 +0200 Subject: [Tutor] valid filenames In-Reply-To: <20010403013931.A2252@Laplace.localdomain>; from lumbricus@gmx.net on Tue, Apr 03, 2001 at 01:39:31AM +0200 References: <E14kC9I-0001dl-00@mail.python.org> <3AC90227.5CFB23FE@mail.verizon.net> <20010402185846.A23622@harmony.cs.rit.edu> <20010403013931.A2252@Laplace.localdomain> Message-ID: <20010403021255.A2484@Laplace.localdomain> On Tue, Apr 03, 2001 at 01:39:31AM +0200, lumbricus@gmx.net wrote: > > | I was going to write that it would be a really bad idea to name a file > > | '-rf ~&', but then I was afraid that someone would actually try it. A > > > Oh damn *shudder* > actually you can try it by locking that beast up in backtics and > using echo ? > $ echo `rm -rfvv ~` > ^^ > to get some output > > grrrrrrreetings-to-all-the-m$-windoze-users-on-this-list-who-are-bored > by-this-thread*wink* > Jö! > to make it clear this was a (OT) QUESTION!!! not an advice From lha2@columbia.edu Tue Apr 3 01:37:44 2001 From: lha2@columbia.edu (Lloyd Hugh Allen) Date: Mon, 02 Apr 2001 20:37:44 -0400 Subject: [Tutor] dovetail shuffle Message-ID: <3AC91B58.AB4888DD@mail.verizon.net> I can't remember whether it was on here or c.l.p that someone was talking about shuffling cards; here's my go, based on my recollection of a paper I read a bit ago. --------begin module dovetail.py-------------- import random def dovetail(deck,splitprecision=2,thumb=2): """Shuffles a deck in a fashion that (hopefully) approximates a "real" shuffle This performs something that hopefully approximates the dovetail shuffle that I remember reading about two years ago when taking a course from Dave Bayer. See Bayer, D. and Diaconis, P. (1992). 'Trailing the dovetail shuffle to its lair.' Ann. Appl. Probab. 2 (1992), no. 2 , 294-313.""" split=-1 #initialize split to a value that guarantees that the while loop goes newdeck=[] #initialize the object to be returned at the end of the day deck.reverse() #because we will be popping elements off of the top, instead of the bottom if len(deck)>1: #abort if we are given an empty deck while split<0 or split>len(deck): #generate a place to split the deck split=len(deck)/2+random.randint(-1*splitprecision,splitprecision) left=deck[:-1*split] #perform the split right=deck[split:] while len(left)>0 or len(right)>0: if len(left)>0: #if there are no cards in the left hand, please don't pop from the left for count in range(random.randint(1,min([len(left),thumb+1]))): newdeck.append(left.pop()) #take [1,3] cards (usually) from this hand if len(right)>0: for count in range(random.randint(1,min([len(right),thumb+1]))): newdeck.append(right.pop()) return newdeck #here is your shuffled deck From dyoo@hkn.eecs.berkeley.edu Tue Apr 3 08:46:25 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 3 Apr 2001 00:46:25 -0700 (PDT) Subject: [Tutor] converting a Python var to a C-type In-Reply-To: <3AC90307.2A184EEF@seatech.fau.edu> Message-ID: <Pine.LNX.4.21.0104030035410.16878-100000@hkn.eecs.berkeley.edu> On Mon, 2 Apr 2001, Benoit Dupire wrote: > the type the C side would accept is contained in a Python string > variable: > examples: "int", "short", "double", "float", "ulong", "uint", "ushort", > "ubyte", "char".. I'm not quite sure if this will help, but the struct module has a nice function calcsize() which will calculate how large a type will be: http://python.org/doc/current/lib/module-struct.html and the rest of the module itself might be very useful, since it does deal with C-style variables. pack() and unpack(), too, sound relevant. I'm not quite sure what you mean by "fit"; do you mean "fit" by the size of the structure, or range? One way I can see about doing this is with a data-directed programming style: keep a dictionary that matches desired_types with your stubs: type_funcs = { 'int' : convertInt, 'ushort' : convertShort, ... } This becomes useful because we can later do a: func = type_funcs[desired_type] return func(value) and have each of your conversion functions take responsibility for either converting things or raising ValueErrors. It makes it easier to add new times as you experiment because it involves just adding another element to your dictionary. There's probably a better way to do this, but I'm getting sleepy at the moment. *grin* Anyway, hope this helps! From alan.gauld@bt.com Tue Apr 3 10:57:54 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 3 Apr 2001 10:57:54 +0100 Subject: [Tutor] Still confused about Python references/objects Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D69D@mbtlipnt02.btlabs.bt.co.uk> > > On Mon, Apr 02, 2001 at 03:22:43PM +0100, alan.gauld@bt.com > > | is not so good, C is better (assembler better still > > | but just toooo painful :-) > > Did you learn x86 assembly? No, far to modern. I learnt 6502, 8080 and the then new Z80. I later played with a 6809 for a motor speed control application for an industrial milling machine. > Something with a really basic instruction set > and few registers, like the 6502, I agree, and there are some nice assember environments out there for emulating the chips so you don't have to struggle with the really primitive development tools we used (Anyone else recall the Rockwell AIM65 - a keyboard, line of 7 segment LEDs and a till-roll printer ;-) [ At this point cue the Python(?) sketch "You had XXX, you were lucky, we..." ] Alan g From NHYTRO@compuserve.com Tue Apr 3 12:07:10 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Tue, 3 Apr 2001 06:07:10 -0500 Subject: [Tutor] ODBC, MS ACCESS Message-ID: <200104030507_MC2-CB07-3B30@compuserve.com> Could someone point me to a tutorial or a Module that gives me access to = MS ACCESS( no pun intended)? I=B4ve searched FAQTS and the vaults of Parness= us and came up with mxODBC which is not free anymore, I would need a free or= open solution for my application Best regards Sharriff From scarblac@pino.selwerd.nl Tue Apr 3 11:13:52 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 3 Apr 2001 12:13:52 +0200 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D69D@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Tue, Apr 03, 2001 at 10:57:54AM +0100 References: <5104D4DBC598D211B5FE0000F8FE7EB20751D69D@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <20010403121352.A5891@pino.selwerd.nl> On Tue, Apr 03, 2001 at 10:57:54AM +0100, alan.gauld@bt.com wrote: > [ At this point cue the Python(?) sketch > "You had XXX, you were lucky, we..." ] Nah, I started on a 6502 as well (I was a kid, had a C64, and there were things that BASIC didn't do... Had to calculate the byte values on paper and put them in DATA statements, though. Assembler? Luxury!) However, I do have the Four Yorkshiremen sketch on .mpg, so if anyone hasn't seen it yet and has no problem downloading 33M, here it is... http://pino.selwerd.nl/Monty_Python-Four_Yorkshiremen.mpg (removing it in a day or two) (had to watch it immediately when you mentioned it, etc ;-)) -- Remco Gerlich From mbc2@netdoor.com Tue Apr 3 13:07:00 2001 From: mbc2@netdoor.com (mbc2@netdoor.com) Date: Tue, 3 Apr 2001 07:07:00 -0500 (CDT) Subject: [Tutor] ODBC, MS ACCESS In-Reply-To: <200104030507_MC2-CB07-3B30@compuserve.com> Message-ID: <Pine.LNX.4.20.0104030701400.1974-100000@localhost.localdomain> Its not immediately apparent, but there is ODBC connectivity included with python already, at least on the ActiveState Windows version I'm using. Look at the database modules (under Special Topics) section of the Python website. There's an ODBC module listed there. There isn't alot of documentation on it, but it's been working fine for me. On Tue, 3 Apr 2001, Sharriff Aina wrote: > Could someone point me to a tutorial or a Module that gives me access to = MS > ACCESS( no pun intended)? I=B4ve searched FAQTS and the vaults of Parness= us > and came up with mxODBC which is not free anymore, I would need a free or > open solution for my application >=20 > Best regards >=20 > Sharriff >=20 > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >=20 From bdupire@seatech.fau.edu Tue Apr 3 13:53:45 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Tue, 03 Apr 2001 08:53:45 -0400 Subject: [Tutor] converting a Python var to a C-type References: <Pine.LNX.4.21.0104030035410.16878-100000@hkn.eecs.berkeley.edu> Message-ID: <3AC9C7D9.931EA955@seatech.fau.edu> Daniel Yoo wrote: > On Mon, 2 Apr 2001, Benoit Dupire wrote: > > > the type the C side would accept is contained in a Python string > > variable: > > examples: "int", "short", "double", "float", "ulong", "uint", "ushort", > > "ubyte", "char".. > > > <snip interesting answer> > > I'm not quite sure what you mean by "fit"; do you mean "fit" by the size > of the structure, or range? both actually... if i pass 257 for a char variable, i would like to detect this at init time before it fails at run-time. > > There's probably a better way to do this, but I'm getting sleepy at the > moment. *grin* that's not so bad ;)))) > > > Anyway, hope this helps! sure! tks From pythoperson@yahoo.com Tue Apr 3 14:49:48 2001 From: pythoperson@yahoo.com (folklore hopeful) Date: Tue, 3 Apr 2001 06:49:48 -0700 (PDT) Subject: [Tutor] Burning python onto CD-ROM? Message-ID: <20010403134948.27064.qmail@web12403.mail.yahoo.com> Hello everyone out there, Here's a wacky question. Would it be possible to burn an installed copy of python onto CD-ROM, along with a *.py script file, so that I could put the cd-rom into any windows 95 PC and run the script without installing python onto the harddrive? What are the issues that I need to be aware of in attempting this? What files necessary to run python2.0 are placed outside of the python20 directory tree, if any? (this would hypothetically be python2.0 with windows 95) I'm not sure if I worded this question correctly, so maybe I'll need to clarify. Thanks in advance for the advice! __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ From dsh8290@rit.edu Tue Apr 3 15:49:29 2001 From: dsh8290@rit.edu (D-Man) Date: Tue, 3 Apr 2001 10:49:29 -0400 Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <20010403121352.A5891@pino.selwerd.nl>; from scarblac@pino.selwerd.nl on Tue, Apr 03, 2001 at 12:13:52PM +0200 References: <5104D4DBC598D211B5FE0000F8FE7EB20751D69D@mbtlipnt02.btlabs.bt.co.uk> <"from alan.gauld"@bt.com> <20010403121352.A5891@pino.selwerd.nl> Message-ID: <20010403104929.B28039@harmony.cs.rit.edu> On Tue, Apr 03, 2001 at 12:13:52PM +0200, Remco Gerlich wrote: | On Tue, Apr 03, 2001 at 10:57:54AM +0100, alan.gauld@bt.com wrote: | | However, I do have the Four Yorkshiremen sketch on .mpg, so if anyone hasn't | seen it yet and has no problem downloading 33M, here it is... | | http://pino.selwerd.nl/Monty_Python-Four_Yorkshiremen.mpg Thanks. Pretty funny! (btw, netscape had trouble with it -- it tried to show it as ascii in the browser, ftp access was fine though) -D From scarblac@pino.selwerd.nl Tue Apr 3 16:28:59 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 3 Apr 2001 17:28:59 +0200 Subject: [Tutor] Burning python onto CD-ROM? In-Reply-To: <20010403134948.27064.qmail@web12403.mail.yahoo.com>; from pythoperson@yahoo.com on Tue, Apr 03, 2001 at 06:49:48AM -0700 References: <20010403134948.27064.qmail@web12403.mail.yahoo.com> Message-ID: <20010403172859.B6540@pino.selwerd.nl> On Tue, Apr 03, 2001 at 06:49:48AM -0700, folklore hopeful wrote: > Hello everyone out there, > > Here's a wacky question. Would it be possible to burn an installed copy of > python onto CD-ROM, along with a *.py script file, so that I could put the > cd-rom into any windows 95 PC and run the script without installing python > onto the harddrive? > > What are the issues that I need to be aware of in attempting this? What > files necessary to run python2.0 are placed outside of the python20 directory > tree, if any? > > (this would hypothetically be python2.0 with windows 95) > > I'm not sure if I worded this question correctly, so maybe I'll need to > clarify. Thanks in advance for the advice! If you get Pythonware's PY20 version of Python 2.0, you have a version that installs into a directory, and uses nothing outside of it, no registry, nothing. So you can burn that to a CD and it should work. PY20 also comes with some cool libraries like PIL. See http://www.secretlabs.com/products/python/index.htm -- Remco Gerlich From chessucat@yahoo.com Tue Apr 3 17:02:29 2001 From: chessucat@yahoo.com (Charles Cheshier) Date: Tue, 3 Apr 2001 09:02:29 -0700 (PDT) Subject: [Tutor] Python In The Wild In-Reply-To: <3AC90CE1.58996CC8@mindless.com> Message-ID: <20010403160229.27216.qmail@web509.mail.yahoo.com> Hey, I just noticed that too. That Yahoo! seem to be using python on their site. I wonder why? Python reminds me of this programming language called ABC, written by some dutch prof. ABC is very easy to use and understand! It had one interesting feature, when started to type a reserved command, like W(rite?) it would fill in what you might have intended. Pretty neat! I haven't done much programming in my life. I do enjoy reading them and trying to decipher their meaning. Kinda like doing a cryptogram or crossword! ~Charles --- "Timothy M. Brauch" <tbrauch@mindless.com> wrote: > I just noticed that on Yahoo!'s maps page, > <http://maps.yahoo.com/py/maps.py> they seem to be > using a Python > script. Just thought you might like to know I had a > Python siting in > the the wild. > > - Tim > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ From kalle@gnupung.net Tue Apr 3 17:26:27 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Tue, 3 Apr 2001 18:26:27 +0200 Subject: [Tutor] Python In The Wild In-Reply-To: <20010403160229.27216.qmail@web509.mail.yahoo.com>; from chessucat@yahoo.com on Tue, Apr 03, 2001 at 09:02:29AM -0700 References: <3AC90CE1.58996CC8@mindless.com> <20010403160229.27216.qmail@web509.mail.yahoo.com> Message-ID: <20010403182627.A537@apone.network.loc> Sez Charles Cheshier: > Python > reminds me of this programming language called ABC, > written by some dutch prof. The similarities are not coincidential. In fact, Guido van Rossum, the creator of Python, worked with the ABC group at CWI from 1982 to 1986. Look at http://www.python.org/doc/essays/foreword.html for more about Python design influences and philosophy. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From szz@philoslabs.com Tue Apr 3 18:08:47 2001 From: szz@philoslabs.com (Szalay Zoltan) Date: Tue, 03 Apr 2001 19:08:47 +0200 Subject: [Tutor] Help: wxTreeCtrl doesn't display images Message-ID: <3ACA039F.1070603@philoslabs.com> Hello! Could anyone please tell me why the hell wxTreeCtrl doesn't display images? Here comes what I do: #----------------------------------- class MyTreeCtrl(wx.wxTreeCtrl): def __init__(...): ... wx.wxInitAllImageHandlers() folderbitmap=wx.wxImage("folder.bmp",wx.wxBITMAP_TYPE_BMP).ConvertToBitmap() imagelist=wx.wxImageList(16,16) idx=imagelist.Add(folderbitmap) self.SetImageList(imagelist) root=self.AddRoot("root",idx,-1) #------------------------------------- Thanx Zoltan Szalay szz@philoslabs.com From bsass@freenet.edmonton.ab.ca Tue Apr 3 18:08:10 2001 From: bsass@freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 3 Apr 2001 11:08:10 -0600 (MDT) Subject: [Tutor] Still confused about Python references/objects In-Reply-To: <20010403121352.A5891@pino.selwerd.nl> Message-ID: <Pine.LNX.4.33.0104031049150.12562-100000@bms> On Tue, 3 Apr 2001, Remco Gerlich wrote: > On Tue, Apr 03, 2001 at 10:57:54AM +0100, alan.gauld@bt.com wrote: > > [ At this point cue the Python(?) sketch > > "You had XXX, you were lucky, we..." ] > > Nah, I started on a 6502 as well (I was a kid, had a C64, and there were > things that BASIC didn't do... Had to calculate the byte values on paper and > put them in DATA statements, though. Assembler? Luxury!) A C64, the lap of luxury, you had a spot for ML starting at 49152 and a nice bunch of devel tools to choose from. A ZX81, on the other hand, forced you to poke bytes into a rem statement's text because Sir Clive's little box didn't have enough RAM to put any aside for ML. - Bruce (I guess we've bored most everyone under 35 now, eh ;) From dsh8290@rit.edu Tue Apr 3 19:24:38 2001 From: dsh8290@rit.edu (D-Man) Date: Tue, 3 Apr 2001 14:24:38 -0400 Subject: [Tutor] Help: wxTreeCtrl doesn't display images In-Reply-To: <3ACA039F.1070603@philoslabs.com>; from szz@philoslabs.com on Tue, Apr 03, 2001 at 07:08:47PM +0200 References: <3ACA039F.1070603@philoslabs.com> Message-ID: <20010403142438.E28277@harmony.cs.rit.edu> I'm not familiar enough with wxPython to anwser helpfully, but the wxPython users list might be a better place? I was subscribed to it for a while, and Robin Dunn (wxPython maintainer) is quite helpful on that list. (see www.wxwindows.org for details on the list) HTH, -D On Tue, Apr 03, 2001 at 07:08:47PM +0200, Szalay Zoltan wrote: | Hello! | | Could anyone please tell me why the hell wxTreeCtrl doesn't display images? | Here comes what I do: | | | #----------------------------------- | class MyTreeCtrl(wx.wxTreeCtrl): | def __init__(...): | ... | wx.wxInitAllImageHandlers() | | folderbitmap=wx.wxImage("folder.bmp",wx.wxBITMAP_TYPE_BMP).ConvertToBitmap() | imagelist=wx.wxImageList(16,16) | idx=imagelist.Add(folderbitmap) | self.SetImageList(imagelist) | root=self.AddRoot("root",idx,-1) | #------------------------------------- | | Thanx | Zoltan Szalay | szz@philoslabs.com From bdupire@seatech.fau.edu Tue Apr 3 19:40:29 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Tue, 03 Apr 2001 14:40:29 -0400 Subject: [Tutor] debugging a module from a Package with IDLE interpreter Message-ID: <3ACA191D.83E6D194@seatech.fau.edu> I am trying to debug a python program with IDLE... it's really a pain in the neck.. Here is an example... i want to load src.chasm.loader (.py) to debug it. Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.6 -- press F1 for help >>> import src.chasm.loader Traceback (innermost last): <SNIP!> ImportError: No module named setNavBehavior.py ### <<< A bug was found >>> ### ### <<< i fix the bug in my editor >>>#### ### << I want to (re) load src.chasm.loader to find the next bug>> ### ## Here are the tries to reload this f #%&?g module. >>> import src.chasm.loader >>> dir(src.chasm.loader) Traceback (innermost last): File "<pyshell#2>", line 1, in ? dir(src.chasm.loader) AttributeError: loader >>> dir (src) ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'chasm', 'resourceFiles'] >>> dir(src.chasm) ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'action', 'file', 'loaderException', 'loaderconst', 'navlibconst', 'state'] >>> import src.chasm >>> dir(src.chasm) ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'action', 'file', 'loaderException', 'loaderconst', 'navlibconst', 'state'] # no change... >>> from src.chasm import loader Traceback (innermost last): File "<pyshell#7>", line 1, in ? from src.chasm import loader ImportError: cannot import name loader Do i miss something ? The only thing I found is to kill the Python interpreter and to rerun it..... Thanks for any advice... ben -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From NHYTRO@compuserve.com Tue Apr 3 20:44:39 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Tue, 3 Apr 2001 14:44:39 -0500 Subject: [Tutor] ODBC Message-ID: <200104031344_MC2-CB2D-AF6E@compuserve.com> Nachricht geschrieben von INTERNET:tutor@python.org >From: mbc2@netdoor.com Date: Tue, 3 Apr 2001 07:07:00 -0500 (CDT) To: tutor@python.org Subject: Re: [Tutor] ODBC, MS ACCESS Its not immediately apparent, but there is ODBC connectivity included wit= h python already, at least on the ActiveState Windows version I'm using. Look at the database modules (under Special Topics) section of the= Python website. There's an ODBC module listed there. There isn't alot of documentation on it, but it's been working fine for me.< Thanks, few minutes after my post I discovered a link to Active state :-)= My only problem is: how can I access a database over a network? or with = a Python CGI Script? boy, documentation on this stuff is mighty hard to fin= d. I would be extremy greatful if you could give me an example of remote access from another PC over a network and maybe one with CGI. Great thanks and regards Sharriff From deirdre@deirdre.net Tue Apr 3 19:58:38 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Tue, 3 Apr 2001 11:58:38 -0700 (PDT) Subject: [Tutor] Python In The Wild In-Reply-To: <20010403160229.27216.qmail@web509.mail.yahoo.com> Message-ID: <Pine.LNX.4.31.0104031153340.6178-100000@emperor.deirdre.org> On Tue, 3 Apr 2001, Charles Cheshier wrote: > Hey, I just noticed that too. That Yahoo! seem to be using python on > their site. I wonder why? Python reminds me of this programming > language called ABC, written by some dutch prof. ABC was a precursor language to Python. Guido van Rossum, who is Dutch, was one of the people who worked on ABC and he is the designer for Python. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From kauphlyn@speakeasy.org Tue Apr 3 20:23:00 2001 From: kauphlyn@speakeasy.org (Daniel Coughlin) Date: Tue, 3 Apr 2001 12:23:00 -0700 (PDT) Subject: [Tutor] ODBC In-Reply-To: <200104031344_MC2-CB2D-AF6E@compuserve.com> Message-ID: <Pine.LNX.4.21.0104031215140.10787-100000@grace.speakeasy.org> try this: http://www.python.org/windows/win32/odbc.html its not much, but it gets the job the done. you have set up a DSN with odbc? if not, you have to control panel/odbc or data sources , and then add a system DSN using the ms access driver. hope this helps ~d On Tue, 3 Apr 2001, Sharriff Aina wrote: > Thanks, few minutes after my post I discovered a link to Active state :-) > My only problem is: how can I access a database over a network? or with a > Python CGI Script? boy, documentation on this stuff is mighty hard to find. > I would be extremy greatful if you could give me an example of remote > access from another PC over a network and maybe one with CGI. From dsh8290@rit.edu Tue Apr 3 20:25:26 2001 From: dsh8290@rit.edu (D-Man) Date: Tue, 3 Apr 2001 15:25:26 -0400 Subject: [Tutor] debugging a module from a Package with IDLE interpreter In-Reply-To: <3ACA191D.83E6D194@seatech.fau.edu>; from bdupire@seatech.fau.edu on Tue, Apr 03, 2001 at 02:40:29PM -0400 References: <3ACA191D.83E6D194@seatech.fau.edu> Message-ID: <20010403152526.C29241@harmony.cs.rit.edu> On Tue, Apr 03, 2001 at 02:40:29PM -0400, Benoit Dupire wrote: | I am trying to debug a python program with IDLE... it's really a pain in | the neck.. | Here is an example... i want to load src.chasm.loader (.py) to debug it. | | Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 | Type "copyright", "credits" or "license" for more information. | IDLE 0.6 -- press F1 for help | | >>> import src.chasm.loader | Traceback (innermost last): <SNIP!> | ImportError: No module named setNavBehavior.py | | ### <<< A bug was found >>> ### | ### <<< i fix the bug in my editor >>>#### | ### << I want to (re) load src.chasm.loader to find the next bug>> ### | ... | Do i miss something ? Yes <wink>. CPython tries to be smart (err, fast at least) -- when you import a module, it cahces it. The next time you import it it simply gives you a reference. It doesn't read the file from disk again. Use the reload() function to force the interpreter to read the module from disk again. (I've heard that it doesn't work quite right in PythonWin or Idle or some IDE, but I don't remember which) >>> print reload.__doc__ reload(module) -> module Reload the module. The module must have been successfully imported before. >>> Hmm, it must have been successfully imported before. I suppose the following might work in your situation : import src import sys.chasm.loader ... errors, fix bug reload( src ) import src.chasm.loader HTH, -D From bdupire@seatech.fau.edu Tue Apr 3 20:50:25 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Tue, 03 Apr 2001 15:50:25 -0400 Subject: [Tutor] debugging a module from a Package with IDLE interpreter References: <3ACA191D.83E6D194@seatech.fau.edu> <20010403152526.C29241@harmony.cs.rit.edu> Message-ID: <3ACA2981.81D60062@seatech.fau.edu> D-Man wrote: > On Tue, Apr 03, 2001 at 02:40:29PM -0400, Benoit Dupire wrote: > | I am trying to debug a python program with IDLE... it's really a pain in > | the neck.. > | Here is an example... i want to load src.chasm.loader (.py) to debug it. > | > | Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 > | Type "copyright", "credits" or "license" for more information. > | IDLE 0.6 -- press F1 for help > | > | >>> import src.chasm.loader > | Traceback (innermost last): <SNIP!> > | ImportError: No module named setNavBehavior.py > | > | ### <<< A bug was found >>> ### > | ### <<< i fix the bug in my editor >>>#### > | ### << I want to (re) load src.chasm.loader to find the next bug>> ### > | > > ... > > Hmm, it must have been successfully imported before. I suppose the > following might work in your situation : Yep, that's my pb. The module was not successfully imported before. > > import src > import src.chasm.loader > ...<<< errors, fix bug>>> > reload( src ) > import src.chasm.loader looks like a good idea... However it does not perform as wanted... >>> import src.chasm.loader <SNIP> NameError: There is no variable named 'neNavBehavior' >>> dir() ['__builtins__', '__doc__', '__name__'] ## src is unknown! >>> import src.chasm.loader >>> dir() ['__builtins__', '__doc__', '__name__', 'src'] >>> reload(src) <module 'src' from 'c:\wincvs\chasm\src\__init__.pyc'> >>> import src.chasm.loader >>> reload(src.chasm) <module 'src.chasm' from 'c:\wincvs\chasm\src\chasm\__init__.pyc'> >>> import src.chasm.loader >>> dir(src.chasm) ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'action', 'file', 'loaderException', 'loaderconst', 'navlibconst', 'state'] >>> src.chasm.loader is still unknown.... I think the pb comes from IDLE... ben From ryanbooz@alumni.psu.edu Tue Apr 3 21:00:11 2001 From: ryanbooz@alumni.psu.edu (Ryan Booz) Date: Tue, 03 Apr 2001 16:00:11 -0400 Subject: [Tutor] Tkinter callback question Message-ID: <3ACA2BCB.F5A5611E@alumni.psu.edu> Hello gang, I'm new to the group. And will be honest that I'm not taking the best road to learning with Python. I'm trying to teach it at a small school that has never had programming before. When it came time to jump into classes, I started stalling because I just hadn't gotten far enough ahead of the students and had to play catch-up. So, somewhat stupidly I introduced them to simple Tkinter concepts. Of course the students are very interested in making little GUI programs and so I got caught again. I think I'm looking for an explanation or at least a point in the right direction for the answer... but I'm pretty sure it relates to classes (or the concept at least). How do I get a widget (let's say a button) to execute a command that changes another widget (say a label). This seems like it should be pretty trivial, and I've looked for two days now and only run into more stuff I have to learn (which is ok, just can't get it all done at once). Let's say I make a Label with some text "Hello" and I have two other buttons ("Good-bye", "Hi There") that when pressed would change the Label to their text (or buttons for changing colors or something). How do I do this with one function? In a regular python function you could pass a variable that would make this happen. But if you pass a variable in the command line, it executes at conception and not after that. The only way I can get it to work right now is to have a separate function for each button that changes one one set of things - there's no "variable" in it. If I'm not making any sense, let me know and I'll try to add some examples of what I've done and what I want, but at the moment I have to go teach. Thanks for any help and for your understanding of asking what I'm sure is a straightforward answer that should be obvious. IT's a perspective issue probably. Thanks again, Ryan Booz Tech Coordinator Belleville Mennonite School From cdwom@mpinet.net Tue Apr 3 21:22:58 2001 From: cdwom@mpinet.net (Corey Woodworth) Date: Tue, 3 Apr 2001 16:22:58 -0400 Subject: [Tutor] Random Numbers Message-ID: <000901c0bc7b$e0b91880$98dc35d8@KellyJoW> How does one generate random numbers in python? Say from 1-10 for example? Thanks! Corey p.s. I'm still having focus() problems with my texteditor if anyone read those posts :( From rick@niof.net Tue Apr 3 22:21:21 2001 From: rick@niof.net (Rick Pasotto) Date: Tue, 3 Apr 2001 17:21:21 -0400 Subject: [Tutor] Tkinter callback question In-Reply-To: <3ACA2BCB.F5A5611E@alumni.psu.edu>; from ryanbooz@alumni.psu.edu on Tue, Apr 03, 2001 at 04:00:11PM -0400 References: <3ACA2BCB.F5A5611E@alumni.psu.edu> Message-ID: <20010403172121.A4858@tc.niof.net> On Tue, Apr 03, 2001 at 04:00:11PM -0400, Ryan Booz wrote: > > How do I get a widget (let's say a button) to execute a command that > changes another widget (say a label). This seems like it should be > pretty trivial, and I've looked for two days now and only run into more > stuff I have to learn (which is ok, just can't get it all done at > once). Let's say I make a Label with some text "Hello" and I have two > other buttons ("Good-bye", "Hi There") that when pressed would change > the Label to their text (or buttons for changing colors or something). > How do I do this with one function? In a regular python function you > could pass a variable that would make this happen. But if you pass a > variable in the command line, it executes at conception and not after > that. The only way I can get it to work right now is to have a separate > function for each button that changes one one set of things - there's no > "variable" in it. The following code will do what you want. There may be a better way and if so I'd like to know it. In order to pass a parameter to a widget's command I think you need to use a lambda but the lambda namespace does not include the instance's namespace. Thus, since the actual function needs to be outside the class, you need to pass the instance as a parameter. from Tkinter import * class Main: def __init__(self,root): self.root=root self.label = Label(root,width=30,height=3) self.label.pack() frm = Frame(root) self.button1 = Button(frm,text='Hello!', command=lambda x=self:do_change(x,1)) self.button1.pack(side=LEFT,padx=10,pady=5) self.button2 = Button(frm,text='Type it in', command=lambda x=self:do_change(x,2)) self.button2.pack(side=LEFT,padx=10,pady=5) self.button3 = Button(frm,text='Goodbye!', command=lambda x=self:do_change(x,3)) self.button3.pack(side=LEFT,padx=10,pady=5) frm.pack(expand=TRUE,fill=BOTH) self.entry = Entry(bg='white',width=20) self.entry.pack(padx=10,pady=5) def do_change(self,button=0): if button == 1: self.label.config(text='Hello!') if button == 2: txt = self.entry.get() self.label.config(text=txt) if button == 3: self.label.config(text='Goodbye!') if __name__=='__main__': root = Tk() main = Main(root) root.mainloop() -- "In the U.S. you have to be a deviant or exist in extreme boredom... Make no mistake; all intellectuals are deviants in the U.S." -- William Burroughs Rick Pasotto email: rickp@telocity.com From bsass@freenet.edmonton.ab.ca Tue Apr 3 22:36:34 2001 From: bsass@freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 3 Apr 2001 15:36:34 -0600 (MDT) Subject: [Tutor] Random Numbers In-Reply-To: <000901c0bc7b$e0b91880$98dc35d8@KellyJoW> Message-ID: <Pine.LNX.4.33.0104031533090.12562-100000@bms> On Tue, 3 Apr 2001, Corey Woodworth wrote: > How does one generate random numbers in python? Say from 1-10 for example? >>> import random >>> random.randint(1,10) 7 - Bruce From Rob Andrews" <rob@jam.rr.com Tue Apr 3 22:43:07 2001 From: Rob Andrews" <rob@jam.rr.com (Rob Andrews) Date: Tue, 3 Apr 2001 16:43:07 -0500 Subject: [Tutor] Random Numbers References: <000901c0bc7b$e0b91880$98dc35d8@KellyJoW> Message-ID: <00f101c0bc87$130e8760$9600a8c0@Planhouse5> A quick reference for random stuff in Python is the Python Library Reference: http://www.python.org/doc/current/lib/module-whrandom.html http://www.python.org/doc/current/lib/module-random.html Here's a really terse example: >>> import whrandom >>> doh = whrandom.randint(1, 10) >>> dog = whrandom.randint(1, 10) >>> doh 5 >>> dog 7 Someone less newbie-like than I am can likely explain them better, but I think this should do it. There are some source examples on Useless Python (http://www.lowerstandard.com/python/pythonsource.html) that demonstrate a few other things that may be done randomly in Python. Rob > How does one generate random numbers in python? Say from 1-10 for example? > > Thanks! > Corey > > p.s. I'm still having focus() problems with my texteditor if anyone read > those posts :( > From charliederr@organicmeat.net Tue Apr 3 22:52:34 2001 From: charliederr@organicmeat.net (Charlie Derr) Date: Tue, 3 Apr 2001 17:52:34 -0400 Subject: [Tutor] Random Numbers In-Reply-To: <000901c0bc7b$e0b91880$98dc35d8@KellyJoW> Message-ID: <LOBBJCAMDNLNCGCCHGEICELBKHAA.charliederr@organicmeat.net> ~ -----Original Message----- ~ From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of ~ Corey Woodworth ~ Sent: Tuesday, April 03, 2001 4:23 PM ~ To: Python Tutor List ~ Subject: [Tutor] Random Numbers ~ ~ ~ How does one generate random numbers in python? Say from 1-10 for example? >>> import random >>> my_random_number = random.choice(range(1,11)) >>> my_random_number 1 >>> another_one = random.choice(range(1,11)) >>> another_one 5 >>> ~ ~ Thanks! ~ Corey yw ~ ~ p.s. I'm still having focus() problems with my texteditor if anyone read ~ those posts :( sorry, didn't read those posts ~ ~ ~ _______________________________________________ ~ Tutor maillist - Tutor@python.org ~ http://mail.python.org/mailman/listinfo/tutor ~ From lha2@columbia.edu Tue Apr 3 23:23:03 2001 From: lha2@columbia.edu (Lloyd Hugh Allen) Date: Tue, 03 Apr 2001 18:23:03 -0400 Subject: [Tutor] dovetail shuffle References: <E14kLXt-0008Mf-00@mail.python.org> Message-ID: <3ACA4D47.DE8D4D38@mail.verizon.net> Last night while procrastinating, I wrote: > --------begin module dovetail.py-------------- > import random > > def dovetail(deck,splitprecision=2,thumb=2): > """Shuffles a deck in a fashion that (hopefully) approximates a "real" shuffle > > This performs something that hopefully approximates the dovetail shuffle > that I remember reading about two years ago when taking a course from Dave > Bayer. See Bayer, D. and Diaconis, P. (1992). 'Trailing the dovetail > shuffle to its lair.' Ann. Appl. Probab. 2 (1992), no. 2 , 294-313.""" #stuff > left=deck[:-1*split] #perform the split > right=deck[split:] #stuff this should be changed to left=deck[:split] #perform the split right=deck[split + 1:] Silly me...I was trying to figure out over lunch why my deck kept growing, and growing, and growing...but that's what happens if every so often you take the first 28 cards and the last 28 cards of a 52 card deck and shuffle them together. Sorry to respond to my own post. Now to figure out how to make this a thingamajiggy-in-place doohickey on a deck object. From jgbrawley@earthlink.net Tue Apr 3 23:45:03 2001 From: jgbrawley@earthlink.net (John Brawley) Date: Tue, 3 Apr 2001 17:45:03 -0500 Subject: [Tutor] Nondestructive interrupting Message-ID: <006601c0bc8f$bec4fd20$bd76d918@jb2> Hello, all; newbie here. I've got a script that runs endlessly (on purpose). It creates a spherical region of space and starts moving points in the space around, and is intended to run forever. However, in the process of fine-tuning it, I need to be able to stop it (without raising an error or exception, as happens now when I stop it with a ctrl-C), and then do "one more thing." There are reasons why I can't do this last thing inside the main part ofthe script, and reasons why I can't do it after the script has terminated with the keyboard interruption (ctrl-C). I tried to use msvcrt --from sys.platform, but it won't work for me (and I'd rather not use Win-Doze-specific in the Python). All I want to do is insert a "watchdog" line in the main body of the script, which repeatedly checks to see if a key has been pressed (_any_ key, although a specific key would be fine also), and then does this last thing and terminates the script. _Why_ I can't find such a simple thing in any of the Python docs, manuals, tutorials, at python.org, or anywhere else, frazzles me; it ought to be an obvious and basic function.... Can anyone tell me? Thanks JB jgbrawley@earthlink.net Web: http://www.jcn1.com/jbrawley http://home.earthlink.net/~jgbrawley From vlindberg@verio.net Wed Apr 4 01:46:22 2001 From: vlindberg@verio.net (VanL) Date: Tue, 03 Apr 2001 18:46:22 -0600 Subject: [Tutor] Still on Linked Lists Message-ID: <3ACA6EDE.77866BBC@verio.net> I know that all of you are probably going to groan, but I really don't have any special affection for linked lists. I am just trying to use them as a tool to learn stuff. That said, I have two questions. I will raise one in this email and the other in the next. 1. I put together a new implementation of a linked list class: class LinkedList2: """ This class provides a generic node for linked lists. Other python classes or objects can inherit from this class to get the ability to represent themselves as a linked list. """ def __init__(self, name, data=None, object=None): self = (name, data, object) def next(self): return self[2] def label(self): return self[0] def setdata(self, object): self[1] = object def getdata(self): return self[1] def link(self, object): self[2] = object def unlink(self): self[2] = None def rename(self, name): self[0] = name However, this doesn't work: >>> from LinkedList2 import * >>> this = LinkedList2('thisname') >>> that = LinkedList2('thatname', 'somedata', this) >>> theother = LinkedList2('theothername', 'someotherdata', that) >>> print theother Traceback (most recent call last): File "<stdin>", line 1, in ? File "LinkedList2.py", line 32, in __str__ print self[0], self[1], self[2] AttributeError: 'LinkedList2' instance has no attribute '__getitem__' >>> Why? Thanks, Van From vlindberg@verio.net Wed Apr 4 01:52:28 2001 From: vlindberg@verio.net (VanL) Date: Tue, 03 Apr 2001 18:52:28 -0600 Subject: [Tutor] Classes Message-ID: <3ACA704C.249A6551@verio.net> Here is my second question: I am investigating python's inheritance structure. Given the class LinkedList: class LinkedList: """ This class provides a generic node for linked lists. Other python classes or objects can inherit from this class to get the ability to represent themselves as a linked list. """ def __init__(self, name, object=None): self.__label = name if object: self.__link = object else: self.__link = None [snip to end] and the class NewClass: class NewClass(LinkedList): def __init__(self): NewString = "This is a new string" def NewString(self): print NewString How do I supply the superclass constructor arguments when instancing an object of type newclass? How does this change if I inherit from multiple classes? Thanks, Van From tim.one@home.com Wed Apr 4 00:51:05 2001 From: tim.one@home.com (Tim Peters) Date: Tue, 3 Apr 2001 19:51:05 -0400 Subject: [Tutor] Random Numbers In-Reply-To: <00f101c0bc87$130e8760$9600a8c0@Planhouse5> Message-ID: <LNBBLJKPBEHFEDALKOLCCEBBJKAA.tim.one@home.com> [Rob Andrews] > Here's a really terse example: > > >>> import whrandom > >>> doh = whrandom.randint(1, 10) > >>> dog = whrandom.randint(1, 10) > >>> doh > 5 > >>> dog > 7 Please don't use whrandom. This was a long-standing confusion in the docs and the code, finally cleared up in 2.1: whrandom will go away some day. "random" is what you want. >>> import random >>> random.randint(1, 10) 4 >>> From lha2@columbia.edu Wed Apr 4 02:27:58 2001 From: lha2@columbia.edu (Lloyd Hugh Allen) Date: Tue, 03 Apr 2001 21:27:58 -0400 Subject: [Tutor] debugging a module from a Package with IDLE interpreter Message-ID: <3ACA789E.3A2A32DE@mail.verizon.net> Message from Benoit Dupire begins ------------ I am trying to debug a python program with IDLE... it's really a pain in the neck.. >>> from src.chasm import loader Traceback (innermost last): File "<pyshell#7>", line 1, in ? from src.chasm import loader ImportError: cannot import name loader Do i miss something ? The only thing I found is to kill the Python interpreter and to rerun it..... Thanks for any advice... -----ends--------------- You have two windows open: the Python Shell and the module with which you are playing. Save your module, and, WITH THE MODULE YOU JUST MODIFIED (and saved) IN THE FOREGROUND, hit f5. It'll reload. I had the same problem and started poking around in the Idle documentation--there's a lot of neat stuff in there. Even figured out (a little) how to run the debugger. Nothing for figuring out scope like watching the debugger run. Few things as tedious, also. -LHA From arcege@shore.net Wed Apr 4 02:48:30 2001 From: arcege@shore.net (Michael P. Reilly) Date: Tue, 3 Apr 2001 21:48:30 -0400 (EDT) Subject: [Tutor] Nondestructive interrupting In-Reply-To: <006601c0bc8f$bec4fd20$bd76d918@jb2> from "John Brawley" at Apr 03, 2001 05:45:03 PM Message-ID: <200104040148.f341mU002205@dsl254-114-246.nyc1.dsl.speakeasy.net> John Brawley wrote > Hello, all; newbie here. > > I've got a script that runs endlessly (on purpose). > It creates a spherical region of space and starts moving points in the > space around, and is intended to run forever. > > However, in the process of fine-tuning it, I need to be able to stop it > (without raising an error or exception, as happens now when I stop it > with a ctrl-C), and then do "one more thing." The Ctrl-C causes the KeyboardInterrupt to be raised. This can be caught inside your loop or just outside it. inside def main(): while 1: try: do_something_fun() except KeyboardInterrupt: do_one_more_thing() break main() outside def main(): try: while 1: do_something_fun() except KeyboardInterrupt: do_one_more_thing() main() You can also deal with the routine regardless of how the program was stopped by using try-finally. def main(): while 1: do_something_fun() try: main() finally: # always gets called do_one_more_thing() > There are reasons why I can't do this last thing inside the main part > ofthe script, and reasons why I can't do it after the script has > terminated with the keyboard interruption (ctrl-C). > > I tried to use msvcrt --from sys.platform, but it won't work for me > (and I'd rather not use Win-Doze-specific in the Python). > > All I want to do is insert a "watchdog" line in the main body of the > script, which repeatedly checks to see if a key has been pressed (_any_ > key, although a specific key would be fine also), and then does this > last thing and terminates the script. Checking for a hardware event like that is bit more difficult. Python tried hard to be as platform independant as possible, and checking for a keyboard press is very platform dependant. -Arcege > _Why_ I can't find such a simple thing in any of the Python docs, > manuals, tutorials, at python.org, or anywhere else, frazzles me; it > ought to be an obvious and basic function.... References: Python Tutorial, section 2.2.1 Error Handling <URL: http://www.python.org/doc/current/tut/node4.html> Python Library Reference, section 2.2 Built-in Exceptions <URL: http://www.python.org/doc/current/lib/module-exceptions.html> Python Tutorial, section 8.3 Handling Exceptions <URL: http://www.python.org/doc/current/tut/node10.html> -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From john_maldives@hotmail.com Wed Apr 4 04:53:30 2001 From: john_maldives@hotmail.com (John Lenon) Date: Wed, 04 Apr 2001 08:53:30 +0500 Subject: [Tutor] attention Message-ID: <F147TrpwACkWHZqYW8B0000033b@hotmail.com> i want to get posted t othe list _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From scarblac@pino.selwerd.nl Wed Apr 4 07:30:25 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 4 Apr 2001 08:30:25 +0200 Subject: [Tutor] Classes In-Reply-To: <3ACA704C.249A6551@verio.net>; from vlindberg@verio.net on Tue, Apr 03, 2001 at 06:52:28PM -0600 References: <3ACA704C.249A6551@verio.net> Message-ID: <20010404083025.B7460@pino.selwerd.nl> On Tue, Apr 03, 2001 at 06:52:28PM -0600, VanL wrote: > Here is my second question: > > I am investigating python's inheritance structure. Given the class > LinkedList: > > class LinkedList: > > """ This class provides a generic node for linked lists. Other > python classes or > objects can inherit from this class to get the ability to represent > themselves as > a linked list. """ > > def __init__(self, name, object=None): > self.__label = name > if object: self.__link = object > else: self.__link = None > > [snip to end] > > > and the class NewClass: > > class NewClass(LinkedList): > > def __init__(self): > NewString = "This is a new string" LinkedList.__init__(self, "somename") > > def NewString(self): > print NewString > > > How do I supply the superclass constructor arguments when instancing an > object of type newclass? How does this change if I inherit from > multiple classes? If you inherit from multiple classes you can call __init__ in each of them, if necessary. Btw, the NewString doesn't work, the variable has to be 'self.NewString', and the function needs a different name (otherwise the self.NewString assignment in __init__ would overwrite the function). -- Remco Gerlich From dyoo@hkn.eecs.berkeley.edu Wed Apr 4 07:56:07 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 3 Apr 2001 23:56:07 -0700 (PDT) Subject: [Tutor] Tkinter callback question [and the Command class] In-Reply-To: <3ACA2BCB.F5A5611E@alumni.psu.edu> Message-ID: <Pine.LNX.4.21.0104032312170.19810-100000@hkn.eecs.berkeley.edu> On Tue, 3 Apr 2001, Ryan Booz wrote: > How do I get a widget (let's say a button) to execute a command that > changes another widget (say a label). This seems like it should be [warning --- slightly long message] One way to change the contents of a label is to use StringVar()'s. Here's an example of a StringVar: s = StringVar() StringVars allow us to change the contents of a label, as long as we created the Label to listen to it. That is, when we make the label: l = Label(textvariable=s) we can later call the set() or get() methods of our StringVar. Whenever we do something to our StringVar, something will happen to the label. For example: ### from Tkinter import * root = Tk() s = StringVar() l = Label(root, textvariable=s) s.set("Hello World!") ### is a small script that uses StringVars. I think the real question that you're asking about is how to use Tkinter callbacks, and how to pass arguments off to functions that we haven't called yet. It won't do if we try to do something like: b = Button(text='Goodbye', command=s.set('goodbye!')) simply because s.set() is being called too early: we want to somehow "delay" the call to the function, but still pass that particular argument when the time is right. Here's something that will do what you want: take a look below at the sample code: ### from Tkinter import * class Command: """ A class we can use to avoid using the tricky "Lambda" expression. "Python and Tkinter Programming" by John Grayson, introduces this idiom.""" def __init__(self, func, *args, **kwargs): self.func = func self.args = args self.kwargs = kwargs def __call__(self): apply(self.func, self.args, self.kwargs) if __name__ == '__main__': root = Tk() contents = StringVar() contents.set("Default message") l = Label(root, textvariable=contents) l.pack() b1 = Button(root, text="Goodbye", command=Command(contents.set, "goodbye!")) b2 = Button(root, text="Hello", command=Command(contents.set, "greetings!")) b1.pack() b2.pack() mainloop() ### The idea is to use a "Command" class: it takes in a function's name and the arguments that you want to pass to that function. Rather than calling the function immediately, it acts as the delayer. For example: ### def sayHello(name): print "Hello", name hiRyan = Command(sayHello, 'Ryan') # a delayed sayHello hiRyan() # Here's where we actually call the function. ### In this case, "hiRyan" takes on the value of a function, and only after we call it does sayHello() fire off. Likewise,i n the Tkinter example, we're giving our buttons a function that knows exactly what arguments to pass to contents.set(), without actually doing it immediately. This avoids the problem of having the functions fire off too quickly, and also lets us pass in our arguments. (Side note: the more traditional way to do the above is to use lambda's, but after being exposed to this Command idiom, I'm really leaning toward using the Command class: it's easier to read.) If you want to show this to your students, it's probably a good idea to just give them the Command class to play with: tell them how to use it, and point them to us when they want to know how it actually works. *grin* > If I'm not making any sense, let me know and I'll try to add some > examples of what I've done and what I want, but at the moment I have > to go teach. Thanks for any help and for your understanding of asking > what I'm sure is a straightforward answer that should be obvious. > IT's a perspective issue probably. You're making sense. Still, it'd be cool to see what you've shown your students. Can you show us some examples? Good luck to you! From sheila@thinkspot.net Wed Apr 4 08:00:09 2001 From: sheila@thinkspot.net (Sheila King) Date: Wed, 04 Apr 2001 00:00:09 -0700 Subject: [Tutor] Still on Linked Lists In-Reply-To: <3ACA6EDE.77866BBC@verio.net> References: <3ACA6EDE.77866BBC@verio.net> Message-ID: <38EACCC09B9@kserver.org> On Tue, 03 Apr 2001 18:46:22 -0600, VanL <vlindberg@verio.net> wrote about [Tutor] Still on Linked Lists: :1. I put together a new implementation of a linked list class: : :class LinkedList2: : : """ This class provides a generic node for linked lists. Other :python classes or : objects can inherit from this class to get the ability to represent :themselves as : a linked list. """ : : def __init__(self, name, data=None, object=None): : self = (name, data, object) : : def next(self): : return self[2] : : def label(self): : return self[0] : : def setdata(self, object): : self[1] = object : : def getdata(self): : return self[1] : : def link(self, object): : self[2] = object : : def unlink(self): : self[2] = None : : def rename(self, name): : self[0] = name It looked fine to me, so I pasted the above into an interpreter session, and then tried your commands below: :However, this doesn't work: : :>>> from LinkedList2 import * :>>> this = LinkedList2('thisname') :>>> that = LinkedList2('thatname', 'somedata', this) :>>> theother = LinkedList2('theothername', 'someotherdata', that) :>>> print theother : :Traceback (most recent call last): : File "<stdin>", line 1, in ? : File "LinkedList2.py", line 32, in __str__ : print self[0], self[1], self[2] :AttributeError: 'LinkedList2' instance has no attribute '__getitem__' :>>> I got no error. Here is my interpreter session: >>> this = LinkedList2('thisname') >>> that = LinkedList2('thatname', 'somedata', this) >>> theother = LinkedList2('theothername', 'someotherdata', that) >>> print theother <__main__.LinkedList2 instance at 00B3601C> >>> Mind you, since I pasted the code for your class definition directly into the interpreter, I didn't need to use the "import" statement. I suspect this is where you're having trouble. So, I'll save your class as a file, called LinkedList2.py and try again, in a new interpreter session. Here it is: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.6 -- press F1 for help >>> from LinkedList2 import * >>> this = LinkedList2('thisname') >>> that = LinkedList2('thatname', 'somedata', this) >>> theother = LinkedList2('theothername', 'someotherdata', that) >>> print theother <LinkedList2.LinkedList2 instance at 00B8FF3C> >>> Hmm. Beats me why it doesn't work for you. Seems to work for me just fine ??? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From scarblac@pino.selwerd.nl Wed Apr 4 08:11:07 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 4 Apr 2001 09:11:07 +0200 Subject: [Tutor] Still on Linked Lists In-Reply-To: <38EACCC09B9@kserver.org>; from sheila@thinkspot.net on Wed, Apr 04, 2001 at 12:00:09AM -0700 References: <3ACA6EDE.77866BBC@verio.net> <38EACCC09B9@kserver.org> Message-ID: <20010404091107.A8056@pino.selwerd.nl> On Wed, Apr 04, 2001 at 12:00:09AM -0700, Sheila King wrote: > I got no error. Here is my interpreter session: > > >>> this = LinkedList2('thisname') > >>> that = LinkedList2('thatname', 'somedata', this) > >>> theother = LinkedList2('theothername', 'someotherdata', that) > >>> print theother > <__main__.LinkedList2 instance at 00B3601C> > >>> The reason you get no error on 'print' is that his code as posted didn't contain the __str__ function, but his original error came from that, so we didn't see something. However, the whole construct with 'self = (a,b,c)' and returning 'self[1]' can't work. Try some of the other functions. __init__ can't make the object into something else, it can only *change* the existing object; for instance, by assigning to something 'inside' it, i.e., self.name = name. And it's a good thing too, if assigning a tuple to self did work, then the methods would be gone, since a tuple doesn't have them :-). -- Remco Gerlich From dyoo@hkn.eecs.berkeley.edu Wed Apr 4 08:26:36 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 4 Apr 2001 00:26:36 -0700 (PDT) Subject: [Tutor] Still on Linked Lists [References, UserDict] In-Reply-To: <3ACA6EDE.77866BBC@verio.net> Message-ID: <Pine.LNX.4.21.0104040007360.21028-100000@hkn.eecs.berkeley.edu> On Tue, 3 Apr 2001, VanL wrote: > I know that all of you are probably going to groan, but I really don't > have any special affection for linked lists. I am just trying to use > them as a tool to learn stuff. No prob, don't worry about it. > That said, I have two questions. I will raise one in this email and the > other in the next. > > 1. I put together a new implementation of a linked list class: > > class LinkedList2: > > """ This class provides a generic node for linked lists. Other > python classes or > objects can inherit from this class to get the ability to represent > themselves as > a linked list. """ > > def __init__(self, name, data=None, object=None): > self = (name, data, object) There's something here that you'll need to fix; unfortunately, the tuple assignment here doesn't quite work, since self is more like a dictionary than a list. To set things inside self, we need to use the period scoping operator ("."). For example, we'll want something like: def __init__(self, name, data=None, object=None): self.name, self.data, self.object = name, data, object which will do the assignment. What you had before did something different: it assigned the name "self" to the tuple (name, data, object), which won't work. Let's take a look again: > def __init__(self, name, data=None, object=None): > self = (name, data, object) It's the situation that Shelia King ran across with references: here, we're saying that, locally, "self" now stands for a tuple of 3 elements, which is certainly not what we want; we want to change the object that "self" refers to, and not redirect "self" to a new object. In any case, with those changes in mind, the accessor functions will need to change, since we're using "self" this way: > def next(self): > return self[2] becomes: def next(self): return self.object > def label(self): > return self[0] becomes: def label(self): return self.name etc. > However, this doesn't work: > > >>> from LinkedList2 import * > >>> this = LinkedList2('thisname') > >>> that = LinkedList2('thatname', 'somedata', this) > >>> theother = LinkedList2('theothername', 'someotherdata', that) > >>> print theother > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "LinkedList2.py", line 32, in __str__ > print self[0], self[1], self[2] > AttributeError: 'LinkedList2' instance has no attribute '__getitem__' By default, we need to change the components of self using that period-scoping syntax. Indexing on "self" doesn't work by default; that's where that AttributeError is coming from. However, it is possible to do this, but it takes some extra work by using UserDict: http://python.org/doc/current/lib/module-UserDict.html If you use UserDict, then your code will work: ### import UserDict class LinkedList2(UserDict.UserDict): def __init__(self, name, data=None, object=None): UserDict.UserDict.__init__(self) self[0], self[1], self[2] = name, data, object # and everything else stays the same. ### But you'll need to experiment with UserDict a bit, just to see how it works. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Wed Apr 4 08:45:10 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 4 Apr 2001 00:45:10 -0700 (PDT) Subject: [Tutor] Classes In-Reply-To: <3ACA704C.249A6551@verio.net> Message-ID: <Pine.LNX.4.21.0104040027140.21028-100000@hkn.eecs.berkeley.edu> On Tue, 3 Apr 2001, VanL wrote: > Here is my second question: > > I am investigating python's inheritance structure. Given the class > LinkedList: > > class LinkedList: > > """ This class provides a generic node for linked lists. Other > python classes or > objects can inherit from this class to get the ability to represent > themselves as > a linked list. """ > > def __init__(self, name, object=None): > self.__label = name > if object: self.__link = object > else: self.__link = None > > [snip to end] > > > and the class NewClass: > > class NewClass(LinkedList): > > def __init__(self): > NewString = "This is a new string" > > def NewString(self): > print NewString > > > How do I supply the superclass constructor arguments when instancing an > object of type newclass? How does this change if I inherit from > multiple classes? In Python, you'll need to call the superclass's constructor explicitely. If you're coming from a Java or C++ background, this will come as a small shock, since those languages take implicit steps to get constructors to run. Here's a definition of NewClass's constructor that calls the parent's constructor: ### class NewClass(LinkedList): def __init__(self): LinkedList.__init__(self) # Calling superclass's constructor NewString = "This is a new string" ### Dealing with multiple inheritance is similar: just call each parent's init function. Another way to do it is to be a little more implicit: every instance implicitely knows where it came from, that is, what class it's from. For example, we can say something like: self.__class__ and get access to the class, which is pretty neat. But more importantly, we can get to the parents of any particular class through the __bases__ of a class: ### >>> class Parent: ... def __init__(self): ... print "I am a parent" ... >>> p = Parent() I am a parent >>> class Child(Parent): ... def __init__(self): ... print self.__class__.__bases__, 'is a tuple of my parents.' ... self.__class__.__bases__[0]() # Call the parent's constructor ... print "End of child's constructor" ... >>> c = Child() (<class __main__.Parent at 80cbf20>,) is a tuple of my parents. I am a parent End of child's constructor ### I know I'm going a little too fast and informal, but I hope this gives a taste of how to call parent constructors. Hope this helps! From alan.gauld@bt.com Wed Apr 4 11:25:22 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 4 Apr 2001 11:25:22 +0100 Subject: [Tutor] Tkinter callback question Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6A8@mbtlipnt02.btlabs.bt.co.uk> > and so I got caught again. I think I'm looking for an > explanation or at least a point in the right direction Your timing is good. I just loaded the latest update to my Tkinter topic. Try http://www.crosswinds.net/~agauld/tutgui.htm It covers exactly what you ask for plus a lot more. It has one section to be completed plus some hyperlinks to F/s tutor. Also it includes a Tcl/Tk for comparison and a wxPython example to show what else is available. Hopefully I'll finish the page this weekend. > sure it relates to classes (or the concept at least). Nope - that's the bit I haven't done yet :-) But you don't need classes for Tkinter. Enjoy, Alan g http;//www.crosswinds.net/~agauld/ From danny@intuitivemedia.com Wed Apr 4 11:44:58 2001 From: danny@intuitivemedia.com (Danny Ruttle) Date: Wed, 04 Apr 2001 11:44:58 +0100 Subject: [Tutor] libpq and PgSQL modules Message-ID: <5.0.2.1.0.20010404114144.00a20310@mail.moonshine.co.uk> Hi I'm desperately trying to locate the source code for these Postgres API modules. Please please please could someone post some URLs to these files. I'm running FreeBSD 4.0 on i386 platform. regards Danny From alan.gauld@bt.com Wed Apr 4 11:39:45 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 4 Apr 2001 11:39:45 +0100 Subject: [Tutor] Still on Linked Lists Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6A9@mbtlipnt02.btlabs.bt.co.uk> > class LinkedList2: > def __init__(self, name, data=None, object=None): > self = (name, data, object) AArgh! This is a really bad idea. Never, ever, mess with self(OK, Never say never but...) self represents the instance itself thus you are trying to replace your object with a tuple! That's not smart. Instead create an instance variable that holds the tuple: self.items = (name, data, object) > def next(self): > return self[2] This won't work because self no longer exists as an object. (Indeed you couldn't actually even call it!) If you do as suggested above you need to rewrite the methods as: def next(self): return self.items[2] > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "LinkedList2.py", line 32, in __str__ > print self[0], self[1], self[2] > AttributeError: 'LinkedList2' instance has no attribute '__getitem__' If you really want to access self as a sequence you need to provide a __getitem__ method. Since you didn't the call fails. You could have done: def __getitem__(self, i): return self.items[i] And it might have worked - but I haven't tried... adding an instance variable is better IMO. Alan G From alan.gauld@bt.com Wed Apr 4 11:43:28 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 4 Apr 2001 11:43:28 +0100 Subject: [Tutor] Nondestructive interrupting Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6AA@mbtlipnt02.btlabs.bt.co.uk> > tried hard to be as platform independant as possible, > and checking for a keyboard press is very platform dependant. But not too hard if you wrap the program in a Tkinter wrapper. Just a very small window which coulkd be iconified would do it. But I think checking for the Interrupt error as already suggested should suffice. Alan G. From joerg.sporer@opencom.de Wed Apr 4 14:42:05 2001 From: joerg.sporer@opencom.de (=?iso-8859-1?Q?J=F6rg_Sporer?=) Date: Wed, 4 Apr 2001 15:42:05 +0200 Subject: [Tutor] Memory Management? Message-ID: <000001c0bd0d$0a0db970$3701000a@arthur> SGVsbG8gZXZlcnlvbmUhDQoNCldoZW4gSSBydW4gbXkgUHl0aG9uIHByb2dyYW0gKGFib3V0IDMw MCBsb2Mgd2l0aCBUa2ludGVyIEd1aSkgaXQgdXNlcyBhYm91dA0KOCBNQiBtZW1vcnkhDQpBZnRl ciBJIG1pbmltaXplIGl0IHRvIHRoZSB0YXNrYmFyIGFuZCBvcGVuIGl0IGFnYWluIGl0IG9ubHkg dXNlcyB+MU1CLiBJcw0KdGhlcmUgYSBnYXJiYWdlIGNvbGxlY3RvciBvciBzb21ldGhpbmcgd29y a2luZyBpbiB0aGUgYmFja2dyb3VuZD8NCg0KVGhhbmtzDQpK9nJnDQoNCg== From dsh8290@rit.edu Wed Apr 4 15:40:56 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 4 Apr 2001 10:40:56 -0400 Subject: [Tutor] attention In-Reply-To: <F147TrpwACkWHZqYW8B0000033b@hotmail.com>; from john_maldives@hotmail.com on Wed, Apr 04, 2001 at 08:53:30AM +0500 References: <F147TrpwACkWHZqYW8B0000033b@hotmail.com> Message-ID: <20010404104056.C1602@harmony.cs.rit.edu> On Wed, Apr 04, 2001 at 08:53:30AM +0500, John Lenon wrote: | i want to get posted t othe list You must join the list to recieve posts that are sent to the list. See http://mail.python.org/mailman/listinfo/tutor for instructions on joining the list. To post a message, simply send an e-mail to tutor@python.org (as you did for this message). When you have questions regarding python, just ask and somebody will answer it. -D From dsh8290@rit.edu Wed Apr 4 16:12:12 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 4 Apr 2001 11:12:12 -0400 Subject: [Tutor] debugging a module from a Package with IDLE interpreter In-Reply-To: <3ACA2981.81D60062@seatech.fau.edu>; from bdupire@seatech.fau.edu on Tue, Apr 03, 2001 at 03:50:25PM -0400 References: <3ACA191D.83E6D194@seatech.fau.edu> <20010403152526.C29241@harmony.cs.rit.edu> <3ACA2981.81D60062@seatech.fau.edu> Message-ID: <20010404111212.C1802@harmony.cs.rit.edu> On Tue, Apr 03, 2001 at 03:50:25PM -0400, Benoit Dupire wrote: | D-Man wrote: ... | > Hmm, it must have been successfully imported before. I suppose the | > following might work in your situation : | | Yep, that's my pb. The module was not successfully imported before. | ... | looks like a good idea... | However it does not perform as wanted... ... | I think the pb comes from IDLE... Could be. If you aren't using any special features from IDLE (other than the interactiveness, of course) then may I suggest using the command line? If you are using windows, get cygwin. Bash is far superior to DOS. My technique tends to be one of using (g)vim to edit and an "xterm" (ok, so I'm on windows too now, it's a DOS-term with cygwin) to run/test. If it fails I can simply type "!![enter]" to execute the command again. This is much easier and faster than hunting down idle in the start menu and then setting it up again. -D From jgbrawley@earthlink.net Wed Apr 4 16:28:24 2001 From: jgbrawley@earthlink.net (John Brawley) Date: Wed, 4 Apr 2001 10:28:24 -0500 Subject: [Tutor] Nondestructive interrupting References: <5104D4DBC598D211B5FE0000F8FE7EB20751D6AA@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <001301c0bd1b$e5b6c120$bd76d918@jb2> Yes, Alan. Thank you. The suggested method(s) generated a cure, which I will use. Of course re: Tkinter: ----- Original Message ----- From: <alan.gauld@bt.com> Me: > > tried hard to be as platform independant as possible, > > and checking for a keyboard press is very platform dependant. > > But not too hard if you wrap the program in a Tkinter > wrapper. Just a very small window which coulkd be iconified > would do it. When the script starts looking like a "program," I will of course have to tackle Tkinter (which I look forward to), but for now I have to make sure the "guts" of the program does exactly what I want it to. Designing a Tkinter GUI interface is going to be fun, but it's not required: basically I'm researching something of extreme importance only to me. Yes, there is a small community of people (like, maybe three or four(*g*)) interested in seeing what the program puts out, but they are mostly all programmers with an interest in "Elastic Interval Geometry," so the one or two also doing Python could use the script/program without needing a GUI, the ones not can see the image files the others put out, and I certainly don't need one for myself. Thanks for the help! JB jgbrawley@earthlink.net Web: http://www.jcn1.com/jbrawley http://home.earthlink.net/~jgbrawley From vlindberg@verio.net Wed Apr 4 21:25:09 2001 From: vlindberg@verio.net (VanL) Date: Wed, 04 Apr 2001 14:25:09 -0600 Subject: [Tutor] Sorting algorithm? Message-ID: <3ACB8325.26C23E2D@verio.net> What sorting algorithm is used to sort lists? given >>> list = ['base', 'ball', 'mound', 'bat', 'glove', 'batter'] >>> list.sort() >>> print list ['ball', 'base', 'bat', 'batter', 'glove', 'mound'] What happens behind the scenes? Quicksort, a la Perl? or some other algorithm, possibly depending on the size of n? From shaleh@valinux.com Wed Apr 4 21:41:30 2001 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Wed, 04 Apr 2001 13:41:30 -0700 (PDT) Subject: [Tutor] Sorting algorithm? In-Reply-To: <3ACB8325.26C23E2D@verio.net> Message-ID: <XFMail.20010404134130.shaleh@valinux.com> On 04-Apr-2001 VanL wrote: > > What sorting algorithm is used to sort lists? > > given >>>> list = ['base', 'ball', 'mound', 'bat', 'glove', 'batter'] >>>> list.sort() >>>> print list > ['ball', 'base', 'bat', 'batter', 'glove', 'mound'] > > What happens behind the scenes? Quicksort, a la Perl? or some other > algorithm, possibly depending on the size of n? In the python source, look at Objects/listobject.c. From vlindberg@verio.net Wed Apr 4 22:05:51 2001 From: vlindberg@verio.net (VanL) Date: Wed, 04 Apr 2001 15:05:51 -0600 Subject: [Tutor] Sorting algorithm? References: <XFMail.20010404134130.shaleh@valinux.com> Message-ID: <3ACB8CAF.7A10DC37@verio.net> Sean 'Shaleh' Perry wrote: > In the python source, look at Objects/listobject.c. I would, but I don't have a copy of the source handy... I thought that someone might know offhand. -V- From tutor@python.org Wed Apr 4 22:07:10 2001 From: tutor@python.org (Tim Peters) Date: Wed, 4 Apr 2001 17:07:10 -0400 Subject: [Tutor] Sorting algorithm? In-Reply-To: <3ACB8325.26C23E2D@verio.net> Message-ID: <LNBBLJKPBEHFEDALKOLCGEEAJKAA.tim.one@home.com> [VanL] > What sorting algorithm is used to sort lists? > > given > >>> list = ['base', 'ball', 'mound', 'bat', 'glove', 'batter'] > >>> list.sort() > >>> print list > ['ball', 'base', 'bat', 'batter', 'glove', 'mound'] > > What happens behind the scenes? Quicksort, a la Perl? or some other > algorithm, possibly depending on the size of n? It's a hybrid algorithm, using binary insertion sort on "small" slices and samplesort on "large" slices. samplesort is an extreme variation of quicksort, that reduces the asymptotic number of expected compares down to N * log2(N). This makes the expected number of compares comparable to mergesort (close to the theoretical minimum), but samplesort requires far less data movement than mergesort. Compares are expensive in Python, so minimizing compares is the primary goal for a Python sort. Sorry there isn't an easy answer, but Python's .sort() method is in fact complicated. A long time ago, Python *did* use the platform C library's qsort() function, but that was much slower, and on some platforms had bugs we couldn't worm around. From vlindberg@verio.net Wed Apr 4 22:57:07 2001 From: vlindberg@verio.net (VanL) Date: Wed, 04 Apr 2001 15:57:07 -0600 Subject: [Tutor] Sorting algorithm? References: <LNBBLJKPBEHFEDALKOLCGEEAJKAA.tim.one@home.com> Message-ID: <3ACB98B3.81C5EAF1@verio.net> Tim Peters wrote: > > It's a hybrid algorithm, using binary insertion sort on "small" slices and > samplesort on "large" slices. samplesort is an extreme variation of > quicksort, that reduces the asymptotic number of expected compares down to N > * log2(N). This makes the expected number of compares comparable to > mergesort (close to the theoretical minimum), but samplesort requires far > less data movement than mergesort. Compares are expensive in Python, so > minimizing compares is the primary goal for a Python sort. Thanks for your informative reply. Just two quick questions: 1. Why are compares expensive in Python? Is this because type must be idenitfied first? 2. Do you know of a good page that describes the samplesort algorithm? A search or two on google found some notes on parallel implementation of the algorithm, but none on the algorithm itself. Thank you, Van From tutor@python.org Wed Apr 4 23:05:49 2001 From: tutor@python.org (Tim Peters) Date: Wed, 4 Apr 2001 18:05:49 -0400 Subject: [Tutor] Sorting algorithm? In-Reply-To: <3ACB98B3.81C5EAF1@verio.net> Message-ID: <LNBBLJKPBEHFEDALKOLCCEEFJKAA.tim.one@home.com> [VanL] > 1. Why are compares expensive in Python? Is this because type must be > idenitfied first? Mostly, yes. There are always at least several layers of C function call involved in each comparison made by list.sort(), even if the "real work" consists of just one or two machine instructions. If you pass a custom comparison function, or have objects that implement their own __cmp__ method, then a (at least one) *Python*-level function call is also required for each comparison. > 2. Do you know of a good page that describes the samplesort > algorithm? A search or two on google found some notes on parallel > implementation of the algorithm, but none on the algorithm itself. Sorry, the best description I know of is the one I wrote up in comments in Python's list.sort() code. If you understand quicksort, samplesort works by first sorting a relatively large random sample from the array, and then using those sorted elements as pivots for an equal number of quicksort partitioning steps. User a large sample ensures that (probabilistically) the pivots are excellent estimates of the true medians. Note that all of Python's source code is available online. For example, the source code for list.sort() is in listobject.c, available by browsing the Python CVS repository on SourceForge (sorry, but you'll have to paste this line together by hand): http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/ python/dist/src/Objects/listobject.c?cvsroot=python From rick@niof.net Wed Apr 4 23:16:36 2001 From: rick@niof.net (Rick Pasotto) Date: Wed, 4 Apr 2001 18:16:36 -0400 Subject: [Tutor] python on windows / mysql on linux Message-ID: <20010404181636.B4858@tc.niof.net> How can I access a MySQL database on my linux box from my windows box using python? Python on the linux box works great. -- "I will not be pushed, filed, stamped, indexed, briefed, debriefed, or numbered. My life is my own." -- The Prisoner Rick Pasotto email: rickp@telocity.com From dsh8290@rit.edu Wed Apr 4 23:46:05 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 4 Apr 2001 18:46:05 -0400 Subject: [Tutor] python on windows / mysql on linux In-Reply-To: <20010404181636.B4858@tc.niof.net>; from rick@niof.net on Wed, Apr 04, 2001 at 06:16:36PM -0400 References: <20010404181636.B4858@tc.niof.net> Message-ID: <20010404184605.B4249@harmony.cs.rit.edu> On Wed, Apr 04, 2001 at 06:16:36PM -0400, Rick Pasotto wrote: | How can I access a MySQL database on my linux box from my windows box | using python? Python on the linux box works great. Does MySQL have something similar to Postgres' "postmaster"? With Postgres you set up the postmaster to accept requests and the postmaster hooks the client up with the actual db. I haven't had much experience, but I've read some docs. I believe the postmaster can recieve requests over TCP/IP, not just from local clients (after all, what use would it be if you couldn't have nice remote client-server connections?). -D From deirdre@deirdre.net Thu Apr 5 00:12:56 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 4 Apr 2001 16:12:56 -0700 (PDT) Subject: [Tutor] python on windows / mysql on linux In-Reply-To: <20010404184605.B4249@harmony.cs.rit.edu> Message-ID: <Pine.LNX.4.31.0104041609570.22860-100000@emperor.deirdre.org> On Wed, 4 Apr 2001, D-Man wrote: > On Wed, Apr 04, 2001 at 06:16:36PM -0400, Rick Pasotto wrote: > | How can I access a MySQL database on my linux box from my windows box > | using python? Python on the linux box works great. > > Does MySQL have something similar to Postgres' "postmaster"? MySQL supports ODBC; since Windows does that as well, it seems the logical choice to connect the two. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From pdiaz88@terra.es Thu Apr 5 00:19:35 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Thu, 5 Apr 2001 01:19:35 +0200 Subject: [Tutor] python on windows / mysql on linux In-Reply-To: <20010404181636.B4858@tc.niof.net> References: <20010404181636.B4858@tc.niof.net> Message-ID: <01040501193502.30149@tajo> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 05 April 2001 00:16, Rick Pasotto wrote: > How can I access a MySQL database on my linux box from my windows box > using python? Python on the linux box works great. Does python on the win box work? Yes, MySQL can accept queries over a network. Suposing that the MySQL module is also supported on the Win box, you only have to use the connect() method. An easy example: import MySQLdb db_conn = MySQLdb.connect( user="myuser", passwd="mypasswd", db="mydb",\ host="myhost" ) db_cur = db_conn.cursor() db_cur.execute( some_query ) print db_cur.fetchone() Take a look at the DB API in the python doc Cheers Pedro -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6y6wHnu53feEYxlERAnOrAKDIiy0vOpJ9VTHN6p39EMtXeN1AWACgyYht XV5zxGBs6RtXlUyNYiTLpF0= =TCsA -----END PGP SIGNATURE----- From rick@niof.net Thu Apr 5 02:44:20 2001 From: rick@niof.net (Rick Pasotto) Date: Wed, 4 Apr 2001 21:44:20 -0400 Subject: [Tutor] python on windows / mysql on linux In-Reply-To: <01040501193502.30149@tajo>; from pdiaz88@terra.es on Thu, Apr 05, 2001 at 01:19:35AM +0200 References: <20010404181636.B4858@tc.niof.net> <01040501193502.30149@tajo> Message-ID: <20010404214420.C4858@tc.niof.net> On Thu, Apr 05, 2001 at 01:19:35AM +0200, Pedro Diaz Jimenez wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Thursday 05 April 2001 00:16, Rick Pasotto wrote: > > How can I access a MySQL database on my linux box from my windows box > > using python? Python on the linux box works great. > Does python on the win box work? Python works but I can't figure out how to install MySQLdb. The README file doesn't even mention Windows, just linux, even though the zip file is called MySQL-python-0.3.5-win32-1.zip. I edited the setup.py file to change the references to d: to c: and then from within idle ran 'setup.py build' and'setup.py install'. Both printed a 0 (does that mean a successful completion?). But when I then try to import MySQLdb it can't be found. I know very little about windoz and so I have no idea how to figure what I'm doing wrong. > Yes, MySQL can accept queries over a network. Suposing that the MySQL module > is also supported on the Win box, you only have to use the connect() method. > An easy example: > > import MySQLdb > > db_conn = MySQLdb.connect( user="myuser", passwd="mypasswd", db="mydb",\ > host="myhost" ) > db_cur = db_conn.cursor() > db_cur.execute( some_query ) > print db_cur.fetchone() Yes, that's what I do on the linux box. But first I have to get the import to work. Surely there must be some simple instructions somewhere showing how to install the MySQLdb module on the windoz box. -- Most of the presidential candidates' economic packages involve 'tax breaks,' which is when the government, amid great fanfare, generously decides not to take quite so much of your income. In other words, these candidates are trying to buy your votes with your own money. -- Dave Barry Rick Pasotto email: rickp@telocity.com From van@lindbergs.org Thu Apr 5 05:19:43 2001 From: van@lindbergs.org (VanL) Date: Wed, 04 Apr 2001 22:19:43 -0600 Subject: [Tutor] python on windows / mysql on linux References: <20010404181636.B4858@tc.niof.net> <01040501193502.30149@tajo> <20010404214420.C4858@tc.niof.net> Message-ID: <3ACBF25F.3ED5C46A@lindbergs.org> > I edited the setup.py file to change the references to d: to c: and then > from within idle ran 'setup.py build' and'setup.py install'. Both > printed a 0 (does that mean a successful completion?). But when I then > try to import MySQLdb it can't be found. There are two things that may be: 1. Did you run "setup.py install"? The built module is not installed by default. 2. The module is built -- try going into the build directory, and then a directory called something like "lib.win32.-2.0".** Copy all the files in that directory into your pythonpath (or open up a python interpreter in that directory). The import should then work. ** This directory name is approximate. Van From mylene.reiners@cmg.nl Thu Apr 5 08:20:37 2001 From: mylene.reiners@cmg.nl (Mylene Reiners) Date: Thu, 5 Apr 2001 09:20:37 +0200 Subject: [Tutor] Q: return-values Message-ID: <B569A4D2254ED2119FE500104BC1D5CD010D18B0@NL-EIN-MAIL01> Hi, I'm writing a program that will handle some rather free-form text, = select some values, and write those values to a CSV-file. The problem is with the free-form text - the lines I have to select are = not always the same: Input: One or more unimportant lines Date: 15-04-2001 Mr. Ir. Drs. A. Somename Somestreet 20, 1234 AB Someplace One or more unimportant lines Datum: 15-04-2001 Aanhef: Dhr. Titel: Voornaam: A. Achternaam: Somename Straat: Somestreet 20 Postcode: 1234 AB Woonplaats: Someplace Output: Datum;Aanhef:Titel;Voornaam;Achternaam;Straat;Postcode;Woonplaats 15-04-2001;Mr;Ir. Drs;A.;Somename;Somestreet 20;1234 AB;Someplace 15-04-2001;Dhr;;A.;Somename;Somestreet 20;1234 AB;Someplace Program: <ignoreList =3D the list to determine what lines to ignore> <open files> <write the first output line> for line in input.readlines(): i =3D 0 test =3D -1 while i < lengte and test < 0: sub =3D ignoreList[i] test =3D string.find(line, sub, 0, 100) i =3D i + 1 if test < 0: < try to determine what lines are filled, and put them at the appropriate spot in the CSV-output> voorkeur =3D bepaal_voorkeur (line) For the last part I want to write some code, first to determine what I = have to put in the CSV-output def bepaal_voorkeur(regel): str =3D "Date " start =3D string.find(regel, str, 0, 250) if start !=3D -1: splitList =3D string.split(regel,":") voork =3D splitList[1] splitList =3D string.split(voork,"\n") voork =3D splitList[0] else: str =3D "Datum:" start =3D string.find(regel, str, 0, 250) if start !=3D -1: splitList =3D string.split(regel,":") voork =3D splitList[1] splitList =3D string.split(voork,"\n") voork =3D splitList[0] else: voork =3D " " return voork But then I have to determine whether I handled the "voorkeur" (the date = can be blank...) So I want to set a boolean to determine. But I can't figure out how...(handle more than one return-value with different meanings - string and boolean). Can anyone help me out? If you have some better ideas than I have about the coding, I would be = very grateful too... TIA, Myl=E8ne ---------------------+ Myl=E8ne Reiners | CMG Eindhoven B.V. | Calculating in binary Luchthavenweg 57 | code is as easy as=20 5657 EA Eindhoven | 01,10,11. The Netherlands | Tel Nr.+31(0)40-2957777 | Fax Nr.+31(0)40-2957600 | I don't speak for CMG, Mob Nr.+31(0)6-25068391 | nor vice-versa. ------------------------+ From ryanbooz@alumni.psu.edu Thu Apr 5 14:02:19 2001 From: ryanbooz@alumni.psu.edu (Ryan Booz) Date: Thu, 05 Apr 2001 09:02:19 -0400 Subject: [Tutor] Tkinter callback question [and the Command class] References: <Pine.LNX.4.21.0104032312170.19810-100000@hkn.eecs.berkeley.edu> Message-ID: <3ACC6CDB.825CFC90@alumni.psu.edu> Daniel, (and others!) Thank you for your help. All of your comments have gotten me headed in a much better (and clearer) direction. I really appreciate it. As per your request Daniel, I will try to post some of the things my class does as we finish them. I'm not sure how productive or useful they are, but as I said, we're all just learning! Thanks again! Ryan Booz Tech Coordinator Belleville Mennonite School From scott@zenplex.com Thu Apr 5 19:25:44 2001 From: scott@zenplex.com (Scott Ralph Comboni) Date: 05 Apr 2001 14:25:44 -0400 Subject: [Tutor] shutil question? on copying files Message-ID: <986495148.1349.0.camel@scoot.zenplex.com> I have a question in regards to the shutil module. I'm trying to copy via a wildcard shutil.copy('/project/tambora/packages/*tar*', '/tmp') and I get this. File "<stdin>", line 1, in ? File "/usr/local/lib/python2.0/shutil.py", line 26, in copyfile fsrc = open(src, 'rb') IOError: [Errno 2] No such file or directory: '/projects/tambora/packages/*tar*' It works fine if I put the complete path name in but I'd like to be able to wildcard this. IS there a way to do this or another module to use? I need to preform this function on *NIX and NT. Thanks Scott From scarblac@pino.selwerd.nl Thu Apr 5 19:32:54 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 5 Apr 2001 20:32:54 +0200 Subject: [Tutor] shutil question? on copying files In-Reply-To: <986495148.1349.0.camel@scoot.zenplex.com>; from scott@zenplex.com on Thu, Apr 05, 2001 at 02:25:44PM -0400 References: <986495148.1349.0.camel@scoot.zenplex.com> Message-ID: <20010405203254.A18962@pino.selwerd.nl> On 0, Scott Ralph Comboni <scott@zenplex.com> wrote: > I have a question in regards to the shutil module. I'm trying to copy > via a wildcard shutil.copy('/project/tambora/packages/*tar*', '/tmp') > and I get this. > > File "<stdin>", line 1, in ? > File "/usr/local/lib/python2.0/shutil.py", line 26, in copyfile > fsrc = open(src, 'rb') > IOError: [Errno 2] No such file or directory: > '/projects/tambora/packages/*tar*' > > It works fine if I put the complete path name in but I'd like to be able > to wildcard this. IS there a way to do this or another module to use? I > need to preform this function on *NIX and NT. shutil does not do wildcars, but for that there is glob; try import shutil, glob for file in glob.glob('/projects/tambora/packages/*tar*'): shutil.copy(file, '/tmp') -- Remco Gerlich From ium@micromuse.com Thu Apr 5 19:39:14 2001 From: ium@micromuse.com (ibraheem umaru-mohammed) Date: Thu, 5 Apr 2001 19:39:14 +0100 Subject: [Tutor] shutil question? on copying files In-Reply-To: <986495148.1349.0.camel@scoot.zenplex.com>; from scott@zenplex.com on Thu, Apr 05, 2001 at 02:25:44PM -0400 References: <986495148.1349.0.camel@scoot.zenplex.com> Message-ID: <20010405193914.B22759@ignoramus> [Scott Ralph Comboni wrote...] -| I have a question in regards to the shutil module. I'm trying to copy -| via a wildcard shutil.copy('/project/tambora/packages/*tar*', '/tmp') -| and I get this. -| -| File "<stdin>", line 1, in ? -| File "/usr/local/lib/python2.0/shutil.py", line 26, in copyfile -| fsrc = open(src, 'rb') -| IOError: [Errno 2] No such file or directory: -| '/projects/tambora/packages/*tar*' -| -| It works fine if I put the complete path name in but I'd like to be able -| to wildcard this. IS there a way to do this or another module to use? I -| need to preform this function on *NIX and NT. I don't know how you would do it under NT but you can try using the glob module under *nixes: >>>import glob >>> glob.glob("/boot/*") ['/boot/System.map', '/boot/System.map-2.4.0-test9', '/boot/boot.0300', '/boot/boot.0303', '/boot/boot.b', '/boot/chain.b', '/boot/kernel.h', '/boot/lost+found', '/boot/map', '/boot/module-info', '/boot/os2_d.b', '/boot/System.map.old', '/boot/boot.0305', '/boot/boot.0200', '/boot/System.map-2.2.18', '/boot/vmlinuz.old', '/boot/vmlinuz-2.4.0-test9', '/boot/vmlinuz-2.2.18', '/boot/vmlinuz-2.2.18.prev', '/boot/boot.0306', '/boot/boot.lnx'] >>> HTH, Kindest regards, --ibs. -- Live never to be ashamed if anything you do or say is published around the world -- even if what is published is not true. -- Messiah's Handbook : Reminders for the Advanced Soul From scott@zenplex.com Thu Apr 5 20:09:49 2001 From: scott@zenplex.com (Scott Ralph Comboni) Date: 05 Apr 2001 15:09:49 -0400 Subject: [Tutor] shutil question? on copying files In-Reply-To: <20010405203254.A18962@pino.selwerd.nl> References: <986495148.1349.0.camel@scoot.zenplex.com> <20010405203254.A18962@pino.selwerd.nl> Message-ID: <986497791.1350.2.camel@scoot.zenplex.com> > On 05 Apr 2001 20:32:54 +0200, Remco Gerlich wrote: > On 0, Scott Ralph Comboni <scott@zenplex.com> wrote: > > I have a question in regards to the shutil module. I'm trying to copy > > via a wildcard shutil.copy('/project/tambora/packages/*tar*', '/tmp') > > and I get this. > > > > File "<stdin>", line 1, in ? > > File "/usr/local/lib/python2.0/shutil.py", line 26, in copyfile > > fsrc = open(src, 'rb') > > IOError: [Errno 2] No such file or directory: > > '/projects/tambora/packages/*tar*' > > > > It works fine if I put the complete path name in but I'd like to be able > > to wildcard this. IS there a way to do this or another module to use? I > > need to preform this function on *NIX and NT. > > shutil does not do wildcars, but for that there is glob; try > > import shutil, glob > > for file in glob.glob('/projects/tambora/packages/*tar*'): > shutil.copy(file, '/tmp') > > -- > Remco Gerlich > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor Thanks that solved my problem. I should have thought of that still a little green. Scott -- Scott Ralph Comboni http://www.zenplex.com http://www.zenplex.org http://tambora.zenplex.org From syrinx@simplecom.net Fri Apr 6 01:33:57 2001 From: syrinx@simplecom.net (Scott) Date: Thu, 05 Apr 2001 19:33:57 -0500 Subject: [Tutor] out of memory conditions Message-ID: <m23qctk16hte31dg1hh0e5htov6mi03uaa@4ax.com> If you're going to be using a LOT of memory, how do you make sure you don't run out? I did this as an experiment, in X (Gnome): x =3D 0 y =3D [] while 1: y.append(' ' * 1000000) x =3D x + 1 print x I thought this would raise an exception, but it didn't. When x got to about 163, I got thrown out of X. I redid 'startx', and everything seemed back to normal, except I couldn't run Agent newsreader under Wine. If you're going to be a memory-hog, do you just have to keep up with it yourself? From van@lindbergs.org Fri Apr 6 04:07:01 2001 From: van@lindbergs.org (VanL) Date: Thu, 05 Apr 2001 21:07:01 -0600 Subject: [Tutor] out of memory conditions References: <m23qctk16hte31dg1hh0e5htov6mi03uaa@4ax.com> Message-ID: <3ACD32D5.B9C4A906@lindbergs.org> > I did this as an experiment, in X (Gnome): > > x = 0 > y = [] > while 1: > y.append(' ' * 1000000) > x = x + 1 > print x > > I thought this would raise an exception, but it didn't. > > When x got to about 163, I got thrown out of X. I redid 'startx', and > everything seemed back to normal, except I couldn't run Agent > newsreader under Wine. This is interesting.... >>> y = [] >>> for x in range(1000): ... y.append(' ' * 10000000) ... print x ... 0 1 2 3 4 [snip] 61 62 63 64 Traceback (most recent call last): File "<stdin>", line 2, in ? MemoryError >>> y = 1 (Memory is freed. Memory consumption drops by ~650 MB) Of course, this is on Win2K, with a hard limit on the size of my swapfile. Are you using a swapfile or swap partition? Linux or a BSD? -VanL From syrinx@simplecom.net Fri Apr 6 03:08:58 2001 From: syrinx@simplecom.net (Scott) Date: Thu, 05 Apr 2001 21:08:58 -0500 Subject: [Tutor] out of memory conditions In-Reply-To: <3ACD32D5.B9C4A906@lindbergs.org> References: <m23qctk16hte31dg1hh0e5htov6mi03uaa@4ax.com> <3ACD32D5.B9C4A906@lindbergs.org> Message-ID: <f69qcto03tcl1kk7u9fqcf687sr4q32qit@4ax.com> >Of course, this is on Win2K, with a hard limit on the size of my >swapfile. Are you using a swapfile or swap partition? Linux or a BSD? 128 megs ram. Equal size swap partition. From wmperry@swbell.net Fri Apr 6 04:19:10 2001 From: wmperry@swbell.net (William Perry) Date: Thu, 05 Apr 2001 22:19:10 -0500 Subject: [Tutor] User selections question Message-ID: <200104052219100830.00A74303@mail.swbell.net> --=====_98652715029358=_ Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Obligatory background "stuff "; I'm still new at this programing hobby and all self-taught. I've gone thru= Alan's online tutorial, Teach Yourself Python in 24 hrs, most of Learning= Python and the Tutorial packaged with Python (and hung around this list= about 6 months). I wanted to try writing something from scratch to see if= any of it had sunk in. It appears it did because what was to be a simple function has grown into 4= stand alone modules that properly combined will actually automate a very= boring task where I work. At least according to the 'alpha testers' at the= job who are clamoring for a finished product. The problem; I have a working function that takes user selections and selects among the= sub-modules returning values to send to the final data module but it feels= clumsy. Since this is still after all a learning project I'm looking for= how to find the answer rather than the answer it's self. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D what I want to= do=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1)user selects from a listing of available functions 2)the selected functions run and return a list of values 3)the combine function processes the list to a final value 4)print to screen/printer =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D I'm hung up on step 1 This is what I came up with just playing with the idea. (yes I did do some= BASIC back in the late 70's ) def com_rate(): l=3D[] tst=3D1 y=3D99 print;print"enter area # for area to rate \n 1-area 1 \n 2-area 2" print "enter y to begin" print;print while tst: area=3Dinput("enter ") if area =3D=3D 1: res=3Darea1() l.append(res) elif area =3D=3D 2: res=3Darea2() l.append(res) elif area =3D=3D 99: combn(l) break else: tst=3D0 def area1(): out=3D11 return out def area2(): out=3D5 return out def combn(l): print l tst=3D0 return tst com_rate() ************************************Something else i= tried********************************** #! usr/bin/python def com_test(): l=3D[] print" Enter number of areas to be rated " arl=3Dinput("Enter ") print;print"enter area # for area to rate \n 1-area 1 \n 2-area 2" for ar in range (arl): ar=3Dinput("? ") l.append (ar) print l com_test() (and like even less) --=====_98652715029358=_ Content-Type: text/html; charset="us-ascii" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 5.50.4611.1300" name=GENERATOR></HEAD> <BODY style="FONT-FAMILY: Arial" text=#000000 bgColor=#ffffff> <DIV><FONT size=2>Obligatory background "stuff ";</FONT></DIV> <DIV> </DIV> <DIV><FONT size=2>I'm still new at this programing hobby and all self-taught. I've gone thru Alan's online tutorial, Teach Yourself Python in 24 hrs, most of Learning Python and the Tutorial packaged with Python (and hung around this list about 6 months). I wanted to try writing something from scratch to see if any of it had sunk in.</FONT></DIV> <DIV> </DIV> <DIV><FONT size=2>It appears it did because what was to be a simple function has grown into 4 stand alone modules that properly combined will actually automate a very boring task where I work. At least according to the 'alpha testers' at the job who are clamoring for a finished product.</FONT></DIV> <DIV> </DIV> <DIV><FONT size=2>The problem;</FONT></DIV> <DIV> </DIV> <DIV><FONT size=2>I have a working function that takes user selections and selects among the sub-modules returning values to send to the final data module but it feels clumsy. Since this is still after all a learning project I'm looking for how to find the answer rather than the answer it's self.</FONT></DIV> <DIV> </DIV> <DIV><FONT size=2>=================== what I want to do============</FONT></DIV> <DIV> </DIV> <DIV><FONT size=2>1)user selects from a listing of available functions<BR>2)the selected functions run and return a list of values<BR>3)the combine function processes the list to a final value<BR>4)print to screen/printer<BR>=======================================================</FONT></DIV> <DIV> </DIV> <DIV><FONT size=2>I'm hung up on step 1</FONT></DIV> <DIV> </DIV><FONT size=2> <DIV><BR>This is what I came up with just playing with the idea. (yes I did do some BASIC back in the late 70's )</DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV>def com_rate():<BR> l=[]<BR> tst=1<BR> y=99<BR> print;print"enter area # for area to rate \n 1-area 1 \n 2-area 2"<BR> print "enter y to begin"<BR> print;print<BR> while tst:<BR> <BR> area=input("enter ")<BR> if area == 1:<BR> res=area1()<BR> l.append(res)<BR> elif area == 2:<BR> res=area2()<BR> l.append(res)<BR> elif area == 99:<BR> combn(l)<BR> break<BR> else:<BR> tst=0</DIV> <DIV> </DIV> <DIV>def area1():<BR> out=11<BR> return out</DIV> <DIV> </DIV> <DIV>def area2():<BR> out=5<BR> return out</DIV> <DIV> </DIV> <DIV>def combn(l):<BR> print l<BR> tst=0<BR> return tst<BR> <BR>com_rate()</DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV>************************************Something else i tried**********************************</DIV> <DIV> </DIV> <DIV>#! usr/bin/python</DIV> <DIV> </DIV> <DIV>def com_test():<BR> l=[]<BR> print" Enter number of areas to be rated "<BR> arl=input("Enter ")<BR> print;print"enter area # for area to rate \n 1-area 1 \n 2-area 2"<BR> for ar in range (arl):<BR> ar=input("? ")<BR> l.append (ar) <BR> <BR> print l</DIV> <DIV> </DIV> <DIV>com_test()</DIV> <DIV> </DIV> <DIV><BR> <BR> <BR> <BR>(and like even less)</FONT></DIV></BODY></HTML> --=====_98652715029358=_-- From tutor@python.org Fri Apr 6 07:09:12 2001 From: tutor@python.org (Tim Peters) Date: Fri, 6 Apr 2001 02:09:12 -0400 Subject: [Tutor] out of memory conditions In-Reply-To: <m23qctk16hte31dg1hh0e5htov6mi03uaa@4ax.com> Message-ID: <LNBBLJKPBEHFEDALKOLCIEIJJKAA.tim.one@home.com> [Scott] > If you're going to be using a LOT of memory, how do you make sure you > don't run out? It depends on the platform. Python raises MemoryError whenever the system malloc function returns NULL (as VanL demonstrated on Win2K). It appears to be "a feature" of Linux that malloc may return a non-NULL pointer even if there's no memory left, based on swapfile heuristics that don't always work. You can complain about that to the Linux developers, but there's nothing Python can do about it on its own. > ... > If you're going to be a memory-hog, do you just have to keep up with > it yourself? You're peering over the edge of a very deep pit. You can dive in headfirst or leap back to safety, just don't stand there staring too long <0.9 wink>. From dyoo@hkn.eecs.berkeley.edu Fri Apr 6 08:30:01 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 6 Apr 2001 00:30:01 -0700 (PDT) Subject: [Tutor] out of memory conditions In-Reply-To: <m23qctk16hte31dg1hh0e5htov6mi03uaa@4ax.com> Message-ID: <Pine.LNX.4.21.0104052229100.15398-100000@hkn.eecs.berkeley.edu> On Thu, 5 Apr 2001, Scott wrote: > > If you're going to be using a LOT of memory, how do you make sure you > don't run out? > > I thought this would raise an exception, but it didn't. > > When x got to about 163, I got thrown out of X. I redid 'startx', and > everything seemed back to normal, except I couldn't run Agent > newsreader under Wine. Hmmm... Strange! Which version of Python? Also, if you're running a Linux 2.4 kernel, I believe that under extreme stress, the Linux kernel will try killing processes to keep the system from going down. From wong_chow_cheok@hotmail.com Fri Apr 6 09:37:25 2001 From: wong_chow_cheok@hotmail.com (wong chow cheok) Date: Fri, 06 Apr 2001 16:37:25 +0800 Subject: [Tutor] (no subject) Message-ID: <F102LoygXLsxpTljBOh00000d58@hotmail.com> hai chow cheok here again. this is a program i wrote import re import urllib import sys import string name={'AS':'Alor Setar '} if sys.argv[1]==["upper()"]: p=re.compile('min:\s\s\d\d\s.^*', re.IGNORECASE) q=re.compile('max:\s\s\d\d\s.^*', re.IGNORECASE) a=re.compile('whole day^*|morning^*|afternoon^*|evening^*', re.IGNORECASE) b=re.compile('fcastimg/(.*?).gif^*', re.IGNORECASE) html=urllib.urlopen("http://www.kjc.gov.my/cgi-bin/fcastdisplay.cgi?lang=EN&loc="+sys.argv[1]).read() mintemp=p.search(html) maxtemp=q.search(html) time=a.search(html) con=b.search(html) print 'Temperature for ',name[sys.argv[1]], mintemp.group(),'and ', maxtemp.group() print 'Weather for the day is ',con.groups(1)[0],'in the ', time.group() else: print 'all caps' what i want to do is to make sure my argument variable is in caps. if it is not it will return an error message. for example when i type in 'python weather AS' it will return the weather output but 'python weather as' will return 'all caps'. also is there anyway to make sure i don't type the wrong argument variable. for example if i type python weather USA, it is caps but out of my range. a few pointers would be great. any help is very appreciated. thank you. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From dyoo@hkn.eecs.berkeley.edu Fri Apr 6 10:37:52 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 6 Apr 2001 02:37:52 -0700 (PDT) Subject: [Tutor] User selections question In-Reply-To: <200104052219100830.00A74303@mail.swbell.net> Message-ID: <Pine.LNX.4.21.0104060211120.20017-100000@hkn.eecs.berkeley.edu> On Thu, 5 Apr 2001, William Perry wrote: > =================== what I want to do============ > > 1)user selects from a listing of available functions > 2)the selected functions run and return a list of values > 3)the combine function processes the list to a final value > 4)print to screen/printer > ======================================================= > > I'm hung up on step 1 > > > This is what I came up with just playing with the idea. (yes I did do > some BASIC back in the late 70's No problem. I have somewhat fond memories of using Basic too. Let's take a look at your program. > def com_rate(): > l=[] > tst=1 > y=99 > print;print"enter area # for area to rate \n 1-area 1 \n 2-area 2" > print "enter y to begin" > print;print > while tst: > > area=input("enter ") > if area == 1: > res=area1() > l.append(res) > elif area == 2: > res=area2() > l.append(res) > elif area == 99: > combn(l) > break > else: > tst=0 The indentation of the code feels a little weird to me; it might be better to indent this like: while tst: area = input("enter ") if area == 1: res = area1() l.append(res) ... When I tried entering your code, it complained of a "inconsistent dedent", which means that Python expects code that follows an if statement to be more indented. Otherwise, what you have looks ok, as long as there are only two choices. But as you add more choices, the code might become more unwieldy. If you really want to generalize the idea of choosing functions and combiners, it's possible by using a dictionary that, given the input(), returns back to us the appropriate function and combiner. Here's a related example that might help explain the idea: ### import sys def mult(): a = input('Enter a.') b = input('Enter b.') return a * b def concat(): a = input('Enter s1.') b = input('Enter s2.') return a + b def quit(): print "Goodbye" sys.quit() if __name__ == '__main__': command_functions = { 'multiply': mult, 'concatenate' : concat, 'quit': quit } while 1: print 'You have the following possible commands: ' print command_functions.keys(), '\n' cmd = input('Enter your choice: ') if command_functions.has_key(cmd): function = command_functions[cmd] print function() ### The idea is that if we need to extend the commands that our program should understand, we only need to add an entry to the command_functions dictionary --- we don't even need to touch program logic! We can even extend this style of programming to use the appropriate combiner of the function's results --- we can have something like: ### command_functions = { 1 : (area1, l.append), 2 : (area2, l.append), 99: (get_l, combn) } # Assume that get_l is some sort of function that returns l. while 1: area = input("enter ") if command_functions.has_key(area): function, combiner = command_functions[area] result = function() combiner(result) else: break ### which, with some fiddling, should have the same behavior as what you had before. In any case, this idea is, admittedly, very weird, but it's very neat when it makes sense. *grin* If you have any questions, please feel free to ask us. Good luck! From turhan@incubatr.com Fri Apr 6 10:53:37 2001 From: turhan@incubatr.com (Turhan Arun) Date: Fri, 6 Apr 2001 12:53:37 +0300 Subject: [Tutor] Date subtraction Message-ID: <B42024B9769B8040919060B0BDB0C2C407A40C@exchange.incubatr.com> This is a multi-part message in MIME format. ------_=_NextPart_001_01C0BE7F.7348B557 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I just started learning python... Now, my question is: I want to have a user enter a date in format dd/mm/YYYY like 06/04/2001 and another date in the same format like 22/04/2001 depending on these two inputs. I just want to create a list of date strings like ['06/04/2001','07/04/2001','08/04/2001'....] It will be great if you could give some idea. Thanks, Turhan Arun ------_=_NextPart_001_01C0BE7F.7348B557 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Diso-8859-1"> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 6.0.4417.0"> <TITLE>Date subtraction</TITLE> </HEAD> <BODY> <!-- Converted from text/plain format --> <P><TT><FONT SIZE=3D2>Hi all,</FONT></TT> <BR><TT><FONT SIZE=3D2>I just started learning python...</FONT></TT> <BR><TT><FONT SIZE=3D2>Now, my question is:</FONT></TT> <BR><TT><FONT SIZE=3D2>I want to have a user enter a date in format = dd/mm/YYYY like 06/04/2001</FONT></TT> <BR><TT><FONT SIZE=3D2>and another date in the same format like = 22/04/2001</FONT></TT> <BR><TT><FONT SIZE=3D2>depending on these two inputs. I just want to = create a list of date strings like</FONT></TT> <BR><TT><FONT = SIZE=3D2>['06/04/2001','07/04/2001','08/04/2001'....]</FONT></TT> <BR><TT><FONT SIZE=3D2>It will be great if you could give some = idea.</FONT></TT> </P> <P><TT><FONT SIZE=3D2>Thanks,</FONT></TT> <BR><TT><FONT SIZE=3D2>Turhan Arun</FONT></TT> </P> </BODY> </HTML> ------_=_NextPart_001_01C0BE7F.7348B557-- From dyoo@hkn.eecs.berkeley.edu Fri Apr 6 11:08:54 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 6 Apr 2001 03:08:54 -0700 (PDT) Subject: [Tutor] Date subtraction In-Reply-To: <B42024B9769B8040919060B0BDB0C2C407A40C@exchange.incubatr.com> Message-ID: <Pine.LNX.4.21.0104060300310.21369-100000@hkn.eecs.berkeley.edu> On Fri, 6 Apr 2001, Turhan Arun wrote: > Hi all, > I just started learning python... > Now, my question is: > I want to have a user enter a date in format dd/mm/YYYY like 06/04/2001 > and another date in the same format like 22/04/2001 > depending on these two inputs. I just want to create a list of date > strings like > ['06/04/2001','07/04/2001','08/04/2001'....] > It will be great if you could give some idea. It sounds like using the string.split() function will be useful for you. string.split() takes in a string, as well as a "delimiter" string, and it tries to break down a string into a list of smaller strings: ### >>> import string >>> string.split('www.python.org', '.') ['www', 'python', 'org'] >>> string.split('06/04/2001', '.') ['06/04/2001'] # Whoops, the delimiter matters! >>> string.split('06/04/2001', '/') ['06', '04', '2001'] ### By using string.split(), it'll be easier to get the "day" part of any date. If you want more formal documentation: http://python.org/doc/current/lib/module-string.html talks about many of the things that you can do with strings. By the way, if you're going to be "adding" days to your date, you'll probably need to turn your day string into a number first, just so the addition works out. Here's a small interpreter session that explores what this means: ### >>> '06' + 1 Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: illegal argument type for built-in operation >>> int('06') + 1 7 >>> str(int('06') + 1) '7' >>> string.zfill(int('06') + 1, 2) '07' ### The last part is a function called string.zfill() --- it's a function that takes a number, and turns it back into a string, while padding it with left zeros if it needs them. Good luck to you! From dyoo@hkn.eecs.berkeley.edu Fri Apr 6 11:19:46 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 6 Apr 2001 03:19:46 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <F102LoygXLsxpTljBOh00000d58@hotmail.com> Message-ID: <Pine.LNX.4.21.0104060309170.21369-100000@hkn.eecs.berkeley.edu> On Fri, 6 Apr 2001, wong chow cheok wrote: > hai chow cheok here again. this is a program i wrote > > import re > import urllib > import sys > import string > > name={'AS':'Alor Setar '} > if sys.argv[1]==["upper()"]: > p=re.compile('min:\s\s\d\d\s.^*', re.IGNORECASE) > q=re.compile('max:\s\s\d\d\s.^*', re.IGNORECASE) > a=re.compile('whole day^*|morning^*|afternoon^*|evening^*', > re.IGNORECASE) > b=re.compile('fcastimg/(.*?).gif^*', re.IGNORECASE) > > html=urllib.urlopen("http://www.kjc.gov.my/cgi-bin/fcastdisplay.cgi?lang=EN&loc="+sys.argv[1]).read() > mintemp=p.search(html) > maxtemp=q.search(html) > time=a.search(html) > con=b.search(html) > print 'Temperature for ',name[sys.argv[1]], mintemp.group(),'and ', > maxtemp.group() > print 'Weather for the day is ',con.groups(1)[0],'in the ', time.group() > > else: > print 'all caps' > > what i want to do is to make sure my argument variable is in caps. if it is > not it will return an error message. for example when i type in One way to check if something is in capitals is to compare a particular string with its capitalized form. In Python 2.0, we can write the following code: ### >>> mailing_list = 'tutor@python.org' >>> if mailing_list.upper() == mailing_list: ... print 'ok' ... else: ... print 'all caps' ... all caps >>> shouting = 'TUTOR@PYTHON.ORG' >>> if shouting.upper() == shouting: ... print 'ok' ... else: ... print 'all caps' ... ok ### If you're using Python 1.52, the function string.upper() will also work to convert a string to all caps. > also is there anyway to make sure i don't type the wrong argument variable. > for example if i type > > python weather USA, it is caps but out of my range. a few pointers would be > great. Sure! If the search is unsuccessful, the search()ing function of your regular expressions will return the None value to show that it wasn't able to find anything. http://python.org/doc/current/lib/Contents_of_Module_re.html mentions this briefly. With this, we can check for these missing values in several ways: if mintemp == None or maxtemp == None or time == None or con == None: ... is one way to do it. However, there's a nice Python idiom to say this: if None in [mintemp, maxtemp, time, con]: ... Hope this helps! From scarblac@pino.selwerd.nl Fri Apr 6 11:36:00 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Fri, 6 Apr 2001 12:36:00 +0200 Subject: [Tutor] Date subtraction In-Reply-To: <B42024B9769B8040919060B0BDB0C2C407A40C@exchange.incubatr.com>; from turhan@incubatr.com on Fri, Apr 06, 2001 at 12:53:37PM +0300 References: <B42024B9769B8040919060B0BDB0C2C407A40C@exchange.incubatr.com> Message-ID: <20010406123600.A19531@pino.selwerd.nl> On 0, Turhan Arun <turhan@incubatr.com> wrote: > Hi all, > I just started learning python... > Now, my question is: > I want to have a user enter a date in format dd/mm/YYYY like 06/04/2001 > and another date in the same format like 22/04/2001 > depending on these two inputs. I just want to create a list of date > strings like > ['06/04/2001','07/04/2001','08/04/2001'....] > It will be great if you could give some idea. Two things: you need to parse a date, and you need to do arithmetic with it. Parsing. The good news is that the Python standard library has the very cool time.strptime() function. The bad news is that it's only available on (most) types of Unix. Luckily someone has made an implementation in Python, so if you don't have a Unix system you can get http://www.fukt.hk-r.se/~flognat/hacks/strptime.py and use that. This then looks like import time # Or import strptimeif you use that datestr = raw_input("Give date:") date = time.strptime(datestr, "%d/%m/%Y") # See library ref of strftime for # possible format strings # use strptime.strptime in the case # of the module You know have a date in tuple format that the other time functions can use. time.mktime(date) gives the date in seconds since 1970 (Unix time). time.strftime("%d/%m/%Y", date) gives the same string back. Arithmetic. The naive way to add a day to the date is to simply add a day's worth a seconds to the seconds since 1970, then print that date. We get something like import time date1 = "06/04/2001" date2 = "22/04/2001" format = "%d/%m/%Y" date1_s = time.mktime(time.strptime(date1, format)) # Get seconds date2_s = time.mktime(time.strptime(date2, format)) if date2_s < date1_s: raise ValueError # Second date can't be earlier current = date1_s datelist = [] while 1: date = time.strftime(format, time.localtime(current)) # String from secs datelist.append(date) if (date == date2) or (current > date2_s): break current += 24*60*60 # Add one day print datelist (this is untested) This is naive because there may be things like leap seconds and whatnot, breaking this code. mxDateTime is a package that's intended for handling date arithmetic, so if you want a great program you should look at that. I never used it myself, but it has a great reputation: http://www.lemburg.com/files/python/mxDateTime.html -- Remco Gerlich From alan.gauld@bt.com Fri Apr 6 11:54:45 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 6 Apr 2001 11:54:45 +0100 Subject: [Tutor] Date subtraction Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6C0@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0BE87.FE0385C0 Content-type: text/plain; charset="iso-8859-1" Look at the time module. > I want to have a user enter a date in format > dd/mm/YYYY like 06/04/2001 and another date > in the same format like 22/04/2001 Here is some pseudo code: #------------- start = raw_inpu('start date dd/mm/yyyy ') end = raw_input('end date dd/mm/yyyy ') startTime = convert time string to time value endTime = convert time string to time value times = [] timestrings = [] newTime = startTime while newTime < end: times.append(newTime) newTime = newTime + 1 day for t in times: str = convert t to time string timestrings.append(str) #-------------- The time module contains all the bits you need to do the conversions. HTH, Alan G ------_=_NextPart_001_01C0BE87.FE0385C0 Content-type: text/html; charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <TITLE>Date subtraction</TITLE> <META content="MSHTML 5.00.3013.2600" name=GENERATOR></HEAD> <BODY> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=110525010-06042001>Look at the time module.</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=110525010-06042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff><FONT face=Arial><TT><SPAN class=110525010-06042001>> </SPAN>I want to have a user enter a date in format <SPAN class=110525010-06042001> </SPAN></TT></FONT></FONT></DIV> <DIV><FONT color=#0000ff><FONT face=Arial><TT><SPAN class=110525010-06042001>> </SPAN>dd/mm/YYYY like 06/04/2001</TT> <TT>and another date <SPAN class=110525010-06042001> </SPAN></TT></FONT></FONT></DIV> <DIV><FONT color=#0000ff><FONT face=Arial><TT><SPAN class=110525010-06042001>> </SPAN>in the same format like 22/04/2001</TT> <BR><FONT size=2><SPAN class=110525010-06042001> </SPAN></FONT></FONT></FONT></DIV> <DIV><FONT color=#0000ff><SPAN class=110525010-06042001><FONT face="Courier New" size=2>Here is some pseudo code:</FONT></SPAN></FONT></DIV> <DIV><FONT color=#0000ff><SPAN class=110525010-06042001></SPAN></FONT> </DIV> <DIV><FONT face="Courier New"><FONT color=#0000ff size=2><SPAN class=110525010-06042001>#------------- </SPAN></FONT></FONT></DIV><TT><SPAN class=110525010-06042001><FONT color=#0000ff></FONT></SPAN></TT> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>start = raw_inpu('start date dd/mm/yyyy ')</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>end = raw_input('end date dd/mm/yyyy ')</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>startTime = convert time string to time value</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>endTime = convert time string to time value</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001></SPAN></TT></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>times = []</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>timestrings = []</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>newTime = startTime</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>while newTime < end:</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001> times.append(newTime)</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001> newTime = newTime + 1 day</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001></SPAN></TT></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>for t in times:</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001> str = convert t to time string</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001> timestrings.append(str)</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001></SPAN></TT></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>#--------------</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>The time module contains all the bits you need to do the conversions.</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001></SPAN></TT></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>HTH,</SPAN></TT></FONT></DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001></SPAN></TT></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial><TT><SPAN class=110525010-06042001>Alan G</SPAN></TT></FONT></DIV> <BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"> <P> </P></BLOCKQUOTE></BODY></HTML> ------_=_NextPart_001_01C0BE87.FE0385C0-- From tirakala@yahoo.com Fri Apr 6 13:12:45 2001 From: tirakala@yahoo.com (mohan tirakala) Date: Fri, 6 Apr 2001 05:12:45 -0700 (PDT) Subject: [Tutor] send me vb tutor Message-ID: <20010406121245.3856.qmail@web13607.mail.yahoo.com> respective sir pliase send me vb tutor and turorial __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ From wheelege@tsn.cc Fri Apr 6 13:47:39 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Fri, 6 Apr 2001 22:47:39 +1000 Subject: [Tutor] urllib, urlopen and the evil frames References: <Pine.LNX.4.21.0104060309170.21369-100000@hkn.eecs.berkeley.edu> Message-ID: <002601c0be97$c49c7160$0200a8c0@ACE> Hi all, I've noticed alot of use of Urllib lately and I thought it would be funky to be able to navigate around and pass arguments to cgi scripts through a python script. But I've hit a kind of snag. Basically, this is what I am looking at wanting to do... 1. Log into server 2. Navigate to a page with some prices 3. Take the page html code as input then.. 4. Use regular expressions to tell the user of the prices, then do what they tell you -OR- 4. Go into complete auto-mode and do some buying, selling, etc based on some rules and things like that. This is for an online game, before any of you suspicious types start looking my direction :) And no it's not bad to do it on this game server....I think. Anyway, I've gotten past step 1, and I logged in by just passing arguments to a few cgi scripts in an order using urllip.urlopen but when I get to navigating around in step 2 I just get returned (through ye olde urllib) 'blah blah This browser does not support frames'. So I thought 'bah who needs that page anyway' and then tried to access the market cgi-script using urlopen but then it spits at me saying I haven't logged in yet. So now I'm stuck. Surely there must be a way to just go 'look website, I don't care about frames just let me take all the source you've got, I don't care how many frames/html files you have'. Thanks guys, Glen. From wheelege@tsn.cc Fri Apr 6 14:18:02 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Fri, 6 Apr 2001 23:18:02 +1000 Subject: [Tutor] webbrowser module, weird weird behaviour Message-ID: <006801c0be9c$039d7400$0200a8c0@ACE> This is a multi-part message in MIME format. ------=_NextPart_000_0065_01C0BEEF.D3E909A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello everyone again, I thought my anguish was for naught when I was looking through the = docs and located the module 'webbrowser' however this module appeared to = do nothing, and in fact had a very strange characteristic...to me at = least. Here is my interpreter session : >>> import webbrowser >>> dir(webbrowser) ['__builtins__', '__doc__', '__file__', '__name__', 'webbrowser'] >>> dir(webbrowser.__doc__) [] ## expected.... >>> dir(webbrowser.webbrowser) ['__builtins__', '__doc__', '__file__', '__name__', 'webbrowser'] >>> dir(webbrowser.webbrowser.webbrowser) ['__builtins__', '__doc__', '__file__', '__name__', 'webbrowser'] >>> dir(webbrowser.webbrowser.webbrowser.webbrowser.webbrowser) ['__builtins__', '__doc__', '__file__', '__name__', 'webbrowser'] ## = yup I'm confused :) >>> dir() ['__builtins__', '__doc__', '__name__', 'pywin', 'webbrowser'] >>> dir(pywin) ['__builtins__', '__doc__', '__file__', '__name__', '__path__', = 'debugger', 'framework', 'idle', 'mfc', 'scintilla', 'sys', 'tools'] >>> import time ## I thought I'd check if it was normal for modules to = do the recursive dir dance... >>> dir() ['__builtins__', '__doc__', '__name__', 'pywin', 'time', 'webbrowser'] =20 >>> dir(time) ['__doc__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', = 'ctime', 'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', = 'strftime', 'time', 'timezone', 'tzname'] >>> dir(time.time) ['__doc__', '__name__', '__self__'] ## nope behaves as expected... >>>=20 So, well though this doesn't have anything to really do with the = function of the webbrowser module or how to use it, I think it's still = curious and worth posting...can anyone plz explain?? Thanks, Glen. ------=_NextPart_000_0065_01C0BEEF.D3E909A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV> Hello everyone again,</DIV> <DIV> </DIV> <DIV> I thought my anguish was for naught when I was looking = through the=20 docs and located the module 'webbrowser' however this module appeared to = do=20 nothing, and in fact had a very strange characteristic...to me at = least. =20 Here is my interpreter session :</DIV> <DIV> </DIV> <DIV><FONT size=3D3>>>> import webbrowser</FONT></DIV> <DIV>>>> dir(webbrowser)<BR>['__builtins__', '__doc__', = '__file__',=20 '__name__', 'webbrowser']<BR>>>> = dir(webbrowser.__doc__)<BR>[] ##=20 expected....<BR>>>> = dir(webbrowser.webbrowser)<BR>['__builtins__',=20 '__doc__', '__file__', '__name__', 'webbrowser']<BR>>>>=20 dir(webbrowser.webbrowser.webbrowser)<BR>['__builtins__', '__doc__', = '__file__',=20 '__name__', 'webbrowser']<BR>>>>=20 dir(webbrowser.webbrowser.webbrowser.webbrowser.webbrowser)<BR>['__builti= ns__',=20 '__doc__', '__file__', '__name__', 'webbrowser'] ## yup I'm = confused=20 :)<BR>>>> dir()<BR>['__builtins__', '__doc__', '__name__', = 'pywin',=20 'webbrowser']<BR>>>> dir(pywin)<BR>['__builtins__', '__doc__',=20 '__file__', '__name__', '__path__', 'debugger', 'framework', 'idle', = 'mfc',=20 'scintilla', 'sys', 'tools']<BR>>>> import time ## I = thought I'd=20 check if it was normal for modules to do the recursive dir=20 dance...<BR>>>> dir()<BR>['__builtins__', '__doc__', = '__name__',=20 'pywin', 'time', 'webbrowser'] <BR>>>> = dir(time)<BR>['__doc__',=20 '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', 'ctime', = 'daylight',=20 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'time', = 'timezone',=20 'tzname']<BR>>>> dir(time.time)<BR>['__doc__', '__name__',=20 '__self__'] ## nope behaves as expected...<BR>>>> </DIV> <DIV> </DIV> <DIV> So, well though this doesn't have anything to really do with = the=20 function of the webbrowser module or how to use it, I think it's still = curious=20 and worth posting...can anyone plz explain??</DIV> <DIV> </DIV> <DIV> Thanks,</DIV> <DIV> Glen.</DIV></BODY></HTML> ------=_NextPart_000_0065_01C0BEEF.D3E909A0-- From syrinx@simplecom.net Fri Apr 6 13:35:45 2001 From: syrinx@simplecom.net (Scott) Date: Fri, 06 Apr 2001 07:35:45 -0500 Subject: [Tutor] out of memory conditions In-Reply-To: <Pine.LNX.4.21.0104052229100.15398-100000@hkn.eecs.berkeley.edu> References: <m23qctk16hte31dg1hh0e5htov6mi03uaa@4ax.com> <Pine.LNX.4.21.0104052229100.15398-100000@hkn.eecs.berkeley.edu> Message-ID: <otdrctg6693dp6nhl637pa4io9e0pvl6ao@4ax.com> >Hmmm... Strange! Which version of Python? This is python 1.5.2, Redhat Linux 7.0 (perhaps the single buggest dist release in Linux history). From kalle@gnupung.net Fri Apr 6 14:48:11 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Fri, 6 Apr 2001 15:48:11 +0200 Subject: [Tutor] webbrowser module, weird weird behaviour In-Reply-To: <006801c0be9c$039d7400$0200a8c0@ACE>; from wheelege@tsn.cc on Fri, Apr 06, 2001 at 11:18:02PM +1000 References: <006801c0be9c$039d7400$0200a8c0@ACE> Message-ID: <20010406154811.A16170@father> Sez Glen Wheeler: > Hello everyone again, > > I thought my anguish was for naught when I was looking through the docs > and located the module 'webbrowser' however this module appeared to do > nothing, and in fact had a very strange characteristic...to me at least. > Here is my interpreter session : > > >>> import webbrowser > >>> dir(webbrowser) > ['__builtins__', '__doc__', '__file__', '__name__', 'webbrowser'] That's some funky sh*t! I've never seen that behavior, but I'm limited to one platform (GNU/Linux). What's your platform and Python version? Anyway, check http://www.python.org/doc/current/lib/module-webbrowser.html (URL from memory...) for what it's supposed to do. I've read your previous message, btw, but I have no time at the moment. Will try to get a reply out tonight. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From wheelege@tsn.cc Fri Apr 6 14:49:00 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Fri, 6 Apr 2001 23:49:00 +1000 Subject: [Tutor] webbrowser module, weird weird behaviour References: <006801c0be9c$039d7400$0200a8c0@ACE> <20010406154811.A16170@father> Message-ID: <001301c0bea0$56d1aac0$0200a8c0@ACE> It is a little strange isn't it...thanks for the incoming reply :) I'm running win98 here. ----- Original Message ----- From: Kalle Svensson <kalle@gnupung.net> To: <tutor@python.org> Sent: Friday, April 06, 2001 11:48 PM Subject: Re: [Tutor] webbrowser module, weird weird behaviour > Sez Glen Wheeler: > > Hello everyone again, > > > > I thought my anguish was for naught when I was looking through the docs > > and located the module 'webbrowser' however this module appeared to do > > nothing, and in fact had a very strange characteristic...to me at least. > > Here is my interpreter session : > > > > >>> import webbrowser > > >>> dir(webbrowser) > > ['__builtins__', '__doc__', '__file__', '__name__', 'webbrowser'] > > That's some funky sh*t! I've never seen that behavior, but I'm limited to > one platform (GNU/Linux). What's your platform and Python version? > > Anyway, check http://www.python.org/doc/current/lib/module-webbrowser.html > (URL from memory...) for what it's supposed to do. > > I've read your previous message, btw, but I have no time at the moment. > Will try to get a reply out tonight. > > Peace, > Kalle > -- > Email: kalle@gnupung.net | You can tune a filesystem, but you > Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) > PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD > [ Not signed due to lossage. Blame Microsoft Outlook Express. ] > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From dsh8290@rit.edu Fri Apr 6 16:40:54 2001 From: dsh8290@rit.edu (D-Man) Date: Fri, 6 Apr 2001 11:40:54 -0400 Subject: [Tutor] out of memory conditions In-Reply-To: <Pine.LNX.4.21.0104052229100.15398-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Fri, Apr 06, 2001 at 12:30:01AM -0700 References: <m23qctk16hte31dg1hh0e5htov6mi03uaa@4ax.com> <Pine.LNX.4.21.0104052229100.15398-100000@hkn.eecs.berkeley.edu> Message-ID: <20010406114054.A12699@harmony.cs.rit.edu> On Fri, Apr 06, 2001 at 12:30:01AM -0700, Daniel Yoo wrote: | | Also, if you're running a Linux 2.4 kernel, I believe that under extreme | stress, the Linux kernel will try killing processes to keep the system | from going down. Just for another data point, I was using Gnumeric on RH7 a while back. I clicked that button in the upper left corner to select all cells, then changed some properties (size, font, etc). When I went to save my work, it took a very long time. I got a snack, came back, and was at the GDM login screen. This was kernel 2.2.16. I tried again, but used gtop to see what was happening. Gnumeric's memory usage keep increasing till the system booted me. It must have thought I wasn't playing nice with the other users (umm, which users?) ;-). -D From alan.gauld@bt.com Fri Apr 6 16:29:08 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 6 Apr 2001 16:29:08 +0100 Subject: [Tutor] Tkinter topic completed Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6C6@mbtlipnt02.btlabs.bt.co.uk> I've just uploaded the final (at least so far as technical content goes) GUI tutor topic to my web site. It is now linked from the contents frame If anyone has comments I'm pleased to receive them, particularly on the wxPython section since I don't use wxPython much (altho' I might now that I've started :-) http://www.crosswinds.net/~agauld/tutgui.htm Enjoy, Alan G From alan.gauld@bt.com Fri Apr 6 16:57:31 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 6 Apr 2001 16:57:31 +0100 Subject: [Tutor] send me vb tutor Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6C8@mbtlipnt02.btlabs.bt.co.uk> > pliase send me vb tutor and turorial I'm afraid this is a mailing list for those learning the Python language. You might have a better chance of locating a VB tutor on a VB mailing list or news group. Alternatively try the various web search engines. For example Yahoo has a comprehensive list of programming tutorials, I'm sure you can find a VB one there. On the other hand, why not try Python? :-) http://www.python.org/ Alan G. From alan.gauld@bt.com Fri Apr 6 17:05:48 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 6 Apr 2001 17:05:48 +0100 Subject: [Tutor] urllib, urlopen and the evil frames Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6C9@mbtlipnt02.btlabs.bt.co.uk> > in step 2 I just get returned (through ye olde urllib) > 'blah blah This browser does not support frames'. > needs that page anyway' and then tried to access the market > cgi-script using urlopen but then it spits at me saying I > haven't logged in yet. > So now I'm stuck. Surely there must be a way to just go > 'look website, I don't care about frames You'll need to go to the site with a Frames equipped browser and open the login frame in a separate window. That should give you the url of the real login page. Then use that to login programmatically (using urllib) then (somehow... anyone?) catch the cookie which presumably is being sent back to the 'browser' ... Using that cookie you can (probably) get access to the cgi page. If you are really lucky they aren't using cookies and just hidden fields but thats unlikely... HTH, Alan g. From samus@feudalkingdoms.tzo.org Fri Apr 6 17:59:11 2001 From: samus@feudalkingdoms.tzo.org (Sam Corder) Date: Fri, 06 Apr 2001 16:59:11 +0000 Subject: [Tutor] webbrowser module, weird weird behaviour Message-ID: <E14lZbO-0000gA-00@mail.python.org> If all you want to do is control a web browser and you don't care about being cross platform ie is pretty easy to control using com. The nice thing about this approach is that ie lets you at the dom objects. You can do strange stuff from reparenting table rows to filling out forms and pressing buttons. Its not cross platform by any stretch but its pretty easy. I would also suggest getting the web developer accessories from MS. It lets you right click on a page and either view partial source (selected text) or view the document tree. Anyway just a suggestion on the easy way out for windows. The harder more cross platform way would be to dump the page into a dom parser keeping track of cookies and sending post data etc but that leaves you simulating a lot of a web browser just not the rendering engine. Anyway good luck. -Sam wheelege@tsn.cc, tutor@python.org wrote: > >It is a little strange isn't it...thanks for the incoming reply :) > I'm running win98 here. From kalle@gnupung.net Fri Apr 6 18:50:19 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Fri, 6 Apr 2001 19:50:19 +0200 Subject: [Tutor] urllib, urlopen and the evil frames In-Reply-To: <002601c0be97$c49c7160$0200a8c0@ACE>; from wheelege@tsn.cc on Fri, Apr 06, 2001 at 10:47:39PM +1000 References: <Pine.LNX.4.21.0104060309170.21369-100000@hkn.eecs.berkeley.edu> <002601c0be97$c49c7160$0200a8c0@ACE> Message-ID: <20010406195019.A374@apone.network.loc> Sez Glen Wheeler: > Anyway, I've gotten past step 1, and I logged in by just passing > arguments to a few cgi scripts in an order using urllip.urlopen but when I > get to navigating around in step 2 I just get returned (through ye olde > urllib) 'blah blah This browser does not support frames'. So I thought > 'bah who needs that page anyway' and then tried to access the market > cgi-script using urlopen but then it spits at me saying I haven't logged > in yet. This sounds like a cookie problem. I had aone like it a while ago, and I have some extremely undocumented, unsupported and application-specific code to send you if you're interested. Basically, I grab a cookie from the login page and then use that cookie to authenticate myself to the script I want to access. The frames problem is most easily solved by parsing the html and then urlopening the frame contents too. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From deirdre@deirdre.net Fri Apr 6 19:17:50 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Fri, 6 Apr 2001 11:17:50 -0700 (PDT) Subject: [Tutor] Date subtraction In-Reply-To: <B42024B9769B8040919060B0BDB0C2C407A40C@exchange.incubatr.com> Message-ID: <Pine.LNX.4.31.0104061109350.11374-100000@emperor.deirdre.org> On Fri, 6 Apr 2001, Turhan Arun wrote: > I want to have a user enter a date in format dd/mm/YYYY like 06/04/2001 > and another date in the same format like 22/04/2001 > depending on these two inputs. I just want to create a list of date > strings like > ['06/04/2001','07/04/2001','08/04/2001'....] > It will be great if you could give some idea. Convert them from those dates into numeric representations of dates using the time module: import time datea = '06/04/2001' dateb = '07/04/2001' tuplea= time.strptime(datea, '%m/%d/%Y') tupleb= time.strptime(dateb, '%m/%d/%Y') (etc) -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From scott@zenplex.com Fri Apr 6 19:53:46 2001 From: scott@zenplex.com (Scott Ralph Comboni) Date: 06 Apr 2001 14:53:46 -0400 Subject: [Tutor] reg expression substitution question Message-ID: <986583230.1285.11.camel@scoot.zenplex.com> I have used perl -p -i -e 's/someName/replaceName/g' <file name>. Is there a way to do this type of substitution with the re module? I have tried various ways but all I can come up with is this>> file = open('config.h').read() newfile = open('config.h.new','w') s = re.sub('8192', '32768', file) newfile.write(s) newfile.close() Is there a way I can just read and write to the same file? Thanks Scott -- Scott Ralph Comboni http://www.zenplex.com http://www.zenplex.org http://tambora.zenplex.org From dsh8290@rit.edu Fri Apr 6 21:21:28 2001 From: dsh8290@rit.edu (D-Man) Date: Fri, 6 Apr 2001 16:21:28 -0400 Subject: [Tutor] reg expression substitution question In-Reply-To: <986583230.1285.11.camel@scoot.zenplex.com>; from scott@zenplex.com on Fri, Apr 06, 2001 at 02:53:46PM -0400 References: <986583230.1285.11.camel@scoot.zenplex.com> Message-ID: <20010406162128.A14647@harmony.cs.rit.edu> On Fri, Apr 06, 2001 at 02:53:46PM -0400, Scott Ralph Comboni wrote: | | file = open('config.h').read() | newfile = open('config.h.new','w') | s = re.sub('8192', '32768', file) | newfile.write(s) | newfile.close() | | Is there a way I can just read and write to the same file? Same as in C : file = open( 'config.h' , 'r+' ) data = file.read() data = re.sub( '8192' , '32768' , data ) file.seek( 0 ) # go back to the begining file.write( data ) file.close() This, however, will have extra junk at the end of the file if the data to write to the file is shorter than the existing data. To solve that I would recommend the following : file = open( 'config.h' , 'r' ) # open in 'read' mode data = file.read() file.close() # we have all the data, let's close the file data = re.sub( ... ) file = open( 'config.h' , 'w' ) # open it for writing, note that the # file was just truncated to have length 0 file.write( data ) file.close() Perhaps using different names for the 'before' and 'after' file/data objects would be better... HTH, -D From scott@zenplex.com Fri Apr 6 21:49:01 2001 From: scott@zenplex.com (Scott Ralph Comboni) Date: 06 Apr 2001 16:49:01 -0400 Subject: [Tutor] reg expression substitution question In-Reply-To: <20010406162128.A14647@harmony.cs.rit.edu> References: <986583230.1285.11.camel@scoot.zenplex.com> <20010406162128.A14647@harmony.cs.rit.edu> Message-ID: <986590146.1134.1.camel@scoot.zenplex.com> Ok Now I understand that a little better. Thanks. Scott On 06 Apr 2001 16:21:28 -0400, D-Man wrote: > On Fri, Apr 06, 2001 at 02:53:46PM -0400, Scott Ralph Comboni wrote: > | > | file = open('config.h').read() > | newfile = open('config.h.new','w') > | s = re.sub('8192', '32768', file) > | newfile.write(s) > | newfile.close() > | > | Is there a way I can just read and write to the same file? > > Same as in C : > > file = open( 'config.h' , 'r+' ) > data = file.read() > data = re.sub( '8192' , '32768' , data ) > file.seek( 0 ) # go back to the begining > file.write( data ) > file.close() > > > This, however, will have extra junk at the end of the file if the data > to write to the file is shorter than the existing data. > > To solve that I would recommend the following : > > file = open( 'config.h' , 'r' ) # open in 'read' mode > data = file.read() > file.close() # we have all the data, let's close the file > > data = re.sub( ... ) > > file = open( 'config.h' , 'w' ) # open it for writing, note that the > # file was just truncated to have length 0 > file.write( data ) > file.close() > > > Perhaps using different names for the 'before' and 'after' file/data > objects would be better... > > HTH, > -D > > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Scott Ralph Comboni president Zenplex, Inc. 317 Madison Ave. Suite 1500 New York NY, 10017 212.499.0668 ext2219 http://www.zenplex.com http://www.zenplex.org http://tambora.zenplex.org From arcege@shore.net Fri Apr 6 21:58:19 2001 From: arcege@shore.net (Michael P. Reilly) Date: Fri, 6 Apr 2001 16:58:19 -0400 (EDT) Subject: [Tutor] reg expression substitution questiony In-Reply-To: <986583230.1285.11.camel@scoot.zenplex.com> from "Scott Ralph Comboni" at Apr 06, 2001 02:53:46 PM Message-ID: <200104062058.f36KwJd07430@dsl254-114-246.nyc1.dsl.speakeasy.net> Scott Ralph Comboni wrote > I have used perl -p -i -e 's/someName/replaceName/g' <file name>. Is > there a way to do this type of substitution with the re module? > I have tried various ways but all I can come up with is this>> > > file = open('config.h').read() > newfile = open('config.h.new','w') > s = re.sub('8192', '32768', file) > newfile.write(s) > newfile.close() > > Is there a way I can just read and write to the same file? > Thanks Scott There is no nice way to read and write to the same file (Perl doesn't do it - it moves the original out of the way first). Doing so creates seeking problems and possible bytes at the end of the file (if the new data is shorter). Python's equivalent of Perl's "-n" and "-p" (with -i) options is the fileinput module: import fileinput, re, sys for line in fileinput.input(inplace=1, backup='.bak'): # or fileinput.input(['config.h'], inplace=1, backup='.bak') for your file newline = re.sub('8192', '32768', line) # sys.stdout gets changed to the output file sys.stdout.write(s) # files are closed automatically Good luck, -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. (Arcege) Reilly | arcege@speakeasy.net | From wmperry@swbell.net Sat Apr 7 01:16:59 2001 From: wmperry@swbell.net (William Perry) Date: Fri, 06 Apr 2001 19:16:59 -0500 Subject: [Tutor] User selections question In-Reply-To: <Pine.LNX.4.21.0104060211120.20017-100000@hkn.eecs.berkeley.edu> References: <Pine.LNX.4.21.0104060211120.20017-100000@hkn.eecs.berkeley.edu> Message-ID: <200104061916590610.0526FF89@mail.swbell.net> *********** REPLY SEPARATOR *********** On 4/6/01 at 2:37 AM Daniel Yoo wrote: >The indentation of the code feels a little weird to me; it might be better >to indent this like: > > while tst: > area =3D input("enter ") > if area =3D=3D 1: > res =3D area1() > l.append(res) > > ... I noticed that the indenation was changed in the posted message. In the= functional code it matches your example. I'll digest your changes. It looks like a cleaner way to do it. and Yes,= the number of possible inputs in a full featured version of what I'd= trying would be in the 20-30 range so expandability is needed from the= start. Thanks !!!! Bill Perry From linuxboy_xjtu@263.net Sat Apr 7 16:43:21 2001 From: linuxboy_xjtu@263.net (Áõ±ó) Date: Sat, 7 Apr 2001 23:43:21 +0800 (CST) Subject: [Tutor] how can i reload a module under win2000 Message-ID: <3ACF3599.27688@mta5> 1 ,i use win2000+idle(python gui),i have import a module when i alter the file ,should i reload the module by "import" ,i have try so,but it seems not work,who can help me ? 2 in my file i use function int() and str(),but when i run the file there is some error : ValueError: invalid literal for int(): thanks a lot! _____________________________________________ ÇéÊ¥½µÁÙ263ÉÌ³Ç http://shopping.263.net/fs/hododo/index.htm ÇåÁ¹Ò»ÏÄ£¬¿Õµ÷ÈÈÂô http://shopping.263.net/hotsale/aircondition/index.asp From lumbricus@gmx.net Sat Apr 7 18:38:17 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Sat, 7 Apr 2001 19:38:17 +0200 Subject: [Tutor] how can i reload a module under win2000 In-Reply-To: <3ACF3599.27688@mta5>; from linuxboy_xjtu@263.net on Sat, Apr 07, 2001 at 11:43:21PM +0800 References: <3ACF3599.27688@mta5> Message-ID: <20010407193817.A15108@Laplace.localdomain> On Sat, Apr 07, 2001 at 11:43:21PM +0800, Áõ±ó wrote: > 1 ,i use win2000+idle(python gui),i have import a module when i alter the file ,should i reload the module by "import" ,i have try so,but it seems not work,who can help me ? reload(module) > 2 in my file i use function int() and str(),but when i run the file there is some error : > ValueError: invalid literal for int(): > > > thanks a lot! HTH > > _____________________________________________ > ÇéÊ¥½µÁÙ263ÉÌ³Ç http://shopping.263.net/fs/hododo/index.htm > ÇåÁ¹Ò»ÏÄ£¬¿Õµ÷ÈÈÂô http://shopping.263.net/hotsale/aircondition/index.asp > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Tact in audacity is knowing how far you can go without going too far. -- Jean Cocteau From van@lindbergs.org Sat Apr 7 18:55:25 2001 From: van@lindbergs.org (VanL) Date: Sat, 07 Apr 2001 11:55:25 -0600 Subject: [Tutor] how can i reload a module under win2000 References: <3ACF3599.27688@mta5> Message-ID: <3ACF548D.FE7ACDA8@lindbergs.org> Try the builtin function reload. For example: vanl@MOUSE ~/winhome $ python Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import os >>> reload(os) <module 'os' from 'c:\lib\python20\lib\os.pyc'> >>> From jthing@frisurf.no Sat Apr 7 19:22:50 2001 From: jthing@frisurf.no (John Thingstad) Date: Sat, 07 Apr 2001 20:22:50 +0200 Subject: Subject: [Tutor] Tkinter topic completed Message-ID: <200104071828.UAA27681@mail48.fg.online.no> >If anyone has comments I'm pleased to receive them, particularly on >the wxPython section since I don't use wxPython much (altho' I >might now that I've started :-) The layout scheme using absolute coordinates in wxWindows is wastfull and produces code which is difficult to port. It is better to use wxWindows layput classes. Heres an example of using a notebook inteface. Notice the wmBoxSizer. #!/usr/env python #----------------------------------------------------------------------------- # Python source generated by wxDesigner from file: notebook.wdr # Do not modify this file, all changes will be lost! #----------------------------------------------------------------------------- # Include wxWindows' modules from wxPython.wx import * # Window functions ID_TEXTCTRL = 10000 def PageOneFunc( parent, call_fit = true, set_sizer = true ): item0 = wxBoxSizer( wxVERTICAL ) item1 = wxTextCtrl( parent, ID_TEXTCTRL, "", wxDefaultPosition, wxSize(200,-1), 0 ) item0.AddWindow( item1, 0, wxALIGN_CENTRE|wxALL, 20 ) item2 = wxTextCtrl( parent, ID_TEXTCTRL, "", wxDefaultPosition, wxSize(200,90), wxTE_MULTILINE ) item0.AddWindow( item2, 0, wxALIGN_CENTRE|wxALL, 20 ) if set_sizer == true: parent.SetAutoLayout( true ) parent.SetSizer( item0 ) if call_fit == true: item0.Fit( parent ) item0.SetSizeHints( parent ) return item0 ID_CHECKBOX = 10001 ID_BUTTON = 10002 def PageTwoFunc( parent, call_fit = true, set_sizer = true ): item0 = wxBoxSizer( wxVERTICAL ) item2 = wxStaticBox( parent, -1, "Checks" ) item1 = wxStaticBoxSizer( item2, wxHORIZONTAL ) item3 = wxCheckBox( parent, ID_CHECKBOX, "Check", wxDefaultPosition, wxDefaultSize, 0 ) item1.AddWindow( item3, 0, wxALIGN_CENTRE|wxALL, 5 ) item4 = wxCheckBox( parent, ID_CHECKBOX, "Check", wxDefaultPosition, wxDefaultSize, 0 ) item1.AddWindow( item4, 0, wxALIGN_CENTRE|wxALL, 5 ) item5 = wxCheckBox( parent, ID_CHECKBOX, "Check", wxDefaultPosition, wxDefaultSize, 0 ) item1.AddWindow( item5, 0, wxALIGN_CENTRE|wxALL, 5 ) item0.AddSizer( item1, 0, wxALIGN_CENTRE|wxALL, 5 ) item7 = wxStaticBox( parent, -1, "Buttons" ) item6 = wxStaticBoxSizer( item7, wxVERTICAL ) item8 = wxButton( parent, ID_BUTTON, "OK", wxDefaultPosition, wxDefaultSize, 0 ) item6.AddWindow( item8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ) item9 = wxButton( parent, ID_BUTTON, "OK", wxDefaultPosition, wxDefaultSize, 0 ) item6.AddWindow( item9, 0, wxALIGN_CENTRE|wxALL, 5 ) item10 = wxButton( parent, ID_BUTTON, "OK", wxDefaultPosition, wxDefaultSize, 0 ) item6.AddWindow( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ) item0.AddSizer( item6, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ) if set_sizer == true: parent.SetAutoLayout( true ) parent.SetSizer( item0 ) if call_fit == true: item0.Fit( parent ) item0.SetSizeHints( parent ) return item0 ID_NOTEBOOK = 10003 ID_LINE = 10004 def NotebookFunc( parent, call_fit = true, set_sizer = true ): item0 = wxBoxSizer( wxVERTICAL ) item2 = wxNotebook( parent, ID_NOTEBOOK, wxDefaultPosition, wxSize(200,160), 0 ) item1 = wxNotebookSizer( item2 ) item3 = wxPanel( item2, -1 ) PageOneFunc( item3, false ) item2.AddPage( item3, "Page 1" ) item4 = wxPanel( item2, -1 ) PageTwoFunc( item4, false ) item2.AddPage( item4, "Page 2" ) item0.AddSizer( item1, 0, wxALIGN_CENTRE|wxALL, 5 ) item5 = wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL ) item0.AddWindow( item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ) item6 = wxBoxSizer( wxHORIZONTAL ) item7 = wxButton( parent, wxID_OK, "OK", wxDefaultPosition, wxDefaultSize, 0 ) item7.SetDefault() item6.AddWindow( item7, 0, wxALIGN_CENTRE|wxALL, 5 ) item8 = wxButton( parent, wxID_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize, 0 ) item6.AddWindow( item8, 0, wxALIGN_CENTRE|wxALL, 5 ) item0.AddSizer( item6, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 ) if set_sizer == true: parent.SetAutoLayout( true ) parent.SetSizer( item0 ) if call_fit == true: item0.Fit( parent ) item0.SetSizeHints( parent ) return item0 # Bitmap functions # End of generated file From cdwom@mpinet.net Sat Apr 7 23:42:37 2001 From: cdwom@mpinet.net (Corey Woodworth) Date: Sat, 7 Apr 2001 18:42:37 -0400 Subject: [Tutor] E-mail in python Message-ID: <000d01c0bfb4$0c382b00$0adc35d8@KellyJoW> Would it be plausible to write an e-mail client in Python? The reason I ask is because Outlook has more than pissed me off too much. I know that I couldn't write something that complex yet, but Its a goal :) So, would A. it be plausible. and B. Where should I start? Thanks, Corey From arcege@shore.net Sun Apr 8 00:11:15 2001 From: arcege@shore.net (Michael P. Reilly) Date: Sat, 7 Apr 2001 19:11:15 -0400 (EDT) Subject: [Tutor] E-mail in python In-Reply-To: <000d01c0bfb4$0c382b00$0adc35d8@KellyJoW> from "Corey Woodworth" at Apr 07, 2001 06:42:37 PM Message-ID: <200104072311.f37NBFT01669@dsl254-114-246.nyc1.dsl.speakeasy.net> Corey Woodworth wrote > Would it be plausible to write an e-mail client in Python? The reason I ask > is because Outlook has more than pissed me off too much. I know that I > couldn't write something that complex yet, but Its a goal :) So, would A. it > be plausible. and B. Where should I start? There is a semi-decent, cross-platform one called "PyMailGui" that comes with the 2nd Edition of Mark Lutz's _Programming Python_. There's a lot to be added to it, but it is open source and looks pretty well extensible. Within Python itself, there are smtplib, poplib and imaplib modules to deal with the sending and receiving of e-mail messages. As well as rfc822, mimecntl and mailbox modules. To do a little self-promoting, there is also a more useful MIME module (for programming) than those that come with Python called "mimecntl" available at <URL: http://starship.python.net/crew/arcege/modules/>. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From syrinx@simplecom.net Sun Apr 8 00:37:31 2001 From: syrinx@simplecom.net (Scott) Date: Sat, 07 Apr 2001 18:37:31 -0500 Subject: [Tutor] for each dictionary key... Message-ID: <k09vctstdpdv796t35o7vavujvtdljc96u@4ax.com> I've been doing this: keys =3D self.someclass.keys() for key in keys: ( do something ) What's the shorter way? From DOUGS@oceanic.com Sun Apr 8 01:05:34 2001 From: DOUGS@oceanic.com (Doug Stanfield) Date: Sat, 7 Apr 2001 14:05:34 -1000 Subject: [Tutor] for each dictionary key... Message-ID: <8457258D741DD411BD3D0050DA62365907A745@huina.oceanic.com> Well, for key in self.someclass.keys(): ( do something ) But shorter doesn't always mean better if it reduces the ability to easily understand the code. Thats a judgement call you have to make. Also, if you decided later that you needed to sort those keys, you'd probably have to go back to your original with the addition of... keys.sort() HTH -Doug- > -----Original Message----- > From: Scott [mailto:syrinx@simplecom.net] > Sent: Saturday, April 07, 2001 1:38 PM > To: tutor@python.org > Subject: [Tutor] for each dictionary key... > > > > I've been doing this: > > keys = self.someclass.keys() > for key in keys: > ( do something ) > > What's the shorter way? > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From dsh8290@rit.edu Sun Apr 8 03:36:54 2001 From: dsh8290@rit.edu (D-Man) Date: Sat, 7 Apr 2001 22:36:54 -0400 Subject: [Tutor] E-mail in python In-Reply-To: <000d01c0bfb4$0c382b00$0adc35d8@KellyJoW>; from cdwom@mpinet.net on Sat, Apr 07, 2001 at 06:42:37PM -0400 References: <000d01c0bfb4$0c382b00$0adc35d8@KellyJoW> Message-ID: <20010407223653.A22169@harmony.cs.rit.edu> On Sat, Apr 07, 2001 at 06:42:37PM -0400, Corey Woodworth wrote: | Would it be plausible to write an e-mail client in Python? The reason I ask | is because Outlook has more than pissed me off too much. I know that I | couldn't write something that complex yet, but Its a goal :) So, would A. it | be plausible. and B. Where should I start? I would recommend starting with pmail or PMS. I don't know if pmail would work on windows or not (probably not -- I think it uses the GNOME desktop for some stuff) but I couldn't get it to work when I tried it on my linux box. PMS (Python Mail System) is a project that Moshe Zadka started/is working on to make a mail client in python. Talk to him about working on it. HTH, -D From jsc_lists@rock-tnsc.com Mon Apr 9 03:51:08 2001 From: jsc_lists@rock-tnsc.com (Jethro Cramp) Date: Sun, 08 Apr 2001 18:51:08 -0800 Subject: [Tutor] E-mail in python References: <000d01c0bfb4$0c382b00$0adc35d8@KellyJoW> Message-ID: <3AD1239C.6010403@rock-tnsc.com> Corey Woodworth wrote: > Would it be plausible to write an e-mail client in Python? The reason I ask > is because Outlook has more than pissed me off too much. I know that I > couldn't write something that complex yet, but Its a goal :) So, would A. it > be plausible. and B. Where should I start? > > Thanks, > Corey > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor As I remember there is a quite advanced gui e-mail client program based on wxpython. I think it is called Balsa or Mahogany. Check on the wxPython page for links. Jethro From moshez@zadka.site.co.il Sun Apr 8 13:49:01 2001 From: moshez@zadka.site.co.il (Moshe Zadka) Date: Sun, 08 Apr 2001 14:49:01 +0200 Subject: [Tutor] (no subject) In-Reply-To: <A50594A71D5FD311A00200902745F06F18A488@go.ihello.com> References: <A50594A71D5FD311A00200902745F06F18A488@go.ihello.com> Message-ID: <E14mEcn-00045C-00@darjeeling> On Thu, 29 Mar 2001 13:01:00 -0800, Glen Bunting <Glen@ihello-inc.com> wrote: > Let me rephrase the question. I didn't state the question very clearly. I > am trying to write a python script on Mandrake Linux that will check the > amount of free memory available, similar to using the 'free' command. I > already have a script written in sh which does this by calling the free > command, but I am trying to re-write it completely in python. os.popen("free") You're free to go dig around in /proc if you really want to, but free will always know more then you do. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez@debian.org |http://www.{python,debian,gnu}.org From moshez@zadka.site.co.il Sun Apr 8 14:00:09 2001 From: moshez@zadka.site.co.il (Moshe Zadka) Date: Sun, 08 Apr 2001 15:00:09 +0200 Subject: [Tutor] E-mail in python In-Reply-To: <000d01c0bfb4$0c382b00$0adc35d8@KellyJoW> References: <000d01c0bfb4$0c382b00$0adc35d8@KellyJoW> Message-ID: <E14mEnZ-0004BJ-00@darjeeling> On Sat, 7 Apr 2001 18:42:37 -0400, "Corey Woodworth" <cdwom@mpinet.net> wrote: > Would it be plausible to write an e-mail client in Python? The reason I ask > is because Outlook has more than pissed me off too much. I know that I > couldn't write something that complex yet, but Its a goal :) So, would A. it > be plausible. and B. Where should I start? One place is http://pythonms.sourceforge.net It's my e-mail client. It's in the public domain, so you can do anything you want with it. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez@debian.org |http://www.{python,debian,gnu}.org From spi" <securityguru@earthlink.net Sun Apr 8 19:30:59 2001 From: spi" <securityguru@earthlink.net (spi) Date: Sun, 8 Apr 2001 14:30:59 -0400 Subject: [Tutor] Issue on POST with httplib.HTTPConnection Message-ID: <062b01c0c05a$0ee62f90$0201a8c0@gate> When doing a POST to a server with httplib.HTTPConnection and grabbing the response "response = connection.getresponse()", the server will always send back a "100 Continue" before sending the real response, how do I read the real response? From julieta_rangel@hotmail.com Sun Apr 8 23:12:08 2001 From: julieta_rangel@hotmail.com (Julieta) Date: Sun, 8 Apr 2001 17:12:08 -0500 Subject: [Tutor] Primes on a two-dimensional plane in the form of a rectangular spiral Message-ID: <OE70ztxc1o8yfogkJXr00000d12@hotmail.com> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C0C04F.0B0992A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable The primes, 2,3,4,5,7, . . . can be arranged on a two-dimensional plane = in the form of a rectangular spiral. <-represents left -> represents right ^represents up | = represents down 59 <- 53 <- 47 <- 43 <- 41 ^ 11 <- 7 <- 5 <- 37 | ^ ^ 13 2 -> 3 31 | ^=20 17 -> 19 -> 23 -> 29 How could I write a program which inputs integers M and N and outputs = the value of the number at location (M, N) on the plane? The initial 2 = is stored at position (0,0). This means that an input of ( 0, 0 ) = should output 2. An input of, say, ( -1, 1) should output 11; an input = of (-1,2) should output 53, and so on. I don't have any programming experience nor have I ever taken a computer = programming class, however, I would like to start learning. I've = written very small programs (20 lines long) in my TI - 92 calculator and = in Python, and I'm trying to build on that. Right now I'm trying to = learn some Python, so any kind of input on this problem would help = tremendously. ------=_NextPart_000_0005_01C0C04F.0B0992A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>The primes, 2,3,4,5,7, . . . can be = arranged on a=20 two-dimensional plane in the form of a rectangular spiral.</FONT></DIV> <DIV><FONT face=3DArial size=3D2><-represents left -> = represents=20 right ^represents up | = represents=20 down</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>59 <- 53 <- 47 = <- =20 43 <- 41</FONT></DIV> <DIV><FONT face=3DArial=20 size=3D2> &nbs= p;  = ; = =20 ^</FONT></DIV> <DIV><FONT face=3DArial = size=3D2> 11=20 <- 7 <- =20 5 <- 37</FONT></DIV> <DIV><FONT face=3DArial=20 size=3D2> =20 | = =20 ^ =20 ^</FONT></DIV> <DIV><FONT face=3DArial = size=3D2> =20 13 2 -> =20 3 31</FONT></DIV> <DIV><FONT face=3DArial=20 size=3D2> |&nb= sp; &nbs= p;  = ; =20 ^ </FONT></DIV> <DIV><FONT face=3DArial=20 size=3D2> 17 = -> =20 19 -> 23 -> = 29</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>How could I write a program which = inputs integers M=20 and N and outputs the value of the number at location (M, N) on the = plane? =20 The initial 2 is stored at position (0,0). This means = that an=20 input of ( 0, 0 ) should output 2. </FONT><FONT face=3DArial = size=3D2>An input=20 of, say, ( -1, 1) should output 11; an input of (-1,2) should output 53, = and so=20 on.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>I don't have any programming experience = nor have I=20 ever taken a computer programming class, however, I would like to start=20 learning. I've written very small programs (20 lines long) in my = TI - 92=20 calculator and in Python, and I'm trying to build on that. Right = now I'm=20 trying to learn some Python, so any kind of input on this problem would = help=20 tremendously.</FONT></DIV> <DIV> </DIV> <DIV> </DIV></BODY></HTML> ------=_NextPart_000_0005_01C0C04F.0B0992A0-- From britt_green@hotmail.com Mon Apr 9 01:28:31 2001 From: britt_green@hotmail.com (Britt Green) Date: Sun, 08 Apr 2001 17:28:31 -0700 Subject: [Tutor] Naming Instances of Classes Message-ID: <F246xNIeA8UJ4Epktkz000014d6@hotmail.com> I have a little problem thats been vexing me for the past week. If I have a class, how do you name the instances of that class? In all the code I've seen its always been hardcoded like this: class Employee: pass john = Employee() Instead of hardcoding it, how can I make my program automatically give a unique name or number to a new class? Britt -- It is pitch black. You are likely to be eaten by a grue. _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From rick@niof.net Mon Apr 9 01:56:11 2001 From: rick@niof.net (Rick Pasotto) Date: Sun, 8 Apr 2001 20:56:11 -0400 Subject: [Tutor] Naming Instances of Classes In-Reply-To: <F246xNIeA8UJ4Epktkz000014d6@hotmail.com>; from britt_green@hotmail.com on Sun, Apr 08, 2001 at 05:28:31PM -0700 References: <F246xNIeA8UJ4Epktkz000014d6@hotmail.com> Message-ID: <20010408205611.A554@tc.niof.net> On Sun, Apr 08, 2001 at 05:28:31PM -0700, Britt Green wrote: > I have a little problem thats been vexing me for the past week. If I > have a class, how do you name the instances of that class? In all the > code I've seen its always been hardcoded like this: > > class Employee: pass > > john = Employee() > > Instead of hardcoding it, how can I make my program automatically give > a unique name or number to a new class? How are you going to refer to it if you don't give it a name? -- "Democracy is being allowed to vote for the candidate you dislike least." -- Robert Byrne Rick Pasotto email: rickp@telocity.com From dsh8290@rit.edu Mon Apr 9 02:24:36 2001 From: dsh8290@rit.edu (D-Man) Date: Sun, 8 Apr 2001 21:24:36 -0400 Subject: [Tutor] E-mail in python In-Reply-To: <3AD1239C.6010403@rock-tnsc.com>; from jsc_lists@rock-tnsc.com on Sun, Apr 08, 2001 at 06:51:08PM -0800 References: <000d01c0bfb4$0c382b00$0adc35d8@KellyJoW> <3AD1239C.6010403@rock-tnsc.com> Message-ID: <20010408212436.A24057@harmony.cs.rit.edu> On Sun, Apr 08, 2001 at 06:51:08PM -0800, Jethro Cramp wrote: | Corey Woodworth wrote: | | > Would it be plausible to write an e-mail client in Python? The reason I ask | > is because Outlook has more than pissed me off too much. I know that I | > couldn't write something that complex yet, but Its a goal :) So, would A. it | > be plausible. and B. Where should I start? | | As I remember there is a quite advanced gui e-mail client program based | on wxpython. I think it is called Balsa or Mahogany. Check on the | wxPython page for links. Balsa is based on GTK+ and GNOME. Mahogany is based on wxWindows and embeds Python for extensibility. It now has a Win32 build available too. Another client you may want to check out is mutt. It is console based (ncurses) but is quite flexible and useable. I like it a lot. It works well on Windows systems with Cygwin (just change all 'fopen' calls to use binary mode or all attachments will be corrupt). -D From dyoo@hkn.eecs.berkeley.edu Mon Apr 9 03:29:35 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 8 Apr 2001 19:29:35 -0700 (PDT) Subject: [Tutor] Naming Instances of Classes In-Reply-To: <20010408205611.A554@tc.niof.net> Message-ID: <Pine.LNX.4.21.0104081927510.22093-100000@hkn.eecs.berkeley.edu> On Sun, 8 Apr 2001, Rick Pasotto wrote: > On Sun, Apr 08, 2001 at 05:28:31PM -0700, Britt Green wrote: > > I have a little problem thats been vexing me for the past week. If I > > have a class, how do you name the instances of that class? In all the > > code I've seen its always been hardcoded like this: > > > > class Employee: pass > > > > john = Employee() > > > > Instead of hardcoding it, how can I make my program automatically give > > a unique name or number to a new class? > > How are you going to refer to it if you don't give it a name? You can put it into a Python list --- the list itself would have a name, but the contents could be indexed by number: employees = [] for i in range(10): employees.append(Employee()) would create a list of 10 employees. I'm not sure if this is what you want, though. Good luck to you. From rick@niof.net Mon Apr 9 04:20:07 2001 From: rick@niof.net (Rick Pasotto) Date: Sun, 8 Apr 2001 23:20:07 -0400 Subject: [Tutor] Naming Instances of Classes In-Reply-To: <Pine.LNX.4.21.0104081927510.22093-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Sun, Apr 08, 2001 at 07:29:35PM -0700 References: <20010408205611.A554@tc.niof.net> <Pine.LNX.4.21.0104081927510.22093-100000@hkn.eecs.berkeley.edu> Message-ID: <20010408232007.B554@tc.niof.net> On Sun, Apr 08, 2001 at 07:29:35PM -0700, Daniel Yoo wrote: > On Sun, 8 Apr 2001, Rick Pasotto wrote: > > > On Sun, Apr 08, 2001 at 05:28:31PM -0700, Britt Green wrote: > > > I have a little problem thats been vexing me for the past week. If > > > I have a class, how do you name the instances of that class? In > > > all the code I've seen its always been hardcoded like this: > > > > > > class Employee: pass > > > > > > john = Employee() > > > > > > Instead of hardcoding it, how can I make my program automatically > > > give a unique name or number to a new class? > > > > How are you going to refer to it if you don't give it a name? > > You can put it into a Python list --- the list itself would have a > name, but the contents could be indexed by number: > > employees = [] > for i in range(10): > employees.append(Employee()) > > would create a list of 10 employees. I'm not sure if this is what you > want, though. Precisely. The names would then be employees[0], employees[1], etc. What the original poster was asking for doesn't make any sense. -- "Moderation in temper is always a virtue; but moderation in principle is always a vice." -- Thomas Paine, _The Rights of Man_ (1791) Rick Pasotto email: rickp@telocity.com From glingl@aon.at Mon Apr 9 07:50:51 2001 From: glingl@aon.at (Gregor Lingl) Date: Mon, 09 Apr 2001 08:50:51 +0200 Subject: [Tutor] Primes on a two-dimensional plane in the form of a rectangular spiral References: <OE70ztxc1o8yfogkJXr00000d12@hotmail.com> Message-ID: <3AD15BCB.CB1E1B5E@aon.at> Julieta schrieb: > The primes, 2,3,4,5,7, . . . can be arranged on a two-dimensional > plane in the form of a rectangular spiral.<-represents left -> > represents right ^represents up | represents down 59 <- 53 <- > 47 <- 43 <- 41 > ^ 11 <- 7 <- 5 <- 37 | > ^ ^ 13 2 -> 3 31 > | ^ 17 -> 19 -> 23 -> > 29 How could I write a program which inputs integers M and N and > outputs the value of the number at location (M, N) on the plane? The > initial 2 is stored at position (0,0). This means that an input of > ( 0, 0 ) should output 2. An input of, say, ( -1, 1) should output > 11; an input of (-1,2) should output 53, and so on. I don't have any > programming experience nor have I ever taken a computer programming > class, however, I would like to start learning. I've written very > small programs (20 lines long) in my TI - 92 calculator and in Python, > and I'm trying to build on that. Right now I'm trying to learn some > Python, so any kind of input on this problem would help > tremendously. Dear Julieta! I assume, that 'any kind of input' doesn't mean a complete solution to the problem. So I'll provide some hints: Befor beginning to code you have to know clearly how to solve the problem by hand. I think it could be helpful to break up the problem in two smaller ones: 1. Calculate an n so that the the location (M,N) ist the n-th 'point' on your spiral, for instance: (0/0) ->1 (1/0) ->2 (1/1) ->3 ... (1/-1) -> 9 (2/-1) -> 10 (2/0) -> 11 ... and so on. 2. Calculate the n-th prime. For this a simple (although probably not very efficient) way would be to use the Sieve of Eratosthenes: Write down all natural numbers from 1 to a certain maximum z (yet to determine). Cancel 1. Next uncancelled number is 2 It's a prime: mark it and cancel all the multiples of two. Next uncancelled number is 3. It's a prime: mark it and cancel all the multiples of three, ... Repeat this until the square of the next uncacelled number ( = found prime) surpasses z. Only primes remain in the list and now you can determine the n-th one. As z use a number which will be securely big enough. Remark: If you have an algorithm to determine if a given natural number is prime, an even simpler but less efficient way would be to go through the natural numbers, determine for each one, if it is a prime and count it ... until you arrive at the n-th prime. 3. Combine those two parts of the solution. 4. If you need more help on specific parts of the solution, try to formulate clear questions and put them into the tutor-newsgroup. 5. If you arrive at a solution post it at Useless Python , the best place where it belongs to. Have fun, Gregor Lingl P.S.: Interesting would be a (more or less) simple and efficient way to calculate from a given prime p next_prime(p). Perhaps someone else knows one .... From sheila@thinkspot.net Mon Apr 9 07:57:40 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 08 Apr 2001 23:57:40 -0700 Subject: [Tutor] Primes on a two-dimensional plane in the form of a rectangular spiral In-Reply-To: <3AD15BCB.CB1E1B5E@aon.at> References: <OE70ztxc1o8yfogkJXr00000d12@hotmail.com> <3AD15BCB.CB1E1B5E@aon.at> Message-ID: <14CE6196C60@kserver.org> On Mon, 09 Apr 2001 08:50:51 +0200, Gregor Lingl <glingl@aon.at> wrote about Re: [Tutor] Primes on a two-dimensional plane in the form of a rectangular spiral: :P.S.: Interesting would be a (more or less) simple and efficient way to :calculate from a given prime p next_prime(p). Perhaps someone else :knows one .... I believe that the algorithm that is generally considered the quickest for calculating primes, is called the "Sieve of Erasthones". (sp?) However, this algorithm requires that you start from the number "two" and work your way on up. I don't believe there is any way to start at an arbitrary prime number and find the next prime without knowing the preceding primes. So, you'd have to implement the Sieve of Erasthones in any case, even though you were only interested in finding a single number. I'm always willing to find out I'm wrong, if someone else knows better... -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From scarblac@pino.selwerd.nl Mon Apr 9 08:16:06 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Mon, 9 Apr 2001 09:16:06 +0200 Subject: [Tutor] Primes on a two-dimensional plane in the form of a rectangular spiral In-Reply-To: <OE70ztxc1o8yfogkJXr00000d12@hotmail.com>; from julieta_rangel@hotmail.com on Sun, Apr 08, 2001 at 05:12:08PM -0500 References: <OE70ztxc1o8yfogkJXr00000d12@hotmail.com> Message-ID: <20010409091606.A24574@pino.selwerd.nl> On 0, Julieta <julieta_rangel@hotmail.com> wrote: > The primes, 2,3,4,5,7, . . . can be arranged on a two-dimensional plane in the form of a rectangular spiral. > <-represents left -> represents right ^represents up | represents down > > 59 <- 53 <- 47 <- 43 <- 41 > ^ > 11 <- 7 <- 5 <- 37 > | ^ ^ > 13 2 -> 3 31 > | ^ > 17 -> 19 -> 23 -> 29 > > How could I write a program which inputs integers M and N and outputs the > value of the number at location (M, N) on the plane? The initial 2 is > stored at position (0,0). This means that an input of ( 0, 0 ) should > output 2. An input of, say, ( -1, 1) should output 11; an input of (-1,2) > should output 53, and so on. What an odd problem. Is this a homework assignment? At first it looks like the way to do this is a) Find out from the position you get which prime you need b) Find that prime On a closer look, the way to find prime n is to build up a list of them, growing it until you've found the nth one. It would be easy to keep track of the position of that prime as well, stopping when we arrive at the right point. If you have the Python source distribution, there is a prime number program in Demos/scripts/primes.py. Change the primes function to primes(x, y) for the position and let it always start at min=2. Initialize cur_x and cur_y to 0, 0, for the start position. Change the loop into something like "while (x,y) != (cur_x, cur_y)" and put some code after primes.append(i) that moves the position (cur_x, cur_y) around appropriately. In the end, primes[-1] has the answer. -- Remco Gerlich From skandel07@hotmail.com Mon Apr 9 10:07:03 2001 From: skandel07@hotmail.com (Derek White) Date: Mon, 09 Apr 2001 05:07:03 -0400 Subject: [Tutor] Message persistence Message-ID: <F72gC81TbdkSmLAztxc00001b0f@hotmail.com> Hello all, If I were wanting to write a web based message board system with CGI with replies in threads what would be some of the ways to consider for message persistence in Python? Thanks, Derek White _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From dyoo@hkn.eecs.berkeley.edu Mon Apr 9 10:21:32 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 9 Apr 2001 02:21:32 -0700 (PDT) Subject: [Tutor] Primes on a two-dimensional plane in the form of a rectangular spiral In-Reply-To: <OE70ztxc1o8yfogkJXr00000d12@hotmail.com> Message-ID: <Pine.LNX.4.21.0104081930230.22093-100000@hkn.eecs.berkeley.edu> On Sun, 8 Apr 2001, Julieta wrote: > The primes, 2,3,4,5,7, . . . can be arranged on a two-dimensional > plane in the form of a rectangular spiral. > <-represents left -> represents right ^represents up | represents down > > 59 <- 53 <- 47 <- 43 <- 41 > ^ > 11 <- 7 <- 5 <- 37 > | ^ ^ > 13 2 -> 3 31 > | ^ > 17 -> 19 -> 23 -> 29 > > How could I write a program which inputs integers M and N and outputs > the value of the number at location (M, N) on the plane? The initial > 2 is stored at position (0,0). This means that an input of ( 0, 0 ) > should output 2. An input of, say, ( -1, 1) should output 11; an > input of (-1,2) should output 53, and so on. Wow! This looks like a really interesting problem. The problem with the primes doesn't seem as interesting as trying to get the cycle thing going. The cycle problem seems rife with patterns; it'd be nice to get it working. The first problem that I'm seeing is trying to figure out a function that, given a location, tells us which prime we're looking for. Let's see if there are patterns... nth location --- ------ 0 (0, 0) 1 (1, 0) 2 (1, 1) 3 (0, 1) 4 (-1, 1) 5 (-1, 0) 6 (-1, -1) ... The numbers that are catching my eye, at the moment, are the ones on the diagonal in Quadrant three: nth location --- ------ 0 (0, 0) 6 (-1, -1) 20 (-2, -2) 42 (-3, -3) ... ... The reason that these numbers seem interesting to me is that if we start taking the differences between them, there's an interesting pattern that occurs: 0 6 20 42 # Position numbers on the diagonal 6 14 22 # Difference level 1 8 8 # Difference level 2 As a prediction, I suspect that at position (-4, -4), we are trying to print out the 72th number. I haven't testing this yet. The reason for this guess is because there's a way to consistantly extend this pattern: 0 6 20 42 72 6 14 22 30 8 8 8 But I'd have to draw it out to manually verify this. Testing it now... verified! Yes: the number at position (-4, -4) should be the 72th prime. Cool, so that's one pattern we might be able to exploit here, that if we take the difference between two diagonal positions, the gap between the appears to expand at a rate of 8. This might not help, but it's a pattern, and there might be a very cute way of writing a function that can quickly find, given a position, the nth number. I'll take a closer look at this when I have time --- this looks really interesting! Skip below if you want to listen to me ramble about discrete math while I'm working at this... *grin* (note: yes, there is a cute way. >>> def a(n): return 2*n*(1+2*n) ... >>> a(0), a(1), a(2), a(3), a(4) (0, 6, 20, 42, 72) The method for deriving this is below.) --- [Math mode on. Warning!] Hmmm... I'd like to label those three sequences I was looking at earlier: 0 6 20 42 72 # Let's call this sequence (a) 6 14 22 30 # Let's call this sequence (b) 8 8 8 # Let's call this sequence (c) The problem that I'd like to solve is to find a nice formula for sequence (a) --- that would solve the problem of finding which nth prime should go on the diagonals. Sequence (c) isn't that interesting, because it's just all 8s. Let's look at sequence (b). Sequence (b) isn't that much harder, because every time we go up the sequence, we just need to add 8 to what we had before. This translates, in math, to: b(n) = 6 + 8 * n With this done, we might be able to handle sequence (a), which looks a little weirder. In order to get from one part of the sequence to the next, we need to add a corresponding element from (b). More formally: a(0) = 0 a(n) = a(n-1) + b(n-1) Let's see if this works in Python. ### >>> def b(n): return 6 + 8*n ... >>> def a(n): ... if n == 0: return 0 ... else: return a(n-1) + b(n-1) ... >>> a(0), a(1), a(2), a(3), a(4) (0, 6, 20, 42, 72) ### Very cool. So this is a perfectly good way of solving the problem of finding which prime numbers should go on the diagonal. But we can go even further, if we're perverse enough. It's also very true that: a(n) = a(n-1) + 8*(n-1) + 6 = a(n-1) + 8*n - 2 if we substitute the value of b(n-1) into the equation. If I were to do this by hand, I'd use a math technique called generating functions that can take something like: a(0) = 0 a(n) = a(n-1) + 8*n - 2 and transform it into something nicer. But I'm cheap and ignorant about generating functions still, so I'll use Mathematica instead. According to Mathematica's RSolve function, a(n) = 2n(1+2n) Does this work? ### >>> def a(n): return 2*n*(1+2*n) ... >>> a(0), a(1), a(2), a(3), a(4) (0, 6, 20, 42, 72) ### My gosh. I must learn how generating functions work, so that I can see how in the world that worked. *grin* From alan.gauld@bt.com Mon Apr 9 11:15:09 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 9 Apr 2001 11:15:09 +0100 Subject: Subject: [Tutor] Tkinter topic completed Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6CD@mbtlipnt02.btlabs.bt.co.uk> > The layout scheme using absolute coordinates in wxWindows is > wastfull and produces code which is difficult to port. Indeed, its the big thing I don't like about wxPython so far. I hate coordinate based layouts. > It is better to use wxWindows layput classes. Aha! I didn't notice those, all the examles/tutors I had seen used coordinates. I will go look at the layout objects, thanks. Thanks for the comments, Alan G From alan.gauld@bt.com Mon Apr 9 11:43:23 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 9 Apr 2001 11:43:23 +0100 Subject: [Tutor] Primes on a two-dimensional plane in the form of a re ctangular spiral Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6D0@mbtlipnt02.btlabs.bt.co.uk> ---Interesting discourse on pattern generayion snipped---- > But I'm cheap and ignorant about generating functions still, > so I'll use Mathematica instead. According to > Mathematica's RSolve function, > > a(n) = 2n(1+2n) > .... > My gosh. I must learn how generating functions work, so that > I can see how in the world that worked. *grin* You do that Danny, me I'm off to buy a copy of Mathematica :-) I didn't know it could do that kind of thing, cool! Alan G. From alan.gauld@bt.com Mon Apr 9 11:31:12 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 9 Apr 2001 11:31:12 +0100 Subject: [Tutor] Naming Instances of Classes Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6CE@mbtlipnt02.btlabs.bt.co.uk> > class, how do you name the instances of that class? > john = Employee() > > Instead of hardcoding it, how can I make my program > automatically give a unique name or number to a new class? Thee are several ways including using sequence numbers and generating unique strings, then use eval() to do the assignment. But since the only real need for this that I can think of is to create collections of objects why not just usea list and append the classes: myBigNumber = 1000000 class myClass: pass myInstances = [] for i in range(aBigNumber): myInstances.append(myClass()) You can then operate on all of your classes using map, filter etc or just a for loop. Or you can find the instance you want (maybe with filter) and assign that to a hard coded name: def selectAnInstance(inst,val = "spam"): return inst.meat == val thisInstance = filter(selectAnInstance, myInstances)[0] #1 only HTH, Alan G From alan.gauld@bt.com Mon Apr 9 11:35:59 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 9 Apr 2001 11:35:59 +0100 Subject: [Tutor] Message persistence Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6CF@mbtlipnt02.btlabs.bt.co.uk> > to write a web based message board system with CGI with > replies in threads what would be some of the ways to consider > for message persistence in Python? Same as any other kind of persistence: 1) Store in memory - valid for life of process 2) Store in flat files - fine oif not too many - maybe OK if a file per thread? 3) pickle/shelve - save the thread object as above but less work :-) 4) Use a database - best if any real volumes involved. Pick any database that runs on your platform and has a Python data driver module Alan G From lha2@columbia.edu Mon Apr 9 15:23:52 2001 From: lha2@columbia.edu (Lloyd Hugh Allen) Date: Mon, 09 Apr 2001 10:23:52 -0400 Subject: [Tutor] Re: [Python] Primes on a two-dimensional plane in the form of a rectangular spiral References: <E14mXtx-00064d-00@mail.python.org> Message-ID: <3AD1C5F8.DA562B35@mail.verizon.net> Because the original post (from Julieta) was encoded by MIME, the formatting got all messed up and I won't be quoting from it. See the bottom of <http://www.ibiblio.org/obp/thinkCSpy/chap08.htm> for how to create a matrix, which can be thought of as a two-dimensional list; the problem is that negative indices won't work the way you want them to. A negative index will count from the end of the list; so matrix=[[1,2,3],[4,5,6],[7,8,9]] is thought of by people as looking like [1,2,3] [4,5,6] [7,8,9] and matrix[-1][-1] should return <9>. You could use a matrix implementation, and keep track of where the origin is, but that could get ugly. Because you have negative indices, it may be easier for you to pretend that you have a sparse matrix (even though you will have zero entries with value zero) and use a dictionary with key-values that are tuples: for the above matrix, with <5> as the "origin", matrixdict = {(0,0):5, (0,1):6} #you can set initial values matrixdict[(-1,1)] = 1 #and you can add values as you go matrixdict[(-1,0)] = 4 matrixdict {(0, 1): 6, (0, 0): 5, (-1, 1): 1, (-1, 0): 4} matrixdict[(0,1)] 6 This implementation looks easier and more appropriate for your project. From st_hickey@hotmail.com Mon Apr 9 15:56:54 2001 From: st_hickey@hotmail.com (Stevenson Hickey) Date: Mon, 9 Apr 2001 07:56:54 -0700 Subject: [Tutor] WxPython Message-ID: <OE49arcR4ZDgC81Tbdk00001056@hotmail.com> This is a multi-part message in MIME format. ------=_NextPart_000_0014_01C0C0CA.A4FACAC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I downloaded WxPython for Python 2.0 and installed it from the download = just by clicking on it. It seemed to install properly, but when I went = to do the demo as instructed, I could not get it from Windows. I went = into Cygwin and went to the directory and typed "python demo.py". This = is the error message I got: stevenson hickey@HICKEY BOX /c/python21/s $ python demo.py Traceback (most recent call last): File "demo.py", line 3, in ? import Main File "Main.py", line 15, in ? from wxPython.wx import * ImportError: No module named wxPython.wx When I did a search of my whole Python directory, I found no file named = wxpython.wx. =20 I understand that this may mean that I have to compile wxpython from = source code, but I don't understand why? =20 I am running Windows 98 on a 400 Mhz PC with 64 Megs Ram. Thanks for any help, Stevenson Hickey --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.247 / Virus Database: 120 - Release Date: 4/6/2001 ------=_NextPart_000_0014_01C0C0CA.A4FACAC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV>I downloaded WxPython for Python 2.0 and installed it from the = download=20 just by clicking on it. It seemed to install properly, but when I = went to=20 do the demo as instructed, I could not get it from Windows. I went = into=20 Cygwin and went to the directory and typed "python demo.py". This = is the=20 error message I got:</DIV> <DIV> </DIV> <DIV>stevenson <A href=3D"mailto:hickey@HICKEY">hickey@HICKEY</A> = BOX=20 /c/python21/s<BR>$ python demo.py<BR>Traceback (most recent call=20 last):<BR> File "demo.py", line 3, in ?<BR> = import=20 Main<BR> File "Main.py", line 15, in ?<BR> =20 from wxPython.wx import *<BR>ImportError: No module named=20 wxPython.wx</DIV> <DIV> </DIV> <DIV>When I did a search of my whole Python directory, I found no file = named=20 wxpython.wx. </DIV> <DIV> </DIV> <DIV>I understand that this may mean that I have to compile wxpython = from source=20 code, but I don't understand why? <BR>I am running Windows 98 = on a=20 400 Mhz PC with 64 Megs Ram.</DIV> <DIV> </DIV> <DIV>Thanks for any help,</DIV> <DIV> </DIV> <DIV>Stevenson Hickey<BR></DIV> <DIV> </DIV> <DIV><BR>---<BR>Outgoing mail is certified Virus Free.<BR>Checked by AVG = anti-virus system (<A=20 href=3D"http://www.grisoft.com">http://www.grisoft.com</A>).<BR>Version: = 6.0.247 /=20 Virus Database: 120 - Release Date: 4/6/2001</DIV></BODY></HTML> ------=_NextPart_000_0014_01C0C0CA.A4FACAC0-- From dsh8290@rit.edu Mon Apr 9 16:17:26 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 9 Apr 2001 11:17:26 -0400 Subject: [Tutor] WxPython In-Reply-To: <OE49arcR4ZDgC81Tbdk00001056@hotmail.com>; from st_hickey@hotmail.com on Mon, Apr 09, 2001 at 07:56:54AM -0700 References: <OE49arcR4ZDgC81Tbdk00001056@hotmail.com> Message-ID: <20010409111725.A24784@harmony.cs.rit.edu> On Mon, Apr 09, 2001 at 07:56:54AM -0700, Stevenson Hickey wrote: | | I downloaded WxPython for Python 2.0 and installed it from the | download just by clicking on it. It seemed to install properly, but | when I went to do the demo as instructed, I could not get it from | Windows. I went into Cygwin and went to the directory and typed | "python demo.py". This is the error message I got: | | stevenson [1]hickey@HICKEY BOX /c/python21/s | $ python demo.py | Traceback (most recent call last): | File "demo.py", line 3, in ? | import Main | File "Main.py", line 15, in ? | from wxPython.wx import * | ImportError: No module named wxPython.wx | | When I did a search of my whole Python directory, I found no file | named wxpython.wx. Where did you install wxPython to? When I installed it I put it in d:\lib\python_packages\wxPython. I needed to add d:\lib\python_packages to my PYTHONPATH environment variable. The reason is python will look in it's install directory and PYTHONPATH to find all modules/packages. If you installed wxPython to a different directory, it won't be able to find it. You need to either include that directory in PYTHONPATH or install it under the python directory. The other solution is to create a .pth file in the python install directory. It can be named anything. For example : ------ d:\apps\Python20\packages.pth ------ d:\lib\python_packages That pth file will add that path to sys.path, and python will recognize all packages in that directory (such as wxPython). HTH, -D From hailan@thing.radiant-media.com Mon Apr 9 16:33:31 2001 From: hailan@thing.radiant-media.com (Hailan Yu) Date: Mon, 9 Apr 2001 11:33:31 -0400 (EDT) Subject: [Tutor] how to change PYTHONPATH in WinPython 2.0 Message-ID: <20010409153331.9F65E1382@thing.radiant-media.com> In win python 2.0 IDLE, you can browse path using path browser, but how you can change path? If you want to install a python app, what you have to do, so it can find all the packages, likw wxpython, XML, etc. Hailan Thanks From dsh8290@rit.edu Mon Apr 9 17:17:51 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 9 Apr 2001 12:17:51 -0400 Subject: [Tutor] how to change PYTHONPATH in WinPython 2.0 In-Reply-To: <20010409153331.9F65E1382@thing.radiant-media.com>; from hailan@thing.radiant-media.com on Mon, Apr 09, 2001 at 11:33:31AM -0400 References: <20010409153331.9F65E1382@thing.radiant-media.com> Message-ID: <20010409121751.A24917@harmony.cs.rit.edu> In Windows 9x you can set PYTHONPATH : o open c:\autoexec.bat with your favorite text editor (notepad or edit will suffice) o add this line at the bottom : set PYTHONPATH c:\path\to\packages o save o reboot ( ?-p ) In WinNT or 2K you can set PYTHONPATH : o click on Start->Settings->Control Panel->System o click on the "Advanced" tab o click on the "Environment Variables" button o click on the "New" button (pick whether you want this change for the current user only, or all users, for all users you must have admin privilegs) o type "PYTHONPATH" (without quotes) for the variable name o type the value (ie c:\path\to\packages) for the value o click the "Ok" button o click the "Ok" button o click the "Ok" button (once again -- all on different dialogs) o logout o login In both situations, if a setting for PYTHONPATH already exists, just append the additional paths you want separated by a ';'. (In the first case, executing 'set PYTHONPATH ...' will override the preexisting value. This can be overcome by using 'set PYTHONPATH %PYTHONPATH%;c:\apath' to include the old value in the new value.) By setting the system's environment, you will affect all programs that don't ignore it. I suppose it's possible that PythonWin ignores the system PYTHONPATH setting, but I would consider that to be broken and should be reported as a bug. (I don't use PythonWin so I don't know what it actually does). -D From lsloan@umich.edu Mon Apr 9 17:33:14 2001 From: lsloan@umich.edu (Lance E Sloan) Date: Mon, 09 Apr 2001 12:33:14 -0400 Subject: [Tutor] converting CGI's FieldStorage to dictionary? Message-ID: <200104091633.MAA11149@birds.us.itd.umich.edu> I'm writing a series of CGIs in Python and I'm using the standard cgi module and I've also copied DocumentTemplate out of Zope. The problem I'm running into is that DocumentTemplate uses dictionaries as arguments to hold template values, but cgi's FieldStorage is not quite a dictionary. So, this doesn't work: import cgi import DocumentTemplate form = cgi.FieldStorage() tmpl = DocumentTemplate.HTMLFile('path/to/file') print tmpl(mapping = form) How can I write a function that takes my FieldStorage form as an argument and returns a dictionary of field names to field values? I think I may have to worry about multiple values for a field (checkboxes), but if somebody could help me get on the right track, I can probably account for that. My CGIs won't be accepting files as input, so I'm glad I don't have to worry about that, too. Thanks in advance! -- Lance E Sloan - lsloan@umich.edu Univ. of Michigan, ITCS From NHYTRO@compuserve.com Mon Apr 9 17:50:03 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Mon, 9 Apr 2001 12:50:03 -0400 Subject: [Tutor] ODBC->CGI results Message-ID: <200104091250_MC2-CBCD-E9FF@compuserve.com> I am accessing an Access database with a CGI script, everything works but= for the problem that the results are in Tuple format when I "print" them = as an output to a browser client, could someone show me a better way to do this or a work around? ##### My script### #!C:/Python/python.exe -u print "Content-Type: text/html\n\n" import dbi, odbc connection =3D odbc.odbc('minicms') cur =3D connection.cursor() cur.execute('select * from benutzer') allrows =3D cur.fetchall() print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' print "<html>" print "<head>" print "<title>blank</title>" print "</head>" print '<body bgcolor=3D"white">' for dbfields in allrows: print "<br>", print dbfields print "</br>" print "</body>" print "</html>" ################ end code ######## and the results look like this: ('Michael',) ('johnny',) and so on... any ideas? Thank you very much for your anticipated help Sharriff Aina From glingl@aon.at Mon Apr 9 18:30:15 2001 From: glingl@aon.at (Gregor Lingl) Date: Mon, 09 Apr 2001 19:30:15 +0200 Subject: [Tutor] Primes on a two-dimensional plane in the form of arectangular spiral References: <Pine.LNX.4.21.0104081930230.22093-100000@hkn.eecs.berkeley.edu> Message-ID: <3AD1F1A6.9F0A80C6@aon.at> --------------A10B7D9871003B18E15DEEBB Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Daniel Yoo wrote: ... but it's a pattern, and there might be a very cute way of writing a function that can quickly find, given a position, the nth number. I'll take a closer look at this when I have time --- this looks really interesting! Skip below if you want to listen to me ramble about discrete math while I'm working at this... *grin* (note: yes, there is a cute way. >>> def a(n): return 2*n*(1+2*n) ... >>> a(0), a(1), a(2), a(3), a(4) (0, 6, 20, 42, 72) The method for deriving this is below.) --- [Math mode on. Warning!] Hmmm... Here I propose a different derivation of this formula: [Geometry mode on. No warnings!] n n n n n n n n x x x x x n n x ... x n n x . O x n n x .. x n n A x x x x n B In this pattern A is at location ( -(n-1), -(n-1) ) an B is at location (-n, -n) There a (2*n-1)**2 points in the inner square, consuming indices from 0 to (2*n-1)**2 - 1, and 6*n points at the rim of the outer square, so (2*n-1)**2 - 1 + 6*n = 4*n**2 -4*n + 1 - 1 + 6*n = 4*n**2+2*n = 2*n*(2*n+2) as was our desire! I've continued to follow this quasi-pythagorean approach of simple counting (beginning with the index 1 for the point (0/0)) and arrived at the following code: def loc_number(M,N): if M==0 and N==0: return 1 maxabs = max(abs(M),abs(N)) innersquare = (2 * maxabs-1)**2 if M == maxabs and N > -maxabs: rest = maxabs + N elif N == maxabs: rest = 3 * maxabs - M elif M == -maxabs: rest = 5 * maxabs - N else: rest = 7 * maxabs + M return innersquare + rest # which can be accompanied by def dannies_loc_number(M,N): return loc_number(M,N) - 1 Of course I'm curious, if someone else (who has already or is off to buy a copy of Mathematica) finds a more elegant or more concise solution. Always interested in useless problems Gregor L. Here follow - for reference - Daniels complete reply to Julieta: > On Sun, 8 Apr 2001, Julieta wrote: > > > The primes, 2,3,4,5,7, . . . can be arranged on a two-dimensional > > plane in the form of a rectangular spiral. > > > <-represents left -> represents right ^represents up | represents down > > > > 59 <- 53 <- 47 <- 43 <- 41 > > ^ > > 11 <- 7 <- 5 <- 37 > > | ^ ^ > > 13 2 -> 3 31 > > | ^ > > 17 -> 19 -> 23 -> 29 > > > > How could I write a program which inputs integers M and N and outputs > > the value of the number at location (M, N) on the plane? The initial > > 2 is stored at position (0,0). This means that an input of ( 0, 0 ) > > should output 2. An input of, say, ( -1, 1) should output 11; an > > input of (-1,2) should output 53, and so on. > > Wow! This looks like a really interesting problem. The problem with the > primes doesn't seem as interesting as trying to get the cycle thing > going. The cycle problem seems rife with patterns; it'd be nice to get it > working. > > > The first problem that I'm seeing is trying to figure out a function that, > given a location, tells us which prime we're looking for. Let's see if > there are patterns... > > nth location > --- ------ > 0 (0, 0) > 1 (1, 0) > 2 (1, 1) > 3 (0, 1) > 4 (-1, 1) > 5 (-1, 0) > 6 (-1, -1) > ... > > The numbers that are catching my eye, at the moment, are the ones on the > diagonal in Quadrant three: > > nth location > --- ------ > 0 (0, 0) > 6 (-1, -1) > 20 (-2, -2) > 42 (-3, -3) > ... ... > > The reason that these numbers seem interesting to me is that if we start > taking the differences between them, there's an interesting pattern that > occurs: > > 0 6 20 42 # Position numbers on the diagonal > 6 14 22 # Difference level 1 > 8 8 # Difference level 2 > > As a prediction, I suspect that at position (-4, -4), we are trying to > print out the 72th number. I haven't testing this yet. The reason for > this guess is because there's a way to consistantly extend this pattern: > > 0 6 20 42 72 > 6 14 22 30 > 8 8 8 > > But I'd have to draw it out to manually verify this. Testing it now... > verified! Yes: the number at position (-4, -4) should be the 72th prime. > Cool, so that's one pattern we might be able to exploit here, that if we > take the difference between two diagonal positions, the gap between the > appears to expand at a rate of 8. > > This might not help, but it's a pattern, and there might be a very cute > way of writing a function that can quickly find, given a position, the nth > number. I'll take a closer look at this when I have time --- this looks > really interesting! > > Skip below if you want to listen to me ramble about discrete math while > I'm working at this... *grin* > > (note: yes, there is a cute way. > > >>> def a(n): return 2*n*(1+2*n) > ... > >>> a(0), a(1), a(2), a(3), a(4) > (0, 6, 20, 42, 72) > > The method for deriving this is below.) > > --- > > [Math mode on. Warning!] > > Hmmm... I'd like to label those three sequences I was looking at earlier: > > 0 6 20 42 72 # Let's call this sequence (a) > 6 14 22 30 # Let's call this sequence (b) > 8 8 8 # Let's call this sequence (c) > > The problem that I'd like to solve is to find a nice formula for sequence > (a) --- that would solve the problem of finding which nth prime should go > on the diagonals. Sequence (c) isn't that interesting, because it's just > all 8s. > > Let's look at sequence (b). Sequence (b) isn't that much harder, because > every time we go up the sequence, we just need to add 8 to what we had > before. This translates, in math, to: > > b(n) = 6 + 8 * n > > With this done, we might be able to handle sequence (a), which looks a > little weirder. In order to get from one part of the sequence to the > next, we need to add a corresponding element from (b). More formally: > > a(0) = 0 > a(n) = a(n-1) + b(n-1) > > Let's see if this works in Python. > > ### > >>> def b(n): return 6 + 8*n > ... > >>> def a(n): > ... if n == 0: return 0 > ... else: return a(n-1) + b(n-1) > ... > >>> a(0), a(1), a(2), a(3), a(4) > (0, 6, 20, 42, 72) > ### > > Very cool. So this is a perfectly good way of solving the problem of > finding which prime numbers should go on the diagonal. But we can go even > further, if we're perverse enough. It's also very true that: > > a(n) = a(n-1) + 8*(n-1) + 6 > = a(n-1) + 8*n - 2 > > if we substitute the value of b(n-1) into the equation. If I were to do > this by hand, I'd use a math technique called generating functions that > can take something like: > > a(0) = 0 > a(n) = a(n-1) + 8*n - 2 > > and transform it into something nicer. > > But I'm cheap and ignorant about generating functions still, so I'll use > Mathematica instead. According to Mathematica's RSolve function, > > a(n) = 2n(1+2n) > > Does this work? > > ### > >>> def a(n): return 2*n*(1+2*n) > ... > >>> a(0), a(1), a(2), a(3), a(4) > (0, 6, 20, 42, 72) > ### > > My gosh. I must learn how generating functions work, so that I can see > how in the world that worked. *grin* > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor --------------A10B7D9871003B18E15DEEBB Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <p>Daniel Yoo wrote: <p>... but it's a pattern, and there might be a very cute <br>way of writing a function that can quickly find, given a position, the nth <br>number. I'll take a closer look at this when I have time --- this looks <br>really interesting! <p>Skip below if you want to listen to me ramble about discrete math while <br>I'm working at this... *grin* <p>(note: yes, there is a cute way. <p>>>> def a(n): return 2*n*(1+2*n) <br>... <br>>>> a(0), a(1), a(2), a(3), a(4) <br>(0, 6, 20, 42, 72) <p>The method for deriving this is below.) <p>--- <p>[Math mode on. Warning!] <p>Hmmm... <p><tt>Here I propose a different derivation of this formula:</tt> <p><tt>[Geometry mode on. No warnings!]</tt> <p><tt> n n n n n n n</tt> <br><tt> n x x x x x n</tt> <br><tt> n x ... x n</tt> <br><tt> n x . O x n</tt> <br><tt> n x .. x n</tt> <br><tt> n A x x x x n</tt> <br><tt> B</tt> <p><tt>In this pattern A is at location ( -(n-1), -(n-1) )</tt> <br><tt>an B is at location (-n, -n)</tt> <p><tt>There a (2*n-1)**2 points in the inner square,</tt> <br><tt>consuming indices from 0 to (2*n-1)**2 - 1,</tt> <br><tt>and 6*n points at the rim of the outer square, so</tt> <br><tt>(2*n-1)**2 - 1 + 6*n = 4*n**2 -4*n + 1 - 1 + 6*n =</tt> <br><tt>4*n**2+2*n = 2*n*(2*n+2) as was our desire!</tt> <p><tt>I've continued to follow this quasi-pythagorean</tt> <br><tt>approach of simple counting (beginning with the</tt> <br><tt>index 1 for the point (0/0)) and arrived at the</tt> <br><tt>following code:</tt> <br> <p><tt>def loc_number(M,N):</tt> <br><tt> if M==0 and N==0:</tt> <br><tt> return 1</tt> <br><tt> maxabs = max(abs(M),abs(N))</tt> <br><tt> innersquare = (2 * maxabs-1)**2</tt> <br><tt> if M == maxabs and N > -maxabs:</tt> <br><tt> rest = maxabs + N</tt> <br><tt> elif N == maxabs:</tt> <br><tt> rest = 3 * maxabs - M</tt> <br><tt> elif M == -maxabs:</tt> <br><tt> rest = 5 * maxabs - N</tt> <br><tt> else:</tt> <br><tt> rest = 7 * maxabs + M</tt> <br><tt> return innersquare + rest</tt> <p><tt># which can be accompanied by</tt> <p><tt>def dannies_loc_number(M,N):</tt> <br><tt> return loc_number(M,N) - 1</tt> <p><tt>Of course I'm curious, if someone else</tt> <br><tt>(who has already or is off to buy a copy</tt> <br><tt>of Mathematica) finds a more elegant or</tt> <br><tt>more concise solution.</tt> <p><tt>Always interested in useless problems</tt> <br><tt>Gregor L.</tt> <br> <br> <p>Here follow - for reference - Daniels complete reply to Julieta: <blockquote TYPE=CITE>On Sun, 8 Apr 2001, Julieta wrote: <p>> The primes, 2,3,4,5,7, . . . can be arranged on a two-dimensional <br>> plane in the form of a rectangular spiral. <p>> <-represents left -> represents right ^represents up | represents down <br>> <br>> 59 <- 53 <- 47 <- 43 <- 41 <br>> ^ <br>> 11 <- 7 <- 5 <- 37 <br>> | ^ ^ <br>> 13 2 -> 3 31 <br>> | ^ <br>> 17 -> 19 -> 23 -> 29 <br>> <br>> How could I write a program which inputs integers M and N and outputs <br>> the value of the number at location (M, N) on the plane? The initial <br>> 2 is stored at position (0,0). This means that an input of ( 0, 0 ) <br>> should output 2. An input of, say, ( -1, 1) should output 11; an <br>> input of (-1,2) should output 53, and so on. <p>Wow! This looks like a really interesting problem. The problem with the <br>primes doesn't seem as interesting as trying to get the cycle thing <br>going. The cycle problem seems rife with patterns; it'd be nice to get it <br>working. <br> <p>The first problem that I'm seeing is trying to figure out a function that, <br>given a location, tells us which prime we're looking for. Let's see if <br>there are patterns... <p>nth location <br>--- ------ <br>0 (0, 0) <br>1 (1, 0) <br>2 (1, 1) <br>3 (0, 1) <br>4 (-1, 1) <br>5 (-1, 0) <br>6 (-1, -1) <br>... <p>The numbers that are catching my eye, at the moment, are the ones on the <br>diagonal in Quadrant three: <p>nth location <br>--- ------ <br>0 (0, 0) <br>6 (-1, -1) <br>20 (-2, -2) <br>42 (-3, -3) <br>... ... <p>The reason that these numbers seem interesting to me is that if we start <br>taking the differences between them, there's an interesting pattern that <br>occurs: <p>0 6 20 42 # Position numbers on the diagonal <br> 6 14 22 # Difference level 1 <br> 8 8 # Difference level 2 <p>As a prediction, I suspect that at position (-4, -4), we are trying to <br>print out the 72th number. I haven't testing this yet. The reason for <br>this guess is because there's a way to consistantly extend this pattern: <p>0 6 20 42 72 <br> 6 14 22 30 <br> 8 8 8 <p>But I'd have to draw it out to manually verify this. Testing it now... <br>verified! Yes: the number at position (-4, -4) should be the 72th prime. <br>Cool, so that's one pattern we might be able to exploit here, that if we <br>take the difference between two diagonal positions, the gap between the <br>appears to expand at a rate of 8. <p>This might not help, but it's a pattern, and there might be a very cute <br>way of writing a function that can quickly find, given a position, the nth <br>number. I'll take a closer look at this when I have time --- this looks <br>really interesting! <p>Skip below if you want to listen to me ramble about discrete math while <br>I'm working at this... *grin* <p>(note: yes, there is a cute way. <p>>>> def a(n): return 2*n*(1+2*n) <br>... <br>>>> a(0), a(1), a(2), a(3), a(4) <br>(0, 6, 20, 42, 72) <p>The method for deriving this is below.) <p>--- <p>[Math mode on. Warning!] <p>Hmmm... I'd like to label those three sequences I was looking at earlier: <p>0 6 20 42 72 # Let's call this sequence (a) <br> 6 14 22 30 # Let's call this sequence (b) <br> 8 8 8 # Let's call this sequence (c) <p>The problem that I'd like to solve is to find a nice formula for sequence <br>(a) --- that would solve the problem of finding which nth prime should go <br>on the diagonals. Sequence (c) isn't that interesting, because it's just <br>all 8s. <p>Let's look at sequence (b). Sequence (b) isn't that much harder, because <br>every time we go up the sequence, we just need to add 8 to what we had <br>before. This translates, in math, to: <p> b(n) = 6 + 8 * n <p>With this done, we might be able to handle sequence (a), which looks a <br>little weirder. In order to get from one part of the sequence to the <br>next, we need to add a corresponding element from (b). More formally: <p> a(0) = 0 <br> a(n) = a(n-1) + b(n-1) <p>Let's see if this works in Python. <p>### <br>>>> def b(n): return 6 + 8*n <br>... <br>>>> def a(n): <br>... if n == 0: return 0 <br>... else: return a(n-1) + b(n-1) <br>... <br>>>> a(0), a(1), a(2), a(3), a(4) <br>(0, 6, 20, 42, 72) <br>### <p>Very cool. So this is a perfectly good way of solving the problem of <br>finding which prime numbers should go on the diagonal. But we can go even <br>further, if we're perverse enough. It's also very true that: <p> a(n) = a(n-1) + 8*(n-1) + 6 <br> = a(n-1) + 8*n - 2 <p>if we substitute the value of b(n-1) into the equation. If I were to do <br>this by hand, I'd use a math technique called generating functions that <br>can take something like: <p> a(0) = 0 <br> a(n) = a(n-1) + 8*n - 2 <p>and transform it into something nicer. <p>But I'm cheap and ignorant about generating functions still, so I'll use <br>Mathematica instead. According to Mathematica's RSolve function, <p> a(n) = 2n(1+2n) <p>Does this work? <p>### <br>>>> def a(n): return 2*n*(1+2*n) <br>... <br>>>> a(0), a(1), a(2), a(3), a(4) <br>(0, 6, 20, 42, 72) <br>### <p>My gosh. I must learn how generating functions work, so that I can see <br>how in the world that worked. *grin* <p>_______________________________________________ <br>Tutor maillist - Tutor@python.org <br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a></blockquote> </html> --------------A10B7D9871003B18E15DEEBB-- From mbc2@netdoor.com Mon Apr 9 18:50:38 2001 From: mbc2@netdoor.com (Brad Chandler) Date: Mon, 9 Apr 2001 12:50:38 -0500 Subject: [Tutor] ODBC->CGI results References: <200104091250_MC2-CBCD-E9FF@compuserve.com> Message-ID: <001201c0c11d$96e6e2e0$111c0d0a@spb.state.ms.us> When you loop through your result, allrows, each row is returned as a tuple. What you want is the first element (in this case, the only element) of that tuple. Which is dbfields[0]. Try 'print dbfields[0]'. Brad ----- Original Message ----- From: "Sharriff Aina" <NHYTRO@compuserve.com> To: <tutor@python.org> Sent: Monday, April 09, 2001 11:50 AM Subject: [Tutor] ODBC->CGI results I am accessing an Access database with a CGI script, everything works but for the problem that the results are in Tuple format when I "print" them as an output to a browser client, could someone show me a better way to do this or a work around? ##### My script### #!C:/Python/python.exe -u print "Content-Type: text/html\n\n" import dbi, odbc connection = odbc.odbc('minicms') cur = connection.cursor() cur.execute('select * from benutzer') allrows = cur.fetchall() print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' print "<html>" print "<head>" print "<title>blank</title>" print "</head>" print '<body bgcolor="white">' for dbfields in allrows: print "<br>", print dbfields print "</br>" print "</body>" print "</html>" ################ end code ######## and the results look like this: ('Michael',) ('johnny',) and so on... any ideas? Thank you very much for your anticipated help Sharriff Aina _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From syrinx@simplecom.net Mon Apr 9 16:57:55 2001 From: syrinx@simplecom.net (Scott) Date: Mon, 09 Apr 2001 10:57:55 -0500 Subject: [Tutor] for each dictionary key... Message-ID: <mvm3dtgm9lttk0uk11aa2m19an6vub9k6t@4ax.com> This post wasn't meant for public consumption. :) I was just trying to put my problem into words, when I had company. I meant to save this message for later, but managed to send it instead. I don't remember where I was really going with it either. Sorry. >I've been doing this: > > keys =3D self.someclass.keys() > for key in keys: > ( do something ) > >What's the shorter way? From rick@niof.net Mon Apr 9 21:34:52 2001 From: rick@niof.net (Rick Pasotto) Date: Mon, 9 Apr 2001 16:34:52 -0400 Subject: [Tutor] user defined compare for sorting Message-ID: <20010409163452.D554@tc.niof.net> I have a list of dictionaries. How can I specify at runtime the key to use for sorting the list? lst[ [ 'A':'a', 'B':'2', 'C':'z' ] [ 'A':'b', 'B':'3', 'C':'x' ] [ 'A':'c', 'B':'1', 'C':'y' ] ] How can I pass 'A', 'B', or 'C' to 'key' in the compare function? def mycmp(a,b): cmp(a[key],b[key]) -- "Capitalism is a social system based on the recognition of individual rights, including property rights, in which all property is privately owned." -- Ayn Rand Rick Pasotto email: rickp@telocity.com From dyoo@hkn.eecs.berkeley.edu Mon Apr 9 21:56:16 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 9 Apr 2001 13:56:16 -0700 (PDT) Subject: [Tutor] Primes on a two-dimensional plane in the form of arectangular spiral In-Reply-To: <3AD1F1A6.9F0A80C6@aon.at> Message-ID: <Pine.LNX.4.21.0104091340250.10609-100000@hkn.eecs.berkeley.edu> Here's one more experiment after I played around with the spiraling function. Take a look! ### >>> def a(n): return 2 * n * (1+2*n) ... >>> def getNum(x, y): ... if abs(x) <= abs(y): return a(-y) + abs(y-x) ... else: return a(-x) - abs(y-x) ... >>> for y in range(5, -5, -1): ... for x in range(-5, 5): ... print "%5d" % getNum(x, y), ... print ... 100 99 98 97 96 95 94 93 92 91 101 64 63 62 61 60 59 58 57 56 102 65 36 35 34 33 32 31 30 55 103 66 37 16 15 14 13 12 29 54 104 67 38 17 4 3 2 11 28 53 105 68 39 18 5 0 1 10 27 52 106 69 40 19 6 7 8 9 26 51 107 70 41 20 21 22 23 24 25 50 108 71 42 43 44 45 46 47 48 49 109 72 73 74 75 76 77 78 79 80 ### There is a Mathgod, after all. *grin* Actually, I finally did the generating function way of deriving the function a(n). If anyone's interested, I'll be glad to post a .pdf to the math. Ok, this was overkill, but I had fun doing it. From glingl@aon.at Mon Apr 9 23:04:56 2001 From: glingl@aon.at (Gregor Lingl) Date: Tue, 10 Apr 2001 00:04:56 +0200 Subject: [Tutor] Primes on a two-dimensional plane in the form of arectangular spiral References: <Pine.LNX.4.21.0104091340250.10609-100000@hkn.eecs.berkeley.edu> Message-ID: <3AD23208.48F3E4E3@aon.at> Dies ist eine mehrteilige Nachricht im MIME-Format. --------------5EA0C941FE15032E318423AD Content-Type: multipart/alternative; boundary="------------B18CC9CDB79AB7DAD05C9D6F" --------------B18CC9CDB79AB7DAD05C9D6F Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Very well done! After all, we can have a script with 20 lines of code, as Julieta wanted: def a(n): return 2 * n * (1+2*n) def getNum(x, y): if abs(x) <= abs(y): return a(-y) + abs(y-x) else: return a(-x) - abs(y-x) def primes(n): primes = [2] i = 3 while len(primes) < n: for p in primes: if i%p == 0 or p*p > i: break if i%p <> 0: primes.append(i) i = i+2 return primes primelist = primes(11*11) for y in range(5, -5, -1): for x in range(-5, 5): print "%5d" % primelist[getNum(x, y)], print which ouputs: 547 541 523 521 509 503 499 491 487 479 557 313 311 307 293 283 281 277 271 269 563 317 157 151 149 139 137 131 127 263 569 331 163 59 53 47 43 41 113 257 571 337 167 61 11 7 5 37 109 251 577 347 173 67 13 2 3 31 107 241 587 349 179 71 17 19 23 29 103 239 593 353 181 73 79 83 89 97 101 233 599 359 191 193 197 199 211 223 227 229 601 367 373 379 383 389 397 401 409 419 Thanks for your ideas Gregor L. P.S.: concerning the math: post it! Daniel Yoo schrieb: > Here's one more experiment after I played around with the spiraling > function. Take a look! > > ### > >>> def a(n): return 2 * n * (1+2*n) > ... > >>> def getNum(x, y): > ... if abs(x) <= abs(y): return a(-y) + abs(y-x) > ... else: return a(-x) - abs(y-x) > ... > >>> for y in range(5, -5, -1): > ... for x in range(-5, 5): > ... print "%5d" % getNum(x, y), > ... print > ... > 100 99 98 97 96 95 94 93 92 91 > 101 64 63 62 61 60 59 58 57 56 > 102 65 36 35 34 33 32 31 30 55 > 103 66 37 16 15 14 13 12 29 54 > 104 67 38 17 4 3 2 11 28 53 > 105 68 39 18 5 0 1 10 27 52 > 106 69 40 19 6 7 8 9 26 51 > 107 70 41 20 21 22 23 24 25 50 > 108 71 42 43 44 45 46 47 48 49 > 109 72 73 74 75 76 77 78 79 80 > ### > > There is a Mathgod, after all. *grin* > > Actually, I finally did the generating function way of deriving the > function a(n). If anyone's interested, I'll be glad to post a .pdf to the > math. > > Ok, this was overkill, but I had fun doing it. --------------B18CC9CDB79AB7DAD05C9D6F Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> Very well done! <br>After all, we can have a script with 20 lines of code, <br>as Julieta wanted: <p><tt>def a(n):</tt> <br><tt> return 2 * n * (1+2*n)</tt><tt></tt> <p><tt>def getNum(x, y):</tt> <br><tt> if abs(x) <= abs(y): return a(-y) + abs(y-x)</tt> <br><tt> else: return a(-x) - abs(y-x)</tt> <br><tt> </tt> <br><tt>def primes(n):</tt> <br><tt> primes = [2]</tt> <br><tt> i = 3</tt> <br><tt> while len(primes) < n:</tt> <br><tt> for p in primes:</tt> <br><tt> if i%p == 0 or p*p > i: break</tt> <br><tt> if i%p <> 0:</tt> <br><tt> primes.append(i)</tt> <br><tt> i = i+2</tt> <br><tt> return primes</tt><tt></tt> <p><tt>primelist = primes(11*11)</tt> <br><tt>for y in range(5, -5, -1):</tt> <br><tt> for x in range(-5, 5):</tt> <br><tt> print "%5d" % primelist[getNum(x, y)],</tt> <br><tt> print</tt><tt></tt> <p>which ouputs:<tt></tt> <p><tt> 547 541 523 521 509 503 499 491 487 479</tt> <br><tt> 557 313 311 307 293 283 281 277 271 269</tt> <br><tt> 563 317 157 151 149 139 137 131 127 263</tt> <br><tt> 569 331 163 59 53 47 43 41 113 257</tt> <br><tt> 571 337 167 61 11 7 5 37 109 251</tt> <br><tt> 577 347 173 67 13 2 3 31 107 241</tt> <br><tt> 587 349 179 71 17 19 23 29 103 239</tt> <br><tt> 593 353 181 73 79 83 89 97 101 233</tt> <br><tt> 599 359 191 193 197 199 211 223 227 229</tt> <br><tt> 601 367 373 379 383 389 397 401 409 419</tt><tt></tt> <p>Thanks for your ideas <p>Gregor L.<tt></tt> <p>P.S.: concerning the math: post it! <p>Daniel Yoo schrieb: <blockquote TYPE=CITE>Here's one more experiment after I played around with the spiraling <br>function. Take a look! <p>### <br>>>> def a(n): return 2 * n * (1+2*n) <br>... <br>>>> def getNum(x, y): <br>... if abs(x) <= abs(y): return a(-y) + abs(y-x) <br>... else: return a(-x) - abs(y-x) <br>... <br>>>> for y in range(5, -5, -1): <br>... for x in range(-5, 5): <br>... print "%5d" % getNum(x, y), <br>... print <br>... <br> 100 99 98 97 96 95 94 93 92 91 <br> 101 64 63 62 61 60 59 58 57 56 <br> 102 65 36 35 34 33 32 31 30 55 <br> 103 66 37 16 15 14 13 12 29 54 <br> 104 67 38 17 4 3 2 11 28 53 <br> 105 68 39 18 5 0 1 10 27 52 <br> 106 69 40 19 6 7 8 9 26 51 <br> 107 70 41 20 21 22 23 24 25 50 <br> 108 71 42 43 44 45 46 47 48 49 <br> 109 72 73 74 75 76 77 78 79 80 <br>### <p>There is a Mathgod, after all. *grin* <p>Actually, I finally did the generating function way of deriving the <br>function a(n). If anyone's interested, I'll be glad to post a .pdf to the <br>math. <p>Ok, this was overkill, but I had fun doing it.</blockquote> </html> --------------B18CC9CDB79AB7DAD05C9D6F-- --------------5EA0C941FE15032E318423AD Content-Type: text/plain; charset=us-ascii; name="primespiral.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="primespiral.py" def a(n): return 2 * n * (1+2*n) def getNum(x, y): if abs(x) <= abs(y): return a(-y) + abs(y-x) else: return a(-x) - abs(y-x) def primes(n): primes = [2] i = 3 while len(primes) < n: for p in primes: if i%p == 0 or p*p > i: break if i%p <> 0: primes.append(i) i = i+2 return primes primelist = primes(11*11) for y in range(5, -5, -1): for x in range(-5, 5): print "%5d" % primelist[getNum(x, y)], print --------------5EA0C941FE15032E318423AD-- From glingl@aon.at Mon Apr 9 23:16:03 2001 From: glingl@aon.at (Gregor Lingl) Date: Tue, 10 Apr 2001 00:16:03 +0200 Subject: [Tutor] or better ... References: <Pine.LNX.4.21.0104091340250.10609-100000@hkn.eecs.berkeley.edu> Message-ID: <3AD234A2.815FB56A@aon.at> --------------BEA9CD40CEA971B83AF0BCEF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Very well done! After all, we can have a script with 20 lines of code, as Julieta wanted: def a(n): return 2 * n * (1+2*n) def getNum(x, y): if abs(x) <= abs(y): return a(-y) + abs(y-x) else: return a(-x) - abs(y-x) def primes(n): primes = [2] i = 3 while len(primes) < n: for p in primes: if i%p == 0 or p*p > i: break if i%p <> 0: primes.append(i) i = i+2 return primes primelist = primes(11*11) for y in range(5, -6, -1): for x in range(-5, 6): print "%5d" % primelist[getNum(x, y)], print which ouputs all the first 121 primes: (Note the changes in the ranges above, sorry) 547 541 523 521 509 503 499 491 487 479 467 557 313 311 307 293 283 281 277 271 269 463 563 317 157 151 149 139 137 131 127 263 461 569 331 163 59 53 47 43 41 113 257 457 571 337 167 61 11 7 5 37 109 251 449 577 347 173 67 13 2 3 31 107 241 443 587 349 179 71 17 19 23 29 103 239 439 593 353 181 73 79 83 89 97 101 233 433 599 359 191 193 197 199 211 223 227 229 431 601 367 373 379 383 389 397 401 409 419 421 607 613 617 619 631 641 643 647 653 659 661 Daniel Yoo schrieb: > Here's one more experiment after I played around with the spiraling > function. Take a look! > > ### > >>> def a(n): return 2 * n * (1+2*n) > ... > >>> def getNum(x, y): > ... if abs(x) <= abs(y): return a(-y) + abs(y-x) > ... else: return a(-x) - abs(y-x) > ... > >>> for y in range(5, -5, -1): > ... for x in range(-5, 5): > ... print "%5d" % getNum(x, y), > ... print > ... > 100 99 98 97 96 95 94 93 92 91 > 101 64 63 62 61 60 59 58 57 56 > 102 65 36 35 34 33 32 31 30 55 > 103 66 37 16 15 14 13 12 29 54 > 104 67 38 17 4 3 2 11 28 53 > 105 68 39 18 5 0 1 10 27 52 > 106 69 40 19 6 7 8 9 26 51 > 107 70 41 20 21 22 23 24 25 50 > 108 71 42 43 44 45 46 47 48 49 > 109 72 73 74 75 76 77 78 79 80 > ### > > There is a Mathgod, after all. *grin* > > Actually, I finally did the generating function way of deriving the > function a(n). If anyone's interested, I'll be glad to post a .pdf to the > math. > > Ok, this was overkill, but I had fun doing it. --------------BEA9CD40CEA971B83AF0BCEF Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> Very well done! <br>After all, we can have a script with 20 lines of code, <br>as Julieta wanted:<tt></tt> <p><tt>def a(n):</tt> <br><tt> return 2 * n * (1+2*n)</tt><tt></tt> <p><tt>def getNum(x, y):</tt> <br><tt> if abs(x) <= abs(y): return a(-y) + abs(y-x)</tt> <br><tt> else: return a(-x) - abs(y-x)</tt> <br><tt> </tt> <br><tt>def primes(n):</tt> <br><tt> primes = [2]</tt> <br><tt> i = 3</tt> <br><tt> while len(primes) < n:</tt> <br><tt> for p in primes:</tt> <br><tt> if i%p == 0 or p*p > i: break</tt> <br><tt> if i%p <> 0:</tt> <br><tt> primes.append(i)</tt> <br><tt> i = i+2</tt> <br><tt> return primes</tt><tt></tt> <p><tt>primelist = primes(11*11)</tt> <br><tt>for y in range(5, -6, -1):</tt> <br><tt> for x in range(-5, 6):</tt> <br><tt> print "%5d" % primelist[getNum(x, y)],</tt> <br><tt> print</tt> <p>which ouputs all the first 121 primes: (Note the changes in the ranges above, sorry) <p><tt> 547 541 523 521 509 503 499 491 487 479 467</tt> <br><tt> 557 313 311 307 293 283 281 277 271 269 463</tt> <br><tt> 563 317 157 151 149 139 137 131 127 263 461</tt> <br><tt> 569 331 163 59 53 47 43 41 113 257 457</tt> <br><tt> 571 337 167 61 11 7 5 37 109 251 449</tt> <br><tt> 577 347 173 67 13 2 3 31 107 241 443</tt> <br><tt> 587 349 179 71 17 19 23 29 103 239 439</tt> <br><tt> 593 353 181 73 79 83 89 97 101 233 433</tt> <br><tt> 599 359 191 193 197 199 211 223 227 229 431</tt> <br><tt> 601 367 373 379 383 389 397 401 409 419 421</tt> <br><tt> 607 613 617 619 631 641 643 647 653 659 661</tt> <br> <p>Daniel Yoo schrieb: <blockquote TYPE=CITE>Here's one more experiment after I played around with the spiraling <br>function. Take a look! <p>### <br>>>> def a(n): return 2 * n * (1+2*n) <br>... <br>>>> def getNum(x, y): <br>... if abs(x) <= abs(y): return a(-y) + abs(y-x) <br>... else: return a(-x) - abs(y-x) <br>... <br>>>> for y in range(5, -5, -1): <br>... for x in range(-5, 5): <br>... print "%5d" % getNum(x, y), <br>... print <br>... <br> 100 99 98 97 96 95 94 93 92 91 <br> 101 64 63 62 61 60 59 58 57 56 <br> 102 65 36 35 34 33 32 31 30 55 <br> 103 66 37 16 15 14 13 12 29 54 <br> 104 67 38 17 4 3 2 11 28 53 <br> 105 68 39 18 5 0 1 10 27 52 <br> 106 69 40 19 6 7 8 9 26 51 <br> 107 70 41 20 21 22 23 24 25 50 <br> 108 71 42 43 44 45 46 47 48 49 <br> 109 72 73 74 75 76 77 78 79 80 <br>### <p>There is a Mathgod, after all. *grin* <p>Actually, I finally did the generating function way of deriving the <br>function a(n). If anyone's interested, I'll be glad to post a .pdf to the <br>math. <p>Ok, this was overkill, but I had fun doing it.</blockquote> </html> --------------BEA9CD40CEA971B83AF0BCEF-- From scarblac@pino.selwerd.nl Mon Apr 9 23:49:57 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 10 Apr 2001 00:49:57 +0200 Subject: [Tutor] user defined compare for sorting In-Reply-To: <20010409163452.D554@tc.niof.net>; from rick@niof.net on Mon, Apr 09, 2001 at 04:34:52PM -0400 References: <20010409163452.D554@tc.niof.net> Message-ID: <20010410004957.A1185@pino.selwerd.nl> On 0, Rick Pasotto <rick@niof.net> wrote: > I have a list of dictionaries. How can I specify at runtime the key to > use for sorting the list? > > lst[ [ 'A':'a', 'B':'2', 'C':'z' ] > [ 'A':'b', 'B':'3', 'C':'x' ] > [ 'A':'c', 'B':'1', 'C':'y' ] ] > > How can I pass 'A', 'B', or 'C' to 'key' in the compare function? > > def mycmp(a,b): cmp(a[key],b[key]) (The above isn't correct, I assume you meant { curly braces } around the dicts, and the mycmp needs a "return"). I understand you want to be able to sort the list on different keys. Make a function that returns a function that sorts on some key: def make_sort_function(key): def sort_func(a, b, key=key): return cmp(a[key], b[key]) return sort_func cmp_func works as we want it to work because it gets key as a default argument. Now you can do, say, lst.sort(make_sort_function('A')) 'lambda' is a way to make functions on the fly. The same thing could like like this: lst.sort(lambda a,b,key='A': cmp(a[key],b[key])) It's up to you to choose the one you find easier to understand. If you don't understand how this works, play around with make_sort_function in the interpreter... -- Remco Gerlich From dsh8290@rit.edu Mon Apr 9 23:53:21 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 9 Apr 2001 18:53:21 -0400 Subject: [Tutor] user defined compare for sorting In-Reply-To: <20010409163452.D554@tc.niof.net>; from rick@niof.net on Mon, Apr 09, 2001 at 04:34:52PM -0400 References: <20010409163452.D554@tc.niof.net> Message-ID: <20010409185321.A26585@harmony.cs.rit.edu> On Mon, Apr 09, 2001 at 04:34:52PM -0400, Rick Pasotto wrote: | I have a list of dictionaries. How can I specify at runtime the key to | use for sorting the list? | | lst[ [ 'A':'a', 'B':'2', 'C':'z' ] | [ 'A':'b', 'B':'3', 'C':'x' ] | [ 'A':'c', 'B':'1', 'C':'y' ] ] minor correction : lst = [ { 'A':'a', 'B':'2', 'C':'z' } , { 'A':'b', 'B':'3', 'C':'x' } , { 'A':'c', 'B':'1', 'C':'y' } ] | How can I pass 'A', 'B', or 'C' to 'key' in the compare function? | | def mycmp(a,b): cmp(a[key],b[key]) Perhaps something like this would help : def make_cmp( key ) : return lambda a , b , key=key : cmp( a[key] , b[key] ) this_key = 'B' # figure out the key to use lst.sort( make_cmp( this_key ) ) The function make_cmp returns a comparison function that uses the particular key you specify as its argument. >>> def make_cmp( key ) : return lambda a , b, key=key : cmp( a[key] , b[key] ) ... >>> lst = [ { 'A':'a', 'B':'2', 'C':'z' } ,{ 'A':'b', 'B':'3', 'C':'x' } , { 'A':'c', 'B':'1', 'C':'y' } ] >>> lst [{'B': '2', 'C': 'z', 'A': 'a'}, {'B': '3', 'C': 'x', 'A': 'b'}, {'B': '1', 'C': 'y', 'A': 'c'}] >>> f = make_cmp( 'B' ) >>> print f <function <lambda> at 007A843C> >>> lst.sort( f ) >>> print lst [{'B': '1', 'C': 'y', 'A': 'c'}, {'B': '2', 'C': 'z', 'A': 'a'}, {'B': '3', 'C': 'x', 'A': 'b'}] >>> Now try and do that as quickly in Java! (on second thought, don't hurt yourself <wink>) (sorry, I am a little annoyed with java right now) -D From vlindberg@verio.net Tue Apr 10 00:11:26 2001 From: vlindberg@verio.net (VanL) Date: Mon, 09 Apr 2001 17:11:26 -0600 Subject: [Tutor] pyopengl name error Message-ID: <3AD2419E.BB5FBB1E@verio.net> Hello, If this is too pyopengl-specific, I'll take this question there. However, it seems to actually be a problem with namespaces, so I decided to try this group first. I installed pyOpenGL. I can import it, get a listing of available functions from dir(), etc. However, When I try to run the example code drawcube.py, I get the following error: Traceback (most recent call last): File "glut.py", line 69, in OnDraw drawCube() File "drawcube.py", line 3, in drawCube OpenGL.GL.glTranslatef(0.0, 0.0, -2.0); NameError: There is no variable named 'OpenGL' Traceback (most recent call last): File "glut.py", line 69, in OnDraw drawCube() File "drawcube.py", line 3, in drawCube OpenGL.GL.glTranslatef(0.0, 0.0, -2.0); NameError: There is no variable named 'OpenGL' Traceback (most recent call last): File "glut.py", line 69, in OnDraw drawCube() File "drawcube.py", line 3, in drawCube OpenGL.GL.glTranslatef(0.0, 0.0, -2.0); NameError: There is no variable named 'OpenGL' Here is the code throwing the exception: '''GLUT rendering context sample ''' from OpenGL.GL import * from OpenGL.GLUT import * from drawcube import drawCube class GLUTContext: def __init__ ( self, title= "GLUT Render Context", size = (300,300), mode = GLUT_DOUBLE | GLUT_RGB ): ### Context parameter setup glutInitDisplayMode( mode ) ### Instantiation # Note: GLUT does this strangely, # most windowing libraries wrap the size # of the context into the creation call... apply ( glutInitWindowSize, size) # create a new rendering window self.windowID = glutCreateWindow( title ) ### Callback setup # so GLUT knows the target window glutSetWindow( self.windowID ) glutSetReshapeFuncCallback(self.OnResize) glutReshapeFunc() glutSetDisplayFuncCallback(self.OnDraw) glutDisplayFunc() def OnResize(self, width, height): ### Size callback glutSetWindow( self.windowID ) glViewport(0, 0, width, height) def OnDraw(self, *arguments): ### Draw callback ### Capture rendering context glutSetWindow( self.windowID ) ### Create projection matrix glMatrixMode(GL_PROJECTION); # load the identity matrix (reset the view) glLoadIdentity() # calculate a 3D perspective view glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0); ### Setup model view matrix # move the object-creation matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity() ### Setup global rendering "environment" # Enable occlusion testing for the depth buffer glEnable(GL_DEPTH_TEST); # Enable lighting calculations glEnable(GL_LIGHTING); # Enable the default light zero (shining forward on the y axis) glEnable(GL_LIGHT0); # Setup buffers # blank the background to a single colour, # also clear the depth-buffer to all 0 glClearColor(1.0,1.0,1.0,1.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ### Render drawCube() ### Swap buffers glutSwapBuffers() if __name__ == "__main__": # initialize GLUT windowing system glutInit('foo') context = GLUTContext( ) glutMainLoop() Any help? Thanks, Van From dsh8290@rit.edu Tue Apr 10 00:13:05 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 9 Apr 2001 19:13:05 -0400 Subject: [Tutor] pyopengl name error In-Reply-To: <3AD2419E.BB5FBB1E@verio.net>; from vlindberg@verio.net on Mon, Apr 09, 2001 at 05:11:26PM -0600 References: <3AD2419E.BB5FBB1E@verio.net> Message-ID: <20010409191305.A26683@harmony.cs.rit.edu> On Mon, Apr 09, 2001 at 05:11:26PM -0600, VanL wrote: | | Traceback (most recent call last): | File "glut.py", line 69, in OnDraw | drawCube() | File "drawcube.py", line 3, in drawCube | OpenGL.GL.glTranslatef(0.0, 0.0, -2.0); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is the line of code causing the exception. This line doesn't occur anywhere in the code you posted. Can you post the first few lines of 'drawcube.py' instead? Something to note : I noticed that the package name uses mixed case. On Windows systems the filesystem is case-insensitive so sometimes there are problems relating to the case not matching. Also, BTW, even though semicolons are allowed for line termination, it isn't exactly encouraged. (not a big deal, though) -D From jsc@rock-tnsc.com Wed Apr 11 01:34:02 2001 From: jsc@rock-tnsc.com (Jethro Cramp) Date: Tue, 10 Apr 2001 16:34:02 -0800 Subject: [Tutor] Problem Moving Python Program From WIndows to Linux Message-ID: <3AD3A67A.5090208@rock-tnsc.com> I have hit upon a thorny little problem. I had started building a program on Windows ME and then I moved over to Linux and want to keep working on it. I have hit a number of problems where my python files won't run on Linux. On Windows there is no problem. On both systems I am using Python 2.0. My Linux system is SuSE7.1 The problem is to do with reading files and then splitting the fields. So I have a text file of the following format: Imperial Black =3.01 Mountain White =2.7 Canton Green =2.8 etc.etc These are names of different types of stone and their mass in MT. The format is <NAME> a couple of tabs for legibility "=" then <MASS> The code I use is like this: def Get_Materials_List(): materialsfile = open(rkpaths.material_specs, "r") materials = {} for material in materialsfile.readlines(): #Ignores blank lines, comments, and currency demarcation if not material=="\n" and not material[:1] == "#" and not material[:1] =="[": #Get the material name and the mass stripping white spaces print material mat, mass = map(string.strip, string.split(material, "=")) materials[string.upper(mat)] = (mat,mass) The error I get when I run this code is: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.0/rk/rkcalc.py", line 172, in Get_Materials_List mat, mass = map(string.strip, string.split(material, "=")) ValueError: unpack list of wrong size Are the tab stops being treated differently in Linux from Windows? Also when I open a file in idle that I wrote under windows there is a "\r" at the end of each line. Is this some kind of windows specific end of line character. If I read the file manually like so: >>> file = open(rkpaths.material_specs, "r") >>> x = file.readlines() for entry in x: print entry # This file contains a list of materials and their mass in MT/m3\r \r Imperial Black = 3.01\r Chinese Tarn = 2.7\r Mongolian Red = 2.7\r Mountain White = 2.7\r Dragon Beige = 2.7\r etc.etc. Then I try: >>> for entry in x: x,y = string.split(entry,"=") Traceback (innermost last): File "<pyshell#24>", line 2, in ? x,y = string.split(entry,"=") ValueError: unpack list of wrong size Notice all the '\r' entries. Anyone know what's going on and what I have to do. Do I have to convert all my scripts using dos2unix? TIA, Jethro From NHYTRO@compuserve.com Tue Apr 10 10:11:31 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Tue, 10 Apr 2001 05:11:31 -0400 Subject: [Tutor] CGI, HTML checkbox extraction Message-ID: <200104100511_MC2-CBD8-8257@compuserve.com> Message text written by INTERNET:tutor@python.org >< Hi! Could someone show me how to extract data per CGI from Checkboxes and Radiobuttons I=B4ve done a search on "Pythonlist", the python homepage and "Pythontut= or" and came up with nothing,. Thanks for your anticipated help. Sharriff From dyoo@hkn.eecs.berkeley.edu Tue Apr 10 10:39:55 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 10 Apr 2001 02:39:55 -0700 (PDT) Subject: [Tutor] Problem Moving Python Program From WIndows to Linux In-Reply-To: <3AD3A67A.5090208@rock-tnsc.com> Message-ID: <Pine.LNX.4.21.0104100231130.31744-100000@hkn.eecs.berkeley.edu> On Tue, 10 Apr 2001, Jethro Cramp wrote: > The error I get when I run this code is: > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/usr/lib/python2.0/rk/rkcalc.py", line 172, in Get_Materials_List > mat, mass = map(string.strip, string.split(material, "=")) > ValueError: unpack list of wrong size > > Are the tab stops being treated differently in Linux from Windows? > Also when I open a file in idle that I wrote under windows there is a > "\r" at the end of each line. Is this some kind of windows specific end > of line character. About the tab stops: not that I can tell. However, you're right about the "\r" stuff: it's the carriage return character that Windows/DOS systems use in conjunction with "\n". > >>> file = open(rkpaths.material_specs, "r") > >>> x = file.readlines() > for entry in x: > print entry > > # This file contains a list of materials and their mass in MT/m3\r > > \r Ah, here's something. If your first line contains a '\r', it's still a line, so the command x,y = string.split(entry,"=") will try doing the string split across this line --- that's what's causing the problem when we tuple-unpack later on. Same sort of thing happens if there are blank lines in your file. One way to fix this is to tell your loop to "skip over" blank lines: ### for entry in x: if string.strip(entry) == "": continue # ... the rest is the same ### "continue" will tell Python to skip this element, and consider the next element in x. For example: ### >>> for x in range(10): ... if x % 2 == 0: continue ... print x ... 1 3 5 7 9 ### Another, more robust way to fix this problem is to use exception handling. Can someone give a good explanation about this? > Notice all the '\r' entries. Use string.strip() to get rid of that trailing whitespace stuff. strip() will help you clean up a string from both the left and right side. It's probably better to do it after unpacking the tuple, just to get rid of all that whitespace at once. Hope this helps! From jsc@rock-tnsc.com Wed Apr 11 03:15:44 2001 From: jsc@rock-tnsc.com (Jethro Cramp) Date: Tue, 10 Apr 2001 18:15:44 -0800 Subject: [Tutor] Problem Moving Python Program From WIndows to Linux References: <Pine.LNX.4.21.0104100231130.31744-100000@hkn.eecs.berkeley.edu> Message-ID: <3AD3BE50.6020905@rock-tnsc.com> Dear Daniel, Thanks alot for the suggestions. Given me several ideas and introduced me to the "continue" function. Can you recommend any utilities to strip "\r" from files. I tried doing search and replace in idle but that failed. Also if I do strip all the "\r" will that render the scripts inoperable under windows? Jethro From kalle@gnupung.net Tue Apr 10 11:59:56 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Tue, 10 Apr 2001 12:59:56 +0200 Subject: [Tutor] Problem Moving Python Program From WIndows to Linux In-Reply-To: <3AD3BE50.6020905@rock-tnsc.com>; from jsc@rock-tnsc.com on Tue, Apr 10, 2001 at 06:15:44PM -0800 References: <Pine.LNX.4.21.0104100231130.31744-100000@hkn.eecs.berkeley.edu> <3AD3BE50.6020905@rock-tnsc.com> Message-ID: <20010410125955.A30323@father> Sez Jethro Cramp: > Can you recommend any utilities to strip "\r" from files. I tried doing > search and replace in idle but that failed. s = open("afile").read() s = s.replace("\r", "") open("afile", "w").write(s) Will remove all "\r"s from "afile". > Also if I do strip all the "\r" will that render the scripts inoperable > under windows? I don't think so, but haven't tested. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From moshez@zadka.site.co.il Tue Apr 10 12:04:31 2001 From: moshez@zadka.site.co.il (Moshe Zadka) Date: Tue, 10 Apr 2001 14:04:31 +0300 Subject: [Tutor] Message persistence In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D6CF@mbtlipnt02.btlabs.bt.co.uk> References: <5104D4DBC598D211B5FE0000F8FE7EB20751D6CF@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <E14mvwl-0001fm-00@darjeeling> On Mon, 9 Apr 2001 11:35:59 +0100, alan.gauld@bt.com wrote: > Same as any other kind of persistence: > > 1) Store in memory - valid for life of process > 2) Store in flat files - fine oif not too many > - maybe OK if a file per thread? > 3) pickle/shelve - save the thread object as above > but less work :-) > 4) Use a database - best if any real volumes involved. > Pick any database that runs on your platform and > has a Python data driver module Alan was a bit vague re 4), one important option is ZODB, which now has a project all to itself, without Zope. www.amk.ca links to it. Which of course brings up the question, why not use Zope? -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez@debian.org |http://www.{python,debian,gnu}.org From moshez@zadka.site.co.il Tue Apr 10 12:08:01 2001 From: moshez@zadka.site.co.il (Moshe Zadka) Date: Tue, 10 Apr 2001 14:08:01 +0300 Subject: [Tutor] Primes on a two-dimensional plane in the form of a rectangular spiral In-Reply-To: <14CE6196C60@kserver.org> References: <14CE6196C60@kserver.org>, <OE70ztxc1o8yfogkJXr00000d12@hotmail.com> <3AD15BCB.CB1E1B5E@aon.at> Message-ID: <E14mw09-0001hU-00@darjeeling> On Sun, 08 Apr 2001, Sheila King <sheila@thinkspot.net> wrote: > However, this algorithm requires that you start from the number "two" and work > your way on up. I don't believe there is any way to start at an arbitrary > prime number and find the next prime without knowing the preceding primes. So, > you'd have to implement the Sieve of Erasthones in any case, even though you > were only interested in finding a single number. > > I'm always willing to find out I'm wrong, if someone else knows better... Dead wrong! The quicket algorithm would be to use Rabin's Criterion for primality, starting at p, and moving up. It is guranteed to stop before 2*p. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez@debian.org |http://www.{python,debian,gnu}.org From rick@niof.net Tue Apr 10 14:13:41 2001 From: rick@niof.net (Rick Pasotto) Date: Tue, 10 Apr 2001 09:13:41 -0400 Subject: [Tutor] pyopengl name error In-Reply-To: <3AD2419E.BB5FBB1E@verio.net>; from vlindberg@verio.net on Mon, Apr 09, 2001 at 05:11:26PM -0600 References: <3AD2419E.BB5FBB1E@verio.net> Message-ID: <20010410091341.E554@tc.niof.net> On Mon, Apr 09, 2001 at 05:11:26PM -0600, VanL wrote: > Hello, > > If this is too pyopengl-specific, I'll take this question there. > However, it seems to actually be a problem with namespaces, so I decided > to try this group first. > > I installed pyOpenGL. I can import it, get a listing of available > functions from dir(), etc. However, When I try to run the example code > drawcube.py, I get the following error: > > Traceback (most recent call last): > File "glut.py", line 69, in OnDraw > drawCube() > File "drawcube.py", line 3, in drawCube > OpenGL.GL.glTranslatef(0.0, 0.0, -2.0); > NameError: There is no variable named 'OpenGL' > Traceback (most recent call last): > File "glut.py", line 69, in OnDraw > drawCube() > File "drawcube.py", line 3, in drawCube > OpenGL.GL.glTranslatef(0.0, 0.0, -2.0); > NameError: There is no variable named 'OpenGL' > Traceback (most recent call last): > File "glut.py", line 69, in OnDraw > drawCube() > File "drawcube.py", line 3, in drawCube > OpenGL.GL.glTranslatef(0.0, 0.0, -2.0); > NameError: There is no variable named 'OpenGL' > > > Here is the code throwing the exception: > > > '''GLUT rendering context sample > ''' > from OpenGL.GL import * > from OpenGL.GLUT import * You haven't imported OpenGL. Instead you have imported some of the *contents* of OpenGL. Change your line to glTranslatef(0.0, 0.0, -2.0) and I suspect it will work. -- "Being an elected Libertarian is like being a designated driver in a bar." --- Michael Emerling Cloud Rick Pasotto email: rickp@telocity.com From dsh8290@rit.edu Tue Apr 10 15:00:06 2001 From: dsh8290@rit.edu (D-Man) Date: Tue, 10 Apr 2001 10:00:06 -0400 Subject: [Tutor] Problem Moving Python Program From WIndows to Linux In-Reply-To: <3AD3BE50.6020905@rock-tnsc.com>; from jsc@rock-tnsc.com on Tue, Apr 10, 2001 at 06:15:44PM -0800 References: <Pine.LNX.4.21.0104100231130.31744-100000@hkn.eecs.berkeley.edu> <3AD3BE50.6020905@rock-tnsc.com> Message-ID: <20010410100006.B1942@harmony.cs.rit.edu> On Tue, Apr 10, 2001 at 06:15:44PM -0800, Jethro Cramp wrote: | Dear Daniel, | | Thanks alot for the suggestions. Given me several ideas and introduced | me to the "continue" function. <nitpick> it's a keyword, not a function </nitpick> | Can you recommend any utilities to strip "\r" from files. I tried doing | search and replace in idle but that failed. In vim : :%s/^V^M// or you can use the python script Kalle suggested. | Also if I do strip all the "\r" will that render the scripts inoperable | under windows? No. I use windows at work and in (g)vim (my favorite editor) I set it to not include the extra, useless, \r characters on each line. Where you will run into trouble is if you write the file on a windows system it will normally translate \n to \r\n in the write operation. If you treat the file as a text file and look for empty lines rather than \n expicitly it will work fine across systems. The other alternative is to open the (data) file in 'binary' mode. Then you will have full control over the contents. Operating systems really shouldn't be mangling your files like that anyways (IMO); it's the job of the library to handle that filetype to do any necessary mangling. -D From kromag@nsacom.net Tue Apr 10 18:23:52 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Tue, 10 Apr 2001 10:23:52 -0700 (PDT) Subject: [Tutor] Compilation of python on win95b using bcc 5.5 Message-ID: <200104101723.f3AHNqk07382@pop.nsacom.net> Help the windows newbie please. I have learned to use configure and make and have become addicted: Since my company uses a standardized windows image based on win95b (for the time being...) and the only compiler available to me is the Borland C++ v. 5.5, I fear I have become a little lost. Is there a Win32 compilation howto anywhere? I have not been able to find one on the python site. Thanks! From ium@micromuse.com Tue Apr 10 16:27:39 2001 From: ium@micromuse.com (ibraheem umaru-mohammed) Date: Tue, 10 Apr 2001 16:27:39 +0100 Subject: [Tutor] Problem Moving Python Program From WIndows to Linux In-Reply-To: <20010410100006.B1942@harmony.cs.rit.edu>; from dsh8290@rit.edu on Tue, Apr 10, 2001 at 10:00:06AM -0400 References: <Pine.LNX.4.21.0104100231130.31744-100000@hkn.eecs.berkeley.edu> <3AD3BE50.6020905@rock-tnsc.com> <20010410100006.B1942@harmony.cs.rit.edu> Message-ID: <20010410162738.A2738@ignoramus> [D-Man wrote...] -| | Can you recommend any utilities to strip "\r" from files. I tried doing -| | search and replace in idle but that failed. -| -| In vim : -| -| :%s/^V^M// -| You could also just use the fileformat command under Vim. :help ff and then just do something like :set ff=dos or :set ff=unix This will automatically handle fileformat issues. Hope that helps, Kindest regards, --ibs. -- The best you get is an even break. -- Franklin Adams From Glen@ihello-inc.com Tue Apr 10 20:54:06 2001 From: Glen@ihello-inc.com (Glen Bunting) Date: Tue, 10 Apr 2001 12:54:06 -0700 Subject: [Tutor] tkinter displaying results? Message-ID: <A50594A71D5FD311A00200902745F06F18A4BA@go.ihello.com> Hi , I am trying to write a program that will diplay my bandwidth speed. I have the program basically written, however I want it to disply the results in a gui. I am trying to use Tkinter, but I keep getting NameErrors in regards to the variable that I have the result stored in. Does anyone have any ideas? Thanks Glen From Glen@ihello-inc.com Tue Apr 10 21:34:59 2001 From: Glen@ihello-inc.com (Glen Bunting) Date: Tue, 10 Apr 2001 13:34:59 -0700 Subject: [Tutor] tkinter displaying results? Message-ID: <A50594A71D5FD311A00200902745F06F18A4BB@go.ihello.com> Please ignore the previous message, I figured it out. Glen -----Original Message----- From: Glen Bunting [mailto:Glen@ihello-inc.com] Sent: Tuesday, April 10, 2001 12:54 PM To: 'tutor@python.org' Subject: [Tutor] tkinter displaying results? Hi , I am trying to write a program that will diplay my bandwidth speed. I have the program basically written, however I want it to disply the results in a gui. I am trying to use Tkinter, but I keep getting NameErrors in regards to the variable that I have the result stored in. Does anyone have any ideas? Thanks Glen _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From Glen@ihello-inc.com Tue Apr 10 23:27:09 2001 From: Glen@ihello-inc.com (Glen Bunting) Date: Tue, 10 Apr 2001 15:27:09 -0700 Subject: [Tutor] (no subject) Message-ID: <A50594A71D5FD311A00200902745F06F18A4BF@go.ihello.com> Below is a simple script I wrote to download a file, time how long it takes to download and display the bandwidth usage in Tkinter. It works initially. But the while loop does not work. After the initial run, the program just hangs there and I cannot even exit out of the Tkinter that pops up. What am I doing wrong? Thanks #!/usr/bin/env python import os, urllib, time, Tkinter from Tkinter import * while 1: urllib.urlopen('http://www.esynch.com') first = time.time() urllib.urlretrieve('http://www.esynch.com/mw_test.dat', 'test') second = time.time() speed1 = second - first print speed1 speed = round(speed1, 1) top = Tkinter.Tk() label = Tkinter.Label(top, text = 'Kilobytes/sec:') label.pack() bandwidth = Tkinter.Label(top, text = speed) bandwidth.pack() quit = Tkinter.Button(top, text = 'QUIT', command=top.quit, bg='red', fg='white') quit.pack() Tkinter.mainloop() time.sleep(500) Glen From Kishore.Prayaga@li.csiro.au Wed Apr 11 04:31:16 2001 From: Kishore.Prayaga@li.csiro.au (Kishore Prayaga) Date: Wed, 11 Apr 2001 13:31:16 +1000 Subject: [Tutor] help Message-ID: <4.2.2.20010411131240.00ba6470@mailhost> Hi Here is a small example of a data file and the script I want write in python to do the job. Please let me know the solution for this data file model: A 62 35.0 A 96 47.0 A 107 56.0 B 42 38.0 B 147 46.0 B 183 52.0 C 34 26.0 C 86 43.0 C 108 52.0 ........................ and so on My idea is to count second column with in the first column serially (which i could do) and then calculate the increment in the third column for every increae in the second column with in the first column. i.e for A 62 35.0 the result would be 35.0 - 35.0 =0 for A 96 47.0 the result would be 47.0 - 35.0 =12.0 for A 107 56.0 the result would be 56.0 - 47.0 =9.0 ...............so on with the following script I could do upto counting and to calculate the differences part I need help #!/usr/bin/python import string, sys infile = open('litint.out') outputfile=open('litint1.out', "w") data = {} for line in infile.readlines(): line = line[0:-1] fields = string.split(line,' ') dam_id = fields[0] age = string.atoi(fields[1]) litter = string.atoi(fields[2]) if data.has_key(dam_id): pass else: data[dam_id] ={} data[dam_id][litter] = fields dkeys= data.keys() dkeys.sort() for dam in dkeys: lkeys = data[dam].keys() lkeys.sort() n = 0 for litter in lkeys: n = n+1 total =data[dam][litter] outputfile.write('%s' % n) for i in range(0, len(total)): outputfile.write(' %s' % (total[i])) outputfile.write('\n') ********************************************************* Dr.Kishore C. Prayaga CSIRO Livestock Industries Locked bag 1 Armidale NSW 2350 Australia Ph: (02) 6776 1379 / (02) 6776 1420 Fax: (02) 6776 1371 e-mail: Kishore.Prayaga@li.csiro.au ********************************************************* From kromag@nsacom.net Wed Apr 11 06:42:59 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Tue, 10 Apr 2001 22:42:59 -0700 (PDT) Subject: [Tutor] _pg module and the insertion of random numbers... Message-ID: <200104110542.f3B5gxk07448@pop.nsacom.net> I am attempting to insert random numbers into a PostGreSQL database using _pg and random. I am unsure as to syntax when adding variables. I have attempted the following: import _pg import random db.connect('test', 'localhost') db.query("insert into pork values(`random.randint(1,1000)`+ 'stuff' +'1-2- 1999')") which returns a parse error at the second opening parenthesis. I have also attempted: db.query("insert into pork values('`random.randint(1,1000)`', 'stuff', '1-2- 1999')") which inserts random.randint() as a literal string. What am I doing wrong? From jsc_lists@rock-tnsc.com Wed Apr 11 20:47:05 2001 From: jsc_lists@rock-tnsc.com (Jethro Cramp) Date: Wed, 11 Apr 2001 11:47:05 -0800 Subject: [Tutor] Configuring Xemacs highlighting for Python Message-ID: <3AD4B4B9.4000200@rock-tnsc.com> Can anyone give me some pointers on how to configure the colour highlighting in python mode in XEmacs? Presumably I have to edit the python-mode.el file and then re-compile it. I have looked at this file but can't see what, if anything, I should change. Thanks in advance. Jethro From jsc@rock-tnsc.com Wed Apr 11 21:08:23 2001 From: jsc@rock-tnsc.com (Jethro Cramp) Date: Wed, 11 Apr 2001 12:08:23 -0800 Subject: [Tutor] Problem Moving Python Program From WIndows to Linux References: <Pine.LNX.4.21.0104100231130.31744-100000@hkn.eecs.berkeley.edu> <3AD3BE50.6020905@rock-tnsc.com> <20010410125955.A30323@father> Message-ID: <3AD4B9B7.1070605@rock-tnsc.com> Kalle Svensson wrote: > Sez Jethro Cramp: > >> Can you recommend any utilities to strip "\r" from files. I tried doing >> search and replace in idle but that failed. > > > s = open("afile").read() > s = s.replace("\r", "") > open("afile", "w").write(s) > > Will remove all "\r"s from "afile". > > >> Also if I do strip all the "\r" will that render the scripts inoperable >> under windows? > > > I don't think so, but haven't tested. > > Peace, > Kalle Thanks. Worked a treat. Jethro From kromag@nsacom.net Wed Apr 11 07:48:26 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Tue, 10 Apr 2001 23:48:26 -0700 (PDT) Subject: [Tutor] Idle/PyGreSQL weirditude. Message-ID: <200104110648.f3B6mQk32144@pop.nsacom.net> I have a rather strange (maybe) bug occouring in IDLE (2.1b2) when attempting to query a PostGreSQL database using the _pg module When attempting the following: import _pg db=_pg.connect('test','localhost') db.query("select * from pork") I get <pg query result> instead of the actual data from the query. Is there something I am missing? From NHYTRO@compuserve.com Wed Apr 11 09:54:37 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Wed, 11 Apr 2001 04:54:37 -0400 Subject: [Tutor] Python variable in SQL statement Message-ID: <200104110454_MC2-CC0C-FC98@compuserve.com> Message text written by INTERNET:tutor@python.org >< I=B4m trying to generate dynamic web pages by reading chunks of HTML from= a database, my prob is, my SQL statements using the Python ODBC module does= not recognize my python container: ###### my code ## print "Content-Type: text/html\n\n" import cgi, dbi, odbc, time # # # my HTML container # template0 =3D """ <html> <head><title>blah</title></head> <body> adkasdkadkadjakdjakdjakdjadjada, adadadad dadadadada,dadadad dadadad adada dad adada adad <body> <html> """ #database access connection =3D odbc.odbc('minicms') cur =3D connection.cursor() cur.execute('select * from dummy') for a in range(3): cur.execute("insert into dummy(fieldtwo, fieldthree) values('foonav',= template0)") connection.commit() cur.close() connection.close() ###### end code ### The ODBC driver states that only one value has been given, it just overlooks the "template0" big string container that I declared. Thanks for your anticipated help in advance Sharriff From dyoo@hkn.eecs.berkeley.edu Wed Apr 11 10:09:30 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 02:09:30 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <A50594A71D5FD311A00200902745F06F18A4BF@go.ihello.com> Message-ID: <Pine.LNX.4.21.0104110142430.28551-100000@hkn.eecs.berkeley.edu> On Tue, 10 Apr 2001, Glen Bunting wrote: > Below is a simple script I wrote to download a file, time how long it takes > to download and display the bandwidth usage in Tkinter. It works initially. > But the while loop does not work. After the initial run, the program just > hangs there and I cannot even exit out of the Tkinter that pops up. What am > I doing wrong? When we hit the mainloop() command, Tkinter takes control, and doesn't exit the mainloop() function until we shut down the gui by closing all windows (or calling quit()). It's meant to be the last command in a program, so that's what's causing the while loop to "hang". It looks like you want to update your display every once in a while: try using the after() method: it tells Tkinter to call a function "after" a certain period of time. For example: ### from Tkinter import * root = Tk() def addLabelContinuously(): Label(root, text='hola').pack() root.after(1000, addLabelContinuously) addLabelContinuously() mainloop() ### is a funny little program that, after every second, pack()s in a new label into our main window. Not very useful, but it illustrates how to use after() a little bit. I hope you don't mind, but I wanted to try converting your code with OOP. As a result, I've mutilated your code somewhat beyond recognition. ### from Tkinter import * import os, urllib, time class GUI(Frame): def __init__(self, root): Frame.__init__(self, root) self.speedvar = StringVar() self.updateSpeedvar() Label(self, text='Kilobytes/sec:').pack() Label(self, textvariable=self.speedvar).pack() Button(self, text='QUIT', command=self.quit, bg='red', fg='white').pack() def updateSpeedvar(self): first = time.time() urllib.urlretrieve('http://www.esynch.com/mw_test.dat', 'test') second = time.time() speed1 = second - first print speed1 speed = round(speed1, 1) self.speedvar.set(speed) self.after(500, self.updateSpeedvar) if __name__ == '__main__': root = Tk() gui = GUI(root) gui.pack() mainloop() ### From danny@intuitivemedia.com Wed Apr 11 10:13:46 2001 From: danny@intuitivemedia.com (Danny Ruttle) Date: Wed, 11 Apr 2001 10:13:46 +0100 Subject: [Tutor] Cursors as Dictionaries Message-ID: <5.0.2.1.0.20010411100042.00a0caa0@mail.moonshine.co.uk> I understand that the Python DB2 API allows the results of a database query to be returned as a dictionary. I have tried the following: >>> import PgSQL >>> import libpq >>> >>> db_init = PgSQL.connect(database="testdb3") >>> my_cursor = db_init.cursor() >>> my_cursor.execute("select user_id, first_name from ruser") >>> dict = {} >>> dict = my_cursor.fetchall() but when I try to access the dictionary I get the following error: >>> h = dict.keys() Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: keys On further investigation I discovered that the type of dict is now a list!! >>> dir(dict) ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] >>> print dict[0] ['abf1tu', 'Amy'] This isn't what I want - I need the field names as well as the data in the result set. regards Danny From dyoo@hkn.eecs.berkeley.edu Wed Apr 11 10:17:06 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 02:17:06 -0700 (PDT) Subject: [Tutor] Compilation of python on win95b using bcc 5.5 In-Reply-To: <200104101723.f3AHNqk07382@pop.nsacom.net> Message-ID: <Pine.LNX.4.21.0104110209410.28551-100000@hkn.eecs.berkeley.edu> On Tue, 10 Apr 2001 kromag@nsacom.net wrote: > Help the windows newbie please. > > I have learned to use configure and make and have become addicted: > > Since my company uses a standardized windows image based on win95b (for the > time being...) and the only compiler available to me is the Borland C++ v. > 5.5, I fear I have become a little lost. > > Is there a Win32 compilation howto anywhere? I have not been able to find one > on the python site. I believe that the compilation environment is optimized for Visual C++. However, Guido van Rossum has written some notes about doing Borland stuff: http://www.cwi.nl/www.python.org/search/hypermail/python-1994q1/0415.html Unfortunately, this is from WAY back in 1994, so the situation now might be so different that the material above might not apply. Furthermore, on the Python web site, the webmaster has written the following warning: "The build process is explained clearly in the file PC/readme.txt contained in the distribution. Only MSVC++ is supported. (Although the source presumably still compiles with the Borland compilers, and there is support for it in config.h, there are currently no Borland project or Makefiles. We lack the personnel to spend time supporting alternate compilers, and nobody has volunteered yet.)" So you're probably going to need to do some work to get Python compiled. I get the feeling that many of us haven't compiled our own Python interpreter, so we might not be able to help with this. Do you really need to compile your own Python interpreter, or are the prebuilt binaries ok for your purposes? Try asking your question in comp.lang.python instead, and you should get better responses. Good luck! From wong_chow_cheok@hotmail.com Wed Apr 11 11:03:14 2001 From: wong_chow_cheok@hotmail.com (wong chow cheok) Date: Wed, 11 Apr 2001 18:03:14 +0800 Subject: [Tutor] (no subject) Message-ID: <F90vY3PUKIYs5CRTYBK00000bed@hotmail.com> hai this is chow cheok again. got another problem here. this is what i have so far f=open('you','w') html=urllib.urlopen("http://www.guardian.co.uk/Distribution/Artifact_Trail_Block/0,5184,179821-0-,00.html").read() f.write(html) but when i read it i don't get the file from the website. all i get is rubbish. why is that. even when i try to write a line ex:"i am a boy' i get rubbish too. the only thing i can write to the file is '12345abcd' and other strings similar to it. how do i write the information i got from the website into the file. it can print out fine when i type print html. but it won't enter my file. any help is appreciated. thank you ps. thanks for all the advise you all have given in the past. it has been very helpful. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From dyoo@hkn.eecs.berkeley.edu Wed Apr 11 11:03:33 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 03:03:33 -0700 (PDT) Subject: [Tutor] Cursors as Dictionaries In-Reply-To: <5.0.2.1.0.20010411100042.00a0caa0@mail.moonshine.co.uk> Message-ID: <Pine.LNX.4.21.0104110256360.30421-100000@hkn.eecs.berkeley.edu> On Wed, 11 Apr 2001, Danny Ruttle wrote: > I understand that the Python DB2 API allows the > results of a database query to be returned as a > dictionary. Can you point out where you saw this? > I have tried the following: > > >>> import PgSQL > >>> import libpq > >>> > >>> db_init = PgSQL.connect(database="testdb3") > >>> my_cursor = db_init.cursor() > >>> my_cursor.execute("select user_id, first_name from ruser") > >>> dict = {} > >>> dict = my_cursor.fetchall() > > but when I try to access the dictionary I get the following error: > > >>> h = dict.keys() > Traceback (most recent call last): > File "<stdin>", line 1, in ? > AttributeError: keys > > On further investigation I discovered that the type of > dict is now a list!! SQL fetchall()'s should return back a list of results. More formally, they return a sequence of sequences, not a dictionary. > This isn't what I want - I need the field names as well as the data in the > result set. You'll probably need to look at the "description" attribute of your cursor object, after you do the execute. According to: http://python.org/topics/database/DatabaseAPI-2.0.html after doing the execute, the database module should automagically fill in that information so you can take a look at it. By the way, have you tried working with SQLDict? This might be a useful module for you: http://dustman.net/andy/python/SQLDict Dunno how well it works with Postgres, but I hope it comes in handy. From dyoo@hkn.eecs.berkeley.edu Wed Apr 11 11:14:07 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 03:14:07 -0700 (PDT) Subject: [Tutor] _pg module and the insertion of random numbers... In-Reply-To: <200104110542.f3B5gxk07448@pop.nsacom.net> Message-ID: <Pine.LNX.4.21.0104110304060.30421-100000@hkn.eecs.berkeley.edu> On Tue, 10 Apr 2001 kromag@nsacom.net wrote: > I am attempting to insert random numbers into a PostGreSQL database using _pg > and random. I am unsure as to syntax when adding variables. > > I have attempted the following: > > import _pg > import random > db.connect('test', 'localhost') > db.query("insert into pork values(`random.randint(1,1000)`+ 'stuff' +'1-2- > 1999')") Python doesn't do string interpolation within strings until you actually trigger it. That is, as far as Python is concerned, both the single and double quotes have the same meaning: there's no difference between them, and no "interpolative context" as in Perl. What you passed to the query was probably the literal string: insert into pork values(`random.randint(1,1000)`+ 'stuff'+'1-2-1999') Instead, you'll probably want to use the string interpolation operator '%'. There's a brief explanation about it here: http://python.org/doc/current/tut/node9.html#SECTION009100000000000000000 The main idea is to tell Python to "fill in the blanks" --- wherever it sees a '%s' within the string, it'll replace it with something useful when we actually do the interpolation: db.query("insert into pork values(%s, stuff, 1-2-1999)" % random.randint(1, 1000)) Try some examples from the tutorial, and if it's still a little unclear, feel free to ask us questions about it. Good luck! From dyoo@hkn.eecs.berkeley.edu Wed Apr 11 11:25:33 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 03:25:33 -0700 (PDT) Subject: [Tutor] Python variable in SQL statement [String interpolation] In-Reply-To: <200104110454_MC2-CC0C-FC98@compuserve.com> Message-ID: <Pine.LNX.4.21.0104110314280.30421-100000@hkn.eecs.berkeley.edu> On Wed, 11 Apr 2001, Sharriff Aina wrote: > #database access > connection = odbc.odbc('minicms') > cur = connection.cursor() > cur.execute('select * from dummy') > for a in range(3): > cur.execute("insert into dummy(fieldtwo, fieldthree) values('foonav', > template0)") > connection.commit() > cur.close() > connection.close() > ###### end code ### > > > The ODBC driver states that only one value has been given, it just > overlooks the "template0" big string container that I declared. (I'm starting to sound like a broken record! *grin*) The reason why template0 isn't being substituted into your SQL string is because Python doesn't know when do do this sort of substitution. For example, if we did something like the following: a = 100 s = "Hello, this is the letter 'a'". should our string s contain: "Hello, this is the letter 'a'", or "Hello, this is the letter '100'" How would Python know? Because of the ambiguity of such situations, Python design dictates less guesswork --- it will not "interpolate" or fill in a string with variable values, until we actually tell it to do it explicitly. That's where string interpolation comes in. Take a look at: http://python.org/doc/current/tut/node9.html#SECTION009100000000000000000 which shows some brief examples about this topic. Also, the page: http://python.sourceforge.net/devel-docs/lib/typesseq-strings.html gives a much drier explanation of string interpolation. From dyoo@hkn.eecs.berkeley.edu Wed Apr 11 11:34:21 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 03:34:21 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <F90vY3PUKIYs5CRTYBK00000bed@hotmail.com> Message-ID: <Pine.LNX.4.21.0104110327140.30827-100000@hkn.eecs.berkeley.edu> On Wed, 11 Apr 2001, wong chow cheok wrote: > hai this is chow cheok again. got another problem here. > this is what i have so far > > f=open('you','w') > html=urllib.urlopen("http://www.guardian.co.uk/Distribution/Artifact_Trail_Block/0,5184,179821-0-,00.html").read() > f.write(html) > > but when i read it i don't get the file from the website. all i get is > rubbish. why is that. even when i try to write a line ex:"i am a boy' What kind of contents are you getting? When I visit that link with my Netscape browser, it spits out the "Sorry, the page you requested is not available at this moment." Could you check the URL again? Also, it's usually helpful to show us what a small portion of the file looks like: although it might not be understandable, it might contain clues about why it's not doing the right thing. > i get rubbish too. the only thing i can write to the file is '12345abcd' and > other strings similar to it. how do i write the information i got from the > website into the file. it can print out fine when i type > print html. Your program looks ok; I'm guessing either the web site is down, or the url needs to be corrected. By the way, try the following program, and see if it works ok for you: ### f = open('evens.txt', 'w') f.write("This is a file that contains even numbers.\n\n") for i in range(20, 2): f.write(i) f.write(' ') f.close() ### It does enough file writing to help you see if file output is working well. From kalle@gnupung.net Wed Apr 11 12:14:13 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Wed, 11 Apr 2001 13:14:13 +0200 Subject: [Tutor] _pg module and the insertion of random numbers... In-Reply-To: <200104110542.f3B5gxk07448@pop.nsacom.net>; from kromag@nsacom.net on Tue, Apr 10, 2001 at 10:42:59PM -0700 References: <200104110542.f3B5gxk07448@pop.nsacom.net> Message-ID: <20010411131413.A10701@father> Sez kromag@nsacom.net: > I am attempting to insert random numbers into a PostGreSQL database using _pg > and random. I am unsure as to syntax when adding variables. > > I have attempted the following: > > import _pg > import random > db.connect('test', 'localhost') > db.query("insert into pork values(`random.randint(1,1000)`+ 'stuff' +'1-2- > 1999')") db.query("insert into pork values(" + `random.randint(1,1000)` + ", 'stuff', '1-2-1999')") should work, but I haven't tested. Also note that use of backticks for stringification is quite uncommon. Using the builtin functions str() or repr() (which is equivalent to backticks) is far more common. repr(123) == `123` # this is always true str(123) == `123` # this isn't always true, but works for integers. Another way to do it is to use the % operator: "insert into pork values(%d, 'stuff', '1-2-1999')" % random.randint(1,1000)) > What am I doing wrong? I think you got lost in a maze of twisty little quotes, all alike. <wink> Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From NHYTRO@compuserve.com Wed Apr 11 13:30:12 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Wed, 11 Apr 2001 08:30:12 -0400 Subject: [Tutor] Interpolative content Message-ID: <200104110830_MC2-CBFA-D759@compuserve.com> Thanks Mr. Yoo, Mr, Coughlin! I=B4m not gonna get chewed up by my boss after all... did I ever mention how much I=B4m enjoying Python...I=B4ll never open tho= se Java books of mine again.. Best regards and thanks Sharriff From shaleh@valinux.com Wed Apr 11 17:56:34 2001 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Wed, 11 Apr 2001 09:56:34 -0700 (PDT) Subject: [Tutor] Configuring Xemacs highlighting for Python In-Reply-To: <3AD4B4B9.4000200@rock-tnsc.com> Message-ID: <XFMail.20010411095634.shaleh@valinux.com> On 11-Apr-2001 Jethro Cramp wrote: > Can anyone give me some pointers on how to configure the colour > highlighting in python mode in XEmacs? > > Presumably I have to edit the python-mode.el file and then re-compile > it. I have looked at this file but can't see what, if anything, I should > change. > ;; figure out which face is being used (defun describe-face-at-point () "Return face used at point." (interactive) (hyper-describe-face (get-char-property (point) 'face))) I have this in my .emacs file. I put the pointer on the item I want to change, type M-X describe-face-at-point and it opens a second frame which shows me all of the attributes. From Glen@ihello-inc.com Wed Apr 11 18:27:42 2001 From: Glen@ihello-inc.com (Glen Bunting) Date: Wed, 11 Apr 2001 10:27:42 -0700 Subject: [Tutor] (no subject) Message-ID: <A50594A71D5FD311A00200902745F06F18A4C1@go.ihello.com> Daniel, Your version works perfectly except for one thing, when I click on the quit button, nothing happens. I will continue to use the program the way you wrote it, but I have a few questions about the way I was trying to write it. 1: The after() method does not redraw or refresh the speed variable, all it does is reprint the variable below the original after the time specified. 2: As long as Tkinter.mainloop() remains in the while loop, the while loop does not continue until after I quit Tkinter. Once I do that the loop continues. If I take Tkinter.mainloop out of the while loop, the loop continues like it should , but the gui never pops up. Any suggestions? The next thing I might be interested in doing is to graph the results. Is that the next logical step, or would that be a little to advanced for a newbie? Thanks Glen -----Original Message----- From: Daniel Yoo [mailto:dyoo@hkn.eecs.berkeley.edu] Sent: Wednesday, April 11, 2001 2:10 AM To: Glen Bunting Cc: 'tutor@python.org' Subject: Re: [Tutor] (no subject) On Tue, 10 Apr 2001, Glen Bunting wrote: > Below is a simple script I wrote to download a file, time how long it takes > to download and display the bandwidth usage in Tkinter. It works initially. > But the while loop does not work. After the initial run, the program just > hangs there and I cannot even exit out of the Tkinter that pops up. What am > I doing wrong? When we hit the mainloop() command, Tkinter takes control, and doesn't exit the mainloop() function until we shut down the gui by closing all windows (or calling quit()). It's meant to be the last command in a program, so that's what's causing the while loop to "hang". It looks like you want to update your display every once in a while: try using the after() method: it tells Tkinter to call a function "after" a certain period of time. For example: ### from Tkinter import * root = Tk() def addLabelContinuously(): Label(root, text='hola').pack() root.after(1000, addLabelContinuously) addLabelContinuously() mainloop() ### is a funny little program that, after every second, pack()s in a new label into our main window. Not very useful, but it illustrates how to use after() a little bit. I hope you don't mind, but I wanted to try converting your code with OOP. As a result, I've mutilated your code somewhat beyond recognition. ### from Tkinter import * import os, urllib, time class GUI(Frame): def __init__(self, root): Frame.__init__(self, root) self.speedvar = StringVar() self.updateSpeedvar() Label(self, text='Kilobytes/sec:').pack() Label(self, textvariable=self.speedvar).pack() Button(self, text='QUIT', command=self.quit, bg='red', fg='white').pack() def updateSpeedvar(self): first = time.time() urllib.urlretrieve('http://www.esynch.com/mw_test.dat', 'test') second = time.time() speed1 = second - first print speed1 speed = round(speed1, 1) self.speedvar.set(speed) self.after(500, self.updateSpeedvar) if __name__ == '__main__': root = Tk() gui = GUI(root) gui.pack() mainloop() ### From m_konermann@gmx.de Wed Apr 11 22:45:20 2001 From: m_konermann@gmx.de (Marcus Konermann) Date: Wed, 11 Apr 2001 23:45:20 +0200 Subject: [Tutor] Need help on a simple problem (i think) Message-ID: <3AD4D070.2CE8C5DE@gmx.de> --------------F02AE80BD61521123CF7363D Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello ! I´ve got two moduls. The first one is mainko.py and the second one functions.py and i only want to call a method from the mainko.py modul named test, wich is declared in the modul functions.py. This is mainko.py : import string,re,sys,glob,operator from functions import * import os #print os.getcwd() #print os.listdir(os.getcwd()) #ausgabe=[] print 'test()=',test() #abweichung('soll.out',(((3,5),1),((7,9),1)),'ist.out',(((3,5),1),((7,9),1)),r'\d+\.\d+[E][+-]\d+',r'[ ]+') #print 'ausgabe=',ausgabe #((3,5),1),(4,(1,3)),(5,1))) and this is the modul functions.py : import string,sys from math import * from types import * from identify import identification class operation(identification): def __init__(self,srchfiles,pattfile,splitfile): identification.__init__(self,srchfiles,pattfile,splitfile) def test(self): print'it is ok' and the ERROR Output from Python is the following: test()=Traceback (innermost last): File "C:\Arbeit_Studienarbeit\PythonPROG\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "C:\Arbeit_Studienarbeit\Arbeit\Marcus\aktuell\mainko.py", line 8, in ? print 'test()=',test() NameError: test and I don´t know why there´s a NameError. I´m using Pythonwin under Win98 and a few days before i put my working directory in another destination, probably there could be an answer of my problem. I already put the following PATH Command in my autoexec.bat: SET PYTHONPATH=c:\arbeit_studienarbeit\arbeit\marcus\aktuell;c:\arbeit_studienarbeit\pythonprog\lib but nothing happend. So ,can anyone help me ??? Thanks a lot Marcus --------------F02AE80BD61521123CF7363D Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> Hello ! <p>I´ve got two moduls. The first one is mainko.py and the second one functions.py and i only want to call a method from the mainko.py modul named test, wich is declared in the modul functions.py. <br>This is mainko.py : <p><i>import string,re,sys,glob,operator</i> <br><i>from functions import *</i> <br><i>import os</i> <p><i>#print os.getcwd()</i> <br><i>#print os.listdir(os.getcwd())</i> <br><i>#ausgabe=[]</i> <br><i>print 'test()=',test()</i> <br><i>#abweichung('soll.out',(((3,5),1),((7,9),1)),'ist.out',(((3,5),1),((7,9),1)),r'\d+\.\d+[E][+-]\d+',r'[ ]+')</i> <br><i>#print 'ausgabe=',ausgabe</i> <p><i>#((3,5),1),(4,(1,3)),(5,1)))</i> <p>and this is the modul functions.py : <p><i>import string,sys</i> <br><i>from math import *</i> <br><i>from types import *</i> <br><i>from identify import identification</i> <p><i>class operation(identification):</i> <p><i> def __init__(self,srchfiles,pattfile,splitfile):</i> <br><i> identification.__init__(self,srchfiles,pattfile,splitfile)</i> <p><i> def test(self):</i> <br><i> print'it is ok'</i> <p>and the ERROR Output from Python is the following: <p><i>test()=Traceback (innermost last):</i> <br><i> File "C:\Arbeit_Studienarbeit\PythonPROG\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript</i> <br><i> exec codeObject in __main__.__dict__</i> <br><i> File "C:\Arbeit_Studienarbeit\Arbeit\Marcus\aktuell\mainko.py", line 8, in ?</i> <br><i> print 'test()=',test()</i> <br><i>NameError: test</i> <p>and I don´t know why there´s a NameError. I´m using Pythonwin under Win98 and a few days before i put my working directory in another destination, probably there could be an answer of my problem. <br>I already put the following PATH Command in my autoexec.bat: <p>SET PYTHONPATH=c:\arbeit_studienarbeit\arbeit\marcus\aktuell;c:\arbeit_studienarbeit\pythonprog\lib <p>but nothing happend. <br>So ,can anyone help me ??? <p>Thanks a lot <br>Marcus</html> --------------F02AE80BD61521123CF7363D-- From kalle@gnupung.net Wed Apr 11 23:06:45 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Thu, 12 Apr 2001 00:06:45 +0200 Subject: [Tutor] Need help on a simple problem (i think) In-Reply-To: <3AD4D070.2CE8C5DE@gmx.de>; from m_konermann@gmx.de on Wed, Apr 11, 2001 at 11:45:20PM +0200 References: <3AD4D070.2CE8C5DE@gmx.de> Message-ID: <20010412000645.C375@apone.network.loc> Sez Marcus Konermann: [snip problem description, basically a NameError] > class operation(identification): > > def __init__(self,srchfiles,pattfile,splitfile): > identification.__init__(self,srchfiles,pattfile,splitfile) > > def test(self): > print'it is ok' The problem seems to be here. test() is defined as a method of the class operation, but you try to call it as a function. Either move the test() function out of the class, or create a class instance in mainko.py: op = operation("f","g","h") print op.test() Also note that "from xxx import *" is generally considered bad practice. A little more obvious indentation, four or eight spaces, wouldn't hurt either, IMHO. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From DOUGS@oceanic.com Thu Apr 12 00:03:06 2001 From: DOUGS@oceanic.com (Doug Stanfield) Date: Wed, 11 Apr 2001 13:03:06 -1000 Subject: [Tutor] Need help on a simple problem (i think) Message-ID: <8457258D741DD411BD3D0050DA62365907A762@huina.oceanic.com> [Marcus Konermann asked:] > I=B4ve got two moduls. The first one is mainko.py and the=20 > second one functions.py and i only want to call a method from=20 > the mainko.py modul named test, wich is declared in the modul=20 > functions.py.=20 > This is mainko.py :=20 > import string,re,sys,glob,operator=20 > from functions import *=20 > import os=20 > #print os.getcwd()=20 > #print os.listdir(os.getcwd())=20 > #ausgabe=3D[]=20 > print 'test()=3D',test()=20 > #abweichung('soll.out',(((3,5),1),((7,9),1)),'ist.out',(((3,5) > ,1),((7,9),1)),r'\d+\.\d+[E][+-]\d+',r'[ ]+')=20 > #print 'ausgabe=3D',ausgabe=20 > #((3,5),1),(4,(1,3)),(5,1)))=20 > and this is the modul functions.py :=20 > import string,sys=20 > from math import *=20 > from types import *=20 > from identify import identification=20 > class operation(identification):=20 > def __init__(self,srchfiles,pattfile,splitfile):=20 > identification.__init__(self,srchfiles,pattfile,splitfile)=20 > def test(self):=20 > print'it is ok'=20 > and the ERROR Output from Python is the following:=20 > test()=3DTraceback (innermost last):=20 > File=20 > "C:\Arbeit_Studienarbeit\PythonPROG\Pythonwin\pywin\framework\ > scriptutils.py", line 237, in RunScript=20 > exec codeObject in __main__.__dict__=20 > File=20 > "C:\Arbeit_Studienarbeit\Arbeit\Marcus\aktuell\mainko.py",=20 > line 8, in ?=20 > print 'test()=3D',test()=20 > NameError: test=20 Python is telling you that you didn't do what you thought you would = when you imported the 'functions' module. What it wanted to see in order to = believe 'test' was a real name was that name defined in the first level of the module. In other words if the fifth line in functions.py was 'test =3D = 27' then it would have known what the name was. In your case you've defined 'test' as a function of a class = 'operation'. That function can't be available simply from a module import. You need = to have something like the following to instantiate an instance of the = class which would have a 'test' function available: spam =3D operation(eggs) print 'test()=3D', spam.test() One comment on style here. To use 'from module import *' as you do = several places here, is considered a "VERY BAD IDEA" (tm), unless you are quite clear what you are doing. It is almost always better to use 'import = module' and then use the module.name format to address the module contents. In = your case this should equate to: import functions spam =3D functions.operation(eggs) HTH -Doug- From cdwom@mpinet.net Wed Apr 11 21:52:55 2001 From: cdwom@mpinet.net (Corey Woodworth) Date: Wed, 11 Apr 2001 16:52:55 -0400 Subject: [Tutor] Newsgroup Message-ID: <000001c0c2de$6e27bc40$dcdd35d8@KellyJoW> I've heard that this mailing list is also posted to a newsgroup? What newsgroup is it? I'm filling up my mailbox with tons of posts i never read, it would be much better If i could read 'em in a newsreaded. thanks Corey From dyoo@hkn.eecs.berkeley.edu Thu Apr 12 00:39:39 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 16:39:39 -0700 (PDT) Subject: [Tutor] Newsgroup In-Reply-To: <000001c0c2de$6e27bc40$dcdd35d8@KellyJoW> Message-ID: <Pine.LNX.4.21.0104111632030.14631-100000@hkn.eecs.berkeley.edu> On Wed, 11 Apr 2001, Corey Woodworth wrote: > I've heard that this mailing list is also posted to a newsgroup? What > newsgroup is it? I'm filling up my mailbox with tons of posts i never > read, it would be much better If i could read 'em in a newsreaded. > thanks What you probably mean is the main Python newsgroup (comp.lang.python). That particular newsgroup is available as a mailing list: http://mail.python.org/mailman/listinfo/python-list/ and as the newsgroup comp.lang.python. However, this mailing list is tutor@python.org. For good or for evil, we don't have our own dedicated newsgroup. Still, all the messages on tutor are archived through a nice web interface: http://mail.python.org/pipermail/tutor so if you want to see what we've been chatting about recently, you can browse messages there. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Thu Apr 12 00:58:05 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 16:58:05 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <A50594A71D5FD311A00200902745F06F18A4C1@go.ihello.com> Message-ID: <Pine.LNX.4.21.0104111641180.14631-100000@hkn.eecs.berkeley.edu> On Wed, 11 Apr 2001, Glen Bunting wrote: > Your version works perfectly except for one thing, when I click on the quit > button, nothing happens. I will continue to use the program the way you > wrote it, but I have a few questions about the way I was trying to write it. Hmmm... strange! What might be happening is that the updating action is taking a long time. At the moment, the program is written to only be able to do one task at a time. The call to: urllib.urlretrieve('http://www.esynch.com/mw_test.dat', 'test') takes a heck of a lot of time, precisely because the file is HUGE, even with a broadband connection. *grin*. That's probably why the GUI isn't as responsive as it should be: it's only doing one thing at a time. Try your program on a less stressful URL, and see if this is the case. > 2: As long as Tkinter.mainloop() remains in the while loop, the while > loop does not continue until after I quit Tkinter. Once I do that the > loop continues. If I take Tkinter.mainloop out of the while loop, the > loop continues like it should , but the gui never pops up. The role of the mainloop() call is to pass control of your program off to Tkinter --- after caling mainloop(), it's all "hands-off". I believe this is called "event-driven programming", because anything that happens afterwards is a response to what the user does with the GUI. The control flow of our GUI programs, then, looks like: start ----> initialize stuff ---> initialize GUI -+ | +------------------<-------------------+ | +----> do GUI stuff ---+---> turn off GUI ---> done! | | +----------<-----------+ handle an "event" The "do GUI stuff" loopiness is what the mainloop() is doing: it keeps on looping until we can't look at any more "events", and then we finish the program. It's a different style of programming than what you might be used to. > The next thing I might be interested in doing is to graph the results. Is > that the next logical step, or would that be a little to advanced for a > newbie? Graphing sounds like a great idea. You'll want to play around with the Canvas widget. If you want, I can take a look at Grayson's "Python and Tkinter Programming" to review how Canvases work. There's supposedly a really good module that works with Tkinter to make really nice widgets. It's called Python Mega Widgets, and I think it has a graphing widget that might be useful. If you're interested, take a look: http://pmw.sourceforge.net Lots of good stuff. Anyway, good luck to you. From dyoo@hkn.eecs.berkeley.edu Thu Apr 12 01:10:54 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 11 Apr 2001 17:10:54 -0700 (PDT) Subject: [Tutor] converting CGI's FieldStorage to dictionary? In-Reply-To: <200104091633.MAA11149@birds.us.itd.umich.edu> Message-ID: <Pine.LNX.4.21.0104111706220.15366-100000@hkn.eecs.berkeley.edu> On Mon, 9 Apr 2001, Lance E Sloan wrote: > The problem I'm running into is that DocumentTemplate uses > dictionaries as arguments to hold template values, but cgi's > FieldStorage is not quite a dictionary. So, this doesn't work: > > import cgi > import DocumentTemplate > > form = cgi.FieldStorage() > tmpl = DocumentTemplate.HTMLFile('path/to/file') > print tmpl(mapping = form) > > How can I write a function that takes my FieldStorage form as an > argument and returns a dictionary of field names to field values? Let's write a function that takes a FieldStorage, and returns back an equivalent dictionary: ### def fieldStorageToDictionary(fs): mydict = {} for k, v in fs.items(): mydict[k] = v.value return mydict ### To tell the truth, I haven't tested this code yet, but hopefully this is close enough that it'll help you write that function. Good luck! From bwgolling@home.com Wed Apr 11 21:55:38 2001 From: bwgolling@home.com (Bruce Golling) Date: Wed, 11 Apr 2001 20:55:38 +0000 Subject: [Tutor] Idle vs PythonWin Env Message-ID: <3AD4C4C9.1026CCA6@home.com> I wonder if anyone can tell me why PythonWin and Idle behave so differently on my win98 box. F'rinstance if I run the turle.demo on Idle, it performs the whole routine. Whereas on PythonWin only the 3 boxes come up and the prog stops. The reason I bring this up is that I gave up on Perl because I had such hard time interfacing with windows. As everyone here knows that problem does not exist with Python. Pythonwin seems to be a little more intuitive for me (I need all the help I can get), but it seems to more buggy than Idle. Do I not have my env set up correctly, or something. Mainly I want to spend more time fooling around with the lang rather than the ide. tks Bruce From spi" <securityguru@earthlink.net Fri Apr 13 03:54:02 2001 From: spi" <securityguru@earthlink.net (spi) Date: Thu, 12 Apr 2001 22:54:02 -0400 Subject: [Tutor] problem with win32com Message-ID: <0df001c0c3c4$ff4d8290$0201a8c0@gate> Hi, I'm messing around with win32com and IE, I grabbed this sample code from some messge groups, it works fine in the pythonwin interactive window, I can control IE and browse .. import win32com import win32com.client ie = win32com.client.Dispatch("InternetExplorer.Application") ie.Navigate("www.yahoo.com") doc = ie.Document print doc.url The problem is that when I put the exact same code in a python script and run it from the command line I get this error D:\data\product\workingDB\py>test.py Traceback (most recent call last): File "D:\data\product\workingDB\py\test.py", line 6, in ? doc = ie.Document File "d:\python20\win32com\client\dynamic.py", line 431, in __getattr__ raise pythoncom.com_error, details pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) It's the exact same code that I enter into pythonwin, and it works there I don't understand what the problem is.. From mosleh@corpotech.com Thu Apr 12 04:26:09 2001 From: mosleh@corpotech.com (Mosleh Uddin) Date: Thu, 12 Apr 2001 13:26:09 +1000 Subject: [Tutor] Can't find FtServer. Message-ID: <3AD52051.8F83F9C3@corpotech.com> Hi I was trying to run a program but it can't find "FtServer". Can you please give me idea how can I can get "FtServer". Thank you. Mosleh From kalle@gnupung.net Thu Apr 12 14:48:29 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Thu, 12 Apr 2001 15:48:29 +0200 Subject: [Tutor] Can't find FtServer. In-Reply-To: <3AD52051.8F83F9C3@corpotech.com>; from mosleh@corpotech.com on Thu, Apr 12, 2001 at 01:26:09PM +1000 References: <3AD52051.8F83F9C3@corpotech.com> Message-ID: <20010412154829.A16549@father> Sez Mosleh Uddin: > I was trying to run a program but it can't find "FtServer". > Can you please give me idea how can I can get "FtServer". Sorry, but I have no idea. What program is it you're trying to run? Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From alan.gauld@bt.com Thu Apr 12 17:24:17 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Thu, 12 Apr 2001 17:24:17 +0100 Subject: [Tutor] Idle vs PythonWin Env Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6E8@mbtlipnt02.btlabs.bt.co.uk> > if I run the turle.demo on Idle, it performs the whole routine. > Whereas on PythonWin only the 3 boxes come up and the prog stops. Works OK for me on both. BUT being a Tkinter program its probably not a good idea to run it from within IDLE - which is also a Tkinter program. IDLE (Tkinrter) usually gets confused about who owns the app mainloop... > Pythonwin seems to be a little more intuitive for me > but it seems to more buggy than Idle. I agree, but for some things the extra function outweighs the occasional hangup etc. > Mainly I want to spend more time fooling around with > the lang rather than the ide. Always a good idea :-) Alan G From alan.gauld@bt.com Thu Apr 12 17:16:05 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Thu, 12 Apr 2001 17:16:05 +0100 Subject: [Tutor] Newsgroup Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6E7@mbtlipnt02.btlabs.bt.co.uk> > > I've heard that this mailing list is also posted to a newsgroup? > However, this mailing list is tutor@python.org. > are archived through a nice web interface: > > http://mail.python.org/pipermail/tutor Also you can elect to get a digest of the messages which means you only see betwen 1 and 4 messaages per day in your mailbox - thats a lot more manageable. Alan g From van@lindbergs.org Thu Apr 12 19:08:05 2001 From: van@lindbergs.org (VanL) Date: Thu, 12 Apr 2001 12:08:05 -0600 Subject: [Tutor] Idle vs PythonWin Env References: <3AD4C4C9.1026CCA6@home.com> Message-ID: <3AD5EF05.A789FF9B@lindbergs.org> Try ActiveState's Komodo IDE. It is free for educational or home use if you sign up for their ASPN. (I'm not sure exactly what ASPN stands for.) It has a couple things that I haven't seen other places: A regular expression editor/checker, project management, and it does other languages too. VanL Bruce Golling wrote: > I wonder if anyone can tell me why PythonWin and Idle behave so > differently on my win98 box. F'rinstance if I run the turle.demo on > Idle, it performs the whole routine. Whereas on PythonWin only the 3 > boxes come up and the prog stops. > The reason I bring this up is that I gave up on Perl because I had such > hard time interfacing with windows. As everyone here knows that problem > does not exist with Python. > Pythonwin seems to be a little more intuitive for me (I need all the > help I can get), but it seems to more buggy than Idle. > Do I not have my env set up correctly, or something. > Mainly I want to spend more time fooling around with the lang rather > than the ide. > tks > Bruce > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor From pythoperson@yahoo.com Thu Apr 12 21:47:36 2001 From: pythoperson@yahoo.com (folklore hopeful) Date: Thu, 12 Apr 2001 13:47:36 -0700 (PDT) Subject: [Tutor] Possible problems using a windows .bat file to run a program? Message-ID: <20010412204736.42896.qmail@web12405.mail.yahoo.com> I was wondering if there are any potential problems in using a windows desktop shortcut to run a batch file which runs a python program. Basically, I have a nifty little program that is useful in the office, but the people using the program are computer-challanged and the word "DOS" sounds confusing to them. So, currently, I am having them double click on a batchfile which runs: c:\python20\python 216.py I've had reports of the program giving error messages and etc. and that computers had to be rebooted so that the program would work. Any ideas what the problem might be? How can I avoid this? Thanks for all your help! __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ From dsh8290@rit.edu Thu Apr 12 22:16:44 2001 From: dsh8290@rit.edu (D-Man) Date: Thu, 12 Apr 2001 17:16:44 -0400 Subject: [Tutor] Possible problems using a windows .bat file to run a program? In-Reply-To: <20010412204736.42896.qmail@web12405.mail.yahoo.com>; from pythoperson@yahoo.com on Thu, Apr 12, 2001 at 01:47:36PM -0700 References: <20010412204736.42896.qmail@web12405.mail.yahoo.com> Message-ID: <20010412171644.A15266@harmony.cs.rit.edu> On Thu, Apr 12, 2001 at 01:47:36PM -0700, folklore hopeful wrote: | I was wondering if there are any potential problems in using a | windows desktop shortcut to run a batch file which runs a python | program. Basically, I have a nifty little program that is useful in | the office, but the people using the program are computer-challanged | and the word "DOS" sounds confusing to them. So, currently, I am | having them double click on a batchfile which runs: The python installer sets the file associations so that they can double click on a .py or .pyw file and it will run in python. The biggest problem with that is getting a traceback, and windows closing the DOS-box before the message can be read. | I've had reports of the program giving error messages and etc. and | that computers had to be rebooted so that the program would work. | Any ideas what the problem might be? Windows <wink> | How can I avoid this? Use Debian <wink>. apt-get rules. No rebooting necessary except for power outages, new kernels, or testing boot loaders and init sequence <grin>. Seriously, though, windows is _very_ reboot-happy. (Ever try to set up networking? Each change requires a reboot! =p) After installing anything (apps, drivers, you name it) windows must be rebooted to work semi-reliably. (IMO windows doesn't work any better than semi-reliably) Another potential solution would be to put a raw_input( "Press [enter] to quit this app" ) at the end of your program so that error messages (the DOS-box) will stay on-screen until you can read them. Without knowing the actual error message it is hard to guess what the real problem is. Is your program a console or gui app? If it is a gui app then you might want to rename the main .py file to .pyw to eliminate the DOS box. -D From info@webb2e.com Fri Apr 13 01:13:37 2001 From: info@webb2e.com (info@webb2e.com) Date: Thu, 12 Apr 2001 17:13:37 -0700 Subject: [Tutor] Free register of online company's profile Message-ID: <0aa973713000d41MAIL@mail3.chinainfoland.com> This is a multi-part message in MIME format. ------=_NextPart_000_389C_01C0C373.E9855A60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit How much are you paying to advertise your business to the world? Expose Your service to the world with bold register of online business profile. Sign up today! Introducing WebB2E.com -- your direct link to global information; source of business, products, education/research, social/culture, entertainment and travel... Additionally you can BUY, SELL or PROMOTE your products and services At www.webb2e.com <http://webb2e.com/promo1.asp> you'll get: --Message center (open to the public). --Employment center. --Sponsorship center. --Bulletin board (business and service issue). --Flexible Online Office (Business Online Report). --Economic news. --View thousands of trade leads. --Post business propositions. --Merchandise marketing (Vast advertising at a low cost). --World shopping center. .. and much more. Please visit www.webb2e.com <http://webb2e.com/promo1.asp> If you do not want to recieve any more e-mails from WebB2E.com and wish to be removed from e-mail list please click here <http://webb2e.net/remove.asp?email=tutor@python.org> . ------=_NextPart_000_389C_01C0C373.E9855A60 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html><head><title>www.webb2e.com</title><meta = http-equiv=3D'Content-Type' content=3D'text/html; = charset=3Diso-8859-1'></head><body bgcolor=3D'#FFFFFF'>How much are you = paying to advertise your business to the world? <br><br>Expose Your = service to the world with bold register of online business profile. Sign = up today! <br><br>Introducing WebB2E.com -- your direct link to global = information; source of business, products, education/research, = social/culture, entertainment and travel... <br>Additionally you can = BUY, SELL or PROMOTE your products and services <br>At <a = href=3D'http://webb2e.com/promo1.asp'>www.webb2e.com</a> you'll get: = <br><br>--Message center (open to the public). <br>--Employment center. = <br>--Sponsorship center. <br>--Bulletin board (business and service = issue). <br>--Flexible Online Office (Business Online Report). = <br>--Economic news. <br>--View thousands of trade leads. <br>--Post = business propositions. <br>--Merchandise marketing (Vast advertising at = a low cost). <br>--World shopping center. <br><br>... and much more. = Please visit <a href=3D'http://webb2e.com/promo1.asp'>www.webb2e.com</a> = <br><br>If you do not want to recieve any more e-mails from WebB2E.com = and wish to be removed from e-mail list please <a = href=3D'http://webb2e.net/remove.asp?email=3Dtutor@python.org'>click = here</a>. <br><br></body></html> ------=_NextPart_000_389C_01C0C373.E9855A60-- From wong_chow_cheok@hotmail.com Fri Apr 13 04:31:36 2001 From: wong_chow_cheok@hotmail.com (wong chow cheok) Date: Fri, 13 Apr 2001 11:31:36 +0800 Subject: [Tutor] (no subject) Message-ID: <F116g7SabkVB1JdRkEc000048a2@hotmail.com> i was wondering how do you extract a url using reg expressions. i mean just say i want my program to extract any url beginning with 'http://......'. is there any way to do that? i tried using 'http:(.*?).com' and some other variations but it is not doing the trick. i can only get those url ending with .com ir other endings that i have tried. thanks for your help. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From van@lindbergs.org Fri Apr 13 05:13:33 2001 From: van@lindbergs.org (VanL) Date: Thu, 12 Apr 2001 22:13:33 -0600 Subject: [Tutor] Recursive search and replace Message-ID: <3AD67CED.17CFAA34@lindbergs.org> Hello, I have written a script to do two things: 1. Copy a set of textfiles into every directory in a directory tree. 2. Edit every htmlfile in the directory tree such that "../(../../)textfile.txt" becomes "textfile.txt" This script does the first, but not the second. I successfully open each htmlfile, but my regex does not to the matching and substitution. However, when I test the same regex in the interpreter, it works perfectly. Can anyone spot the problem? Thanks, Van SCRIPT: import re, string, os, os.path from shutil import copy txtfilematch = re.compile(r'txt') htmlfilematch = re.compile(r'html') includematch = re.compile(r'(include file=")(\.\./)+') def walk(includes, dirname, names): for obj in names: if os.path.isfile(obj): if re.search(htmlfilematch, obj): linelist = open(obj).readlines() print "Opened:", os.path.join(dirname, obj) newfile = open(obj, 'w') for line in linelist: if re.search(includematch, line): print "Found include:", line line = includematch.sub(r'include file="', line) print "New line:", line newfile.write(line) else: newfile.write(line) newfile.flush() newfile.close() for file in includes: filename = os.path.split(file)[1] newloc = os.path.join(dirname, filename) copy(file, newloc) #print "Copied:", filename, newloc includefiles = [] for file in os.listdir(os.getcwd()): if re.search(txtfilematch, file): includefiles.append(file) os.path.walk('.', walk, includefiles) From dyoo@hkn.eecs.berkeley.edu Fri Apr 13 08:58:36 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 13 Apr 2001 00:58:36 -0700 (PDT) Subject: [Tutor] Message persistence In-Reply-To: <F72gC81TbdkSmLAztxc00001b0f@hotmail.com> Message-ID: <Pine.LNX.4.21.0104111711020.15366-100000@hkn.eecs.berkeley.edu> On Mon, 9 Apr 2001, Derek White wrote: > Hello all, > > If I were wanting to write a web based message board system with CGI with > replies in threads what would be some of the ways to consider for message > persistence in Python? If there's going to be a lot of messages, you'll probably want to store your data within some sort of SQL database. The reason for this is because databases are equipped to handle large amounts of heirarchical stuff. There are a few free (free speech and free beer) systems out there, including mysql and postgresql: http://www.mysql.com http://www.pgsql.com (Strangely enough, www.pgsql.com seems to be down at the time of this writing. Check back on it later.) There's a nice web site that talks a lot about mysql called devshed: http://devshed.com/Server_Side/MySQL/ which might give you ideas on how to plan out the structure of your web message board. Something tells me, though, that all this might be overkill. Is this what you're looking for, or something else? From dyoo@hkn.eecs.berkeley.edu Fri Apr 13 10:46:14 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 13 Apr 2001 02:46:14 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <F116g7SabkVB1JdRkEc000048a2@hotmail.com> Message-ID: <Pine.LNX.4.21.0104130241060.23370-100000@hkn.eecs.berkeley.edu> On Fri, 13 Apr 2001, wong chow cheok wrote: > i was wondering how do you extract a url using reg expressions. > > i mean just say i want my program to extract any url beginning with > 'http://......'. is there any way to do that? i tried using > 'http:(.*?).com' and some other variations but it is not doing the trick. i > can only get those url ending with .com ir other endings that i have tried. Here ya go: ### abs_http_url = r''' # one of the main protocols (http | https | ftp | telnet | gopher | file | wais | ftp | mailto) : # followed by a colon [\w.#@&=\-_~/;:\n]+? # a bunch of stuff that can span lines, # nongreedily, (?=([,:\-.!?;]? # that shouldn't contain any # trailing punctutation, (\s+|$))) # spaces, or eol character. ''' abs_http_url_re = re.compile(abs_http_url, re.VERBOSE) ### Let's see it in action: ### >>> result = abs_http_url_re.search("this is a test with an url\ http://python.org embedded in it.") >>> result <SRE_Match object at 0x8120ee0> >>> result.group(0) 'http://python.org' ### It might not be perfect, but it's commented heavily, so you can see where to fix it up. Hope this helps! From dyoo@hkn.eecs.berkeley.edu Fri Apr 13 11:01:17 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 13 Apr 2001 03:01:17 -0700 (PDT) Subject: [Tutor] Recursive search and replace In-Reply-To: <3AD67CED.17CFAA34@lindbergs.org> Message-ID: <Pine.LNX.4.21.0104130250550.23468-100000@hkn.eecs.berkeley.edu> On Thu, 12 Apr 2001, VanL wrote: > Hello, > > I have written a script to do two things: > 1. Copy a set of textfiles into every directory in a directory > tree. > 2. Edit every htmlfile in the directory tree such that > "../(../../)textfile.txt" becomes "textfile.txt" > > This script does the first, but not the second. I successfully open > each htmlfile, but my regex does not to the matching and > substitution. However, when I test the same regex in the > interpreter, it works perfectly. Can anyone spot the problem? You might want to make sure that it's not interfering with case sensitivity by using the IGNORECASE flag: txtfilematch = re.compile(r'txt', re.IGNORECASE) That's the only think I can think of so far; otherwise, I don't see an obvious bug in the code. As a style comment: it might be better to separate the code: > linelist = open(obj).readlines() > print "Opened:", > os.path.join(dirname, obj) > newfile = open(obj, 'w') > > for line in linelist: > if re.search(includematch, > line): > print "Found > include:", line > line = > includematch.sub(r'include file="', line) > print "New line:", > line > newfile.write(line) > > else: > newfile.write(line) > > newfile.flush() > newfile.close() off into a separate function, just to reduce the amount of nested blocks in the program. Conceptually, it's doing a large task: it's taking in a file, fiddling it's contents, and writing it back to disk. We could call the function something like fixupFile(f). By doing this, we can independently test to see if the string replacement is the bug, or if it's something else. From cruciatuz <sasoft@gmx.de> Fri Apr 13 13:28:48 2001 From: cruciatuz <sasoft@gmx.de> (cruciatuz) Date: Fri, 13 Apr 2001 14:28:48 +0200 Subject: [Tutor] wxPyhton installation Message-ID: <12211033629.20010413142848@gmx.de> Hello tutorlist, I installed wxPython for Python 2 on my windows 98 machine but i have the problem that i am using Python 2.1b1, so i get the following error msg: Traceback (most recent call last): File "<pyshell#0>", line 1, in ? from wxPython import * File "c:\python21\lib\wxPython\__init__.py", line 20, in ? import wxc ImportError: Module use of python20.dll conflicts with this version of Python. After that i set the sys.version variable from Python 2.1b to Python 2.0, but that didn't help. Is there a solution? + ---------------------------------- + | Stefan Antoni | + ---------------------------------- + | ICQ: 72292815 | | PGP-Key: AVAILABLE | + ---------------------------------- + 14:13 / Freitag, 13. April 2001 From dsh8290@rit.edu Fri Apr 13 15:16:02 2001 From: dsh8290@rit.edu (D-Man) Date: Fri, 13 Apr 2001 10:16:02 -0400 Subject: [Tutor] Message persistence In-Reply-To: <Pine.LNX.4.21.0104111711020.15366-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Fri, Apr 13, 2001 at 12:58:36AM -0700 References: <F72gC81TbdkSmLAztxc00001b0f@hotmail.com> <Pine.LNX.4.21.0104111711020.15366-100000@hkn.eecs.berkeley.edu> Message-ID: <20010413101602.F16516@harmony.cs.rit.edu> On Fri, Apr 13, 2001 at 12:58:36AM -0700, Daniel Yoo wrote: | http://www.pgsql.com | | (Strangely enough, www.pgsql.com seems to be down at the time of this | writing. Check back on it later.) It's up now. There is also http://www.postgresql.org -D From rdsteph@earthlink.net Thu Apr 12 18:58:41 2001 From: rdsteph@earthlink.net (Ron Stephens) Date: Thu, 12 Apr 2001 13:58:41 -0400 Subject: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-)))) Message-ID: <3AD5ECD1.8B050A84@earthlink.net> Sacrilege, I know. ;-))) But sometimesIi wonder why no modern language will let me have a simple goto statement when nothing else will do as well...this is a rhetorical statement only... I have written and am writing a series of similar small programs to help a user choose amongst several different alternatives. The programs mostly use simple weighted averages based on several appropriate criteria with weights, or importance levels. Maybe later, Bayes;-))) On such program is general in nature and lets the user input the options to be decided amongst, and then input the criteria to be used to decide and then the weights for each criteria and then the scores for each option on each criteria. Other options are sort of mini expert systems in which the programmer pre inputs the options and criteria and the scores for each option on each criteria, then the user only enters his individual weights amongst the criteria. These programlets can cover any field in which the programmer is "expert". Now, my problem. I want to create a sort of simple menu to offer the user a choice between the various mini-decisonanalysis programs. So, the user can choose the general program, or else a specific program. Once the user chooses, the appropriate mini-progran should launch. If I had goto statements available, my job would be finished. Just create a simple choice, say 1-10 and when the user inputs 10 the program launches its program. I first considered using a Tkinter menu, but I am still struggling with gui event-driven programs. Also, if I use Tkinter, how would I solve my basic problem to jump to each a specific program when the user chooses its menu item? In other words, I would have to launch a procedural program from a gui event-driven menu program. So, now I consider procedural menu program using raw_input. Still, how do I go to the appropriate sub-program when the user chooses one? With goto's this would be trivial. Now, I consider a nested set of "if " statements that determines which number was chosen, but still how do I "jump" to the correct sub-program??? Even if I define the subprograms as functions even, how do I jump to them??? Any help for hopelessly confused newbie will be greatly appreciated... Ron Stephens From Rob Andrews" <rob@jam.rr.com Fri Apr 13 19:12:01 2001 From: Rob Andrews" <rob@jam.rr.com (Rob Andrews) Date: Fri, 13 Apr 2001 13:12:01 -0500 Subject: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-)))) References: <3AD5ECD1.8B050A84@earthlink.net> Message-ID: <004c01c0c445$3e086920$9600a8c0@Planhouse5> On Useless Python, I have an example script that uses a GOTO-like structure, as well as an example of the next revision which does it without any GOTO behavior. The URL for Useless Python is http://www.lowerstandard.com/python/pythonsource.html and the two scripts are slotmachine.py (the one that acts like it has a GOTO) and zippy.py. Not menu-driven, but the behavior is there. Hope this helps some at all, Rob ----- Original Message ----- From: "Ron Stephens" <rdsteph@earthlink.net> To: <tutor@python.org> Sent: Thursday, April 12, 2001 12:58 PM Subject: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-)))) > Sacrilege, I know. ;-))) But sometimesIi wonder why no modern language > will let me have a simple goto statement when nothing else will do as > well...this is a rhetorical statement only... > > I have written and am writing a series of similar small programs to help > a user choose amongst several different alternatives. The programs > mostly use simple weighted averages based on several appropriate > criteria with weights, or importance levels. Maybe later, Bayes;-))) > > On such program is general in nature and lets the user input the options > to be decided amongst, and then input the criteria to be used to decide > and then the weights for each criteria and then the scores for each > option on each criteria. Other options are sort of mini expert systems > in which the programmer pre inputs the options and criteria and the > scores for each option on each criteria, then the user only enters his > individual weights amongst the criteria. These programlets can cover any > field in which the programmer is "expert". > > Now, my problem. I want to create a sort of simple menu to offer the > user a choice between the various mini-decisonanalysis programs. So, the > user can choose the general program, or else a specific program. Once > the user chooses, the appropriate mini-progran should launch. > > If I had goto statements available, my job would be finished. Just > create a simple choice, say 1-10 and when the user inputs 10 the program > launches its program. > > I first considered using a Tkinter menu, but I am still struggling with > gui event-driven programs. Also, if I use Tkinter, how would I solve my > basic problem to jump to each a specific program when the user chooses > its menu item? In other words, I would have to launch a procedural > program from a gui event-driven menu program. > > So, now I consider procedural menu program using raw_input. Still, how > do I go to the appropriate sub-program when the user chooses one? With > goto's this would be trivial. Now, I consider a nested set of "if " > statements that determines which number was chosen, but still how do I > "jump" to the correct sub-program??? Even if I define the subprograms as > functions even, how do I jump to them??? > > Any help for hopelessly confused newbie will be greatly appreciated... > > Ron Stephens > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor From rdsteph@earthlink.net Thu Apr 12 22:12:03 2001 From: rdsteph@earthlink.net (Ronald D Stephens) Date: Thu, 12 Apr 2001 17:12:03 -0400 Subject: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-)))) References: <3AD5ECD1.8B050A84@earthlink.net> <004c01c0c445$3e086920$9600a8c0@Planhouse5> Message-ID: <001d01c0c395$39f561e0$dc75e9d0@cerf.net> Thanks tremendously!!! I am on my way to your web site right now...! Ron Stephens ----- Original Message ----- From: "Rob Andrews" <randrews@planhouse.com> To: "Ron Stephens" <rdsteph@earthlink.net> Cc: <tutor@python.org> Sent: Friday, April 13, 2001 2:12 PM Subject: Re: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-)))) > On Useless Python, I have an example script that uses a GOTO-like structure, > as well as an example of the next revision which does it without any GOTO > behavior. The URL for Useless Python is > http://www.lowerstandard.com/python/pythonsource.html and the two scripts > are slotmachine.py (the one that acts like it has a GOTO) and zippy.py. Not > menu-driven, but the behavior is there. > > Hope this helps some at all, > Rob > > ----- Original Message ----- > From: "Ron Stephens" <rdsteph@earthlink.net> > To: <tutor@python.org> > Sent: Thursday, April 12, 2001 12:58 PM > Subject: [Tutor] Menu to choose programlets: if only python had a GoTO > statement ;-)))) > > > > Sacrilege, I know. ;-))) But sometimesIi wonder why no modern language > > will let me have a simple goto statement when nothing else will do as > > well...this is a rhetorical statement only... > > > > I have written and am writing a series of similar small programs to help > > a user choose amongst several different alternatives. The programs > > mostly use simple weighted averages based on several appropriate > > criteria with weights, or importance levels. Maybe later, Bayes;-))) > > > > On such program is general in nature and lets the user input the options > > to be decided amongst, and then input the criteria to be used to decide > > and then the weights for each criteria and then the scores for each > > option on each criteria. Other options are sort of mini expert systems > > in which the programmer pre inputs the options and criteria and the > > scores for each option on each criteria, then the user only enters his > > individual weights amongst the criteria. These programlets can cover any > > field in which the programmer is "expert". > > > > Now, my problem. I want to create a sort of simple menu to offer the > > user a choice between the various mini-decisonanalysis programs. So, the > > user can choose the general program, or else a specific program. Once > > the user chooses, the appropriate mini-progran should launch. > > > > If I had goto statements available, my job would be finished. Just > > create a simple choice, say 1-10 and when the user inputs 10 the program > > launches its program. > > > > I first considered using a Tkinter menu, but I am still struggling with > > gui event-driven programs. Also, if I use Tkinter, how would I solve my > > basic problem to jump to each a specific program when the user chooses > > its menu item? In other words, I would have to launch a procedural > > program from a gui event-driven menu program. > > > > So, now I consider procedural menu program using raw_input. Still, how > > do I go to the appropriate sub-program when the user chooses one? With > > goto's this would be trivial. Now, I consider a nested set of "if " > > statements that determines which number was chosen, but still how do I > > "jump" to the correct sub-program??? Even if I define the subprograms as > > functions even, how do I jump to them??? > > > > Any help for hopelessly confused newbie will be greatly appreciated... > > > > Ron Stephens > > > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > From bsass@freenet.edmonton.ab.ca Fri Apr 13 23:05:35 2001 From: bsass@freenet.edmonton.ab.ca (Bruce Sass) Date: Fri, 13 Apr 2001 16:05:35 -0600 (MDT) Subject: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-)))) In-Reply-To: <3AD5ECD1.8B050A84@earthlink.net> Message-ID: <Pine.LNX.4.33.0104131538000.942-100000@bms> On Thu, 12 Apr 2001, Ron Stephens wrote: <...> > "jump" to the correct sub-program??? Even if I define the subprograms as > functions even, how do I jump to them??? >>> def hi(): ... print "Hi!" ... >>> a = {1:hi} >>> a[1] <function hi at 806ecf0> >>> a[1]() Hi! >>> n=1 >>> a[n]() Hi! >>> so... "goto n" --> a[n]() and... "n rem some code" --> "def fn... ; a[n]=fn" These... menuitems = dict.keys() validmenuitem = dict.has_key(key) ...are handy identities. > Any help for hopelessly confused newbie will be greatly appreciated... Is that the piece you were missing? - Bruce From rdsteph@earthlink.net Fri Apr 13 01:16:58 2001 From: rdsteph@earthlink.net (Ronald D Stephens) Date: Thu, 12 Apr 2001 20:16:58 -0400 Subject: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-)))) References: <Pine.LNX.4.33.0104131538000.942-100000@bms> Message-ID: <000f01c0c3af$0ea40fe0$dc75e9d0@cerf.net> Thanks!!! ----- Original Message ----- From: "Bruce Sass" <bsass@freenet.edmonton.ab.ca> To: "Ron Stephens" <rdsteph@earthlink.net> Cc: <tutor@python.org> Sent: Friday, April 13, 2001 6:05 PM Subject: Re: [Tutor] Menu to choose programlets: if only python had a GoTO statement ;-)))) > On Thu, 12 Apr 2001, Ron Stephens wrote: > <...> > > "jump" to the correct sub-program??? Even if I define the subprograms as > > functions even, how do I jump to them??? > > >>> def hi(): > ... print "Hi!" > ... > >>> a = {1:hi} > >>> a[1] > <function hi at 806ecf0> > >>> a[1]() > Hi! > >>> n=1 > >>> a[n]() > Hi! > >>> > > so... "goto n" --> a[n]() > > and... "n rem some code" --> "def fn... ; a[n]=fn" > > These... > menuitems = dict.keys() > validmenuitem = dict.has_key(key) > > ...are handy identities. > > > > Any help for hopelessly confused newbie will be greatly appreciated... > > Is that the piece you were missing? > > > - Bruce > > From pdiaz88@terra.es Sat Apr 14 04:23:50 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Sat, 14 Apr 2001 05:23:50 +0200 Subject: [Tutor] FYI Message-ID: <01041405235005.00327@debian> --------------Boundary-00=_QRIRU6T1DIUEDCBG1FDA Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Wow, I didn't know this: Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian GNU/Linux)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> a=[1,2,3,4,5,6] >>> b=a >>> a.remove(3) >>> a [1, 2, 4, 5, 6] >>> b [1, 2, 4, 5, 6] >>> c=a[:] >>> a.remove(1) >>> a [2, 4, 5, 6] >>> b [2, 4, 5, 6] >>> c [1, 2, 4, 5, 6] >>> a={} >>> b=a >>> a[1]='1' >>> a {1: '1'} >>> b {1: '1'} >>> c=a[:] Maybe I'm not the only that missed that part on the tutorial, so thats why I post this ;D Moral: lists, dictionaries (and all other objects???) are copies by reference, be careful when you pass them to functions Cheers Pedro - -- /* * Pedro Diaz Jimenez * pdiaz88@terra.es * pdiaz@acm.asoc.fi.upm.es * * La sabiduria me persigue, pero yo soy mas rapido */ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE618LGnu53feEYxlERAmbVAJ91ROLA1sgNnLUeA/1KBeMXGtW32ACg4RiQ GrwS/csYskS7OZ5rMIbxXGc= =RXKv -----END PGP SIGNATURE----- --------------Boundary-00=_QRIRU6T1DIUEDCBG1FDA Content-Type: application/pgp-keys; name="my pgp key" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=public_key.asc LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tClZlcnNpb246IEdudVBHIHYxLjAu NCAoR05VL0xpbnV4KQpDb21tZW50OiBGb3IgaW5mbyBzZWUgaHR0cDovL3d3dy5nbnVwZy5vcmcK Cm1RR2lCRHFjR1pzUkJBREZJYWhOUExrOHN1TWxTMzltOFJxYXRMZ1g0ZE83UFUyRjVwMW9Wdmt5 QjdQYUxRQ3YKRlJFV3dmcmpHcHhBalJueHlaNFRkYUZpMW9DUDQ5NXQ1UjJDZGpQWnUwRWZqc0Vx b3NkTFhrakRzS2wybjRXbwpBZmI2QmFITUpTNVBBREVJMFFmcFpPa0I4T3J1QVpqYS9vR21uNXJU aHlqZ0N4V0hVdUsxQXJtZUd3Q2c3KzlhCm93Zzl3UDFSb2hlUEhKU0RCOWQySFlNRC9pN3oxWDRl ditLOTBMdW1nSndTV2xTY0o3TUVpcDVydzR3cUdPa0sKbEYvQzJuVFlzb1g1Q1ZFbi9wdTdoUk9M L0JXSVl0QmdrTkRhRWpzVnN5Yis0S2pRWGNaVVc1bDNBRGlwV1l4MgpyOXM0c0ZmZVo5bmZoRGNH MGFOWVJjQ05rWVNaL1d4VWtYUzhValZFQUVoa0Z1MUJBKzZVWm1lcTNwS3RKWlRSCitIcUtBLzl6 Um1nVG9uMzZ6dDJxZTllaVI2RHlZMEVwR0VJMGlZK0tZWDZHQy93eGl6ZUhCdzBGVzFlT0VveEYK R2p0eGRCdi9VOXZpN1ZnYXY2YVkrcHI0bGE1cTZqVmFiZTAzWTh5R0RGZUw4ak0rbHF3dzFyenB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G1FDA-- From pdiaz88@terra.es Sat Apr 14 04:32:38 2001 From: pdiaz88@terra.es (Pedro Diaz Jimenez) Date: Sat, 14 Apr 2001 05:32:38 +0200 Subject: [Tutor] FYI In-Reply-To: <01041405235005.00327@debian> References: <01041405235005.00327@debian> Message-ID: <01041405323806.00327@debian> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Just a note On Saturday 14 April 2001 05:23, Pedro Diaz Jimenez wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Wow, I didn't know this: > > Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian > GNU/Linux)] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > > >>> a=[1,2,3,4,5,6] > >>> b=a > >>> a.remove(3) > >>> a > > [1, 2, 4, 5, 6] > > >>> b > > [1, 2, 4, 5, 6] > > >>> c=a[:] > >>> a.remove(1) > >>> a > > [2, 4, 5, 6] > > >>> b > > [2, 4, 5, 6] > > >>> c > > [1, 2, 4, 5, 6] > > >>> a={} > >>> b=a > >>> a[1]='1' > >>> a > > {1: '1'} > > >>> b > > {1: '1'} > > >>> c=a[:] ^^^^^^^^^^ THIS WONT WORK (hey, they are dictionaries after all, but I had to try it :) > > Maybe I'm not the only that missed that part on the tutorial, so thats why > I post this ;D > > Moral: lists, dictionaries (and all other objects???) are copies by > reference, be careful when you pass them to functions > > Cheers > Pedro > - -- > > /* > * Pedro Diaz Jimenez > * pdiaz88@terra.es > * pdiaz@acm.asoc.fi.upm.es > * > * La sabiduria me persigue, pero yo soy mas rapido > */ > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.4 (GNU/Linux) > Comment: For info see http://www.gnupg.org > > iD8DBQE618LGnu53feEYxlERAmbVAJ91ROLA1sgNnLUeA/1KBeMXGtW32ACg4RiQ > GrwS/csYskS7OZ5rMIbxXGc= > =RXKv > -----END PGP SIGNATURE----- - ---------------------------------------- Content-Type: application/pgp-keys; charset="iso-8859-1"; name="my pgp key" Content-Transfer-Encoding: base64 Content-Description: - ---------------------------------------- - -- /* * Pedro Diaz Jimenez * pdiaz88@terra.es * pdiaz@acm.asoc.fi.upm.es * * La sabiduria me persigue, pero yo soy mas rapido */ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE618TWnu53feEYxlERAr6NAJ9OgQoRtdFhPTBchmfL2MGDbwRj2ACfYJwD CN/IUTHHtv/oIYLK7/I5bXM= =izjV -----END PGP SIGNATURE----- From sheila@thinkspot.net Sat Apr 14 06:55:27 2001 From: sheila@thinkspot.net (Sheila King) Date: Fri, 13 Apr 2001 22:55:27 -0700 Subject: [Tutor] Python Advocacy Message-ID: <3B02ED26B9@kserver.org> [this was also posted to comp.lang.python earlier this evening.] OK, I apologize for posting questions of this type, YET AGAIN, to this group. But I don't really have the background to answer them (being only a newbie Python programmer), so I'm hoping someone will help me out, here. (I searched at Google Groups and Python.org, but don't feel like I'm finding the essence of the answers...) Basically: The sysadmin/tech at the company where I host my website is thinking of *possibly* dipping his toes into Python. He is considering using it for some upcoming projects, instead of Perl. (I've got an entire Python Advocacy thread, which I started on their web board, here: http://www.aota.net/ubb/Forum3/HTML/001567-1.html ) Anyhow, the sysadmin is still skeptical, and asks the following questions: ------------------(begin quoted questions)------------------------------------ Python does have it's 'methods of programming' benefits over Perl, and a much cleaner syntax... I can write ugly-ugly perl code that does beautiful things - and vice versa... I have a couple questions about Python: 1) It's speed in relation to perl... If figure this will be subjective to the task at hand - but hopefully there is an average overall performance increase/decrease... I would assume lugging around the OOP methodologies will impose overhead which would be pretty much unavoidable... 2) How does it stack up against Perl's regex capabilities, which I rely __heavily__ on for massive processing duties... 3) How well does it perform auto-vivication of complex data structures: e.g.: http://www.perl.com/pub/doc/manual/html/pod/perldsc.html **yes, I know that perl's dereferencing syntax is for masochists, but once mastered - the sadistic side shines through... I have some projects that might fit better into an object oriented way of thinking - however I must be careful of time spent learning 'Yet Another Programming Language' since deadlines could quickly slip... I don't think anyone can argue that Perl is **extremely** powerful and runs the full gamut of simple one-shot scripts - to system level capabilities via syscall()/POSIX interface... Thoughts on the above? ------------------(end quoted questions)------------------------------------ What should I tell him? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From deirdre@deirdre.net Sat Apr 14 07:02:58 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Fri, 13 Apr 2001 23:02:58 -0700 (PDT) Subject: [Tutor] Python Advocacy In-Reply-To: <3B02ED26B9@kserver.org> Message-ID: <Pine.LNX.4.31.0104132256360.698-100000@emperor.deirdre.org> On Fri, 13 Apr 2001, Sheila King wrote: > I have a couple questions about Python: 1) It's speed in relation to > perl... If figure this will be subjective to the task at hand - but > hopefully there is an average overall performance increase/decrease... > I would assume lugging around the OOP methodologies will impose > overhead which would be pretty much unavoidable... OOP is not inherently slower. Late binding is slower than early, no question. However, python is byte compiled, which may offer speed advantages. However, in general, if you're looking for speed, you wouldn't be using perl either. > 2) How does it stack up against Perl's regex capabilities, which I rely > __heavily__ on for massive processing duties... The python regex is modeled after perl. http://www.python.org/doc/current/lib/module-re.html > 3) How well does it perform auto-vivication of complex data structures: e.g.: > http://www.perl.com/pub/doc/manual/html/pod/perldsc.html > **yes, I know that perl's dereferencing syntax is for masochists, but once > mastered - the sadistic side shines through... It's also like flying in bad weather without instruments. :) Python has lists and lists of lists and classes (which can contain their own members). But it doesn't have hashes, nor does it need them. > I have some projects that might fit better into an object oriented way of > thinking - however I must be careful of time spent learning 'Yet Another > Programming Language' since deadlines could quickly slip... Well, here's the thing: perl is essentially awk on steroids. Python is a general-purpose programming language. Do you intend on sysadminning forever? Because shell scripting will limit your career options more than learning a more traditional-style language. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From sheila@thinkspot.net Sat Apr 14 07:20:20 2001 From: sheila@thinkspot.net (Sheila King) Date: Fri, 13 Apr 2001 23:20:20 -0700 Subject: [Tutor] Python Advocacy In-Reply-To: <Pine.LNX.4.31.0104132256360.698-100000@emperor.deirdre.org> References: <3B02ED26B9@kserver.org> <Pine.LNX.4.31.0104132256360.698-100000@emperor.deirdre.org> Message-ID: <51C1D43A9F@kserver.org> On Fri, 13 Apr 2001 23:02:58 -0700 (PDT), Deirdre Saoirse <deirdre@deirdre.net> wrote about Re: [Tutor] Python Advocacy: :Python has lists and lists of lists and classes (which can contain their :own members). But it doesn't have hashes, nor does it need them. Wouldn't you consider the Python dictionaries to be like hashes? (OK, I admit it, I really don't know what Perl hashes are...) : FQ sysadmin asked: :> I have some projects that might fit better into an object oriented way of :> thinking - however I must be careful of time spent learning 'Yet Another :> Programming Language' since deadlines could quickly slip... : :Well, here's the thing: perl is essentially awk on steroids. Python is a :general-purpose programming language. Do you intend on sysadminning :forever? Because shell scripting will limit your career options more than :learning a more traditional-style language. Just a note: The sysadmin in question is the OWNER of the web hosting company. He works for himself. FutureQuest, http://www.futurequest.net , is a small web hosting company that has grown, in about three years time, from one community server, to twelve. They offer superlative support, integrity and honesty, and a personal relationship with your hosting company. (Um, did I mention that I like them?) <In general, the "limiting yourself to scripting languages only will limit your career options" is a good point, but I feel a little silly telling that to a successful business man who owns his own business.> -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From deirdre@deirdre.net Sat Apr 14 07:21:14 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Fri, 13 Apr 2001 23:21:14 -0700 (PDT) Subject: [Tutor] Python Advocacy In-Reply-To: <51C1D43A9F@kserver.org> Message-ID: <Pine.LNX.4.31.0104132319250.698-100000@emperor.deirdre.org> On Fri, 13 Apr 2001, Sheila King wrote: > Wouldn't you consider the Python dictionaries to be like hashes? (OK, > I admit it, I really don't know what Perl hashes are...) No, not really. I mean, you can use them like the simple form of the hash, but perl hashes get intensely evil. > Just a note: The sysadmin in question is the OWNER of the web hosting > company. He works for himself. Yes, but how successful is it if the owner IS the sysadmin? :) I like small companies, don't get me wrong. In a different economy, I'd start one (I was just laid off). > FutureQuest, http://www.futurequest.net , is a small web hosting > company that has grown, in about three years time, from one community > server, to twelve. They offer superlative support, integrity and > honesty, and a personal relationship with your hosting company. (Um, > did I mention that I like them?) Sounds like a great place. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From alan.gauld@freenet.co.uk Sat Apr 14 09:44:22 2001 From: alan.gauld@freenet.co.uk (Alan Gauld) Date: Sat, 14 Apr 2001 08:44:22 +0000 Subject: [Tutor] Functional Programming tutor Message-ID: <3.0.1.32.20010414084422.015de55c@mail.freenet.co.uk> For anyone interested I have uploaded a bnew topic to my tutor: Functional Programming. Its only a brief overview of FP and how Python supports it but covers: map(), reduce(), filter(), lambda and short circuit evaluation as a replacement for if/else I haven't covered the new v2.0 features, partly coz I haven't really used them myself yet! It's at: http://www.crosswinds.net/~agauld Under advanced topics. Feedback, as ever, is welcomed. Alan G From scarblac@pino.selwerd.nl Sat Apr 14 20:54:17 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sat, 14 Apr 2001 21:54:17 +0200 Subject: [Tutor] FYI In-Reply-To: <01041405235005.00327@debian>; from pdiaz88@terra.es on Sat, Apr 14, 2001 at 05:23:50AM +0200 References: <01041405235005.00327@debian> Message-ID: <20010414215417.A5995@pino.selwerd.nl> On 0, Pedro Diaz Jimenez <pdiaz88@terra.es> wrote: > Moral: lists, dictionaries (and all other objects???) are copies by > reference, be careful when you pass them to functions Yes, all other objects as well. Assignment is by reference. Python never copies things "by itself". If the object is immutable, like a string or an integer, you'll never notice the difference, of course (except it's faster this way). -- Remco Gerlich From sheila@thinkspot.net Sat Apr 14 21:29:58 2001 From: sheila@thinkspot.net (Sheila King) Date: Sat, 14 Apr 2001 13:29:58 -0700 Subject: [Tutor] Python Advocacy In-Reply-To: <Pine.LNX.4.31.0104132256360.698-100000@emperor.deirdre.org> References: <3B02ED26B9@kserver.org> <Pine.LNX.4.31.0104132256360.698-100000@emperor.deirdre.org> Message-ID: <356116929B2@kserver.org> On Fri, 13 Apr 2001 23:02:58 -0700 (PDT), Deirdre Saoirse <deirdre@deirdre.net> wrote about Re: [Tutor] Python Advocacy: :However, python is byte compiled, which may offer speed :advantages. However, in general, if you're looking for speed, you wouldn't :be using perl either. I've been sharing the comments I've received to this post (some were sent by private e-mail, some came from comp.lang.python). In response to Deidre's remarks above, someone responded: PK> How Python being compiled to bytecodes would give it a speed advantage over Perl, which is PK> also compiled to "bytecodes" which are then interpreted, is beyond me. I just am not qualified to respond to these types of remarks. Is anyone here game? He further states: PK> Speed is often not a BIG issue: if a script in Perl takes 1 minute and in Python PK>it took 1 and a half minutes, that's really not going to be an issue most of the time. If a Perl PK> script that runs in 1 minute takes 20 minutes in Python, that may well be an issue: and it's a PK> possibility too. http://home.hiwaay.net/~gbacon/py-vs-pl.html (It's from 1995: I assume Python PK> has gotten considerably faster since then. The point is that it most certainly COULD be that PK> scale of difference, not that it IS.) Then he proposes a challenge: Some task, where the Perl fans will write their idiomatic solution, and the Python fans (me? I don't know that there is anyone else there), will write their solution. And then they'll benchmark it. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From rob@jam.rr.com Sat Apr 14 23:06:59 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Sat, 14 Apr 2001 17:06:59 -0500 Subject: [Tutor] Python Advocacy References: <3B02ED26B9@kserver.org> <Pine.LNX.4.31.0104132256360.698-100000@emperor.deirdre.org> <356116929B2@kserver.org> Message-ID: <3AD8CA03.CC2E5B39@jam.rr.com> I've just composed two scripts that count from 2 to 10,000. One is in Perl, freshly downloaded from ActiveState, and the other in Python 2.0. Each ran in just about exactly 5 seconds from the command prompt on a Win98 PII-266. Here are the scripts: Python: i = 0 while i <= 10000: i = i+1 print i Perl: $i = 0; while ($i <= 10000){ $i = $i + 1; print "$i\n"; } If anyone feels like an adventure (and knows how to do it), we could devise a number of fair challenges for a Script Olympics of sorts. I've only seen limited and somewhat dated comparisons between languages out there as a general rule, so I'm tempted to come up with a few similar scripts like this and put them head-to-head. (Kinda like *Junkyard Wars*, only digital. 3;-> ) Uselessly yours, Rob Sheila King wrote: > > On Fri, 13 Apr 2001 23:02:58 -0700 (PDT), Deirdre Saoirse > <deirdre@deirdre.net> wrote about Re: [Tutor] Python Advocacy: > > :However, python is byte compiled, which may offer speed > :advantages. However, in general, if you're looking for speed, you wouldn't > :be using perl either. > > I've been sharing the comments I've received to this post (some were sent by > private e-mail, some came from comp.lang.python). > > In response to Deidre's remarks above, someone responded: > > PK> How Python being compiled to bytecodes would give it a speed advantage > over Perl, which is > PK> also compiled to "bytecodes" which are then interpreted, is beyond me. > > I just am not qualified to respond to these types of remarks. Is anyone here > game? > > He further states: > > PK> Speed is often not a BIG issue: if a script in Perl takes 1 minute and in > Python > PK>it took 1 and a half minutes, that's really not going to be an issue most > of the time. If a Perl > PK> script that runs in 1 minute takes 20 minutes in Python, that may well be > an issue: and it's a > PK> possibility too. http://home.hiwaay.net/~gbacon/py-vs-pl.html (It's from > 1995: I assume Python > PK> has gotten considerably faster since then. The point is that it most > certainly COULD be that > PK> scale of difference, not that it IS.) > > Then he proposes a challenge: Some task, where the Perl fans will write their > idiomatic solution, and the Python fans (me? I don't know that there is anyone > else there), will write their solution. And then they'll benchmark it. > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From arcege@speakeasy.net Sat Apr 14 23:28:38 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Sat, 14 Apr 2001 18:28:38 -0400 (EDT) Subject: [Tutor] Python Advocacy In-Reply-To: <356116929B2@kserver.org> from "Sheila King" at Apr 14, 2001 01:29:58 PM Message-ID: <200104142228.f3EMSdp03147@dsl254-114-246.nyc1.dsl.speakeasy.net> Sheila King wrote > In response to Deidre's remarks above, someone responded: > > PK> How Python being compiled to bytecodes would give it a speed advantage > over Perl, which is > PK> also compiled to "bytecodes" which are then interpreted, is beyond me. > > I just am not qualified to respond to these types of remarks. Is anyone here > game? Perl is compiled into bytecode as well... but every time the program runs. Python has the ability, like Java, to save the bytecode to a file (.pyc) and use the bytecode files instead (if up-to-date). Beyond that, there will be little that has to be done. But it used to be a big gotcha in the Perl world that all files had to be compiled when loaded. >From what I can tell, newer version of Perl have a "backend bytecode compiler". You need to run a different program, "byteperl", to use the resulting files (which they called "plc" and "pmc" files, taking from Python's "pyc" extension - like they did with most of Perl 5). This is a seperate, developer-initiated step. Since the bytecode needs to be recompiled in Perl every execution, and Python can use already compiled files. Recompiling can be a fairly expensive processes, slowing the program's startup down. But, there is one overriding reason for using Python over Perl. It is summed up well in an excerpt from _Programming Python, 2nd Edition_ by Mark Lutz. ----------------- A Morality Tale of Perl Versus Python (The following was posted recently to the rec.humor.funny Usenet newsgroup by Larry Hastings, and is reprinted here with the original author's permission. I don't necessarily condone language wars; okay?) This has been percolating in the back of my mind for a while. It's a scene from "The Empire Strikes Back," reinterpreted to serve a valuable moral lesson for aspiring programmers. EXTERIOR: DAGOBAH-DAY With Yoda strapped to his back, Luke climbs up one of the many thick vines that grow in the swamp until he reaches the Dagobah statistics lab. Panting heavily, he continues his exercises - grepping, installing new packages, logging in as root, and writing replacements for two-year- old shell scripts in Python. YODA: Code! Yes. A programmer's strength flows from code maintainability. But beware of Perl. Terse syntax.. more than one way to do it... default variables. The dark side of code maintainability are they. Easily they flow, quick to join you when code you write. If once you start down the dark path, forever will it dominate your destiny, consume you it will. LUKE: Is Perl better than Python? YODA: No... no... no. Quicker, easier, more seductive. LUKE: But how will I know why Python is better than Perl? YODA: You will know. When your code you try to read six months from now. ----------------- As someone who has a web hosting company, where his customers require him to maintain his systems, he should be more than just conscious of code maintainability. If he had Perl as his system language, I'd be looking elsewhere for such services. -Arcege FYI: Interestingly, the Perl byte-compile makes a HUGE file relative to the source code: $ echo 'print "Hi there"' > foo.py $ python -c 'import pycompile; pycompile.compile_file("foo.py")' Traceback (innermost last): File "<string>", line 1, in ? ImportError: No module named pycompile $ python -c 'import py_compile; py_compile.compile("foo.py")' $ echo 'print "Hi there\n";' > foo.pl $ perl -MO=Bytecode foo.pl > foo.plc foo.pl syntax OK $ ls -l foo.* -rw-rw-r-- 1 arcege arcege 20 Apr 14 17:59 foo.pl -rw-rw-r-- 1 arcege arcege 159127 Apr 14 17:59 foo.plc -rw-rw-r-- 1 arcege arcege 17 Apr 14 17:58 foo.py -rw-rw-r-- 1 arcege arcege 90 Apr 14 17:58 foo.pyc The Python bytecode is five times the source code, but Perl's is nearly 2000 times larger. Hmmm.... efficient? Don't know. -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From scarblac@pino.selwerd.nl Sun Apr 15 02:55:30 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 15 Apr 2001 03:55:30 +0200 Subject: [Tutor] Python Advocacy In-Reply-To: <356116929B2@kserver.org>; from sheila@thinkspot.net on Sat, Apr 14, 2001 at 01:29:58PM -0700 References: <3B02ED26B9@kserver.org> <Pine.LNX.4.31.0104132256360.698-100000@emperor.deirdre.org> <356116929B2@kserver.org> Message-ID: <20010415035530.A6272@pino.selwerd.nl> On 0, Sheila King <sheila@thinkspot.net> wrote: > PK> How Python being compiled to bytecodes would give it a speed advantage > over Perl, which is > PK> also compiled to "bytecodes" which are then interpreted, is beyond me. > > I just am not qualified to respond to these types of remarks. Is anyone here > game? "PK" is being clever. His point is that Perl is byte-compiled as well. Saying "How this is a difference is beyond me" is c.l.perl.misc talk for "I'm sorry, but you were inaccurate there, there is no difference." > He further states: > > PK> Speed is often not a BIG issue: if a script in Perl takes 1 minute and in > Python > PK>it took 1 and a half minutes, that's really not going to be an issue most > of the time. If a Perl > PK> script that runs in 1 minute takes 20 minutes in Python, that may well be > an issue: and it's a > PK> possibility too. http://home.hiwaay.net/~gbacon/py-vs-pl.html (It's from > 1995: I assume Python > PK> has gotten considerably faster since then. The point is that it most > certainly COULD be that > PK> scale of difference, not that it IS.) > > Then he proposes a challenge: Some task, where the Perl fans will write their > idiomatic solution, and the Python fans (me? I don't know that there is anyone > else there), will write their solution. And then they'll benchmark it. His first point is good. Perl and Python are both slow compared to typically fast languages (say, C). So if you're going to use one, it's not going to matter if one is slightly slower than the other. If one is going to be substantially slower (like a factor 20) then it matters, for that application. >From what I've seen, most huge differences between Perl and Python were caused by incompetence in the slower language. Some idiom in Perl was translated too directly to Python or vice versa. There's often a better way. Still, such a challenge would be reasonable, if it were to use a lot of different problems. I don't know what his challenge was about, url? -- Remco Gerlich From sheila@thinkspot.net Sun Apr 15 03:58:54 2001 From: sheila@thinkspot.net (Sheila King) Date: Sat, 14 Apr 2001 19:58:54 -0700 Subject: [Tutor] Python Advocacy In-Reply-To: <20010415035530.A6272@pino.selwerd.nl> References: <3B02ED26B9@kserver.org> <Pine.LNX.4.31.0104132256360.698-100000@emperor.deirdre.org> <356116929B2@kserver.org> <20010415035530.A6272@pino.selwerd.nl> Message-ID: <4B5AC8B0320@kserver.org> On Sun, 15 Apr 2001 03:55:30 +0200, Remco Gerlich <scarblac@pino.selwerd.nl> wrote about Re: [Tutor] Python Advocacy: :On 0, Sheila King <sheila@thinkspot.net> wrote: ...<snipped>... :"PK" is being clever. His point is that Perl is byte-compiled as well. : :Saying "How this is a difference is beyond me" is c.l.perl.misc talk for :"I'm sorry, but you were inaccurate there, there is no difference." : :> He further states: ...<snipped>... :> Then he proposes a challenge: Some task, where the Perl fans will write their :> idiomatic solution, and the Python fans (me? I don't know that there is anyone :> else there), will write their solution. And then they'll benchmark it. : :His first point is good. Perl and Python are both slow compared to typically :fast languages (say, C). So if you're going to use one, it's not going to :matter if one is slightly slower than the other. If one is going to be :substantially slower (like a factor 20) then it matters, for that application. : :From what I've seen, most huge differences between Perl and Python were :caused by incompetence in the slower language. Some idiom in Perl was :translated too directly to Python or vice versa. There's often a better way. Yes, this is what I figured. However, it's one thing to say to someone else, "Well, it is my understanding that there isn't that much difference in speed between the two languages." And have them just accept my statement at face value. It is another thing, entirely, to convince them of that. :Still, such a challenge would be reasonable, if it were to use a lot of :different problems. I don't know what his challenge was about, url? Yes, well, I'm warming up to the idea of a good challenge. If the Pythoners from this list want to team up, I think I can find an opposing team of Perl Monks who'd want to take up the challenge. PK didn't suggest any specific task. More like, he was casting about for someone to propose one. Here is the URL where this discussion is taking place: http://www.aota.net/ubb/Forum3/HTML/001567-3.html -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From tbrauch@mindless.com Sun Apr 15 07:02:35 2001 From: tbrauch@mindless.com (Timothy M. Brauch) Date: Sun, 15 Apr 2001 02:02:35 -0400 (EDT) Subject: [Tutor] Python Advocacy In-Reply-To: <20010415035530.A6272@pino.selwerd.nl> References: <20010415035530.A6272@pino.selwerd.nl> Message-ID: <1079.216.68.187.116.987314555.squirrel@titan.centre.edu> Here's my two cents on the subject. A long time ago I learned programming on my Apple IIe based on DOS 3.0 (or was it 3.1?). I learned by looking at the code other people had already written. Then, I changed things to see what the difference was. And, there were never any comments in these programs. Nothing was better than starting a stock market game I had with one million dollars instead of one thousand. Now, I know Python decent enough to be able to accomplish just about anything I want to do with it. I have some knowledge of C/C++ and very little of Perl. I think that I know Python best now because I can look at the code and understand what is happening and what happens if I change something. Even ugly, uncommented code I can usually decipher (although I am still a little fuzzy on pickling and lamda functions). On tests for my Comp Sci class on Python, there were even always questions such as "What is the output of the following code?" That is why I think Python is better, at least to learn, than Perl. Someday I thought I might actually make an attempt at learning Perl for real, but if I can't just look at code and figure things out, it will make learning it a little harder for me. I'm sure Perl has a good quality and if I look hard enough, one day I might find it. However, right now I am spending my time learning some good ol' assembly language. Tim Brauch From cooler12001@yahoo.com Sun Apr 15 10:09:42 2001 From: cooler12001@yahoo.com (Matthews James) Date: Sun, 15 Apr 2001 02:09:42 -0700 (PDT) Subject: [Tutor] To anyone that understands python or tkinter....... Message-ID: <20010415090942.63266.qmail@web11405.mail.yahoo.com> Does anyone have any useless programs that i might beable to mess around with to help me understand this. i can understand most of python but i would like some tkinter programs also __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ From Daniel.Kinnaer@Advalvas.be Sun Apr 15 10:47:20 2001 From: Daniel.Kinnaer@Advalvas.be (Daniel Kinnaer) Date: Sun, 15 Apr 2001 11:47:20 +0200 Subject: [Tutor] Python Advocacy In-Reply-To: <4B5AC8B0320@kserver.org> Message-ID: <LPBBLJLBPKOAHOOJGJIJIEEJCPAA.Daniel.Kinnaer@Advalvas.be> When it comes to testing a language, one has to be very careful. If I remember well, in the "old days" Basic was often compared to Turbo Pascal and Turbo C and the testers used a.o. the Sieve of Erastothenes to make those comparisons. Now, what is interesting in this story is that at some time, there were very optimized Basic-subroutines for the Sieve, which they were running on faster/better PCs as well, thus making Basic "as fast as" Pascal or C ! Let us come up with something honest: - note what a language can do and what a language can't do - test the the common parts (like SMTP, the Sieve, database,...) - use the same hardware and OS for the tests - test with equivalent knowledge (newbie, intermediate, expert) - test the ease of changing the code after a few weeks/months This little list can be extended in many ways, but I guess I summed up the important points, though. Hope to read about these tests pretty soon! Best regards, Daniel From scarblac@pino.selwerd.nl Sun Apr 15 11:02:31 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 15 Apr 2001 12:02:31 +0200 Subject: [Tutor] To anyone that understands python or tkinter....... In-Reply-To: <20010415090942.63266.qmail@web11405.mail.yahoo.com>; from cooler12001@yahoo.com on Sun, Apr 15, 2001 at 02:09:42AM -0700 References: <20010415090942.63266.qmail@web11405.mail.yahoo.com> Message-ID: <20010415120231.A6585@pino.selwerd.nl> On 0, Matthews James <cooler12001@yahoo.com> wrote: > Does anyone have any useless programs that i might > beable to mess around with to help me understand this. We have a collection of them, at Useless Python, http://www.lowerstandard.com/python/pythonsource.html No guarantees whatsoever about the code, but there is a lot to look at :). You can also search for Python related stuff at Parnassus, http://www.vex.net/parnassus/ Loads of stuff there. And if you get the Python source distribution, there is a directory called "Demos" in it with some good things. -- Remco Gerlich From kstoner@netins.net Sun Apr 15 14:03:58 2001 From: kstoner@netins.net (Katharine Stoner) Date: Sun, 15 Apr 2001 08:03:58 -0500 Subject: [Tutor] ool Message-ID: <000a01c0c5ac$89092aa0$ab52b1cf@oemcomputer> This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C0C582.9F92EB00 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, Is python a completely object orientated language or is it a hybrid? -Cameron ------=_NextPart_000_0007_01C0C582.9F92EB00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Is python a completely object = orientated language=20 or is it a hybrid?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-Cameron</FONT></DIV> <DIV> </DIV></BODY></HTML> ------=_NextPart_000_0007_01C0C582.9F92EB00-- From rob@jam.rr.com Sun Apr 15 15:28:28 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Sun, 15 Apr 2001 09:28:28 -0500 Subject: [Tutor] ool References: <000a01c0c5ac$89092aa0$ab52b1cf@oemcomputer> Message-ID: <3AD9B00C.F054104D@jam.rr.com> One of the Old Wise Ones may be able to answer in more detail than this, but I can say that while Python is OOP, it is possible to write simple procedural scripts such as: >>> n = 0 >>> while n < 3: print n n = n +1 0 1 2 This is great, because it enables morons such as m'self to draft simple scripts that do stuff until we begin to get the gist of OOP. But OOP runs deep in Python, such that by the time I started to think of coding in OOP I discovered that Python had snuck it in on me in some of the built-in parts. The short story is that you don't have to use OOP to code "hello world", but merely to do this: >>> print "hello world" hello world Hope this helps, Rob > Katharine Stoner wrote: > > Hi all, > > Is python a completely object orientated language or is it a hybrid? > > -Cameron > -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From scarblac@pino.selwerd.nl Sun Apr 15 17:00:34 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 15 Apr 2001 18:00:34 +0200 Subject: [Tutor] ool In-Reply-To: <000a01c0c5ac$89092aa0$ab52b1cf@oemcomputer>; from kstoner@netins.net on Sun, Apr 15, 2001 at 08:03:58AM -0500 References: <000a01c0c5ac$89092aa0$ab52b1cf@oemcomputer> Message-ID: <20010415180034.A7122@pino.selwerd.nl> On 0, Katharine Stoner <kstoner@netins.net> wrote: > Is python a completely object orientated language or is it a hybrid? I don't think that's a very useful question. Whatever answer we give will immediately wander off into a discussion of what "completely object oriented language" is supposed to mean. And it doesn't actually matter for anything, does it? Everything is an object in Python, including functions, classes, and the module you run things in. But some people insist that to be "completely object oriented", you must be forced to put everything inside class definitions, and that's not the case in Python. So although it uses objects everywhere, you can write lots of Python without ever defining a class. It's not "completely class-oriented". Deciding whether this means "yes", "no" or "maybe" is left as an excercise for the reader. Regardless of that, in my opinion the way Python does it is the Right Thing, and that does matter :-). Putting a main() function inside some dummy class, supposedly for being more OO, is just stupid. -- Remco Gerlich From britt_green@hotmail.com Mon Apr 16 02:03:05 2001 From: britt_green@hotmail.com (Britt Green) Date: Sun, 15 Apr 2001 18:03:05 -0700 Subject: [Tutor] Name Error? Message-ID: <F78GW6Ex3AkwtsQztQo00002eac@hotmail.com> Hello All, Whenever I run this code, I get a Name Error: import string class Parser: def __init__(self): pass def isVerb(self, firstWord): verbs = ['go', 'get', 'drop', 'open', 'close', 'look', 'throw', 'lock', 'unlock'] if firstWord in verbs: return 1 else: return 0 def parseWords(self): phrase = raw_input("-->") splitPhrase = string.split(phrase) if isVerb(splitPhrase[0]): print splitPhrase[0] + " is a verb!" else: print splitPhrase[0] + " is not a verb!" if __name__ == "__main__": myParser = Parser() myParser.parseWords() And the error I'm getting is this: Traceback (innermost last): File "C:/Python20/Code/parser.py", line 25, in ? myParser.parseWords() File "C:/Python20/Code/parser.py", line 18, in parseWords if isVerb(splitPhrase[0]) == 1: NameError: There is no variable named 'isVerb' What am I doing wrong? _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From rick@niof.net Mon Apr 16 02:15:51 2001 From: rick@niof.net (Rick Pasotto) Date: Sun, 15 Apr 2001 21:15:51 -0400 Subject: [Tutor] Name Error? In-Reply-To: <F78GW6Ex3AkwtsQztQo00002eac@hotmail.com>; from britt_green@hotmail.com on Sun, Apr 15, 2001 at 06:03:05PM -0700 References: <F78GW6Ex3AkwtsQztQo00002eac@hotmail.com> Message-ID: <20010415211551.A26067@tc.niof.net> On Sun, Apr 15, 2001 at 06:03:05PM -0700, Britt Green wrote: > Hello All, > > Whenever I run this code, I get a Name Error: > > import string > > class Parser: > def __init__(self): > pass > > def isVerb(self, firstWord): > verbs = ['go', 'get', 'drop', 'open', 'close', 'look', 'throw', > 'lock', > 'unlock'] > if firstWord in verbs: > return 1 > else: > return 0 > > def parseWords(self): > phrase = raw_input("-->") > splitPhrase = string.split(phrase) > if isVerb(splitPhrase[0]) if self.isVerb(splitPhrase[0]): > print splitPhrase[0] + " is a verb!" > else: > print splitPhrase[0] + " is not a verb!" > > if __name__ == "__main__": > myParser = Parser() > myParser.parseWords() > > And the error I'm getting is this: > > Traceback (innermost last): > File "C:/Python20/Code/parser.py", line 25, in ? > myParser.parseWords() > File "C:/Python20/Code/parser.py", line 18, in parseWords > if isVerb(splitPhrase[0]) == 1: > NameError: There is no variable named 'isVerb' > > What am I doing wrong? Two things. There was no colon after your if (possibly a typo in the email) and since the function is defined within a class you need to qualify it with either the class name or the instance. -- "A moral code impossible to practice, a code that demands imperfection or death, has taught you to dissolve all ideas in fog, to permit no firm definitions, to regard any concept as approximate & any rule of conduct as elastic, to hedge on any principle, to compromise on any value, to take the middle of any road." -- Ayn Rand Rick Pasotto email: rickp@telocity.com From cooler12001@yahoo.com Mon Apr 16 05:38:17 2001 From: cooler12001@yahoo.com (Matthews James) Date: Sun, 15 Apr 2001 21:38:17 -0700 (PDT) Subject: [Tutor] Help with Tkinter's Entry or whatever else im wrong about Message-ID: <20010416043817.23322.qmail@web11407.mail.yahoo.com> This is what i have. I just started really learning Tkinter so beware it might not be pretty. ####################################################### from Tkinter import * def do(): entry.get() for times in range(0,13): label = Label(root,text=times+'X'+entry) label.pack() root = Tk() entry = Entry(root,input) entry.pack() button = Button(root,text='Times',command=do) button.pack() ###################################################### I'm wanting to know how to get entry to get a number or text but it always says that entry is .027483 and that number is always different each time i run the program Thanks Very Much James Matthews __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ From sheila@thinkspot.net Mon Apr 16 06:50:23 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 15 Apr 2001 22:50:23 -0700 Subject: [Tutor] Listing files in directories recursively Message-ID: <42313A62FE@kserver.org> OK, so I'm practicing a bit using os and os.path modules. I think I will try to list all the files under a given root directory, recursively going through all of its subdirectories and listing their contents, too. Shouldn't be too hard? OK, here's my script in its current version: ----------------------------------------------------- import sys, os '''print all the files in a directory and recursively in all directories below the given starting directory''' def listFiles(dir): basedir = dir print "Files in ", os.path.abspath(dir), ": " subdirlist = [] for item in os.listdir(dir): if os.path.isfile(item): print item else: subdirlist.append(os.path.join(basedir, item)) for subdir in subdirlist: listFiles(subdir) startdir = sys.argv[1] #starting dir passed as argument to script print "startdir is ", startdir listFiles(startdir) ----------------------------------------------------- Here is the command line call to the script: ----------------------------------------------------- E:>python E:\programs\LearningPython\recursfilelist.py C:\temp\ ----------------------------------------------------- Here is the output: ----------------------------------------------------- startdir is C:\temp\ Files in C:\temp : Files in C:\temp\Courses : Files in C:\temp\Courses\APCS : Files in C:\temp\Courses\APCS\KARELWIN : Files in C:\temp\Courses\APCS\KARELWIN\BC450RTL.DLL : Traceback (most recent call last): File "E:\programs\LearningPython\recursfilelist.py", line 20, in ? listFiles(startdir) File "E:\programs\LearningPython\recursfilelist.py", line 16, in listFiles listFiles(subdir) File "E:\programs\LearningPython\recursfilelist.py", line 16, in listFiles listFiles(subdir) File "E:\programs\LearningPython\recursfilelist.py", line 16, in listFiles listFiles(subdir) File "E:\programs\LearningPython\recursfilelist.py", line 16, in listFiles listFiles(subdir) File "E:\programs\LearningPython\recursfilelist.py", line 10, in listFiles for item in os.listdir(dir): WindowsError: [Errno 3] The system cannot find the path specified: 'C:\\temp\\Courses\\APCS\\KARELWIN\\BC450RTL.DLL' ----------------------------------------------------- Now, I don't know why it isn't listing any of the files. The listFiles function clearly tests if item is a file, using os.path.isfile, and if so, should list the file before calling the recursion to the next directory level below. But it isn't listing any of the files. Moreover, it's considering a .dll file to be a directory? I've been playing with this for two days, now. (Actually, my original idea was to add up the sizes of all the files, but I've put the file sizes on hold, until I can just list the blasted files.) I must be doing something simple wrong. Does anyone see what it is? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sheila@thinkspot.net Mon Apr 16 06:59:54 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 15 Apr 2001 22:59:54 -0700 Subject: [Tutor] Listing files in directories recursively In-Reply-To: <42313A62FE@kserver.org> References: <42313A62FE@kserver.org> Message-ID: <4ACB4746F6@kserver.org> OK, I solved my problem already. Here is what I changed: def listFiles(dir): basedir = dir print "Files in ", os.path.abspath(dir), ": " subdirlist = [] for item in os.listdir(dir): if os.path.isfile(item): print item else: subdirlist.append(os.path.join(basedir, item)) for subdir in subdirlist: listFiles(subdir) Changed the line above: print "Files in ", os.path.abspath(dir), ": " To print "Files in ", dir, ": " I don't figure that had anything to do with the error, but putting abspath on it wouldn't really help. Plus, I've found that abspath just really tacks on the path for the current working directory, which isn't really what I want, here. The key change, was changing this line: if os.path.isfile(item): To this: if os.path.isfile(os.path.join(basedir,item)): The files systems are kind of tricky to work with, because the files must be clearly indicated, by full path. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Sun, 15 Apr 2001 22:50:23 -0700, Sheila King <sheila@thinkspot.net> wrote about [Tutor] Listing files in directories recursively: :OK, so I'm practicing a bit using os and os.path modules. I think I will try :to list all the files under a given root directory, recursively going through :all of its subdirectories and listing their contents, too. Shouldn't be too :hard? : :OK, here's my script in its current version: : :----------------------------------------------------- :import sys, os : :'''print all the files in a directory and recursively :in all directories below the given starting directory''' : :def listFiles(dir): : basedir = dir : print "Files in ", os.path.abspath(dir), ": " : subdirlist = [] : for item in os.listdir(dir): : if os.path.isfile(item): : print item : else: : subdirlist.append(os.path.join(basedir, item)) : for subdir in subdirlist: : listFiles(subdir) : :startdir = sys.argv[1] #starting dir passed as argument to script :print "startdir is ", startdir :listFiles(startdir) :----------------------------------------------------- : :Here is the command line call to the script: : :----------------------------------------------------- :E:>python E:\programs\LearningPython\recursfilelist.py C:\temp\ :----------------------------------------------------- : : :Here is the output: :----------------------------------------------------- :startdir is C:\temp\ :Files in C:\temp : :Files in C:\temp\Courses : :Files in C:\temp\Courses\APCS : :Files in C:\temp\Courses\APCS\KARELWIN : :Files in C:\temp\Courses\APCS\KARELWIN\BC450RTL.DLL : :Traceback (most recent call last): : File "E:\programs\LearningPython\recursfilelist.py", line 20, in ? : listFiles(startdir) : File "E:\programs\LearningPython\recursfilelist.py", line 16, in listFiles : listFiles(subdir) : File "E:\programs\LearningPython\recursfilelist.py", line 16, in listFiles : listFiles(subdir) : File "E:\programs\LearningPython\recursfilelist.py", line 16, in listFiles : listFiles(subdir) : File "E:\programs\LearningPython\recursfilelist.py", line 16, in listFiles : listFiles(subdir) : File "E:\programs\LearningPython\recursfilelist.py", line 10, in listFiles : for item in os.listdir(dir): :WindowsError: [Errno 3] The system cannot find the path specified: :'C:\\temp\\Courses\\APCS\\KARELWIN\\BC450RTL.DLL' :----------------------------------------------------- : :Now, I don't know why it isn't listing any of the files. The listFiles :function clearly tests if item is a file, using os.path.isfile, and if so, :should list the file before calling the recursion to the next directory level :below. But it isn't listing any of the files. Moreover, it's considering a :.dll file to be a directory? : :I've been playing with this for two days, now. (Actually, my original idea was :to add up the sizes of all the files, but I've put the file sizes on hold, :until I can just list the blasted files.) : :I must be doing something simple wrong. Does anyone see what it is? From parth.malwankar@wipro.com Mon Apr 16 07:11:24 2001 From: parth.malwankar@wipro.com (Parth Malwankar) Date: Mon, 16 Apr 2001 11:41:24 +0530 Subject: [Tutor] unicode support in 're' Message-ID: <20010416114124.A19244@wipro.wipsys.sequent.com> Hello, I wish to find the occurance of a pattern in a unicode text file. I tried using re for this purpose. ##### expr = re.compile(u'^\.', re.UNICODE|re.M) x = expr.split(textfromfile) ##### but this doesnt seem to split on the character specified. Am I doing something wrong. It is possible to convert the read lines into ascii and then run the match. But I was wondering if there is any direct way to do this. Thanks in advance, Parth From van@lindbergs.org Mon Apr 16 07:37:32 2001 From: van@lindbergs.org (VanL) Date: Mon, 16 Apr 2001 00:37:32 -0600 Subject: [Tutor] Listing files in directories recursively References: <42313A62FE@kserver.org> <4ACB4746F6@kserver.org> Message-ID: <3ADA932C.B99EAC62@lindbergs.org> For what its worth, there is already a builtin that will do most of the work for you: >>> import os >>> >>> def walker(arg, dirname, names): ... print arg, dirname, names ... >>> os.path.walk('.', walker, 'Please show me:') Please show: . ['Addons'] Please show: .\Addons ['avl-2.0.tar.gz', 'egenix-mx-base-2.0.0.win32-py2.0.exe', 'egenix-mx-commercial-2.0.0.win32-py2.0.exe', 'eopl.tar.gz', 'HTMLgen', 'HTMLge n.tar', 'NumPy', 'PyOpenGL-1.5.6.win32-py2.0.exe', 'win32all-138.exe', 'wxPython -2.2.1-Py20b1.EXE'] hth, VanL From dyoo@hkn.eecs.berkeley.edu Mon Apr 16 09:42:23 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 16 Apr 2001 01:42:23 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <F10481IfpT8vWyu9kst00007f8b@hotmail.com> Message-ID: <Pine.LNX.4.21.0104160122080.28625-100000@hkn.eecs.berkeley.edu> On Mon, 16 Apr 2001, wong chow cheok wrote: > hai daniel. sorry to bother you like this. but i cannot seem to grasp what > you did. i know it works but i do not know how to edit it as i cannot > understand all the signs you used. it has really confused me. > > [\w.#@&=\-_~/;:\n]+? # a bunch of stuff that can span > >lines, > > # nongreedily, > > (?=([,:\-.!?;]? # that shouldn't contain any > > # trailing punctutation, > > (\s+|$))) # spaces, or eol character. > > ''' > > i cannot seem to get all the lines here. i know that the first line after > the colon(:) is the rest of the url after the HTTP but what is the others > for and what is the function of the ?. sorry for being a bore but your help > is really appreciated. thanks a lot. Let's take a closer look at some of those lines: [\w.#@&=\-_~/;:\n]+? # a bunch of stuff that can span lines, This particular regular expression says a few things. It's defining a "character class" between the two brackets '[' and ']'. A character class says that all of the enclosed "characters" should be considered the same --- the reason this is useful is because the plus sign character afterwards means that we want to have at least one or more of those characters. For example: [abcd]+ will match "aabbcc" "dabbac", "cad", but will reject "raccoon", "wizard", or anything that doesn't consist of the letters 'a', 'b', 'c', or 'd'. Let's take a closer look at the characters within the class. There's a "metacharacter" called '\w' that stands for all word-like characters. By this, we're telling Python to recognize the letters "A" through "Z" and digits "0" through "9" as perfectly good characters. Also, I need to say that the symbols '.', '#', '&', and the rest could be part of an URL. So, for example: python.org/doc/Intros.html will match with the above, because each character will match with something within our character class. The question mark '?' is a little harder to explain. It's called the "nongreedy" modifier, and it takes a few examples to see why it's necessary. Take a look: ### >>> re.search('begin.*end', 'let us begin and end this.').group(0) 'begin and end' >>> re.search('begin.*end', 'begin and end this, and end it.').group(0) 'begin and end this, and end' ### Notice that when we try matching with this regular expression, that it tries to grab as many characters as it can. Intuitively, we can see that the search is "greedy". To make it nongreedy, we need to give our regular expression some doubt, which is symbolized by the question mark: ### >>> re.search('begin.*?end', 'let us begin and end this, and end it now').group(0) 'begin and end' ### The question mark modifies the matching to tell Python to try matching without so much greediness, to try matching as quickly as possible. I actually adapted the code from Tom Christensen's nice "Far More than Everything You Wanted To Know About Regexps" article on perl.org. He explains regular expressions a lot better than me; take a look at his article: http://language.perl.com/all_about/regexps.html Hope this helps! From cooler12001@yahoo.com Mon Apr 16 10:07:37 2001 From: cooler12001@yahoo.com (Matthews James) Date: Mon, 16 Apr 2001 02:07:37 -0700 (PDT) Subject: [Tutor] Need help with Tkinter Entry() Message-ID: <20010416090737.48228.qmail@web11405.mail.yahoo.com> This is what i have ####################################################### from Tkinter import * def do(): ENTRY = entry.get() for times in range(0,13): E = '%d X %d = %d' % (ENTRY,times,ENTRY*times) label = Label(root,text=E) label.pack() root = Tk() entry = Entry(root) entry.pack() button = Button(root,text='Times',command=do) button.pack() ###################################################### I dont know how to get the entry to get the number or text it always say that it needs a integer. but when i call it in the python shell it says that it is .274467 or something like that and this number is always different when i run the program James __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ From cooler12001@hotmail.com Mon Apr 16 10:22:02 2001 From: cooler12001@hotmail.com (James Matthews) Date: Mon, 16 Apr 2001 09:22:02 -0000 Subject: [Tutor] Need help with Tkinter Entry().. Message-ID: <F17502H67yRLVbNDN4C00008ba7@hotmail.com> ####################################################### from Tkinter import * def do(): ENTRY = entry.get() for times in range(0,13): E = '%d X %d = %d' % (ENTRY,times,ENTRY*times) label = Label(root,text=E) label.pack() root = Tk() entry = Entry(root) entry.pack() button = Button(root,text='Times',command=do) button.pack() ###################################################### I dont know how to get the entry to get the number or text it always say that it needs a integer. but when i call it in the python shell it says that it is .274467 or something like that and this number is always different when i run the program James _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From dyoo@hkn.eecs.berkeley.edu Mon Apr 16 17:31:33 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 16 Apr 2001 09:31:33 -0700 (PDT) Subject: [Tutor] Need help with Tkinter Entry().. In-Reply-To: <F17502H67yRLVbNDN4C00008ba7@hotmail.com> Message-ID: <Pine.LNX.4.21.0104160916380.2865-100000@hkn.eecs.berkeley.edu> On Mon, 16 Apr 2001, James Matthews wrote: > > ####################################################### > from Tkinter import * > > def do(): > ENTRY = entry.get() > for times in range(0,13): > E = '%d X %d = %d' % (ENTRY,times,ENTRY*times) > label = Label(root,text=E) > label.pack() > > root = Tk() > entry = Entry(root) > entry.pack() > button = Button(root,text='Times',command=do) > button.pack() > ###################################################### > > I dont know how to get the entry to get the number or > text it always say that it needs a integer. but > when i call it in the python shell it says that it is > .274467 or something like that and this number is > always different when i run the program On the whole, your program looks ok. There are a few nitpicky things we'll need to fix to get things working: 1. The Entry doesn't have an initial value --- it starts off empty by default --- so let's check within your do() to see if the entry has a good value in there. There are a few ways to do this (some with exception handling), but for now, let's just check that the user's not putting in an empty string. 2. Also, the value that you get out of entry.get() is a string, so you'll want to coerce it into an integer form, because arithmetic on strings doesn't work. For example: ### >>> "3" + "4" ## "Addition" between two strings is concatenation '34' >>> "3" * "4" Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: can't multiply sequence with non-int >>> int("3") * int("4") ## Converting strings to ints first 12 ### 3. Don't forget to do a mainloop() at the end of your program, to tell Python that the gui's constructed and we're ready to listen to the user. The reason this is necessary is because, if we get to the bottom of the program, Python assumes that we're done with everything, and quits too prematurely. Here's a version of the code with the corrections: ### from Tkinter import * def do(): ENTRY = entry.get().strip() if ENTRY == "": return ## Do nothing if we don't have a string NUMENTRY = int(ENTRY) for times in range(0,13): E = '%d X %d = %d' % (NUMENTRY, times, NUMENTRY*times) label = Label(root,text=E) label.pack() root = Tk() entry = Entry(root) entry.pack() button = Button(root, text='Times', command=do) button.pack() mainloop() ### Hope this helps! From alan.gauld@bt.com Mon Apr 16 22:57:21 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 16 Apr 2001 22:57:21 +0100 Subject: [Tutor] Python Advocacy Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F2@mbtlipnt02.btlabs.bt.co.uk> > own members). But it doesn't have hashes, nor does it need them. Umm, I think a dictionary is a hash? It may not be identical to a Perl hash but it is a hash none the less. In particular Python can do associative arrays - Vital to any Perler and would wipe Python out of consideration if you suggest otherwise! Otherwise I agree :-) Alan G From deirdre@deirdre.net Mon Apr 16 23:06:08 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 16 Apr 2001 15:06:08 -0700 (PDT) Subject: [Tutor] Python Advocacy In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F2@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <Pine.LNX.4.31.0104161505220.11428-100000@emperor.deirdre.org> On Mon, 16 Apr 2001 alan.gauld@bt.com wrote: > > > own members). But it doesn't have hashes, nor does it need them. > > Umm, I think a dictionary is a hash? In the simple form, yes. There are peculiar things you can do with perl hashes that are not so easily replicated in Python. > It may not be identical to a Perl hash but it is a hash none the less. > In particular Python can do associative arrays - Vital to any Perler > and would wipe Python out of consideration if you suggest otherwise! -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From alan.gauld@bt.com Mon Apr 16 23:12:52 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 16 Apr 2001 23:12:52 +0100 Subject: [Tutor] To anyone that understands python or tkinter....... Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F3@mbtlipnt02.btlabs.bt.co.uk> > Does anyone have any useless programs that i might > beable to mess around with to help me understand this. > > i can understand most of python but i would like some > tkinter programs also Try starting with my event driven programming tutor: http://www.crosswinds.net/~agauld/tutevent.htm Then move to the next topic: GUI Programming with Tkinter http://www.crosswinds.net/~agauld/tutgui.htm Then try the Case Study http://www.crosswinds.net/~agauld/tutcase.htm which concludes with a Tkinter version of the grammar counter. Finally there is an OO Games Framework and a GUI implementation of hangman on the Useless Python site. There is a link to it on this page: http://www.crosswinds.net/~agauld/tutintro.htm HTH, Alan G PS If you find lamdas difficult you could also look at the explanation here: http://www.crosswinds.net/~agauld/tutfctnl.htm From arthur.watts@gbst.com Mon Apr 16 23:11:15 2001 From: arthur.watts@gbst.com (Arthur Watts) Date: Tue, 17 Apr 2001 08:11:15 +1000 Subject: [Tutor] Python and Speed Message-ID: <1CDB101F0CB6D311882F0000F8063924033A786A@aquarius.bne.star.com.au> Guys, I noticed that the Advocacy thread contained reference to the question of Perl's assumed speed advantage over Python. As someone who championed Python's acceptance for use in implementing a replacement for the shell scripts which support our bread-and-butter application, I was keen to quantify the difference. I was particularly keen to see how well Python went with a common shell operation - reading in a file, sorting it and then writing the new file. Lets assume we have two text files, each containing variable length strings (I think I used Linux HOW-TO's, from memory). We want to merge the files and sorted the merged result by ASCII collating sequence. The resulting 'newmaster' contained over 70,000 lines of text. Trivial stuff for a shell script : cat master.txt > /tmp/temp.txt cat trans.txt >> /tmp/temp.txt cat /tmp/temp.txt | sort | uniq > newmaster.txt I wrote code in C, Perl and Python (each using the default 'quicksort' algorithm to sort the data), and ran tests on a Celeron 566 (SuSe Linux), SPARC Enterprise 65000 (Solaris 2.6) and Compaq Alphaserver 4100. Under Solaris and Linux, Python actually outperformed Perl on each machine, with the Sun machine (much bigger than the Alpha..) achieving the best overall result. The C implementation took a total of 1.10 , Python 2.07 and Perl 2.21 secs. I'd like to make the following points : 1. These are just numbers - I'm sure that better programmers than myself could achieve better numbers for their chosen language. I doubt whether the Perl or Python code would ever begin to approach the C execution times without some sort of C extension. 2. The vast majority of the elapsed time, in each case, was spent in the performing file ops ('User'), whilst 'System' times are what the serious benchmarkers seem to focus on. For the record, they were .05, .11 and .15 respectively. 3. I tried to use the same algorithmic approach for each language, and relied on the default 'quicksort' approach. 4. If you read almost any treatise on sorting, you will see that different sort algorithms suit different patterns of data. I believe that Perl uses deep recursion in its version of the quicksort algorithm, which would give it an advantage with smaller text files. I think I prefer the approach taken by the C and Python guys. For me, the big win was not in any perceived speed advantage : it was the fact that I achieved my goal with 32 lines of Python (over 45 linees of Perl and way too many lines of C...). Here are the comparisons between the Perl sort code and the Python sort code : Perl : sub quicksort ($) { my ($arrayref) = @_; @$arrayref = sort { $a cmp $b } @$arrayref; return $arrayref; } Python list1.sort() # sort the list of strings In defence of Perl, we also use it for a variety of purposes, and it is a fantastically powerful language with a wealth of available modules. However, after mucking around for a while with the C and Perl solutions, I was stunned by how quickly the Python solution fell into my lap. Debugging it would also be a lot more bearable at 3am ... And, yes, we are now using Python as part of our revenue raiser ! Finally, I would like this to provide the catalyst for the Perl and Python communities to each agree on a set of common tasks which we could use for benchmark testing each new release of these interpreters. I know that Guido has never denied that Python is slower, but I'd like to be able to quantify it against something a little less trivial than my own manufactured example. Enjoy, Arthur Arthur Watts Software Engineer GBST Automation Global Banking & Securities Transactions Telephone + 61 7 3331 5555 mailto: arthur.watts@gbst.com www.gbst.com From alan.gauld@bt.com Mon Apr 16 23:17:39 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 16 Apr 2001 23:17:39 +0100 Subject: [Tutor] ool Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F4@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0C6C3.0C709100 Content-type: text/plain; charset="iso-8859-1" Is python a completely object orientated language or is it a hybrid? Does a completely OO language exist? I've never seen one. If one did exist would it be a good thing? Why? I think Smalltalk comes closest to completely OO but you can still write what is effectively non OO code in it. Python is a hybrid that allows you to use imperative, OO or functional styles of programming as appropriate. Alan G ------_=_NextPart_001_01C0C6C3.0C709100 Content-type: text/html; charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META content="MSHTML 5.00.3013.2600" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"> <DIV><FONT face=Arial size=2>Is python a completely object orientated language or is it a hybrid?</FONT></DIV></BLOCKQUOTE> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001>Does a completely OO language exist? I've never seen one.</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001>If one did exist would it be a good thing? Why?</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001>I think Smalltalk comes closest to completely OO but you </SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001>can still write what is effectively </SPAN></FONT><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001>non OO code in it.</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001>Python is a hybrid that allows you to use imperative, OO or </SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001>functional styles of programming as appropriate.</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=520311922-16042001>Alan G</SPAN></FONT></DIV></BODY></HTML> ------_=_NextPart_001_01C0C6C3.0C709100-- From alan.gauld@bt.com Mon Apr 16 23:21:50 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 16 Apr 2001 23:21:50 +0100 Subject: [Tutor] ool Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F5@mbtlipnt02.btlabs.bt.co.uk> > ...It's not "completely class-oriented". Amen to that. I have taken to calling Java a class oriented language rather than on object oriented because it relies so heavily on static class functions. This annoys my Java programming colleagues enormously ;-) Alan G > From alan.gauld@bt.com Mon Apr 16 23:27:29 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 16 Apr 2001 23:27:29 +0100 Subject: [Tutor] Help with Tkinter's Entry or whatever else im wrong a bout Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F6@mbtlipnt02.btlabs.bt.co.uk> > def do(): > entry.get() multiplier = int(entry.get()) # need a variable > for times in range(0,13): > label = Label(root,text=times+'X'+entry) label = Label(root,text=str(times)+'X'+multipler) Alternatively delete the entry.get() line and just do: label = Label(root,text=str(times)+'X'+entry.get()) HTH, Alan G From deirdre@deirdre.net Mon Apr 16 23:26:34 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 16 Apr 2001 15:26:34 -0700 (PDT) Subject: [Tutor] ool In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F5@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <Pine.LNX.4.31.0104161525210.11428-100000@emperor.deirdre.org> On Mon, 16 Apr 2001 alan.gauld@bt.com wrote: > > ...It's not "completely class-oriented". > > Amen to that. I have taken to calling Java a class > oriented language rather than on object oriented > because it relies so heavily on static class functions. I don't like Java, but mostly because it's a language designed for beginners (ostensibly) that doesn't really seem to encourage good programming practices. > This annoys my Java programming colleagues enormously You mean like my claim that Java is "C++ with training wheels"? :) -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From alan.gauld@bt.com Mon Apr 16 23:34:33 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 16 Apr 2001 23:34:33 +0100 Subject: [Tutor] Need help with Tkinter Entry() Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F7@mbtlipnt02.btlabs.bt.co.uk> Further to my earlier reply... > def do(): > ENTRY = entry.get() Better but you are reading a string not a number - it just looks like a number! > for times in range(0,13): > E = '%d X %d = %d' % (ENTRY,times,ENTRY*times) Much better once you make ENTRY into a number > when i call it in the python shell it says that it is > .274467 or something like that and this number is Thats the underlying Tcl/Tk represntation of your widget. The number is basically the memory address and the '.' is the root widget. If you had put your entry within a frame youd have gotten something like: .274467.123456 You don't need to know about any of that except to recognise it as Tcl/Tk internals... Alan G From dsh8290@rit.edu Mon Apr 16 23:48:16 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 16 Apr 2001 18:48:16 -0400 Subject: [Tutor] Python and Speed In-Reply-To: <1CDB101F0CB6D311882F0000F8063924033A786A@aquarius.bne.star.com.au>; from arthur.watts@gbst.com on Tue, Apr 17, 2001 at 08:11:15AM +1000 References: <1CDB101F0CB6D311882F0000F8063924033A786A@aquarius.bne.star.com.au> Message-ID: <20010416184816.C16@harmony.cs.rit.edu> On Tue, Apr 17, 2001 at 08:11:15AM +1000, Arthur Watts wrote: | Guys, | | I noticed that the Advocacy thread contained reference to the | question of Perl's assumed speed advantage over Python. As someone who | championed Python's acceptance for use in implementing a replacement for the | shell scripts which support our bread-and-butter application, I was keen to | quantify the difference. I was particularly keen to see how well Python went | with a common shell operation - reading in a file, sorting it and then | writing the new file. ... | 3. I tried to use the same algorithmic approach for each language, | and relied on the default 'quicksort' approach. I think that this is a 'defect' in your benchmark. I have seen several examples of perl (or other) programmers on c.l.py saying that Python is horribly slow in comparison to the other language. Then the gurus on c.l.py reworked their python code using more pythonic idioms and data structures and the speed became comparable. I think that for the benchmark to be "better" (by some definition of better <wink>) the most natural approach (algorithm, data structures) for each language must be used, even those approaches are almost certainly quite different. ... | For me, the big win was not in any perceived speed advantage : it | was the fact that I achieved my goal with 32 lines of Python (over 45 linees | of Perl and way too many lines of C...). Here are the comparisons between | the Perl sort code and the Python sort code : <grin> That's the goal and the win. ... | Finally, I would like this to provide the catalyst for the Perl and | Python communities to each agree on a set of common tasks which we could use | for benchmark testing each new release of these interpreters. I know that | Guido has never denied that Python is slower, but I'd like to be able to | quantify it against something a little less trivial than my own manufactured | example. I don't really agree that a "standard" benchmark would be a real advantage because developers have a tendency to optimize to the benchmark then. Sure, the numbers on the benchmark may look great, but what about the rest of the uses? The following perl is faster than the python below it : (barring any careless mistakes; yes I know the python version will add an extra newline to every line , I'm not sure about the perl version) for (<STDIN>) { print ; } for line in sys.stdin.readlines() : print line because (according to Tim Peters, and others) perl heavily optimizes file io at the cost of portability (supposedly they toy with the C FILE structs directly rather than use the C API) while python focuses more on being portable and thread-safe. Other differences include readlines sucks everything into RAM at once, xreadlines (in >=2.1 would be better). For another example, see the archives regarding counting words in a file. I posted a perl sample (didn't make it to the list) that I wrote for a class, then later translated to python. The perl version was (insignificantly, IMO) faster than the python version. Both produced identical results. I posted several observations about the testbed and the python code. The python version is on the Useless pages. I did have ~3 bugs in the perl version, but I don't remember what they are (the prof said so when I got my grade). The python version probably has the same 3 errors <wink>. I rewrote that script and measured the times in response to someone having trouble with performance of his solution to a similar problem. The original post used several classes and nested linear traversals of lists. He said it took over 15 minutes (or so) for his version to count a 2M (or something) file. The version I posted used different data structures and took less than 2 minutes (at most, I don't remember exactly now). -D From dsh8290@rit.edu Mon Apr 16 23:52:37 2001 From: dsh8290@rit.edu (D-Man) Date: Mon, 16 Apr 2001 18:52:37 -0400 Subject: [Tutor] ool In-Reply-To: <Pine.LNX.4.31.0104161525210.11428-100000@emperor.deirdre.org>; from deirdre@deirdre.net on Mon, Apr 16, 2001 at 03:26:34PM -0700 References: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F5@mbtlipnt02.btlabs.bt.co.uk> <Pine.LNX.4.31.0104161525210.11428-100000@emperor.deirdre.org> Message-ID: <20010416185237.D16@harmony.cs.rit.edu> On Mon, Apr 16, 2001 at 03:26:34PM -0700, Deirdre Saoirse wrote: | On Mon, 16 Apr 2001 alan.gauld@bt.com wrote: | | > > ...It's not "completely class-oriented". | > | > Amen to that. I have taken to calling Java a class | > oriented language rather than on object oriented | > because it relies so heavily on static class functions. | | I don't like Java, but mostly because it's a language designed for | beginners (ostensibly) that doesn't really seem to encourage good | programming practices. I didn't think Java was really designed (s/designed/suited/) for beginners. I think a 'beginner' language wouldn't make the beginner learn how to deal with exceptions to do IO. I have a friend who recently started studying CS in college. He has a bad professor (or so he describes) who is teaching java and awt. This is a beginning course. According to my friend they haven't learned a whole lot and always struggle through the projects. The only thing he really knows about exceptions is that putting "throws Exception" on the end of 'main' will let the prog compile and run. | > This annoys my Java programming colleagues enormously | | You mean like my claim that Java is "C++ with training wheels"? :) :-) There are a few conveniences Java has over C++, but I don't see a huge advantage; especially not compared to python. -D From scarblac@pino.selwerd.nl Tue Apr 17 00:13:04 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 17 Apr 2001 01:13:04 +0200 Subject: [Tutor] Python Advocacy In-Reply-To: <Pine.LNX.4.31.0104161505220.11428-100000@emperor.deirdre.org>; from deirdre@deirdre.net on Mon, Apr 16, 2001 at 03:06:08PM -0700 References: <5104D4DBC598D211B5FE0000F8FE7EB20751D6F2@mbtlipnt02.btlabs.bt.co.uk> <Pine.LNX.4.31.0104161505220.11428-100000@emperor.deirdre.org> Message-ID: <20010417011304.A9337@pino.selwerd.nl> On 0, Deirdre Saoirse <deirdre@deirdre.net> wrote: > On Mon, 16 Apr 2001 alan.gauld@bt.com wrote: > > > > > > own members). But it doesn't have hashes, nor does it need them. > > > > Umm, I think a dictionary is a hash? > > In the simple form, yes. There are peculiar things you can do with perl > hashes that are not so easily replicated in Python. Ooh, didn't know that. Examples? -- Remco Gerlich From deirdre@deirdre.net Tue Apr 17 00:21:45 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 16 Apr 2001 16:21:45 -0700 (PDT) Subject: [Tutor] Python Advocacy In-Reply-To: <20010417011304.A9337@pino.selwerd.nl> Message-ID: <Pine.LNX.4.31.0104161619460.11428-100000@emperor.deirdre.org> On Tue, 17 Apr 2001, Remco Gerlich wrote: > > In the simple form, yes. There are peculiar things you can do with perl > > hashes that are not so easily replicated in Python. > > Ooh, didn't know that. Examples? You know, I knew someone was going to ask that and I knew I wouldn't have an example handy. I remember someone showing me some clever (and unreadable) Perl code a couple years ago. Unfortunately, I'm not enough of a Perl masochist to try and replicate it. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From deirdre@deirdre.net Tue Apr 17 00:27:59 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 16 Apr 2001 16:27:59 -0700 (PDT) Subject: [Tutor] ool In-Reply-To: <20010416185237.D16@harmony.cs.rit.edu> Message-ID: <Pine.LNX.4.31.0104161622340.11428-100000@emperor.deirdre.org> On Mon, 16 Apr 2001, D-Man wrote: > | I don't like Java, but mostly because it's a language designed for > | beginners (ostensibly) that doesn't really seem to encourage good > | programming practices. > > I didn't think Java was really designed (s/designed/suited/) for > beginners. I think a 'beginner' language wouldn't make the beginner > learn how to deal with exceptions to do IO. Oh, I agree -- but it's being touted as though it was. Other examples: try "hello world" as standardly taught in Java. > I have a friend who recently started studying CS in college. He has a > bad professor (or so he describes) who is teaching java and awt. > This is a beginning course. According to my friend they haven't > learned a whole lot and always struggle through the projects. The > only thing he really knows about exceptions is that putting "throws > Exception" on the end of 'main' will let the prog compile and run. ::snort:: That's really useful. I really think my older statement really was spot-on: "Java is Cobol 2.0." > There are a few conveniences Java has over C++, but I don't see a huge > advantage; especially not compared to python. I agree, which is why I use Python. The biggest advantage Java seems to have over C++ is database access and multilanguage support (esp. 2-byte characters). The downside is that JVMs are, on average, as stable as the high elements of the periodic table. Not to mention the arguing over GUI libraries and so on. Which means that Java is uniquely suited for cron and batch jobs that access databases -- which is pretty much what Cobol has been historically used for. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From kojo@hal-pc.org Tue Apr 17 01:40:25 2001 From: kojo@hal-pc.org (Kojo) Date: Mon, 16 Apr 2001 19:40:25 -0500 Subject: [Tutor] ool In-Reply-To: <Pine.LNX.4.31.0104161622340.11428-100000@emperor.deirdre.o rg> References: <20010416185237.D16@harmony.cs.rit.edu> Message-ID: <5.0.2.1.0.20010416192831.01f13fc8@Pop3.norton.antivirus> At 04:27 PM 4/16/2001 -0700, you wrote: >I really think my older statement really was spot-on: "Java is Cobol 2.0." Ouch!! I'm no great lover of Java, but man, that even hurts MY feelings. :-) As a recovering Accounting PhD student who has always been interested in Computers (I'm leaving the Accounting PhD program to start work on a Comp Sci BS in the fall) , someone's always trying to talk to be about COBOL. Puh-Leaze!! Didn't we learn anything from Y2K? My research area was Accounting Info Systems, and when people found that out, too many of them wanted to dazzle me with the fact that they'd heard of COBOL, not knowing that it was like telling a neurosurgeon that they knew what leeches were... Ok, maybe that's a bit extreme, but I think you get my drift. "Java is Cobol 2.0." I may have to use that Deirdre. I've already used your sig about "deadlines swooshing by" in a conversation You (and Douglas Adams)were cited, or course. :-) **************************** Kojo Idrissa kojo@hal-pc.org **************************** From van@lindbergs.org Tue Apr 17 02:15:58 2001 From: van@lindbergs.org (VanL) Date: Mon, 16 Apr 2001 19:15:58 -0600 Subject: [Tutor] Python and Speed References: <1CDB101F0CB6D311882F0000F8063924033A786A@aquarius.bne.star.com.au> <20010416184816.C16@harmony.cs.rit.edu> Message-ID: <3ADB994E.A608D978@lindbergs.org> > D-Man said: > I think that this is a 'defect' in your benchmark. I have seen > several examples of perl (or other) programmers on c.l.py saying that > Python is horribly slow in comparison to the other language. > > Then the gurus on c.l.py reworked their python code using more > pythonic idioms and data structures and the speed became comparable. > I think that for the benchmark to be "better" (by some definition of > better <wink>) the most natural approach (algorithm, data structures) > for each language must be used, even those approaches are almost > certainly quite different. > > ...... > | Finally, I would like this to provide the catalyst for the Perl and > | Python communities to each agree on a set of common tasks which we could use > | for benchmark testing each new release of these interpreters. I know that > | Guido has never denied that Python is slower, but I'd like to be able to > | quantify it against something a little less trivial than my own manufactured > | example. I would be very interested in this sort of test. You mention that using identical data structures would be detrimental to the integrity of the test -- definately so. What about a standard set of tasks, running the gamut from system administration tasks to database to algorithms and scientific computing. May the best implementation in each language win. Then a weighted average of all the scores could determine (both within task groups, and overall) a "fastest" language. Moreover, if the set of tests were broad enough, the temptation for the language writers to "write to the test" would be diminished, in favor of better overall efficiency. Scores could be weighted, for example, to count consistent scores more heavily. I think this sort of idea would be interesting for another reason, as well: the scripts themselves would be very instructive for aspiring programmers as a example "best" implementation of a particular task. Hmmmm..... From sheila@thinkspot.net Tue Apr 17 02:59:25 2001 From: sheila@thinkspot.net (Sheila King) Date: Mon, 16 Apr 2001 18:59:25 -0700 Subject: [Tutor] Python and Speed In-Reply-To: <3ADB994E.A608D978@lindbergs.org> References: <1CDB101F0CB6D311882F0000F8063924033A786A@aquarius.bne.star.com.au> <20010416184816.C16@harmony.cs.rit.edu> <3ADB994E.A608D978@lindbergs.org> Message-ID: <6487B72077@kserver.org> On Mon, 16 Apr 2001 19:15:58 -0600, VanL <van@lindbergs.org> wrote about Re: [Tutor] Python and Speed: :I think this sort of idea would be interesting for another reason, as well: the :scripts themselves would be very instructive for aspiring programmers as a example :"best" implementation of a particular task. : :Hmmmm..... This is a good point, as well. I'm restricted in my available time, but I'm the one who started this whole thing (at least on this Tutor list), and I'm willing to do organizational type stuff, and put up a web page with results and all of the code afterwards. I'm also willing to help write code, but as a Python newbie, don't know how helpful that will be. Maybe I could write code for one or two of the suggested tests, and then post it for critiquing. Should we take this off-list to some other forum/discussion area? I'm afraid it may not be on-topic for this list. I'm willing to host a temporary mailing list, for the duration of such a project. If enough people respond, indicating interest, I'll start working on this, and try to drum up some Perl programmers to write the other code. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From alan.gauld@bt.com Tue Apr 17 17:10:29 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 17 Apr 2001 17:10:29 +0100 Subject: [Tutor] Python and Speed Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D6FC@mbtlipnt02.btlabs.bt.co.uk> > :I think this sort of idea would be interesting for another > reason, as well: the :scripts themselves would be > very instructive for aspiring programmers as a example > :"best" implementation of a particular task. I'm not sure that's true. The problem with these kinds of tasks is that the rapidly degenerate to a performance fine tuning exercise. Finely tuned code is rarely typical of what you write day to day, nor is it usually very maintainable. So proving that "tweaked till it squeaks" Python is as fast as "tweaked till it squeaks" Perl just doesn't say a lot about day to day tasks. Maybe a better idea is to point to the production code that is written in each language - Majordomo vv Mailman for example. Zope vv ??? A fastCGI site using modPerl and one using modPython. Or compare both top Java - in most cases either Perl or Python will be faster than Java on a JVM! FWIW THe Ruby web site carries a comment somewhere that their code falls about midway between Perl and Python in speed, but retains the readability of Python. Alan G. From bobhicks@adelphia.net Tue Apr 17 17:41:16 2001 From: bobhicks@adelphia.net (Robert Hicks) Date: Tue, 17 Apr 2001 12:41:16 -0400 Subject: [Tutor] Python and Speed In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D6FC@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <E14pYY0-00009U-00@mail.python.org> > FWIW THe Ruby web site carries a comment somewhere that > their code falls about midway between Perl and Python > in speed, but retains the readability of Python. Personally, I would say the Ruby site is wrong. Ruby is NOT a readable as Python for a newbie. I looked into it as an Admin that wanted to bridge the gap. From Ruby Central FAQ: "Ruby's syntax and design philosophy are heavily influenced by Perl." "If you like Perl, you will like Ruby and be right at home with its syntax." "Ruby is much more complex than Python but its features, for the most part, hang together well." From van@lindbergs.org Tue Apr 17 18:00:02 2001 From: van@lindbergs.org (Van Edward Lindberg) Date: Tue, 17 Apr 2001 11:00:02 -0600 Subject: [Tutor] Ruby v. Python? Message-ID: <3ADC7692.49FE734E@lindbergs.org> Sorry if this is slilghtly OT... I just read the Ruby send-up on slashdot. I checked out the Ruby website, it looks all right. Someone made the comment that Ruby looks like the mythical April Fool's Day "Parrot" language. From an initial perusal, that appears to be so. Has anyone had any direct experience with Ruby? How does it compare v. Python? VanL From st_hickey@hotmail.com Wed Apr 18 09:22:19 2001 From: st_hickey@hotmail.com (Stevenson Hickey) Date: Wed, 18 Apr 2001 01:22:19 -0700 Subject: [Tutor] Win98 appears as NT Message-ID: <OE49ZPWv1QJ2NX1bR1O0000443a@hotmail.com> This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C0C7A6.038329C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable There are certain inconsistencies that I have come across in running = Py21.b. I don't know if these are in earlier versions. Apparently my Windows 98 system is identified by Python as an 'NT' = system. Below is some of the data: import sys >>> print sys.builtin_module_names ('__builtin__', '__main__', '_codecs', '_locale', '_weakref', 'array', = 'audioop', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'errno', = 'exceptions', 'gc', 'imageop', 'imp', 'marshal', 'math', 'md5', = 'msvcrt', 'new', 'nt', 'operator', 'pcre', 'regex', 'rgbimg', 'rotor', = 'sha', 'signal', 'strop', 'struct', 'sys', 'thread', 'time', = 'xreadlines') (notice that 'nt' appears, but not 'dos') I also got this: >>> os.path.__name__ 'ntpath' And also: >>> os.path <module 'ntpath' from 'c:\python21\lib\ntpath.pyc'> (I do have a dospath.py file in my library.) In the Faqw of 1998, it says: "There are (at least) three kinds of = modules in Python: 1) modules written in Python (.py); 2) modules = written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc); 3) = modules written in C and linked with the interpreter; to get a list of = these, type:=20 import sys print sys.builtin_module_names" This came about when I was investigating os.py in relationship to the = os.path.walk method. =20 Any clues as to why my system seems to be referred to as 'nt'? Is it possible that I made some mistake upon installation of py21? If = so, where would I look to make changes? Stevenson Hickey --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.248 / Virus Database: 121 - Release Date: 4/11/2001 ------=_NextPart_000_0007_01C0C7A6.038329C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV>There are certain inconsistencies that I have come across in = running=20 Py21.b. I don't know if these are in earlier versions.</DIV> <DIV> </DIV> <DIV>Apparently my Windows 98 system is identified by Python as an 'NT'=20 system. Below is some of the data:</DIV> <DIV> </DIV> <DIV>import sys<BR>>>> print=20 sys.builtin_module_names<BR>('__builtin__', '__main__', '_codecs', = '_locale',=20 '_weakref', 'array', 'audioop', 'binascii', 'cPickle', 'cStringIO', = 'cmath',=20 'errno', 'exceptions', 'gc', 'imageop', 'imp', 'marshal', 'math', 'md5', = 'msvcrt', 'new', 'nt', 'operator', 'pcre', 'regex', 'rgbimg', 'rotor', = 'sha',=20 'signal', 'strop', 'struct', 'sys', 'thread', 'time', = 'xreadlines')</DIV> <DIV><BR>(notice that 'nt' appears, but not 'dos')</DIV> <DIV> </DIV> <DIV>I also got this:</DIV> <DIV> </DIV> <DIV>>>> os.path.__name__<BR>'ntpath'</DIV> <DIV> </DIV> <DIV>And also:</DIV> <DIV> </DIV> <DIV>>>> os.path<BR><module 'ntpath' from=20 'c:\python21\lib\ntpath.pyc'></DIV> <DIV> </DIV> <DIV>(I do have a dospath.py file in my library.)</DIV> <DIV> </DIV> <DIV>In the Faqw of 1998, it says: "There are (at least) three kinds of = modules=20 in Python: 1) modules written in Python (.py); 2) modules written in C = and=20 dynamically loaded (.dll, .pyd, .so, .sl, etc); 3) modules written in C = and=20 linked with the interpreter; to get a list of these, type:=20 <BR> import sys<BR> print=20 sys.builtin_module_names"</DIV> <DIV> </DIV> <DIV>This came about when I was investigating os.py in relationship to = the=20 os.path.walk method. </DIV> <DIV> </DIV> <DIV>Any clues as to why my system seems to be referred to as = 'nt'?</DIV> <DIV> </DIV> <DIV>Is it possible that I made some mistake upon installation of = py21? If=20 so, where would I look to make changes?</DIV> <DIV> </DIV> <DIV>Stevenson Hickey</DIV> <DIV> </DIV> <DIV><BR>---<BR>Outgoing mail is certified Virus Free.<BR>Checked by AVG = anti-virus system (<A=20 href=3D"http://www.grisoft.com">http://www.grisoft.com</A>).<BR>Version: = 6.0.248 /=20 Virus Database: 121 - Release Date: 4/11/2001</DIV></BODY></HTML> ------=_NextPart_000_0007_01C0C7A6.038329C0-- From wong_chow_cheok@hotmail.com Wed Apr 18 10:31:19 2001 From: wong_chow_cheok@hotmail.com (wong chow cheok) Date: Wed, 18 Apr 2001 17:31:19 +0800 Subject: [Tutor] (no subject) Message-ID: <F1123SBQURyIKeqA1Uz0000c394@hotmail.com> hello ya all. i have a problem again. still trying to extract url from the web. but now i need to extract multiple url and not just one. i ahve tried using findall() but all i get is the 'http' and nothing else. http_url=r''' (http|https|ftp|wais|telnet|mailto|gopher|file) : [\w.#@&=\,-_~/;:\n]+ (?=([,.:;\-?!\s])) ''' http_re=re.compile(http_url, re.X) p=http_re.findall("http:\\www.hotmial.com abnd http:\\www.my.com") print p this was very helpful and very confusing. after reading more on it i am only more confused with all the simbols. (?=...) what does this mean. i read it up but still am having trouble using it and underdtanding how it works. and i still cannot extract more than one url. tried many other ways but this is the only one with a bit of progress(the 'http') well sorry for being so muxh trouble but your help is appreciated. thank you _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From tim.one@home.com Wed Apr 18 11:10:55 2001 From: tim.one@home.com (Tim Peters) Date: Wed, 18 Apr 2001 06:10:55 -0400 Subject: [Tutor] Win98 appears as NT In-Reply-To: <OE49ZPWv1QJ2NX1bR1O0000443a@hotmail.com> Message-ID: <LNBBLJKPBEHFEDALKOLCAEPKJMAA.tim.one@home.com> [Stevenson Hickey] > There are certain inconsistencies that I have come across in running > Py21.b. I don't know if these are in earlier versions. > > Apparently my Windows 98 system is identified by Python as an 'NT' > system. Below is some of the data: Na, if you do >>> import sys >>> sys.platform I bet it displays 'win32' And it should do that on Win95, Win98, ME, NT, *and* Win2000. The sys.nt module you're seeing is an internal implementation detail. You should never import it directly! The os module (which you should import instead) tries to provide (as far as possible) the same functions across operating systems, and it's an internal implementation detail that, on Win32 systems, the os module happens to be largely *implemented*, under the covers, by a module named "nt". Under other operating systems the os module is implemented by modules with names other than nt. It would have been better had the nt module been named, say, win32 instead -- but it wasn't, and it's too late to change now. Don't get discouraged by it! This is a very hairy part of the implementation, because cross-platform portability is difficult for us to provide, and the details are both complicated and not at all worth *your* time to learn. > ... > I also got this: > > >>> os.path.__name__ > 'ntpath' > > And also: > > >>> os.path > <module 'ntpath' from 'c:\python21\lib\ntpath.pyc'> Sure. Those are expected on all Win32 platforms -- you're just confusing yourself by looking at stuff nobody else ever looks at <wink>. > (I do have a dospath.py file in my library.) And if you were running a pure DOS (*not* Windows!) system, os.path would be implemented via dospath.py instead. > Is it possible that I made some mistake upon installation of py21? I don't think it's possible for you to make a mistake when running the installer we ship <wink>. click-on-'next'-until-it-stops-ly y'rs - tim From alan.gauld@bt.com Wed Apr 18 18:29:10 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 18 Apr 2001 18:29:10 +0100 Subject: [Tutor] Python and Speed Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D703@mbtlipnt02.btlabs.bt.co.uk> > > their code falls about midway between Perl and Python > > in speed, but retains the readability of Python. > Personally, I would say the Ruby site is wrong. Ruby is NOT a > readable as Python for a newbie. Its not far off. I'd I looked into it as an Admin that wanted to > bridge the gap. > > From Ruby Central FAQ: > > "Ruby's syntax and design philosophy are heavily influenced by Perl." > "If you like Perl, you will like Ruby and be right at home with its > syntax." > "Ruby is much more complex than Python but its features, for the most > part, hang together well." > > From alan.gauld@bt.com Wed Apr 18 18:39:49 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 18 Apr 2001 18:39:49 +0100 Subject: [Tutor] Python and Speed Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D704@mbtlipnt02.btlabs.bt.co.uk> Sorry for the false send, I'll try again :-( > > their code falls about midway between Perl and Python > > in speed, but retains the readability of Python. > > Personally, I would say the Ruby site is wrong. Ruby is NOT a > readable as Python for a newbie. I don't think it's far off. Ruby is certainly much closer to Python than it is to Perl syntactically - despite the comments you cited. I think those are designed to attract Perl programmers! What Ruby does have is, like Perl, builtin regular expressions. That makes most regex activities noticably faster than Python. Otherwise I don't honestly see any difference in general programming between Ruby and Python. I do find Perl is usually slightly faster than either, but only a few percent. Certainly not the hundreds of percent claimed by the Perl zealots. > "Ruby's syntax and design philosophy are heavily > influenced by Perl." I don't understand this comment, other than as sales pitch. Ruby is readable, Perl isn't. In fact about the only Perl like syntax I've seen is the addition of '@' in front of instance variables class Foo def initialize(i) .... @var = i end ... end f = Foo.new(42) Doesn't look much like Perl to me! In fact it looks rather a lot like Python... :-) > "Ruby is much more complex than Python but its > features, for the most part, hang together well." It has a more complete and consistent object model but otherwise I wouldn't say it was much more "complex". Alan g From alan.gauld@bt.com Wed Apr 18 18:44:00 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 18 Apr 2001 18:44:00 +0100 Subject: [Tutor] Ruby v. Python? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D705@mbtlipnt02.btlabs.bt.co.uk> > Has anyone had any direct experience with Ruby? How does it > compare v. Python? See my previous post. My editor wanted me to do a version of my book in Ruby so I downloaded it and had a play. Theres a big potential market for Ruby books but I decided that Ruby just takes the OOP concept too far to make it suitable as a first language. You can't do hardly anything in Ruby without running into objects, and to try to explain those without any prior knowledge is too hard for a simple soul like me! But as a general purpose scripting language it has promise. If I hadn't already seen Python I would probably be a Ruby programmer by now... I'll probably continue playing with it for a while yet. Its infinitely better than perl! Alan G. From bobhicks@adelphia.net Wed Apr 18 18:53:05 2001 From: bobhicks@adelphia.net (Robert Hicks) Date: Wed, 18 Apr 2001 13:53:05 -0400 Subject: [Tutor] Python and Speed In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D704@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <E14pw98-0005pZ-00@mail.python.org> Well if I had to choose between Ruby and Perl...I would take Ruby for readability. Python is the first VHL that I can look at the code and say "hey, I know where that is going". Hmmm...maybe I could write "Learn to program using Ruby".... : ) Just kidding! I use the language I like...Python. - Bob - the comments quoted about Ruby were from a Ruby site...not my opinion. From shaleh@valinux.com Wed Apr 18 18:58:42 2001 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Wed, 18 Apr 2001 10:58:42 -0700 (PDT) Subject: [Tutor] flatten a tuple Message-ID: <XFMail.20010418105842.shaleh@valinux.com> So I have a tuple: ((0, 1, 2), (3,4,5), (6,7,8)) and I want to get: (6,7,8,3,4,5,0,1,2) i.e. reverse the container, then get the contents in order. The tuple in question happens to be a 3x3, but this need not affect the answer. From alan.gauld@bt.com Wed Apr 18 18:53:43 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 18 Apr 2001 18:53:43 +0100 Subject: [Tutor] (no subject) Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D706@mbtlipnt02.btlabs.bt.co.uk> > more confused with all the simbols. (?=...) what does this > mean. Its a regular expression. There are several web sites that explain how they work. The one you have is a fairly complex one but the principles are straightforward. If you can, goo to informIT.com (you';ll need to register), and do a searchh for my name and you should find an article on regular expressions that explains their use. [ Or you could buy my book which contains the same info in a chapter :-) ] > the only one with a bit of progress(the 'http') Not sure but the fact you used \\ instead of // after the http might have confused things? Alan G. From scarblac@pino.selwerd.nl Wed Apr 18 19:11:11 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 18 Apr 2001 20:11:11 +0200 Subject: [Tutor] flatten a tuple In-Reply-To: <XFMail.20010418105842.shaleh@valinux.com>; from shaleh@valinux.com on Wed, Apr 18, 2001 at 10:58:42AM -0700 References: <XFMail.20010418105842.shaleh@valinux.com> Message-ID: <20010418201111.A22891@pino.selwerd.nl> On 0, Sean 'Shaleh' Perry <shaleh@valinux.com> wrote: > So I have a tuple: > > ((0, 1, 2), (3,4,5), (6,7,8)) > > and I want to get: > > (6,7,8,3,4,5,0,1,2) > > i.e. reverse the container, then get the contents in order. > > The tuple in question happens to be a 3x3, but this need not affect the answer. In general it's easier to convert tuples to lists for this sort of thing, then convert them back at the end. That's because it's easier to build things if they're mutable. def flatten_reverse_tuple(tuples_tuple): result = [] tuples_list = list(tuples_tuple) tuples_list.reverse() for tup in tuples_list: result.extend(tup) return tuple(result) It doesn't completely flatten it, so that you won't get a big flat tuple if you have a tuple of tuples of tuples (I love saying that) but you didn't define what should happen in that case anyway. -- Remco Gerlich From deirdre@deirdre.net Wed Apr 18 19:13:22 2001 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 18 Apr 2001 11:13:22 -0700 (PDT) Subject: [Tutor] flatten a tuple In-Reply-To: <XFMail.20010418105842.shaleh@valinux.com> Message-ID: <Pine.LNX.4.31.0104181103110.6659-100000@emperor.deirdre.org> On Wed, 18 Apr 2001, Sean 'Shaleh' Perry wrote: > So I have a tuple: > > ((0, 1, 2), (3,4,5), (6,7,8)) > > and I want to get: > > (6,7,8,3,4,5,0,1,2) > > i.e. reverse the container, then get the contents in order. > > The tuple in question happens to be a 3x3, but this need not affect the answer. Well, tuples being immutable, use an intermediary list. I was in the middle of typing a longer answer, but Remco's clearly more awake than I am.... -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From shaleh@valinux.com Wed Apr 18 19:25:13 2001 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Wed, 18 Apr 2001 11:25:13 -0700 (PDT) Subject: [Tutor] flatten a tuple In-Reply-To: <20010418201111.A22891@pino.selwerd.nl> Message-ID: <XFMail.20010418112513.shaleh@valinux.com> > > In general it's easier to convert tuples to lists for this sort of thing, > then convert them back at the end. That's because it's easier to build > things if they're mutable. > > def flatten_reverse_tuple(tuples_tuple): > result = [] > tuples_list = list(tuples_tuple) > tuples_list.reverse() > for tup in tuples_list: > result.extend(tup) > return tuple(result) > > It doesn't completely flatten it, so that you won't get a big flat tuple if > you have a tuple of tuples of tuples (I love saying that) but you didn't > define what should happen in that case anyway. > hmm, so much list conversion )-: guess I will store them as lists. BTW, list.extend() requires a list too, so it should have been result.extend(list(tup)). From scarblac@pino.selwerd.nl Wed Apr 18 19:35:35 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Wed, 18 Apr 2001 20:35:35 +0200 Subject: [Tutor] flatten a tuple In-Reply-To: <XFMail.20010418112513.shaleh@valinux.com>; from shaleh@valinux.com on Wed, Apr 18, 2001 at 11:25:13AM -0700 References: <20010418201111.A22891@pino.selwerd.nl> <XFMail.20010418112513.shaleh@valinux.com> Message-ID: <20010418203535.A22934@pino.selwerd.nl> On 0, Sean 'Shaleh' Perry <shaleh@valinux.com> wrote: > BTW, list.extend() requires a list too, so it should have been > result.extend(list(tup)). It can take a sequence, I tested that. >>> x=[] >>> x.extend((1,2,3)) >>> x [1, 2, 3] Hmm. Grumble. Writing *this* post, I dug into the actual docs. http://www.python.org/doc/current/lib/typesseq-mutable.html s.extend(x) Same as s[len(s):len(s)] = x (2) (2) Raises an exception when x is not a list object. The extend() method is experimental and not supported by mutable sequence types other than lists. Well, it does not raise an exception when used with a tuple! But since the lib ref says it's illegal, it may disappear at any point :-(. I *hate* things that work although it is by accident. When you're coding Python and suspect that something works, you're going to test it in the interpreter. You're not going to dig into the references :-(. And s[len(s):len(s)] = x does give the exception. Ah well. Just another reason to use lists in the first place :-). -- Remco Gerlich From arcege@speakeasy.net Wed Apr 18 19:36:19 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Wed, 18 Apr 2001 14:36:19 -0400 (EDT) Subject: [Tutor] flatten a tuple In-Reply-To: <XFMail.20010418105842.shaleh@valinux.com> from "Sean 'Shaleh' Perry" at Apr 18, 2001 10:58:42 AM Message-ID: <200104181836.f3IIaJ101424@dsl254-114-246.nyc1.dsl.speakeasy.net> Sean 'Shaleh' Perry wrote > > So I have a tuple: > > ((0, 1, 2), (3,4,5), (6,7,8)) > > and I want to get: > > (6,7,8,3,4,5,0,1,2) > > i.e. reverse the container, then get the contents in order. > > The tuple in question happens to be a 3x3, but this need not affect the answer. How about: def reverse_flatten(a): if not a: return () # force to a tuple, just to make sure return tuple(a[-1]) + reverse_flatten(a[:-1]) The function will take any sequence and return a tuple. It will not completely flatten the given sequence, just the top level. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From dsh8290@rit.edu Wed Apr 18 19:39:42 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 18 Apr 2001 14:39:42 -0400 Subject: [Tutor] flatten a tuple In-Reply-To: <XFMail.20010418105842.shaleh@valinux.com>; from shaleh@valinux.com on Wed, Apr 18, 2001 at 10:58:42AM -0700 References: <XFMail.20010418105842.shaleh@valinux.com> Message-ID: <20010418143942.A17879@harmony.cs.rit.edu> On Wed, Apr 18, 2001 at 10:58:42AM -0700, Sean 'Shaleh' Perry wrote: | So I have a tuple: | | ((0, 1, 2), (3,4,5), (6,7,8)) | | and I want to get: | | (6,7,8,3,4,5,0,1,2) | | i.e. reverse the container, then get the contents in order. | | The tuple in question happens to be a 3x3, but this need not affect | the answer. Reversing is easy : def reverse_tuple( t ) : l = list( t ) l.reverse() return tuple( l ) maybe you could save (execution) time and leave it as a list? import types def flatten( coll ) : """ Take a linear collection (currently only handles tuple and list properly) and return a tuple containing all the elements. Any sub-tuple/list will be "flattened". """ # the result, as a list res_l = [] for item in col : # here is where Lisp is a bit better, or the new adapter stuff # would be _really_ useful # # # If the item is a list/tuple, recursively flatten it, then # add all that stuff to the result list. # # Otherwise it is an "atom" (see Lisp for a definition), # append it to the result list. # if type( item ) == types.ListType or type( item ) == types.TupleType : res_l.extend( flatten( item ) ) else : res_l.append( item ) return tuple( res_l ) print flatten( reverse( ((0, 1, 2), (3,4,5), (6,7,8)) ) ) Double check, then thoroughly test this :-). -D From shaleh@valinux.com Wed Apr 18 21:21:37 2001 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Wed, 18 Apr 2001 13:21:37 -0700 (PDT) Subject: [Tutor] flatten a tuple In-Reply-To: <20010418203535.A22934@pino.selwerd.nl> Message-ID: <XFMail.20010418132137.shaleh@valinux.com> On 18-Apr-2001 Remco Gerlich wrote: > On 0, Sean 'Shaleh' Perry <shaleh@valinux.com> wrote: >> BTW, list.extend() requires a list too, so it should have been >> result.extend(list(tup)). > > It can take a sequence, I tested that. > >>>> x=[] >>>> x.extend((1,2,3)) >>>> x > [1, 2, 3] > > Hmm. Grumble. Writing *this* post, I dug into the actual docs. > http://www.python.org/doc/current/lib/typesseq-mutable.html > > s.extend(x) Same as s[len(s):len(s)] = x (2) > > (2) Raises an exception when x is not a list object. The extend() method is > experimental and not supported by mutable sequence types other than > lists. > > Well, it does not raise an exception when used with a tuple! But since the > lib ref says it's illegal, it may disappear at any point :-(. > it did raise an exception under 1.5.2. From Hans.Beernink@UCHSC.edu Wed Apr 18 21:58:03 2001 From: Hans.Beernink@UCHSC.edu (Hans.Beernink@UCHSC.edu) Date: Wed, 18 Apr 2001 14:58:03 -0600 Subject: [Tutor] python on OS-X Message-ID: <B0B3F220BEB8D311949700805FA7797F71503C@ex1.UCHSC.EDU> has anyone successfully compiled py2.1 on MacOS-X? and while we're on the topic, why didnt python come preinstalled like pearl/java/tcl/etc.etc.etc.???? seems like some lobbying needs to be done with apple! thanks, htb ___________________________________________ Hans T.H. Beernink, Ph.D. Department of Biochemistry and Molecular Genetics University of Colorado Health Science Center 4200 E. 9th Ave Campus Box B121 Denver CO 80262 tel. 303.315.7547 FAX 303.315.8215 Hans.Beernink@UCHSC.edu From dyoo@hkn.eecs.berkeley.edu Wed Apr 18 22:34:21 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 18 Apr 2001 14:34:21 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <F1123SBQURyIKeqA1Uz0000c394@hotmail.com> Message-ID: <Pine.LNX.4.21.0104181402550.5265-100000@hkn.eecs.berkeley.edu> On Wed, 18 Apr 2001, wong chow cheok wrote: > hello ya all. i have a problem again. still trying to extract url from the > web. but now i need to extract multiple url and not just one. i ahve tried > using findall() but all i get is the 'http' and nothing else. Hmm... I have to take a look at the findall() documentation... (http://python.org/doc/current/lib/Contents_of_Module_re.html) "findall(pattern, string) Return a list of all non-overlapping matches of pattern in string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result." Ah, ok. What they mean by "group" is anything surrounded by parentheses. In regular expressions, a pair of parentheses form a group that can be treated as a single thing. If we look at the regular expression, we can see that there's parentheses around the "http|https|ftp|..." stuff. findall() is a bit sensitive towards groups: if it sees them, it will think that the groups are all we are interested it, which explains why we're getting only the "http" part of an url. We'll need to put the whole url regular expression in one large group, to get findall() to work properly: ### http_url=r''' ( (http|https|ftp|wais|telnet|mailto|gopher|file) : [\w.#@&=\,-_~/;:\n]+ ) (?=([,.:;\-?!\s])) ''' ### Just to clarify: the url above has three groups: the first is the one that encloses the whole regular expression. The second surrounds all the protocol types (http/https...). Finally, the last is called the lookahead group, which I'll have to skip: I need to think about it a little more. (Also, there's some bugs in the regular expression itself that doesn't let it find urls perfectly... whoops!) Let's see if this sorta works: ### >>> http_re.findall("http://www.hotmail.com abnd http://www.my.com") [('http://www.hotmail.com', 'http', ' '), ('http://www.my', 'http', '.')] ### So it almost works, but there's bugs in the regular expression that need to be fixed. I'm not quite as certain that the lookahead (?=...) is doing the right thing; I'll need to look at it later. > this was very helpful and very confusing. after reading more on it i am only > more confused with all the simbols. (?=...) what does this mean. i read it Regular expressions are meant to be useful for computers --- they're not really meant for humans, so don't worry if the symbols are confusing: they take a bit of practice to figure out what's happening. OReilly publishes a book called "Mastering Regular Expressions" which I've heard is really good if you're trying to learn regular expressions. Take a look to see if it's useful for you. Good luck! From dyoo@hkn.eecs.berkeley.edu Wed Apr 18 22:51:37 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 18 Apr 2001 14:51:37 -0700 (PDT) Subject: [Tutor] flatten a tuple In-Reply-To: <XFMail.20010418105842.shaleh@valinux.com> Message-ID: <Pine.LNX.4.21.0104181437160.5265-100000@hkn.eecs.berkeley.edu> On Wed, 18 Apr 2001, Sean 'Shaleh' Perry wrote: > So I have a tuple: > > ((0, 1, 2), (3,4,5), (6,7,8)) > > and I want to get: > > (6,7,8,3,4,5,0,1,2) > > i.e. reverse the container, then get the contents in order. Reversal isn't too bad; I think that flattening is the more interesting problem. One way to do this flattening is with a recursive definition: To flatten a thing: 1. Trying to flatten a non-tuple should return that thing in a flat tuple. For example, flatten(42) should give us the tuple (42,). If we're at this point, the thing must be a tuple: 2. If the tuple's empty, let's return it without any changes. That is, flatten(()) should return (). 3. Otherwise, let's flatten the first element of the tuple, and concatenate it with the flattening of the rest of the tuple. What we get back should be altogether flattened. ### >>> def isTuple(x): return type(x) == types.TupleType ... >>> def flatten(T): ... if not isTuple(T): return (T,) ... elif len(T) == 0: return () ... else: return flatten(T[0]) + flatten(T[1:]) ... >>> flatten( ((0, 1, 2), (3, 4, 5), (6, 7, 8)) ) (0, 1, 2, 3, 4, 5, 6, 7, 8) ### What's nice is that the flattening is "deep", that is, it can handle any amount of nesting: >>> flatten( ( ((0,), (1, 2)), (3, (((4,))), 5), (6, 7, 8) ) ) (0, 1, 2, 3, 4, 5, 6, 7, 8) Hope this helps! From dyoo@hkn.eecs.berkeley.edu Wed Apr 18 23:01:11 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 18 Apr 2001 15:01:11 -0700 (PDT) Subject: [Tutor] python on OS-X In-Reply-To: <B0B3F220BEB8D311949700805FA7797F71503C@ex1.UCHSC.EDU> Message-ID: <Pine.LNX.4.21.0104181452550.5265-100000@hkn.eecs.berkeley.edu> On Wed, 18 Apr 2001 Hans.Beernink@UCHSC.edu wrote: > has anyone successfully compiled py2.1 on MacOS-X? and while we're on the > topic, why didnt python come preinstalled like > pearl/java/tcl/etc.etc.etc.???? seems like some lobbying needs to be done > with apple! Ouch! You'll want to talk with the people who built Python. Try asking on comp.lang.python: I'm sure that someone there knows what's happening. About Python being preinstalled with MacOS-X... um... good point. *grin* According to the documentation, they're working at it: http://python.sourceforge.net/devel-docs/mac/node23.html Give it a few days: Python 2.1 just came out on Tuesday, and the implementors are probably still a little dizzy. If you're looking for any version of Python 2.x for Mac OS X, here's one for 2.0: http://tony.lownds.com/macosx/ and on Jack's MacPython page, they have a prebuilt Python 2.1 beta: http://www.cwi.nl/~jack/macpython.html Good luck to you. From arthur.watts@gbst.com Thu Apr 19 00:31:13 2001 From: arthur.watts@gbst.com (Arthur Watts) Date: Thu, 19 Apr 2001 09:31:13 +1000 Subject: [Tutor] Python as a superior teaching language Message-ID: <1CDB101F0CB6D311882F0000F8063924033A7897@aquarius.bne.star.com.au> Guys, One of our developers had me build the GNU readline library, then 'activate' the module for Python 2.0 on our Alpha. I initially thought that being able to scroll thru one's command history in the interative interpreter was pretty good, but that's nothing compared to the info he just sent me : Here's some of the cool stuff you can do with Readline in Python. As well as providing a command history, the Readline module allows you to do auto-completion. This can be very handy when you are just learning the language and/or its objects. (NOTE Readline is installed on Taurus, but is not yet on Jupiter). Run the following lines when you run the Python Interactive Shell (or better still, put them in your $PYTHONSTARTUP program) >>> import rlcompleter >>> import readline >>> readline.parse_and_bind("tab: complete") And you now have AutoCompleting on. To use it, type part of a variable and press "<TAB>". If there is only one variable matching, it will be filled in automatically, as in >>> readline.i<TAB> Line will become >>> readline.insert_text because the readline module on has one attribute beginning with the letter 'i'. If there are more than one, nothing will happen after the first <TAB>. Press <TAB> again to see a list of variables that match, as in >>> import sys >>> sys.<TAB><TAB> sys.__doc__ sys.exec_prefix sys.ps1 sys.__name__ sys.executable sys.ps2 sys.__stderr__ sys.exit sys.setcheckinterval sys.__stdin__ sys.exitfunc sys.setprofile sys.__stdout__ sys.getdefaultencoding sys.setrecursionlimit sys.argv sys.getrecursionlimit sys.settrace sys.builtin_module_names sys.getrefcount sys.stderr sys.byteorder sys.hexversion sys.stdin sys.copyright sys.maxint sys.stdout sys.exc_info sys.modules sys.version sys.exc_traceback sys.path sys.version_info sys.exc_type sys.platform sys.exc_value sys.prefix gem> sys. Very handy if you don't know what methods/attributes are available (or how to spell them). Like I said earlier, the main purpose of Readline is to provide a command-line history. By default, it is emacs style. Use your arrow keys to go through your previous commands. I however, prefer the 'vi' style line editing. To do this, put a '.inputrc' file in your home directory with the following line set editing-mode vi Now you can use all your 'vi' commands (<ESC-K>, search with '/", etc). Also, if you want to save your command history between sessions, get Python to save it to file when you exit and re-reading it when you go back in. Here's my complete $PYTHONSTARTUP script (That is, I have written this to '/u/stephenb/python.py' and pointed the PYTHONSTARTUP Shell variable to it) try: import readline except ImportError: pass else: import rlcompleter import os import atexit # Allow auto-complete stuff readline.parse_and_bind("tab: complete") # Save the history file for next session histfile = os.path.join(os.environ["HOME"], ".pyhist") try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) # Cleanup del os, histfile, readline, atexit, rlcompleter I know that many commercial IDE's contain handy online references, but I find this particularly valuable when you want to work your way thru a module's namespace to find what you need. Enjoy, Arthur Arthur Watts Software Engineer GBST Automation Global Banking & Securities Transactions Telephone + 61 7 3331 5555 mailto: arthur.watts@gbst.com www.gbst.com From sheila@thinkspot.net Thu Apr 19 01:00:17 2001 From: sheila@thinkspot.net (Sheila King) Date: Wed, 18 Apr 2001 17:00:17 -0700 Subject: [Tutor] Python as a superior teaching language In-Reply-To: <1CDB101F0CB6D311882F0000F8063924033A7897@aquarius.bne.star.com.au> References: <1CDB101F0CB6D311882F0000F8063924033A7897@aquarius.bne.star.com.au> Message-ID: <135D3C5413F@kserver.org> On Thu, 19 Apr 2001 09:31:13 +1000, Arthur Watts <arthur.watts@gbst.com> wrote about [Tutor] Python as a superior teaching language: : I know that many commercial IDE's contain handy online references, :but I find this particularly valuable when you want to work your way thru a :module's namespace to find what you need. PythonWin has a popup scroll menu, that lists the modules namespace, and can autocomplete on a TAB. (For those on a Windows system...and PythonWin is free.) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From bobhicks@adelphia.net Thu Apr 19 02:37:32 2001 From: bobhicks@adelphia.net (Robert Hicks) Date: Wed, 18 Apr 2001 21:37:32 -0400 Subject: [Tutor] PYTHON ON OSX Message-ID: <E14q3OX-0001Xf-00@mail.python.org> http://www.zope.org/Members/jshell/ZopeOnOSX This pretty much explains it all. I did NOT have to do the FCNTL I DID have to edit the Makefile I did NOT have to do "cp Python/python ./python.exe" - Bob From dyoo@hkn.eecs.berkeley.edu Thu Apr 19 03:46:50 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Wed, 18 Apr 2001 19:46:50 -0700 (PDT) Subject: [Tutor] PYTHON ON OSX In-Reply-To: <E14q3OX-0001Xf-00@mail.python.org> Message-ID: <Pine.LNX.4.21.0104181944110.14296-100000@hkn.eecs.berkeley.edu> On Wed, 18 Apr 2001, Robert Hicks wrote: > http://www.zope.org/Members/jshell/ZopeOnOSX > > This pretty much explains it all. > > I did NOT have to do the FCNTL > I DID have to edit the Makefile > I did NOT have to do "cp Python/python ./python.exe" Thanks for the info; there was a LOT of people asking about this on python-help as well. From NHYTRO@compuserve.com Thu Apr 19 07:04:01 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Thu, 19 Apr 2001 02:04:01 -0400 Subject: [Tutor] Client redirect? Message-ID: <200104190204_MC2-CCFC-995C@compuserve.com> Hello! I would like to use a CGI script to redirect a clients browser to a HTML page on the server, could someone tell me how I should accomplish this? I= did not find anything similar in the CGI module Best regards Sharriff From sheila@thinkspot.net Thu Apr 19 07:22:51 2001 From: sheila@thinkspot.net (Sheila King) Date: Wed, 18 Apr 2001 23:22:51 -0700 Subject: [Tutor] Client redirect? In-Reply-To: <200104190204_MC2-CCFC-995C@compuserve.com> References: <200104190204_MC2-CCFC-995C@compuserve.com> Message-ID: <290B82F7F44@kserver.org> On Thu, 19 Apr 2001 02:04:01 -0400, Sharriff Aina <NHYTRO@compuserve.com> wrote about [Tutor] Client redirect?: :Hello! : :I would like to use a CGI script to redirect a clients browser to a HTML :page on the server, could someone tell me how I should accomplish this? I :did not find anything similar in the CGI module The entire output of your script should be print "Location: http://www.yourdomain.com/redirect/URL.html\n\n" -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sburr@mac.com Thu Apr 19 08:07:53 2001 From: sburr@mac.com (Steven Burr) Date: Thu, 19 Apr 2001 00:07:53 -0700 Subject: [Tutor] PYTHON ON OSX In-Reply-To: <Pine.LNX.4.21.0104181944110.14296-100000@hkn.eecs.berkeley.edu> Message-ID: <20010419070729.MNKI26880.mail1.rdc1.az.home.com@localhost> On Wednesday, April 18, 2001, at 07:46 PM, Daniel Yoo wrote: > On Wed, 18 Apr 2001, Robert Hicks wrote: > >> http://www.zope.org/Members/jshell/ZopeOnOSX >> >> This pretty much explains it all. >> >> I did NOT have to do the FCNTL >> I DID have to edit the Makefile >> I did NOT have to do "cp Python/python ./python.exe" > > Thanks for the info; there was a LOT of people asking about this on > python-help as well. > I think the instructions on the Zope web site may be a bit dated. The Unix version of Python 2.1 now compiles "out of the box" on OS X. The README file in the Python-2.1/ directory that you get after untarring the tarball includes specific instructions for running the configure script in OS X. If you follow those instructions, you can do the usual make, make install routine afterwards. There's no longer any need to edit the Makefile manually. I just compiled and installed the final release this way, and it worked without a hitch. One caveat, OS X users may need to add /usr/local/bin, where the python binary is installed by default, to their paths. There's a lot more information on what people have been up to with python on OS X in the archives for the python-mac SIG. From NHYTRO@compuserve.com Thu Apr 19 13:22:47 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Thu, 19 Apr 2001 08:22:47 -0400 Subject: [Tutor] testing for "None" Message-ID: <200104190823_MC2-CCF3-4EAE@compuserve.com> Hi guys! ## code start ## templinks =3D [("aa,None,cc,dd")] # from databse links =3D string.split(templinks[0],",") for x in links: if x !=3D None: counter =3D counter + 1 print "<td>%d. </td>" %(counter) print "<td>", print x print """ </td> <td><input type=3D"button" onclick=3D"" value=3D"edit"</td> </tr> <tr> """ else: pass ## code end ## can someone tell me why this code fails? I=B4m trying to print values tha= t are not " None" From scarblac@pino.selwerd.nl Thu Apr 19 13:35:00 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 19 Apr 2001 14:35:00 +0200 Subject: [Tutor] testing for "None" In-Reply-To: <200104190823_MC2-CCF3-4EAE@compuserve.com>; from NHYTRO@compuserve.com on Thu, Apr 19, 2001 at 08:22:47AM -0400 References: <200104190823_MC2-CCF3-4EAE@compuserve.com> Message-ID: <20010419143500.A24074@pino.selwerd.nl> On 0, Sharriff Aina <NHYTRO@compuserve.com> wrote: > Hi guys! > > ## code start ## > templinks = [("aa,None,cc,dd")] # from databse > links = string.split(templinks[0],",") > for x in links: > if x != None: > counter = counter + 1 > print "<td>%d. </td>" %(counter) > print "<td>", > print x > print """ > </td> > <td><input type="button" onclick="" value="edit"</td> > </tr> > <tr> > """ > else: > pass > ## code end ## > > can someone tell me why this code fails? I´m trying to print values that > are not " None" None of the values are None, they're all strings - "aa", "None", "cc" and "dd". You should be testing for the string "None", not the object None (if x != "None": ...). -- Remco Gerlich From dsh8290@rit.edu Thu Apr 19 15:26:19 2001 From: dsh8290@rit.edu (D-Man) Date: Thu, 19 Apr 2001 10:26:19 -0400 Subject: [Tutor] Python as a superior teaching language In-Reply-To: <1CDB101F0CB6D311882F0000F8063924033A7897@aquarius.bne.star.com.au>; from arthur.watts@gbst.com on Thu, Apr 19, 2001 at 09:31:13AM +1000 References: <1CDB101F0CB6D311882F0000F8063924033A7897@aquarius.bne.star.com.au> Message-ID: <20010419102619.D28426@harmony.cs.rit.edu> On Thu, Apr 19, 2001 at 09:31:13AM +1000, Arthur Watts wrote: | Guys, | <readline stuff> | >>> import rlcompleter | >>> import readline | >>> readline.parse_and_bind("tab: complete") | | And you now have AutoCompleting on. To use it, type part of a variable and | press "<TAB>". If there is only one variable matching, it will be filled in | automatically, as in ... | provide a command-line history. By default, it is emacs style. Use your | arrow keys to go through your previous commands. I however, prefer the 'vi' | style line editing. To do this, put a '.inputrc' file in your home | directory with the following line | set editing-mode vi It is very cool. Thanks for sharing. It works with Python 2.1 under cygwin as well. Except for the history stuff, you can get the same setup by putting the line "\t": complete in the .inputrc file. -D PS, for all you *nix fans stuck with windo~1 out there : 2.1 with cygwin is _very_ cool. It handles EOF properly (^D) and works with readline, as it is supposed to. It also handles job control from bash properly (^Z suspends it and returns your shell prompt) From bobhicks@adelphia.net Thu Apr 19 15:35:09 2001 From: bobhicks@adelphia.net (Robert Hicks) Date: Thu, 19 Apr 2001 10:35:09 -0400 Subject: [Tutor] How I got Python on OSX Message-ID: <E14qFX5-0006XZ-00@mail.python.org> Get the source... I usually do all my stuff from /usr/local/src but you can do it anywhere. So open a Terminal and go to where you want to start.... type: wget http://www.python.org/ftp/python/2.1/python-2.1.tgz This will download the TGZ to your current folder/directory type: gnutar -xzf python-2.1.tgz cd python-2.1/ ./configure --program-suffix=.exe --with-dyld We need to take care of a case sensitive issue on OSX: Edit the Makefile...find the line that says EXE= and make sure it says EXE=.exe type: make OPT="-traditional-cpp" make install After it is installed you want to go to /usr/local/bin and... type: cp python.exe python cp python2.1.exe python2.1 You can remove the .exe ones if you like. Type: python Your interpreter should fire up... Hope this helps someone. The README from the TGZ states the steps as well. You cannot do a simple ./configure make make install unfortunately(or at least I couldn't). - Bob From alan.gauld@bt.com Thu Apr 19 16:38:25 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Thu, 19 Apr 2001 16:38:25 +0100 Subject: [Tutor] flatten a tuple Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D70B@mbtlipnt02.btlabs.bt.co.uk> > So I have a tuple: > > ((0, 1, 2), (3,4,5), (6,7,8)) > > and I want to get: > > (6,7,8,3,4,5,0,1,2) Go to my web tutor, look thru' the topic on recursion. In there, there is a recursive function for printing a list of arbitrary complexity in a flattened format. Convert the tuples to lists and change the print statements to result.append() and you should have most of your solution. HTH Alan G From dsh8290@rit.edu Thu Apr 19 17:10:11 2001 From: dsh8290@rit.edu (D-Man) Date: Thu, 19 Apr 2001 12:10:11 -0400 Subject: [Tutor] flatten a tuple In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D70B@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Thu, Apr 19, 2001 at 04:38:25PM +0100 References: <5104D4DBC598D211B5FE0000F8FE7EB20751D70B@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <20010419121011.E28582@harmony.cs.rit.edu> On Thu, Apr 19, 2001 at 04:38:25PM +0100, alan.gauld@bt.com wrote: | > So I have a tuple: | > | > ((0, 1, 2), (3,4,5), (6,7,8)) | > | > and I want to get: | > | > (6,7,8,3,4,5,0,1,2) | | Go to my web tutor, look thru' the topic on recursion. | In there, there is a recursive function for printing | a list of arbitrary complexity in a flattened format. | | Convert the tuples to lists and change the print | statements to result.append() and you should have | most of your solution. A slight subltety here : >>> result = [] >>> result.append( [ 6 , 7 , 8 ] ) >>> print result [[6, 7, 8]] >>> What you really want is 'extend', the subtleties of which (taking only a list as the argument) have already been discussed. -D From winanss@earthlink.net Thu Apr 19 17:49:35 2001 From: winanss@earthlink.net (Sean M Winans) Date: Thu, 19 Apr 2001 12:49:35 -0400 (EDT) Subject: [Tutor] reload a module Message-ID: <385465291.987698975484.JavaMail.root@web443-wrb> Hi all, I'm picking Python up again after a few months off... I can't remember how to reload a module after making changes. Thanks in advance, Sean. From kalle@gnupung.net Thu Apr 19 17:58:50 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Thu, 19 Apr 2001 18:58:50 +0200 Subject: [Tutor] reload a module In-Reply-To: <385465291.987698975484.JavaMail.root@web443-wrb>; from winanss@earthlink.net on Thu, Apr 19, 2001 at 12:49:35PM -0400 References: <385465291.987698975484.JavaMail.root@web443-wrb> Message-ID: <20010419185850.D379@apone.network.loc> Sez Sean M Winans: > Hi all, > > I'm picking Python up again after a few months off... > > I can't remember how to reload a module after making changes. reload(module) Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From bdupire@seatech.fau.edu Thu Apr 19 18:12:16 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Thu, 19 Apr 2001 13:12:16 -0400 Subject: [Tutor] weird python code Message-ID: <3ADF1C70.F3CF7026@seatech.fau.edu> I found this on a Python website (i don' t remember where exactly).. but did not figure out why this does not work.... can someone explain it to me? thanks... def f(): global path from sys import * print path >>> f() Traceback (innermost last): File "<pyshell#24>", line 1, in ? f() File "<pyshell#23>", line 4, in f print path NameError: path -- Benoit Dupire Graduate Student Systems Engineering - FAU ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From curtis.larsen@Covance.Com Thu Apr 19 18:52:03 2001 From: curtis.larsen@Covance.Com (Curtis Larsen) Date: Thu, 19 Apr 2001 12:52:03 -0500 Subject: [Tutor] Python NNTP Scripts? Message-ID: <sadedf93.082@madis2.truax.covance.com> Does anyone know where I could find some Python NNTP scripts to study? I'm especially interested in a Python-based news-searcher: how one would grab a collection of headers, then look through them using regex, then getting more if what you're looking for isn't there. If it is there, then downloading the messages) for later perusal. (What does the NNTP communications ebb and flow look like, etc.) In my case attachments aren't a real issue -- and would probably blow my teeny little mind trying to figure out how to collect, put together, then decode anyway. Maybe after I understand the textual part of the deal I can work on the binary parts. (A MIME is such a terrible thing to waste.) Yes, I know there's things like Deja out there, but: 1. I _wanna_ do it in Python (the power! The SHEER POWER! Muwahahahahaa!), and 2. Deja kinda sorta sucks anymore Thanks! Curtis ----------------------------------------------------- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender, so that we can arrange for proper delivery, and then please delete the message from your inbox. Thank you. From dsh8290@rit.edu Thu Apr 19 19:01:13 2001 From: dsh8290@rit.edu (D-Man) Date: Thu, 19 Apr 2001 14:01:13 -0400 Subject: [Tutor] weird python code In-Reply-To: <3ADF1C70.F3CF7026@seatech.fau.edu>; from bdupire@seatech.fau.edu on Thu, Apr 19, 2001 at 01:12:16PM -0400 References: <3ADF1C70.F3CF7026@seatech.fau.edu> Message-ID: <20010419140113.D29633@harmony.cs.rit.edu> On Thu, Apr 19, 2001 at 01:12:16PM -0400, Benoit Dupire wrote: | | I found this on a Python website (i don' t remember where exactly).. | but did not figure out why this does not work.... | | can someone explain it to me? | thanks... | | def f(): | global path | from sys import * | print path | | | >>> f() | Traceback (innermost last): | File "<pyshell#24>", line 1, in ? | f() | File "<pyshell#23>", line 4, in f | print path | NameError: path The global statement says that 'path' should be found in the global namespace, not the local one. The from-import-* creates a local name 'path', I guess. from-import-* is bad to do, except _maybe_ at module scope (ie not inside a function). AFAIK the Ref Man says it's behavior is undefined (implementation specific) except at module-level. If you use from sys import path instead and leave out the 'global' statement it will work. Or better yet use import sys print sys.path (BTW, it gives the same error in 2.0 and 2.1, but tells a little more: NameError: global name 'path' is not defined) HTH, -D From dsh8290@rit.edu Thu Apr 19 19:03:18 2001 From: dsh8290@rit.edu (D-Man) Date: Thu, 19 Apr 2001 14:03:18 -0400 Subject: [Tutor] Python as a superior teaching language In-Reply-To: <20010419102619.D28426@harmony.cs.rit.edu>; from dsh8290@rit.edu on Thu, Apr 19, 2001 at 10:26:19AM -0400 References: <1CDB101F0CB6D311882F0000F8063924033A7897@aquarius.bne.star.com.au> <"from arthur.watts"@gbst.com> <20010419102619.D28426@harmony.cs.rit.edu> Message-ID: <20010419140318.E29633@harmony.cs.rit.edu> On Thu, Apr 19, 2001 at 10:26:19AM -0400, D-Man wrote: | Putting | "\t": complete | in the .inputrc file. A side-effect I just discovered : >>> def func() : ... <TAB><TAB> doesn't work as before -- rather than indenting, readline asks if you want to see all possible completions. Can't have everything I guess ;-). -D From scarblac@pino.selwerd.nl Thu Apr 19 19:18:27 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 19 Apr 2001 20:18:27 +0200 Subject: [Tutor] Python NNTP Scripts? In-Reply-To: <sadedf93.082@madis2.truax.covance.com>; from curtis.larsen@Covance.Com on Thu, Apr 19, 2001 at 12:52:03PM -0500 References: <sadedf93.082@madis2.truax.covance.com> Message-ID: <20010419201827.A24611@pino.selwerd.nl> On 0, Curtis Larsen <curtis.larsen@Covance.Com> wrote: > Does anyone know where I could find some Python NNTP scripts to study? I'll add to this post part of a late night hack that I did about a year ago. I was having a few beers and wanted to know which newsreaders people were using in nl.*. (Outlook 49.7%, Forte Agent 15.2%, Netscape 12.3%, Forte Free Agent 4.8%, 33 other newsreaders). I must say I'm rather surprised how easy to understand the code is now - I don't want to see the Perl I produce when slightly drunk... This is the function for downloading the posts; the bit for getting the bodies is commented out, and the posts are stored by Message-ID in a shelf in a directory per group: import nntplib, string, time, shelve, os def get_posts(grouplistfile, server='news.rug.nl', filename_func=default_file): nntp = nntplib.NNTP('news.rug.nl') groups = map(string.strip, grouplistfile.readlines()) for group in groups: filename = ("/home/scarblac/python/nntphack/groups/%s/%s.dat" % (time.strftime("%Y%m%d",time.localtime(time.time())), group)) if os.path.exists(filename): continue try: # This gets info about the list of articles in this group resp, count, first, last, name = nntp.group(group) except nntplib.NNTPError: continue db = shelve.open(filename) for i in xrange(int(first), int(last)+1): article = Article() try: resp, nr, id, list = nntp.head(str(i)) article.set_headers(list) # resp, nr, id, list = nntp.body(str(i)) # article.set_body(list) db[article.get_header("Message-ID")] = article except nntplib.NNTPError: pass And the Article class: class Article: def __init__(self, headers=None, body=None): self.headers = {} if headers: self.set_headers(headers) self.body = body def set_headers(self, header_list): """Internal. Header_list is a list of header strings from nntplib.""" for line in header_list: i = string.find(line, ": ") if i == -1: continue self.headers[line[:i]] = string.strip(line[i+1:]) def set_body(self, body): self.body = body def get_headers(self): return self.headers def get_header(self, header): return self.headers.get(header, "") def get_body(self): return self.body > I'm especially interested in a Python-based news-searcher: how one > would grab a collection of headers, then look through them using regex, > then getting more if what you're looking for isn't there. If it is > there, then downloading the messages) for later perusal. (What does the > NNTP communications ebb and flow look like, etc.) What you see above should be enough. The sad thing is that in order to get all the headers in NNTP, you have to download the whole article. There are but a few that you can get with an XOVER command (From:, Xref:, Subject: and two others I think) but I can't remember how that's done with Python's nntplib. -- Remco Gerlich From Daniel.Kinnaer@Advalvas.be Thu Apr 19 21:42:26 2001 From: Daniel.Kinnaer@Advalvas.be (Daniel Kinnaer) Date: Thu, 19 Apr 2001 22:42:26 +0200 Subject: [Tutor] Python NNTP Scripts? In-Reply-To: <sadedf93.082@madis2.truax.covance.com> Message-ID: <LPBBLJLBPKOAHOOJGJIJKEFLCPAA.Daniel.Kinnaer@Advalvas.be> Below is a very straightforward script I tried to write which scans for a single word in the NNTP-Headers and only downloads the MessageBody to disk if the specific word is found in the Headers. I must admit that I copied much from the EffBot Guide: The Standard Python Library by /F :) It is my first 'real' Python program, so don't be too hard on me :) ############################################################## # script : NNTP_ScanHeaders_GetBody_on_found.py # author : Daniel Kinnaer # ref : The EffBot Guide: The Standard Python Library by /F # start : 26 December 2000 # finish : 28 December 2000 # updates: # # purpose: connect to an NNTP Server # check all de messages kept on the server for # authors named "Daniel". If found, download # that message and save it on disk # ############################################################## #get libraries from nntplib import * import string, StringIO, rfc822 #name variables SERVER="news.skynet.be" GROUP="comp.lang.python" KEYWORD="Daniel" THEPATH="C:/Data/Py/AProject/NNTP/NNTPBodies/" #Slash, not BackSlash! print " " #connect to server server=NNTP(SERVER) print "### Connecting to " + SERVER + "..." #select a newsgroup print "### reading group " + GROUP + "..." resp,count,first,last,name=server.group(GROUP) print "count=%s first=%s last=%s " %(count,first,last) #get every item from id=first to id=last resp, items = server.xover(first,last) #search every item for the KEYWORD print "### now searching for keyword " + KEYWORD + " in each article from group " + name for id,subject,author,date,message_id,references,size,lines in items: if string.find(author,KEYWORD)>=0: resp,id,message_id,text=server.article(id) #save body artikellijnen =str(len(text)) FileNaam=THEPATH + str(id)+'.txt' f=open(FileNaam,'w') print "writing %s lines to file %s " %(artikellijnen,FileNaam) author=author+'\n' f.write(author) subject=subject+'\n' artikellijnen=artikellijnen + "\n" f.write(artikellijnen) text=string.join(text,"\n") file=StringIO.StringIO(text) message=rfc822.Message(file) for k,v in message.items(): lijn=k,"=",v+'\n' f.writelines(lijn) lijnen=message.fp.read() f.writelines(lijnen) f.write( "\r\n") f.close() print "End of Script..." How can this be improved with 'regex'? I'd like to scan on several parts of the header (like must contain A and B or C). What is the best way to improve this? Hope to read you soon. Best regards, Daniel... From tbrauch@mindless.com Thu Apr 19 23:39:26 2001 From: tbrauch@mindless.com (Timothy M. Brauch) Date: Thu, 19 Apr 2001 18:39:26 -0400 Subject: [Tutor] COM Ports Message-ID: <3ADF691E.74775B5F@mindless.com> I have a project that I would greatly appreciate some help with getting started. I think it can be done in Python, and would love it if it can be. I have an infrared receiver for a remote control hooked up to my Win98 computer's COM2. What I would like to do is be able to use the remote to fun functions inside a Python program, depending on what button is pushed. The receiver also can pick up signals from any remote, but the program that came with the remote will only operate with this remote. I would really like to eventually write a program that can be changed fairly easily depending on what remote I have on hand (no need to worry about losing the remote). The problem is I don't know how (or even if it is possible) to use Python to "get" the buttons from COM2. Also, I'm not even sure what COM2 sends when I do push a button. If someone can just point me in the right direction, I would be very greatful. Of course, any other help you might want to provide would be great as well. - Tim From jonsoons@telocity.com Fri Apr 20 00:05:56 2001 From: jonsoons@telocity.com (jonsoons@telocity.com) Date: 19 Apr 2001 16:05:56 -0700 Subject: [Tutor] trouble reading Programming Python Message-ID: <20010419230556.1296.cpmta@c007.snv.cp.net> I am on page 47 of "Programming Python" 2nd Edition and 3/4 of the way down the page there are a couple of lines with three double quotes within: print 'Got this" "%s"' % raw_input() and Got this" "Help! Help! I'm being repressed!" It all makes sense apart from the first " in each line. Are these characters protected from interpretation in some way that the %s is not? Why is this not a syntax error? To quote the manual: "...r"\" is a valid string literal, r"\"" is not..." From rob@jam.rr.com Fri Apr 20 03:20:13 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Thu, 19 Apr 2001 21:20:13 -0500 Subject: [Tutor] trouble reading Programming Python References: <20010419230556.1296.cpmta@c007.snv.cp.net> Message-ID: <3ADF9CDD.C5DCA2C7@jam.rr.com> Although I'm not sure why that first " is in there, it's as protected as it needs to be due to the fact that it appears between two single quotes. Everything between those single quotes is to be printed, including each double quote sign, such as in the following: >>> print '"""""' """"" If you place single quotes inside a pair of double quotes, the same thing happens: >>> print "'''''" ''''' You can use either single or double quotes for containment, and sometimes it doesn't matter which you choose. However, there are circumstances in which one will work but the other will not, such as in these examples: >>> print 'quoth the Raven "nevermore"' quoth the Raven "nevermore" >>> print "quoth the Raven "nevermore"" Traceback ( File "<interactive input>", line 1 print "quoth the Raven "nevermore"" ^ SyntaxError: invalid syntax >>> print "I can't see!" I can't see! >>> print 'I can't see!' Traceback ( File "<interactive input>", line 1 print 'I can't see!' ^ SyntaxError: invalid syntax I hope this helps, Rob jonsoons@telocity.com wrote: > > I am on page 47 of "Programming Python" 2nd Edition > and 3/4 of the way down the page there are a couple > of lines with three double quotes within: > > print 'Got this" "%s"' % raw_input() > > and > > Got this" "Help! Help! I'm being repressed!" > > It all makes sense apart from the first " in > each line. Are these characters protected from > interpretation in some way that the %s is not? > Why is this not a syntax error? > > To quote the manual: "...r"\" is a valid string > literal, r"\"" is not..." > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From kstoner@netins.net Fri Apr 20 03:24:20 2001 From: kstoner@netins.net (Katharine Stoner) Date: Thu, 19 Apr 2001 21:24:20 -0500 Subject: [Tutor] inverse Message-ID: <000a01c0c941$0914f700$8352b1cf@oemcomputer> This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C0C917.18D029A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, How do you get the inverse of tan using python? -Cameron ------=_NextPart_000_0007_01C0C917.18D029A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>How do you get the inverse of tan using = python?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-Cameron</FONT></DIV> <DIV> </DIV></BODY></HTML> ------=_NextPart_000_0007_01C0C917.18D029A0-- From python tutor" <tutor@python.org Fri Apr 20 03:52:33 2001 From: python tutor" <tutor@python.org (Tim Peters) Date: Thu, 19 Apr 2001 22:52:33 -0400 Subject: [Tutor] inverse In-Reply-To: <000a01c0c941$0914f700$8352b1cf@oemcomputer> Message-ID: <LNBBLJKPBEHFEDALKOLCEEGIJNAA.tim.one@home.com> [Katharine Stoner] > How do you get the inverse of tan using python? Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> import math >>> math.atan(1) 0.78539816339744828 >>> _ * 4 3.1415926535897931 >>> Note that, as in most computer languages, Python's trigonometric functions measure angles in radians (pi radians == 180 degrees). Also see the docs for the math module. From tbrauch@mindless.com Fri Apr 20 04:53:10 2001 From: tbrauch@mindless.com (Timothy M. Brauch) Date: Thu, 19 Apr 2001 23:53:10 -0400 Subject: [Tutor] COM Ports Message-ID: <3ADFB2A6.9242E68@mindless.com> I have a program I want to write and I would greatly appreciate some help with getting started. I think it can be done in Python, and would love it if it can be. I have an infrared receiver for a remote control hooked up to my Win98 computer's COM2. What I would like to do is be able to use the remote to fun functions inside a Python program, depending on what button is pushed. The receiver also can pick up signals from any remote, but the program that came with the remote will only operate with this remote. I would really like to eventually write a program that can be changed fairly easily depending on what remote I have on hand (no need to worry about losing the remote). The problem is I don't know how (or even if it is possible) to use Python to "get" the buttons from COM2. Also, I'm not even sure what COM2 sends when I do push a button. If someone can just point me in the right direction, I would be very greatful. Of course, any other help you might want to provide would be great as well. - Tim **I tried sending this earlier, but I don't know if it went through. If so, please ignore my double posting.** From ash@zyx.net Fri Apr 20 05:44:30 2001 From: ash@zyx.net (Aaron Mathews) Date: Thu, 19 Apr 2001 22:44:30 -0600 Subject: [Tutor] COM Ports References: <3ADF691E.74775B5F@mindless.com> Message-ID: <002a01c0c954$97bc4db0$7800000a@gandalf> Unless you can find a published spec for the communication mode the IR receiver uses, you will be in for some reverse engineering if you want full functionality (generally). You might try contacting the manufacturer of the device and see if they have any developer kits, etc. You might try watching COM2 from a terminal, and capturing the output from the IR receiver when you press buttons- you could watch for that output (per button) and execute a function when you see the command for '5', for example. Oh, and I don't know anything about accessing serial ports on windows... I'm used to just opening the serial device as a filehandle under BSD. Sorry :) -Aaron ----- Original Message ----- From: "Timothy M. Brauch" <tbrauch@mindless.com> To: "Python Tutor" <tutor@python.org> Sent: Thursday, April 19, 2001 4:39 PM Subject: [Tutor] COM Ports > I have a project that I would greatly appreciate some help with getting > started. I think it can be done in Python, and would love it if it can > be. > I have an infrared receiver for a remote control hooked up to my Win98 > computer's COM2. What I would like to do is be able to use the remote > to fun functions inside a Python program, depending on what button is > pushed. The receiver also can pick up signals from any remote, but the > program that came with the remote will only operate with this remote. I > would really like to eventually write a program that can be changed > fairly easily depending on what remote I have on hand (no need to worry > about losing the remote). > > The problem is I don't know how (or even if it is possible) to use > Python to "get" the buttons from COM2. Also, I'm not even sure what > COM2 sends when I do push a button. > > If someone can just point me in the right direction, I would be very > greatful. Of course, any other help you might want to provide would be > great as well. > > - Tim > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From baris@gelecek.com.tr Fri Apr 20 08:09:58 2001 From: baris@gelecek.com.tr (Baris Metin) Date: Fri, 20 Apr 2001 10:09:58 +0300 (EEST) Subject: [Tutor] tail -f Message-ID: <Pine.LNX.4.21.0104201008400.1099-100000@tiger.obua.org> Hello, How can I read a file continuously, like the command "tail -f" on unix systems ? Do I have to open and close file ? -- Baris Metin From kalle@gnupung.net Fri Apr 20 11:49:14 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Fri, 20 Apr 2001 12:49:14 +0200 Subject: [Tutor] tail -f In-Reply-To: <Pine.LNX.4.21.0104201008400.1099-100000@tiger.obua.org>; from baris@gelecek.com.tr on Fri, Apr 20, 2001 at 10:09:58AM +0300 References: <Pine.LNX.4.21.0104201008400.1099-100000@tiger.obua.org> Message-ID: <20010420124914.C372@apone.network.loc> Sez Baris Metin: > How can I read a file continuously, like the command "tail -f" on unix > systems ? > > Do I have to open and close file ? No, just reading from it should work: f = open("fisk") import time while 1: print f.read() time.sleep(1) f.close() will print all new text in the file every time through the loop. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From bdupire@seatech.fau.edu Fri Apr 20 14:34:43 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Fri, 20 Apr 2001 09:34:43 -0400 Subject: [Tutor] COM Ports References: <3ADFB2A6.9242E68@mindless.com> Message-ID: <3AE03AF3.997D1B3E@seatech.fau.edu> In electronics, like in CE, the communication between a transmitter and a receiver uses a particular 'protocol' to be sure that the message the receiver receives is being caused by the transmitter, and not by any noise..... For instance, if you press the button '5', the remote can send '01100101' 10 times in a row, and the receiver aknowledge the signal when it receives 3 of them.... this protocol is often 'hardware', therefore can't be changed, and depends of the product... so make sure before beginning your project that you can substitute your first remote by another one....(Maybe there exists a 'universal' remote out there or maybe you can buy several remotes for this product from the constructor). Then, what you want to know is the output of the receiver, when it deciphers '01100101'...... you have to get the spec...otherwise you have to do it yourself and to look at the output for each event of the remote... Then, you can ask yourself whether the rest of the project can be done in Python... -- Benoit Dupire Graduate Student Systems Engineering ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From alan.gauld@bt.com Fri Apr 20 15:14:41 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 20 Apr 2001 15:14:41 +0100 Subject: [Tutor] flatten a tuple Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D717@mbtlipnt02.btlabs.bt.co.uk> | Convert the tuples to lists and change the print > | statements to result.append() and you should have > > What you really want is 'extend' Nope, I want append. The recursive routine reduces the list to elements before printing thus you never attempt to print a list... Here it is: def printList(L): if not L: return if type(L[0]) == type([]): # extend for other sequences? printList(L[0]) else: #no list so just print element print L[0] # now process the rest of L printList(L[1:]) I think it was Danny posted something similar already, that also did the reversal by using -1 instead of 0, a neat twist :-) Alan G. PS Is there a better way of testing the type? For example something that could check for any sequence? if L.hasMethod(__getitems__) or whatever? From dsh8290@rit.edu Fri Apr 20 15:41:12 2001 From: dsh8290@rit.edu (D-Man) Date: Fri, 20 Apr 2001 10:41:12 -0400 Subject: [Tutor] flatten a tuple In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D717@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Fri, Apr 20, 2001 at 03:14:41PM +0100 References: <5104D4DBC598D211B5FE0000F8FE7EB20751D717@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <20010420104112.A2753@harmony.cs.rit.edu> On Fri, Apr 20, 2001 at 03:14:41PM +0100, alan.gauld@bt.com wrote: | | Convert the tuples to lists and change the print | > | statements to result.append() and you should have | > | > What you really want is 'extend' | | Nope, I want append. The recursive routine reduces | the list to elements before printing thus you never | attempt to print a list... Oh ok. You have a nested list (only 1 level) , then you strip that level when you print. I was trying to get rid of all levels of nesting, then the print would simply be 'print'. Same result, different perspective :-). | PS Is there a better way of testing the type? | For example something that could check for any | sequence? if L.hasMethod(__getitems__) or whatever? It really depends on what you expect to be in the list. If you want to allow the list to contain strings, and consider those strings as "atoms", then that technique won't work. I think the adapter PEP or the interfaces PEP (I haven't read the interfaces one yet) might address this situation, but I don't know that it would consider a string to be an atom (after all, you can iterate over a string a character at a time ...). If you want the code to be slightly faster and use a little less memory make the following change : - if type( L ) == type( [] ) : + import types + if type( L ) == types.ListType : The difference is the first line creates a new list, calls a function to get its type, then frees the list each time it is executed. The second one creates a list, gets its type, frees it only on the import. OTOH the second form does the same thing for every other type, so it really depends on where you want the time to be spent. If you check the type of other stuff or if you run through the loop a lot it is a good tradeoff. -D From jsoons@juilliard.edu Fri Apr 20 16:05:23 2001 From: jsoons@juilliard.edu (Jonathan Soons) Date: Fri, 20 Apr 2001 11:05:23 -0400 Subject: [Tutor] readline recompile fails Message-ID: <B7C74E1A6FBAD411BFC60002B309DDF4E46E@mailbox.juilliard.edu> I cannot make Python2.0 recompile with readline enabled in Modules/Setup. I have installed GNU readline in /usr/local/lib (same place as tcl and tk libs). I am on a SPARC with Solaris7. gcc2.8.0. Do I need ncurses also? The Setup file seems to say this is optional. From kalle@gnupung.net Fri Apr 20 16:37:12 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Fri, 20 Apr 2001 17:37:12 +0200 Subject: [Tutor] readline recompile fails In-Reply-To: <B7C74E1A6FBAD411BFC60002B309DDF4E46E@mailbox.juilliard.edu>; from jsoons@juilliard.edu on Fri, Apr 20, 2001 at 11:05:23AM -0400 References: <B7C74E1A6FBAD411BFC60002B309DDF4E46E@mailbox.juilliard.edu> Message-ID: <20010420173712.A6905@apone.network.loc> Sez Jonathan Soons: > I cannot make Python2.0 recompile with readline enabled in Modules/Setup. I > have installed GNU readline in /usr/local/lib (same place as tcl and tk > libs). > I am on a SPARC with Solaris7. > gcc2.8.0. How does it fail? Could you post an error message, and perhaps the relevant part of Setup? > Do I need ncurses also? The Setup file seems to say this is optional. ncurses is optional. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From alan.gauld@bt.com Fri Apr 20 17:05:05 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 20 Apr 2001 17:05:05 +0100 Subject: [Tutor] flatten a tuple Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D71C@mbtlipnt02.btlabs.bt.co.uk> > | PS Is there a better way of testing the type? > It really depends on what you expect to be in the list. If you want > to allow the list to contain strings, and consider those strings as > "atoms", No, I think I'd treat strings as sequences. > If you want the code to be slightly faster and use a little less > memory make the following change : > > - if type( L ) == type( [] ) : > + import types > + if type( L ) == types.ListType : True, Good catch. Alan G. From jsoons@juilliard.edu Fri Apr 20 18:24:12 2001 From: jsoons@juilliard.edu (Jonathan Soons) Date: Fri, 20 Apr 2001 13:24:12 -0400 Subject: [Tutor] RE: recompiling with readline Message-ID: <B7C74E1A6FBAD411BFC60002B309DDF4E471@mailbox.juilliard.edu> I cannot make Python2.0 recompile with readline enabled in Modules/Setup. It may have been a mistake to install readline if the source comes with Python2.0. Maybe that's the conflict??? Here is the line from Setup: readline readline.c -lreadline -ltermcap Here is the error: make[1]: Leaving directory `/usr/share/src/Python-2.0/Python' cd Modules ; make OPT="-g -O2 -Wall -Wstrict-prototypes" VERSION="2.0" \ prefix="/usr/local" exec_prefix="/usr/local" all make[1]: Entering directory `/usr/share/src/Python-2.0/Modules' gcc -g -O2 -Wall -Wstrict-prototypes -I./../Include -I.. -DHAVE_CONFIG_H -c ./readline.c ./readline.c:31: conflicting types for `rl_read_init_file' /usr/local/include/readline/readline.h:303: previous declaration of `rl_read_init_file' ./readline.c:32: conflicting types for `rl_insert_text' /usr/local/include/readline/readline.h:363: previous declaration of `rl_insert_text' ./readline.c: In function `set_completer_delims': ./readline.c:227: warning: passing arg 1 of `free' discards `const' from pointer target type ./readline.c: In function `flex_complete': ./readline.c:399: warning: implicit declaration of function `completion_matches' ./readline.c:399: warning: return makes pointer from integer without a cast make[1]: *** [readline.o] Error 1 make[1]: Leaving directory `/usr/share/src/Python-2.0/Modules' make: *** [Modules] Error 2 From kalle@gnupung.net Fri Apr 20 19:09:04 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Fri, 20 Apr 2001 20:09:04 +0200 Subject: [Tutor] RE: recompiling with readline In-Reply-To: <B7C74E1A6FBAD411BFC60002B309DDF4E471@mailbox.juilliard.edu>; from jsoons@juilliard.edu on Fri, Apr 20, 2001 at 01:24:12PM -0400 References: <B7C74E1A6FBAD411BFC60002B309DDF4E471@mailbox.juilliard.edu> Message-ID: <20010420200904.B7649@apone.network.loc> Sez Jonathan Soons: > > I cannot make Python2.0 recompile with readline enabled in Modules/Setup. > It may have been a mistake to install readline if the source comes with > Python2.0. > Maybe that's the conflict??? No, I don't think there is any readline code in the Python dist. > Here is the line from Setup: > readline readline.c -lreadline -ltermcap > > Here is the error: > > make[1]: Leaving directory `/usr/share/src/Python-2.0/Python' > cd Modules ; make OPT="-g -O2 -Wall -Wstrict-prototypes" VERSION="2.0" \ > prefix="/usr/local" exec_prefix="/usr/local" all > make[1]: Entering directory `/usr/share/src/Python-2.0/Modules' > gcc -g -O2 -Wall -Wstrict-prototypes -I./../Include -I.. -DHAVE_CONFIG_H -c > ./readline.c > ./readline.c:31: conflicting types for `rl_read_init_file' > /usr/local/include/readline/readline.h:303: previous declaration of > `rl_read_init_file' > ./readline.c:32: conflicting types for `rl_insert_text' > /usr/local/include/readline/readline.h:363: previous declaration of > `rl_insert_text' [snip] Aha! You use readline 4.2, right? A CVS commit on Fri Apr 13 18:14:27 2001 UTC has the following log entry: """ Clean up the unsightly mess around the readline header files. We now always: - #undef HAVE_CONFIG_H (because otherwise chardefs.h tries to include strings.h) - #include readline.h and history.h and we never declare any readline function prototypes ourselves. This makes it compile with readline 4.2, albeit with a few warnings. Some of the remaining warnings are about completion_matches(), which is renamed to rl_completion_matches(). I've tested it with various other versions, from 2.0 up, and they all seem to work (some with warnings) -- but only on Red Hat Linux 6.2. Fixing the warnings for readline 4.2 would break compatibility with 3.0 (and maybe even earlier versions), and readline doesn't seem to have a way to test for its version at compile time, so I'd rather leave the warnings in than break compilation with older versions. """ This probably means you have to downgrade readline to 3.x or upgrade Python to 2.1. I suggest upgrading Python... Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From bsass@freenet.edmonton.ab.ca Fri Apr 20 19:22:47 2001 From: bsass@freenet.edmonton.ab.ca (Bruce Sass) Date: Fri, 20 Apr 2001 12:22:47 -0600 (MDT) Subject: [Tutor] flatten a tuple In-Reply-To: <20010420104112.A2753@harmony.cs.rit.edu> Message-ID: <Pine.LNX.4.33.0104201214390.18843-100000@bms> On Fri, 20 Apr 2001, D-Man wrote: <...> > - if type( L ) == type( [] ) : > + import types > + if type( L ) == types.ListType : > > The difference is the first line creates a new list, calls a function > to get its type, then frees the list each time it is executed. The > second one creates a list, gets its type, frees it only on the import. > OTOH the second form does the same thing for every other type, so it > really depends on where you want the time to be spent. If you check > the type of other stuff or if you run through the loop a lot it is a > good tradeoff. I'd say the best way is to do... ListType = type([]) ... if type(L) == ListType The first line is what "import types" does; doing it manually will always be faster because there is no "import" or attribute access (".") overhead. - Bruce From dyoo@hkn.eecs.berkeley.edu Fri Apr 20 19:45:07 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Fri, 20 Apr 2001 11:45:07 -0700 (PDT) Subject: [Tutor] flatten a tuple In-Reply-To: <Pine.LNX.4.33.0104201214390.18843-100000@bms> Message-ID: <Pine.LNX.4.21.0104201139030.26546-100000@hkn.eecs.berkeley.edu> On Fri, 20 Apr 2001, Bruce Sass wrote: > On Fri, 20 Apr 2001, D-Man wrote: > <...> > > - if type( L ) == type( [] ) : > > + import types > > + if type( L ) == types.ListType : > > > > The difference is the first line creates a new list, calls a function > > to get its type, then frees the list each time it is executed. The > > second one creates a list, gets its type, frees it only on the import. > > OTOH the second form does the same thing for every other type, so it > > really depends on where you want the time to be spent. If you check > > the type of other stuff or if you run through the loop a lot it is a > > good tradeoff. > > I'd say the best way is to do... > > ListType = type([]) > ... > if type(L) == ListType > > The first line is what "import types" does; doing it manually will > always be faster because there is no "import" or attribute access > (".") overhead. Deja vu! *grin* http://mail.python.org/pipermail/tutor/2001-March/003911.html From pt00aar@student.bth.se Fri Apr 20 20:00:12 2001 From: pt00aar@student.bth.se (Anders Arvidsson) Date: Fri, 20 Apr 2001 21:00:12 +0200 Subject: [Tutor] please help and I will be so happy Message-ID: <001c01c0c9cc$20b63fa0$998f2fc2@rsn.hkr.se> This is a multi-part message in MIME format. ------=_NextPart_000_0019_01C0C9DC.E42E46C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I would like to know how to recive and print information from a certain = webpage by using sockets in Python.=20 ------=_NextPart_000_0019_01C0C9DC.E42E46C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.3105.105" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>I would like to know how to recive and = print=20 information from a certain webpage by using sockets in Python.=20 </FONT></DIV></BODY></HTML> ------=_NextPart_000_0019_01C0C9DC.E42E46C0-- From dsh8290@rit.edu Fri Apr 20 20:08:02 2001 From: dsh8290@rit.edu (D-Man) Date: Fri, 20 Apr 2001 15:08:02 -0400 Subject: [Tutor] please help and I will be so happy In-Reply-To: <001c01c0c9cc$20b63fa0$998f2fc2@rsn.hkr.se>; from pt00aar@student.bth.se on Fri, Apr 20, 2001 at 09:00:12PM +0200 References: <001c01c0c9cc$20b63fa0$998f2fc2@rsn.hkr.se> Message-ID: <20010420150802.A3673@harmony.cs.rit.edu> On Fri, Apr 20, 2001 at 09:00:12PM +0200, Anders Arvidsson wrote: | I would like to know how to recive and print information from a certain webpage by using sockets in Python. Don't use sockets. Sockets are very low level, and you would have to implement the HTTP protocol on top of them. Instead use the "httplib" module that is in the standard distribution. http://www.python.org/doc/lib/lib.html HTH, -D From randrews@planhouse.com Fri Apr 20 20:17:05 2001 From: randrews@planhouse.com (Rob Andrews) Date: Fri, 20 Apr 2001 14:17:05 -0500 Subject: [Tutor] please help and I will be so happy In-Reply-To: <001c01c0c9cc$20b63fa0$998f2fc2@rsn.hkr.se> Message-ID: <000701c0c9ce$7d6e4b00$1e00a8c0@planhouse5> You can find info on sockets with Python at this URL: http://www.python.org/doc/current/lib/module-socket.html If you can tell us a bit more detail about what you'd like to do, it'll be easier to give more specific feedback. Rob -----Original Message----- I would like to know how to recive and print information from a certain webpage by using sockets in Python. From arcege@speakeasy.net Fri Apr 20 20:21:41 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Fri, 20 Apr 2001 15:21:41 -0400 (EDT) Subject: [Tutor] flatten a tuple In-Reply-To: <Pine.LNX.4.33.0104201214390.18843-100000@bms> from "Bruce Sass" at Apr 20, 2001 12:22:47 PM Message-ID: <200104201921.f3KJLfv04312@dsl254-114-246.nyc1.dsl.speakeasy.net> Bruce Sass wrote > I'd say the best way is to do... > > ListType = type([]) > ... > if type(L) == ListType > > The first line is what "import types" does; doing it manually will > always be faster because there is no "import" or attribute access > (".") overhead. Folks, If you are concerned with this level of efficiency, then it is very likely that you have a decent sized application, and that you are doing this in a number of places. Creating all these *Type values in a lot of different modules is going to be far more wasteful (memory and speed) than importing the types module. And if you are so concerned with the attribute references, you can use the "from types import ListType" form. The time to load an already compiled standard module is not all that much. Except for small, pedantic scripts, defining your own ListType global isn't more efficient at all, and probably the worst way to do this (at least the `type([])' method frees the memory). -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From kromag@nsacom.net Fri Apr 20 23:59:42 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Fri, 20 Apr 2001 15:59:42 -0700 (PDT) Subject: [Tutor] COM Ports Message-ID: <200104202259.f3KMxgm07111@pop.nsacom.net> > > Oh, and I don't know anything about accessing serial ports on windows... > I'm used to just opening the serial device as a filehandle under BSD. > Sorry :) But never let a chance like this go to waste..... I have a project in the works that requires me to read data from a multi-port serial card (which I don't have yet - it should arrive in the mail soon) and squirt the data into a database. I am using (at this moment) linux for this particular job, but would have no problem switching to Free/NetBSD (I don't think PostGreSQL will run on OpenBSD yet...). As I understand it, one has to create a C module to read from the serial port in python under unix. I have read the Linux-Serial- Programming-HOWTO and the C Extentions Overview in Programming Python and am beginning to get some idea of how creating such a mawnstah might work, but would really like to see some example code that is a little less generic. Can you or any of the other clueful post some examples or url's for same? Thanks! d From vijay.kumar@cqsl.com Wed Apr 11 18:18:31 2001 From: vijay.kumar@cqsl.com (Vijay Kumar) Date: Wed, 11 Apr 2001 13:18:31 -0400 (EDT) Subject: [Tutor] Help Message-ID: <Pine.LNX.4.21.0104111315370.17078-100000@mailer.cqsl.com> Hi, I am beginner in Python & working on Linux. I have set the PYTHONSTARTUP variable to some file in the .bash_profile. When I start python Interactively this script is not being executed alothough the PYTHONSTARTUP variable has the value which is specified in the .bash_profile. How do I set the Value in the PYTHONSTARTUP variable ??? Please Help Thank You, Vijay. From dsh8290@rit.edu Fri Apr 20 22:15:29 2001 From: dsh8290@rit.edu (D-Man) Date: Fri, 20 Apr 2001 17:15:29 -0400 Subject: [Tutor] COM Ports In-Reply-To: <200104202259.f3KMxgm07111@pop.nsacom.net>; from kromag@nsacom.net on Fri, Apr 20, 2001 at 03:59:42PM -0700 References: <200104202259.f3KMxgm07111@pop.nsacom.net> Message-ID: <20010420171529.B3917@harmony.cs.rit.edu> On Fri, Apr 20, 2001 at 03:59:42PM -0700, kromag@nsacom.net wrote: | > | > Oh, and I don't know anything about accessing serial ports on windows... | > I'm used to just opening the serial device as a filehandle under BSD. | > Sorry :) | | But never let a chance like this go to waste..... | | I have a project in the works that requires me to read data from a multi-port | serial card (which I don't have yet - it should arrive in the mail soon) and | squirt the data into a database. | | I am using (at this moment) linux for this particular job, but would have no | problem switching to Free/NetBSD (I don't think PostGreSQL will run on | OpenBSD yet...). As I understand it, one has to create a C module to read | from the serial port in python under unix. I have read the Linux-Serial- | Programming-HOWTO and the C Extentions Overview in Programming Python and am | beginning to get some idea of how creating such a mawnstah might work, but | would really like to see some example code that is a little less generic. | | Can you or any of the other clueful post some examples or url's for same? To toy with your modem, on COM3 (under linux) : modem = open( "/dev/ttyS2" , "r+" ) modem.write( "ATZ" ) modem.write( "ATDT*80,4272000" ) print modem.readline() print modem.readline() print modem.readline() <grin>. Unix is rather orthogonal when it comes to device access. It treats everything as a file -- terminals, ttys, serial ports, actual files. The serial ports under Linux >= 2.2.x are /dev/ttySn where n is a single digit integer (I suppose you could have more serial ports, but I only have at most 3 on my systems). Simply open the device file and read/write to your heart's content. The main thing to be careful of is knowing how the device will react and interacting appropriately. If instead I tried to print modem.read() the interpreter will "hang" waiting for an EOF signal from the modem. Of course, that isn't about to happen anytime soon. I must confess that I too don't know how to open a Windows serial port for reading/writing. The following DOS command will copy a disk file directly to a port: copy /b Linux-Advocacy.ps LPT1 This is useful if you have, say, a postscript file and a postscript printer on LPT1. -D PS. Disclaimer : Even though I did use the interactive interpreter some when I was trying to get my modem to work, I haven't done any serious serial (or parallel, or USB, etc) programming and haven't read that HOWTO you referred to. From bsass@freenet.edmonton.ab.ca Fri Apr 20 22:26:52 2001 From: bsass@freenet.edmonton.ab.ca (Bruce Sass) Date: Fri, 20 Apr 2001 15:26:52 -0600 (MDT) Subject: [Tutor] flatten a tuple In-Reply-To: <200104201921.f3KJLfv04312@dsl254-114-246.nyc1.dsl.speakeasy.net> Message-ID: <Pine.LNX.4.33.0104201432250.18843-100000@bms> On Fri, 20 Apr 2001, Michael P. Reilly wrote: > If you are concerned with this level of efficiency, then it is very > likely that you have a decent sized application, and that you are doing > this in a number of places. Creating all these *Type values in a lot of > different modules is going to be far more wasteful (memory and speed) > than importing the types module. > > And if you are so concerned with the attribute references, you can > use the "from types import ListType" form. The time to load an already > compiled standard module is not all that much. Ya, there is no "best way" in the general case... > Except for small, pedantic scripts, defining your own ListType global > isn't more efficient at all, and probably the worst way to do this > (at least the `type([])' method frees the memory). ...this was for a standalone script with a single check inside a loop. Thanks for the reality check though, it is easy to get hooked on one way of doing things. Two questions come to mind: Why isn't this a FAQ? Anyone have any idea of how many manual someType=type(something)-s are in an "import types". ``grep "Type = type(" types.py | wc -l'' -> 28 with py-2.1, so does that mean you could do it manually >28 times before using "import types" is more efficient? - Bruce From arcege@speakeasy.net Fri Apr 20 22:35:13 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Fri, 20 Apr 2001 17:35:13 -0400 (EDT) Subject: [Tutor] COM Ports In-Reply-To: <200104202259.f3KMxgm07111@pop.nsacom.net> from "kromag@nsacom.net" at Apr 20, 2001 03:59:42 PM Message-ID: <200104202135.f3KLZDw04474@dsl254-114-246.nyc1.dsl.speakeasy.net> kromag@nsacom.net wrote > I am using (at this moment) linux for this particular job, but would have no > problem switching to Free/NetBSD (I don't think PostGreSQL will run on > OpenBSD yet...). As I understand it, one has to create a C module to read > from the serial port in python under unix. I have read the Linux-Serial- > Programming-HOWTO and the C Extentions Overview in Programming Python and am > beginning to get some idea of how creating such a mawnstah might work, but > would really like to see some example code that is a little less generic. You don't need to create a new C module just to access the serial lines, open the device file for the serial line (eg. /dev/ttyS0), configure the line as needed with the termios/TERMIOS modules and read and write the data as needed. The select module can help you for when data is ready. >>> import termios, TERMIOS >>> f= open('/dev/ttyS2', 'r+') >>> settings = termios.tcgetattr(f.fileno()) >>> settings[3] = settings[3] & ~TERMIOS.ICANON >>> settings[4] = settings[5] = TERMIOS.B9600 >>> termios.tcsetattr(f.fileno(), settings, TERMIOS.TCSAFLUSH) >>> f.write('AT\r') # Hayes modem protocol >>> f.read(10) 'AT\n' # this is contrived, it might return 'AT\r\n' >>> There are other packages out there that will do this for you as well. [Shameless self-promotion] Such as ExpectPy, which is a C module interface to the Expect library (usually associated with Tcl); it doesn't sound like you need ExpectPy though. Definately look into termios. Myself, as a developer of FreeBSD products, I'd stay with Linux. There are a lot of problems that FreeBSD creates (and if you were to use FreeBSD, do NOT use the canned Python 1.5.2 in the distributions, build it yourself). -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From pt00aar@student.bth.se Sat Apr 21 00:27:45 2001 From: pt00aar@student.bth.se (Anders Arvidsson) Date: Sat, 21 Apr 2001 01:27:45 +0200 Subject: [Tutor] please help me and I will be so happy again Message-ID: <006b01c0c9f1$811f7e40$998f2fc2@rsn.hkr.se> This is a multi-part message in MIME format. ------=_NextPart_000_0068_01C0CA02.448FE440 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable People are very nice here on this mailing list.... My problem is that I shall create a program that get's stock values from = a website and then saves it in a textfile, and I dont know how to recive = the stock numbers from the website... ------=_NextPart_000_0068_01C0CA02.448FE440 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.3105.105" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>People are very nice here on this = mailing=20 list....</FONT></DIV> <DIV><FONT face=3DArial size=3D2>My problem is that I shall create = a program=20 that get's stock values from a website and then saves it in a=20 textfile, and I dont know how to recive the stock numbers from the=20 website...</FONT></DIV></BODY></HTML> ------=_NextPart_000_0068_01C0CA02.448FE440-- From parth.malwankar@wipro.com Sat Apr 21 01:23:46 2001 From: parth.malwankar@wipro.com (Parth Malwankar) Date: Sat, 21 Apr 2001 05:53:46 +0530 Subject: [Tutor] COM Ports In-Reply-To: <3ADFB2A6.9242E68@mindless.com>; from Timothy M. Brauch on Thu, Apr 19, 2001 at 11:53:10PM -0400 References: <3ADFB2A6.9242E68@mindless.com> Message-ID: <20010421055346.A8996@wipro.wipsys.sequent.com> Though I am very new to python, incase you are considering writing a wrapper to C code for accessing the serial port, functions _inp() and _outp() declared in c onio.h under windows provide access to i/o ports for reading and writing bytes. Regards, Parth On Thu, Apr 19, 2001 at 11:53:10PM -0400, Timothy M. Brauch wrote: |I have a program I want to write and I would greatly appreciate some |help with getting started. I think it can be done in Python, and would |love it if it can be. | |I have an infrared receiver for a remote control hooked up to my Win98 |computer's COM2. What I would like to do is be able to use the remote |to fun functions inside a Python program, depending on what button is |pushed. The receiver also can pick up signals from any remote, but the |program that came with the remote will only operate with this remote. I |would really like to eventually write a program that can be changed |fairly easily depending on what remote I have on hand (no need to worry |about losing the remote). | |The problem is I don't know how (or even if it is possible) to use |Python to "get" the buttons from COM2. Also, I'm not even sure what |COM2 sends when I do push a button. | |If someone can just point me in the right direction, I would be very |greatful. Of course, any other help you might want to provide would be |great as well. | | - Tim | |**I tried sending this earlier, but I don't know if it went through. If |so, please ignore my double posting.** | |_______________________________________________ |Tutor maillist - Tutor@python.org |http://mail.python.org/mailman/listinfo/tutor From rick@niof.net Sat Apr 21 03:29:18 2001 From: rick@niof.net (Rick Pasotto) Date: Fri, 20 Apr 2001 22:29:18 -0400 Subject: [Tutor] Help In-Reply-To: <Pine.LNX.4.21.0104111315370.17078-100000@mailer.cqsl.com>; from vijay.kumar@cqsl.com on Wed, Apr 11, 2001 at 01:18:31PM -0400 References: <Pine.LNX.4.21.0104111315370.17078-100000@mailer.cqsl.com> Message-ID: <20010420222918.O15213@tc.niof.net> On Wed, Apr 11, 2001 at 01:18:31PM -0400, Vijay Kumar wrote: > > Hi, > > I am beginner in Python & working on Linux. > > I have set the PYTHONSTARTUP variable to some file in the .bash_profile. Are you sure? You need to post *exactly* what you have. Little things mean a lot. > When I start python Interactively this script is not being executed > alothough the PYTHONSTARTUP variable has the value which is specified in > the .bash_profile. > > How do I set the Value in the PYTHONSTARTUP variable ??? What are you trying to accomplish? -- "The financial policy of the welfare state requires that there be no way for the owners of wealth to protect themselves. This is the shabby secret of the welfare statists' tirades against gold. Deficit spending is simply a scheme for the 'hidden' confiscation of wealth. Gold stands in the way of this insidious process. It stands as a protector of property rights." -- Alan Greenspan Rick Pasotto email: rickp@telocity.com From joejava@dragoncat.net Sat Apr 21 05:31:15 2001 From: joejava@dragoncat.net (JRicker) Date: Sat, 21 Apr 2001 00:31:15 -0400 Subject: [Tutor] Regex troubles References: <Pine.LNX.4.21.0104181402550.5265-100000@hkn.eecs.berkeley.edu> Message-ID: <003801c0ca1b$e9cfa080$d4a1d6d1@ceo> Ok I'm at wits end here and would love to hear some ideas on what I'm doing wrong here. I'm trying to match all occurances of this text in a web page: <font color="">Some Text </font> I want to be able to search for that text plus match certain keywords, and return the text between the two tags if the keyword appears anywhere in the text. Some code: keywords = "[Foobar|Some]" keyword_re = re.compile("<font color=\"\">(.*?" + keywords + ".*?)</font>", re.I | re.DOTALL) for x in re.findall(keyword_re, apage): print x where apage is a web page .read() in. Now this is returning everything between each appearance of <font color=""></font> whether the keywords match or not. Something else that struck me as odd. I tried making keywords a single word to search for (ie keywords = "Some") and my script crashed giving me an error of maximum recursion level reached. Any ideas what caused this? Thanks Joel From not@my.house Sat Apr 21 07:56:41 2001 From: not@my.house (N/A) Date: Sat, 21 Apr 2001 01:56:41 -0500 Subject: [Tutor] newbie needs simple file handling help Message-ID: <000a01c0ca30$5d603140$824643cf@devious> This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C0CA06.4F0DE8A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, i'm trying to write a program for creating and managing LARP = character sheets for a friend, I understand most of the basic syntax and = data handling needed, but I can't figure out how to open and write = strings to a text file. If it's possible could you send me the commands = and attributes for this, unfortunatley I don't have the code I have = written here and my linux box isn't online. any help is appreciated, Aaron ------=_NextPart_000_0007_01C0CA06.4F0DE8A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4207.2601" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi, i'm trying to write a program for = creating and=20 managing LARP character sheets for a friend, I understand most of the = basic=20 syntax and data handling needed, but I can't figure out how to open and = write=20 strings to a text file. If it's possible could you send me the commands = and=20 attributes for this, unfortunatley I don't have the code I have written = here and=20 my linux box isn't online.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>any help is appreciated,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Aaron</FONT></DIV></BODY></HTML> ------=_NextPart_000_0007_01C0CA06.4F0DE8A0-- From dyoo@hkn.eecs.berkeley.edu Sat Apr 21 10:36:55 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 21 Apr 2001 02:36:55 -0700 (PDT) Subject: [Tutor] please help me and I will be so happy again In-Reply-To: <006b01c0c9f1$811f7e40$998f2fc2@rsn.hkr.se> Message-ID: <Pine.LNX.4.21.0104210233500.12832-100000@hkn.eecs.berkeley.edu> On Sat, 21 Apr 2001, Anders Arvidsson wrote: > My problem is that I shall create a program that get's stock values > from a website and then saves it in a textfile, and I dont know how to > recive the stock numbers from the website... In this case, it might be easier not to work with the raw sockets, but to work with the urllib module: urllib lets us open network resources easily. For example, to read the contents of python.org's main page, we could do this: ### >>> import urllib >>> myfile = urllib.urlopen('http://www.python.org') >>> contents = myfile.read() >>> print contents[0:200] <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> <!-- Tue Apr 17 09:11:50 2001 --> <!-- USING HT2HTML 1.1 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- U >>> ### I just printed out the first 200 characters of the main page, but I hope this gives the flavor of getting at web pages. There's more information about urllib here: http://python.org/doc/current/lib/module-urllib.html From dyoo@hkn.eecs.berkeley.edu Sat Apr 21 10:52:33 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 21 Apr 2001 02:52:33 -0700 (PDT) Subject: [Tutor] Regex troubles In-Reply-To: <003801c0ca1b$e9cfa080$d4a1d6d1@ceo> Message-ID: <Pine.LNX.4.21.0104210238100.12832-100000@hkn.eecs.berkeley.edu> On Sat, 21 Apr 2001, JRicker wrote: > Ok I'm at wits end here and would love to hear some ideas on what I'm > doing wrong here. > > I'm trying to match all occurances of this text in a web page: > > <font color="">Some Text > </font> As a small note: your problem might be a little easier if you use the htmlllib module: it contains a parser that understands http documents. You can use htmllib to focus on certain tags, like font, and have it do something in response to those tags. There's some documentation on htmllib here: http://python.org/doc/current/lib/module-htmllib.html and if you want, we could cook up a quick example that uses htmllib. > Some code: > > keywords = "[Foobar|Some]" > keyword_re = re.compile("<font color=\"\">(.*?" + keywords + > ".*?)</font>", re.I | re.DOTALL) > for x in re.findall(keyword_re, apage): > print x > > where apage is a web page .read() in. Now this is returning everything > between each appearance of <font color=""></font> whether the keywords > match or not. Strange; I'm not seeing anything that would cause this to break... wait! Ah! > for x in re.findall(keyword_re, apage): > print x There's the bug! You meant to write: for x in keyword_re.findall(apage): print x instead. When we "compile" a regular expression, what we get back is a regular expression object: http://python.org/doc/current/lib/re-objects.html and it's on that object that we do the findall() methods from. What was happening before was that we were passing the whole regular expression object into re.findall(), but that's something that re.findall()'s not equipped to handle. > Something else that struck me as odd. I tried making keywords a single > word to search for (ie keywords = "Some") and my script crashed giving > me an error of maximum recursion level reached. Any ideas what caused > this? Most likely, this was a result of the weird interaction caused by passing a regular expression object into re.findall(). I wouldn't worry about it too much: see if the correction above fixes your program. If you have time, play around with htmllib too; it's not too bad, and it simplifies a lot of the work necessary to parse out HTML files. From dyoo@hkn.eecs.berkeley.edu Sat Apr 21 11:02:07 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 21 Apr 2001 03:02:07 -0700 (PDT) Subject: [Tutor] newbie needs simple file handling help In-Reply-To: <000a01c0ca30$5d603140$824643cf@devious> Message-ID: <Pine.LNX.4.21.0104210252460.12832-100000@hkn.eecs.berkeley.edu> On Sat, 21 Apr 2001, N/A wrote: > Hi, i'm trying to write a program for creating and managing LARP > character sheets for a friend, I understand most of the basic syntax > and data handling needed, but I can't figure out how to open and write > strings to a text file. If it's possible could you send me the > commands and attributes for this, unfortunatley I don't have the code > I have written here and my linux box isn't online. Here's a small program that prints out a multiplication table into the file "mult.txt": ### if __name__ == '__main__': file = open('mult.txt', 'w') for y in range(10, 0, -1): for x in range(1, 11): file.write( str(x * y) + ' ') # Alternatively: file.write('%s ' % x*y) file.write('\n') ### The documentation talks about file handling here: http://python.org/doc/current/lib/bltin-file-objects.html http://python.org/doc/current/tut/node9.html#SECTION009200000000000000000 so you can take a look at that for more of the gory details. By the way, what sort of strings are you trying to write? Tell us a little more about how the data's organized, and we can give more helpful advice. From babyboy@oninet.pt Sat Apr 21 22:53:59 2001 From: babyboy@oninet.pt (wilson edgar) Date: Sat, 21 Apr 2001 14:53:59 -0700 Subject: [Tutor] newbie needs simple file handling help References: <000a01c0ca30$5d603140$824643cf@devious> Message-ID: <001c01c0caad$9310f950$39093ad5@wcimageqci2cvz> This is a multi-part message in MIME format. ------=_NextPart_000_0017_01C0CA72.E5D92670 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable >>> filename =3D ("Somefile.txt") >>> file =3D open(filename, "a") >>> file.write("hello world") >>> file.close() basically all you need is open(filename, mode), where mode can be "r"- = read only, "w" - write only, "a", - append, so it doesn't erase the data = already in the file, it's also quite handy, because when you use it if = the file filename does not exist it will create it. hope that helped=20 wilson edgar ----- Original Message -----=20 From: N/A=20 To: tutor@python.org=20 Sent: Friday, April 20, 2001 11:56 PM Subject: [Tutor] newbie needs simple file handling help Hi, i'm trying to write a program for creating and managing LARP = character sheets for a friend, I understand most of the basic syntax and = data handling needed, but I can't figure out how to open and write = strings to a text file. If it's possible could you send me the commands = and attributes for this, unfortunatley I don't have the code I have = written here and my linux box isn't online. =20 any help is appreciated, Aaron ------=_NextPart_000_0017_01C0CA72.E5D92670 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>>>> filename =3D=20 ("Somefile.txt")<BR>>>> file =3D open(filename, = "a")<BR>>>>=20 file.write("hello world")<BR>>>> file.close()</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>basically all you need is = open(filename, mode),=20 where mode can be "r"- read only, "w" - write only, "a", - append, so it = doesn't=20 erase the data already in the file, it's also quite handy, because when = you use=20 it if the file filename does not exist it will create it.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>hope that helped </FONT></DIV> <DIV><FONT face=3DArial size=3D2>wilson edgar</FONT></DIV> <BLOCKQUOTE=20 style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: = 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A href=3D"mailto:not@my.house" title=3Dnot@my.house>N/A</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = href=3D"mailto:tutor@python.org"=20 title=3Dtutor@python.org>tutor@python.org</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, April 20, 2001 = 11:56=20 PM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] newbie needs = simple file=20 handling help</DIV> <DIV><BR></DIV> <DIV><FONT face=3DArial size=3D2>Hi, i'm trying to write a program for = creating=20 and managing LARP character sheets for a friend, I understand most of = the=20 basic syntax and data handling needed, but I can't figure out how to = open and=20 write strings to a text file. If it's possible could you send me the = commands=20 and attributes for this, unfortunatley I don't have the code I have = written=20 here and my linux box isn't online.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>any help is appreciated,</FONT></DIV> <DIV><FONT face=3DArial = size=3D2>Aaron</FONT></DIV></BLOCKQUOTE></BODY></HTML> ------=_NextPart_000_0017_01C0CA72.E5D92670-- From joejava@dragoncat.net Sat Apr 21 14:39:59 2001 From: joejava@dragoncat.net (JRicker) Date: Sat, 21 Apr 2001 09:39:59 -0400 Subject: [Tutor] Regex troubles References: <Pine.LNX.4.21.0104210238100.12832-100000@hkn.eecs.berkeley.edu> Message-ID: <001001c0ca68$919d7980$61a2d6d1@ceo> : > for x in re.findall(keyword_re, apage): : > print x : > : Strange; I'm not seeing anything that would cause this to break... wait! : Ah! : : > for x in re.findall(keyword_re, apage): : > print x Well I changed it this but it still is giving me the same results. Also, I've used the structure above for all my regexs and they work fine. This was the final part of a larger program. ?? I'll clean up my code a little and post it later for comments. Thanks Joel From aichele@mindspring.com Sat Apr 21 19:54:13 2001 From: aichele@mindspring.com (Stephen Aichele) Date: Sat, 21 Apr 2001 14:54:13 -0400 (EDT) Subject: [Tutor] transferring binary files over a network In-Reply-To: <E14qzoq-0005oD-00@mail.python.org> Message-ID: <200104211854.OAA28779@hall.mail.mindspring.net> Hello. I have a couple newby networking questions here. 1. In sending network events, I'm wondering just how they get delivered. For example, I've set up two sockets, client and server, and the client is sending a file to the server. What if the server doesn't want files larger than a certain size coming through or if it doesn't want to receive files from a particular client: how do I set up a protocol to deal with these situations?? 2. I've been tossing strings back and forth over my network connection, but now I'd like to move to binary files. I'm guessing that I'm going to have to do something like: a) open file for reading b) readlines to python variable c) send python variable over network to server d) have server parse variable (ie, if it has a header describing filetype, etc..) Does this sound about right, or am I missing something important here? thanks! Stephen From julieta_rangel@hotmail.com Sat Apr 21 20:44:37 2001 From: julieta_rangel@hotmail.com (Julieta) Date: Sat, 21 Apr 2001 14:44:37 -0500 Subject: [Tutor] functions to integrate, multiply and divide polynomials,GUI; classes and fcns. Message-ID: <OE34Oc0Ne0PaLI9mK6P00000a4c@hotmail.com> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C0CA71.96E243E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How can I write a programm that will build functions to integrate, = multiply, and divide polynomials, and test these functions? I am new at = programming so Python is my first language, therefore whatever input or = help you might offer will be truly appreciated. Write to = julieta_rangel@hotmail.com. if you have any suggestions or can help me = with this. Also, I'm trying to learn about the Graphical User Interface = (GUI) and about classes and functions. If someone can explain to me how = these work, or if someone has a program that makes use of all three and = won't mind showing it to me, I will appreciate it to the tenth. Julieta=20 ------=_NextPart_000_0005_01C0CA71.96E243E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>How can I write a programm that will = build=20 functions to integrate, multiply, and divide polynomials, and test these = functions? I am new at programming so Python is my first = language,=20 therefore whatever input or help you might offer will be truly=20 appreciated. Write to <A=20 href=3D"mailto:julieta_rangel@hotmail.com">julieta_rangel@hotmail.com</A>= . if=20 you have any suggestions or can help me with this. Also, I'm = trying to=20 learn about the Graphical User Interface (GUI) and about classes and=20 functions. If someone can explain to me how these work, = or if=20 someone has a program that makes use of all three and won't mind = showing it=20 to me, I will appreciate it to the tenth.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial = size=3D2>Julieta</FONT> </DIV></BODY></HTML> ------=_NextPart_000_0005_01C0CA71.96E243E0-- From phil.bertram@clear.net.nz Sat Apr 21 21:11:43 2001 From: phil.bertram@clear.net.nz (Phil Bertram) Date: Sun, 22 Apr 2001 08:11:43 +1200 Subject: [Tutor] E-mail format suggestions please Message-ID: <01C0CB03.F4C55F50@b001-m005-p056.acld.clear.net.nz> Hello, Off topic I know but someone may be able to help. I have been working on a little program that tracks a sports = competition. I need to E-mail weekly results to a 100 or so of people. Originally I created a table in the body of the E-mail. The table was = constructed using spaces to line up the columns. The problem is that = some recieving E-mail programs default to a proportional font. Thus = every thing goes out of line. Is their something in the MIME spec. or other, where the default font = can be specified for the recieving E-mail program? My current solution is to create the output in HTML and attatch it to = the E-mail. I am using win32com modules and Microsoft Exchange to do the E-mail part = of the program. Running NT4 Thanks in advance Phil B From dyoo@hkn.eecs.berkeley.edu Sat Apr 21 22:41:53 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 21 Apr 2001 14:41:53 -0700 (PDT) Subject: [Tutor] functions to integrate, multiply and divide polynomials,GUI; classes and fcns. In-Reply-To: <OE34Oc0Ne0PaLI9mK6P00000a4c@hotmail.com> Message-ID: <Pine.LNX.4.21.0104211417240.22784-100000@hkn.eecs.berkeley.edu> On Sat, 21 Apr 2001, Julieta wrote: > How can I write a programm that will build functions to integrate, > multiply, and divide polynomials, and test these functions? I am new > at programming so Python is my first language, therefore whatever Hello! How much do you know about programming already? It sounds like you're just starting off, so some of the suggestions we can give might not make much sense for a while. Also, as we talked about on python-help, because this sounds like a homework assignment, we cannot help you directly; we can only direct you toward things that might help you. Believe us: it's not because we want to be mean, but because the point of the work is for you to figure out how the pieces come together. Have you tried one of the Python tutorials yet? They're made to help you learn how effectively use the language. Many of them are located here: http://python.org/doc/Intros.html and the one that you'll want to look at is Alan Gauld's "Learning To Program": http://www.crosswinds.net/~agauld/ Alan frequents this mailing list, so if the tutorial is confusing, you have at least one person here who knows what he's talking about. *grin* One thing that helps is to try doing a lot of examples of polynomial multiplication "by hand", and think about what kind of "procedure" you're running internally in your head. A lot of programming deals with trying to capture these ideas into a form that's extraordinarily unambiguous, and it does take some practice to do this. This is admittedly hard, so try simpler problems first, and you'll build up this skill. > input or help you might offer will be truly appreciated. Write to > julieta_rangel@hotmail.com. if you have any suggestions or can help me > with this. Also, I'm trying to learn about the Graphical User > Interface (GUI) and about classes and functions. If someone can > explain to me how these work, or if someone has a program that makes > use of all three and won't mind showing it to me, I will appreciate it > to the tenth. You might want to look at Useless Python, a web site that collects bits of Python programs. If you'd like to see examples of Python programs, Useless Python is a good resource: http://www.lowerstandard.com/python/pythonsource.html About classes: Alan Gauld's tutorial talks about Object Oriented Programming (OOP), and you can learn about classes there. It's a slightly advanced topic, so I'd recommend putting it on hold until you learn about how to write functions in Python. GUI programming is handled by a module called Tkinter, and you can learn more about Tkinter here: http://python.org/topics/tkinter/ However, the material there might be a little dense, so feel free to ask us questions about how to work with Tkinter. Good luck to you. From sheila@thinkspot.net Sun Apr 22 01:20:30 2001 From: sheila@thinkspot.net (Sheila King) Date: Sat, 21 Apr 2001 17:20:30 -0700 Subject: [Tutor] Creating files inside a script Message-ID: <6C220FB41AB@kserver.org> OK, I'm so confused right now... I've been going through docs, and experimenting, and my experiments seem to contradict each other from one time to the next. I'll tell you one thing, after I post this message, I am definitely going to go take a break! OK, as far as creating files...let's just assume that I have the name of the file I want to work with hard-coded into my script. If I do f = open(filename, 'w') It will create the file, if it does not already exist, otherwise it will truncate an existing file, losing all previously existing data. How does this compare with f = open(filename, 'w+') ??? And then, if I do f = open(filename, 'a') and the file already exists, this will simply append new text written to the file to the end of the already existing stuff. What if the file doesn't already exist? I thought, it would create the file. But, it seemed at some points today, as though I was getting IOErrors, for being unable to open the file, because it did not already exist, when using an append command like the one shown above. I was getting error messages in the webserver's cgi script error logs like this: File "gypsymail.py", line 117, in PrintErrorToLogFile logfile = open(logfilename, 'a+') IOError: (2, 'No such file or directory') So, then I think, "No, if the file doesn't exist already, opening in mode 'a' doesn't work..." HOWEVER, I just deleted my special logfile, caused an error, and it created the file for me. How does opening in 'a' mode compare to opening in 'a+' mode? If anyone could clear up this confusion for me, I'd be most grateful. Looked at too many docs today... -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dyoo@hkn.eecs.berkeley.edu Sun Apr 22 03:54:19 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 21 Apr 2001 19:54:19 -0700 (PDT) Subject: [Tutor] Creating files inside a script In-Reply-To: <6C220FB41AB@kserver.org> Message-ID: <Pine.LNX.4.21.0104211929150.27304-100000@hkn.eecs.berkeley.edu> On Sat, 21 Apr 2001, Sheila King wrote: > I've been going through docs, and experimenting, and my experiments > seem to contradict each other from one time to the next. I'll tell you > one thing, after I post this message, I am definitely going to go take > a break! No problem; that happens to me too. It stopped raining yesterday, and it was a gorgeous day for a walk... About the modes that open() can take in: the problem is that open() is a wrapper around the C function fopen(), which means that it's not quite as well documented as the rest of the Python functions. Doing a "man fopen" on my Linux system gives some detail to what all these modes mean: ### Documentation for C's fopen(): --- r Open text file for reading. The stream is positioned at the beginning of the file. r+ Open for reading and writing. The stream is positioned at the beginning of the file. w Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. w+ Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file. a Open for writing. The file is created if it does not exist. The stream is positioned at the end of the file. a+ Open for reading and writing. The file is created if it does not exist. The stream is positioned at the end of the file. ### Whew. One caveat: Python's append plus "a+" mode behaves differently from C's "a+" mode. Here's what the Python reference manual says: "Modes 'r+', 'w+' and 'a+' open the file for updating... If the file cannot be opened, IOError is raised." http://python.org/doc/current/lib/built-in-funcs.html We'll talk about this later in this message. > OK, as far as creating files...let's just assume that I have the name of the > file I want to work with hard-coded into my script. > > If I do > > f = open(filename, 'w') > It will create the file, if it does not already exist, otherwise it will > truncate an existing file, losing all previously existing data. > > How does this compare with > f = open(filename, 'w+') ??? In "w+" mode, the file can also be used for reading as well: we're allowed to do read() calls on it. All of the "plus" modes allow reading and writing: the main difference between them is where we're positioned in the file. "r+" puts us at the beginning. "w+" puts us at the beginning and, technically, the end, because the file's truncated. "a+" puts us at the end. > f = open(filename, 'a') > and the file already exists, this will simply append new text written to the > file to the end of the already existing stuff. > What if the file doesn't already exist? I thought, it would create the file. > But, it seemed at some points today, as though I was getting IOErrors, for > being unable to open the file, because it did not already exist, when using an In C, it would have been ok. However, the Python docs appear to say that if the files don't exist, it'll throw off an IOError. I wonder why they made the behavior different than from C... In any case, that's why the IOErrors are popping up. In summary, it appears that all '+' modes allow reading and writing. However, you're right that this is a little confusing: it FEELS inconsistant how the Python implementors have done this: ### ## Assume that foo1.txt, foo2.txt, and foo3.txt don't exist in the ## current directory. >>> open('foo1.txt', 'r+') Traceback (most recent call last): File "<stdin>", line 1, in ? IOError: [Errno 2] No such file or directory: 'foo1.txt' >>> open('foo2.txt', 'a+') <open file 'foo2.txt', mode 'a+' at 0x80e6c80> >>> open('foo3.txt', 'w+') <open file 'foo3.txt', mode 'w+' at 0x80e2798> ### *sigh* So the updating append, "a+", appears to be a special case that's not symmetric: "a+" will assume that the file exists, but if it doesn't, it raises an IOError. Perhaps this is a bug though; we should ask one of the Python implementors why "a+" is a special case. Now I need to take a break. *grin* From dyoo@hkn.eecs.berkeley.edu Sun Apr 22 04:34:03 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 21 Apr 2001 20:34:03 -0700 (PDT) Subject: [Tutor] Creating files inside a script [I made a mistake!] In-Reply-To: <Pine.LNX.4.21.0104211929150.27304-100000@hkn.eecs.berkeley.edu> Message-ID: <Pine.LNX.4.21.0104212023340.28796-100000@hkn.eecs.berkeley.edu> My gosh, I have to apologize for not reading things properly. I made a terrible mistake in misreading the docs, so I'd better make things right, before I cause more confusion. According to C's fopen(): > r+ Open for reading and writing. The stream is positioned at the > beginning of the file. > > a+ Open for reading and writing. The file is created if it does not > exist. The stream is positioned at the end of the file. What I said, incorrectly, was: > Whew. One caveat: Python's append plus "a+" mode behaves differently from > C's "a+" mode. But it doesn't! It does behave the same as C's fopen(). I can't explain why I misread the documentation like that. > *sigh* So the updating append, "a+", appears to be a special case that's > not symmetric: "a+" will assume that the file exists, but if it doesn't, > it raises an IOError. Perhaps this is a bug though; we should ask one of > the Python implementors why "a+" is a special case. I meant to talk about "r+", not "a+". I don't know why I insisted on talking about append, when it's "r+" that causes the IOError. I apologize about this error again. In retrospect, it makes sense why "r+" is one that raises IOError: it means that we're assuming that the file exists and is good for reading and writing. But like the regular "r" mode, if the file isn't there, then it will raise an IOError. Now I really DO need to take a break. *sigh* From mark21rowe@yahoo.com Sun Apr 22 06:02:46 2001 From: mark21rowe@yahoo.com (Mark Rowe) Date: Sun, 22 Apr 2001 17:02:46 +1200 Subject: [Tutor] E-mail format suggestions please References: <01C0CB03.F4C55F50@b001-m005-p056.acld.clear.net.nz> Message-ID: <008501c0cae9$a9e016c0$7a849aca@hhyd> I think it would be a good idea to use the MimeWriter and smtplib modules to build and send the message with, as you mentioned, an attached HTML table. This would then avoid having to use COM. Some example code is below. Mark Rowe --- Example Code --- import sys, smtplib, MimeWriter, base64, StringIO message = StringIO.StringIO() writer = MimeWriter.MimeWriter(message) writer.addheader('Subject', 'The kitten picture') writer.startmultipartbody('mixed') # start off with a text/plain part part = writer.nextpart() body = part.startbody('text/plain') body.write('This is a picture of a kitten, enjoy :)') # now add an image part part = writer.nextpart() part.addheader('Content-Transfer-Encoding', 'base64') body = part.startbody('image/jpeg') base64.encode(open('kitten.jpg', 'rb'), body) # finish off writer.lastpart() # send the mail smtp = smtplib.SMTP('smtp.server.address') smtp.sendmail('from@from.address', 'to@to.address', message.getvalue()) smtp.quit() ----- Original Message ----- From: "Phil Bertram" <phil.bertram@clear.net.nz> To: <tutor@python.org> Sent: Sunday, April 22, 2001 8:11 AM Subject: [Tutor] E-mail format suggestions please Hello, Off topic I know but someone may be able to help. I have been working on a little program that tracks a sports competition. I need to E-mail weekly results to a 100 or so of people. Originally I created a table in the body of the E-mail. The table was constructed using spaces to line up the columns. The problem is that some recieving E-mail programs default to a proportional font. Thus every thing goes out of line. Is their something in the MIME spec. or other, where the default font can be specified for the recieving E-mail program? My current solution is to create the output in HTML and attatch it to the E-mail. I am using win32com modules and Microsoft Exchange to do the E-mail part of the program. Running NT4 Thanks in advance Phil B _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From pursang@interact.net.au Sun Apr 22 17:01:47 2001 From: pursang@interact.net.au (John Murray) Date: Sun, 22 Apr 2001 16:01:47 +0000 Subject: [Tutor] destroying a window in tkinter Message-ID: <01042216014700.01806@localhost.localdomain> What's the best way to destroy a toplevel and it's children in tkinter? The toplevel is called up as part of a function rather than a class. This is my first (clumsy) attempt at tkinter - maybe I should stick to the good 'ol command line :) Cheers, Johnno. From xxcrisxx@tiscalinet.it Sun Apr 22 06:45:07 2001 From: xxcrisxx@tiscalinet.it (cris) Date: Sun, 22 Apr 2001 07:45:07 +0200 Subject: [Tutor] Re: well... this is not a real program Message-ID: <002201c0caef$631e52a0$32570a3e@b4z2a3> THE EVOLUTION OF A PROGRAMMER High School/Jr.High 10 PRINT "HELLO WORLD" 20 END First year in College program Hello(input, output) begin writeln('Hello World') end. Senior year in College (defun hello (print (cons 'Hello (list 'World)))) New professional #include void main(void) { char *message[] = {"Hello ", "World"}; int i; for(i = 0; i < 2; ++i) printf("%s", message[i]); printf("\n"); } Seasoned professional #include #include class string { private: int size; char *ptr; public: string() : size(0), ptr(new char('\0')) {} string(const string &s) : size(s.size) { ptr = new char[size + 1]; strcpy(ptr, s.ptr); } ~string() { delete [] ptr; } friend ostream &operator <<(ostream &, const string &); string &operator=(const char *); }; ostream &operator<<(ostream &stream, const string &s) { return(stream << s.ptr); } string &string::operator=(const char *chrs) { if (this != &chrs) { delete [] ptr; size = strlen(chrs); ptr = new char[size + 1]; strcpy(ptr, chrs); } return(*this); } int main() { string str; str = "Hello World"; cout << str << endl; return(0); } System Administrator #include main() { char *tmp; int i=0; /* on y va bourin */ tmp=(char *)malloc(1024*sizeof(char)); while (tmp[i]="Hello Wolrd"[i++]); /* Ooopps y'a une infusion ! */ i=(int)tmp[8]; tmp[8]=tmp[9]; tmp[9]=(char)i; printf("%s\n",tmp); } Apprentice Hacker #!/usr/local/bin/perl $msg="Hello, world.\n"; if ($#ARGV >= 0) { while(defined($arg=shift(@ARGV))) { $outfilename = $arg; open(FILE, ">" . $outfilename) || die "Can't write $arg: $!\n"; print (FILE $msg); close(FILE) || die "Can't close $arg: $!\n"; } } else { print ($msg); } 1; Experienced Hacker #include #define S "Hello, World\n" main(){exit(printf(S) == strlen(S) ? 0 : 1);} Seasoned Hacker % cc -o a.out ~/src/misc/hw/hw.c % a.out Guru Hacker % cat Hello, world. ^D New Manager 10 PRINT "HELLO WORLD" 20 END Middle Manager mail -s "Hello, world." bob@b12 Bob, could you please write me a program that prints "Hello, world."? I need it by tomorrow. ^D Senior Manager % zmail jim I need a "Hello, world." program by this afternoon. Chief Executive % letter letter: Command not found. % mail To: ^X ^F ^C % help mail help: Command not found. % damn! !: Event unrecognized % logout From rusddf@yahoo.com Fri Apr 20 23:13:48 2001 From: rusddf@yahoo.com (Sergey) Date: Sat, 21 Apr 2001 01:13:48 +0300 Subject: [Tutor] ÄÂÅ e-mail áàçû íà îäíîì CD-äèñêå Message-ID: <029bf3609211641SERVER@server> Çäðàâñòâóéòå! Ïðåäëàãàåì ïðèîáðåñòè Âàì ÄÂÅ e-mail áàçû íà îäíîì CD-äèñêå çà 1000 ðóáëåé. Âñå Email Ìîñêâû - 42.000 àäðåñîâ (ôèðìû + 19.500 áåç ðàçáèâêè). Îáñëóæèâàíèå_àãåíòñòâà_íîâîñòåé153 Îáñëóæèâàíèå_àóäèò173 Îáñëóæèâàíèå_ãîñòèíèöû69 Îáñëóæèâàíèå_èçäàòåëüñòâà662 Îáñëóæèâàíèå_êóëüòóðà360 Îáñëóæèâàíèå_ìåäèöèíà_ñïîðò365 Îáñëóæèâàíèå_íàóêà352 Îáñëóæèâàíèå_îáó÷åíèå513 Îáñëóæèâàíèå_îáùåïèò93 Îáñëóæèâàíèå_îõðàííûå298 Îáñëóæèâàíèå_ïðåññà819 Îáñëóæèâàíèå_ïðîãðàììèðîâàíèå579 Îáñëóæèâàíèå_ïðîèçâîäñòâî553 Îáñëóæèâàíèå_ðàçíîå418 Îáñëóæèâàíèå_ðåêëàìà1041 Îáñëóæèâàíèå_ðåìîíò404 Îáñëóæèâàíèå_ñâÿçü726 Îáñëóæèâàíèå_ñêëàäû41 Îáñëóæèâàíèå_ñòðîèòåëüñòâî359 Îáñëóæèâàíèå_òåëåðàäèî129 Îáñëóæèâàíèå_òðàíñïîðò605 Îáñëóæèâàíèå_òðóäîóñòðîéñòâî249 Îáñëóæèâàíèå_òóðèçì1377 Îáñëóæèâàíèå_þðèäè÷åñêèå438 Ïðî÷åå_áàíêè579 Ïðî÷èå_ãîññòðóêòóðû323 Ïðî÷èå_èíâåñòèöèîííûå225 Ïðî÷èå_èíîôèðìû240 Ïðî÷èå_êîíñàëòèíã235 Ïðî÷èå_îáùåñòâåííûå_îðãàíèçàöèè268 Ïðî÷èå_ïîñîëüñòâà45 Ïðî÷èå_ñòðàõîâûå126 Òîðãîâëÿ_àâòîìîáèëè_çàï÷àñòè1141 òîðãîâëÿ_àïòåêè16 Òîðãîâëÿ_áûòîâûå_òîâàðû511 Òîðãîâëÿ_äåòñêèå_òîâàðû195 Òîðãîâëÿ_ìåáåëü273 Òîðãîâëÿ_ìåäèöèíñêèå_òîâàðû405 Òîðãîâëÿ_íåäâèæèìîñòü829 Òîðãîâëÿ_îáîðóäîâàíèå1821 Òîðãîâëÿ_îáóâü33 Òîðãîâëÿ_îäåæäà159 Òîðãîâëÿ_îïòîâàÿ_îäåæäà42 Òîðãîâëÿ_îïòîâàÿ_ïðîäóêòû519 Òîðãîâëÿ_îïòîâàÿ_ïðîìòîâàðû104 Òîðãîâëÿ_îðãòåõíèêà1256 Òîðãîâëÿ_îõðàííîå169 Òîðãîâëÿ_ïàðôþìåðèÿ118 Òîðãîâëÿ_ïðîäóêòû164 Òîðãîâëÿ_ðàçíîå639 Òîðãîâëÿ_ñïîðòòîâàðû75 Òîðãîâëÿ_ñòðîéìàòåðèàëû805 Òîðãîâëÿ_ÒÍÏ217 Òîðãîâëÿ_õîçòîâàðû162 Òîðãîâëÿ_ýêñïîðò_èìïîðò45 E-mail áàçà "Âñÿ Ðîññèÿ" Áàçà ñîäåðæèò 340 òûñÿ÷ àäðåñîâ (èç íèõ îêîëî 30% - àäðåñà îðãàíèçàöèé). Âñå àäðåñà ïðåäâàðèòåëüíî ïðîâåðåíû ñ ïîìîùüþ ñïåöèàëüíîé ïðîãðàììû â ôåâðàëå 2001 ã. è ðåàëüíî ñóùåñòâóþò. Áàçà â âèäå 14 txt ôàéëà c ïåðå÷íåì å-ìàéëîâ. Ïðèëàãàåòñÿ ïðîãðàììà äëÿ ìàññîâîé ðàññûëêè + îïèñàíèå ïî ïîëüçîâàíèþ. Áàçà ïðåäíàçíà÷åíà äëÿ ìàññîâîé ðàññûëêè ðåêëàìû òîâàðîâ, ñàéòîâ, êîììåð÷åñêèõ ïðåäëîæåíèé è ò.ï. Îïëàòà: ïî Ìîñêâå íàëè÷íûìè êóðüåðó Ïðîñèì ñîîáùàòü Âàøè êîíòàêòíûå òåëåôîíû. From syrinx@simplecom.net Mon Apr 23 02:39:00 2001 From: syrinx@simplecom.net (Scott) Date: Sun, 22 Apr 2001 20:39:00 -0500 Subject: [Tutor] portability Message-ID: <dp17etoqimm5i0u3re8u86ek0snn359n68@4ax.com> Can anyone point me to a website that offers tips on writing Python programs that will run (succesfully :) on Linux and Windows? From sheila@thinkspot.net Mon Apr 23 07:01:50 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 22 Apr 2001 23:01:50 -0700 Subject: [Tutor] Creating files inside a script [I made a mistake!] In-Reply-To: <Pine.LNX.4.21.0104212023340.28796-100000@hkn.eecs.berkeley.edu> References: <Pine.LNX.4.21.0104211929150.27304-100000@hkn.eecs.berkeley.edu> <Pine.LNX.4.21.0104212023340.28796-100000@hkn.eecs.berkeley.edu> Message-ID: <4C3F3982409@kserver.org> Thanks, Daniel, for your replies. On Sat, 21 Apr 2001 20:34:03 -0700 (PDT), Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> wrote about Re: [Tutor] Creating files inside a script [I made a mistake!]: :I meant to talk about "r+", not "a+". I don't know why I insisted on :talking about append, when it's "r+" that causes the IOError. I apologize :about this error again. : : :In retrospect, it makes sense why "r+" is one that raises IOError: it :means that we're assuming that the file exists and is good for reading and :writing. But like the regular "r" mode, if the file isn't there, then it :will raise an IOError. This is how I would have thought things work, and that is obviously what the docs say. But, then I just don't get why I was getting this error: File "gypsymail.py", line 117, in PrintErrorToLogFile logfile = open(logfilename, 'a+') IOError: (2, 'No such file or directory') In any case, the script seems to be working fine, now. I changed that line of my program to logfile = open(logfilename, 'a') since I'm only going to write to the file, anyway, and I don't need the a+ functionality. It now seems to create the file, when the file doesn't already exist. Beats me, what the problem was before. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dyoo@hkn.eecs.berkeley.edu Mon Apr 23 07:48:57 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 22 Apr 2001 23:48:57 -0700 (PDT) Subject: [Tutor] Creating files inside a script [I made a mistake!] In-Reply-To: <4C3F3982409@kserver.org> Message-ID: <Pine.LNX.4.21.0104222336410.27775-100000@hkn.eecs.berkeley.edu> On Sun, 22 Apr 2001, Sheila King wrote: > :In retrospect, it makes sense why "r+" is one that raises IOError: it > :means that we're assuming that the file exists and is good for reading and > :writing. But like the regular "r" mode, if the file isn't there, then it > :will raise an IOError. > > This is how I would have thought things work, and that is obviously what the > docs say. But, then I just don't get why I was getting this error: > > File "gypsymail.py", line 117, in PrintErrorToLogFile > logfile = open(logfilename, 'a+') > IOError: (2, 'No such file or directory') Very strange... It sounds like it might be something platform dependent, because Python's open() is definitely using the C version of fopen() that your system provides. If you can tell us what kind of system you're on, we can verify that it's a platform-specific issue. The Python docs hint as much when they talk about how append might be wacky under certain Unices. http://python.org/doc/current/lib/built-in-funcs.html "... and 'a' opens it for appending (which on some Unix systems means that all writes append to the end of the file, regardless of the current seek position)." Go figure. > In any case, the script seems to be working fine, now. I changed that line of > my program to > logfile = open(logfilename, 'a') > > since I'm only going to write to the file, anyway, and I don't need > the a+ functionality. It now seems to create the file, when the file > doesn't already exist. Beats me, what the problem was before. If we still want "a+" behavior, and have it do it nicely, we can write a small wrapper function that does the same thing as open(), but test things out: ### def safe_aplus_open(filename): """A "permissive" style open() for mode "a+". It appears that on some Unices, if the file doesn't exist, we run into IOErrors. This function will try to open it with "a+", and if it fails, creates the file, and tries again. """ try: return open(filename, "a+") except IOError: open(filename, "w") return open(filename, "a+") ### I wonder if there's a better way to do this. Until then, if you need "a+", this function should make things nicer. By the way, have you been able to find a Python user's group in SoCal? Just curious. Good luck! From rob@jam.rr.com Mon Apr 23 12:32:27 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Mon, 23 Apr 2001 06:32:27 -0500 Subject: [Tutor] portability References: <dp17etoqimm5i0u3re8u86ek0snn359n68@4ax.com> Message-ID: <3AE412CB.706E47B7@jam.rr.com> I don't know of a single website I'd recommend for cross-platform Python scripting, because just about every Python script I've tried running on both platforms did what it was supposed to. If you go through a tutorial or two, you may find one that tells you about the special line you can put in your script on the first line that tells it where to find the Python interpreter on a Linux box. This line may be left in place when the script is run on Windows, since it's then interpreted as just a comment line. I get the impression that many of the differences in coding for the two platforms can be somewhat esoteric, but that you often get into the differences when you import modules designed to work with one OS or the other (such as if you wanted to work with COM or something in Windows. Did you have any particular sorts of scripts in mind? In case it helps, here's my list of links (no operating system preference): http://www.lowerstandard.com/python/pythonlinks.html Rob Scott wrote: > > Can anyone point me to a website that offers tips on writing Python > programs that will run (succesfully :) on Linux and Windows? > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From rob@jam.rr.com Mon Apr 23 12:33:36 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Mon, 23 Apr 2001 06:33:36 -0500 Subject: [Tutor] portability References: <dp17etoqimm5i0u3re8u86ek0snn359n68@4ax.com> Message-ID: <3AE41310.F7174B0F@jam.rr.com> I don't know of a single website I'd recommend for cross-platform Python scripting, because just about every Python script I've tried running on both platforms did what it was supposed to. If you go through a tutorial or two, you may find one that tells you about the special line you can put in your script on the first line that tells it where to find the Python interpreter on a Linux box. This line may be left in place when the script is run on Windows, since it's then interpreted as just a comment line. I get the impression that many of the differences in coding for the two platforms can be somewhat esoteric, but that you often get into the differences when you import modules designed to work with one OS or the other (such as if you wanted to work with COM or something in Windows. Did you have any particular sorts of scripts in mind? In case it helps, here's my list of links (no operating system preference): http://www.lowerstandard.com/python/pythonlinks.html Rob Scott wrote: > > Can anyone point me to a website that offers tips on writing Python > programs that will run (succesfully :) on Linux and Windows? > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From thomas.pletl@system-integration.de Mon Apr 23 17:24:06 2001 From: thomas.pletl@system-integration.de (Thomas Pletl) Date: Mon, 23 Apr 2001 18:24:06 +0200 Subject: [Tutor] PIL, text rendering and Mac Message-ID: <B70A23C6.B01%thomas.pletl@system-integration.de> Has anyone used the Python imaging library (PIL) on a Mac before? What I am trying to do is to setup a script that takes text input (from a Web page for example) and then renders the text to a bitmap. As far as I understand it, PIL uses fonts in the BDF format with which I am not familiar. Is there a way to get these fonts for Mac? Also I can't seem to get the pilfont.py script to run - the window's bar simply tells me "terminated" after starting the script. Alternatively is there a way to get the gd-library (+freetype) running with Python (I know gd is not available for the Mac, but I already have a little of experience with gd on Linux and that would make migrating easier for me). Thanks! Thomas From Aedin@chah.ucc.ie Mon Apr 23 18:10:54 2001 From: Aedin@chah.ucc.ie (Aedin Culhane) Date: Mon, 23 Apr 2001 18:10:54 +0100 (BST) Subject: [Tutor] Re: Tutor digest, Vol 1 #741 - 6 msgs In-Reply-To: <E14rilt-000654-00@mail.python.org> Message-ID: <Pine.OSF.3.96.1010423180651.13756C-100000@chah.ucc.ie> Dear Tutor My apologies to those subscribed to comp.lang.python, as I have posted my request there last week, but as yet have no response. As I am hitting a blank wall, I would be really really grateful of your help. I am trying to get idle working on Tru64 5.1 Unix running Python 2.1, but tkinter can not be imported. tcl/tk seems to be installed already. I am trying to follow the instructions in http://www.python.org/topics/tkinter/trouble.html. "which tcl" gives /usr/bin/tcl The files tcl.h and tk.h exist in /usr/include/ and list the version numbers of tcl and tk as 8.2. However there are no tcl/tk lib files, libtcl"version".a or libtk"version".a in /usr/lib or /usr/local/lib. There is a tcl directory in /usr/lib, but these files do not have the .a extension... am I looking in the wrong place? Equally I am not sure whether if the X11 libraries are /usr/lib/X11. Also do I need the Tix, BLT, PIL, TOGL or AIX libraries. Thanks a million for your help, Best wishes Aedin -------------------------------- Aedin Culhane Bioinformatics Group Biochemistry Department University College Cork Cork, Ireland From scarblac@pino.selwerd.nl Mon Apr 23 17:49:55 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Mon, 23 Apr 2001 18:49:55 +0200 Subject: [Tutor] Re: Tutor digest, Vol 1 #741 - 6 msgs In-Reply-To: <Pine.OSF.3.96.1010423180651.13756C-100000@chah.ucc.ie>; from Aedin@chah.ucc.ie on Mon, Apr 23, 2001 at 06:10:54PM +0100 References: <E14rilt-000654-00@mail.python.org> <Pine.OSF.3.96.1010423180651.13756C-100000@chah.ucc.ie> Message-ID: <20010423184955.A30750@pino.selwerd.nl> On 0, Aedin Culhane <Aedin@chah.ucc.ie> wrote: > Dear Tutor > My apologies to those subscribed to comp.lang.python, as I have posted my > request there last week, but as yet have no response. As I am hitting a > blank wall, I would be really really grateful of your help. > > I am trying to get idle working on Tru64 5.1 Unix running Python 2.1, but > tkinter can not be imported. tcl/tk seems to be installed already. I am > trying to follow the instructions in > http://www.python.org/topics/tkinter/trouble.html. > > "which tcl" gives /usr/bin/tcl > > The files tcl.h and tk.h exist in /usr/include/ and list the version > numbers of tcl and tk as 8.2. > > However there are no tcl/tk lib files, libtcl"version".a or > libtk"version".a in /usr/lib or /usr/local/lib. There is a tcl directory > in /usr/lib, but these files do not have the .a extension... am I looking > in the wrong place? Equally I am not sure whether if the X11 libraries are > /usr/lib/X11. I'm not familiar with AIX. It's quite possible that noone on this list is. You'll have better luck on the main Python list (or comp.lang.python, which is the same thing). Are there any libtcl* files there? Or try to find them somewhere else. If you have a working find command, find / -name 'libtcl*' -print should find them eventually. If there are no libs, tcl/tk isn't installed completely. There's a tiny chance that AIX names libraries some other way, do the other files in /usr/lib have names like libwhee.a or .so? -- Remco Gerlich From deirdre@deirdre.net Mon Apr 23 18:11:04 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Mon, 23 Apr 2001 10:11:04 -0700 Subject: [Tutor] portability In-Reply-To: <3AE41310.F7174B0F@jam.rr.com> References: <dp17etoqimm5i0u3re8u86ek0snn359n68@4ax.com> Message-ID: <l03130307b70a123ffbef@[10.0.1.10]> At 6:33 AM -0500 4/23/01, rob@jam.rr.com wrote: >I don't know of a single website I'd recommend for cross-platform Python >scripting, because just about every Python script I've tried running on >both platforms did what it was supposed to. Agreed. I used to work for searchbutton.com as a python coder and, while I worked on Linux, some stuff was also deployed on Windows NT and seemed to work fine. The differences seemed to be mostly in stuff like thread support. My experiment for the day, btw, is trying to set up Jython on MacOS X and seeing if I can use it with Interface Builder and Project Builder. -- _Deirdre NEW Stash-o-Matic: http://fuzzyorange.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From cwebster@nevada.edu Mon Apr 23 18:41:47 2001 From: cwebster@nevada.edu (Corran Webster) Date: Mon, 23 Apr 2001 10:41:47 -0700 Subject: [Tutor] PIL, text rendering and Mac In-Reply-To: <B70A23C6.B01%thomas.pletl@system-integration.de> References: <B70A23C6.B01%thomas.pletl@system-integration.de> Message-ID: <f05001900b70a167bd93a@[131.216.77.14]> At 6:24 PM +0200 23/4/01, Thomas Pletl wrote: >Has anyone used the Python imaging library (PIL) on a Mac before? > >What I am trying to do is to setup a script that takes text input (from a >Web page for example) and then renders the text to a bitmap. As far as I >understand it, PIL uses fonts in the BDF format with which I am not >familiar. Is there a way to get these fonts for Mac? Also I can't seem to >get the pilfont.py script to run - the window's bar simply tells me >"terminated" after starting the script. This sounds as though the program has successfully run - PIL doesn't output to the screen, and if you haven't saved the image to a file in the program, you'll have no way of viewing the image. >Alternatively is there a way to get the gd-library (+freetype) running with >Python (I know gd is not available for the Mac, but I already have a little >of experience with gd on Linux and that would make migrating easier for me). You might want to look at Sping/Piddle (http://piddle.sourceforge.net) which is a consistent graphical drawing environment to a bunch of different backends, including PIL and Quickdraw in the IDE. This allows you to test the output interactively in the IDE, then switch over the backend to get output in the formats that PIL supports. Although I've not tested the fonts recently, but I've been using it successfully for drawing graphs for my classes on the Mac. Regards, Corran From phil.bertram@clear.net.nz Mon Apr 23 19:44:38 2001 From: phil.bertram@clear.net.nz (Phil Bertram) Date: Tue, 24 Apr 2001 06:44:38 +1200 Subject: [Tutor] E-mail format suggestions please Message-ID: <01C0CC8A.0BBBBCE0@b002-m002-p006.acld.clear.net.nz> ---------- From: Mark Rowe Sent: Sunday, 22 April 2001 05:02=20 To: Phil Bertram; tutor@python.org Subject: Re: [Tutor] E-mail format suggestions please I think it would be a good idea to use the MimeWriter and smtplib = modules to build and send the message with, as you mentioned, an attached HTML = table. This would then avoid having to use COM. I have briefly exprimented with smtplib. I switched to COM (MS Exchange) = for two reasons. 1/. I want to save messages in an offline mailbox and transfer all at = once as I only have a dial-up connection. 2/. I want to check that all is correct before I send. (You see I still = can't believe that I have got so far with my little project and don't = fully trust my programming skills) Otherwise I think you have pointed me in the write direction by using = 'Encoding' types to control how the recieving E-mail program displays a = message. Mark Rowe --- Example Code --- import sys, smtplib, MimeWriter, base64, StringIO message =3D StringIO.StringIO() writer =3D MimeWriter.MimeWriter(message) writer.addheader('Subject', 'The kitten picture') writer.startmultipartbody('mixed') # start off with a text/plain part part =3D writer.nextpart() body =3D part.startbody('text/plain') body.write('This is a picture of a kitten, enjoy :)') # now add an image part part =3D writer.nextpart() part.addheader('Content-Transfer-Encoding', 'base64') body =3D part.startbody('image/jpeg') base64.encode(open('kitten.jpg', 'rb'), body) # finish off writer.lastpart() # send the mail smtp =3D smtplib.SMTP('smtp.server.address') smtp.sendmail('from@from.address', 'to@to.address', message.getvalue()) smtp.quit() ----- Original Message ----- From: "Phil Bertram" <phil.bertram@clear.net.nz> To: <tutor@python.org> Sent: Sunday, April 22, 2001 8:11 AM Subject: [Tutor] E-mail format suggestions please Hello, Off topic I know but someone may be able to help. I have been working on a little program that tracks a sports = competition. I need to E-mail weekly results to a 100 or so of people. Originally I created a table in the body of the E-mail. The table was constructed using spaces to line up the columns. The problem is that = some recieving E-mail programs default to a proportional font. Thus every = thing goes out of line. Is their something in the MIME spec. or other, where the default font = can be specified for the recieving E-mail program? My current solution is to create the output in HTML and attatch it to = the E-mail. I am using win32com modules and Microsoft Exchange to do the E-mail part = of the program. Running NT4 Thanks in advance Phil B _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor From ssinha@sageware.com Mon Apr 23 22:25:37 2001 From: ssinha@sageware.com (Shefali Sinha) Date: Mon, 23 Apr 2001 14:25:37 -0700 Subject: [Tutor] pasting using ctrl-V Message-ID: <8B92E681D1EDD411A3D000B0D03D5B9308AA82@MERCURY> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C0CC3B.F06A29C0 Content-Type: text/plain; charset="iso-8859-1" Hi, I have created a UI using tkinter to run on WinNT platform. I'm using tkSimpleDialog to get a user entry. When I paste text in this box using ctrl-v, it works. When its ctrl-V, it does nothing. How can I fix this? Thanks. -Shefali ------_=_NextPart_001_01C0CC3B.F06A29C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Diso-8859-1"> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2653.12"> <TITLE>pasting using ctrl-V</TITLE> </HEAD> <BODY> <P><FONT SIZE=3D2 FACE=3D"Arial">Hi,</FONT> </P> <P><FONT SIZE=3D2 FACE=3D"Arial">I have created a UI using tkinter to = run on WinNT platform. I'm using tkSimpleDialog to get a user entry. = When I paste text in this box using ctrl-v, it works. When its ctrl-V, = it does nothing. How can I fix this?</FONT></P> <P><FONT SIZE=3D2 FACE=3D"Arial">Thanks.</FONT> <BR><FONT SIZE=3D2 FACE=3D"Arial">-Shefali</FONT> </P> </BODY> </HTML> ------_=_NextPart_001_01C0CC3B.F06A29C0-- From babyboy@oninet.pt Tue Apr 24 07:41:36 2001 From: babyboy@oninet.pt (wilson edgar) Date: Mon, 23 Apr 2001 23:41:36 -0700 Subject: [Tutor] COM compliant scripting engine Message-ID: <000801c0cc89$9cdc8f20$640c3ad5@wcimageqci2cvz> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C0CC4E.EFBA1900 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hiya=20 where can i find some COM compliant scripting engine, in order to use = Python as my scripting language in IIS. thanks in advance ------=_NextPart_000_0005_01C0CC4E.EFBA1900 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>hiya </FONT></DIV> <DIV><FONT face=3DArial size=3D2>where can i find some COM compliant = scripting=20 engine, in order to use Python as my scripting language in = IIS.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>thanks in = advance</FONT></DIV></BODY></HTML> ------=_NextPart_000_0005_01C0CC4E.EFBA1900-- From thomas.pletl@system-integration.de Mon Apr 23 23:39:05 2001 From: thomas.pletl@system-integration.de (Thomas Pletl) Date: Tue, 24 Apr 2001 00:39:05 +0200 Subject: [Tutor] PIL, text rendering and Mac In-Reply-To: <f05001900b70a167bd93a@[131.216.77.14]> Message-ID: <B70A7BA6.B08%thomas.pletl@system-integration.de> Thanks for your answer, Corran. I immediately checked out Sping/Piddle and yes -- it works! Great hint! What it lacks however is the possibility to merge two images, i. e. you have a template and would like to fill some text in. Is there any workaround for that? Thomas From bobhicks@adelphia.net Mon Apr 23 23:39:24 2001 From: bobhicks@adelphia.net (Robert Hicks) Date: Mon, 23 Apr 2001 18:39:24 -0400 Subject: [Tutor] COM compliant scripting engine In-Reply-To: <000801c0cc89$9cdc8f20$640c3ad5@wcimageqci2cvz> Message-ID: <E14rozs-0004q6-00@mail.python.org> I believe if you get the Win32 extensions there is an app in there that=20= registers Python as a WSH scripting language along side JScript and=20 VBScript. - Bob On Tuesday, April 24, 2001, at 02:41 AM, wilson edgar wrote: > hiya > where can i find some COM compliant scripting engine, in order to use=20= > Python as my scripting language in IIS. > =A0 > thanks in advance From cwebster@nevada.edu Tue Apr 24 00:12:06 2001 From: cwebster@nevada.edu (Corran Webster) Date: Mon, 23 Apr 2001 16:12:06 -0700 Subject: [Tutor] PIL, text rendering and Mac In-Reply-To: <B70A7BA6.B08%thomas.pletl@system-integration.de> References: <B70A7BA6.B08%thomas.pletl@system-integration.de> Message-ID: <f05001904b70a65485cde@[131.216.77.14]> At 12:39 AM +0200 24/4/01, Thomas Pletl wrote: >Thanks for your answer, Corran. > >I immediately checked out Sping/Piddle and yes -- it works! Great hint! What >it lacks however is the possibility to merge two images, i. e. you have a >template and would like to fill some text in. Is there any workaround for >that? I think that you can do what you want with the .drawImage method of Piddle canvases. Draw up your template in a Piddle/PIL canvas and save it somewhere - either as a file or as a PIL object somewhere in your script. Then create your a new canvas, and for your first step copy the PIL template object to the canvas with .drawImage. Exactly the best strategy for this will depend on your script - for long-running scripts it may suffice to generate the template once at the start and then simply repeatedly copy it each time you fill out a new template. If your script only fills in one template at a time, it's probably better to save the template image as a file and read it in via PIL each time. Hope this helps. Regards, Corran From julieta_rangel@hotmail.com Tue Apr 24 02:27:03 2001 From: julieta_rangel@hotmail.com (Julieta Rangel) Date: Mon, 23 Apr 2001 20:27:03 -0500 Subject: [Tutor] Re: [Python-Help] functions to integrate, multiply and divide polynomials Message-ID: <F992aTMxSpB28sS0Um30000bda2@hotmail.com> <html><DIV> <P><BR><BR></P> <DIV></DIV> <P><BR><BR></P></DIV> <DIV></DIV> <DIV></DIV> <P><BR><BR></P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>From: "Alex Martelli" <ALEAXIT@YAHOO.COM> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>To: "Julieta" <JULIETA_RANGEL@HOTMAIL.COM>, <HELP@PYTHON.ORG> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Subject: Re: [Python-Help] functions to integrate, multiply and divide polynomials <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Date: Sun, 22 Apr 2001 00:15:39 +0200 <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>"Julieta" <JULIETA_RANGEL@HOTMAIL.COM>writes: <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>""" <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>I am currently working on a project, which is intended to build functions to <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>1)Integrate a polynomial, 2) to multiply and 3) to divide two polynomials, <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>and to test that the class and function are working properly. I am new at <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>using Python, so any kind of help would be appreciated. Questions or <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>comments feel free to e-mail me at julieta_rangel@hotmail.com <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>""" <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>The natural Python approach is to first build a Polynomial *class* to <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>encapsulate <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>the task of holding the coefficients. There are many choices you can make <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>about <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>how to represent a polynomial, and encapsulating the representation (thus <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>the <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>choice!) in a class, with methods to return the degree of the polynomial and <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>the <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>coefficient for any power (ensure a 0.0 is returned for arbitrarily high <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>power, for <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>ease of other computations!), lets you tune representation freely. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Don't make the error of mixing higher-level functionality in the class that <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>just <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>holds the representation; have a *low*-level class that "just holds the <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>poly's <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>representation", and use it from higher-level functionality (inheritance <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>works <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>well for that, for example). To test correct functioning, you'll want to be <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>able <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>to read ("parse") a string representing a polynomial, creating a Polynomial <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>instance object, and emit a readable representation from one such instance. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Being able to build and modify the Polynomial instance will also be <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>important <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>for the other functions (a way to arbitrarily set any power's coefficient, <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>for <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>example -- remember the Polynomial instance will need to update its degree <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>when you do that). <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Once you have the representation class, integration and multiplication are <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>easy. Division is hard, but there are good resources on the net, that <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>explain how it's done by hand -- <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>http://www.sosmath.com/algebra/factor/fac01/fac01.html. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Once you CAN do it by hand, coding it into Python is not very hard. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>The key for each operation is to think in term of loops over all powers <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>up to the highest degree of interest. You know the formulas that give <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>the coefficient of each power in the result in terms of those in the <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>operands; for example, in multiplication, each power i in one operand <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>and j in the other will add the product of their coefficients to the <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>coefficient of power i+j in the result. Start to build the result with <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>all coefficients zero, write two nested loops over the powers in the <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>operands, and it takes less to write in Python than in English -- as <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>long as your low-level class supplies the right methods, of course. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Alex <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P>> Alex, Daniel, and Gregor</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P>Thanks for your suggestions. The manual math part of multiplying, integrating, differentiating, and dividing polynomials does not seem that bad. I'm a high school math teacher, so I have an idea of the manual labor needed in this project; however, it is the programming that I need to work on. If you don't mind, would you take a look at the following and tell me if I'm headed in the right direction?</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P>> import string<BR>class Poly:<BR> def __init__ ( self, v = 'x', c = [0]):<BR> """__init__():<BR> Initializes a polynomial<BR> Default variable is x<BR> Default polynomial is zero"""<BR> self.var = v<BR> self.coef = c<BR> self.deg = len(c)-1<BR> def __str__ (self):<BR> """__str__():<BR> Converts a polynomial into a string"""<BR> x = `self.coef[0]`<BR> for i in range (1, self.deg+1):<BR> x = x + " + " + `self.coef[i]` + self.var + "^" + `i`<BR> return x</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P>def Derivative(p):<BR> """Input: an instance of a polynomial<BR> Output: a polynomial that is the derivative of the input polynomial<BR> Side Effects: None"""<BR> pv=p.var<BR> pc=[]<BR> if p.deg==0:<BR> return Poly (v=pv,c=[0])<BR> else:<BR> for i in range(0,p.deg):<BR> d=(i+1)*p.coef[i+1]<BR> pc.append(d)<BR> return Poly (v=pv,c=pc)<BR>______________________________________________________</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P># This next line imports the polynomial class and the Derivative function<BR>from dkPoly import Poly<BR>from dkPoly import Derivative</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P># This is just a start of the function Integrate<BR># IT DOES NOT WORK !!!!!!<BR>def Integrate(p):<BR> """Input: an instance of a polynomial<BR> Output: a polynomial that is the integral of the input polynomial<BR> Side Effects: None"""<BR> pv=p.var<BR> return p</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P># This is just a start of the function Multiply<BR># IT DOES NOT WORK !!!!!!<BR>def Multiply(p,q):<BR> """Input: two instances of a polynomial<BR> Output: a polynomial that is the product of the input polynomials<BR> Side Effects: None"""<BR> pv=p.var<BR> return p</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P># This is just some code to test that the class and function are working properly</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P>r = Poly (c=[5])<BR>p = Poly (c = [-1,1,2])<BR>q = Poly (v = 'y', c = [-1,0,2,0,4,3])<BR>print "The degree of polynomial %s is %d." % (p,p.deg)<BR>print " "<BR>print "The degree of polynomial %s is %d." % (q,q.deg)<BR>print " "<BR>print "The degree of polynomial %s is %d." % (r,r.deg)<BR>print " "<BR>m = Derivative(p)<BR>n = Derivative(q)<BR>o = Derivative(r)<BR>print "The derivative of %s is: \n %s" % (p,m)<BR>print " "<BR>print "The derivative of %s is: \n %s" % (q,n)<BR>print " "<BR>print "The derivative of %s is: \n %s" % (r,o)<BR>print " "</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P># This is some code to test new functions<BR>t = Integrate(p)<BR>u = Multiply(p,q)<BR>print "The intgral of %s is: \n %s" % (p,t)<BR>print " "<BR>print "The product of %s and \n %s is: \n %s" % (p,q,u)<BR>print " "<BR></P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P>If you see a serious mistake, or have any suggestions for this code, would you please let me know? Any input is greatly appreciated.</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <P>Julieta</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>_________________________________________________________ <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Do You Yahoo!? <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>>Get your free @yahoo.com address at http://mail.yahoo.com <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV><br clear=all><hr>Get your FREE download of MSN Explorer at <a href="http://explorer.msn.com">http://explorer.msn.com</a><br></p></html> From rob@jam.rr.com Tue Apr 24 03:09:27 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Mon, 23 Apr 2001 21:09:27 -0500 Subject: [Tutor] using Python with time Message-ID: <3AE4E057.12633A15@jam.rr.com> I'd like to write a Python app that I can run "in the background" in both Windows and Linux/BSD/*nix, although it's hardly mission-critical that this be cross-platform. What I'd like it to do is notify me at certain times of day (say, at 10:32 a.m. and 3:40 p.m.) or after a given interval of time (say, every XYZ minutes from the moment the app is activated). My practical aim for it is to have a way to remind myself to practice mindfulness every so often during the day, but I'm also curious how to handle the timing part of the code. If anyone could recommend where I can look on the timing part, I'll credit helpful folk when I post the code to Useless Python!</bribe> Rob -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From toodles@yifan.net Tue Apr 24 04:24:16 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Tue, 24 Apr 2001 11:24:16 +0800 Subject: [Tutor] using Python with time In-Reply-To: <3AE4E057.12633A15@jam.rr.com> Message-ID: <FPEHJJPEEOIPMAHOADBKKEAICDAA.toodles@yifan.net> Howdy Rob, I don't know how helpful it is, but I'll mention it anyway. I'm coding this python MUD system, and I wanted it to save every "XYZ minutes from the moment the app is activated." import time #time() returns seconds since epoch, so you might want python to do some of the work and convert #it into separate fields with gmtime(). The index you want to use for minutes is 4. Check # http://www.python.org/doc/current/lib/module-time.html #for documentation. #This following bit can be pretty inaccurate if you are running other things in the process...otherwise... import time last_time=time.gmtime(time.time())[4:6] done=0 while not done: time_interval=1 #in minutes new_time=time.gmtime(time.time())[4:6] if (new_time[0]-last_time[0])>=time_interval and new_time[1]>=last_time[1]: print 'It was 1 minute since...' last_time=time.gmtime(time.time())[4:6] #I tried the other one, where it tests for a specific time...eg. 10:32. I got the hour, and it came as 3... # and the time is 11:00, so i don't know how that one works... I hope this helps... Andrew Wilkins > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > rob@jam.rr.com > Sent: Tuesday, 24 April 2001 10:09 AM > To: tutor@python.org > Subject: [Tutor] using Python with time > > > I'd like to write a Python app that I can run "in the background" in > both Windows and Linux/BSD/*nix, although it's hardly mission-critical > that this be cross-platform. What I'd like it to do is notify me at > certain times of day (say, at 10:32 a.m. and 3:40 p.m.) or after a given > interval of time (say, every XYZ minutes from the moment the app is > activated). > > My practical aim for it is to have a way to remind myself to practice > mindfulness every so often during the day, but I'm also curious how to > handle the timing part of the code. If anyone could recommend where I > can look on the timing part, I'll credit helpful folk when I post the > code to Useless Python!</bribe> > > Rob > -- > > Useless Python! > If your Python is this useless, we need you. > http://www.lowerstandard.com/python/pythonsource.html > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From sheila@thinkspot.net Tue Apr 24 05:13:09 2001 From: sheila@thinkspot.net (Sheila King) Date: Mon, 23 Apr 2001 21:13:09 -0700 Subject: [Tutor] Creating files inside a script [I made a mistake!] In-Reply-To: <Pine.LNX.4.21.0104222336410.27775-100000@hkn.eecs.berkeley.edu> References: <4C3F3982409@kserver.org> <Pine.LNX.4.21.0104222336410.27775-100000@hkn.eecs.berkeley.edu> Message-ID: <31CFD9D6EB5@kserver.org> On Sun, 22 Apr 2001 23:48:57 -0700 (PDT), Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> wrote about Re: [Tutor] Creating files inside a script [I made a mistake!]: :On Sun, 22 Apr 2001, Sheila King wrote: : :> This is how I would have thought things work, and that is obviously what the :> docs say. But, then I just don't get why I was getting this error: :> :> File "gypsymail.py", line 117, in PrintErrorToLogFile :> logfile = open(logfilename, 'a+') :> IOError: (2, 'No such file or directory') : :Very strange... It sounds like it might be something platform dependent, :because Python's open() is definitely using the C version of fopen() that :your system provides. : :If you can tell us what kind of system you're on, we can verify that it's :a platform-specific issue. Here is the info about the server: Linux Kernel: 2.2.19-RAID-FQ_Phoenix-sr91 (RedHat...I believe 6.2, but upgraded/rebuilt kernel several times since?) :The Python docs hint as much when they talk :about how append might be wacky under certain Unices. : : http://python.org/doc/current/lib/built-in-funcs.html : :"... and 'a' opens it for appending (which on some Unix systems means that :all writes append to the end of the file, regardless of the current seek :position)." : :Go figure. Yeah, I went there and read that over (I'm sure I've read it before, too...), but this time I especially looked for hints about wacky OS stuff, but I really don't see that... : :> In any case, the script seems to be working fine, now. I changed that line of :> my program to :> logfile = open(logfilename, 'a') :> :> since I'm only going to write to the file, anyway, and I don't need :> the a+ functionality. It now seems to create the file, when the file :> doesn't already exist. Beats me, what the problem was before. : :If we still want "a+" behavior, and have it do it nicely, we can write a :small wrapper function that does the same thing as open(), but test things :out: : :### :def safe_aplus_open(filename): : """A "permissive" style open() for mode "a+". : :It appears that on some Unices, if the file doesn't exist, :we run into IOErrors. This function will try to open it :with "a+", and if it fails, creates the file, and tries again. :""" : try: : return open(filename, "a+") : except IOError: : open(filename, "w") : return open(filename, "a+") :### : : :I wonder if there's a better way to do this. Until then, if you need :"a+", this function should make things nicer. Interesting. I would have never thought of that. I probably don't need a+ mode, but who knows what may come up in the future? :By the way, have you been able to find a Python user's group in SoCal? :Just curious. Well, no. Although I've made, really, no effort, other than the inquiry I made on this list. (Heh, Diedre's suggestion that *I* could start one, certainly scared me enough to make me shut up! At this point in my life, there is no way I could take on, yet one more "thing to do"! Maybe some time in a few months from now? Although I don't know where we would hold the meetings. My house is totally inappropriate.) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From tutor@python.org Tue Apr 24 05:18:44 2001 From: tutor@python.org (Tim Peters) Date: Tue, 24 Apr 2001 00:18:44 -0400 Subject: [Tutor] using Python with time In-Reply-To: <3AE4E057.12633A15@jam.rr.com> Message-ID: <LNBBLJKPBEHFEDALKOLCGEEEJOAA.tim.one@home.com> [rob@jam.rr.com] > I'd like to write a Python app that I can run "in the background" in > both Windows and Linux/BSD/*nix, although it's hardly mission-critical > that this be cross-platform. The good news is that it will be cross-platform without even trying. > What I'd like it to do is notify me at certain times of day (say, > at 10:32 a.m. and 3:40 p.m.) or after a given interval of time (say, > every XYZ minutes from the moment the app is activated). > > My practical aim for it is to have a way to remind myself to practice > mindfulness every so often during the day, but I'm also curious how to > handle the timing part of the code. If anyone could recommend where I > can look on the timing part, I'll credit helpful folk when I post the > code to Useless Python!</bribe> Everything you need is in the time module, so read the docs for that. I'm afraid the facilities in the time module are based closely on a horrible old Unix interface for dealing with time, so there's not a lot there that will make any sort of intuitive sense. This is where an interactive shell is *essential*, so you can play with the time functions until what they really do "clicks" for you: >>> import time >>> time.time() >>> print time.time() 988084770.06 >>> # and about 6 seconds later >>> print time.time() 988084776.32 >>> So that's your first tool: time.time() returns a number that goes up by one each second. So if you want to wait, say, for 3 minutes "from now", here's one (but bad!) way to do that: now = time.time() while time.time() < now + 3*60: pass That's a really bad way to do it because it will keep your CPU busy the entire time, running time.time() just as fast and often as it can. The other tool you need is time.sleep(): >>> time.sleep(5) >>> You have to *try* that to get anything useful out of the example <wink>: what happens is that, after hitting ENTER, the interactive shell just appears to freeze for 5 seconds before you get a prompt back. Python's time.sleep(x) is a portable way to tell the operating system "I don't want to do *anything* for the next x seconds -- please just ignore me and do other stuff until x seconds have elapsed, then please remember to wake me up again". This lets you wait a long time without interfering with other programs. So if you've got N seconds remaining to wait, time.sleep(N) will put your program to sleep for *about* N seconds. It's better to sleep a little less than that, because the OS may not wake you up *exactly* when N seconds have elapsed, and the longer your program has been sleeping, the more likely that the OS has swapped it out of main memory and onto disk. Then, depending on your system, it make take the OS a couple seconds just to read your program back into memory again so it can continue running it! That's all nasty details, though. To a reasonably good first approximation, if you want your program to wait for an hour, the one-liner time.sleep(60*60) will get pretty close. So start with that, then play around with the combination of that and a "busy loop" (the "really bad" method above -- which isn't bad at all when waiting for very *short* periods of time) to imporve the accuracy. From rob@jam.rr.com Tue Apr 24 05:44:15 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Mon, 23 Apr 2001 23:44:15 -0500 Subject: [Tutor] using Python with time | MindStorms & Python References: <LNBBLJKPBEHFEDALKOLCGEEEJOAA.tim.one@home.com> Message-ID: <3AE5049F.12845B63@jam.rr.com> Thanks! I did discover the time module right after posting my question, and went ahead and had a little fun with time.sleep() before seeing your responses. (The results of this foolishness are up on Useless Python since I wound up writing a script that makes fun of script kiddie viruses. So far, about the only other programming experience I enjoy as much as Python is my Lego MindStorms, which reminds me.... Has anyone had a chance to try programming a MindStorms robot with Python? I've seen talk of such on the web, but not had a chance to really investigate yet. I definitely want to program my bots with Python! Rob Tim Peters wrote: > > [rob@jam.rr.com] > > I'd like to write a Python app that I can run "in the background" in > > both Windows and Linux/BSD/*nix, although it's hardly mission-critical > > that this be cross-platform. > > The good news is that it will be cross-platform without even trying. > > > What I'd like it to do is notify me at certain times of day (say, > > at 10:32 a.m. and 3:40 p.m.) or after a given interval of time (say, > > every XYZ minutes from the moment the app is activated). > > > > My practical aim for it is to have a way to remind myself to practice > > mindfulness every so often during the day, but I'm also curious how to > > handle the timing part of the code. If anyone could recommend where I > > can look on the timing part, I'll credit helpful folk when I post the > > code to Useless Python!</bribe> > > Everything you need is in the time module, so read the docs for that. I'm > afraid the facilities in the time module are based closely on a horrible old > Unix interface for dealing with time, so there's not a lot there that will > make any sort of intuitive sense. This is where an interactive shell is > *essential*, so you can play with the time functions until what they really > do "clicks" for you: > > >>> import time > >>> time.time() > >>> print time.time() > 988084770.06 > >>> # and about 6 seconds later > >>> print time.time() > 988084776.32 > >>> > > So that's your first tool: time.time() returns a number that goes up by one > each second. So if you want to wait, say, for 3 minutes "from now", here's > one (but bad!) way to do that: > > now = time.time() > while time.time() < now + 3*60: > pass > > That's a really bad way to do it because it will keep your CPU busy the > entire time, running time.time() just as fast and often as it can. > > The other tool you need is time.sleep(): > > >>> time.sleep(5) > >>> > > You have to *try* that to get anything useful out of the example <wink>: > what happens is that, after hitting ENTER, the interactive shell just appears > to freeze for 5 seconds before you get a prompt back. Python's time.sleep(x) > is a portable way to tell the operating system "I don't want to do *anything* > for the next x seconds -- please just ignore me and do other stuff until x > seconds have elapsed, then please remember to wake me up again". This lets > you wait a long time without interfering with other programs. > > So if you've got N seconds remaining to wait, time.sleep(N) will put your > program to sleep for *about* N seconds. It's better to sleep a little less > than that, because the OS may not wake you up *exactly* when N seconds have > elapsed, and the longer your program has been sleeping, the more likely that > the OS has swapped it out of main memory and onto disk. Then, depending on > your system, it make take the OS a couple seconds just to read your program > back into memory again so it can continue running it! > > That's all nasty details, though. To a reasonably good first approximation, > if you want your program to wait for an hour, the one-liner > > time.sleep(60*60) > > will get pretty close. So start with that, then play around with the > combination of that and a "busy loop" (the "really bad" method above -- which > isn't bad at all when waiting for very *short* periods of time) to imporve > the accuracy. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From s349929@student.uq.edu.au Tue Apr 24 06:54:21 2001 From: s349929@student.uq.edu.au (Suzanne Little) Date: Tue, 24 Apr 2001 15:54:21 +1000 (GMT+1000) Subject: [Tutor] can't find module running on apache Message-ID: <Pine.OSF.4.30.0104241545170.2070-100000@student.uq.edu.au> Hello, I've got some code using the MySQLdb module that I want to put on a web server (apache1.3.12). As far as I can tell the code is fine - that is it works when not on the server but when I try to run it I get the following error in my log: Traceback (most recent call last): File "/projects/rdu/apache/apache_1.3.12/cgi-bin/search.py", line 18, in ? import cgi, re, MySQLdb ImportError: No module named MySQLdb [Tue Apr 24 14:22:27 2001] [error] [client 130.102.176.124] Premature end of script headers: /projects/rdu/apache/apache_1.3.12/cgi-bin/search.py Okay so it couldn't find the MySQLdb module. >From information in 'Dave Mitchell's Python CGI FAQ' it looks like it's some sort of path problem. So following one of the suggestions I made a small start up script which set the environment variables to the same as the ones in my environment (since they work) but either I didn't write the script correctly or that's not the problem because it didn't work. I know next to nothing about apache. I'm using Python2.0 on solaris8. Thanks for any advice, Suzanne :) -------------------------------------------------------------------------- "Contrariwise," continued Tweedledee, "If it was so, it might be; and if it were so, it would be; but as it isn't, it ain't. That's logic" -Lewis Carroll -------------------------------------------------------------------------- From dyoo@hkn.eecs.berkeley.edu Tue Apr 24 10:34:57 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 24 Apr 2001 02:34:57 -0700 (PDT) Subject: [Tutor] Re: [Python-Help] functions to integrate, multiply and divide polynomials In-Reply-To: <F992aTMxSpB28sS0Um30000bda2@hotmail.com> Message-ID: <Pine.LNX.4.21.0104240217000.28962-100000@hkn.eecs.berkeley.edu> > Thanks for your suggestions. The manual math part of multiplying, > integrating, differentiating, and dividing polynomials does not seem that > bad. I'm a high school math teacher, so I have an idea of the manual > labor needed in this project; however, it is the programming that I need > to work on. If you don't mind, would you take a look at the following > and tell me if I'm headed in the right direction? > > > import string > class Poly: > def __init__ ( self, v = 'x', c = [0]): > """__init__(): > Initializes a polynomial > Default variable is x > Default polynomial is zero""" > self.var = v > self.coef = c > self.deg = len(c)-1 > def __str__ (self): > """__str__(): > Converts a polynomial into a string""" > x = `self.coef[0]` > for i in range (1, self.deg+1): > x = x + " + " + `self.coef[i]` + self.var + "^" + `i` > return x Looks ok so far. It might be better to have your docstrings show how many arguments each member function can take in. For example: """__init__()...""" could be more descriptive as: """__init__(variable, coefficients) ...""" Personally, I like to see "x^0" just for consistancy's sake, but that's just me. *grin* Your approach looks good. I still think that using classes, (as opposed to lists), might be overkill in this particular example; if you're going to use this code with students, are you assuming that they know about OOP already? Anyway, it looks like a good start. When you gain more progress, feel free to post it up. From scarblac@pino.selwerd.nl Tue Apr 24 12:30:09 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 24 Apr 2001 13:30:09 +0200 Subject: [Tutor] Re: [Python-Help] functions to integrate, multiply and divide polynomials In-Reply-To: <Pine.LNX.4.21.0104240217000.28962-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Tue, Apr 24, 2001 at 02:34:57AM -0700 References: <F992aTMxSpB28sS0Um30000bda2@hotmail.com> <Pine.LNX.4.21.0104240217000.28962-100000@hkn.eecs.berkeley.edu> Message-ID: <20010424133008.A32009@pino.selwerd.nl> On 0, Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> wrote: > > Thanks for your suggestions. The manual math part of multiplying, > > integrating, differentiating, and dividing polynomials does not seem that > > bad. I'm a high school math teacher, so I have an idea of the manual > > labor needed in this project; however, it is the programming that I need > > to work on. If you don't mind, would you take a look at the following > > and tell me if I'm headed in the right direction? I haven't seen your earlier post (hmm, there was one in HTML I couldn't read, maybe that was it?). In my first CS year, we had to make some code (in Pascal) for expressions. The idea is that you can write an expression in prefix notation, ie 2*x*x+3*x = + * 2 * x x * 3 x. You can turn that into a tree notation, or Python classes for sum, product etc. Idea is something like: class Atom: """ Usage e.g. >>> x = Atom("y") >>> x.eval(y=4) 4 """ def __init__(self, atom): # atom is either an integer or a string # in case of a string, it's the variable name self.atom = atom def eval(self, **args): # optional keyword args to set variable's value if type(self.atom) == type("") and args.has_key(self.atom): return args[self.atom] return self.atom def derive(self, variable): if self.atom == variable: return 1 else: return 0 # Constant def __repr__(self): return str(self.atom) # Rest left as exercise class Sum: def __init__(self, one, two): self.one = one self.two = two def eval(self, **args): return self.one.eval(**args) + self.two.eval(**args) def derive(self, variable): # Derivation of sum is sum of derivatives return Sum(self.one.derive(variable), self.two.derive(variable)) def __repr__(self): return "(%s+%s)" % (repr(self.one),repr(self.two)) class Product: def __init__(self, one, two): self.one = one self.two = two def eval(self, **args): return self.one.eval(**args) * self.two.eval(**args) def derive(self, variable): # Product rule return Sum(Product(self.one, self.two.derive(variable)), Product(self.one.derive(variable), self.two)) def __repr__(self): return "%s*%s" % (repr(self.one), repr(self.two)) Etc. >>> x = Sum(Product(Atom(3), Atom("x")), Atom(4)) # 3*x+4 >>> x.eval(x=4) 16 >>> x.derive("x") ((3*1+0*x)+0) None of this is tested at all, I'm at the uni now and typing this into my mailreader, but something like this should work. Now the fun starts - try to find ways to pretty-print them, and to simplify expressions, like removing the zeroes... We had about four different algorithms that we kept applying until the expression didn't change anymore. Probably a seperate simple polynomial class like yours can fit in somewhere :). Deriving 3*x by means of the multiplication rule isn't ideal... -- Remco Gerlich From jsoons@juilliard.edu Tue Apr 24 14:36:23 2001 From: jsoons@juilliard.edu (Jonathan Soons) Date: Tue, 24 Apr 2001 09:36:23 -0400 Subject: [Tutor] RE: Tru64 tkinter problem Message-ID: <B7C74E1A6FBAD411BFC60002B309DDF4E47D@mailbox.juilliard.edu> I am trying to get idle working on Tru64 5.1 Unix running Python 2.1, but tkinter can not be imported. tcl/tk seems to be installed already. -------------------------------- Aedin Culhane Bioinformatics Group Biochemistry Department University College Cork Cork, Ireland I am not familiar with Tru64 but I was in the same situation as you on Solaris7 and also on Debian Linux. As the instructions suggest, the Modules/Setup file is really the key. It wouldn't hurt to try compiling on the assumption that your tcl and tk libs and includes are /usr/lib and /usr/include since you seem to have the same setup as one of my machines. As for the X11 libs you have to poke around for files with names like libX*.a or libX*.so and libX*.so.? I can send you my Modules/Setup files (from both machines) if you think you might get a clue from them or you might try posting yours. Good Luck From tyson571us@yahoo.com Tue Apr 24 16:18:25 2001 From: tyson571us@yahoo.com (tyson toussaint) Date: Tue, 24 Apr 2001 08:18:25 -0700 (PDT) Subject: [Tutor] Moduling Message-ID: <20010424151825.74242.qmail@web11803.mail.yahoo.com> Could you direct me to someone who can help me with moduling problems. I seem to be able to draft simple functions and make them run. But I cannot call that very same function as a module into a different program. If yours is the correct place to go, please give VERY specific explanation of how to save the module and call it. I say very specific, because I have Gauld's and Beazley's books, and their very general instructions seem beyond my ability to copy. I am very ignorant about programming; I don't care how simple your assistance, it will not be insulting - though I do know how to turn the computer on. Thanx!! __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ From kromag@nsacom.net Tue Apr 24 20:30:11 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Tue, 24 Apr 2001 12:30:11 -0700 (PDT) Subject: [Tutor] Creating a widows screensaver with python.... Message-ID: <200104241930.f3OJUB808773@pop.nsacom.net> Hey all. I have a desire to put a simple bitmap on the screen of a windows box. Has anyone got experience/example code for creating *.scr files with python? I seem to recall that numpy has some sort of bitmap fun in it's tutorial. Am I lurching in the right direction? Thanks! d From thelink <electro-owner@ml.poplist.fr> Tue Apr 24 15:21:54 2001 From: thelink <electro-owner@ml.poplist.fr> (thelink) Date: Tue, 24 Apr 2001 16:21:54 +0200 Subject: [Tutor] WWW.090000900.COM GAGNEZ 1 AN DE COMMUNICATIONS GSM ! WIN 1 JAAR GRATIS GSM-GEBRUIK ! Message-ID: <007601c0ccc9$e9f7d540$01fea8c0@jctubiermont.brutele.be> This is a multi-part message in MIME format. ------=_NextPart_000_006E_01C0CCDA.AD2CB8E0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_006F_01C0CCDA.AD2CB8E0" ------=_NextPart_001_006F_01C0CCDA.AD2CB8E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable --{ Liste h=E9berg=E9e par PoPList }------{ http://www.poplist.fr/ }-- --{ Voir en bas de ce mail les options de d=E9sabonnement }-- ______________________________________________________________________ GAGNEZ 1 AN DE COMMUNICATIONS GSM GRATUITES ! WIN 1 JAAR GRATIS GSM-GEBRUIK ! =20=20=20=20=20=20=20 TELECHARGEZ PAR SMS 1500 LOGOS et SONNERIES AU TARIF LE PLUS BAS ( 30 bef /= unite ) ! DOWNLOAD PER SMS 1500 LOGOS en RINGTONES AAN HET LAAGSTE TARIEF ( 30 bef / = stuk ) ! http://www.090000900.com $ Pour vous d=E9sabonner, rendez-vous simplement sur cette page : -> <http://cgi.poplist.fr/@/u/electro/tutor@python.org> ------=_NextPart_001_006F_01C0CCDA.AD2CB8E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN"> <HTML> <HEAD> <META content=3Dtext/html;charset=3Diso-8859-1 http-equiv=3DContent-Type> <META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR> </HEAD> <BODY bgColor=3D#ffffff><DIV ALIGN=3D"LEFT"> <TABLE BORDER=3D"0" CELLPADDING=3D"2" CELLSPACING=3D"0"> <TR> <TD ALIGN=3D"LEFT"> <FONT FACE=3D"Verdana,Arial,Helvetica" SIZE=3D"2"> <NOBR>--{ Liste h=E9berg=E9e par PoPList }------= --{ <A HREF=3D"http://www.poplist.fr/">http://www.poplist.fr/</A= > }--</NOBR><BR> <NOBR>--{ Voir en b= as de ce mail les &n= bsp;options de d=E9sabonnement }--</NOBR> </FONT> </TD> </TR> <TR> <TD><HR SIZE=3D"1" ALIGN=3D"CENTER" WIDTH=3D"100%" NOSHADE></TD> </TR> <TR><TD> <BR></TD></TR> </TABLE> </DIV> <DIV align=3Dcenter><FONT color=3D#000000><FONT size=3D4><FONT=20 face=3D"Times New Roman">GAGNEZ 1 AN DE COMMUNICATIONS GSM GRATUITES=20 !</FONT></FONT></FONT><FONT face=3D"Times New Roman"><FONT=20 size=3D4></FONT></FONT></DIV> <DIV align=3Dcenter><FONT color=3D#000000><FONT size=3D4><FONT=20 face=3D"Times New Roman"></FONT></FONT></FONT><FONT face=3D"Times New Roman= "><FONT=20 size=3D4>WIN 1 JAAR GRATIS GSM-GEBRUIK !</FONT></FONT><FONT size=3D1></FONT= ></DIV> <DIV align=3Dcenter><FONT size=3D1></FONT> </DIV> <DIV align=3Dcenter><A href=3D"http://www.090000900.com"><IMG=20 src=3D"cid:006201c0ccc9$e9718e40$01fea8c0@jctubiermont.brutele.be"></A><FON= T=20 color=3D#000000 size=3D1> </FONT><FONT = size=3D1><A=20 href=3D"http://www.090000900.com"><IMG=20 src=3D"cid:006401c0ccc9$e98b7ee0$01fea8c0@jctubiermont.brutele.be"></A></FO= NT></DIV> <DIV align=3Dcenter><FONT face=3D"Times New Roman" size=3D4></FONT><FONT fa= ce=3D""=20 size=3D3></FONT> </DIV> <DIV align=3Dcenter><FONT color=3D#000000><FONT face=3D"Times New Roman"><F= ONT=20 size=3D3>TELECHARGEZ PAR SMS 1500 LOGOS et SONNERIES AU TARIF LE PLUS BAS (= 30 bef=20 / unite ) !</FONT></FONT></FONT><FONT size=3D3><FONT=20 face=3D"Times New Roman"></FONT></FONT></DIV> <DIV align=3Dcenter><FONT color=3D#000000><FONT face=3D"Times New Roman"><F= ONT=20 size=3D3></FONT></FONT></FONT><FONT size=3D3><FONT face=3D"Times New Roman"= >DOWNLOAD=20 PER SMS 1500 LOGOS en RINGTONES AAN HET LAAGSTE TARIEF ( 30 bef / stuk )=20 !</FONT></FONT><FONT face=3D"Times New Roman" size=3D5></FONT></DIV> <DIV align=3Dcenter><FONT color=3D#000000 size=3D1><A=20 href=3D"http://www.090000900.com"><FONT face=3D"Times New Roman"=20 size=3D5>http://www.090000900.com</FONT></A></FONT></DIV> <DIV align=3Dcenter><FONT color=3D#000000 size=3D1></FONT> </DIV> <DIV><FONT color=3D#000000 size=3D1>$</FONT></DIV><DIV ALIGN=3D"LEFT"> <TABLE BORDER=3D"0" CELLPADDING=3D"2" CELLSPACING=3D"0"> <TR><TD> <BR></TD></TR> <TR> <TD ALIGN=3D"LEFT"> <FONT FACE=3D"Verdana,Arial,Helvetica" SIZE=3D"2"> Pour vous d=E9sabonner, rendez-vous simplement sur cette page :<BR> <<A HREF=3D"http://cgi.poplist.fr/@/u/electro/tutor@python.org"> http://cgi.poplist.fr/@/u/electro/tutor@python.org</A>> </FONT> </TD> </TR> </TABLE> </DIV> </BODY></HTML> ------=_NextPart_001_006F_01C0CCDA.AD2CB8E0-- ------=_NextPart_000_006E_01C0CCDA.AD2CB8E0 Content-Type: image/gif Content-Transfer-Encoding: base64 Content-Id: <006201c0ccc9$e9718e40$01fea8c0@jctubiermont.brutele.be> R0lGODlhgACAAMQWAPSpi4Y2a5FKeapmk/KPaP7+/uxeJvnSw7FJUO1pNM1S Or2Tr+94Sfe/qPjn49Gzx+RbK/z089/L2Prf1OldKP3v6f///wAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFZAAW ACwAAAAAgACAAAAF/2AgjmRpnmiqrmzrvnAsz3Rt33iu73zv/zSIcAihUIjG 4nGYZCaXRCTTOV1Cp0JrFvrENqvRsBRlKJvP6LR6zW673/B4nIKiyO/4vH4P h9T5gIGCg2Z+J3aEiYqLaoYmiIyRkoGOJZCTmIAMAAcOEREOBwAMd5Ukl5mp cgwHBQUREwedEa4NpH1/qrpvCQCvBwQJZwkErREAwm6mI6i7ugkMBAAEDA0F EwRtBA4FAG/LIs1x0LfOBuTJbAQNtK7u2W4ME93KuWsE+PnSwQAVE+V3elE7 s2mUm37/2CSwVkDUugIVrsFrw8ATwDTgAogz466jK2muLsYhUOsMyQIT1//4 ipASjbUD5axJ+9RSDckDbTJuLNOgZ8QIPRv0esUAWjozDESWOdmAIACDw4qa 8VVh4tGTBxpkI9nUAIEIFY6uaaW0jM42CdK2+pfWgLUInRxgM0NgQoUKwNIw JSiLVLGsDuTCo5oNwAShZRLM63hg3kRf3tyQjNzInsK1Md1FhOiXliyILffS pVVYsysHpStEi0iZ5LGkDBOaucsLLpuzbhJgNsMwWG/F9NwWQEy35GiUBgCQ HnosucRWxJ1TXjj8qLWyZ+zetrxG97XMEfx+THBaVkQHAEUvJZ2cFikGr7yt jCibZ3iT1c/4qpmm1fZDvOzGE1FejefKJ2DhlZ7/ceshp1wB78XnnDsTWHdf cdE5xx8a/q2BG1oCCnffScG44o0wbeE3nEnsPRhhc7440EBE0flCHHUZXvdG YP89EuB3vBFIoneoJTUNGljlE02L7hkAH4wFoNdbccPh0wq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ptWKGOKqJrMC9tqG7iZWzuMWHgcTDZDLMzY3HX8rIutXR0NvbN9Dc3UJm 4JPnxb/C2q/Zvbfsy1fG6a7r9OH5Pu+n+GRA7AWTB+/YvByr+uxrBgtUHIGW TJV6SFCUpFLS6i2sdXGiwowFDWrbR00jN1Lf+lYNBHmPViWV0arROvimor6N nDC1q8nSmU1CM2ny7Dntpx6dO4vitLZUUVChPD+GLHmTn9GDRIE+RWa1aTeO Iot2zbqSLKCwSod6xdqSVz21Ztla3DoiBAA7 ------=_NextPart_000_006E_01C0CCDA.AD2CB8E0 Content-Type: image/gif Content-Transfer-Encoding: base64 Content-Id: <006401c0ccc9$e98b7ee0$01fea8c0@jctubiermont.brutele.be> R0lGODlhgACAALMNALdLTOzBuq9tmfKPaOxeJZVSfoU1aoU2aoU2a+xfJoY2 a+xeJv///////wAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFZAANACwA AAAAgACAAAAE/1DJSau9OOvNu/9gKI5kaZ5oqq5s677kIs90bd94ru987/+Y WSI3lBVrBOHROEw4ibolsyZ9OqtUW1FaC2aNt21SRnguxuUrzbouC89fJc68 eI6Zy+273rwvvEduQwR+TW9FhFqDYEdNS4lgPYE0Y2xieXWZZGwzXniHdHwJ gjqFmqCnmoiCjYh8M26Zeq88oTJBiJyGh3Kisr67N0mNcJlJfpuwxjuWsGzD sU+eg3SOxJGi1mSfwa/Retq0a6mnowMDAQzqDAED1W/DR153W6NZ9nWJo9fi 43RlkOzZO8boFb8rhBKgWxegYTp17RJS2ncHUKtfyeRYcTJM2D4owf/UGGSE 71QaJwMgusOzkMFKYKkAUYKXzwayKUIqFcPYh4u/MJEUnjuXrl29NSnZ0Zt0 6wKtk/eUnHMUjdY1nTiZTYUVy0jLdeoGUDm6UKygjp2cEqQytO3UogPQFBSD 9ByedmJ5zkjZbk+lh3gfshN7hW6dpHn3ZJo2MwHYx+fUcUH2LmmAWIj7CXlI WAvcTOkiu/wl8jA7fGibWpgCSYZDhg0TPFSoh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RbRCJN FFS9wdcIwgJqKzw8gKVF/yW2TBCPdsh+4WEgVMiBCi8yYoKlHu6FghOodyL5 6pGdWodHTo16V2t3D7XB3w7SzGvvvfiOMdV9ivgWBn/GaBrHIlqYpQWkTGpC I2CdUEUTkFLoZ0cnBT3Dw0omQQGnmYWYZBY1DltVwr7xZVxpxVFy8a0uPRj4 BqS6QYoIYAdFWF8PNaD8JEdBnvhGNv92zJ0TCKdI3ykqgaKzmNb18xB0SufW sCBT0BQnfpF6Qki0R2QErrRYrLNPHjYN6gbJ8V0pGsqreIRHblhC0xuB/25D Yw/eSNzC2xWX1EI34pZJTSEsjDB0S2DvR8WojcCCpVTw/OsRXmYqYqMNnEGa Viu99o0g0CsjyVzWU+IKk4c8K+Rz2KQw5ztBzvNy7vrr+8ke++yu2457cxEA ADs= ------=_NextPart_000_006E_01C0CCDA.AD2CB8E0-- From kromag@nsacom.net Tue Apr 24 23:00:58 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Tue, 24 Apr 2001 15:00:58 -0700 (PDT) Subject: [Tutor] Creating a widows screensaver with python.... Message-ID: <200104242200.f3OM0w813408@pop.nsacom.net> kromag@nsacom.net said: Once again: Try and code a little bit before you post.. <blush> I got this far: from Tkinter import * root=Tk() tux=PhotoImage(file='\windows\desktop\tux.gif') w=Label(root, image=tux) w.pack() root.mainloop() Which squirts a penguin into a window for me. If I'd've tried for 20 minutes I woul't have wasted Ye Bandwidth... Anyway, my next goals are: 1. Stripping off the standard toolbar, frame and button widgets from the window, leaving only the image. 2. Making the window close upon keyboard or mouse input. 3. Blacking out the entire screen except for the image. _Now_ I need some actual input. I have been looking through the excellent "Introduction to Tkinter" but can find nothing that clues me to any of these. Any suggestions? > Hey all. > > I have a desire to put a simple bitmap on the screen of a windows box. Has > anyone got experience/example code for creating *.scr files with python? > > I seem to recall that numpy has some sort of bitmap fun in it's tutorial. Am I > lurching in the right direction? > > Thanks! > > d > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From bdupire@seatech.fau.edu Tue Apr 24 21:10:31 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Tue, 24 Apr 2001 16:10:31 -0400 Subject: [Tutor] Moduling References: <20010424151825.74242.qmail@web11803.mail.yahoo.com> Message-ID: <3AE5DDB7.2E6C170@seatech.fau.edu> if you want a specific answer, you 'd better post your program and what you try to do, and the error that Python returns. Which step goes wrong ? tyson toussaint wrote: > Could you direct me to someone who can help me with > moduling problems. I seem to be able to draft simple > functions and make them run. But I cannot call that > very same function as a module into a different > program. > > If yours is the correct place to go, please give VERY > specific explanation of how to save the module and > call it. I say very specific, because I have Gauld's > and Beazley's books, and their very general > instructions seem beyond my ability to copy. > > I am very ignorant about programming; I don't care how > simple your assistance, it will not be insulting - > though I do know how to turn the computer on. > > Thanx!! > > __________________________________________________ > Do You Yahoo!? > Yahoo! Auctions - buy the things you want at great prices > http://auctions.yahoo.com/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From kromag@nsacom.net Wed Apr 25 00:38:06 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Tue, 24 Apr 2001 16:38:06 -0700 (PDT) Subject: [Tutor] Creating a widows screensaver with python.... Message-ID: <200104242338.f3ONc6826852@pop.nsacom.net> > > 1. Stripping off the standard toolbar, frame and button widgets from the > window, leaving only the image. > Found overrideredirect(1) From virketis@fas.harvard.edu Tue Apr 24 23:49:16 2001 From: virketis@fas.harvard.edu (Pijus Virketis) Date: Tue, 24 Apr 2001 18:49:16 -0400 Subject: [Tutor] looping through object names In-Reply-To: <E14s5I1-0007TM-00@mail.python.org> Message-ID: <200104242245.SAA11329@smtp4.fas.harvard.edu> I am writing a Tk GUI, and want to loop through some string names, in order to assign them as StringVars(). Thus: list = [name, wage, wage_to_date] var_list = [] for i in list: i = stringVar() var_list.append(i) Except that this raises an error: I cannot store previously unnasigned object names in a list like that. What would be an alternative method of accomplishing this task? Perhaps storing them in a list as strings, and them somehow extracting and using them? Thanks for your help! Pijus ---------------------------------------------------------------------------- ------------------- Please have a look at my weblog at www.fas.harvard.edu/~virketis. From gibbs05@flash.net Wed Apr 25 02:12:34 2001 From: gibbs05@flash.net (Harry Kattz) Date: Tue, 24 Apr 2001 20:12:34 -0500 Subject: [Tutor] looping through object names References: <200104242245.SAA11329@smtp4.fas.harvard.edu> Message-ID: <033901c0cd24$eab4ad40$72ef3040@gibbs05> > I am writing a Tk GUI, and want to loop through some string names, in order > to assign them as StringVars(). Thus: > > list = [name, wage, wage_to_date] > var_list = [] > for i in list: > i = stringVar() > var_list.append(i) > > Except that this raises an error: I cannot store previously unnasigned > object names in a list like that. What would be an alternative method of > accomplishing this task? Perhaps storing them in a list as strings, and > them somehow extracting and using them? The first dificulty I see here is that 'list' is a built in function. If you run help on it in Python 2.1 you should see the following: >>> from pydoc import help >>> help(list) Help on built-in function list: list(...) list(sequence) -> list Return a new list whose items are the same as those of the argument sequence. The second difficulty is that the variables 'name', etc. haven't been defined yet. >>> name_list = [name, wage, wage_to_date] Traceback (most recent call last): File "<interactive input>", line 1, in ? NameError: name 'name' is not defined As you said, you can get around this by making a list of strings. >>> name_list = ['name', 'wage', 'wage_to_date'] >>> print name_list ['name', 'wage', 'wage_to_date'] >From here, two ways to construct these variables come to mind. First, append them to an object: >>> from Tkinter import * >>> root = Tk() # Master Tk needed to init StringVar >>> class Empty: ... pass ... >>> name_list = ['name', 'wage', 'wage_to_date'] >>> StrVars = Empty() >>> for i in name_list: ... StrVars.__dict__[i] = StringVar() Now you can get'em and set'em however you like: >>> StrVars.name.set('Test') >>> print StrVars.name.get() Test A second, and easier, way would be using a dictionary: >>> from Tkinter import * >>> root = Tk() >>> name_list = ['name', 'wage', 'wage_to_date'] >>> StrDict = {} >>> for i in name_list: ... StrDict[i] = StringVar() ... Use get and set the same way: >>> StrDict['name'].set('Another Test') >>> print StrDict['name'].get() Another Test There are probably other ways to do this that I don't know about yet. :-) > Thanks for your help! I hope this helps some. > Pijus Sam From bdupire@seatech.fau.edu Wed Apr 25 02:57:51 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Tue, 24 Apr 2001 21:57:51 -0400 Subject: [Tutor] Moduling References: <20010425013834.17008.qmail@web11808.mail.yahoo.com> Message-ID: <3AE62F1F.3ABB15E1@seatech.fau.edu> Your function 'times' is ok! It takes a single argument, do some processing (here, it prints smtg on the screen) and returns None (i.e nothing) If you want to return something use the 'return' instruction: def times (n): for i in range(1, 15): my_string ="%d x %d = %d" % (i, n, i*n) return my_string I assume you defined the 'times' function in a file called 'times.py' So the function 'times' lives in the module which has the same name 'times'. To execute this function times from the Python interpreter or from another module ( timesrun.py, for example ;o) ), you need to import times. Then you have to call the function, and to tell Python in which module it lives. You can do it like this... import times times.times(8) You prepend the name of the function with the name of the module... In This way you can have different times( ) functions in different modules... There is no colision between the different times( ) function names....Each module defines a new namespace.... you don't need the 'print' statement because the printing is done inside the function. The function only returns None, so if you do print times.times(8) then it would print None... For the 2nd problem the syntax of if.. elif ... else.. is the following: if v>7: blabla code... elif v=5: blabla code... elif v<4: blabla code else: bla bla code # code executed if v=4, 6, 7 hope it helps, Benoit tyson toussaint wrote: > def times (n): > for i in range(1, 15): > print "%d x %d = %d" % (i, n, i*n) > > import times > print times(8) > > IDLE 0.6 -- press F1 for help > >>> > Traceback (innermost last): > File "<string>", line 1, in ? > File "A:\PythonFiles\timesrun.py", line 2, in ? > print times(8) > TypeError: call of non-function (type module) > > def isPostitive(v): > if v >= 7: > return 1 > elif: > return 0 > > import isPositive > print isPositive(4) > > Traceback (innermost last): > File "<string>", line 1, in ? > File "A:\PythonFiles\positive2run.py", line 1, in ? > import isPositive > File "A:\PythonFiles\isPositive.py", line 4 > elif: > ^ > SyntaxError: invalid syntax > > Thanks a lot for responding Benoit. > > You should see two sets of problems: one for the > function "times"; the second for the function > "isPositive." In both cases, I've provided all the > data I have. In all cases, I've tried to save > everything on the A-drive to reduce any PythonPath > problems. > > As you can see, I'm very lost and would appreciate any > direction. (Right now "Go to hell" would be more > direction than I have.) > -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From dyoo@hkn.eecs.berkeley.edu Wed Apr 25 03:45:19 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Tue, 24 Apr 2001 19:45:19 -0700 (PDT) Subject: [Tutor] can't find module running on apache In-Reply-To: <Pine.OSF.4.30.0104241545170.2070-100000@student.uq.edu.au> Message-ID: <Pine.LNX.4.21.0104241943120.17133-100000@hkn.eecs.berkeley.edu> On Tue, 24 Apr 2001, Suzanne Little wrote: > import cgi, re, MySQLdb > ImportError: No module named MySQLdb > [Tue Apr 24 14:22:27 2001] [error] [client 130.102.176.124] Premature end > of script headers: > /projects/rdu/apache/apache_1.3.12/cgi-bin/search.py > > Okay so it couldn't find the MySQLdb module. > >From information in 'Dave Mitchell's Python CGI FAQ' it looks like it's > some sort of path problem. So following one of the suggestions I made a > small start up script which set the environment variables to the same as > the ones in my environment (since they work) but either I didn't write the > script correctly or that's not the problem because it didn't work. I know > next to nothing about apache. I'm using Python2.0 on solaris8. Can you verify that Python1.52 isn't being run? Since you mentioned Python 2.0, it could be possible that Apache might be using the wrong Python version. You can check this with a quick script: ### import sys print "content-type: text/plain\n\n" print sys.version ### which should tell us if that's the problem. Good luck to you! From joerg.sporer@opencom.de Wed Apr 25 09:50:25 2001 From: joerg.sporer@opencom.de (=?iso-8859-1?Q?J=F6rg_Sporer?=) Date: Wed, 25 Apr 2001 10:50:25 +0200 Subject: [Tutor] How can i center a window on the screen? Message-ID: <000401c0cd64$c605b3a0$3701000a@arthur> Hello! How can I create a new Toplevel Widget in the center of the screen in Windows? Thanks Joerg From wheelege@tsn.cc Wed Apr 25 07:05:48 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Wed, 25 Apr 2001 16:05:48 +1000 Subject: [Tutor] Quick Question Message-ID: <00b701c0cd4d$e747eb80$0200a8c0@ACE> This is a multi-part message in MIME format. ------=_NextPart_000_002F_01C0CDA1.97B93520 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey guys, I've been writing up a bunch of graphing tools in python...just for = fun, and on paper I write x squared as x^2 - this is normal for me. However, in python, it is x**2 - right? My question is, what does x^2 do? It seems like x^y =3D=3D=3D x + y - = is this true? Thanks, Glen. ------=_NextPart_000_002F_01C0CDA1.97B93520 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV> Hey guys,</DIV> <DIV> </DIV> <DIV> I've been writing up a bunch of graphing tools in = python...just for=20 fun, and on paper I write x squared as x^2 - this is normal for = me.</DIV> <DIV> However, in python, it is x**2 - right?</DIV> <DIV> My question is, what does x^2 do? It seems like x^y = =3D=3D=3D x + y=20 - is this true?</DIV> <DIV> </DIV> <DIV> Thanks,</DIV> <DIV> Glen.</DIV></BODY></HTML> ------=_NextPart_000_002F_01C0CDA1.97B93520-- From wheelege@tsn.cc Wed Apr 25 15:17:46 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Thu, 26 Apr 2001 00:17:46 +1000 Subject: [Tutor] Quick Question References: <200104251407.f3PE79102546@dsl254-114-246.nyc1.dsl.speakeasy.net> Message-ID: <010101c0cd92$81b95520$0200a8c0@ACE> ----- Original Message ----- From: "Michael P. Reilly" <arcege@dsl254-114-246.nyc1.dsl.speakeasy.net> To: "Glen Wheeler" <wheelege@tsn.cc> Cc: <tutor@python.org> Sent: Thursday, April 26, 2001 12:07 AM Subject: Re: [Tutor] Quick Questiony > Glen Wheeler wrote > > I've been writing up a bunch of graphing tools in python...just for = > > fun, and on paper I write x squared as x^2 - this is normal for me. > > However, in python, it is x**2 - right? > > My question is, what does x^2 do? It seems like x^y =3D=3D=3D x + y - = > > is this true? > > Not quite. The '^' operator is 'exclusive or' in binary arithmatic. > Bits in the binary representation of the number are merged together, > but where two bits are both one, the result is zero. > > Since computer programs in the past were far more inclined to binary > arithmatic than more complex maths, the "and" (&), "or" (|), "not" (~) > and "exclusive or" (^) operations are more prevalent than "power of" > (which is "**", but also the pow() function), "square root" (sqrt()) > and "absolute value" (which could be "|x|", but is abs(x)), or even the > factorial ("!"). > > However, as you get into graphics, you'll find that a "exclusive > or" operator is far more powerful and useful to you than "power of". > Moving an object within a bitmap is often accomplished using the exlusive > or of the objects bitmap and the background (well, from what I remember > of my graphics course years ago anyway ;). > Thankyou for the detailed response - that makes so much more sense now! Glen. > -Arcege > > -- > +----------------------------------+-----------------------------------+ > | Michael P. Reilly | arcege@speakeasy.net | > From kromag@nsacom.net Wed Apr 25 21:42:39 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Wed, 25 Apr 2001 13:42:39 -0700 (PDT) Subject: [Tutor] Parsing control characters from serial port Message-ID: <200104252042.f3PKgd822867@pop.nsacom.net> I have had some success with grabbing strings from '/dev/ttyS0' by using readline(). It works just like I would expect, i.e. it stops 'listening' when a 'n' is detected. How can I tell readline() to complete a line when another character is detected? (I am listening for '0x02' FWIW) Basically the device on the other end of the serial port talks like this: 0x02 #Listen up! I have news for you! (string of characters) 0x03 #I'm Done! Since readline() opens the serial port and listens intently without need for a wake-up call, it won't be any big deal to strip the initial '0x02' off, but ending the message on '0x03' is confusing me. Do I need to somehow tell readlines() 'n'? is there a way to tell python that for the purposes of this function '0x03' == 'n'? I have tried to come up with some sort of garble that does while string contents != 0x03 read it all in and put it here else n (Sorry, I am not at my home machine and lunch is short!) I hope this is clear enough! Thanks, Douglas From dsh8290@rit.edu Wed Apr 25 20:17:24 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 25 Apr 2001 15:17:24 -0400 Subject: FW: Re: [Tutor] Quick Question Message-ID: <20010425151724.A29491@harmony.cs.rit.edu> Hmm, I got an error message back and I don't think my post made it to the list. I will be away for a couple weeks so I set my filtes to redirect to /dev/null. CC any replies to me if you don't want my filters to drop them. -D ----- Forwarded message from D-Man <dsh8290@rit.edu> ----- From: D-Man <dsh8290@rit.edu> Date: Wed, 25 Apr 2001 10:14:25 -0400 To: tutor@python.org User-Agent: Mutt/1.2.5i Mail-Followup-To: tutor@python.org On Wed, Apr 25, 2001 at 04:05:48PM +1000, Glen Wheeler wrote: | Hey guys, | | I've been writing up a bunch of graphing tools in python...just | for fun, and on paper I write x squared as x^2 - this is normal | for me. However, in python, it is x**2 - right? Yes. | My question is, what does x^2 do? It seems like x^y === x + y - | is this true? It might be -- depends on what the values of x and y are : >>> x = 3 >>> y = 4 >>> print x+y 7 >>> print x^y 7 >>> x = 2 >>> y = 3 >>> print x+y 5 >>> print x^y 1 <grin> http://www.python.org/doc/current/ref/bitwise.html#l2h-336 The ^ operator yields the bitwise XOR (exclusive OR) of its arguments, which must be plain or long integers. The arguments are converted to a common type. IIRC this operator is the same in Java. C and C++ don't have a builtin _logical_ XOR and I don't remember off the top of my head what the '^' operator does. I think it might be bitwise negation or bitwise xor, but I don't think I've ever used it. In the examples above, in case you're not familiar with binary, 3 : 011 4 : 100 7 : 111 2 : 010 3 : 011 1 : 001 1 : true 0 : false HTH, -D ----- End forwarded message ----- From dsh8290@rit.edu Wed Apr 25 15:14:25 2001 From: dsh8290@rit.edu (D-Man) Date: Wed, 25 Apr 2001 10:14:25 -0400 Subject: [Tutor] Quick Question In-Reply-To: <00b701c0cd4d$e747eb80$0200a8c0@ACE>; from wheelege@tsn.cc on Wed, Apr 25, 2001 at 04:05:48PM +1000 References: <00b701c0cd4d$e747eb80$0200a8c0@ACE> Message-ID: <20010425101425.B29081@harmony.cs.rit.edu> On Wed, Apr 25, 2001 at 04:05:48PM +1000, Glen Wheeler wrote: | Hey guys, | | I've been writing up a bunch of graphing tools in python...just | for fun, and on paper I write x squared as x^2 - this is normal | for me. However, in python, it is x**2 - right? Yes. | My question is, what does x^2 do? It seems like x^y === x + y - | is this true? It might be -- depends on what the values of x and y are : >>> x = 3 >>> y = 4 >>> print x+y 7 >>> print x^y 7 >>> x = 2 >>> y = 3 >>> print x+y 5 >>> print x^y 1 <grin> http://www.python.org/doc/current/ref/bitwise.html#l2h-336 The ^ operator yields the bitwise XOR (exclusive OR) of its arguments, which must be plain or long integers. The arguments are converted to a common type. IIRC this operator is the same in Java. C and C++ don't have a builtin _logical_ XOR and I don't remember off the top of my head what the '^' operator does. I think it might be bitwise negation or bitwise xor, but I don't think I've ever used it. In the examples above, in case you're not familiar with binary, 3 : 011 4 : 100 7 : 111 2 : 010 3 : 011 1 : 001 1 : true 0 : false HTH, -D From NHYTRO@compuserve.com Wed Apr 25 07:51:02 2001 From: NHYTRO@compuserve.com (Sharriff Aina) Date: Wed, 25 Apr 2001 02:51:02 -0400 Subject: [Tutor] removing values using a loop Message-ID: <200104250251_MC2-CDA4-570F@compuserve.com> Hi List! I retrieve strings from a database using CGI in the format: [('Home, None, Kontakt, Termine, None, None')] as an example, this string varies according to the database entry made by= the user I=B4m trying to generate HTML from these links by splitting the big strin= g into singular values, my big problem is removing the "None"s. I=B4ve tri= ed my best and rewrote the code at least 3 times, but my code fails and only= works when the nones are at the end of the string, my code: #### code start, test 1 #### templinks =3D alllinks[0] links =3D string.split(templinks[0],",") for x in links: .... if x =3D=3D "Kontakt": ........ counter =3D counter + 1 ........ print "<td>%d. </td>" %(counter) ........ print '<td bgcolor=3D"#EDBE30">', ........ print x ........# more HTML code ....else: ........pass ###### code end ####### I=B4ve also tried: #### code start, test 2 #### templinks =3D alllinks[0] links =3D string.split(templinks[0],",") for x in links: ....if x =3D=3D "None: ........pass ....elif =3D=3D "Kontakt": ........ counter =3D counter + 1 ........ print "<td>%d. </td>" %(counter) ........ print '<td bgcolor=3D"#EDBE30">', ........ print x ........# more HTML code #### code end #### both code snippets do not work as expected, could some one help? = Frustrated I thought it would be a good idea to remove the "None"s BEFOR= E the string is sored in the database, but that proved to be a more diffucu= lt task, see: #### code start ### # get links from form # -------------------- = for a in range(len(form.keys())): ....b =3D form.getvalue("link" + str(a)) ....linklist.append(b) ....delimitedlinks =3D string.join(map(str, (linklist)), ",") cur.execute("update users set navlinks=3D'%s' where username =3D'%s'" %(delimitedlinks,usernamevalue)) connection.commit() cur.close() connection.close() #### code end ### I have likewise written several versions of this snippet, but I end up breaking my databse access Please forgive my long post, I have to present an alpha of this applicati= on today, but I think the deadline stress and staring too long at the same piece of code has got to me. :-( Thank you very, very much in advance for your anticipated help. Sharriff From deirdre@deirdre.net Wed Apr 25 20:32:15 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Wed, 25 Apr 2001 12:32:15 -0700 Subject: [Tutor] Quick Question In-Reply-To: <20010425101425.B29081@harmony.cs.rit.edu> References: <00b701c0cd4d$e747eb80$0200a8c0@ACE>; from wheelege@tsn.cc on Wed, Apr 25, 2001 at 04:05:48PM +1000 <00b701c0cd4d$e747eb80$0200a8c0@ACE> Message-ID: <l03130306b70cd4d3e940@[10.0.1.18]> >IIRC this operator is the same in Java. C and C++ don't have a >builtin _logical_ XOR and I don't remember off the top of my head what >the '^' operator does. I think it might be bitwise negation or >bitwise xor, but I don't think I've ever used it. It is a bitwise XOR in C. http://web.cs.mun.ca/~michael/c/op.html -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From aichele@mindspring.com Wed Apr 25 07:40:51 2001 From: aichele@mindspring.com (Stephen Aichele) Date: Wed, 25 Apr 2001 02:40:51 -0400 (EDT) Subject: [Tutor] transferring files over a network In-Reply-To: <E14s6t1-00074d-00@mail.python.org> Message-ID: <200104250640.CAA10910@smtp10.atl.mindspring.net> I'm looking for suggestions for implementing P2P filesharing over a network using Python. with respect to the connection itself, I think I'm ok. However, I'm thinking that there must be a better way to handle the data transfer than what I'm currently doing: open the file on machine #1, read it into a variable, and send the data (as a python variable) to machine #2. machine #2 then catches it and writes it to a file. this is all well and good for simple files, but for longer files it seems like too much data to have read into a variable and sent all at once. seems there should be a way to copy the file directly from machine #1 to machine #2. If anyone has a minute to spare with a suggestion or two, I'd really appreciate it... thanks! Stephen From kalle@gnupung.net Wed Apr 25 15:01:39 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Wed, 25 Apr 2001 16:01:39 +0200 Subject: [Tutor] Quick Question In-Reply-To: <00b701c0cd4d$e747eb80$0200a8c0@ACE>; from wheelege@tsn.cc on Wed, Apr 25, 2001 at 04:05:48PM +1000 References: <00b701c0cd4d$e747eb80$0200a8c0@ACE> Message-ID: <20010425160139.A24093@father> Sez Glen Wheeler: > Hey guys, > > I've been writing up a bunch of graphing tools in python...just for fun, > and on paper I write x squared as x^2 - this is normal for me. > However, in python, it is x**2 - right? Yes. > My question is, what does x^2 do? It seems like x^y === x + y - is this > true? No. x^y is x (bitwise xor) y: >>> x = 4 # 0100 >>> y = 3 # 0011 >>> z = 7 # 0111 >>> x ^ y # 0111 7 >>> x ^ z # 0011 3 ^ compares the bits in the operands and bit N in the result is 1 iff either bit N in the left hand operand or bit N in the right hand operand, but not both, is 1. Otherwise bit N in the result is 0. I hope. My brain is all mushy... Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From lumbricus@gmx.net Tue Apr 24 20:56:10 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Tue, 24 Apr 2001 21:56:10 +0200 Subject: [Tutor] using Python with time In-Reply-To: <3AE4E057.12633A15@jam.rr.com>; from rob@jam.rr.com on Mon, Apr 23, 2001 at 09:09:27PM -0500 References: <3AE4E057.12633A15@jam.rr.com> Message-ID: <20010424215610.B621@Laplace.localdomain> --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, Apr 23, 2001 at 09:09:27PM -0500, rob@jam.rr.com wrote: > I'd like to write a Python app that I can run "in the background" in ^^^^^^^^^^^^^^^^^^^ you are talking about daemons ! see attchmnt (posting from c.l.py) > both Windows and Linux/BSD/*nix, although it's hardly mission-critical > that this be cross-platform. What I'd like it to do is notify me at > certain times of day (say, at 10:32 a.m. and 3:40 p.m.) or after a given > interval of time (say, every XYZ minutes from the moment the app is > activated). > does win know about syslog ? > My practical aim for it is to have a way to remind myself to practice > mindfulness every so often during the day, but I'm also curious how to > handle the timing part of the code. If anyone could recommend where I > can look on the timing part, I'll credit helpful folk when I post the > code to Useless Python!</bribe> > > Rob > -- > > Useless Python! > If your Python is this useless, we need you. > http://www.lowerstandard.com/python/pythonsource.html > HTH Jö! -- I just remembered something about a TOAD! --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="daemon.py" # Daemon Module - basic facilities for becoming a daemon process # # Combines ideas from Steinar Knutsens daemonize.py and # Jeff Kunces demonize.py """Facilities for Creating Python Daemons""" import os import time import sys class NullDevice: def write(self, s): pass def daemonize(): if (not os.fork()): # get our own session and fixup std[in,out,err] os.setsid() os.chdir("/") os.umask(000) sys.stdin.close() sys.stdout = NullDevice() sys.stderr = NullDevice() if (not os.fork()): # hang around till adopted by init ppid = os.getppid() while (ppid != 1): time.sleep(0.5) ppid = os.getppid() else: # time for child to die os._exit(0) else: # wait for child to die and then bail os.wait() sys.exit() --bp/iNruPH9dso1Pn-- From lumbricus@gmx.net Wed Apr 25 16:12:10 2001 From: lumbricus@gmx.net (lumbricus@gmx.net) Date: Wed, 25 Apr 2001 17:12:10 +0200 Subject: [Tutor] Quick Question In-Reply-To: <00b701c0cd4d$e747eb80$0200a8c0@ACE>; from wheelege@tsn.cc on Wed, Apr 25, 2001 at 04:05:48PM +1000 References: <00b701c0cd4d$e747eb80$0200a8c0@ACE> Message-ID: <20010425171210.A2362@Laplace.localdomain> On Wed, Apr 25, 2001 at 04:05:48PM +1000, Glen Wheeler wrote: > Hey guys, and girls ;-) > > I've been writing up a bunch of graphing tools in python...just for fun, and on paper I write x squared as x^2 - this is normal for me. > However, in python, it is x**2 - right? ACK > My question is, what does x^2 do? It seems like x^y === x + y - is this true? NACK: the "^" operator is (like in c) a bitwise exclusive OR > > Thanks, > Glen. HTH Jö -- You'd like to do it instantaneously, but that's too slow. From vlindberg@verio.net Wed Apr 25 22:11:12 2001 From: vlindberg@verio.net (VanL) Date: Wed, 25 Apr 2001 15:11:12 -0600 Subject: [Tutor] removing values using a loop References: <200104250251_MC2-CDA4-570F@compuserve.com> Message-ID: <3AE73D70.5E67C62@verio.net> Hello! Hmmm.. None is also false, by definition. Maybe you could try something like this: #### code start, test 1 #### templinks = alllinks[0] links = string.split(templinks[0],",") for x in links: .... if x: ........ if x == "Kontakt": ............ counter = counter + 1 ............ print "<td>%d. </td>" %(counter) ............ print '<td bgcolor="#EDBE30">', ............ print x ............# more HTML code ....else: ........pass ###### code end ####### HTH, Van From rick@niof.net Wed Apr 25 14:21:22 2001 From: rick@niof.net (Rick Pasotto) Date: Wed, 25 Apr 2001 09:21:22 -0400 Subject: [Tutor] How can i center a window on the screen? In-Reply-To: <000401c0cd64$c605b3a0$3701000a@arthur>; from joerg.sporer@opencom.de on Wed, Apr 25, 2001 at 10:50:25AM +0200 References: <000401c0cd64$c605b3a0$3701000a@arthur> Message-ID: <20010425092122.D507@tc.niof.net> On Wed, Apr 25, 2001 at 10:50:25AM +0200, Jörg Sporer wrote: > Hello! > > How can I create a new Toplevel Widget in the center of the screen in > Windows? If you haven't yet done so, I suggest you get the Pmw (Python MegaWidgets) package. Take a look at the All.py demo do see how he starts with a centered splash screen. -- "I'll take unequal justice to equal injustice any day." Rick Pasotto email: rickp@telocity.com From arcege@speakeasy.net Wed Apr 25 21:14:56 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Wed, 25 Apr 2001 16:14:56 -0400 (EDT) Subject: [Tutor] transferring files over a networky In-Reply-To: <200104250640.CAA10910@smtp10.atl.mindspring.net> from "Stephen Aichele" at Apr 25, 2001 02:40:51 AM Message-ID: <200104252014.f3PKEuC02969@dsl254-114-246.nyc1.dsl.speakeasy.net> Stephen Aichele wrote > > > I'm looking for suggestions for implementing P2P filesharing over a network using Python. > > with respect to the connection itself, I think I'm ok. However, I'm thinking that there must be a better way to handle the data transfer than what I'm currently doing: > > open the file on machine #1, read it into a variable, and send the data (as a python variable) to machine #2. machine #2 then catches it and writes it to a file. > > this is all well and good for simple files, but for longer files it seems like too much data to have read into a variable and sent all at once. seems there should be a way to copy the file directly from machine #1 to machine #2. > > If anyone has a minute to spare with a suggestion or two, I'd really appreciate it... Generally, you want to send "blocks" of data across. >>> blksize = 2048 # 2KB >>> f = open(filename, 'rb') >>> conn = get_remote_connection(...) >>> blk = f.read(blksize) >>> while blk: ... conn.send(blk) ... blk = f.read(blksize) ... >>> conn.shutdown(0) # tell the otherwise we're done >>> f.close() This way, you send 2 kilobytes chunks of the file to the other side at a time (you can adjust the size as needed, but try to make it a power of two). The last block will likely not be the full size, but the data read in and transmitted will be correct, and the remote side will get just that much as needed. The receiver is the reverse of the sender and would look like: >>> blksize = 2048 >>> f = open(filename, 'wb') >>> conn = receive_connection() >>> blk = conn.recv(blksize) >>> while blk: ... f.write(blk) ... blk = conn.recv(blksize) ... >>> f.close() >>> conn.shutdown(0) (You'll have to fill in the network connection routines as needed.) Good luck! -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From arcege@speakeasy.net Wed Apr 25 20:47:04 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Wed, 25 Apr 2001 15:47:04 -0400 (EDT) Subject: [Tutor] removing values using a loopy In-Reply-To: <200104250251_MC2-CDA4-570F@compuserve.com> from "Sharriff Aina" at Apr 25, 2001 02:51:02 AM Message-ID: <200104251947.f3PJl4002931@dsl254-114-246.nyc1.dsl.speakeasy.net> Sharriff Aina wrote >=20 > Hi List! >=20 > I retrieve strings from a database using CGI in the format: > [('Home, None, Kontakt, Termine, None, None')] >=20 > as an example, this string varies according to the database entry made = by > the user > I=B4m trying to generate HTML from these links by splitting the big str= ing > into singular values, my big problem is removing the "None"s. I=B4ve t= ried > my best and rewrote the code at least 3 times, but my code fails and on= ly > works when the nones are at the end of the string, my code: Three common idioms are to use the list methods and filtering and loops. >>> noNone =3D string.split(s, ', ') >>> while noNone.count('None') > 0: ... noNone.remove('None') ... and: >>> noNone =3D filter(lambda s: s !=3D 'None', string.split(s, ', ')) and: >>> noNone =3D [] >>> for x in string.split(s, ', '): ... if x !=3D 'None': ... noNone.append(x) ... Of these, I think Tim and Guido were saying (some years ago) that the most efficient would be the last one. But don't let me put words into their mouths. ;) Also, notice that I use ', ' (with a space) in the separator, this removes the leading whitespace which would likely be messing up your comparisons in your other examples. -Arcege PS: Someone pedantic enough can give some silly little list continuation equivalent. But the above are all version compatible, and since you said you would like to have something soonest... --=20 +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From arcege@speakeasy.net Wed Apr 25 15:07:09 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Wed, 25 Apr 2001 10:07:09 -0400 (EDT) Subject: [Tutor] Quick Questiony In-Reply-To: <00b701c0cd4d$e747eb80$0200a8c0@ACE> from "Glen Wheeler" at Apr 25, 2001 04:05:48 PM Message-ID: <200104251407.f3PE79102546@dsl254-114-246.nyc1.dsl.speakeasy.net> Glen Wheeler wrote > I've been writing up a bunch of graphing tools in python...just for = > fun, and on paper I write x squared as x^2 - this is normal for me. > However, in python, it is x**2 - right? > My question is, what does x^2 do? It seems like x^y =3D=3D=3D x + y - = > is this true? Not quite. The '^' operator is 'exclusive or' in binary arithmatic. Bits in the binary representation of the number are merged together, but where two bits are both one, the result is zero. Since computer programs in the past were far more inclined to binary arithmatic than more complex maths, the "and" (&), "or" (|), "not" (~) and "exclusive or" (^) operations are more prevalent than "power of" (which is "**", but also the pow() function), "square root" (sqrt()) and "absolute value" (which could be "|x|", but is abs(x)), or even the factorial ("!"). However, as you get into graphics, you'll find that a "exclusive or" operator is far more powerful and useful to you than "power of". Moving an object within a bitmap is often accomplished using the exlusive or of the objects bitmap and the background (well, from what I remember of my graphics course years ago anyway ;). -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From arcege@speakeasy.net Wed Apr 25 14:05:03 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Wed, 25 Apr 2001 09:05:03 -0400 (EDT) Subject: [Tutor] How can i center a window on the screen?y In-Reply-To: <000401c0cd64$c605b3a0$3701000a@arthur> from "=?iso-8859-1?Q?J=F6rg_Sporer?=" at Apr 25, 2001 10:50:25 AM Message-ID: <200104251305.f3PD54602452@dsl254-114-246.nyc1.dsl.speakeasy.net> > How can I create a new Toplevel Widget in the center of the screen in > Windows? First, you need to know how big you want your window to be (Ww, Wh). Next would be to determine the (virtual) screen's size (Sx, Sy), then to create a geometry based on those values. x = Sx / 2 - (Ww / 2), y = Sy / 2 - (Wh / 2) You remove half the window's size to offset the top-left corner. >>> t = Toplevel() >>> w, h = t.winfo_width(), t.winfo_height() >>> sx, sy = t.winfo_vrootwidth(), t.winfo_vrootheight() >>> t.geometry('%dx%d+%d+%d' % (w, h, sx/2-w/2, sy/2-h/2)) '' >>> Use the virtual screen's size, instead of the "real" screen since there are programs out there that that make shrink or expand the viewable display. Good luck. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From s349929@student.uq.edu.au Wed Apr 25 23:41:55 2001 From: s349929@student.uq.edu.au (Suzanne Little) Date: Thu, 26 Apr 2001 08:41:55 +1000 (GMT+1000) Subject: [Tutor] can't find module running on apache In-Reply-To: <Pine.LNX.4.21.0104241943120.17133-100000@hkn.eecs.berkeley.edu> Message-ID: <Pine.OSF.4.30.0104260836040.14403-100000@student.uq.edu.au> On Tue, 24 Apr 2001, Robert Hicks wrote: > Are you sure it is MySQL.db that you import and not just MySQL? Thanks Robert. Yes, I'm sure that it's the right name since I can run parts of the code of the server and they work fine. On Tue, 24 Apr 2001, Daniel Yoo wrote: > Can you verify that Python1.52 isn't being run? Since you mentioned > Python 2.0, it could be possible that Apache might be using the wrong > Python version. > > which should tell us if that's the problem. > > Good luck to you! > Thanks Daniel. After running the script I get - 2.0 (#1, Feb 14 2001, 10:51:28) [GCC 2.95.2 19991025 (release)] So that looks like it's right. So neither of those seems to be the problem. Has this happened to anyone else? Suzanne From virketis@fas.harvard.edu Thu Apr 26 05:50:31 2001 From: virketis@fas.harvard.edu (Pijus Virketis) Date: Thu, 26 Apr 2001 00:50:31 -0400 Subject: [Tutor] strange output In-Reply-To: <E14rrdV-0001yg-00@mail.python.org> Message-ID: <200104260446.AAA05493@smtp4.fas.harvard.edu> Hi, not that this is very significant, but perhaps someone can explain this curious bit of output? Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> 4.2-2.5 1.7000000000000002 <-- ?!? Where do we get this miraculous digit? >>># just for comparison ... >>> 7.0-4.0 3.0 <-- All's well ... >>> Cheers, Pijus ---------------------------------------------------------------------------- ------------------- Please have a look at my weblog at www.fas.harvard.edu/~virketis. From scarblac@pino.selwerd.nl Thu Apr 26 09:22:34 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 26 Apr 2001 10:22:34 +0200 Subject: [Tutor] strange output In-Reply-To: <200104260446.AAA05493@smtp4.fas.harvard.edu>; from virketis@fas.harvard.edu on Thu, Apr 26, 2001 at 12:50:31AM -0400 References: <E14rrdV-0001yg-00@mail.python.org> <200104260446.AAA05493@smtp4.fas.harvard.edu> Message-ID: <20010426102234.A2439@pino.selwerd.nl> On 0, Pijus Virketis <virketis@fas.harvard.edu> wrote: > Hi, > > not that this is very significant, but perhaps someone can explain this > curious bit of output? > > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> 4.2-2.5 > 1.7000000000000002 <-- ?!? Where do we get this miraculous digit? > > >>># just for comparison ... > >>> 7.0-4.0 > 3.0 <-- All's well ... > >>> This has to do with the inherent inaccuracy of floating points that are represented by a fixed number of binary digits. '4.2' has no precise representation, neither has '1.7'. I finally got tired of answering this question so I added an explanation to the FAQ, some other people should review it too since it's early morning and I'm sure it could be worded better, but it's really time an explanation for this is in there: http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp -- Remco Gerlich From wheelege@tsn.cc Thu Apr 26 10:30:09 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Thu, 26 Apr 2001 19:30:09 +1000 Subject: [Tutor] Not-so Quick Question Message-ID: <000d01c0ce33$7f0ebc60$0200a8c0@ACE> This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C0CE87.4E2DB8E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey all, I've got this tkinter program which is going to be an arkanoid clone = (eventually). However, it (seemingly) randomly dumps with this error : Traceback (most recent call last): File "C:\WINDOWS\Profiles\Glen\Desktop\etc\pystuff\the bouncy ball = game.py", line 280, in gogamego co =3D Screen.coords(block) File "c:\python20\lib\lib-tk\Tkinter.py", line 1929, in coords self.tk.splitlist( ValueError: invalid literal for float(): 27.0expected What does 'invalid literal' mean? line 280 in gogamego looks like = this : co =3D Screen.coords(block) =20 I really can't see anything wrong with that. Is it complaining = because a function received maybe an integer or perhaps a different = object than a float? 'Screen' is a Canvas widget, and the variable = 'block' is simply a reference to an element on the Screen (a block, if = you hadn't guessed...) so perhaps it is trying to find coords for = something that is not there? I do not know, I don't see how this could = happen - considering that like is in a loop which loops through the = blocks...only the ones which exist. This doesn't happen all the time. In fact, I bet if I run it again = then it won't happen. But since this is for not only me and my personal = enjoyment/learning of python, but also doubles as a project, I don't = want any teacher to run it and then it spit this out at him/her. If you want to see the code then I can post it, but it's hideous :) Incidentally it always crashes with '27.0expected' - never 13.0, 120.0 = or any other float..just 27.0. Thanks, Glen. =20 =20 ------=_NextPart_000_0009_01C0CE87.4E2DB8E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV> Hey all,</DIV> <DIV> </DIV> <DIV> I've got this tkinter program which is going to be an = arkanoid clone=20 (eventually). However, it (seemingly) randomly dumps with this = error=20 :</DIV> <DIV> </DIV> <DIV>Traceback (most recent call last):<BR> File=20 "C:\WINDOWS\Profiles\Glen\Desktop\etc\pystuff\the bouncy ball game.py", = line=20 280, in gogamego<BR> co =3D = Screen.coords(block)<BR> File=20 "c:\python20\lib\lib-tk\Tkinter.py", line 1929, in = coords<BR> =20 self.tk.splitlist(<BR>ValueError: invalid literal for float():=20 27.0expected</DIV> <DIV> </DIV> <DIV> What does 'invalid literal' mean? line 280 in gogamego = looks=20 like this :</DIV> <DIV> </DIV> <DIV> = co =3D=20 Screen.coords(block)</DIV> <DIV> </DIV> <DIV> I really can't see anything wrong with that. Is it = complaining=20 because a function received maybe an integer or perhaps a different = object than=20 a float? 'Screen' is a Canvas widget, and the variable 'block' is = simply a=20 reference to an element on the Screen (a block, if you hadn't = guessed...) so=20 perhaps it is trying to find coords for something that is not = there? I do=20 not know, I don't see how this could happen - considering that like is = in a loop=20 which loops through the blocks...only the ones which exist.</DIV> <DIV> This doesn't happen all the time. In fact, I bet if I = run it=20 again then it won't happen. But since this is for not only me and = my=20 personal enjoyment/learning of python, but also doubles as a project, I = don't=20 want any teacher to run it and then it spit this out at him/her.</DIV> <DIV> If you want to see the code then I can post it, but it's = hideous=20 :)</DIV> <DIV> Incidentally it always crashes with '27.0expected' - never = 13.0,=20 120.0 or any other float..just 27.0.</DIV> <DIV> </DIV> <DIV> Thanks,</DIV> <DIV> Glen.</DIV> <DIV><FONT face=3D"Times New Roman"></FONT> </DIV> <DIV><FONT face=3D"Times New Roman"> </FONT></DIV> <DIV><FONT face=3D"Times New Roman"> = </FONT></DIV></BODY></HTML> ------=_NextPart_000_0009_01C0CE87.4E2DB8E0-- From wheelege@tsn.cc Thu Apr 26 10:34:41 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Thu, 26 Apr 2001 19:34:41 +1000 Subject: [Tutor] amendment to my not-so quick question Message-ID: <003201c0ce34$1f78b700$0200a8c0@ACE> This is a multi-part message in MIME format. ------=_NextPart_000_002F_01C0CE87.F096DEE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey all again, I said that it was always 27.0 - not so. It seems to be not always = 27.0, but any number of different floating point numbers.... Thanks, Glen. ------=_NextPart_000_002F_01C0CE87.F096DEE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV>Hey all again,</DIV> <DIV> </DIV> <DIV> I said that it was always 27.0 - not so. It seems to = be not=20 always 27.0, but any number of different floating point = numbers....</DIV> <DIV> </DIV> <DIV>Thanks,</DIV> <DIV>Glen.</DIV></BODY></HTML> ------=_NextPart_000_002F_01C0CE87.F096DEE0-- From wheelege@tsn.cc Thu Apr 26 10:43:08 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Thu, 26 Apr 2001 19:43:08 +1000 Subject: [Tutor] Quick Question References: <00b701c0cd4d$e747eb80$0200a8c0@ACE> <20010425160139.A24093@father> Message-ID: <00ae01c0ce35$4d30b480$0200a8c0@ACE> Thanks heaps everyone who replied - I can now say I know exactly what the '^' operator does AND explain it (oo as well as understand it). Good old binary :) Thanks again, Glen. (I love this list!) From scarblac@pino.selwerd.nl Thu Apr 26 11:46:09 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 26 Apr 2001 12:46:09 +0200 Subject: [Tutor] Parsing control characters from serial port In-Reply-To: <200104252042.f3PKgd822867@pop.nsacom.net>; from kromag@nsacom.net on Wed, Apr 25, 2001 at 01:42:39PM -0700 References: <200104252042.f3PKgd822867@pop.nsacom.net> Message-ID: <20010426124609.A3052@pino.selwerd.nl> On 0, kromag@nsacom.net wrote: > I have had some success with grabbing strings from '/dev/ttyS0' by using > readline(). It works just like I would expect, i.e. it stops 'listening' when > a 'n' is detected. Actually, a '\n'. That's not an n, but a newline character. > How can I tell readline() to complete a line when another character is > detected? (I am listening for '0x02' FWIW) Temporarily setting os.linesep *might* work, but then that's a Perl-style hack that I wouldn't use. It's a global variable that you set to make your local readline() do something it wasn't intended to do. It probably doesn't work either. Make your own function! > Basically the device on the other end of the serial port talks like this: > > 0x02 #Listen up! I have news for you! > (string of characters) > 0x03 #I'm Done! > > Since readline() opens the serial port and listens intently without need for a > wake-up call, it won't be any big deal to strip the initial '0x02' off, but > ending the message on '0x03' is confusing me. Do I need to somehow tell > readlines() 'n'? > > is there a way to tell python that for the purposes of this function '0x03' == > 'n'? > > I have tried to come up with some sort of garble that does > > while string contents != 0x03 > read it all in and put it here > else n > > (Sorry, I am not at my home machine and lunch is short!) You can read character by character using read(). If there's nothing on the serial line atm (EOF), it returns '', but you still have to keep reading until the rest is there, until the 0x03. Something like def read_serial_line(file): c = file.read(1) if c != '\x02': raise IOError, "Input expected to start with 0x02" sofar = [] while 1: c = file.read(1) if not c: continue if c == '\x03': return "".join(sofar) sofar.append(c) -- Remco Gerlich From kstoner@netins.net Thu Apr 26 13:25:13 2001 From: kstoner@netins.net (Katharine Stoner) Date: Thu, 26 Apr 2001 07:25:13 -0500 Subject: [Tutor] fractions Message-ID: <000a01c0ce4b$f25500e0$1452b1cf@oemcomputer> This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C0CE22.08E7E900 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, Does anyone know of a function to convert fractions to decimals and = decimals to fractions? -Cameron ------=_NextPart_000_0007_01C0CE22.08E7E900 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Does anyone know of a function to = convert fractions=20 to decimals and decimals to fractions?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-Cameron</FONT></DIV> <DIV> </DIV></BODY></HTML> ------=_NextPart_000_0007_01C0CE22.08E7E900-- From arcege@speakeasy.net Thu Apr 26 14:11:04 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Thu, 26 Apr 2001 09:11:04 -0400 (EDT) Subject: [Tutor] fractions In-Reply-To: <000a01c0ce4b$f25500e0$1452b1cf@oemcomputer> from "Katharine Stoner" at Apr 26, 2001 07:25:13 AM Message-ID: <200104261311.f3QDB5001824@dsl092-074-184.bos1.dsl.speakeasy.net> --%--multipart-mixed-boundary-1.1422.988290664--% Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > Hi all, > > Does anyone know of a function to convert fractions to decimals and = > decimals to fractions? There is no nice function to do it, simply because there are no fractions in Python (maybe in P3K?). But a couple of years ago (Jan '99), there were questions about rational numbers in Python and I whipped up a little class which I'm attaching. If you mean simply the division of integers (as opposed to fractions as a data type). Then you can do something as simple as: x / float(y) Division of a float with any other object (except a complex number) will result in a float. Converting back to a "fraction" is something else - there has to be the exception where it is not possible. In fact, I just realized that my rational class doesn't even do this. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | --%--multipart-mixed-boundary-1.1422.988290664--% Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Description: a /usr/local/bin/python script text Content-Disposition: attachment; filename="rational.py" #!/usr/local/bin/python # Copyright (C) 1999 Michael P. Reilly, All rights reserved class Rational: def __init__(self, numerator, denominator=1): if denominator == 0: raise ValueError, 'undefined value' if isinstance(numerator, Rational): denominator = denominator * numerator.d numerator = numerator.n if int(numerator) != numerator or int(denominator) != int(denominator): raise ValueError, 'must supply integer values (for now)' self.n = int(numerator) self.d = int(denominator) self.normalize() def __int__(self): return int(self.n/self.d) def __float__(self): return float(self.n)/self.d def __str__(self): if self.d == 1: return '%d' % self.n else: return '%d/%d' % (self.n, self.d) def __repr__(self): return '%s(%d, %d)' % (self.__class__.__name__, self.n, self.d) def __cmp__(self, other): s, o, d = self.gcd(other) return cmp(s, o) def __rcmp__(self, other): s, o, d = self.gcd(other) return cmp(o, s) def normalize(self): num = self.n dem = self.d # this isn't the best algorithm i = dem while i > 0: if (num % i) == 0 and (dem % i) == 0: break i = i - 1 else: return self.n = int(num/i) self.d = int(dem/i) def gcd(self, other): sn = self.n * other.d on = other.n * self.d d = self.d * other.d return (sn, on, d) def __add__(self, other): s, o, d = self.gcd(other) r = self.__class__(s+o, d) return r __radd__ = __add__ def __sub__(self, other): s, o, d = self.gcd(other) r = self.__class__(s-o, d) return r def __rsub__(self, other): s, o, d = self.gcd(other) r = self.__class__(o-s, d) return r def __mul__(self, other): r = self.__class__(self.n*other.n, self.d*other.d) return r __rmul__ = __mul__ def __div__(self, other): r = self.__class__(self.n*other.d, self.d*other.n) return r def __rdiv__(self, other): r = self.__class__(other.n*self.d, other.d*self.n) return r def __mod__(self, other): r = divmod(self, other) return r[1] def __rmod__(self, other): r = divmod(other, self) return r[1] def __divmod__(self, other): r = self / other whole = r.n / r.d remainder = r.n % r.d return (whole, remainder) def __rdivmod__(self, other): r = other / self whole = r.n / r.d remainder = r.n % r.d return (whole, remainder) def __pow__(self, other): if other.d < 0: # great, now check for complex if other.d == -1: return complex(0, float(self)) else: raise ValueError, 'not implimented' sn = pow(self.n, float(other)) sd = pow(self.d, float(other)) r = self.__class__(sn, sd) return r def __rpow__(self, other): return other ** self def __neg__(self): r = self.__class__(-self.n, self.d) return r def __pos__(self): r = self.__class__(self.n, self.d) return r def __abs__(self): r = self.__class__(abs(self.n), abs(self.d)) return r def __coerce__(self, other): if isinstance(other, Rational): return self, other elif type(other) is type(0): return self, self.__class__(other) elif type(other) is type(0L): return self, self.__class__(other) elif type(other) is type(0.0): raise ValueError, 'not implimented' elif type(other) == type(0j): raise ValueError, 'not implimented' return self, self.__class__(other.real, other.imag) --%--multipart-mixed-boundary-1.1422.988290664--%-- From glingl@mail.rg16.asn-wien.ac.at Thu Apr 26 14:17:59 2001 From: glingl@mail.rg16.asn-wien.ac.at (Gregor Lingl) Date: Thu, 26 Apr 2001 15:17:59 +0200 Subject: [Tutor] fractions References: <000a01c0ce4b$f25500e0$1452b1cf@oemcomputer> Message-ID: <3AE82007.1A0D3E57@rg16.asn-wien.ac.at> --------------5E254BDC9F658F00391A326D Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Katharine Stoner schrieb: > Hi all, Does anyone know of a function to convert fractions to > decimals and decimals to fractions? -Cameron Dear Cameron, You may have a look at http://www.lowerstandard.com/python/ACMsolutions.html which contains two solutions ( 332gsl.py and 332gl.py) to the problem posed on: http://acm.uva.es/problemset/v3/332.html which is the heavier part of your question. For the other part you may use the expression 1.0*p/q to convert the fraction p/q into a float. Have a lot of fun ;-) Gregor Lingl --------------5E254BDC9F658F00391A326D Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <body bgcolor="#FFFFFF"> <p>Katharine Stoner schrieb: <blockquote TYPE=CITE><style></style> <font face="Arial"><font size=-1>Hi all,</font></font> <font face="Arial"><font size=-1>Does anyone know of a function to convert fractions to decimals and decimals to fractions?</font></font> <font face="Arial"><font size=-1>-Cameron</font></font> </blockquote> <p><br>Dear Cameron, <p>You may have a look at <p> <a href="http://www.lowerstandard.com/python/ACMsolutions.html">http://www.lowerstandard.com/python/ACMsolutions.html</a> <p>which contains two solutions ( 332gsl.py and 332gl.py) to the problem posed on: <p> <a href="http://acm.uva.es/problemset/v3/332.html">http://acm.uva.es/problemset/v3/332.html</a> which is the heavier part of your question. <p>For the other part you may use the expression 1.0*p/q to convert <br>the fraction p/q into a float. <p>Have a lot of fun ;-) <p>Gregor Lingl </body> </html> --------------5E254BDC9F658F00391A326D-- From dyoo@hkn.eecs.berkeley.edu Thu Apr 26 15:12:10 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 26 Apr 2001 07:12:10 -0700 (PDT) Subject: [Tutor] Not-so Quick Question In-Reply-To: <000d01c0ce33$7f0ebc60$0200a8c0@ACE> Message-ID: <Pine.LNX.4.21.0104260706500.6331-100000@hkn.eecs.berkeley.edu> On Thu, 26 Apr 2001, Glen Wheeler wrote: > Hey all, > > I've got this tkinter program which is going to be an arkanoid clone (eventually). However, it (seemingly) randomly dumps with this error : > > Traceback (most recent call last): > File "C:\WINDOWS\Profiles\Glen\Desktop\etc\pystuff\the bouncy ball game.py", line 280, in gogamego > co = Screen.coords(block) > File "c:\python20\lib\lib-tk\Tkinter.py", line 1929, in coords > self.tk.splitlist( > ValueError: invalid literal for float(): 27.0expected Hmmm... Do you have any string that looks like "27.0expected"? The problem with float() is that if you're going to convert something into a float, the whole string needs to have a floatlike quality to it. For example: ### >>> float(27.0) 27.0 >>> float("27.0") 27.0 >>> float("27.0a") Traceback (innermost last): File "<stdin>", line 1, in ? ValueError: invalid literal for float(): 27.0a ### So if there's even a hint of extra stuff in the string, it won't successfully bend itself into a float. That's what they mean by invalid literal. A similar thing happens with the int() function: ### >>> int("27.0") Traceback (innermost last): File "<stdin>", line 1, in ? ValueError: invalid literal for int(): 27.0 >>> int(float("27.0")) 27 ### and this was a bit of a shock to me, that it actually takes two passes to get the string "27.0" into an integer form. Hope this helps! From liana@upfrontsystems.co.za Thu Apr 26 15:31:08 2001 From: liana@upfrontsystems.co.za (Liana Wiehahn) Date: Thu, 26 Apr 2001 16:31:08 +0200 Subject: [Tutor] % function Message-ID: <NFBBLFKIFKOLKGJBGPFCAEGCCIAA.liana@upfrontsystems.co.za> hi Can somebody please explain to me when you are using the % function and explain it to me? thanks liana From scarblac@pino.selwerd.nl Thu Apr 26 15:48:55 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 26 Apr 2001 16:48:55 +0200 Subject: [Tutor] % function In-Reply-To: <NFBBLFKIFKOLKGJBGPFCAEGCCIAA.liana@upfrontsystems.co.za>; from liana@upfrontsystems.co.za on Thu, Apr 26, 2001 at 04:31:08PM +0200 References: <NFBBLFKIFKOLKGJBGPFCAEGCCIAA.liana@upfrontsystems.co.za> Message-ID: <20010426164855.A3505@pino.selwerd.nl> On 0, Liana Wiehahn <liana@upfrontsystems.co.za> wrote: > Can somebody please explain to me when you are using the % function and > explain it to me? There are two different % operators, one for numbers and one for strings. The number one computes the remainder of a division: >>> 4 % 3 1 # Because if you do 4/3, the remainder is 1 You probably meant the string operator :). The idea is to have a format string, in which you leave some positions open, so you can fill them in later. >>> x = "Liana" >>> "Hello, %s!" % x "Hello, Liana!" This is neater than >>> "Hello, "+x+"!" and it quickly becomes a lot better when there's more than one variable. The %s means that a string can be filled in there. If you have multiple things to fill in, use a tuple: >>> "%s, %s, %s, %s and %s" % ("spam","spam","spam","bacon","spam") "spam, spam, spam, bacon and spam" There are several different % things you can use, which are available depends on the C library I think, and there's no good page for a complete list (try searching for the Linux man printf page, or do man printf if you're on Unix/Linux). '%%' simply means a % sign. %d is used for integers. >>> '%d' % 4 '4' >>> '%3d' % 4 # The 4 is the field size. Works for strings too. ' 4' >>> '%03d' % 4 # Fill the field up with 0s '004' >>> '%-3d' % 4 # Align the field to the left, not right '4 ' The last neat trick is % with a dictionary. You can put give variables you use in the format string a name, and fill them in with a dictionary: format = "Agent %(agent)03d's name is %(surname)s. %(name)s %(surname)s." print format % { 'agent': 7 'name': 'James' 'surname': 'Bond' } Prints "Agent 007's name is Bond. James Bond." I find I hardly ever need other things than %s and %d. -- Remco Gerlich From wheelege@tsn.cc Thu Apr 26 16:08:31 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Fri, 27 Apr 2001 01:08:31 +1000 Subject: [Tutor] Not-so Quick Question References: <Pine.LNX.4.21.0104260706500.6331-100000@hkn.eecs.berkeley.edu> Message-ID: <03b401c0ce62$c380f820$0200a8c0@ACE> > On Thu, 26 Apr 2001, Glen Wheeler wrote: > > > Hey all, > > > > I've got this tkinter program which is going to be an arkanoid clone (eventually). However, it (seemingly) randomly dumps with this error : > > > > Traceback (most recent call last): > > File "C:\WINDOWS\Profiles\Glen\Desktop\etc\pystuff\the bouncy ball game.py", line 280, in gogamego > > co = Screen.coords(block) > > File "c:\python20\lib\lib-tk\Tkinter.py", line 1929, in coords > > self.tk.splitlist( > > ValueError: invalid literal for float(): 27.0expected > > > Hmmm... Do you have any string that looks like "27.0expected"? The > problem with float() is that if you're going to convert something into a > float, the whole string needs to have a floatlike quality to it. For > example: > > <snip examples on how to use and what not to do with the int() and float() functions> No, I'm not converting anything at all to a float, anywhere in my entire propgram...well, maybe somehwere but if I am then I'm pretty sure I'm doing it right. That leads me to believe that something is spitting inside the function 'coords' in the Canvas widget. I had a poke around, but I am way too newbie to make any sort of understanding. Why would Tkinter.py output '27.0expected' for a float instead of '27.0'? Or any number of other flaots which it may output? I added a try-except block around that chunk of code, so it looks like this : try: co = Screen.coords(block) except: print 'weird float error...' And on one complete run-through it will print 'weird float error...' several times, but will continue to hum along nicely regardless. I can't notice any outside symptoms of this, but I really don't believe in (essentially) ignoring a problem. Would it be that I am asking for the co-ordinates of something that is not on the Screen (canvas) ? Thanks, Glen. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From scarblac@pino.selwerd.nl Thu Apr 26 16:32:16 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 26 Apr 2001 17:32:16 +0200 Subject: [Tutor] Not-so Quick Question In-Reply-To: <03b401c0ce62$c380f820$0200a8c0@ACE>; from wheelege@tsn.cc on Fri, Apr 27, 2001 at 01:08:31AM +1000 References: <Pine.LNX.4.21.0104260706500.6331-100000@hkn.eecs.berkeley.edu> <03b401c0ce62$c380f820$0200a8c0@ACE> Message-ID: <20010426173216.A3593@pino.selwerd.nl> On 0, Glen Wheeler <wheelege@tsn.cc> wrote: > > On Thu, 26 Apr 2001, Glen Wheeler wrote: > > > > > Hey all, > > > > > > I've got this tkinter program which is going to be an arkanoid clone > (eventually). However, it (seemingly) randomly dumps with this error : > > > > > > Traceback (most recent call last): > > > File "C:\WINDOWS\Profiles\Glen\Desktop\etc\pystuff\the bouncy ball > game.py", line 280, in gogamego > > > co = Screen.coords(block) > > > File "c:\python20\lib\lib-tk\Tkinter.py", line 1929, in coords > > > self.tk.splitlist( > > > ValueError: invalid literal for float(): 27.0expected > > > > > > Hmmm... Do you have any string that looks like "27.0expected"? The > > problem with float() is that if you're going to convert something into a > > float, the whole string needs to have a floatlike quality to it. For > > example: > > > > <snip examples on how to use and what not to do with the int() and float() > functions> > > No, I'm not converting anything at all to a float, anywhere in my entire > propgram... The actual float() happened in line 1929 of Tkinter.py, in a function that was in turn called by your program. Does the string "expected" occur in any part of your program? Or the input? > That leads me to believe that something is spitting inside the function > 'coords' in the Canvas widget. I had a poke around, but I am way too newbie > to make any sort of understanding. Why would Tkinter.py output > '27.0expected' for a float instead of '27.0'? Hmm. In Tcl, everything is a string. Accidentally added 27.0 and "expected" together for some reason? > I added a try-except block around that chunk of code, so it looks like > this : > > try: > co = Screen.coords(block) > except: > print 'weird float error...' > > And on one complete run-through it will print 'weird float error...' > several times, but will continue to hum along nicely regardless. I can't > notice any outside symptoms of this, but I really don't believe in > (essentially) ignoring a problem. Would it be that I am asking for the > co-ordinates of something that is not on the Screen (canvas) ? Try to make your problem as small as possible, ie make the smallest program that still has the problem. This may well be a Tcl/Tk bug, if you're sure the 'expected' string doesn't occur in your program. -- Remco Gerlich From wheelege@tsn.cc Thu Apr 26 16:45:46 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Fri, 27 Apr 2001 01:45:46 +1000 Subject: [Tutor] Not-so Quick Question References: <Pine.LNX.4.21.0104260706500.6331-100000@hkn.eecs.berkeley.edu> <03b401c0ce62$c380f820$0200a8c0@ACE> <20010426173216.A3593@pino.selwerd.nl> Message-ID: <040601c0ce67$f6aa8ea0$0200a8c0@ACE> > On 0, Glen Wheeler <wheelege@tsn.cc> wrote: > > > On Thu, 26 Apr 2001, Glen Wheeler wrote: > > > > > > > Hey all, > > > > > > > > I've got this tkinter program which is going to be an arkanoid clone > > (eventually). However, it (seemingly) randomly dumps with this error : > > > > > > > > Traceback (most recent call last): > > > > File "C:\WINDOWS\Profiles\Glen\Desktop\etc\pystuff\the bouncy ball > > game.py", line 280, in gogamego > > > > co = Screen.coords(block) > > > > File "c:\python20\lib\lib-tk\Tkinter.py", line 1929, in coords > > > > self.tk.splitlist( > > > > ValueError: invalid literal for float(): 27.0expected > > > > > > > > > Hmmm... Do you have any string that looks like "27.0expected"? The > > > problem with float() is that if you're going to convert something into a > > > float, the whole string needs to have a floatlike quality to it. For > > > example: > > > > > > <snip examples on how to use and what not to do with the int() and float() > > functions> > > > > No, I'm not converting anything at all to a float, anywhere in my entire > > propgram... > > The actual float() happened in line 1929 of Tkinter.py, in a function that > was in turn called by your program. > > Does the string "expected" occur in any part of your program? Or the input? > Nope, never...not unless your counting docstrings :) > > That leads me to believe that something is spitting inside the function > > 'coords' in the Canvas widget. I had a poke around, but I am way too newbie > > to make any sort of understanding. Why would Tkinter.py output > > '27.0expected' for a float instead of '27.0'? > > Hmm. In Tcl, everything is a string. Accidentally added 27.0 and "expected" > together for some reason? > Quite possible...but I have no idea how that would happen. Unless threads are messing around. > > I added a try-except block around that chunk of code, so it looks like > > this : > > > > try: > > co = Screen.coords(block) > > except: > > print 'weird float error...' > > > > And on one complete run-through it will print 'weird float error...' > > several times, but will continue to hum along nicely regardless. I can't > > notice any outside symptoms of this, but I really don't believe in > > (essentially) ignoring a problem. Would it be that I am asking for the > > co-ordinates of something that is not on the Screen (canvas) ? > > Try to make your problem as small as possible, ie make the smallest program > that still has the problem. This may well be a Tcl/Tk bug, if you're sure > the 'expected' string doesn't occur in your program. > I'll try and replicate it in a small prog asap. Could threads be confusing tcl? I have one running which almost never stops and spawns other threads (but only two are ever running at the same time). I read somewhere that variable values can get confused by threads - is this an issue here? I'm running win98. > -- > Remco Gerlich > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From bdupire@seatech.fau.edu Thu Apr 26 17:22:48 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Thu, 26 Apr 2001 12:22:48 -0400 Subject: [Tutor] strange output References: <E14rrdV-0001yg-00@mail.python.org> <200104260446.AAA05493@smtp4.fas.harvard.edu> <20010426102234.A2439@pino.selwerd.nl> Message-ID: <3AE84B57.A962DCC7@seatech.fau.edu> Computer store numbers using a binary representation. For example, a= 1101 0101. So if you decide to have 4 digits for the fractional part, this number can be converted to decimal in this way trunc(a) = 1101 ---> trunc (a) = 1 * 2^3 + 1 * 2^2 + 0 * 2^1 + 1 * 2^0 = 13 fract(a) = 0101 --> fract (a) = 0 * 2^(-1) + 1 * 2^(-2) + 0 * 2^(-3) + 1* 2^(-4) = 0 * 1/2 + 1 * 1/4 + 0 * 1/8 + 1 * 1/16 As you can see, the precision obtained is 1/16. a = 13.3125 Tne number just prior to 'a' is 1101 0100, which is 13.25 in decimal. You can see that 13.3 has no correct representation, but it's not related to Python, just to the way numbers are represented by the computer. Benoit Remco Gerlich wrote: > On 0, Pijus Virketis <virketis@fas.harvard.edu> wrote: > > Hi, > > > > not that this is very significant, but perhaps someone can explain this > > curious bit of output? > > > > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > > Type "copyright", "credits" or "license" for more information. > > IDLE 0.8 -- press F1 for help > > >>> 4.2-2.5 > > 1.7000000000000002 <-- ?!? Where do we get this miraculous digit? > > > > >>># just for comparison ... > > >>> 7.0-4.0 > > 3.0 <-- All's well ... > > >>> > > This has to do with the inherent inaccuracy of floating points that are > represented by a fixed number of binary digits. '4.2' has no precise > representation, neither has '1.7'. > > I finally got tired of answering this question so I added an explanation to > the FAQ, some other people should review it too since it's early morning and > I'm sure it could be worded better, but it's really time an explanation > for this is in there: > http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp > > -- > Remco Gerlich > From me@mboffin.com Thu Apr 26 17:57:06 2001 From: me@mboffin.com (Dylan Bennett) Date: Thu, 26 Apr 2001 09:57:06 -0700 Subject: [Tutor] Newbie question Message-ID: <001e01c0ce71$ed6ace40$2101a8c0@delphian.org> Hello, everyone. I just joined this list. I'm an instructor at a private boarding school and I'm looking at implementing Python as the introductory computer language for the students in the computer classes. (Right now we use QuickBASIC, which is rather out-dated.) I am new to Python myself. Since I'm exploring different ways of teaching Python to someone who has zero programming experience, I have been looking through some of the online resources. I am currently following a tutorial that was linked on the python.org site. If any of you happen to know of excellent resources for teaching Python to students with zero programming experience, please let me know. Now to my question. :) So I'm going through this tutorial and it says to do the following: s = raw_input("Who are you? ") That should pass what the user inputs to the variable s. However, when I run the program it gets to where I can input data, but then after I hit enter, it doesn't do anything. I just goes to the next line. Nothing I try will actually end it accepting input. It just keeps accepting input no matter how many times I hit enter. I even tried ctrl-enter, shift-enter, etc. Oh yeah, and I'm using IDLE in a Windows environment. Anyone have any ideas on why this isn't working? --Dylan From deirdre@deirdre.net Thu Apr 26 18:01:20 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Thu, 26 Apr 2001 10:01:20 -0700 Subject: [Tutor] Newbie question In-Reply-To: <001e01c0ce71$ed6ace40$2101a8c0@delphian.org> Message-ID: <l0313031bb70e04c3aa9e@[10.0.1.18]> >Now to my question. :) So I'm going through this tutorial and it says to do >the following: > >s = raw_input("Who are you? ") > >That should pass what the user inputs to the variable s. However, when I run >the program it gets to where I can input data, but then after I hit enter, >it doesn't do anything. I just goes to the next line. Nothing I try will >actually end it accepting input. It just keeps accepting input no matter how >many times I hit enter. I even tried ctrl-enter, shift-enter, etc. Oh yeah, >and I'm using IDLE in a Windows environment. Anyone have any ideas on why >this isn't working? What's the rest of the program after that line? -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From wheelege@tsn.cc Thu Apr 26 18:02:38 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Fri, 27 Apr 2001 03:02:38 +1000 Subject: [Tutor] Newbie question References: <001e01c0ce71$ed6ace40$2101a8c0@delphian.org> Message-ID: <047a01c0ce72$b3002a60$0200a8c0@ACE> > Hello, everyone. I just joined this list. I'm an instructor at a private > boarding school and I'm looking at implementing Python as the introductory > computer language for the students in the computer classes. (Right now we > use QuickBASIC, which is rather out-dated.) I am new to Python myself. Since > I'm exploring different ways of teaching Python to someone who has zero > programming experience, I have been looking through some of the online > resources. I am currently following a tutorial that was linked on the > python.org site. If any of you happen to know of excellent resources for > teaching Python to students with zero programming experience, please let me > know. > Alan Gauld's tutorial is great - you can find it at http://www.crosswinds.net/~agauld > Now to my question. :) So I'm going through this tutorial and it says to do > the following: > > s = raw_input("Who are you? ") > > That should pass what the user inputs to the variable s. However, when I run > the program it gets to where I can input data, but then after I hit enter, > it doesn't do anything. I just goes to the next line. Nothing I try will > actually end it accepting input. It just keeps accepting input no matter how > many times I hit enter. I even tried ctrl-enter, shift-enter, etc. Oh yeah, > and I'm using IDLE in a Windows environment. Anyone have any ideas on why > this isn't working? > Alright, first off, are you at the interactive window? If so, then it will just keep accepting input - that's its job. If your not in the interactive window then try altering your script to say something like... s = raw_input("Who are you? ") print s Then save and run. If your going to go onto tkinter (the standard GUI toolkit for python) then I suggest you grab the Activestate IDE - it is not written IN tk (as opposed to IDLE) and handles such things alot better. Also, I have had bad experiences with threads in IDLE. I'm still relatively new myself, so don't just go on what I say :) Glen. > --Dylan > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From arcege@speakeasy.net Thu Apr 26 19:10:02 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Thu, 26 Apr 2001 14:10:02 -0400 (EDT) Subject: [Tutor] Newbie questiony In-Reply-To: <001e01c0ce71$ed6ace40$2101a8c0@delphian.org> from "Dylan Bennett" at Apr 26, 2001 09:57:06 AM Message-ID: <200104261810.f3QIA2x01236@dsl092-074-184.bos1.dsl.speakeasy.net> Dylan Bennett wrote > Now to my question. :) So I'm going through this tutorial and it says to do > the following: > > s = raw_input("Who are you? ") > > That should pass what the user inputs to the variable s. However, when I run > the program it gets to where I can input data, but then after I hit enter, > it doesn't do anything. I just goes to the next line. Nothing I try will > actually end it accepting input. It just keeps accepting input no matter how > many times I hit enter. I even tried ctrl-enter, shift-enter, etc. Oh yeah, > and I'm using IDLE in a Windows environment. Anyone have any ideas on why > this isn't working? This shouldn't be a problem with newer versions of IDLE (version 0.4 and later), but once upon a time it was indeed a problem. You might want to try Ctrl-D and Ctrl-Z (although I think both would end IDLE). Check which version you are using (select "About IDLE..." from the Help menu). And you might also want to see which version of Python you are running while you are at it. :) -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From pythoperson@yahoo.com Thu Apr 26 20:56:01 2001 From: pythoperson@yahoo.com (folklore hopeful) Date: Thu, 26 Apr 2001 12:56:01 -0700 (PDT) Subject: [Tutor] One more time: weird python windows batch file error Message-ID: <20010426195601.57704.qmail@web12405.mail.yahoo.com> Hello all, I posted about this before but perhaps I did not word it correctly. I have written a nifty python program and have burned it, along with py20, onto a CD-ROM so that it can be easily used on Win95 computers without installing Python. To make it easier for my non-dos savvy audience, I am trying to use a batch file to start the python program. That way I can say to everyone "click on My Computer. Click on the D drive. Click on the file call FOO.BAT" and we're away. My FOO.BAT contains this: @echo off pythonw FOO.PY It works just fine, but pops up an error message every time my users exit the program. It's the basic windows error message which says, in a nutshel "Pythonw.exe has done something illegal, tell it stop." Any suggestions what the problem might be? I know there are solutions other than a batch file, but I am now curious about this particular problem, regardless of whether there's a better way. What is causing the problem? Is it python? My batch file? Or windows? I appreciate any advice. Thanks to everyone for their help so far. __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ From phil.bertram@clear.net.nz Thu Apr 26 21:17:09 2001 From: phil.bertram@clear.net.nz (Phil Bertram) Date: Fri, 27 Apr 2001 08:17:09 +1200 Subject: [Tutor] How to inspect variables in a module from the command line Message-ID: <003901c0ce8d$f7aaa440$723661cb@pf05nt.bayernz.co.nz> This is a multi-part message in MIME format. ------=_NextPart_000_0036_01C0CEF2.742197E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I often develop my programs by writing a class in a module class MyClass: stuff here if __name__ =3D=3D '__main__' : klass=3DMyClass() klass.mutate() print klass.attribute to run and test scripts written in a module. With print statements for = debugging. (I press f5 in PythonWin). Is there a way to switch to the interpreter and inspect the variables in = the module I've tried thinds like=20 >>> __main__.klass.anotherAttribute but can't seem to work it out. Any ideas ? Phil B ------=_NextPart_000_0036_01C0CEF2.742197E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Dwindows-1252"> <META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR></HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT size=3D2>Hi all,</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>I often develop my programs by writing a class in a=20 module</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>class MyClass:</FONT></DIV> <DIV><FONT size=3D2> stuff here</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>if __name__ =3D=3D '__main__' :</FONT></DIV> <DIV><FONT size=3D2> klass=3DMyClass()</FONT></DIV> <DIV><FONT size=3D2> klass.mutate()</FONT></DIV> <DIV><FONT size=3D2> print = klass.attribute</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>to run and test scripts written in a module. With = print=20 statements for debugging. (I press f5 in PythonWin).</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>Is there a way to switch to the interpreter and = inspect the=20 variables in the module</FONT><FONT size=3D2></FONT></DIV> <DIV><FONT size=3D2>I've tried thinds like </FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2>>>> = __main__.klass.anotherAttribute</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>but can't seem to work it out.</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>Any ideas ?</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>Phil B</FONT></DIV></BODY></HTML> ------=_NextPart_000_0036_01C0CEF2.742197E0-- From me@mboffin.com Thu Apr 26 22:04:37 2001 From: me@mboffin.com (Dylan Bennett) Date: Thu, 26 Apr 2001 14:04:37 -0700 Subject: [Tutor] Newbie question References: <001e01c0ce71$ed6ace40$2101a8c0@delphian.org> <047a01c0ce72$b3002a60$0200a8c0@ACE> Message-ID: <001201c0ce94$8116a340$2101a8c0@delphian.org> Ok, I feel like kind of a putz. Some other things weren't working, so I checked some stuff out. Turns out I downloaded 1.52, not the latest version of 2.1. Hehe. Thanks for the help, anyway. I take it as a good sign of a close-knit, active community that within 15 minutes of posting I had gotten something like 5 replies. :) --Dylan From Desai.Dinakar@mayo.edu Thu Apr 26 22:16:48 2001 From: Desai.Dinakar@mayo.edu (Dinakar Desai) Date: Thu, 26 Apr 2001 16:16:48 -0500 Subject: [Tutor] command line syntax References: <001e01c0ce71$ed6ace40$2101a8c0@delphian.org> <047a01c0ce72$b3002a60$0200a8c0@ACE> <001201c0ce94$8116a340$2101a8c0@delphian.org> Message-ID: <3AE89040.AD39F5FB@mayo.edu> This is a multi-part message in MIME format. --------------92077563F41A7664805DA842 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello Everyone: I was wondering is there any way one can write command line script like that done in perl or shell. I tried FAQ and could not find what I was looking for. I look forward to hear from you. Dinakar --------------92077563F41A7664805DA842 Content-Type: text/x-vcard; charset=us-ascii; name="desai.dinakar.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Dinakar Desai Content-Disposition: attachment; filename="desai.dinakar.vcf" begin:vcard n:Desai;Dinakar tel;fax:507-284-0615 tel;home:507-289-3972 tel;work:507-266-2831 x-mozilla-html:FALSE adr:;;;;;; version:2.1 email;internet:desai.dinakar@mayo.edu note;quoted-printable:Restrictive tools designed to prevent the worst programmers from failing often prevent the best=0D=0Aprogrammers from succeeding. Conversely, unsupportive languages and tools can make average=0D=0Aprogrammers unproductive. fn:Dinakar end:vcard --------------92077563F41A7664805DA842-- From scarblac@pino.selwerd.nl Thu Apr 26 22:31:36 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 26 Apr 2001 23:31:36 +0200 Subject: [Tutor] command line syntax In-Reply-To: <3AE89040.AD39F5FB@mayo.edu>; from Desai.Dinakar@mayo.edu on Thu, Apr 26, 2001 at 04:16:48PM -0500 References: <001e01c0ce71$ed6ace40$2101a8c0@delphian.org> <047a01c0ce72$b3002a60$0200a8c0@ACE> <001201c0ce94$8116a340$2101a8c0@delphian.org> <3AE89040.AD39F5FB@mayo.edu> Message-ID: <20010426233136.A4669@pino.selwerd.nl> On 0, Dinakar Desai <Desai.Dinakar@mayo.edu> wrote: > I was wondering is there any way one can write command line script like > that done in perl or shell. > I tried FAQ and could not find what I was looking for. > > > I look forward to hear from you. I'm not sure what you mean. Is the -c option what you're looking for? bash$ python -c 'print "whee"' whee bash$ python -c ' > from time import * > print ctime() > ' Thu Apr 26 23:29:58 2001 If you want a script that you can start from the command line, just put in the appropriate #! line (#!/usr/bin/env python) just like you would with sh, perl, tcl, expect or whatever... -- Remco Gerlich From scarblac@pino.selwerd.nl Thu Apr 26 22:42:42 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 26 Apr 2001 23:42:42 +0200 Subject: [Tutor] How to inspect variables in a module from the command line In-Reply-To: <003901c0ce8d$f7aaa440$723661cb@pf05nt.bayernz.co.nz>; from phil.bertram@clear.net.nz on Fri, Apr 27, 2001 at 08:17:09AM +1200 References: <003901c0ce8d$f7aaa440$723661cb@pf05nt.bayernz.co.nz> Message-ID: <20010426234242.B4669@pino.selwerd.nl> On 0, Phil Bertram <phil.bertram@clear.net.nz> wrote: > I often develop my programs by writing a class in a module > > class MyClass: > stuff here > > if __name__ == '__main__' : > klass=MyClass() > klass.mutate() > print klass.attribute > > to run and test scripts written in a module. With print statements for debugging. (I press f5 in PythonWin). > > Is there a way to switch to the interpreter and inspect the variables in the module > I've tried thinds like > > >>> __main__.klass.anotherAttribute > > but can't seem to work it out. > > Any ideas ? I'm not sure what you mean so I'll just put some suggestions here. The current module's name is in __name__ (in the interactive interpreter, it's usually '__main__'). You can use that name to look up the module, in the dictionary sys.modules. The dir() function shows a list attributes of a module (or class, or other object). With getattr(object, name) you can get the value of some object So something like this is possible: import sys mod = sys.modules[__name__] # Get current module for attr in dir(mod): print attr, "=", repr(getattr(mod, attr)) This is what we call neat introspection abilities :) Similarly, mod.klass is the class klass in the module mod, and you can look at its attributes with dir() and getattr(), exactly the same way. Instead of mod, you can also use some module you just imported, like your script. With the command line option -i you can run a script first, then go into the interactive interpreter to inspect things (I don't have much Idle experience). Hmm, I hope I've written down enough random thoughts now to get to something useful :-) -- Remco Gerlich From aichele@mindspring.com Thu Apr 26 22:52:42 2001 From: aichele@mindspring.com (Stephen Aichele) Date: Thu, 26 Apr 2001 17:52:42 -0400 (EDT) Subject: [Tutor] id() In-Reply-To: <E14soCd-0004Gu-00@mail.python.org> Message-ID: <200104262152.RAA16267@mclean.mail.mindspring.net> I have a question regarding the use of id(): basically, I'd like to find a way to reverse this process- in otherwords, is there a way to access a specific instance's attributes from the id # alone? I need to do this because in my app, I may have several instances of the same class up concurrently - all with the same variable name... (I'm using wxPython) - I know that by reusing the variable name, I won't have access to any but the last instance created; however, I'm wondering if the previous instance IDs will still exist and if so, how to use them to access previous instances/windows... sorry to be so confusing (and confused), but if anyone has an idea of my problem and how to deal with it, I'd love to hear it. thanks! -Stephen From scarblac@pino.selwerd.nl Thu Apr 26 22:59:48 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Thu, 26 Apr 2001 23:59:48 +0200 Subject: [Tutor] id() In-Reply-To: <200104262152.RAA16267@mclean.mail.mindspring.net>; from aichele@mindspring.com on Thu, Apr 26, 2001 at 05:52:42PM -0400 References: <E14soCd-0004Gu-00@mail.python.org> <200104262152.RAA16267@mclean.mail.mindspring.net> Message-ID: <20010426235948.A4750@pino.selwerd.nl> On 0, Stephen Aichele <aichele@mindspring.com> wrote: > I have a question regarding the use of id(): basically, I'd like to find a > way to reverse this process- in otherwords, is there a way to access a > specific instance's attributes from the id # alone? No. > I need to do this because in my app, I may have several instances of the > same class up concurrently - all with the same variable name... (I'm using > wxPython) - I know that by reusing the variable name, I won't have access to > any but the last instance created; however, I'm wondering if the previous > instance IDs will still exist and if so, how to use them to access previous > instances/windows... An object ceases to exist when the last reference to it is gone. So if nothing else keeps a reference to your class instance, it will be gone the moment you assign something else to the variable. If something else does keep a reference (see, you've attached it to the GUI or so) there may be a way to get it back from there, who knows. > sorry to be so confusing (and confused), but if anyone has an idea of my > problem and how to deal with it, I'd love to hear it. Um, don't do that then? :) You could keep an index to them. Append them to a list when you create them, or something like that. Then you can keep referring to them through the list. Apparently you do keep the objects' id(). Why don't you keep the object itself there instead? Without more information about what you're doing I don't think I can give more advice. Time to sleep now, then I'll be gone for two days... -- Remco Gerlich From bdupire@seatech.fau.edu Thu Apr 26 23:04:24 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Thu, 26 Apr 2001 18:04:24 -0400 Subject: [Tutor] id() References: <200104262152.RAA16267@mclean.mail.mindspring.net> Message-ID: <3AE89B68.34789314@seatech.fau.edu> Stephen Aichele wrote: > I have a question regarding the use of id(): basically, I'd like to find a way to reverse this process- in otherwords, is there a way to access a specific instance's attributes from the id # alone? > > I need to do this because in my app, I may have several instances of the same class up concurrently - all with the same variable name... (I'm using wxPython) - I know that by reusing the variable name, I won't have access to any but the last instance created; however, I'm wondering if the previous instance IDs will still exist and if so, how to use them to access previous instances/windows... if you don't keep track of the old objects, they are deleted by the garbage collector. You can't access them anymore. I am not sure what you are referring to about wxPython.... To keep track of all your objects, just add them to a list... my_list = [] for i in range(1,5): my_list.append( MyClass() ) Then you can access the last object: my_list[-1] and the previous ones... If you want to refer an object by its id, you have to keep a table (dictionary) key= id, value = reference to the object... I don't think there is another way to do it... my_list = [] reverse_id_dict={} for i in range(1,5): obj = MyClass() my_list.append( obj) reverse_id_dict[id(obj)] = obj hope it helps benoit > > > sorry to be so confusing (and confused), but if anyone has an idea of my problem and how to deal with it, I'd love to hear it. > > thanks! > > -Stephen > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From bdupire@seatech.fau.edu Thu Apr 26 23:10:52 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Thu, 26 Apr 2001 18:10:52 -0400 Subject: [Tutor] id() References: <200104262152.RAA16267@mclean.mail.mindspring.net> <3AE89B68.34789314@seatech.fau.edu> Message-ID: <3AE89CEC.E950307B@seatech.fau.edu> Benoit Dupire wrote: > > I don't think there is another way to do it... > > my_list = [] > reverse_id_dict={} > for i in range(1,5): > obj = MyClass() > my_list.append( obj) > reverse_id_dict[id(obj)] = obj > actually i realize my_list is no use if you store the references in a dictionary. this is better : reverse_id_dict{} for i in range(1,5): obj = MyClass() reverse_id_dict[id(obj)] = obj From arcege@speakeasy.net Thu Apr 26 23:40:00 2001 From: arcege@speakeasy.net (Michael P. Reilly) Date: Thu, 26 Apr 2001 18:40:00 -0400 (EDT) Subject: [Tutor] id() In-Reply-To: <200104262152.RAA16267@mclean.mail.mindspring.net> from "Stephen Aichele" at Apr 26, 2001 05:52:42 PM Message-ID: <200104262240.f3QMe0O01509@dsl092-074-184.bos1.dsl.speakeasy.net> Stephen Aichele wrote > > I have a question regarding the use of id(): basically, I'd like to find a way to reverse this process- in otherwords, is there a way to access a specific instance's attributes from the id # alone? > > I need to do this because in my app, I may have several instances of the same class up concurrently - all with the same variable name... (I'm using wxPython) - I know that by reusing the variable name, I won't have access to any but the last instance created; however, I'm wondering if the previous instance IDs will still exist and if so, how to use them to access previous instances/windows... > The short answer is: you won't be able to do what you are trying to do, at all (if it is what I'm gathering). Objects are areas of memory, yes, but dynamic memory (read malloc() with references counts to free up the memory. Variables are just bindings to objects, if you reassign, you decrement the reference to an object and increment the reference count to the new value. The 'sys' module has a nice function called getrefcount() which returns the number of references and object has, plus one for the function argument itself. >>> import sys >>> class A: ... pass ... >>> a = A() >>> sys.getrefcount(a) 2 - one for the binding to 'a', and one for the function call >>> b = a >>> id(a), id(b) (135094016, 135094016) >>> sys.getrefcount(a) 3 >>> a = A() # create a new instance and bind it to 'a' >>> sys.getrefcount(a), sys.getrefcount(b) (2, 2) >>> id(a), id(b) (135094192, 135094016) >>> Now when the reference count gets to 0 (no references to the object), the memory is freed, and therefore the memory is usable for another object. Basically, reusing variables won't give you access to old values because those old values may be gone and overwritten. In any event, Python does not have a mechanism for taking a "id" of an object and getting back the object itself. You might want to go thru past discussions on this in the Python newsgroup archives on the website. <URL: http://groups.google.com/groups?group=comp.lang.python.%2a&q=id%28%29> What you might want to do instead is place the objects in a list (maybe as a class member) to keep track of them. Just beware of "circular references" - you will need to remove the object from the list as well before the memory can be freed. -Arcege -- +----------------------------------+-----------------------------------+ | Michael P. Reilly | arcege@speakeasy.net | From csima@spidynamics.com Fri Apr 27 01:43:52 2001 From: csima@spidynamics.com (csima) Date: Thu, 26 Apr 2001 20:43:52 -0400 Subject: [Tutor] Python and DLL's Message-ID: <005101c0ceb3$220c4070$0201a8c0@gate> Does anyone have any information on being able to make a python script an activex dll? I want to be able to create a dll that will be accessible by a VB program From dyoo@hkn.eecs.berkeley.edu Fri Apr 27 03:10:26 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 26 Apr 2001 19:10:26 -0700 (PDT) Subject: [Tutor] % function In-Reply-To: <20010426164855.A3505@pino.selwerd.nl> Message-ID: <Pine.LNX.4.21.0104261904190.23822-100000@hkn.eecs.berkeley.edu> On Thu, 26 Apr 2001, Remco Gerlich wrote: > On 0, Liana Wiehahn <liana@upfrontsystems.co.za> wrote: > > Can somebody please explain to me when you are using the % function and > > explain it to me? > > There are two different % operators, one for numbers and one for strings. > The number one computes the remainder of a division: > >>> 4 % 3 > 1 # Because if you do 4/3, the remainder is 1 > > You probably meant the string operator :). By the way, I finally found out where the documentation mentions string interpolation: http://python.org/doc/current/lib/typesseq-strings.html#l2h-68 and http://python.org/doc/current/tut/node9.html#SECTION009100000000000000000 so you can take a look at the documentation if you're a details-oriented person. From dyoo@hkn.eecs.berkeley.edu Fri Apr 27 03:19:11 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 26 Apr 2001 19:19:11 -0700 (PDT) Subject: [Tutor] One more time: weird python windows batch file error In-Reply-To: <20010426195601.57704.qmail@web12405.mail.yahoo.com> Message-ID: <Pine.LNX.4.21.0104261914170.23822-100000@hkn.eecs.berkeley.edu> On Thu, 26 Apr 2001, folklore hopeful wrote: > Hello all, I posted about this before but perhaps I did not word > it correctly. I have written a nifty python program and have > burned it, along with py20, onto a CD-ROM so that it can be > easily used on Win95 computers without installing Python. To make > it easier for my non-dos savvy audience, I am trying to use > a batch file to start the python program. That way I can say > to everyone "click on My Computer. Click on the D drive. Click > on the file call FOO.BAT" and we're away. My FOO.BAT contains this: > > @echo off > pythonw FOO.PY > > It works just fine, but pops up an error message every time > my users exit the program. It's the basic windows error message > which says, in a nutshel "Pythonw.exe has done something illegal, > tell it stop." Ouch! pythonw.exe should never return an error message like this. Hmmm... have you tried using your program with Python 2.1? Let's make sure this isn't a bug that's been fixed recently. If the same thing happens with 2.1, then you'll probably want to talk with some people at comp.lang.python; they might be better able to help diagnose what's going on. Your batch file looks ok, so it's either Python or Windows. Personally, I'd put suspicion on Windows. *grin* Good luck to you. From dyoo@hkn.eecs.berkeley.edu Fri Apr 27 03:21:33 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 26 Apr 2001 19:21:33 -0700 (PDT) Subject: [Tutor] How to inspect variables in a module from the command line In-Reply-To: <003901c0ce8d$f7aaa440$723661cb@pf05nt.bayernz.co.nz> Message-ID: <Pine.LNX.4.21.0104261920390.23822-100000@hkn.eecs.berkeley.edu> On Fri, 27 Apr 2001, Phil Bertram wrote: > I often develop my programs by writing a class in a module > > class MyClass: > stuff here > > if __name__ == '__main__' : > klass=MyClass() > klass.mutate() > print klass.attribute > > to run and test scripts written in a module. With print statements for > debugging. (I press f5 in PythonWin). > > Is there a way to switch to the interpreter and inspect the variables in the module > I've tried thinds like > > >>> __main__.klass.anotherAttribute > > but can't seem to work it out. It sounds like you might want to try out the debugger that comes with PythonWin. However, I have to profess total ignorance about it. *grin* Does anyone have any experience with PythonWin's debugger? From dyoo@hkn.eecs.berkeley.edu Fri Apr 27 03:30:32 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Thu, 26 Apr 2001 19:30:32 -0700 (PDT) Subject: [Tutor] Python and DLL's In-Reply-To: <005101c0ceb3$220c4070$0201a8c0@gate> Message-ID: <Pine.LNX.4.21.0104261924540.23822-100000@hkn.eecs.berkeley.edu> On Thu, 26 Apr 2001, csima wrote: > Does anyone have any information on being able to make a python script an > activex dll? I want to be able to create a dll that will be accessible by a > VB program Hmmm... I haven't played with Windows in a while, but I've seen a few links that might be useful: There's some information on making DLL's here: http://python.org/doc/current/ext/building-on-windows.html There's also ways of writing COM objects in Python, which you should be able to access from VB. There's some information on doing this here: http://starship.python.net/crew/mhammond/ and the book "Python and Win32 Programming", by Mark Hammond and Andy Robinson: http://www.ora.com/catalog/pythonwin32/ gives more details about doing this sort of stuff. Good luck to you. From rfalck@home.com Fri Apr 27 06:34:54 2001 From: rfalck@home.com (Rick Falck) Date: Thu, 26 Apr 2001 22:34:54 -0700 Subject: [Tutor] Python problem... Message-ID: <3AE904FE.5F8D149@home.com> Hi, I tried to create a python extension dll but when I import it into python it gives an error message that says initExtest() si not defined - even though it is. It is a very simple example so I copied it into this email. Could you tell me what is wrong with this? Any help would be appreciated.... Code follows: ================================== #include <stdio.h> #include <stdlib.h> #include <string.h> int fac(int n) { if (n < 2) return(1); return ((n)*fac(n-1)); } char *reverse(char *s) { register char t, *p = s, *q = (s + (strlen(s) - 1)); while (s && (p < q)) { t = *p; *p++ = *q; *q-- = t; } return(s); } void test() { char s[BUFSIZ]; printf("4! == %d\n", fac(4)); printf("8! == %d\n", fac(8)); printf("12! == %d\n", fac(12)); strcpy(s, "abcdef"); printf("reversing 'abcdef', we get '%s'\n", \ reverse(s)); strcpy(s, "madam"); printf("reversing 'madam', we get '%s'\n", \ reverse(s)); } #include "Python.h" static PyObject * Extest_fac(PyObject *self, PyObject *args) { int num; if (!PyArg_ParseTuple(args, "i", &num)) return NULL; return (PyObject*)Py_BuildValue("i", fac(num)); } static PyObject * Extest_doppel(PyObject *self, PyObject *args) { char *orig_str; char *dupe_str; PyObject* retval; if (!PyArg_ParseTuple(args, "s", &orig_str)) return NULL; retval = (PyObject*)Py_BuildValue("ss", orig_str, dupe_str=reverse(strdup(orig_str))); free(dupe_str); return retval; } static PyObject * Extest_test(PyObject *self, PyObject *args) { test(); return (PyObject*)Py_BuildValue(""); } static PyMethodDef ExtestMethods[] = { { "fac", Extest_fac, METH_VARARGS }, { "doppel", Extest_doppel, METH_VARARGS }, { "test", Extest_test, METH_VARARGS }, { NULL, NULL }, }; DL_EXPORT(void) initExtest() { (void) Py_InitModule("Extest", ExtestMethods); } From rick@niof.net Thu Apr 26 22:26:29 2001 From: rick@niof.net (Rick Pasotto) Date: Thu, 26 Apr 2001 17:26:29 -0400 Subject: [Tutor] command line syntax In-Reply-To: <3AE89040.AD39F5FB@mayo.edu>; from Desai.Dinakar@mayo.edu on Thu, Apr 26, 2001 at 04:16:48PM -0500 References: <001e01c0ce71$ed6ace40$2101a8c0@delphian.org> <047a01c0ce72$b3002a60$0200a8c0@ACE> <001201c0ce94$8116a340$2101a8c0@delphian.org> <3AE89040.AD39F5FB@mayo.edu> Message-ID: <20010426172629.A23289@tc.niof.net> On Thu, Apr 26, 2001 at 04:16:48PM -0500, Dinakar Desai wrote: > Hello Everyone: > > I was wondering is there any way one can write command line script like > that done in perl or shell. > I tried FAQ and could not find what I was looking for. That would be rather difficult since white space *is* significant in python. -- "The means of defense against foreign danger historically have become the instruments of tyranny at home." -- James Madison Rick Pasotto email: rickp@telocity.com From rob@jam.rr.com Fri Apr 27 12:37:54 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Fri, 27 Apr 2001 06:37:54 -0500 Subject: [Tutor] ActiveState Python Cookbook Message-ID: <3AE95A12.69D5243C@jam.rr.com> ActiveState and O'Reilly, in a clear attempt to copy Useless Python, have set up the on-line Python Cookbook. I just pass this on because I figure it might turn into a useful resource for some of us, and we just might stumble across contributions from some of the Elder pythonistas on the tutor list there. http://www.activestate.com/ASPN/Python/Cookbook/ -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From Mark A. Tobin" <mtobin@bigfoot.com Fri Apr 27 14:24:32 2001 From: Mark A. Tobin" <mtobin@bigfoot.com (Mark A. Tobin) Date: Fri, 27 Apr 2001 09:24:32 -0400 Subject: [Tutor] Classes and "Self" References: <E14stti-0001PU-00@mail.python.org> Message-ID: <001d01c0cf1d$6674b660$4bbcc28e@anonymous> Hi there, I've been playing around with Python for a while now as my first real foray into programming. I've just started looking at creating classes as they seem to be the more "mature" way to structure one's programming. I can now implement instances and what not, thanks to some of the great tutorials out there, however I can't figure out what the "self" argument is all about. It is used throughout the program to refer to something, but I don't really "get it". As I said, I can use it (i.e.. repeat the structure I've seen in the tutorials by rote), but I don't really know why or how I'm using it. An explanation or a point to an explanation would be helpful, Mark From kalle@gnupung.net Fri Apr 27 15:04:27 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Fri, 27 Apr 2001 16:04:27 +0200 Subject: [Tutor] Classes and "Self" In-Reply-To: <001d01c0cf1d$6674b660$4bbcc28e@anonymous>; from mtobin@attcanada.net on Fri, Apr 27, 2001 at 09:24:32AM -0400 References: <E14stti-0001PU-00@mail.python.org> <001d01c0cf1d$6674b660$4bbcc28e@anonymous> Message-ID: <20010427160427.A980@father> Sez Mark A. Tobin: > Hi there, > I've been playing around with Python for a while now as my first real foray > into programming. I've just started looking at creating classes as they > seem to be the more "mature" way to structure one's programming. I can now > implement instances and what not, thanks to some of the great tutorials out > there, however I can't figure out what the "self" argument is all about. Well, it is a reference to the instance that the method is run with. An example: >>> class C: ... def f(self): ... global i, j # don't do this at home, kids... <wink> ... if i is self: ... print "self is i!" ... elif j is self: ... print "self is j!" ... else: ... print "self is not i or j!" ... >>> i = C(); j = C(); k = C() # create three instances of C >>> i.f() self is i! >>> j.f() self is j! >>> k.f() self is not i or j! >>> C.f(i) # check this one out... self is i! self is used to access the methods and data of the instance from inside its own methods. It is automatically passed as the first argument when a method is sccessed from a class instace. When the method is accessed from the class, as in the last example, it's called an unbound method and the first argument must be an instance of the class or a subclass. I don't know if that helped at all, but it's a try. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From wheelege@tsn.cc Fri Apr 27 15:23:02 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Sat, 28 Apr 2001 00:23:02 +1000 Subject: [Tutor] X11 Bitmaps in windows... Message-ID: <04e101c0cf25$922c72e0$0200a8c0@ACE> This is a multi-part message in MIME format. ------=_NextPart_000_04DE_01C0CF79.63290900 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I'm looking for some way to make a bitmap in windows. I have been = looking on the 'net for any tool - but all I find are = unix/linux/not-windows utilities. The reason I'd like an X11 bitmap is so I can use it for my icon in a = tkinter program I'm making. I am sure that I can make a normal bitmap = with colours as my icon - because I have seen other tcl/tk programs do = it. However, I cannot find any mention of it in the docs or the book = 'Python and Tkinter Programming'. Specifically, this is what I'm trying to do... from tkinter import * root =3D TK() myicon =3D BitmapImage(file=3Dr'C:\icon.bmp') root.iconbitmap(icon) Seems it only wants a monochrome bitmap in that case. Thanks for any help, Glen. ------=_NextPart_000_04DE_01C0CF79.63290900 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV> Hi all,</DIV> <DIV> </DIV> <DIV> I'm looking for some way to make a bitmap in windows. = I have=20 been looking on the 'net for any tool - but all I find are=20 unix/linux/not-windows utilities.</DIV> <DIV> The reason I'd like an X11 bitmap is so I can use it for my = icon in=20 a tkinter program I'm making. I am sure that I can make a normal = bitmap=20 with colours as my icon - because I have seen other tcl/tk programs do = it. =20 However, I cannot find any mention of it in the docs or the book 'Python = and=20 Tkinter Programming'.</DIV> <DIV> Specifically, this is what I'm trying to do...</DIV> <DIV> </DIV> <DIV>from tkinter import *</DIV> <DIV>root =3D TK()</DIV> <DIV>myicon =3D BitmapImage(file=3Dr'C:\icon.bmp')</DIV> <DIV>root.iconbitmap(icon)</DIV> <DIV> </DIV> <DIV> Seems it only wants a monochrome bitmap in that case.</DIV> <DIV> </DIV> <DIV> Thanks for any help,</DIV> <DIV> Glen.</DIV></BODY></HTML> ------=_NextPart_000_04DE_01C0CF79.63290900-- From bdupire@seatech.fau.edu Fri Apr 27 16:05:35 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Fri, 27 Apr 2001 11:05:35 -0400 Subject: [Tutor] Classes and "Self" References: <E14stti-0001PU-00@mail.python.org> <001d01c0cf1d$6674b660$4bbcc28e@anonymous> Message-ID: <3AE98ABF.17B53991@seatech.fau.edu> Here's my try: ;o) Correct me if i am wrong >>> class Foo: def __init__(self, value): i = 8 self.name = value >>> dir(Foo) ['__doc__', '__init__', '__module__'] >>> a=Foo(12) >>> dir(a) ['name'] Why self ? Namespace issue! >From within __init__, the local namespace consists of all the variables defined within __init__ (ie i can access 'i') The global namespace is the module (ie. i can access a). and there is the built in namespace.... I can't access 'name' directly from __init__ because it is in the object namespace (somewhat nested), and thus it's not local to __init__ or global to the module I can access 'name' from the global namespace, using 'a.name'. So i can access 'name' from __init__ only if i have got a reference to 'a', so that i can use 'a.name' As the problem occurs for every instance variables, we need this ref every time and to pass it, and the convention is to call it self. When you call __init__(a, 12) then you create 2 variable in the __init__ namespace self, and i. "Mark A. Tobin" wrote: > Hi there, > I've been playing around with Python for a while now as my first real foray > into programming. I've just started looking at creating classes as they > seem to be the more "mature" way to structure one's programming. I can now > implement instances and what not, thanks to some of the great tutorials out > there, however I can't figure out what the "self" argument is all about. It > is used throughout the program to refer to something, but I don't really > "get it". As I said, I can use it (i.e.. repeat the structure I've seen in > the tutorials by rote), but I don't really know why or how I'm using it. > An explanation or a point to an explanation would be helpful, > > Mark > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From Christopher Bemis" <laser151@tvn.net Fri Apr 27 17:32:48 2001 From: Christopher Bemis" <laser151@tvn.net (Christopher Bemis) Date: Fri, 27 Apr 2001 12:32:48 -0400 Subject: [Tutor] DOS Prompt Message-ID: <000c01c0cf37$b6b8f720$2008683f@laser151> This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C0CF16.2B444B20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Does anyone know how I can fix this problem? I can run my programs from = IDLE, and from Start/Run, but when I type: Python Helloworld.py ,e.g. = into a command prompt, I keep getting "Bad Command or File Name". I'm = still kinda new at this, but is there any way for me to fix this? The Great One ------=_NextPart_000_0009_01C0CF16.2B444B20 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><STRONG><FONT face=3D"Californian FB" color=3D#800080 size=3D2>Does = anyone know=20 how I can fix this problem? I can run my programs from IDLE, and from = Start/Run,=20 but when I type: Python Helloworld.py ,e.g. into a command = prompt, I=20 keep getting "Bad Command or File Name". I'm still kinda new at this, = but is=20 there any way for me to fix this?</FONT></STRONG></DIV> <DIV><STRONG><FONT face=3D"Californian FB" color=3D#800080 size=3D2>The = Great=20 One</FONT></STRONG></DIV></BODY></HTML> ------=_NextPart_000_0009_01C0CF16.2B444B20-- From vlindberg@verio.net Fri Apr 27 20:32:31 2001 From: vlindberg@verio.net (VanL) Date: Fri, 27 Apr 2001 13:32:31 -0600 Subject: [Tutor] Classes and "Self" References: <E14stti-0001PU-00@mail.python.org> <001d01c0cf1d$6674b660$4bbcc28e@anonymous> Message-ID: <3AE9C94F.FA919CCD@verio.net> I'll try too. This may be a bit long-winded, but I'll get to your question. The concept of object-oriented programming (OOP) was invented, in part, to help make software contructs that mirrored their real-world counterparts. Previous imperative programs worked more like a recipe -- take the ingredients, follow a procedure, produce an output. While this worked well for a lot of problems, there were certain problems that didn't match well to this style of solving a problem. Take, for instance, a software model that would drive a (virtual) car. In an imperative program, the program would need to know a lot about how all of the different parts of the car worked -- after all, the same 'recipe' would control everything from steering to the drivetrain to the electrical system. In an important sense, though, that isn't how we drive a car. We don't have to worry about the drivetrain or the electrical system while we are steering -- we have a couple of well-defined controls (the steering wheel, pedals, etc) to tell the car what we want to do and we don't worry about the underlying mechanics of how it all works. Thus, this problem could be modeled more closely by imagining a set of interacting players, each of which did one particular thing. The 'driver' object steered, the 'drivetrain' object transmitted power, etc. These objects worked with each other via defined interfaces. Furthermore, an interacting collection of objects could itself be considered an object, just like we take a bunch of parts, put them together, and call them a car. Now when we think of a physical object with controls, it is sort of hard to imagine the steering wheel of one car actually controlling some other car down the street. With software, though, it was possible to do just that. Hence, it was necessary to define which object went with which set of controls. Now when you declare an instance of an class, you are actually doing two things: 1. creating the instance (the object) and 2. naming it uniquely. This enables the computer to keep track of which set of controls goes with each object. The 'self' parameter is the object's internal name -- it lets the computer know which object you actually want to do stuff with. HTH, VanL From doc_pepin@yahoo.com Fri Apr 27 20:29:50 2001 From: doc_pepin@yahoo.com (doc pepin) Date: Fri, 27 Apr 2001 12:29:50 -0700 (PDT) Subject: [Tutor] tkinter or python Message-ID: <20010427192950.85590.qmail@web13903.mail.yahoo.com> for a newbie programmer which is easier learn tkinter or wxpython __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ From bdupire@seatech.fau.edu Fri Apr 27 22:38:13 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Fri, 27 Apr 2001 17:38:13 -0400 Subject: [Tutor] DOS Prompt .. changing PATH envir. var References: <000c01c0cf37$b6b8f720$2008683f@laser151> <3AE9C386.1310809E@seatech.fau.edu> <000e01c0cf5d$8188aca0$3f08683f@laser151> Message-ID: <3AE9E6C5.A9DA1868@seatech.fau.edu> If C:\Python20 is the name of the directory in which Python is installed type: set PATH=C:\Python20;%PATH% If you don't want to type this command each time you reboot your PC (win 98 :o) !!! ), you can edit the autoexec.bat file at the root of the file system...and add PATH=C:\Python20;%PATH% (i don't think you need the 'set', but i have NT , i do this another way , not sure about this) Christopher Bemis wrote: > I have Python 1.5, on a Windows98SE machine, How do I change the > path?It comes from DOS...The Great One From cooler12001@yahoo.com Sat Apr 28 07:22:45 2001 From: cooler12001@yahoo.com (Matthews James) Date: Fri, 27 Apr 2001 23:22:45 -0700 (PDT) Subject: [Tutor] how do i get one of my program to open when i open a folder or something. Message-ID: <20010428062245.2289.qmail@web11401.mail.yahoo.com> i am want a program of mine to open when i open a folder sort of like a password protecting thingamabob Thanks James __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ From deirdre@deirdre.net Sat Apr 28 07:38:17 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Fri, 27 Apr 2001 23:38:17 -0700 Subject: [Tutor] how do i get one of my program to open when i open a folder or something. In-Reply-To: <20010428062245.2289.qmail@web11401.mail.yahoo.com> References: <20010428062245.2289.qmail@web11401.mail.yahoo.com> Message-ID: <a05100e00b710159c461f@[10.0.1.20]> >i am want a program of mine to open when i open a >folder sort of like a password protecting thingamabob It would help significantly if you mentioned what operating system you were programming on. In any case, it probably involves more interaction with the operating system than you might prefer to code. -- -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From wheelege@tsn.cc Sat Apr 28 08:09:17 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Sat, 28 Apr 2001 17:09:17 +1000 Subject: [Tutor] tkinter or python References: <20010427192950.85590.qmail@web13903.mail.yahoo.com> Message-ID: <00d801c0cfb2$24ba6ea0$0200a8c0@ACE> > for a newbie programmer which is easier learn tkinter > or wxpython > Tkinter is definitely easier to learn for a newbie programer - as to which one is 'better' to learn, that is still up for debate. You will *need* to get some understanding of Object Oriented programming before you start with tkinter. I recommend going through Alan Gaulds tutorial (here : http://www.crosswinds.net/~agauld) with particular regard to the Object Oriented Programming section and the tkinter section. Glen. From brett42@flex.com Sat Apr 28 08:32:16 2001 From: brett42@flex.com (Brett) Date: Fri, 27 Apr 2001 21:32:16 -1000 Subject: [Tutor] A couple questions about lists Message-ID: <4.3.2.7.0.20010427211821.00ab3230@mail.flex.com> <html> I had some variables I wanted to do similar operations on, so i put them in a list and sent them through a for loop:<br> for x in [a,b,c,d,e]:<br> <x-tab> </x-tab>if x<10:<br> <x-tab> </x-tab><x-tab> </x-tab>x=x+10<br> After running this the list and the variables all had the same values, but x was equal to 15(the value of e). I<u>s there a way to change part of a list with using it's index?</u> Either way, I figured out that I could use<br> list=[a,b,c,d,e]<br> for x in range(0,4):<br> <x-tab> </x-tab>if list[x]<10:<br> <x-tab> </x-tab><x-tab> </x-tab>list[x]=list[x]+10<br> But it only changed the values in the list, and didn't change the variables. I<u>s there a way to make a list, or some other object, that keeps a reference to the variable instead of just taking it's value?<br> <br> </u><br> <div>When Schrodinger's cat's away,</div> <div>the mice may or may not play,</div> <div>no one can tell.</div> </html> From wheelege@tsn.cc Sat Apr 28 08:46:38 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Sat, 28 Apr 2001 17:46:38 +1000 Subject: [Tutor] A couple questions about lists Message-ID: <00f801c0cfb7$5da91220$0200a8c0@ACE> This is a multi-part message in MIME format. ------=_NextPart_000_00F5_01C0D00B.2CD750E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I had some variables I wanted to do similar operations on, so i put = them in a list and sent them through a for loop: for x in [a,b,c,d,e]: if x<10: x=3Dx+10 After running this the list and the variables all had the same = values, but x was equal to 15(the value of e). Is there a way to change = part of a list with using it's index? Either way, I figured out that I = could use list=3D[a,b,c,d,e] for x in range(0,4): if list[x]<10: list[x]=3Dlist[x]+10 But it only changed the values in the list, and didn't change the = variables. Is there a way to make a list, or some other object, that = keeps a reference to the variable instead of just taking it's value? Okay, so you want to get some variables, put them in a list and make a = change to a member of the list change the variable that was its model? First off, I've got to ask why you don't just use lists and give up on = the single variables? For example... >>> x =3D 1 >>> y =3D 2 >>> z =3D 3 >>> l =3D [x, y, z] >>> l [1, 2, 3] >>> l[0] 1 >>> l[1] 2 >>> l[2] 3 Now, how is writing l[0] different to writing x? Except for the two = extra key presses, I don't see any disadvantages to storing it this way. = Then something like... >>> for index in range(len(l)): ... l[index] =3D l[index] + 5 ...=20 >>> l [6, 7, 8] >>> l[0] 6 >>> l[1] 7 >>> l[2] 8 Will work fine, and you don't need to worry about it. I only say this = because the only way I can see to get back to the x,y,z variables is by = direct assignment - ie x =3D l[0], y =3D l[1], z =3D l[2]. Which just = adds another step when you can directly reference them by just writing = l[0] etc. Food for thought, Glen. ------=_NextPart_000_00F5_01C0D00B.2CD750E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV> <BLOCKQUOTE=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV>I had some variables I wanted to do similar operations on, so i = put them=20 in a list and sent them through a for loop:<BR>for x in=20 = [a,b,c,d,e]:<BR><X-TAB> </= X-TAB>if=20 = x<10:<BR><X-TAB> </X-TA= B><X-TAB> </X-TAB>x=3Dx+10= </DIV> <DIV><BR> After running this the list and the variables all had = the same=20 values, but x was equal to 15(the value of e). I<U>s there a way to = change=20 part of a list with using it's index?</U> Either way, I figured = out that=20 I could use<BR>list=3D[a,b,c,d,e]<BR>for x in=20 = range(0,4):<BR><X-TAB> </X= -TAB>if=20 = list[x]<10:<BR><X-TAB> = </X-TAB><X-TAB> </X-TAB>li= st[x]=3Dlist[x]+10<BR>But=20 it only changed the values in the list, and didn't change the = variables. =20 I<U>s there a way to make a list, or some other object, that keeps a = reference=20 to the variable instead of just taking it's = value?</U></DIV></BLOCKQUOTE></DIV> <DIV> Okay, so you want to get some variables, put them in a list = and make=20 a change to a member of the list change the variable that was its = model?</DIV> <DIV> First off, I've got to ask why you don't just use lists and = give up=20 on the single variables? For example...</DIV> <DIV> </DIV> <DIV>>>> x =3D 1<BR>>>> y =3D 2<BR>>>> z =3D=20 3<BR>>>> l =3D [x, y, z]<BR>>>> l<BR>[1, 2, = 3]<BR>>>>=20 l[0]<BR>1<BR>>>> l[1]<BR>2<BR>>>> l[2]<BR>3<BR></DIV> <DIV> Now, how is writing l[0] different to writing x? = Except for=20 the two extra key presses, I don't see any disadvantages to storing it = this=20 way. Then something like...</DIV> <DIV> </DIV> <DIV>>>> for index in range(len(l)):<BR>... l[index] =3D = l[index] +=20 5<BR>... <BR>>>> l<BR>[6, 7, 8]<BR>>>>=20 l[0]<BR>6<BR>>>> l[1]<BR>7<BR>>>> l[2]<BR>8</DIV> <DIV> </DIV> <DIV> Will work fine, and you don't need to worry about it. = I only=20 say this because the only way I can see to get back to the x,y,z = variables=20 is by direct assignment - ie x =3D l[0], y =3D l[1], z =3D l[2]. = Which just adds=20 another step when you can directly reference them by just writing l[0]=20 etc.</DIV> <DIV> </DIV> <DIV> Food for thought,</DIV> <DIV> Glen.</DIV></BODY></HTML> ------=_NextPart_000_00F5_01C0D00B.2CD750E0-- From wheelege@tsn.cc Sat Apr 28 10:55:24 2001 From: wheelege@tsn.cc (Glen Wheeler) Date: Sat, 28 Apr 2001 19:55:24 +1000 Subject: [Tutor] Not-so Quick Question References: <Pine.LNX.4.21.0104260706500.6331-100000@hkn.eecs.berkeley.edu> <03b401c0ce62$c380f820$0200a8c0@ACE> <20010426173216.A3593@pino.selwerd.nl> Message-ID: <011a01c0cfc9$5a81b540$0200a8c0@ACE> > > <snip old correspondence> > Try to make your problem as small as possible, ie make the smallest program > that still has the problem. This may well be a Tcl/Tk bug, if you're sure > the 'expected' string doesn't occur in your program. > I now think it is a Pythonwin problem - I run the program under pythonwin and now it gets to the point where even ignoring the error through tr: except: will not work - it still stops inside that function. So I thought it might be similar to my problem with IDLE and ran it through the command line - not even one error. Whereas when running under pythonwin I would get about 10 messages inside a minute, and then wouldn't be able to continue. So, perhaps a bug report to Activestate? Glen. > -- > Remco Gerlich > > From renegade_65535@hotmail.com Sat Apr 28 16:09:36 2001 From: renegade_65535@hotmail.com (JJk k) Date: Sat, 28 Apr 2001 16:09:36 +0100 Subject: [Tutor] Help: Python GUI Message-ID: <F18qhNPPzQT456UnHAa0000e790@hotmail.com> Hi, How do I use the GUI? Say if I wanted to say: >>>print "None Shall Pass!" >>>"\n" >>>print "Fight or Die" Thats just an example, but when I type the first line in (print "None Shall Pass") when I press enter to carry on typing, it just prints out None Shall Pass How do I use this correctly? I'd really appreciate help :) Thanks very much :) Jake. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From rob@jam.rr.com Sat Apr 28 16:28:37 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Sat, 28 Apr 2001 10:28:37 -0500 Subject: [Tutor] Help: Python GUI References: <F18qhNPPzQT456UnHAa0000e790@hotmail.com> Message-ID: <3AEAE1A5.BEAA0460@jam.rr.com> Were you looking for something like this? >>> print "None Shall Pass!\nFight or Die!" None Shall Pass! Fight or Die! Rob JJk k wrote: > > Hi, > How do I use the GUI? > Say if I wanted to say: > >>>print "None Shall Pass!" > >>>"\n" > >>>print "Fight or Die" > > Thats just an example, but when I type the first line in (print "None Shall > Pass") when I press enter to carry on typing, it just prints out > None Shall Pass > How do I use this correctly? I'd really appreciate help :) > Thanks very much :) > Jake. > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From rob@jam.rr.com Sat Apr 28 16:44:18 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Sat, 28 Apr 2001 10:44:18 -0500 Subject: [Tutor] Help: Python GUI References: <F187cDjoYAPNXRPmcar0000d2a5@hotmail.com> Message-ID: <3AEAE552.92D6D2F9@jam.rr.com> Well, you do have options. I assume you're using IDLE, PythonWin, or something similar, where you type in a line of code, press [Enter], and get prompted for another line of code with >>>. You can also use your favorite text editor (such as notepad if you're using Windows) to just type the entire script in a document. Then save it as a document ending in .py (fightordie.py, for example). It often doesn't matter where you save the file, but since it *sometimes* matters, you can safely save the file in the folder/directory containing your Python install, such as (again, assuming Windows) C:\Python21. You can then run the program in one of several different ways, but try doing this within IDLE: >>>import fightordie Notice that you can leave off the .py when running the script in this manner. Or from the command prompt (which some Windows users call the DOS prompt): C:\Python21>python fightordie.py Which operating system are you running, by the way? And does this help any? Rob JJk k wrote: > > Thank you very much! That's a great help, > but say I wanted a large script using the "print" function, if I pressed > enter to start a new line, it says "syntac error" or something like that, so > how would I write multiple lines on sepatate lines without using "\n"? > Thank you again :) > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From deirdre@deirdre.net Sat Apr 28 18:30:52 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Sat, 28 Apr 2001 10:30:52 -0700 Subject: [Tutor] Help: Python GUI In-Reply-To: <F18qhNPPzQT456UnHAa0000e790@hotmail.com> References: <F18qhNPPzQT456UnHAa0000e790@hotmail.com> Message-ID: <a05100e05b710ae382c7b@[10.0.1.24]> >Hi, >How do I use the GUI? This question is platform-dependent to some extent, so it's helpful to state what platform you're on and what your ultimate aims are so we can help you. (I know, I sound like a broken record....) -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From deirdre@deirdre.net Sat Apr 28 18:38:31 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Sat, 28 Apr 2001 10:38:31 -0700 Subject: [Tutor] Help: Python GUI In-Reply-To: <F203D7qGla5V7XNeNSj00004d23@hotmail.com> References: <F203D7qGla5V7XNeNSj00004d23@hotmail.com> Message-ID: <a05100e06b710b02ea24f@[10.0.1.24]> >Erm..i nto actually sure myself! lol! >What do u want to do with it?? I think you're confused -- I was trying to help answer your question, but I need more information. Recognize that the GUI toolkits are not a part of the language proper and that only some subset of people on a list will be able to answer questions about any specific one. -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams From jko@andover.edu Sat Apr 28 20:41:30 2001 From: jko@andover.edu (Justin Ko) Date: Sat, 28 Apr 2001 15:41:30 -0400 Subject: [Tutor] Low Level Reads Message-ID: <5.0.0.25.2.20010428153001.0232dd60@mail.andover.edu> Hey everyone, I've got a question about reading from files. I'm working on a module to read ID3v2 tags off of mp3 files. When I read data from the mp3 file, the data is returned as a string of hex. For instance... >>> file = open("some.mp3") >>> file.seek(0, 0) >>> header = file.read(11) >>> header 'ID3\x03\x00\x00\x00\x00\x0ejT' >>> How can i perform the conversion from hex to base 10? More specifically, I need to obtain base 10 values for header[3:5]. int() doesn't seem to like hexadecimal values. Neither does str() or float()... _justin Ko From dyoo@hkn.eecs.berkeley.edu Sat Apr 28 21:59:49 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 28 Apr 2001 13:59:49 -0700 (PDT) Subject: [Tutor] Low Level Reads In-Reply-To: <5.0.0.25.2.20010428153001.0232dd60@mail.andover.edu> Message-ID: <Pine.LNX.4.21.0104281348530.6618-100000@hkn.eecs.berkeley.edu> On Sat, 28 Apr 2001, Justin Ko wrote: > Hey everyone, > I've got a question about reading from files. I'm working on a > module to read ID3v2 tags off of mp3 files. When I read data from the mp3 > file, the data is returned as a string of hex. For instance... > > > >>> file = open("some.mp3") > >>> file.seek(0, 0) > >>> header = file.read(11) > >>> header > 'ID3\x03\x00\x00\x00\x00\x0ejT' > >>> > > How can i perform the conversion from hex to base 10? More > specifically, I need to obtain base 10 values for header[3:5]. int() > doesn't seem to like hexadecimal values. Neither does str() or float()... I thought that int() would be fairly happy with hexidecimal numbers. Let's check: ### >>> int("0x03") Traceback (innermost last): File "<stdin>", line 1, in ? ValueError: invalid literal for int(): 0x03 ### You're right; int() doesn't appear to know how to work with hexidecimal. However, there's a more robust version of int() within the string module called atoi() ("ascii to integer"): ### >>> import string >>> print string.atoi.__doc__ atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. ### Let's try this out: ### >>> string.atoi("0x03", 0) 3 ### Ok, so string.atoi() looks like it will be more useful for you: it can convert strings in a particular base, like hexidecimal, to integers. Try using string.atoi() instead. Good luck! From rick@niof.net Sat Apr 28 23:35:09 2001 From: rick@niof.net (Rick Pasotto) Date: Sat, 28 Apr 2001 18:35:09 -0400 Subject: [Tutor] Low Level Reads In-Reply-To: <5.0.0.25.2.20010428153001.0232dd60@mail.andover.edu>; from jko@andover.edu on Sat, Apr 28, 2001 at 03:41:30PM -0400 References: <5.0.0.25.2.20010428153001.0232dd60@mail.andover.edu> Message-ID: <20010428183509.B23289@tc.niof.net> On Sat, Apr 28, 2001 at 03:41:30PM -0400, Justin Ko wrote: > > > Hey everyone, > I've got a question about reading from files. I'm working on a > module to read ID3v2 tags off of mp3 files. When I read data from the mp3 > file, the data is returned as a string of hex. For instance... > > > >>> file = open("some.mp3") > >>> file.seek(0, 0) > >>> header = file.read(11) > >>> header > 'ID3\x03\x00\x00\x00\x00\x0ejT' > >>> > > How can i perform the conversion from hex to base 10? More > specifically, I need to obtain base 10 values for header[3:5]. int() > doesn't seem to like hexadecimal values. Neither does str() or float()... The start of an ID3v2 header is 'ID\x33'. 0x33 *is* decimal 3. -- "I would remind you that extremism in the defense of liberty is no vice. And let me remind you also that moderation in the pursuit of liberty is no virtue." -- Barry Goldwater Rick Pasotto email: rickp@telocity.com From netsspike@hotmail.com Sun Apr 29 00:55:59 2001 From: netsspike@hotmail.com (net spike) Date: Sat, 28 Apr 2001 23:55:59 -0000 Subject: [Tutor] how can i Message-ID: <F76I9IJsaJbqJGNzscE00003693@hotmail.com> how do i set my system up so if i open a command promp and type python it will start the python prompt? i run windows 2000pro if thats any help thank you for any help you can provide Brian _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From julieta_rangel@hotmail.com Sun Apr 29 02:31:59 2001 From: julieta_rangel@hotmail.com (Julieta) Date: Sat, 28 Apr 2001 20:31:59 -0500 Subject: [Tutor] 15 puzzle Message-ID: <OE57AqHlC2E8i7qgzyU00005db4@hotmail.com> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C0D022.467F7EC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi! My name is Maritza and I am trying to learn how to program with the = python language. I'm interested in a computer version of the 15 puzzle. = I've seen how it works and used it as well, but I am curious about how = the program was set up. Just to make sure that we all know which puzzle = I'm refering to, it is the one that you can get at toy stores and is = essentially a 4 x 4 matrix with the numbers 1-15 on tiles placed in the = matrix. There is one blank space where tiles adjacent to the blank = space may be moved into the blank space. The object of the game is to = arrange the numbers 1-15 in order. They are initially scrambled, of = course. If you have this program or can help me put it together, please = e-mail me at maritza_rodz.hotmail.com ------=_NextPart_000_0005_01C0D022.467F7EC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi! My name is Maritza and I am trying = to learn how=20 to program with the python language. I'm interested in a computer = version=20 of the 15 puzzle. I've seen how it works and used it as well, but = I am=20 curious about how the program was set up. Just to make sure that = we all=20 know which puzzle I'm refering to, it is the one that you can get at toy = stores=20 and is essentially a 4 x 4 matrix with the numbers 1-15 on tiles placed = in the=20 matrix. There is one blank space where tiles adjacent to the blank = space=20 may be moved into the blank space. The object of the game is to = arrange=20 the numbers 1-15 in order. They are initially scrambled, of = course. =20 If you have this program or can help me put it together, = please e-mail=20 me at maritza_rodz.hotmail.com</FONT></DIV></BODY></HTML> ------=_NextPart_000_0005_01C0D022.467F7EC0-- From kalle@gnupung.net Sun Apr 29 02:51:36 2001 From: kalle@gnupung.net (Kalle Svensson) Date: Sun, 29 Apr 2001 03:51:36 +0200 Subject: [Tutor] Low Level Reads In-Reply-To: <Pine.LNX.4.21.0104281348530.6618-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Sat, Apr 28, 2001 at 01:59:49PM -0700 References: <5.0.0.25.2.20010428153001.0232dd60@mail.andover.edu> <Pine.LNX.4.21.0104281348530.6618-100000@hkn.eecs.berkeley.edu> Message-ID: <20010429035136.A368@apone.network.loc> Sez Daniel Yoo: > On Sat, 28 Apr 2001, Justin Ko wrote: > > > Hey everyone, > > I've got a question about reading from files. I'm working on a > > module to read ID3v2 tags off of mp3 files. When I read data from the mp3 > > file, the data is returned as a string of hex. For instance... > > > > > > >>> file = open("some.mp3") > > >>> file.seek(0, 0) > > >>> header = file.read(11) > > >>> header > > 'ID3\x03\x00\x00\x00\x00\x0ejT' > > >>> > > > > How can i perform the conversion from hex to base 10? More > > specifically, I need to obtain base 10 values for header[3:5]. int() > > doesn't seem to like hexadecimal values. Neither does str() or float()... The thing is, the data is not returned hex-encoded, it is returned raw. You want to take a look at the struct module. >>> import struct >>> file = open("some.mp3") >>> file.seek(0, 0) # this is not necessary if you just opened the file. >>> header = file.read(11) >>> header 'ID3\x03\x00\x00\x00\x00\x0ejT' >>> struct.unpack("h", header[3:5]) (3,) >>> > I thought that int() would be fairly happy with hexidecimal numbers. > Let's check: > > ### > >>> int("0x03") > Traceback (innermost last): > File "<stdin>", line 1, in ? > ValueError: invalid literal for int(): 0x03 > ### > > You're right; int() doesn't appear to know how to work with hexidecimal. You need to supply a second argument: >>> int("0x03") Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: invalid literal for int(): 0x03 >>> int("0x03", 16) 3 > However, there's a more robust version of int() within the string module > called atoi() ("ascii to integer"): [snip] > Ok, so string.atoi() looks like it will be more useful for you: it can > convert strings in a particular base, like hexidecimal, to integers. Try > using string.atoi() instead. string.atoi is deprecated, IIRC. Peace, Kalle -- Email: kalle@gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From bdupire@seatech.fau.edu Sun Apr 29 02:54:54 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Sat, 28 Apr 2001 21:54:54 -0400 Subject: [Tutor] how can i References: <F76I9IJsaJbqJGNzscE00003693@hotmail.com> Message-ID: <3AEB746E.FC59D556@seatech.fau.edu> You need to change the PATH variable which designates the default directories in which the OS looks into to find your programs...... If C:\Python20 is the name of the directory in which Python is installed type: set PATH=C:\Python20;%PATH% If you don't want to type this command each time you reboot your PC you can edit the autoexec.bat file at the root of the file system...and add PATH=C:\Python20;%PATH% I don't know at all Windows 2000.... In NT you can do START > Settings > Control Panel > System > environment and there you can set the PATH environment variable check if this works with Win2000.... hope it helps... Benoit net spike wrote: > how do i set my system up so if i open a command promp and type python > it will start the python prompt? i run windows 2000pro if thats any help > thank you for any help you can provide > > Brian > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From dyoo@hkn.eecs.berkeley.edu Sun Apr 29 03:01:57 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 28 Apr 2001 19:01:57 -0700 (PDT) Subject: [Tutor] 15 puzzle In-Reply-To: <OE57AqHlC2E8i7qgzyU00005db4@hotmail.com> Message-ID: <Pine.LNX.4.21.0104281850110.13156-100000@hkn.eecs.berkeley.edu> On Sat, 28 Apr 2001, Julieta wrote: > Hi! My name is Maritza and I am trying to learn how to program with > the python language. I'm interested in a computer version of the 15 > puzzle. I've seen how it works and used it as well, but I am curious > about how the program was set up. Just to make sure that we all know If you're trying to write a game to play the 15 puzzle, it sounds like a fun problem. How far have you gotten in Python? We can help give you pointers on writing the game. However, if you're trying to write a program to get the computer to try _solving_ the problem, that's a whole different story. Solving the 15 puzzle is a HARD problem --- it's something that even beginning computer scientists have trouble writing. *grin* > which puzzle I'm refering to, it is the one that you can get at toy > stores and is essentially a 4 x 4 matrix with the numbers 1-15 on > tiles placed in the matrix. There is one blank space where tiles > adjacent to the blank space may be moved into the blank space. The > object of the game is to arrange the numbers 1-15 in order. They are ### [You might want to ignore the message below; now that I think about it, this is probably not what you're looking for.] If you'd like an example on how to get the computer to solve 15 puzzles, take a look at: http://hkn.eecs.berkeley.edu/~dyoo/python/ Check under the heading "A* Search", which has a solution to the 8-puzzle. Modifying it to do the 15 puzzle shouldn't be too bad... (However, if you're just starting out in Python, I'm not quite sure if my code will be readable for you.) From toodles@yifan.net Sun Apr 29 06:28:16 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Sun, 29 Apr 2001 13:28:16 +0800 Subject: [Tutor] popen Message-ID: <FPEHJJPEEOIPMAHOADBKAEBPCDAA.toodles@yifan.net> Hi tutors! I want my program to do the following: In main.py, in an infinity loop (temporarily) it continually runs an update command. I want to open up a new python window for input, for an administrator to punch in commands using input() or raw_input(). input.py looks like this: while 1: x=input('>') print x #print to the main process Now I tried using os.popen: input_process=os.popen('python input.py') This works, but the window doesn't show up! It's probably not meant to, but is there a way around this? Because otherwise I can not input at all... Is there another function that does this better? TIA, Andrew From julieta_rangel@hotmail.com Sun Apr 29 06:57:06 2001 From: julieta_rangel@hotmail.com (Julieta) Date: Sun, 29 Apr 2001 00:57:06 -0500 Subject: [Tutor] determining whether a set is a group Message-ID: <OE29ef2b0Jpc05IXgTh00005dcd@hotmail.com> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C0D047.4FEC1020 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello everyone! I took a modern abstract algebra class this semester = and there is something that caught my attention, and which I think would = make a neat program. I would like to have a program in which given any = set and the table accompaning the set, the computer would display a = message stating whether the set is a group or not. I guess I would have = to get the computer to ask for the amount of elements in the set, say 6, = and then have the computer generate a 6 by 6 matrix, in which the user = would enter the corresponding table, so the computer can figure out, = after testing for the required properties, whether the set is a group or = not. You might think that I'm very lazy to want the computer to do this = for me, and I guess you are right, this is probably the reason why = computer programming is becoming more interesting by the minute. You do = the work only once and then the computer does it for you. It is = beautiful! I have so many little projects that could make my life much = much easier, that I don't know where to start. My only and biggest = problem is that I'm a computer illiterate and have no clue as to where = to start, however, I'm willing to do what it takes to learn. I know = that some help over the internet might not do miracles for me, but I = guess it would be a start. I have the book Teach Yourself Python in 24 = Hours and I'm reading it, but I guess I need more help. Can you help = me. Julieta =20 ------=_NextPart_000_0005_01C0D047.4FEC1020 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hello everyone! I took a modern = abstract=20 algebra class this semester and there is something that caught my = attention, and=20 which I think would make a neat program. I would like to have a = program in=20 which given any set and the table accompaning the set, the computer = would=20 display a message stating whether the set is a group or not. I = guess I=20 would have to get the computer to ask for the amount of elements in the = set, say=20 6, and then have the computer generate a 6 by 6 matrix, in which the = user would=20 enter the corresponding table, so the computer can figure out, after = testing for=20 the required properties, whether the set is a group or not. You = might=20 think that I'm very lazy to want the computer to do this for me, and I = guess you=20 are right, this is probably the reason why computer programming is = becoming more=20 interesting by the minute. You do the work only once and then the = computer=20 does it for you. It is beautiful! I have so many little = projects=20 that could make my life much much easier, that I don't know where to=20 start. My only and biggest problem is that I'm a computer = illiterate and=20 have no clue as to where to start, however, I'm willing to do what it = takes to=20 learn. I know that some help over the internet might not do = miracles for=20 me, but I guess it would be a start. I have the book <U>Teach = Yourself=20 Python in 24 Hours</U> and I'm reading it, but I guess I need more = help. =20 Can you help me.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Julieta = </FONT></DIV></BODY></HTML> ------=_NextPart_000_0005_01C0D047.4FEC1020-- From deirdre@deirdre.net Sun Apr 29 06:57:56 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Sat, 28 Apr 2001 22:57:56 -0700 Subject: [Tutor] 15 puzzle In-Reply-To: <OE57AqHlC2E8i7qgzyU00005db4@hotmail.com> References: <OE57AqHlC2E8i7qgzyU00005db4@hotmail.com> Message-ID: <a05100e0ab7115ce93c2a@[10.0.1.24]> --============_-1223598608==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" >Hi! My name is Maritza and I am trying to learn how to program with >the python language. I'm interested in a computer version of the 15 >puzzle. I've seen how it works and used it as well, but I am >curious about how the program was set up. Just to make sure that we >all know which puzzle I'm refering to, it is the one that you can >get at toy stores and is essentially a 4 x 4 matrix with the numbers >1-15 on tiles placed in the matrix. There is one blank space where >tiles adjacent to the blank space may be moved into the blank space. >The object of the game is to arrange the numbers 1-15 in order. >They are initially scrambled, of course. If you have this >program or can help me put it together, please e-mail me at >maritza_rodz.hotmail.com The best way to set it up would be as a 4 x 4 matrix. That way, it's easy to know whether or not any given spot was "next to" the hole -- as only something that's up, down, left or right of the hole can move there. Then, you'd swap the space and the number that was there. As Daniel said, it's an interesting problem and it could be designed either with a command-line interface or a gui one (or done as a command-line at first and developed into a GUI program). -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams --============_-1223598608==_ma============ Content-Type: text/html; charset="us-ascii" <!doctype html public "-//W3C//DTD W3 HTML//EN"> <html><head><style type="text/css"><!-- blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 } --></style><title>Re: [Tutor] 15 puzzle</title></head><body> <blockquote type="cite" cite><font face="Arial" size="-1">Hi! My name is Maritza and I am trying to learn how to program with the python language. I'm interested in a computer version of the 15 puzzle. I've seen how it works and used it as well, but I am curious about how the program was set up. Just to make sure that we all know which puzzle I'm refering to, it is the one that you can get at toy stores and is essentially a 4 x 4 matrix with the numbers 1-15 on tiles placed in the matrix. There is one blank space where tiles adjacent to the blank space may be moved into the blank space. The object of the game is to arrange the numbers 1-15 in order. They are initially scrambled, of course. If you have this program or can help me put it together, please e-mail me at maritza_rodz.hotmail.com</font></blockquote> <div><br> <br> </div> <div>The best way to set it up would be as a 4 x 4 matrix. That way, it's easy to know whether or not any given spot was "next to" the hole -- as only something that's up, down, left or right of the hole can move there.</div> <div><br></div> <div>Then, you'd swap the space and the number that was there. As Daniel said, it's an interesting problem and it could be designed either with a command-line interface or a gui one (or done as a command-line at first and developed into a GUI program).</div> </body> </html> --============_-1223598608==_ma============-- From deirdre@deirdre.net Sun Apr 29 07:10:28 2001 From: deirdre@deirdre.net (Deirdre Saoirse Moen) Date: Sat, 28 Apr 2001 23:10:28 -0700 Subject: [Tutor] determining whether a set is a group In-Reply-To: <OE29ef2b0Jpc05IXgTh00005dcd@hotmail.com> References: <OE29ef2b0Jpc05IXgTh00005dcd@hotmail.com> Message-ID: <a05100e0bb7115df57b1c@[10.0.1.24]> --============_-1223597837==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" The hardest part about learning to program, and the reason why so many people give up on it is exactly what you said below: knowing where to start. That's why we're here. :) And you're right -- a lot of people learn to program for the same reason you do: because they want to do something and they are lazy. In fact, I think there's a Linus Torvalds quote about why that makes him a good programmer. The first thing to ask about any project is: "what do I know about it?" You'll realize that you know more than you think you do, you just may not have broken it down into the little baby steps computers want. Most programming isn't hard really, just time-consuming. The next thing is to start with what you can program in the project. The overall problem may seem too huge, but right now, you probably can start with something. In other words, start somewhere. This is counter to advice you may get later on (on how to design) but you know enough to do *something* most likely (like ask the user how many elements are in the set). Then, when you knock off all the things you know how to do, then there's a few things you don't know. As much as you can, break each one down into pieces and write what you can. Yell for help when you need it. Most of the expertise gained in the first few years of programming for a living isn't anything you learn, you just learn how to go through this process more efficiently. >Hello everyone! I took a modern abstract algebra class this >semester and there is something that caught my attention, and which >I think would make a neat program. I would like to have a program >in which given any set and the table accompaning the set, the >computer would display a message stating whether the set is a group >or not. I guess I would have to get the computer to ask for the >amount of elements in the set, say 6, and then have the computer >generate a 6 by 6 matrix, in which the user would enter the >corresponding table, so the computer can figure out, after testing >for the required properties, whether the set is a group or not. You >might think that I'm very lazy to want the computer to do this for >me, and I guess you are right, this is probably the reason why >computer programming is becoming more interesting by the minute. >You do the work only once and then the computer does it for you. It >is beautiful! I have so many little projects that could make my >life much much easier, that I don't know where to start. My only >and biggest problem is that I'm a computer illiterate and have no >clue as to where to start, however, I'm willing to do what it takes >to learn. I know that some help over the internet might not do >miracles for me, but I guess it would be a start. I have the book >Teach Yourself Python in 24 Hours and I'm reading it, but I guess I >need more help. Can you help me. -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams --============_-1223597837==_ma============ Content-Type: text/html; charset="us-ascii" <!doctype html public "-//W3C//DTD W3 HTML//EN"> <html><head><style type="text/css"><!-- blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 } --></style><title>Re: [Tutor] determining whether a set is a group</title></head><body> <div>The hardest part about learning to program, and the reason why so many people give up on it is exactly what you said below: knowing where to start. That's why we're here. :)</div> <div><br></div> <div>And you're right -- a lot of people learn to program for the same reason you do: because they want to do something and they are lazy. In fact, I think there's a Linus Torvalds quote about why that makes him a good programmer.</div> <div><br></div> <div>The first thing to ask about any project is: "what do I know about it?" You'll realize that you know more than you think you do, you just may not have broken it down into the little baby steps computers want. Most programming isn't hard really, just time-consuming.</div> <div><br></div> <div>The next thing is to start with what you can program in the project. The overall problem may seem too huge, but right now, you probably can start with something. In other words, start somewhere. This is counter to advice you may get later on (on how to design) but you know enough to do *something* most likely (like ask the user how many elements are in the set).</div> <div><br></div> <div>Then, when you knock off all the things you know how to do, then there's a few things you don't know. As much as you can, break each one down into pieces and write what you can. Yell for help when you need it.</div> <div><br></div> <div>Most of the expertise gained in the first few years of programming for a living isn't anything you learn, you just learn how to go through this process more efficiently.</div> <div><br></div> <blockquote type="cite" cite><font face="Arial" size="-1">Hello everyone! I took a modern abstract algebra class this semester and there is something that caught my attention, and which I think would make a neat program. I would like to have a program in which given any set and the table accompaning the set, the computer would display a message stating whether the set is a group or not. I guess I would have to get the computer to ask for the amount of elements in the set, say 6, and then have the computer generate a 6 by 6 matrix, in which the user would enter the corresponding table, so the computer can figure out, after testing for the required properties, whether the set is a group or not. You might think that I'm very lazy to want the computer to do this for me, and I guess you are right, this is probably the reason why computer programming is becoming more interesting by the minute. You do the work only once and then the computer does it for you. It is beautiful! I have so many little projects that could make my life much much easier, that I don't know where to start. My only and biggest problem is that I'm a computer illiterate and have no clue as to where to start, however, I'm willing to do what it takes to learn. I know that some help over the internet might not do miracles for me, but I guess it would be a start. I have the book<u> Teach Yourself Python in 24 Hours</u> and I'm reading it, but I guess I need more help. Can you help me.</font></blockquote> </body> </html> --============_-1223597837==_ma============-- From sheila@thinkspot.net Sun Apr 29 07:31:42 2001 From: sheila@thinkspot.net (Sheila King) Date: Sat, 28 Apr 2001 23:31:42 -0700 Subject: [Tutor] determining whether a set is a group In-Reply-To: <OE29ef2b0Jpc05IXgTh00005dcd@hotmail.com> References: <OE29ef2b0Jpc05IXgTh00005dcd@hotmail.com> Message-ID: <1B89315070E@kserver.org> On Sun, 29 Apr 2001 00:57:06 -0500, "Julieta" <julieta_rangel@hotmail.com> wrote about [Tutor] determining whether a set is a group: :Hello everyone! I took a modern abstract algebra class this semester and there is something that caught my attention, and which I think would make a neat program. I would like to have a program in which given any set and the table accompaning the set, the computer would display a message stating whether the set is a group or not. OK, you made me go look up what a group is. (I couldn't remember for sure...and couldn't find my abstract algebra text.) For the benefit of others, who may not know, I found this definition on the web: The axioms (basic rules) for a group are: ( where the dot (•) symbolizes some operation...) 1.CLOSURE: If a and b are in the group then a • b is also in the group. 2.ASSOCIATIVITY: If a, b and c are in the group then (a • b) • c = a • (b • c). 3.IDENTITY: There is an element e of the group such that for any element a of the group a • e = e • a = a. 4.INVERSES: For any element a of the group there is an element a^(-1) such that a • a^(-1) = e and a^(-1) • a = e : I guess I would have to get the computer to ask for the amount of elements in the set, say 6, and then have the computer generate a 6 by 6 matrix, in which the user would enter the corresponding table, so the computer can figure out, after testing for the required properties, whether the set is a group or not. Well, it sounds like an interesting project. It only would work for discrete sets, with a finite number of elements. But writing the program would help you learn a number of things. You'd have to define your operation, symbolized by the dot (•). I suppose you'd have to write a function to handle checking (1)Closure, and another to handle checking (2) Associativity. As far as checking for an identity element and inverses, though...I can't think how you'd get the computer to do that, except (possibly), by exhaustion (try all possible combinations until you find one that works?). I don't know that a matrix would be necessary. A simple list of the elements, and then iterate through the list, checking each element of the list against all others (so a nested loop). :You might think that I'm very lazy to want the computer to do this for me, and I guess you are right, this is probably the reason why computer programming is becoming more interesting by the minute. You do the work only once and then the computer does it for you. It is beautiful! I have so many little projects that could make my life much much :easier, that I don't know where to start. My only and biggest problem is that I'm a computer illiterate and have no clue as to where to start, however, I'm willing to do what it takes to learn. I know that some help over the internet might not do mira cles for me, but I guess it would be a start. I have the book Teach Yourself Python in 24 Hours and I'm reading it, but I guess I need more help. Can you help me. Yep, I've got a list of projects, too. Computer programming can be great. Here are some websites that have Python tutorials aimed at non-programmers: For non-programmers: Non-programmer's tutorial for Python http://www.honors.montana.edu/~jjc/easytut/easytut/ Learning To Program http://www.crosswinds.net/~agauld/ Python Baby-steps Tutorial (crashed my NS but viewable in IE) http://www.coolnamehere.com/z/programming/python/pythontut.asp How To Think Like a Computer Scientist http://www.ibiblio.org/obp/ Instant Hacking http://www.hetland.org/python/instant-hacking.php -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dyoo@hkn.eecs.berkeley.edu Sun Apr 29 07:32:44 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 28 Apr 2001 23:32:44 -0700 (PDT) Subject: [Tutor] 15 puzzle (fwd) Message-ID: <Pine.LNX.4.21.0104282256100.17256-101000@hkn.eecs.berkeley.edu> This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ------=_NextPart_000_53dd_1d84_16c4 Content-Type: TEXT/PLAIN; FORMAT=flowed; charset=US-ASCII Content-ID: <Pine.LNX.4.21.0104282256102.17256@hkn.eecs.berkeley.edu> Dear Maritza, Unfortunately, I'm unable to read word documents, so I'm forwarding this to the other python tutors, in hopes that someone out there has Windows. *grin* By the way, when you're replying to messages from tutor, make sure you're doing a reply-to-all, so that other people can volunteer their insight to the problem. We can translate much of the meaning of the Java applet into a Python program. However, it's not going to be a line-by-line translation: there are certain things that are easier to do in Python than Java, and vice versa. Python makes working with lists very convenient, and it's this versetility that encourages idioms that might not translate well without some effort. Just to give an example, when we're trying to represent something two-dimensionally in Java, the language offers a structure called the array, which is something analogous to a Python list. Let's talk about how we can possible represent a board position in Java and Python. As a warning, my Java's very rusty, so some of this code may offend Java purists. At the same time, I threaten to offend Python programmers with what must look like an eyesore. Either way, I apologize in advance. *grin* Here's a snippet of code that explores one possible way we can represent the 15-puzzle board, as a 2-dimensional array: /// public class test { static String[][] makeBoard() { String[][] board = new String[4][4]; int counter = 1; for(int row = 0; row < board.length; row++) { for(int col = 0; col < board[row].length; col++) { board[row][col] = (counter++)+""; } } board[3][3] = " "; return board; } static public void main(String[] args) { String[][] board = makeBoard(); for(int i = 0; i < board.length; i++) { for(int j = 0; j < board[i].length; j++) { System.out.print(board[i][j] + " "); } System.out.println(); } } } /// Here's a bit of Python code that does a similar task: ### def makeBoard(): board = [None] * 4 for i in range(len(board)): board[i] = map(str, range(4*i+1, 4*i + 5)) board[3][3] = ' ' return board if __name__ == '__main__': board = makeBoard(); for row in range(len(board)): print board[row] ### As you can see, there are a lot of concepts that transfer cleanly between both languages, but there are also substantial differences. Some of these owe to the fact that I haven't played around enough with Java to feel casual with it; at the same time, Java isn't really meant for casual use anyway. *grin* I guess I'm trying to say that, yes, you can borrow some ideas from the Java applet, but to really learn Python, you'll want to experiment with the "Pythonic" way of doing things, and this you'll learn as you play with examples and programs. I hope that we can talk more about your program. Feel free to email us your progress as you learn Python. Good luck! ---------- Forwarded message ---------- Date: Sat, 28 Apr 2001 23:08:03 -0500 From: Maritza Rodriguez <maritza_rodz@hotmail.com> To: dyoo@hkn.eecs.berkeley.edu Subject: 15 puzzle I found this information on the internet. It appears to be the actual program generating the game, but it is in another language. Is it possible to translate it to python? Please help. Maritza _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com ------=_NextPart_000_53dd_1d84_16c4 Content-Type: APPLICATION/OCTET-STREAM; NAME="The 15 Applet.doc" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.LNX.4.21.0104282256103.17256@hkn.eecs.berkeley.edu> Content-Description: Content-Disposition: ATTACHMENT; FILENAME="The 15 Applet.doc" 0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAB AAAAKgAAAAAAAAAAEAAALAAAAAEAAAD+////AAAAACkAAAD///////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// ///////////////////////spcEANyAJBAAA8BK/AAAAAAAAEAAAAAAABAAA iQwAAA4AYmpialUWVRYAAAAAAAAAAAAAAAAAAAAAAAAJBBYAIiAAADd8AAA3 fAAAiQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAA AAD//w8AAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAGwAAAAAACoBAAAA AAAAKgEAACoBAAAAAAAAKgEAAAAAAAAqAQAAAAAAACoBAAAAAAAAKgEAABQA AAAAAAAAAAAAAD4BAAAAAAAARgcAAAAAAABGBwAAAAAAAEYHAAAAAAAARgcA AAwAAABSBwAAHAAAAD4BAAAAAAAA5QsAAPYAAAB6BwAAAAAAAHoHAAAAAAAA egcAAAAAAAB6BwAAAAAAAHoHAAAAAAAAegcAAAAAAAB6BwAAAAAAAHoHAAAA AAAAZAsAAAIAAABmCwAAAAAAAGYLAAAAAAAAZgsAAAAAAABmCwAAAAAAAGYL AAAAAAAAZgsAACQAAADbDA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AAAAAAFABD ShQAT0oDAFBKAwBRSgMAYUoUAAAAAACJCAAABAAAIAAAAAD/////AAAAAAMA AAAUAAAAXQAAAKQAAADrAAAANAEAAH4BAACsAQAArQEAAMwBAAAUAgAAXQIA AKYCAADnAgAACAMAAAsDAAAhAwAANAMAAIEDAAClAwAApwMAAOoDAAA+BAAA dgQAAI4EAACyBAAAxQQAAAkFAABDBQAARgUAAGUFAACFBQAAvwUAAMIFAADD BQAABwYAABsGAAAeBgAAKQYAAEQGAABFBgAAWQYAAJcGAAC1BgAAtgYAAMUG AADeBgAA8QYAAPQGAAAZBwAAMgcAAEgHAABJBwAAcAcAAIkHAACfBwAAoAcA ALIHAADJBwAA3wcAAOMHAAD0BwAA9wcAADsIAABqCAAAbQgAAHgIAAB7CAAA iAgAAIsIAACYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAA AAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICY AAAADzAAAAAAAAAAgAAAAICYAAAADzAAAAAAAAAAgAAAAICYAAAAADAAAAAA AAAAgAAAAIAABAAAiQwAAAsAAAAABAAAQwkAALILAACJDAAADAAAAA4AAAAP AAAAAAQAAIkMAAANAAAAAAAAANoAAADiAAAAEgMAAB0DAAAoAwAAMAMAALID AADDAwAA1AMAAOUDAAArBAAAMgQAAFAEAABaBAAAgQQAAIQEAACZBAAAnAQA ABgFAAAlBQAAIAYAACMGAAAkBgAAJQYAADIGAAA1BgAAWwYAAGQGAACZBgAA pgYAAKcGAACyBgAAvAYAAL0GAADMBgAA0wYAAPsGAAAFBwAAIAcAACcHAABQ BwAAWwcAAHcHAAB+BwAAQwgAAEoIAABYCAAAWwgAAG8IAAByCAAAcwgAAHQI AACCCAAAgwgAAIsIAAAHABwABwAcAAcAHAAHABwABwAcAAcAHAAHABwABwAc AAcAHAAHABwABwAcAAcAHAAHABwABwAcAAcAHAAHABwABwAcAAcAHAAHABwA BwAcAAcAHAAHABwABwAcAAcAHAAHABwABwAcAAcAHAAHAAAAAAAMAAAAEgAA AEoAAABQAAAAUgAAAFwAAABfAAAAZQAAAKYAAACtAAAA7QAAAPIAAAA2AQAA OgEAAIABAACIAQAAXwIAAGMCAACoAgAAsAIAAOkCAAD8AgAACwMAABEDAAAh AwAAJwMAAIEDAACHAwAAqgMAALEDAADtAwAA9AMAAEEEAABIBAAAeQQAAIAE AACRBAAAmAQAALUEAAC8BAAACgUAABAFAABIBQAATgUAAAgGAAAOBgAAIAYA ACMGAAA6BgAAQQYAAEcGAABNBgAAWwYAAGQGAACZBgAApgYAALgGAAC7BgAA zAYAANMGAADkBgAA6gYAAPYGAAD6BgAAIAcAACcHAAA7BwAAQQcAAEsHAABP BwAAdwcAAH4HAACSBwAAmAcAAKgHAACsBwAAtAcAALgHAADSBwAA2AcAAOYH AADsBwAAPAgAAEIIAABvCAAAcggAAH4IAACBCAAAiwgAAAcAMwAHADMABwAz AAcAMwAHADMABwAzAAcAMwAHADMABwAzAAcAMwAHADMABwAzAAcAMwAHADMA BwAzAAcAMwAHADMABwAzAAcAMwAHADMABwAzAAcAMwAHADMABwAzAAcAMwAH ADMABwAzAAcAMwAHADMABwAzAAcAMwAHADMABwAzAAcAMwAHADMABwAzAAcA MwAHADMABwAzAAcAMwAHADMABwAzAAcA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIA AAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAA AA4AAAAPAAAAEAAAAP7///8SAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAA /v///xoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAACAAAAD+////IgAAACMAAAAk AAAAJQAAACYAAAAnAAAAKAAAAP7////9////KwAAAP7////+/////v////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////9SAG8AbwB0ACAARQBuAHQAcgB5AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgAFAf//////////AwAA AAYJAgAAAAAAwAAAAAAAAEYAAAAAAAAAAAAAAAAAcPi7YdDAAS0AAACAAAAA AAAAADEAVABhAGIAbABlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAIA////////////////AAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAQAAAAAAAAVwBv AHIAZABEAG8AYwB1AG0AZQBuAHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAABoAAgEFAAAA//////////8AAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIiAAAAAAAAAFAFMAdQBtAG0A YQByAHkASQBuAGYAbwByAG0AYQB0AGkAbwBuAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAKAACAQIAAAAEAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAABkAAAAAEAAAAAAAAAUARABvAGMAdQBtAGUAbgB0 AFMAdQBtAG0AYQByAHkASQBuAGYAbwByAG0AYQB0AGkAbwBuAAAAAAAAAAAA AAA4AAIB////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAIQAAAAAQAAAAAAAAAQBDAG8AbQBwAE8AYgBqAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAgEB AAAABgAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAagAAAAAAAABPAGIAagBlAGMAdABQAG8AbwBsAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgABAP////////// /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAHD4u2HQwAEAcPi7YdDAAQAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////AAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AQAAAP7///////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////8BAP7/AwoAAP////8GCQIAAAAAAMAAAAAAAABG GAAAAE1pY3Jvc29mdCBXb3JkIERvY3VtZW50AAoAAABNU1dvcmREb2MAEAAA AFdvcmQuRG9jdW1lbnQuOAD0ObJxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== ------=_NextPart_000_53dd_1d84_16c4-- From dyoo@hkn.eecs.berkeley.edu Sun Apr 29 07:43:28 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sat, 28 Apr 2001 23:43:28 -0700 (PDT) Subject: [Tutor] determining whether a set is a group In-Reply-To: <a05100e0bb7115df57b1c@[10.0.1.24]> Message-ID: <Pine.LNX.4.21.0104282334150.17256-100000@hkn.eecs.berkeley.edu> Hiya Julieta, Could you tell us some facts about groups? I do have my abstract algebra book with me, but it might have different definitions than what your books have. *grin* Let's talk about what it means for something to be a group. We might find ways to express these ideas in Python syntax. > And you're right -- a lot of people learn to program for the same > reason you do: because they want to do something and they are lazy. > In fact, I think there's a Linus Torvalds quote about why that makes > him a good programmer. The Perl people understand this as the Three Virtues of a Programmer: "Laziness, impatience, and hubris". http://www.netropolis.org/hash/perl/virtue.html > >and biggest problem is that I'm a computer illiterate and have no > >clue as to where to start, however, I'm willing to do what it takes > >to learn. I know that some help over the internet might not do > >miracles for me, but I guess it would be a start. I have the book > >Teach Yourself Python in 24 Hours and I'm reading it, but I guess I > >need more help. Can you help me. We'll do our best to help. Good luck! From sheila@thinkspot.net Sun Apr 29 07:51:04 2001 From: sheila@thinkspot.net (Sheila King) Date: Sat, 28 Apr 2001 23:51:04 -0700 Subject: [Tutor] 15 puzzle (fwd) In-Reply-To: <Pine.LNX.4.21.0104282256100.17256-101000@hkn.eecs.berkeley.edu> References: <Pine.LNX.4.21.0104282256100.17256-101000@hkn.eecs.berkeley.edu> Message-ID: <1CA350D3FC8@kserver.org> On Sat, 28 Apr 2001 23:32:44 -0700 (PDT), Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> wrote about [Tutor] 15 puzzle (fwd): Here are the contents of the MS Word document: /* The 15 Applet. You can do whatever you want with the code. You can use it, modify it, delete it. You can even print it out and burn it, or you can burn it without printing it out, but then please do be very carefull, for I heard that monitors, hard drives and computers in general don't behave well under high temperatures. Just don't hold me responsible if it does anything, um, not so good to your computer. There is one thing I do ask: This is my first Java effort, so I don't know the language very well. I'm almost sure that some things here are quite incorrect, even though they do work. Never mind the algorithms themselves, but if you do find anything that needs to be changed, please send me a message at eugene@interlog.com Thank you. */ import java.applet.*; import java.awt.*; //-------------------------------------------------------------------------- public class fifteen extends Applet { private SevenSegmentDigit[] display = new SevenSegmentDigit[3]; private Button[] Buttons = new Button[16]; //This array is an actuall playfield. private Button shuffleBtn = new Button ("&Shuffle"); private int score=0; private int shuffling=0; private Font f; /*---------------------------------------------------------------*/ public String getAppletInfo() //Do I need this function? { return "Name: fifteen\r\n" + "Author: Eugene\r\n" + "Created with Microsoft Visual J++ Version 1.0"; } /*---------------------------------------------------------------*/ public void init() { int i=0; String str=new String(); resize(200, 300); setLayout(null); //Why do they bother so hard with layouts? setBackground(Color.black); for(i=0; i3) moveBtn(empty-4); return true; case Event.LEFT: if(empty % 4 !=3) moveBtn(empty+1); return true; case Event.RIGHT: if(empty % 4 != 0) moveBtn(empty-1); return true; case 's': case 'S': shuffle(); return true; } return false; } /*---------------------------------------------------------------*/ public boolean action(Event evt, Object what) { int i=0; for(i=0;i -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dyoo@hkn.eecs.berkeley.edu Sun Apr 29 08:05:50 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 29 Apr 2001 00:05:50 -0700 (PDT) Subject: [Tutor] determining whether a set is a group In-Reply-To: <1B89315070E@kserver.org> Message-ID: <Pine.LNX.4.21.0104282350400.17256-100000@hkn.eecs.berkeley.edu> On Sat, 28 Apr 2001, Sheila King wrote: > The axioms (basic rules) for a group are:=20 > ( where the dot (=95) symbolizes some operation...) >=20 > 1.CLOSURE: If a and b are in the group then a =95 b is also in the gro= up.=20 > 2.ASSOCIATIVITY: If a, b and c are in the group then (a =95 b) =95 c = =3D a =95 (b =95 > c).=20 > 3.IDENTITY: There is an element e of the group such that for any eleme= nt a > of the group > a =95 e =3D e =95 a =3D a.=20 > 4.INVERSES: For any element a of the group there is an element a^(-1) = such > that=20 > a =95 a^(-1) =3D e=20 > and=20 > a^(-1) =95 a =3D e=20 Doing stuff with infinite sets looks messy, so let's try working with finite groups for now. It appears that a group is a combination of: 1. a set of elements. 2. some operation that combines any two elements. There's no built-in that perfectly represents a set in Python, but in a pinch, the list structure works very well. Also, Python functions seem like a great way to represent a group operator. For example, we can say that: ### def addModFour(x, y): return (x + y) % 4 mygroup =3D ([0, 1, 2, 3], addModFour) ### would be one way to represent a group in Python, as a 2-tuple. What's nice is that this representation allows us to test for all four cases fairly nicely. Here's a little snippet that hints at a possible way to test for closure: ### elements, operator =3D mygroup if operator(elements[0], elements[1]) in elements: print "Our group might not be closed," print "but at least %s dotted with %s is in our set" % (elements[0], elements[1]") else: print "There's no way this is a group, because it's not closed!" ### Once you get through the for-loops and lists chapter in Teach Yourself Python, try writing the closure checking function; I think you'll be pleasantly surprised. Hope this helps! From juno@gamefire.com Sun Apr 29 09:30:33 2001 From: juno@gamefire.com (juno@gamefire.com) Date: Sun, 29 Apr 2001 01:30:33 -0700 Subject: [Tutor] Help with the technique "Menu Processing" Message-ID: <DEEGIKBPAICAIOPICOHKEECLCBAA.juno@gamefire.com> Hi Everyone, I was wondering if I might be able to get some help with "Menu Processing". What I'm looking for is an example of how it might be done within an object. I've been trying myself, but I keep getting an error. Here's an example of what I'm trying to do: Class msg: def __init__(self): self.msgtype = {"priv":send_priv_msg, "pub":send_pub_msg, "action":send_action_msg, "notice":send_notice_msg, "ctcp":send_ctcp_msg} ...more stuff... def send_priv_msg(connection, nick, text): ... send code .. def send_pub_msg(connection, nick, text): ... send code .. def send_action_msg(connection, nick, text): ... send code .. def send_notice_msg(connection, nick, text): ... send code .. def send_ctcp_msg(connection, nick, text): ... send code .. def send_msg_by(connection, nick, text, type): self.msgtype[type](connection, nick, text) Thanks, Juno From toodles@yifan.net Sun Apr 29 14:05:54 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Sun, 29 Apr 2001 21:05:54 +0800 Subject: [Tutor] Help with the technique "Menu Processing" In-Reply-To: <DEEGIKBPAICAIOPICOHKEECLCBAA.juno@gamefire.com> Message-ID: <FPEHJJPEEOIPMAHOADBKCECCCDAA.toodles@yifan.net> Hi Juno, What you need to do is set up the class so... 1) Each method's first argument is self. self refers to the instance itself, if you don't know. eg. > def send_priv_msg(connection, nick, text): > ... send code .. should be: def send_priv_msg(self,connection,nick,text): blah blah blah 2) The msgtype dictionary's values should have self before the variables, to tell python to look in the instance's own namespace. eg. > self.msgtype = {"priv":send_priv_msg, should be: self.msgtype={"priv":self.send_priv_msg, #and so on... Now when you call them, it should be fine and dandy! def send_msg_by(connection, nick, text, type): > self.msgtype[type](connection, nick, text) *looks puzzled* You had it right in that one! =) Hope you can understand my badly written attempt at helping... Andrew > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > juno@gamefire.com > Sent: Sunday, 29 April 2001 4:31 PM > To: tutor@python.org > Subject: [Tutor] Help with the technique "Menu Processing" > > > Hi Everyone, > I was wondering if I might be able to get some help with "Menu > Processing". > What I'm looking for is an example of how it might be done within > an object. > I've been trying myself, but I keep getting an error. > > Here's an example of what I'm trying to do: > > Class msg: > def __init__(self): > self.msgtype = {"priv":send_priv_msg, > "pub":send_pub_msg, > "action":send_action_msg, > "notice":send_notice_msg, > "ctcp":send_ctcp_msg} > ...more stuff... > > def send_priv_msg(connection, nick, text): > ... send code .. > def send_pub_msg(connection, nick, text): > ... send code .. > def send_action_msg(connection, nick, text): > ... send code .. > def send_notice_msg(connection, nick, text): > ... send code .. > def send_ctcp_msg(connection, nick, text): > ... send code .. > > def send_msg_by(connection, nick, text, type): > self.msgtype[type](connection, nick, text) > > > Thanks, > > Juno > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From bdupire@seatech.fau.edu Sun Apr 29 16:59:58 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Sun, 29 Apr 2001 11:59:58 -0400 Subject: [Tutor] determining whether a set is a group References: <Pine.LNX.4.21.0104282350400.17256-100000@hkn.eecs.berkeley.edu> Message-ID: <3AEC3A7E.1868590F@seatech.fau.edu> Daniel Yoo wrote: > On Sat, 28 Apr 2001, Sheila King wrote: > > > The axioms (basic rules) for a group are: > > ( where the dot (=95) symbolizes some operation...) > > > > 1.CLOSURE: If a and b are in the group then a =95 b is also in the= group. > > 2.ASSOCIATIVITY: If a, b and c are in the group then (a =95 b) =95= c =3D a =95 (b =95 > > c). > > 3.IDENTITY: There is an element e of the group such that for any e= lement a > > of the group > > a =95 e =3D e =95 a =3D a. > > 4.INVERSES: For any element a of the group there is an element a^(= -1) such > > that > > a =95 a^(-1) =3D e > > and > > a^(-1) =95 a =3D e > The pb is that my computer can't handle very well infinite sets... how do= es a program like Mapple handle this kind of things ? How can i implement something whose cardinal is Cantor something (ie. inf= inite) ? Although i remember what a group is , i don't remember what groups are us= eful for....... any math teachers? Benoit From sheila@thinkspot.net Sun Apr 29 17:40:06 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 29 Apr 2001 09:40:06 -0700 Subject: [Tutor] determining whether a set is a group In-Reply-To: <3AEC3A7E.1868590F@seatech.fau.edu> References: <Pine.LNX.4.21.0104282350400.17256-100000@hkn.eecs.berkeley.edu> <3AEC3A7E.1868590F@seatech.fau.edu> Message-ID: <3E369671789@kserver.org> On Sun, 29 Apr 2001 11:59:58 -0400, Benoit Dupire <bdupire@seatech.fau.edu> wrote about Re: [Tutor] determining whether a set is a group: :Although i remember what a group is , i don't remember what groups are us= :eful :for....... any math teachers? Uh, I am a math teacher. Sorry to say, I don't work much with groups. I took one required course in Abstract Algebra, and then went on to do probability and analysis, and a small bit of numerical methods. Abstract algebra is more for the theorists and purists. I'm more interested in the practical application of math (although I enjoy the theory and beauty of it, as well). Here is a nice page with a lot of Algebra definitions and theorems on it: http://www.math.niu.edu/~beachy/aaol/ If I get a better answer to "What are groups good for?", I will share. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sheila@thinkspot.net Sun Apr 29 18:03:18 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 29 Apr 2001 10:03:18 -0700 Subject: [Tutor] determining whether a set is a group In-Reply-To: <3E369671789@kserver.org> References: <Pine.LNX.4.21.0104282350400.17256-100000@hkn.eecs.berkeley.edu> <3AEC3A7E.1868590F@seatech.fau.edu> <3E369671789@kserver.org> Message-ID: <3F8364E13E9@kserver.org> On Sun, 29 Apr 2001 09:40:06 -0700, Sheila King <sheila@thinkspot.net> wrote about Re: [Tutor] determining whether a set is a group: :If I get a better answer to "What are groups good for?", I will share. OK, from a Britannica.com article on Fourier Analysis (which we all know is extremely important for engineering, right?) here: http://www.britannica.com/eb/article?eu=120670 I quote: """ Since their formal introduction in the early 19th century, groups have been one of the principal objects of mathematical attention (see algebra: Groups). Their widespread and profound applications to such physical subjects as crystallography, quantum mechanics, and hydrodynamics and to such other mathematical regimes as number theory, harmonic analysis, and geometry have demonstrated their importance. """ And from this article at Britannica.com on Groups: http://www.britannica.com/eb/article?eu=120647 I quote: """ In studying the solution of polynomial equations, a Norwegian mathematician, Niels Henrik Abel, showed that in general the equation of fifth degree cannot be solved by radicals. Then the French mathematician Évariste Galois, using groups systematically, showed that the solution of an equation by radicals is possible only if a group associated with the equation has certain specific properties; these groups are now called solvable groups. The group concept is now recognized as one of the most fundamental in all of mathematics and in many of its applications. The German mathematician Felix Klein considered geometry to be those properties of a space left unchanged by a certain specific group of transformations. In topology geometric entities are considered equivalent if one can be transformed into another by an element of a continuous group. """ If you're interested, you will find much more on the importance and usefulness of groups at the links listed above. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From julieta_rangel@hotmail.com Sun Apr 29 19:48:34 2001 From: julieta_rangel@hotmail.com (Julieta Rangel) Date: Sun, 29 Apr 2001 13:48:34 -0500 Subject: [Tutor] Multiplication of polynomials Message-ID: <F171gStMVhEUsebmspH0000c3d1@hotmail.com> <html><DIV>If I want to write a program that multiplies polynomials, just to show you how illiterate I am at computer programming, this is what I would do: I would need the user to enter the amount of polynomials that will be multiplying. Lets say the user wants to multiply two polynomials. Once the user enters the amount of polynomials that will be multiplying, the computer would have to ask the degree of the polynomials, say the first polynomial is of third degree and the second is a second degree polynomial (2x^3 + x^2 + 3x + 2) * (x^2 + 1)Once the person enters the degree of the polynomials, the computer would have to ask the coefficient of each of the terms of the polynomials, in this case the computer would have to ask the user to enter the coefficient of x^3, x^2, x, and c and then the coefficients of the second polynomial. Should I have the computer create two lists for each polynomial? In one list I would store all the coefficients and in another the exponents of the expression. I'm assuming that if I have two lists for each polynomial, I could do the operations required. Based on the polynomials I have, the lists of coefficients would look like (L1) [2,1,3,2] and (L2)[1,0,1] and my lists of exponents would look like (L 3) [3,2,1,0] and (L 4)[2,1,0]. I would then have the first element in L1 times each element in L2, so that I get list 5 [2,0,2]</DIV> <DIV>and 1st element in L3 + each element in L4, so that I get list 6 [5,4,3]. Then I would have the 2nd element in L1 times each element in L2 so that I get another list [1,0,1] and also have the 2nd element in L3 + each element in L4, so that I get [4,3,2]. This would go on for each element and I would end up with 4 more lists [3,0,3], [3,2,1], [2,0,2], [2,1,0]. I would then take the numbers from my lists and have the computer write the coefficients along with the exponents: 2x^5 + 0x^4 + 2x^3 + x^4 +0x^3+x^2+3x^3+0x^2 +3x+ 2x^2+0x+2. I would then have to get rid of those terms with zero coefficients and combine like terms. Is this crazy or what? How could I accomplish this? Like I told you before, this is all new to me, but I'm really interested in finding out how this complex task can be accomplished in Python. Can you help?</DIV> <DIV> </DIV> <DIV>Julieta</DIV><br clear=all><hr>Get your FREE download of MSN Explorer at <a href="http://explorer.msn.com">http://explorer.msn.com</a><br></p></html> From sheila@thinkspot.net Sun Apr 29 20:26:46 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 29 Apr 2001 12:26:46 -0700 Subject: [Tutor] Multiplication of polynomials In-Reply-To: <F171gStMVhEUsebmspH0000c3d1@hotmail.com> References: <F171gStMVhEUsebmspH0000c3d1@hotmail.com> Message-ID: <47A4FFB472F@kserver.org> Juliet, PLEASE set your mail settings, to compose in plain text. On Sun, 29 Apr 2001 13:48:34 -0500, "Julieta Rangel" <julieta_rangel@hotmail.com> wrote about [Tutor] Multiplication of polynomials: :<html><DIV>If I want to write a program that multiplies polynomials, just to show you how illiterate I am at computer programming, this is what I would do: I would need the user to enter the amount of polynomials that will be multiplying. Let s say the user wants to multiply two polynomials. Once the user enters the amount of polynomials that will be multiplying, the computer would have to ask the degree of the polynomials, say the first polynomial is of third degree and the second is a second degree polynomial (2x^3 + x^2 + 3x + 2) * (x^2 + 1)Once the person enters the degree of the polynomials, the computer would have to ask the coefficient of each of the terms of the polynomials, in this case the computer would have to ask the user to enter the coefficient of x^3, x^2, x, and c and then the coefficients of the second polynomial. Should I have the computer create two lists for each polynomial? In one list I would store all the coefficients :and in another the exponents of the expression. This is a worthy problem. I might suggest, first implementing polynomial addition, rather than multiplication. Do the addition first, and once you've got that, try multiplication. Another worthy problem, is evaluating a single polynomial for a given value of x. Well, maybe that one is a bit easy. Still, worthy trying for a new, non-programmer. As to your problem, you really don't need to store the exponents of the polynomial in a second list. You could infer the exponent from the placement of the polynomial's coefficient in the list. For example, you could store 2x^4+x^2-3x+5 as [2, 0, 1, -3, 5] or, you might want to store it in reverse order, as [5, -3, 1, 0, 2] The advantage of the second representation is that, if coeff = [5, -3, 1, 0, 2] then coeff[4] refers to the coefficient of the x^4 term, and coeff[1] refers to the coefficient of the x^1 term, and so on. You should store zeros for the coefficients equal to zero. Really, you might want to make a class called Polynomial and give it methods like ValueAtX and Add and Multiply. : I'm assuming that if I have two lists for each polynomial, I could do the operations required. Based on the polynomials I have, the lists of coefficients would look like (L1) [2,1,3,2] and (L2)[1,0,1] and my lists of exponents would look li ke (L 3) [3,2,1,0] and (L 4)[2,1,0]. I would then have the first element in L1 times each element in L2, so that I get list 5 [2,0,2]</DIV> :<DIV>and 1st element in L3 + each element in L4, so that I get list 6 [5,4,3]. Then I would have the 2nd element in L1 times each element in L2 so that I get another list [1,0,1] and also have the 2nd element in L3 + each element in L4, so that I get [4,3,2]. This would go on for each element and I would end up with 4 more lists [3,0,3], [3,2,1], [2,0,2], [2,1,0]. I would then take the numbers from my lists and have the computer write the coefficients along with the exponents: 2x^5 + 0x^4 + 2x^3 + x^4 +0x^3+x^2+3x^3+0x^2 +3x+ 2x^2+0x+2. I would then have to get rid of those terms with zero coefficients and combine like terms. Is this crazy or what? How could I accomplish this? Like I told yo u before, this is all new to me, but I'm really interested in finding out how this complex task can be accomplished in Python. Can you help?</DIV> In order to multiply two polynomials, you would need to take each coefficient in the one list and multiply it be each coefficient in the other list. So, your suggested problem (2x^3 + x^2 + 3x + 2) * (x^2 + 1) might look like this: p1 = [2, 3, 1, 2] p2 = [1, 0, 1] I would note, that since you are multiplying a 3rd degree polynomial by a 2nd degree one, that your result should be fifth degree. You could find this out by doing len(p1)-1 added to len(p2)-1 then create a new list to store the results of your multiplication. Give it length of 5 and initialize all spots to zero. Let's call this new list for the result, p3. Now create a loop to go through each element of p1. Start with p1[0] and multiply it by p2[0] and add the result to p3[0]. Now multiply p1[0] with p2[1] and add the result to p3[1]. Now multiply p1[0] with p2[2] and add the result to p3[2]. All done with p1[0]. Now the loop moves to p1[1]. Multiply p1[1] with p2[0] and add the result to p3[1]. Now multiply p1[1] with p2[1] and add the result to p3[2]. Now multiply p1[1] with p2[2] and add the result to p3[3]. Note, that the indices indicate the exponent on your variable. So, p1[1] is an x^1 coefficient and p2[2] is an x^2 coefficient, so the result needs to be an x^3 coefficient, so add that result to p3[3]. Proceed on to p1[2] and p1[3] in the same manner. So, you have a loop on p1, and inside that loop is another loop that iterates over all the indices in p2. I hope this is helpful. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From bdupire@seatech.fau.edu Sun Apr 29 20:39:15 2001 From: bdupire@seatech.fau.edu (Benoit Dupire) Date: Sun, 29 Apr 2001 15:39:15 -0400 Subject: [Tutor] Multiplication of polynomials References: <F171gStMVhEUsebmspH0000c3d1@hotmail.com> Message-ID: <3AEC6DE2.E438AFD@seatech.fau.edu> you would want to have several functions one to define a polynom as a name one to add 2 polynoms one to multiply 2 polynoms and it would be nice to propose a menu to the user, so that he can choose what he wants to do A frame for your program could be ( i did not debug it...) polynome= {} def initPolynom(): global polynome name= raw_input('Polynom name ?') degree=raw_input('degree ?') coeff=[] for i in range (0, degree+1): coefficient = raw_input('coeff for x^ %i' %i) coeff.append(coefficient) polynome[name]=coeff def multiply(): global polynome name1= raw_input('Polynom name 1?') name2= raw_input('Polynom name 2?') pol1= polynome[name1] pol2 =polynome[name2] # perform here the multiplication logic. pol3 = pol1 * pol2 print pol3 name3 = raw_input('Give a name for the result..') polynome[name3]=pol3 def add(): pass # and now ... the menu menu=['init': initPolynom, 'multiply': multiply, 'add': add] for item in menu.keys(): print item choice = raw_input('your choice') if menu.has_key(choice): menu[choice]() Julieta Rangel wrote: > If I want to write a program that multiplies polynomials, just to show > you how illiterate I am at computer programming, this is what I would > do: I would need the user to enter the amount of polynomials that will > be multiplying. Lets say the user wants to multiply two polynomials. > Once the user enters the amount of polynomials that will be > multiplying, the computer would have to ask the degree of the > polynomials, say the first polynomial is of third degree and the > second is a second degree polynomial (2x^3 + x^2 + 3x + 2) * (x^2 + > 1)Once the person enters the degree of the polynomials, the computer > would have to ask the coefficient of each of the terms of the > polynomials, in this case the computer would have to ask the user to > enter the coefficient of x^3, x^2, x, and c and then the coefficients > of the second polynomial. Should I have the computer create two lists > for each polynomial? In one list I would store all the coefficients > and in another the exponents of the expression. > > > One list is enough (just the coeff): coeff[0] is coeff for exp. 0, > etc... > > > I'm assuming that if I have two lists for each polynomial, I could do > the operations required. Based on the polynomials I have, the lists > of coefficients would look like (L1) [2,1,3,2] and (L2)[1,0,1] and my > lists of exponents would look like (L 3) [3,2,1,0] and (L 4)[2,1,0]. I > would then have the first element in L1 times each element in L2, so > that I get list 5 [2,0,2]and 1st element in L3 + each element in L4, > so that I get list 6 [5,4,3]. Then I would have the 2nd element in L1 > times each element in L2 so that I get another list [1,0,1] and also > have the 2nd element in L3 + each element in L4, so that I get > [4,3,2]. This would go on for each element and I would end up with 4 > more lists [3,0,3], [3,2,1], [2,0,2], [2,1,0]. I would then take the > numbers from my lists and have the computer write the coefficients > along with the exponents: 2x^5 + 0x^4 + 2x^3 + x^4 > +0x^3+x^2+3x^3+0x^2 +3x+ 2x^2+0x+2. I would then have to get rid of > those terms with zero coefficients and combine like terms. Is this > crazy or what? How could I accomplish this? Like I told you before, > this is all new to me, but I'm really interested in finding out how > this complex task can be accomplished in Python. Can you > help? Julieta > > > ----------------------------------------------------------------------- > Get your FREE download of MSN Explorer at http://explorer.msn.com > _______________________________________________ Tutor maillist - > Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Benoit Dupire Graduate Student ---------------- I'd like to buy a new Boomerang. How can i get rid of the old one? From scarblac@pino.selwerd.nl Sun Apr 29 22:46:58 2001 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 29 Apr 2001 23:46:58 +0200 Subject: [Tutor] Multiplication of polynomials In-Reply-To: <F171gStMVhEUsebmspH0000c3d1@hotmail.com>; from julieta_rangel@hotmail.com on Sun, Apr 29, 2001 at 01:48:34PM -0500 References: <F171gStMVhEUsebmspH0000c3d1@hotmail.com> Message-ID: <20010429234658.A10233@pino.selwerd.nl> On 0, Julieta Rangel <julieta_rangel@hotmail.com> wrote: *Please* set your email to sending plain text. I have to jump through some hoops to get html mail into readable form. Not everyone uses Microsoft products, even though they want you to believe so. > <html><DIV>If I want to write a program that multiplies > polynomials, just to show you how illiterate I am at computer > programming, this is what I would do: I would need the user to enter the > amount of polynomials that will be multiplying. Lets say the user > wants to multiply two polynomials. Once the user enters the amount of > polynomials that will be multiplying, the computer would have to ask the > degree of the polynomials, say the first polynomial is of third degree and > the second is a second degree polynomial (2x^3 + x^2 + 3x + 2) * (x^2 + > 1)Once the person enters the degree of the polynomials, the computer would > have to ask the coefficient of each of the terms of the polynomials, > in this case the computer would have to ask the user to enter the > coefficient of x^3, x^2, x, and c and then the coefficients of the > second polynomial. Should I have the computer create two lists for > each polynomial? In one list I would store all the coeffici! ents and > in another the exponents of the expression. Let's ignore the way the user gives his input at first. It's relatively trivial, and there are many ways to do it. No, two lists aren't necessary. Keep one list for the coefficients, and you'll know from the length of that list which exponents the numbers belong to. If you have a list, say, L=[1,2,3,4], then that should be for a 3rd degree polynomial (len(L)-1), where L[0] is the coefficient of the 0-degree term, ie the constant. It stands for 4x^3+3x^2+2x+1. > I'm assuming that if I > have two lists for each polynomial, I could do the operations > required. Based on the polynomials I have, the lists of coefficients > would look like (L1) [2,1,3,2] and (L2)[1,0,1] and my lists of exponents > would look like (L 3) [3,2,1,0] and (L 4)[2,1,0]. I would then have the > first element in L1 times each element in L2, so that I get list > 5 [2,0,2]</DIV> > <DIV>and 1st element in L3 + each element in L4, so that I get list 6 > [5,4,3]. Then I would have the 2nd element in L1 times each element in > L2 so that I get another list [1,0,1] and also have the 2nd element in L3 + > each element in L4, so that I get [4,3,2]. This would go on for each > element and I would end up with 4 more lists [3,0,3], [3,2,1], [2,0,2], > [2,1,0]. I would then take the numbers from my lists and have the > computer write the coefficients along with the exponents: 2x^5 + 0x^4 > + 2x^3 + x^4 +0x^3+x^2+3x^3+0x^2 +3x+ 2x^2+0x+2. I would > then have to get rid of those terms with zero coefficients and combine like > terms. Is this crazy or what? Make one function that adds two functions, by adding together their coefficients. Then you can have the multiplication function generate the polynomials that have to be added together. > How could I accomplish this? > Like I told you before, this is all new to me, but I'm really interested in > finding out how this complex task can be accomplished in Python. Can > you help?</DIV> I'm going to explain how I would do this with OO (Object Oriented) programming. You see, a polynomial here is a bit of data, with a nontrivial representation (like your lists, but there may be other ways), and a bunch of related functions (for adding them together, evaluating them, printing them as a string, and so on). This kind of "rich data" usually means that making an object is a good idea. This is the first version: class Polynomial: def __init__(self, coefficients): self.coefficients = coefficients def degree(self): return len(self.coefficients)-1 def coefficient(self, n): # n is the degree of the term of which we need the coefficient # it has to be an integer >= 0 if (type(n) != type(1)) or n < 0: raise ValueError, "n has to be an integer >= 0" if n >= len(self.coefficients): # All coefficients greater than the ones in the list are 0 return 0 else: return self.coefficients[n] That's a simple first version. You could use it like this (suppose it is in a file polynomial.py): >>> import polynomial >>> p = polynomial.Polynomial([1,2,3,4]) >>> p.degree() 3 # It's a third degree polynomial >>> p.coefficient(3) 4 # coefficient of x^3 is 4 You'd want to add methods for turning it into a string, evaluating it, adding them together and multiplying: def __str__(self): terms = [] for i in range(len(self.coefficients)): if i == 0: # If i == 0, the term is a constant terms.append(str(self.coefficients[0])) elif i == 1: # If i == 1, it's simply coefficient*x terms.append(str(self.coefficients[0])+"x") else: # Otherwise use the ^ thing terms.append(str(self.coefficients[0])+"x^"+str(i)) terms.reverse() # Customary to list highest degree first return "+".join(terms) # Put '+' between the terms def eval(self, x): result = 0L for i in range(len(self.coefficients)): result += self.coefficients[i]*(x**i) return result def add(self, other): """Return a new polynomial that is the sum of self and other""" # The length of the needed list is the maximum of their two degrees, # plus one. length = max(self.degree(), other.degree()) + 1 # Initialize a list that length result = [0] * length # Fill it with the sums for i in range(len(result)): result[i] = self.coefficient(i) + other.coefficient(i) # Construct new polynomial and return it return Polynomial(result) def multiply_single_term(self, coefficient, degree): # First the simple form of multiplication: by a single term. # If the polynomial is multiplied by, say, 4x^3, we added three # zeroes to the beginning of the list of coefficients, and multiply # the rest by 4. # Construct a new polynomial that is a copy of this one result = Polynomial(self.coefficients[:]) # Add zeroes result.coefficients[0:0] = [0]*degree # Multiply by coefficient for i in range(len(result.coefficients)): result.coefficients *= coefficient return result def multiply(self, other): # Start with a zero polynomial, add to it self multiplied by each # term of other. Return the result. result = Polynomial([]) for term in range(other.degree()+1): result=result.add(self.multiply_single_term(other.coefficient(term), term)) return result Hmm, this has become rather longer than I expected. No time left to explain the details, argh. Ask about whatever is unclear, like what OO is and how to use this.... (of course, nothing tested, as usual) -- Remco Gerlich From juno@gamefire.com Mon Apr 30 00:35:35 2001 From: juno@gamefire.com (juno@gamefire.com) Date: Sun, 29 Apr 2001 16:35:35 -0700 Subject: [Tutor] Help with saving data Message-ID: <DEEGIKBPAICAIOPICOHKIECNCBAA.juno@gamefire.com> Hello, Can someone tell me the best way to save an object to disk? It the object uses a list of dictionaries for storing its data. Thanks, Juno PS. Andrew, your email helped, thx! From jaime@hilcos01.hilconet.com Mon Apr 30 00:36:28 2001 From: jaime@hilcos01.hilconet.com (JAIME'S MAIL) Date: Sun, 29 Apr 2001 18:36:28 -0500 Subject: [Tutor] 15 puzzle Message-ID: <000901c0d105$37f63d60$38178440@oemcomputer> I would like to make a program for the 15-puzzle in python language. I have this program for it, but it is in another language. Could you help me translate it to python? import java.applet.*; import java.awt.*; //-------------------------------------------------------------------------- public class fifteen extends Applet { private SevenSegmentDigit[] display = new SevenSegmentDigit[3]; private Button[] Buttons = new Button[16]; //This array is an actuall playfield. private Button shuffleBtn = new Button ("&Shuffle"); private int score=0; private int shuffling=0; private Font f; /*---------------------------------------------------------------*/ public String getAppletInfo() //Do I need this function? { return "Name: fifteen\r\n" + "Author: Eugene\r\n" + "Created with Microsoft Visual J++ Version 1.0"; } /*---------------------------------------------------------------*/ public void init() { int i=0; String str=new String(); resize(200, 300); setLayout(null); //Why do they bother so hard with layouts? setBackground(Color.black); for(i=0; i3) moveBtn(empty-4); return true; case Event.LEFT: if(empty % 4 !=3) moveBtn(empty+1); return true; case Event.RIGHT: if(empty % 4 != 0) moveBtn(empty-1); return true; case 's': case 'S': shuffle(); return true; } return false; } /*---------------------------------------------------------------*/ public boolean action(Event evt, Object what) { int i=0; for(i=0;i _____________________________________________________________ I would appreciate any help! Maritza From rob@jam.rr.com Mon Apr 30 00:30:25 2001 From: rob@jam.rr.com (rob@jam.rr.com) Date: Sun, 29 Apr 2001 18:30:25 -0500 Subject: [Tutor] Help with saving data References: <DEEGIKBPAICAIOPICOHKIECNCBAA.juno@gamefire.com> Message-ID: <3AECA411.A16AE528@jam.rr.com> If I understand your question correctly, you might want to look into the pickle module. Rob juno@gamefire.com wrote: > > Hello, > Can someone tell me the best way to save an object to disk? It the object > uses a list of dictionaries for storing its data. > > Thanks, > > Juno > > PS. Andrew, your email helped, thx! > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Useless Python! If your Python is this useless, we need you. http://www.lowerstandard.com/python/pythonsource.html From dyoo@hkn.eecs.berkeley.edu Mon Apr 30 05:43:28 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Sun, 29 Apr 2001 21:43:28 -0700 (PDT) Subject: [Tutor] 15 puzzle In-Reply-To: <000901c0d105$37f63d60$38178440@oemcomputer> Message-ID: <Pine.LNX.4.21.0104292103170.9111-100000@hkn.eecs.berkeley.edu> On Sun, 29 Apr 2001, JAIME'S MAIL wrote: > I would like to make a program for the 15-puzzle in python language. > I have this program for it, but it is in another language. Could you > help me translate it to python? Almost all of the code included in the message deals with GUI stuff: building buttons and displaying the game as a window. As much as it pains me to say this, I'd recommend not using this as a base for your own code for now, because Java's model for doing GUI's is a bit different from Python. (We can help you to write a graphical program later on with the Tkinter module a little later though.) Can you try writing a program that does the 15-puzzle in plain text? It might sound a little less exciting than graphics, but it's easier to work with, and with some imagination, it's still a fun problem. Once we have something that, at the heart of it, represents the 15-puzzle, we should be able to slap a nice GUI on top of that. It looks like the author of the code uses an array of length 16 to represent a particular "state" or situation of the board. This sounds like a nice idea. Try to work on getting the 15-puzzle working as a text game first, and we can help convert it to something that uses the gui stuff. If you're getting really stuck on starting, I've typed up a small skeleton framework that might be useful for you; you don't need to use it though.: [spoiler space ahead] ### winning_board = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '.'] def printBoard(board): for i in range(0, 16, 4): print board[i:i+4] def moveHole(board, direction): # Fix me! Nowhere near done yet. if direction == 'up': pass elif direction == 'down': pass elif direction == 'left' : pass elif direction == 'right' : pass def didWeWin(board): if board == winning_board: return 1 else: return 0 def playGame(): # let's start it off with some board. board = ['2', '1', '3', '4', '1', '.', '7', '8', '5', '10', '11', '12', '9', '13', '14', '15'] while not didWeWin(board): pass # Fix me! We should probably add stuff to ask # the user where to move, and modify our board # accordingly. Also, it might be nice to show # what the board looks like as we play the # game. if __name__ == '__main__': playGame() ### Good luck to you! From toodles@yifan.net Mon Apr 30 10:32:14 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Mon, 30 Apr 2001 17:32:14 +0800 Subject: [Tutor] Help with saving data In-Reply-To: <DEEGIKBPAICAIOPICOHKIECNCBAA.juno@gamefire.com> Message-ID: <FPEHJJPEEOIPMAHOADBKGECECDAA.toodles@yifan.net> Using pickle (or cPickle for an improvement in speed) should be sufficient. example: import cPickle my_dict={'example':'123'} #dictionary for saving file_path='c:\\file.tmp' file=open(file_path,'w') #open the file for reading cPickle.dump(my_dict,file) #save to file file.close() file=open(file_path) #open for reading cPickle.dump(my_dict,file) #read from file file.close() The pickle module also supports other types, as well as user defined classes. I don't know a lot about the module, I've only just started using it...I'm about part way through making a MUD system...I'll put it up on Useless once I'm done...sound good Rob? =) > PS. Andrew, your email helped, thx! No worries, that's what I'm here for...apart from lurking of course heh heh Andrew > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From toodles@yifan.net Mon Apr 30 11:12:42 2001 From: toodles@yifan.net (Andrew Wilkins) Date: Mon, 30 Apr 2001 18:12:42 +0800 Subject: [Tutor] Help with saving data In-Reply-To: <FPEHJJPEEOIPMAHOADBKGECECDAA.toodles@yifan.net> Message-ID: <FPEHJJPEEOIPMAHOADBKOECECDAA.toodles@yifan.net> in the loading bit it's meant to be cPickle.load() not cPickle.dump() sorry for that...ahh the perils of cut and paste =) Andrew > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > Andrew Wilkins > Sent: Monday, 30 April 2001 5:32 PM > To: tutor@python.org > Subject: RE: [Tutor] Help with saving data > > > Using pickle (or cPickle for an improvement in speed) should be > sufficient. > > example: > > import cPickle > > my_dict={'example':'123'} #dictionary for saving > file_path='c:\\file.tmp' > > file=open(file_path,'w') #open the file for reading > cPickle.dump(my_dict,file) #save to file > file.close() > > file=open(file_path) #open for reading > cPickle.dump(my_dict,file) #read from file > file.close() > > The pickle module also supports other types, as well as user defined > classes. I don't know a lot about the module, I've only just started using > it...I'm about part way through making a MUD system...I'll put it up on > Useless once I'm done...sound good Rob? =) > > > PS. Andrew, your email helped, thx! > > No worries, that's what I'm here for...apart from lurking of > course heh heh > > Andrew > > > > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > From alan.gauld@bt.com Mon Apr 30 15:28:40 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 30 Apr 2001 15:28:40 +0100 Subject: [Tutor] 15 puzzle Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D726@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0D181.DA0A2C20 Content-type: text/plain; charset="iso-8859-1" This may well have been answered already - I'm catching up from a week's vacation... Here is a skeleton for a 3x3 game and lacks any input validation - ie it's easily broken but it should form a basis for something... Alan G class Grid: grid = [(0,1),(1,2),(2,5), (3,3),(4,7),(5,6), (6,0),(7,4),(8,8)] def findBlock(self,val): for item in self.grid: if item[1] == val: return item def printIt(self): for i in self.grid: if (i[0]+1)%3 != 0: print i[1], else: print i[1] def isSorted(self): for i in range(7): if self.grid[i][1] > self.grid[i+1][1]: return 0 return 1 def swap(self,pos): gap = self.findBlock(0) self.grid[gap[0]] = (gap[0],pos[1]) self.grid[pos[0]] = (pos[0],0) g = Grid() g.printIt() while not g.isSorted(): block = input("Item to move?") item = g.findBlock(block) g.swap(item) g.printIt() if g.isSorted(): print "Game over" break ------_=_NextPart_001_01C0D181.DA0A2C20 Content-type: text/html; charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META content="MSHTML 5.00.3013.2600" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001>This may well have been answered already - I'm catching up from a week's vacation...</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001>Here is a skeleton for a 3x3 game and lacks any input validation </SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001>- ie it's easily broken but it should form a basis for something...</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001>Alan G</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001><BR>class Grid:<BR> grid = [(0,1),(1,2),(2,5),<BR> (3,3),(4,7),(5,6),<BR> (6,0),(7,4),(8,8)]</SPAN></FONT></DIV> <DIV> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001> def findBlock(self,val):<BR> for item in self.grid:<BR> if item[1] == val:<BR> return item<BR> <BR> def printIt(self):<BR> for i in self.grid:<BR> if (i[0]+1)%3 != 0:<BR> print i[1],<BR> else: print i[1]</SPAN></FONT></DIV> <DIV> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001> def isSorted(self):<BR> for i in range(7):<BR> if self.grid[i][1] > self.grid[i+1][1]:<BR> return 0<BR> return 1</SPAN></FONT></DIV> <DIV> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001> def swap(self,pos):<BR> gap = self.findBlock(0)<BR> self.grid[gap[0]] = (gap[0],pos[1])<BR> self.grid[pos[0]] = (pos[0],0) <BR> <BR>g = Grid()<BR>g.printIt()<BR>while not g.isSorted():<BR> block = input("Item to move?")<BR> item = g.findBlock(block)<BR> g.swap(item)<BR> g.printIt()<BR> if g.isSorted():<BR> print "Game over"<BR> break<BR></SPAN></FONT></DIV></BODY></HTML> ------_=_NextPart_001_01C0D181.DA0A2C20-- From alan.gauld@bt.com Mon Apr 30 16:18:31 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 30 Apr 2001 16:18:31 +0100 Subject: [Tutor] Multiplication of polynomials Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D727@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0D188.D0F1F850 Content-type: text/plain; charset="iso-8859-1" how illiterate I am at computer programming, this is what I would do: I Pretty much correct. But instead of using lists try using dictionaries. Thus the dictionary vcan be keyed by the order of the polynomial and you can assign the coefficients to the value part. This makes rationalising the final expression a bit easier IMHO. (In fact you could do it 'on the fly') Alan G. ------_=_NextPart_001_01C0D188.D0F1F850 Content-type: text/html; charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META content="MSHTML 5.00.3013.2600" name=GENERATOR></HEAD> <BODY> <BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"> <DIV>how illiterate I am at computer programming, this is what I would do: I <SPAN class=010332215-30042001><FONT color=#0000ff face=Arial size=2> </FONT></SPAN></DIV> <DIV><SPAN class=010332215-30042001></SPAN> </DIV></BLOCKQUOTE> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001>Pretty much correct.</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001>But instead of using lists try using dictionaries.</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001>Thus the dictionary vcan be keyed by the order of </SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001>the polynomial and you can assign the coefficients to the </SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001>value part. This makes rationalising the final expression </SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001>a bit easier IMHO. (In fact you could do it 'on the fly')</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=010332215-30042001>Alan G.</SPAN></FONT></DIV> <BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"> <P></P></BLOCKQUOTE></BODY></HTML> ------_=_NextPart_001_01C0D188.D0F1F850-- From kromag@nsacom.net Mon Apr 30 18:40:38 2001 From: kromag@nsacom.net (kromag@nsacom.net) Date: Mon, 30 Apr 2001 10:40:38 -0700 (PDT) Subject: [Tutor] Displaying image in scrolled canvas Message-ID: <200104301740.f3UHec821609@pop.nsacom.net> I am attempting to place a large .gif file into a scrolled canvas. I am working from the examples in programming python (in case the code looked slightly familiar :-) To wit: from Tkinter import * class ScrolledCanvas(Frame): def __init__(self, parent=None, color='white'): Frame.__init__(self, parent) self.pack(expand=YES, fill=BOTH) photo=PhotoImage(file='\windows\desktop\wacky3.gif') canv = Canvas(self, bg=color, relief=SUNKEN) canv.config(width=1010, height=745) canv.config(scrollregion=(0,0,300, 1000)) canv.create_image(10,10, image=photo, anchor=NW) sbar = Scrollbar(self) sbar.config(command=canv.yview) canv.config(yscrollcommand=sbar.set) sbar.pack(side=RIGHT, fill=Y) canv.pack(side=LEFT, expand=YES, fill=BOTH) if __name__ == '__main__': ScrolledCanvas().mainloop() results in the properly-sized frame and scrollbar, but for some reason the image does not pop to life. What am I missing here? d From alan.gauld@bt.com Mon Apr 30 17:13:24 2001 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 30 Apr 2001 17:13:24 +0100 Subject: [Tutor] 15 puzzle Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D72A@mbtlipnt02.btlabs.bt.co.uk> ------_=_NextPart_001_01C0D190.7BB06EF0 Content-type: text/plain; charset="iso-8859-1" This may well have been answered already - I'm catching up from a week's vacation... It appears not yet... Here is a skeleton for a 3x3 game and lacks any input validation - ie it's easily broken but it should form a basis for something... Here it is in full 4x4 size with minimal error detection... class Grid: size = 4 grid = [(0,1),(1,2),(2,5),(3,9), (4,3),(5,7),(6,6),(7,10), (8,0),(9,4),(10,8),(11,11), (12,15),(13,14),(14,13),(15,12) ] def findBlock(self,val): if val in range(self.size**2): for item in self.grid: if item[1] == val: return item else: print "invalid item" return self.findBlock(0) def printIt(self): for i in self.grid: if (i[0]+1)%self.size != 0: print i[1], else: print i[1] def isSorted(self): limit = (self.size**2)-2 for i in range(limit): if (self.grid[i+1][1] - self.grid[i][1]) != 1: return 0 return 1 def swap(self,pos): gap = self.findBlock(0) self.grid[gap[0]] = (gap[0],pos[1]) self.grid[pos[0]] = (pos[0],0) g = Grid() g.printIt() while not g.isSorted(): block = input("Item to move?") item = g.findBlock(block) g.swap(item) g.printIt() if g.isSorted(): print "Game over" break ------_=_NextPart_001_01C0D190.7BB06EF0 Content-type: text/html; charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META content="MSHTML 5.00.3013.2600" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001>This may well have been answered already - I'm catching up from a week's vacation...</SPAN></FONT></DIV></BLOCKQUOTE> <DIV><SPAN class=060143314-30042001></SPAN><SPAN class=440511716-30042001><FONT color=#0000ff face=Arial size=2>It appears not yet...</FONT></SPAN> </DIV> <BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001>Here is a skeleton for a 3x3 game and lacks any input validation </SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001>- ie it's easily broken but it should form a basis for something...</SPAN></FONT></DIV></BLOCKQUOTE> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=060143314-30042001></SPAN></FONT> <FONT color=#0000ff face=Arial size=2><SPAN class=440511716-30042001>Here it is in full 4x4 size with minimal error detection...</SPAN></FONT></DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=440511716-30042001></SPAN></FONT> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=440511716-30042001><BR>class Grid:<BR> size = 4<BR> grid = [(0,1),(1,2),(2,5),(3,9),<BR> (4,3),(5,7),(6,6),(7,10),<BR> (8,0),(9,4),(10,8),(11,11),<BR> (12,15),(13,14),(14,13),(15,12)<BR> ]</SPAN></FONT></DIV> <DIV> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=440511716-30042001> def findBlock(self,val):<BR> if val in range(self.size**2):<BR> for item in self.grid:<BR> if item[1] == val:<BR> return item<BR> else:<BR> print "invalid item"<BR> return self.findBlock(0)<BR> <BR> def printIt(self):<BR> for i in self.grid:<BR> if (i[0]+1)%self.size != 0:<BR> print i[1],<BR> else: print i[1]</SPAN></FONT></DIV> <DIV> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=440511716-30042001> def isSorted(self):<BR> limit = (self.size**2)-2<BR> for i in range(limit):<BR> if (self.grid[i+1][1] - self.grid[i][1]) != 1:<BR> return 0<BR> return 1</SPAN></FONT></DIV> <DIV> </DIV> <DIV><FONT color=#0000ff face=Arial size=2><SPAN class=440511716-30042001> def swap(self,pos):<BR> gap = self.findBlock(0)<BR> self.grid[gap[0]] = (gap[0],pos[1])<BR> self.grid[pos[0]] = (pos[0],0) <BR> <BR>g = Grid()<BR>g.printIt()<BR>while not g.isSorted():<BR> block = input("Item to move?")<BR> item = g.findBlock(block)<BR> g.swap(item)<BR> g.printIt()<BR> if g.isSorted():<BR> print "Game over"<BR> break<BR></SPAN></FONT></DIV></BODY></HTML> ------_=_NextPart_001_01C0D190.7BB06EF0-- From dyoo@hkn.eecs.berkeley.edu Mon Apr 30 22:41:05 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 30 Apr 2001 14:41:05 -0700 (PDT) Subject: [Tutor] Displaying image in scrolled canvas [PhotoImage weirdness] In-Reply-To: <200104301740.f3UHec821609@pop.nsacom.net> Message-ID: <Pine.LNX.4.21.0104301434400.26119-100000@hkn.eecs.berkeley.edu> On Mon, 30 Apr 2001 kromag@nsacom.net wrote: > I am attempting to place a large .gif file into a scrolled canvas. I am > working from the examples in programming python (in case the code looked > slightly familiar :-) > > To wit: > > from Tkinter import * > class ScrolledCanvas(Frame): > def __init__(self, parent=None, color='white'): > Frame.__init__(self, parent) > self.pack(expand=YES, fill=BOTH) > photo=PhotoImage(file='\windows\desktop\wacky3.gif') > canv = Canvas(self, bg=color, relief=SUNKEN) > canv.config(width=1010, height=745) > canv.config(scrollregion=(0,0,300, 1000)) > canv.create_image(10,10, image=photo, anchor=NW) > sbar = Scrollbar(self) > sbar.config(command=canv.yview) > canv.config(yscrollcommand=sbar.set) > sbar.pack(side=RIGHT, fill=Y) > canv.pack(side=LEFT, expand=YES, fill=BOTH) > if __name__ == '__main__': ScrolledCanvas().mainloop() > > results in the properly-sized frame and scrollbar, but for some reason the > image does not pop to life. What am I missing here? The same question popped up last year too! http://mail.python.org/pipermail/tutor/2000-February/001002.html You're right; it's not popping up. For the life of me, I have no idea why this isn't working. What's weird is that: ### root = Tk() photo = PhotoImage(file="test.gif") canv = Canvas(root) canv.pack() canv.create_image(0, 0, image=photo, anchor=NW) mainloop() ### works, but: ### class MyFrame(Frame): def __init__(self, root): Frame.__init__(self, root) photo = PhotoImage(file="test.gif") canvas = Canvas(self) canvas.pack() canvas.create_image(0, 0, image=photo, anchor=NW) root = Tk() f = MyFrame(root) f.pack() mainloop() ### doesn't! I'm looking into this right now; in the meantime, has anyone else run into the same thing? From dyoo@hkn.eecs.berkeley.edu Mon Apr 30 23:04:31 2001 From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 30 Apr 2001 15:04:31 -0700 (PDT) Subject: [Tutor] Breaking threads In-Reply-To: <200104302306.f3UN6r802577@pop.nsacom.net> Message-ID: <Pine.LNX.4.21.0104301452300.29377-100000@hkn.eecs.berkeley.edu> On Mon, 30 Apr 2001 kromag@nsacom.net wrote: > I am working my way through "Programming Python" from the begining (I have > asked too many silly questions! :-). Here is a non-silly question: No problem. > import thread, time > > glarf=open('\windows\desktop\goat.txt', 'w') > > def counter(myId, count): > for i in range(count): > mutex.acquire() > # time.sleep(1) > glarf.write('[%s]=> %s' % (myId, i)) > mutex.release() > > mutex = thread.allocate_lock() > for i in range(10000): > thread.start_new_thread(counter, (i, 3)) > It starts to write 10,000 counts to goat.txt, then dies with the following: > > > Traceback (most recent call last): > File "cornfedbeef.py", line 14, in ? > thread.start_new_thread(counter, (i, 3)) > thread.error: can't start new thread > > It works fine in iterations of 10, 100 and 1000. Why does it puke at the > 10000 mark? Python's thread support is based on what the system underneath provides us. Unfortunately, not all platforms support a threaded model well. What probably happened was that the system got flooded by too many threads. Many systems have a hard time supporting even 1000 threads. According to one group: "It has been our experience that in real world use, Windows NT is incapable of running more than 1000 simultaneous threads at a time" http://www.lyris.com/about/company/whitepapers/lm_extreme/secondgen.html On the Linux side, the story is even more grim: you're limited to 256 threads at a time: http://pauillac.inria.fr/~xleroy/linuxthreads/faq.html So this is something that will probably need to be fixed. At the moment though, try to avoid writing programs that abuse the threading system. *grin* From wildchild07770@yahoo.com Mon Apr 30 21:54:42 2001 From: wildchild07770@yahoo.com (Aaron) Date: Mon, 30 Apr 2001 15:54:42 -0500 Subject: [Tutor] Program not accessing while loops Message-ID: <OE433mPqsoWGaaDi3dQ00004c17@hotmail.com> This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C0D18D.DEF0F0A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I wrote this out last night on a different computer and I had the = script running fine but now that I rewrote it doesn't seem to be = accesing the second group of while loops, the main menu will load and = keep running and asking for input, but it won't call on the loop. #character managment program totop =3D 1 while totop =3D=3D 1: print print "Main Menu" print "---------" print mainmenu =3D ["1 for to create a new character", "2 to manage an = existing character", "3 to exit the program"] for x in mainmenu: print "Enter", x mainmen =3D raw_input(">") while mainmen =3D=3D 1: print "This function is under construction" while mainmen =3D=3D 2: print "This function is under construction" while mainmen =3D=3D 3: exit =3D raw_input("are you sure? ") if exit =3D=3D r"yes": totop =3D=3D 2 break elif exit =3D=3D r"no": totop =3D=3D 1 break while mainmen < 3: print "Invalid choice, choose again" for x in mainmenu: print "Enter", x mainmen =3D raw_input(">") Thanks, aaron ------=_NextPart_000_0007_01C0D18D.DEF0F0A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi, I wrote this out last night on = a different=20 computer and I had the script running fine but now that I rewrote = it=20 doesn't seem to be accesing the second group of while loops, the main = menu will=20 load and keep running and asking for input, but it won't call on the=20 loop.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>#character managment program<BR>totop = =3D 1<BR>while=20 totop =3D=3D 1:<BR> print<BR> print = "Main=20 Menu"<BR> print "---------"<BR> =20 print<BR> mainmenu =3D ["1 for to create a new = character", "2 to=20 manage an existing character", "3 to exit the = program"]<BR> =20 for x in mainmenu:<BR> print = "Enter",=20 x<BR> mainmen =3D = raw_input(">")<BR> while=20 mainmen =3D=3D 1:<BR> print = "This function=20 is under construction"<BR> while mainmen =3D=3D=20 2:<BR> print "This function is = under=20 construction"<BR> while mainmen =3D=3D=20 3:<BR> exit =3D raw_input("are = you sure?=20 ")<BR> if exit =3D=3D=20 r"yes":<BR> &n= bsp;=20 totop =3D=3D = 2<BR> =20 break<BR> elif exit =3D=3D=20 r"no":<BR> &nb= sp;=20 totop =3D=3D = 1<BR> =20 break<BR> while mainmen <=20 3:<BR> print "Invalid choice, = choose=20 again"<BR> for x in=20 mainmenu:<BR> = =20 print "Enter", x<BR> mainmen = =3D=20 raw_input(">")</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Thanks, = aaron</FONT></DIV></BODY></HTML> ------=_NextPart_000_0007_01C0D18D.DEF0F0A0--