From Moshe Zadka Fri Oct 1 06:24:37 1999 From: Moshe Zadka (Moshe Zadka) Date: Fri, 1 Oct 1999 07:24:37 +0200 (IST) Subject: [Tutor] Ok, take one step back and let you look In-Reply-To: <199909302044.QAA22017@northshore.shore.net> Message-ID: On Thu, 30 Sep 1999, Michael P. Reilly wrote: > >>> classify = {} > >>> for item in inventory: > ... key = item.__class__ > ... if classify.has_key(key): > ... classify[key] = classify[key] + 1 > ... else: > ... classify[key] = 1 But a better idiom, both in clarity and efficiency, would be to simulate Perl's hash semantics and use .get: classify={} for item in inventory: classify[item.__class__]=classify.get(item.__class__, 0) -- Moshe Zadka . INTERNET: Learn what you know. Share what you don't. From Moshe Zadka Fri Oct 1 09:59:50 1999 From: Moshe Zadka (Moshe Zadka) Date: Fri, 1 Oct 1999 10:59:50 +0200 (IST) Subject: [Tutor] Ok, take one step back and let you look In-Reply-To: Message-ID: On Fri, 1 Oct 1999, Moshe Zadka wrote: > On Thu, 30 Sep 1999, Michael P. Reilly wrote: > > > >>> classify = {} > > >>> for item in inventory: > > ... key = item.__class__ > > ... if classify.has_key(key): > > ... classify[key] = classify[key] + 1 > > ... else: > > ... classify[key] = 1 > > But a better idiom, both in clarity and efficiency, would be to simulate > Perl's hash semantics and use .get: > > classify={} > for item in inventory: > classify[item.__class__]=classify.get(item.__class__, 0) Sorry for the typo. There should be a +1 at the end of the last line. -- Moshe Zadka . INTERNET: Learn what you know. Share what you don't. From DanRey23@aol.com Sat Oct 2 01:58:41 1999 From: DanRey23@aol.com (DanRey23@aol.com) Date: Fri, 1 Oct 1999 20:58:41 EDT Subject: [Tutor] (no subject) Message-ID: I am eager to learn how to program......I heard Python was the best beginner's language. How can i get started when have no history in programing? I don't know any other language.....the assumed knowledge Python covers is unkown to me.... pls help....thanx.. From zarie@ucc.gu.uwa.edu.au Sat Oct 2 02:42:01 1999 From: zarie@ucc.gu.uwa.edu.au (Tracey Brown) Date: Sat, 2 Oct 1999 09:42:01 +0800 (WST) Subject: [Tutor] (no subject) In-Reply-To: Message-ID: On Fri, 1 Oct 1999 DanRey23@aol.com wrote: > I am eager to learn how to program......I heard Python was the best > beginner's language. How can i get started when have no history in > programing? I don't know any other language.....the assumed knowledge Python > covers is unkown to me.... Assumed knowledge? Where've you been looking? I would suggest the python tutorial, which can be found on the python website.. www.python.org/doc/current/tut/tut.html I, myself don't have much prior knowledge of programming, but I didn't find it very hard to work out what was going on.. It probably also helps if you know other ppl that can program in python, and then you can ask them what might seem to be stupid questions :) Likewise, I guess that's what this list is for :P Goodluck :P Blessed Be, Tracey > pls help....thanx.. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor > @}-->--- "Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen an angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had." -- Linus Torvalds ---<--{@ From warren@nightwares.com Sat Oct 2 02:59:54 1999 From: warren@nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Fri, 01 Oct 1999 20:59:54 -0500 Subject: [Tutor] (no subject) References: Message-ID: <37F5671A.2794D0B7@nightwares.com> DanRey23@aol.com wrote: > I am eager to learn how to program......I heard Python was the best > beginner's language. You heard correctly. I am new to Python myself, but I know what you mean. To grasp and hold the power of programming can be a wonderful, but frustrating, dream. I'm pretty much a guru with Director, a commercial and for-profit product made by Macromedia, and most of my domain is involved in working with it. If you surfed there you would find a 20-odd step tutorial in Director, which would at least get you started with it. I mention this specifically because Director's script, Lingo, is very similar to Python in many ways. And you can get a save-disabled version of it from Macromedia, which could at least let you practice. However for saved projects I would recommend you look into MetaCard, http://www.metacard.com/ , which gives you a *fully functional* version of their high-level language for *free* -- you pay only if you distribute your files. I mention Director and MetaCard specifically because I suspect you want to be able to make graphical programs fairly easily, as well as learn how to write programs in general, and either one of these tools does this for you very well, whereas attaching a GUI to Python takes a bit more work than perhaps you want to undertake at this point. (FWIW, I'm in the beginning stages of putting together a py/tcl/tk based IDE like Director, something similar to impress, but with more lowlevel coding, animation control and such -- in fact I moved to py and its ancillary modules partly out of frustration with Director, which is arguably a wonderful tool but still limited since it is not opensource.) Beside that, though, I can possibly help you with general concepts and so on. Not really all Python, but the idea of how to actually *do* a program as a meta-concept. (Before I started working for a commercial company, I wrote educational software for about 5 years.) Feel free to write me personally on this, and of course to surf my pages. Welcome, fellow traveller, to the world of programming. Once you are in, you'll *never* want to go back. :) Oh. A good start is the O'Reilly publication _Programming Python_. Hit amazon to get a copy. I very strongly recommend it. It gets thick in some places but it is a hell of an introduction to programming in general, not just with Python. And it comes with a CD full of files. Very nicely done overall. -- warren ockrassa | nightwares | mailto:warren@nightwares.com -- n i g h t w a r e s -- director faq lingo tutorial free files links http://www.nightwares.com/ From spiderman@nasachem.com Sat Oct 2 16:07:04 1999 From: spiderman@nasachem.com (R Parker) Date: Sat, 02 Oct 1999 10:07:04 -0500 Subject: [Tutor] FOR loops Message-ID: <37F61F98.A93795CA@ghg.net> Hello, I am a beginner at python and have been learning it from the O'reilly book 'Learning Python' it has been pretty easy to understand for someone who has never programmed before, but it stumps me sometimes.......Thats where this message comes in, I got to the part that introduces FOR loops the book doesn't explain the concept very well and I don't understand how to use FOR loops in my programs.Could anyone explain what FOR loops do and how to implement them in my programming?? I would really appreciate it. From cwebster@nevada.edu Sat Oct 2 17:12:40 1999 From: cwebster@nevada.edu (Corran Webster) Date: Sat, 2 Oct 1999 09:12:40 -0700 (PDT) Subject: [Tutor] FOR loops In-Reply-To: <37F61F98.A93795CA@ghg.net> Message-ID: > Hello, I am a beginner at python and have been learning it from the > O'reilly book 'Learning Python' > it has been pretty easy to understand for someone who has never > programmed before, but it stumps me sometimes....... I think it is fair to say that "Learning Python" is aimed more at people who already know some programming but don't know any python than at absolute beginners. Which doesn't mean that you won't learn a great deal from it, but be prepared for other stumbling blocks along the way. It would be very nice to have a "Learning Programming with Python" type of book given that python is a very good language for beginners. > Thats where this > message comes in, I got to the part that introduces FOR loops > the book doesn't explain the concept very well and I don't understand > how to use FOR loops in my programs.Could anyone explain what FOR loops > do and how to implement them in my programming?? I would really > appreciate it. The one-line summary: a for loop takes the elements of a list, one at a time, and does something with them. For example: mylist = ["Bruce", "Sheila", "Kevin"] for person in mylist: print person will go through the list of names, and print each out. It will produce the output Bruce Sheila Kevin The variable "person" first takes the value "Bruce" and prints it out; then the loop goes back and gives it the value "Sheila" and prints it out; and finally it gives it the value "Kevin" and prints it out. It is very common in practise to have a list which you want to do something to each element - for example, doing something with each line in a file you have read; or doing something to each item in some list of data. Another common use of the for loop is to do something with a range of numbers using the range function: for i in range(10): print i, i*i This will print a list of numbers and their squares from 0 through to 9, inclusive. If you want from 1 to 10, you would need to use range(1,11) instead. Here the range(10) function returns the list [0,1,2,3,4,5,6,7,8,9]; the the for loop goes through and assigns each element of the list to i sequentially - first 0, than 1, then 2, and so on up to 9. For each value of i, the print statement prints out i and it's square (i*i). Also sometimes you just want to do something repeatedly. In this case you can use a range, but ignore the variable - for example: times = 10 for i in range(times): print "This will print", times, "times" Notice that i is not referred to inside the for loop; this will simply print out the same thing over and over a grand total of 10 times. Some more examples for you to think about: age = {'Bruce": 43, "Sheila": 32, "Kevin": 8} for person in age.keys(): print person, "is", age[person], "years old" names = {"Bruce", "Sheila", "Kevin"] for name in names: if name == "Bruce": print "Bruce is in the list!" Hope this sheds some light. Regards, Corran From eroubinc@u.washington.edu Sat Oct 2 17:29:19 1999 From: eroubinc@u.washington.edu (Evgeny Roubinchtein) Date: Sat, 2 Oct 1999 09:29:19 -0700 (PDT) Subject: [Tutor] FOR loops In-Reply-To: <37F61F98.A93795CA@ghg.net> Message-ID: On Sat, 2 Oct 1999, R Parker wrote: [...snip...] >message comes in, I got to the part that introduces FOR loops >the book doesn't explain the concept very well and I don't understand >how to use FOR loops in my programs.Could anyone explain what FOR loops >do and how to implement them in my programming?? I would really [...snip...] I'll give this a shot, and if I mess up somewhere, other people will (hopefully) correct me. You typically use for-loops when you have a list (or a tuple) of things and you want to do something to each element of the list. For example: >>> friends = ('Jack', 'Jill', 'John') >>> for friend in friends: ... print 'Hello,', friend ... Hello, Jack Hello, Jill Hello, John I have a difficult time thinking of an example you must have for-loops or else you cannot say what you wish to say. I could have written the example above with a while-loop, for instance like this: >>> friends = ('Jack', 'Jill', 'John') >>> i = 0 >>> while i < len(friends): ... print 'Hello,', friends[i] ... i = i + 1 ... Hello, Jack Hello, Jill Hello, John In the example above, I made a list explicitely, but it is probably more common to let Python make the list for me. For instance, if I have a shopping list like this: shopping_list = {'ham' : 2.25, 'eggs' : 1.50, 'milk' : 1.75} ,I could figure out the total like so: >>> total = 0 >>> for thing in shopping_list.keys(): ... total = total + shopping_list[thing] ... >>> print total 5.5 Here I am letting Python make the list of items for me by saying shopping_list.keys() first, and then I get the price for each thing on my list, and sum the prices up. Here's what shopping_list.keys() does: >>> shopping_list.keys() ['milk', 'eggs', 'ham'] Again, I don't _really_ need a for-loop here, I could have used a while-loop, for example like so: >>> i = 0 >>> total = 0 >>> k = shopping_list.keys() >>> while i < len(k): ... total = total + shopping_list[ k[i] ] ... i = i + 1 ... >>> print total 5.5 (but using for-loop is more convenient, since I have to say less to achieve the same result). It is very common to want to do something to a list of integers, and since you probably don't want to write out a list of integers from 1 to 1000 by hand every time you want to use one, Python provides a function called range() that makes the list for you Here is a way to do factorial of 5: >>> fact = 1 >>> for i in range(2, 6): ... fact = fact * i ... >>> print fact 120 You can see that you could do the same thing with a while-loop. (How?) What follows probably will make more sense after you have read about exceptions (I think they are in Ch 7). Here's another way to re-write my first example with a while-loop, that is, as I understand it, closer in spirit to what Python "actually does" >>> friends = ('Jack', 'Jill', 'John') >>> i = 0 >>> try: ... while 1: ... friend = friends[i] ... print 'Hello,', friend ... i = i + 1 ... except IndexError: ... pass ... Hello, Jack Hello, Jill Hello, John -- Evgeny Roubinchtein, eroubinc@u.washington.edu ................... Unprecedented performance: Nothing ever ran this slow before. From deirdre@deirdre.net Sat Oct 2 19:07:07 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sat, 2 Oct 1999 11:07:07 -0700 (PDT) Subject: [Tutor] FOR loops In-Reply-To: <37F61F98.A93795CA@ghg.net> Message-ID: On Sat, 2 Oct 1999, R Parker wrote: > Hello, I am a beginner at python and have been learning it from the > O'reilly book 'Learning Python' > it has been pretty easy to understand for someone who has never > programmed before, but it stumps me sometimes.......Thats where this > message comes in, I got to the part that introduces FOR loops > the book doesn't explain the concept very well and I don't understand > how to use FOR loops in my programs.Could anyone explain what FOR loops > do and how to implement them in my programming?? I would really > appreciate it. When you want to do a for loop, you have to have a range of numbers for which you want to execute the loop. If you wanted to do it ten times, a common way of doing it would be: for i in range (0,10): print i If you wanted to do it for several arbitrary numbers, you could also do it without a range parameter: for i in [6,12,18,24]: print i (the range can also be enclosed in parentheses rather than square brackets) You can also be fancier: def fibonacci(endval=50): a = [1, 1] while 1: z = z = a[len(a)-1] + a[len(a)-2] if z < endval: a.append(z) else: break return a for i in fibonacci(50): print i -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "I must say that I was really happy to see _Linux for Dummies_ -- that's when you know you've arrived." -- Linus Torvalds From Emile van Sebille" Message-ID: <025701bf0d03$a132fec0$01ffffc0@direcpc.com> Hello R., For loops provide you a way to apply the same logic to a number of items. For example, to count the number of vowels in a string: >>> test = "this is a test string" >>> count = 0 >>> for letter in test: if letter in 'aeiou': count = count + 1 >>> print count 5 or to add up the first 100 numbers: >>> total = 0 >>> for i in range(100): total = total + i >>> print total 5050 or, more generally: for each in things: do something HTH, Emile van Sebille emile@fenx.com PS: My spell checker objected to count and total where they appear after the '=' above. Any ideas why? My-spell-checker-practices-Heisenberg-ly y'rs - Emile ------------------- ----- Original Message ----- From: R Parker To: Sent: Saturday, October 02, 1999 8:07 AM Subject: [Tutor] FOR loops > Hello, I am a beginner at python and have been learning it from the > O'reilly book 'Learning Python' > it has been pretty easy to understand for someone who has never > programmed before, but it stumps me sometimes.......Thats where this > message comes in, I got to the part that introduces FOR loops > the book doesn't explain the concept very well and I don't understand > how to use FOR loops in my programs.Could anyone explain what FOR loops > do and how to implement them in my programming?? I would really > appreciate it. > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor > > > From parkw@better.net Sun Oct 3 21:10:14 1999 From: parkw@better.net (William Park) Date: Sun, 3 Oct 1999 16:10:14 -0400 Subject: [Tutor] FOR loops In-Reply-To: <37F61F98.A93795CA@ghg.net> References: <37F61F98.A93795CA@ghg.net> Message-ID: <19991003161014.A30296@better.net> On Sat, Oct 02, 1999 at 10:07:04AM -0500, R Parker wrote: > Hello, I am a beginner at python and have been learning it from the > O'reilly book 'Learning Python' > it has been pretty easy to understand for someone who has never > programmed before, but it stumps me sometimes.......Thats where this > message comes in, I got to the part that introduces FOR loops > the book doesn't explain the concept very well and I don't understand > how to use FOR loops in my programs.Could anyone explain what FOR loops > do and how to implement them in my programming?? I would really > appreciate it. FOR-loop goes through each item of a sequence (list, tuple, or string) starting from index=0 until the sequence item is exhausted. For example, for i in ["a", "b", "c"]: print i, i+i will print a aa b bb c cc In the first loop, "a" is assigned to the index variable 'i'; in the second loop, "b" is assigned to 'i'; and, in the third (and last) loop, "c" is assigned to 'i'. For list or tuple, the sequence items are simply the items of list or tuple themselves; but, for string, the sequence items are the characters of the string. Yours truly, William Park From teroc@zianet.com Mon Oct 4 14:17:24 1999 From: teroc@zianet.com (K P) Date: Mon, 4 Oct 1999 08:17:24 -0500 Subject: [Tutor] Quick thank you Message-ID: <13122325057731@zianet.com> Thank you everyone for your input on my 'wonderful' inventory program questions. You've presented me a lot of new, exciting info. I am excited to try these newly seen (from my perspective) toys in my program. Thank you again, Ken From vball@erols.com Mon Oct 4 16:13:37 1999 From: vball@erols.com (Michael Perry) Date: Mon, 04 Oct 1999 11:13:37 -0400 Subject: [Tutor] Print Doc Strings Message-ID: <37F8C420.7541C2C0@erols.com> Hello, I would like to loop through all of the classes of a module and print the __doc__ strings. I've got this >>>import sys >>>for name in dir(sys): ... print name This prints all the names. How can I get to the __doc__ strings? Michael From joe@strout.net Mon Oct 4 16:57:34 1999 From: joe@strout.net (Joseph J. Strout) Date: Mon, 4 Oct 1999 08:57:34 -0700 Subject: [Tutor] Print Doc Strings In-Reply-To: <37F8C420.7541C2C0@erols.com> References: <37F8C420.7541C2C0@erols.com> Message-ID: > >>>for name in dir(sys): >... print name > >This prints all the names. How can I get to the __doc__ strings? for name in dir(sys): item = getattr(sys,name) print item.__doc__ (I haven't tried this, but it should work.) ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From deirdre@deirdre.net Mon Oct 4 22:49:29 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 4 Oct 1999 14:49:29 -0700 (PDT) Subject: [Tutor] A problem, but where? Message-ID: I have a program I'm working on that's a CGI and I've had this problem crop up a few times. Before, I've worked around it but somehow I think I've hit a genuine issue. I'm just not sure if it's me doing something stupid (you know how hard it is to be objective about your own code). The original code can be found at http://www.deirdre.org/ebaycgi.py and the included structures can be found at http://www.deirdre.org/bidStructs.py The problem occurs around line 277: self.parseRecord(form) print self.a.auctionId In the parseRecord method, it prints self.a.auctionId twice. Correctly. It is set the once and never re-set. However, in the calling method, it is NOT set. This is what I get as output: 169763363 169763363 Auction No : Auction Title : Recycled [etc.] The first two lines are the parseRecord method's printing, the blank line is line 278 (not printing), same on the right side of the colon. Any ideas? I'm stumped. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "I must say that I was really happy to see _Linux for Dummies_ -- that's when you know you've arrived." -- Linus Torvalds From deirdre@deirdre.net Mon Oct 4 23:13:27 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 4 Oct 1999 15:13:27 -0700 (PDT) Subject: [Tutor] A problem, but where? In-Reply-To: Message-ID: I forgot to mention. I am *currently* running 1.51 but had the problem with a CVS snapshot that was about a week old. In desperation, I tried last night's snapshot, then regressed to 1.51. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "I must say that I was really happy to see _Linux for Dummies_ -- that's when you know you've arrived." -- Linus Torvalds From arcege@shore.net Tue Oct 5 01:31:18 1999 From: arcege@shore.net (Michael P. Reilly) Date: Mon, 4 Oct 1999 20:31:18 -0400 (EDT) Subject: [Tutor] A problem, but where? In-Reply-To: from Deirdre Saoirse at "Oct 4, 99 02:49:29 pm" Message-ID: <199910050031.UAA05702@northshore.shore.net> > I have a program I'm working on that's a CGI and I've had this problem > crop up a few times. Before, I've worked around it but somehow I think > I've hit a genuine issue. I'm just not sure if it's me doing something > stupid (you know how hard it is to be objective about your own code). > > The original code can be found at http://www.deirdre.org/ebaycgi.py and > the included structures can be found at > http://www.deirdre.org/bidStructs.py > > The problem occurs around line 277: > > self.parseRecord(form) > print self.a.auctionId > > In the parseRecord method, it prints self.a.auctionId twice. Correctly. It > is set the once and never re-set. > > However, in the calling method, it is NOT set. This is what I get as > output: > > 169763363 > 169763363 > > Auction No : > Auction Title : Recycled [etc.] > > The first two lines are the parseRecord method's printing, the blank line > is line 278 (not printing), same on the right side of the colon. What I notice (somewhat) right away is: def parseRecord(self, form): self.initVars() try: a = form["auctionid"] # extract auction number b = a.value self.a.auctionid = string.strip(b) print self.a.auctionid except: pass But lower down you have: self.parseRecord(form) print self.a.auctionId A captitalized "I" is probably the problem. -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From deirdre@deirdre.net Tue Oct 5 01:27:59 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 4 Oct 1999 17:27:59 -0700 (PDT) Subject: [Tutor] A problem, but where? In-Reply-To: <199910050031.UAA05702@northshore.shore.net> Message-ID: On Mon, 4 Oct 1999, Michael P. Reilly wrote: > self.parseRecord(form) > print self.a.auctionId > > A captitalized "I" is probably the problem. Doh! I knew I was probably doing something, but I couldn't see it. Thanks bunches! -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "I must say that I was really happy to see _Linux for Dummies_ -- that's when you know you've arrived." -- Linus Torvalds From mike@virtualblue.org Tue Oct 5 15:49:28 1999 From: mike@virtualblue.org (mike@virtualblue.org) Date: Tue, 05 Oct 1999 10:49:28 -0400 Subject: [Tutor] Print Doc Strings Message-ID: <199910051449.KAA05706@www.virtualblue.org> After trying your loop and then trying to display a __doc__ string it looks like I'm not dealing with void __doc__ strings correctly. $ python Python 1.5.1 (#1, Mar 21 1999, 22:49:36) [GCC egcs-2.91.66 19990314/Li on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> for name in dir(sys): ... item = getattr(sys,name) ... print item.__doc__ ... Traceback (innermost last): File "", line 3, in ? AttributeError: 'None' object has no attribute '__doc__' >>> >>> dir(sys) ['__doc__', '__name__', '__stderr__', '__stdin__', '__stdout__', 'argv', 'builtin_module_names', 'copyright', 'exc_info', 'exc_type', 'exec_prefix', 'executable', 'exit', 'getrefcount', 'last_traceback', 'last_type', 'last_value', 'maxint', 'modules', 'path', 'platform', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setprofile', 'settrace', 'stderr', 'stdin', 'stdout', 'version'] >>> sys.__doc__ >>> print sys.__doc__ None >>> sys.path.__doc__ Traceback (innermost last): File "", line 1, in ? AttributeError: __doc__ >>> dir(sys.path) ['append', 'count', 'index', 'insert', 'remove', 'reverse', 'sort'] >>> dir(sys.path.append) ['__doc__', '__name__', '__self__'] >>> dir(sys.path.append.__doc__) [] >>> print sys.path.append.__doc__ None >>> From alan.gauld@bt.com Tue Oct 5 17:54:37 1999 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 5 Oct 1999 17:54:37 +0100 Subject: [Tutor] FOR loops Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF5E42@mbtlipnt02.btlabs.bt.co.uk> > message comes in, I got to the part that introduces FOR loops > the book doesn't explain the concept very well and I don't understand > how to use FOR loops in my programs.Could anyone explain what > FOR loops > do and how to implement them in my programming?? I would really > appreciate it. Shameless plug follows: My programming tutor has this to say: (context is building a 'multiplication table' generator) -------------------------------------------- FOR Loops What we are going to do is get the programming language to do the repetition, substituting a variable which increases in value each time it repeats. In Python it looks like this: >>>for i in range(1,13): ... print "%d x 12 = %d" % (i, i*12) Note 1: we need the range(1,13) to specify 13 because range() generates from the first number up to, but not including, the second number. This may seem somewhat bizarre at first but there are reasons and you get used to it. Note 2: The for operator in Python is actually a foreach operator in that it applies the subsequent code sequence to each member of a collection. In this case the collection is the list of numbers generated by range(). You can check that by typing: >>> print range(1,13) you will see that you get a Python list of numbers back. Here's the same loop in BASIC: FOR I = 1 to 12 PRINT I, " x 12 = ", I*12 NEXT I This is much more explicit and easier to see what is happening. However the Python version is more flexible in that we can loop over a set of numbers, the items in a list or any other collection (e.g. a string). ------------------------------ Find it at: http://members.xoom.com/alan_gauld/tutor/tutindex.htm Alan G. From Alexandre Passos" Dan Rey wrote: >I am eager to learn how to program......I heard Python was the best >beginner's language. How can i get started when have no history in >programing? I don't know any other language.....the assumed knowledge Python >covers is unkown to me.... >pls help....thanx.. Python is really good for starting off. No real help is needed, just take a look at some tutorials and guides of commands. From eroubinc@u.washington.edu Wed Oct 6 02:21:57 1999 From: eroubinc@u.washington.edu (Evgeny Roubinchtein) Date: Tue, 5 Oct 1999 18:21:57 -0700 (PDT) Subject: [Tutor] Print Doc Strings In-Reply-To: <199910051449.KAA05706@www.virtualblue.org> Message-ID: On Tue, 5 Oct 1999 mike@virtualblue.org wrote: >After trying your loop and then trying to display a __doc__ string it >looks like I'm not dealing with void __doc__ strings correctly. So why not put it in a "try" statement like so try: if item.__doc__ is not None: print item.__doc__ except AttributeError: pass Would this work? > >$ python >Python 1.5.1 (#1, Mar 21 1999, 22:49:36) [GCC egcs-2.91.66 19990314/Li on linux-i386 >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>> import sys >>>> for name in dir(sys): >... item = getattr(sys,name) >... print item.__doc__ >... >Traceback (innermost last): > File "", line 3, in ? >AttributeError: 'None' object has no attribute '__doc__' >>>> > >>>> dir(sys) >['__doc__', '__name__', '__stderr__', '__stdin__', '__stdout__', 'argv', 'builtin_module_names', 'copyright', 'exc_info', 'exc_type', 'exec_prefix', 'executable', 'exit', 'getrefcount', 'last_traceback', 'last_type', 'last_value', 'maxint', 'modules', 'path', 'platform', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setprofile', 'settrace', 'stderr', 'stdin', 'stdout', 'version'] >>>> sys.__doc__ >>>> print sys.__doc__ >None >>>> sys.path.__doc__ >Traceback (innermost last): > File "", line 1, in ? >AttributeError: __doc__ >>>> dir(sys.path) >['append', 'count', 'index', 'insert', 'remove', 'reverse', 'sort'] >>>> dir(sys.path.append) >['__doc__', '__name__', '__self__'] >>>> dir(sys.path.append.__doc__) >[] >>>> print sys.path.append.__doc__ >None >>>> > > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor > > -- Evgeny Roubinchtein, eroubinc@u.washington.edu ................... EBO: Emulate Brown-Out From trazor@internet.com.uy Thu Oct 7 17:05:48 1999 From: trazor@internet.com.uy (Eduardo Roldan) Date: Thu, 07 Oct 1999 13:05:48 -0300 Subject: [Tutor] GPL Python editor Message-ID: <37FCC4DC.9429CB32@internet.com.uy> SET's Editor is a friendly text editor; it was designed to be used by programmers; the main target of the editor is C and C++ code but it can be used for other tasks and supports syntax highlight for more than 24 languages (Python included). It have a user interface very easy to understand for people that used non-UNIX programs (real windows, dialogs, buttons, pull-down menues, mouse, etc.). DOS & UNIX versions available. http://www.geocities.com/SiliconValley/Vista/6552/setedit.html http://www.geocities.com/CapeCanaveral/Runway/6218/setedit.html http://setsoft.webjump.com/setedit.html From deirdre@deirdre.net Fri Oct 8 00:29:45 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 7 Oct 1999 16:29:45 -0700 (PDT) Subject: [Tutor] Matching problem.... Message-ID: I'm working on a silly project -- an APOP server -- and I'm having a problem coming up with an equivalent to the following command line. I'd rather not just have this as a commands.getstatusoutput() (which I could do and is in fact what I'm doing now...) cat /var/spool/mail/deirdre | grep ^From\ | wc or, for you egrep fans: egrep '^From\ ' /var/spool/mail/deirdre | wc What I want is ONLY the count of the matches. I don't, at this point, care a hoot about the matches themselves. That comes later. :) I'm *also* interested in the following: egrep '^From\ ' /var/spool/mail/deirdre -b ...but at a different point in time. :) -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From arcege@shore.net Fri Oct 8 01:25:43 1999 From: arcege@shore.net (Michael P. Reilly) Date: Thu, 7 Oct 1999 20:25:43 -0400 (EDT) Subject: [Tutor] Matching problem.... In-Reply-To: from Deirdre Saoirse at "Oct 7, 99 04:29:45 pm" Message-ID: <199910080025.UAA15029@northshore.shore.net> > I'm working on a silly project -- an APOP server -- and I'm having > a problem coming up with an equivalent to the following command line. I'd > rather not just have this as a commands.getstatusoutput() (which I could > do and is in fact what I'm doing now...) > > cat /var/spool/mail/deirdre | grep ^From\ | wc > > or, for you egrep fans: > > egrep '^From\ ' /var/spool/mail/deirdre | wc > > What I want is ONLY the count of the matches. I don't, at this point, care > a hoot about the matches themselves. That comes later. :) > > I'm *also* interested in the following: > > egrep '^From\ ' /var/spool/mail/deirdre -b > > ...but at a different point in time. :) Starting with: >>> import string >>> mbox = open(mboxfname).read() How about: >>> howmanymsgs = len(string.split(mbox, '\nFile ')) This runs in under a second for 80 msgs totaling about 1.5 Mbytes. And from the grep side, you could run. ;) grep -c '^From ' /var/spool/mail/deirdre Good luck. -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From deirdre@deirdre.net Fri Oct 8 01:32:08 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 7 Oct 1999 17:32:08 -0700 (PDT) Subject: [Tutor] Matching problem.... In-Reply-To: <199910080025.UAA15029@northshore.shore.net> Message-ID: On Thu, 7 Oct 1999, Michael P. Reilly wrote: > Starting with: > >>> import string > >>> mbox = open(mboxfname).read() I guess this is a question I was wondering about (and didn't explicitly state): is it reasonable to assume that a mailbox (or even that a whole message) for a pop session will fit in RAM? This is not designed as an industrial-strength APOP server that will meet all needs, but I do have to be aware that it can break, especially since it's running as root. :) People have a way of sending snarky attachments (like PowerPoint docs) that are huge. I suppose I really answered my own questions (no and no) and I'll have to work around them. :) > How about: > >>> howmanymsgs = len(string.split(mbox, '\nFile ')) > > This runs in under a second for 80 msgs totaling about 1.5 Mbytes. > > And from the grep side, you could run. ;) > grep -c '^From ' /var/spool/mail/deirdre Ah, good point. I forgot about the -c option. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From python-list@teleo.net Fri Oct 8 02:57:42 1999 From: python-list@teleo.net (Patrick Phalen) Date: Thu, 7 Oct 1999 18:57:42 -0700 Subject: [Tutor] Matching problem.... In-Reply-To: References: Message-ID: <9910071900320M.01353@quadra.teleo.net> [Deirdre Saoirse, on Thu, 07 Oct 1999]: :: I guess this is a question I was wondering about (and didn't explicitly :: state): is it reasonable to assume that a mailbox (or even that a whole :: message) for a pop session will fit in RAM? Several weeks ago, on one of the servers I do work on, I encountered a miadmin (Illustra) mailbox which had grown to 110 MB. :) From deirdre@deirdre.net Fri Oct 8 03:14:57 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 7 Oct 1999 19:14:57 -0700 (PDT) Subject: [Tutor] Matching problem.... In-Reply-To: <9910071900320M.01353@quadra.teleo.net> Message-ID: On Thu, 7 Oct 1999, Patrick Phalen wrote: > [Deirdre Saoirse, on Thu, 07 Oct 1999]: > > :: I guess this is a question I was wondering about (and didn't explicitly > :: state): is it reasonable to assume that a mailbox (or even that a whole > :: message) for a pop session will fit in RAM? > > Several weeks ago, on one of the servers I do work on, I encountered a > miadmin (Illustra) mailbox which had grown to 110 MB. :) Yeeep! Well, I'm going to stick (temporarily) with the icky but workable solution of spawning a grep process. I can read in chunks of the file when I need to send it. 110 MB would take a LONG time at 56k.... Anyhow, I'm having a lot of fun today. :) -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From michael@mediamanager.com.sg Fri Oct 8 07:27:08 1999 From: michael@mediamanager.com.sg (Michael Ang) Date: Fri, 08 Oct 1999 14:27:08 +0800 Subject: [Tutor] Run another py script In-Reply-To: <199910080506.BAA27032@python.org> Message-ID: <4.1.19991008142207.00a06290@po.mediamanager.com.sg> How can I run another python script within a script. Thanks Regards, Michael ICQ: 9684577 From joe@strout.net Fri Oct 8 15:39:22 1999 From: joe@strout.net (Joseph J. Strout) Date: Fri, 8 Oct 1999 07:39:22 -0700 Subject: [Tutor] Run another py script In-Reply-To: <4.1.19991008142207.00a06290@po.mediamanager.com.sg> References: <4.1.19991008142207.00a06290@po.mediamanager.com.sg> Message-ID: At 2:27 PM +0800 10/08/99, Michael Ang wrote: >How can I run another python script within a script. Thanks That depends. On what platform, and whatever for? Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From spiderman@nasachem.com Fri Oct 8 16:40:14 1999 From: spiderman@nasachem.com (R Parker) Date: Fri, 08 Oct 1999 10:40:14 -0500 Subject: [Tutor] GUI's Message-ID: <37FE105E.F0854CDC@ghg.net> I was wondering how you could make a GUI python program for Windows 95 From andyquake@hotmail.com Sun Oct 10 03:15:28 1999 From: andyquake@hotmail.com (Andy Quake) Date: Sat, 09 Oct 1999 21:15:28 CDT Subject: [Tutor] compile doesn't work Message-ID: <19991010021529.75568.qmail@hotmail.com> i am having problems with compile...i looked at your help thing and everyhing but nothing seems to work...can you please give me DETAILED instructions on how to do this... Thanks, AndyQuake ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From arcege@shore.net Sun Oct 10 04:00:48 1999 From: arcege@shore.net (Michael P. Reilly) Date: Sat, 9 Oct 1999 23:00:48 -0400 (EDT) Subject: [Tutor] compile doesn't work In-Reply-To: <19991010021529.75568.qmail@hotmail.com> from Andy Quake at "Oct 9, 99 09:15:28 pm" Message-ID: <199910100300.XAA17715@northshore.shore.net> > i am having problems with compile...i looked at your help thing and > everyhing but nothing seems to work...can you please give me DETAILED > instructions on how to do this... > Thanks, > AndyQuake Andy, You don't say what your problem is or what you have tried. The docs are pretty clear about the builtin compile() function: http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-106 But basically, it goes like so. There are three required arguments, the string to compile, the filename it came from, and what kind of compilation to perform (a string argument). If the string did not come from a file, the convention is to use the filename ''. There are three valid values for the kind of compilation argument. The first is 'exec', where the first argument is compiled as python statements; for example, the string could be a for loop, a function definition, an assignment, or combinations. The second is 'eval' which allows expressions, such as function calls, arithmetic, subscripting, etc. The last is 'single' which works just like interactive mode. Any python statement that does not result in None will by printed to stdout. Here are some examples: >>> c = compile('a = 10', '', 'exec') # an assignment cannot be an expression >>> b = compile('a = 10', '', 'eval') Traceback (innermost last): File "", line 1, in ? File "", line 1 a = 10 ^ SyntaxError: invalid syntax >>> d = compile('a ** 2', '', 'eval') # just because we compile the code doesn't mean it has run yet >>> v1 = eval(d) Traceback (innermost last): File "", line 1, in ? NameError: a # we could use eval(c) too, but it would return None >>> exec c >>> v1 = eval(d) >>> print v1 100 >>> s = compile('range(a)', '', 'single') # 'single' prints non-None values to the screen like interactive mode >>> v2 = eval(s) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> v2 is None 1 >>> I hope this helps you understand it better; you might want to read the Python Language Reference Manual. -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From krhodes@webside.ca Sun Oct 10 17:30:31 1999 From: krhodes@webside.ca (ken rhodes) Date: Sun, 10 Oct 1999 09:30:31 -0700 Subject: [Tutor] [Fwd: Web programming catagory] Message-ID: <3800BF27.AD43D1D8@webside.ca> This is a multi-part message in MIME format. --------------A382420FCD13C9F9639F20C5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi; I was told to place this message to tutor instead of webmaster. Thank you; Ken --------------A382420FCD13C9F9639F20C5 Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Mozilla-Status2: 00000000 Message-ID: <38009A60.73239070@webside.ca> Date: Sun, 10 Oct 1999 06:53:37 -0700 From: ken rhodes Organization: Webside X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.9-27mdk i586) X-Accept-Language: en MIME-Version: 1.0 To: webmaster@python.org Subject: Web programming catagory Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi fellow Webmaster; I am looking on information on using Python to write HTML Applets. I tried the example in "Programming Python" by Mark Lutz. It did not work! The applet does not appear. Where are the pages which will help me understand why. If this I can not make this work I am planning to get the "Perl Resource Kit" It does not mater which tool I use at this point I just need to get one to work. Can you help. Thank you; Ken Rhodes Webmaster Webside Communications Ltd http://www.WEBSIDE.Ca --------------A382420FCD13C9F9639F20C5-- From oc918@mizzou.edu Sun Oct 10 17:52:29 1999 From: oc918@mizzou.edu (Oscar Chavez) Date: Sun, 10 Oct 1999 11:52:29 -0500 Subject: [Tutor] Simple question In-Reply-To: <199910090505.BAA27103@python.org> Message-ID: I wrote this simple program: ---- F2C.py: # Temperature conversion print "This little program converts from Farenheit to Celsius," print "or from Celsius to Farenheit" print "-----------------------------------------------" # Print the menu print "What do you want to convert?" print "1 From Farenheit to Celsius" print "2 From Celsius to Farenheit" # Get the user's choice: formula = input("-->") print # Calculate the result: if formula == 1: F = input("What is the temperature in °F?") C = (F - 32)*5/9 print print F,"°F is equivalent to", C, "°C" else: C = input("What is the temperature in °C?") F = C*9/5 + 32 print print C, "°C is equivalent to", F, "°F" ----- And it works fine, except for the way it has to be run. The only way I can make it run as a command line program is when I save it as an applet. I like the way it looks, at this moment I don't want to be concerned about GUI. The problem is that as soon as it gives the answer, it quits by itself, not allowing the user to see the result. How can I make it to wait for, let's say a return, to quit? __________________________________________________________________________ Oscar Chavez 104 Stewart Hall oc918@mizzou.edu University of Missouri (573) 882-4521 Columbia, MO 65211-6180 From joe@strout.net Sun Oct 10 20:38:59 1999 From: joe@strout.net (Joseph J. Strout) Date: Sun, 10 Oct 1999 12:38:59 -0700 Subject: [Tutor] Simple question In-Reply-To: References: <199910090505.BAA27103@python.org> Message-ID: At 9:52 AM -0700 10/10/99, Oscar Chavez wrote: >And it works fine, except for the way it has to be run. The only way I can >make it run as a command line program is when I save it as an applet. This is a platform-specific issue; there is no such thing as an "applet" in the general Python world. Maybe you're using a Mac? Next time, please specify. >The problem is that as soon as it gives the answer, it quits by >itself, not allowing the user to see the result. How can I make it to wait >for, let's say a return, to quit? I use: raw_input("[Press Return.]") at the end of the program. Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From neilconway@home.com Mon Oct 11 03:03:32 1999 From: neilconway@home.com (neilconway@home.com) Date: Sun, 10 Oct 1999 22:03:32 -0400 (EDT) Subject: [Tutor] GUI Toolkit? Message-ID: Hello all. I have decided to begin GUI programming, using Python. All the Python books I have contain information on Tkinter - but all the Tk apps I have used tend to be pretty drab looking, and out-of-date. I am just using poor applications, or is Tkinter outdated? I would like an honest opinion before I start, so I don't waste my time. A guru friend of mine said that Tk is a bad choice - he recommended gtk. Does anyone use pygtk? How stable/complete is it? Does anyone know where I can find some documentation on how to use it (other than on gtk.org, which documents only gtk in C). What about wxPython? How good is that? I am primarily concerned primarily with appearence, and ease of use for a newbie, followed by portability (ideally, *NIX, and Windows). TIA Neil Conway From deirdre@deirdre.net Mon Oct 11 07:09:29 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sun, 10 Oct 1999 23:09:29 -0700 (PDT) Subject: [Tutor] [Fwd: Web programming catagory] In-Reply-To: <3800BF27.AD43D1D8@webside.ca> Message-ID: You're not very specific about what you tried exactly and why it didn't work. What did your logs say? I've done way too much cgi programming in Python lately.... On Sun, 10 Oct 1999, ken rhodes wrote: > Hi; > I was told to place this message to tutor instead of webmaster. > > Thank you; > Ken > -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From krhodes@webside.ca Mon Oct 11 17:35:11 1999 From: krhodes@webside.ca (ken rhodes) Date: Mon, 11 Oct 1999 09:35:11 -0700 Subject: [Fwd: [Tutor] [Fwd: Web programming catagory]] Message-ID: <380211BF.8BF802BA@webside.ca> This is a multi-part message in MIME format. --------------E573A113054D492C8D0BA593 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit --------------E573A113054D492C8D0BA593 Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline Return-Path: Received: from adelie.baypiggies.org (really [204.94.189.31]) by webside.ca via smail with esmtp id (Webside.ca: Smail 3.2.0.101) for ; Mon, 11 Oct 1999 09:05:33 -0700 (PDT) Received: from localhost (deirdre@localhost) by adelie.baypiggies.org (8.9.3/8.9.3) with ESMTP id IAA15755 for ; Mon, 11 Oct 1999 08:56:46 -0700 X-Authentication-Warning: adelie.deirdre.org: deirdre owned process doing -bs Date: Mon, 11 Oct 1999 08:56:45 -0700 (PDT) From: Deirdre Saoirse X-Sender: deirdre@adelie.deirdre.org To: ken rhodes Subject: Re: [Tutor] [Fwd: Web programming catagory] In-Reply-To: <3801EAA3.B0760ED@webside.ca> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Mozilla-Status2: 00000000 When asking a problem on a list and someone replies to the list seeking clarification, etiquette demands that the answer also be given on the list. That way, anyone can help with the answer and it doesn't burden one person overly much. I'll post a reply when I get into work today. On Mon, 11 Oct 1999, ken rhodes wrote: > Hi Deirdre; > I have been writing CGI's in Perl, but I am finding programming on the back > end very difficult, and I wanted to program at the front end, through the Java > Applet. (Java does not have the database functions I would like to use) > I have the book Programming Python on page 719, 720 there is a question > program which is suppose to place a Button with a question on it in the > browser. > > When I run the program out of Xterm it compiles and then puts a bunch of > commands on the screen with a message that it cannot connect to display. > > I have a copy of the program on my server at > HTTP://Python.websice.ca/question.py and the webpage which calls it is > HTTP://Python.webside.ca The webpage comes up but there is no sign of it > running the applet. > > Thank you; > Ken Rhodes > > > Deirdre Saoirse wrote: > > > You're not very specific about what you tried exactly and why it didn't > > work. What did your logs say? > > > > I've done way too much cgi programming in Python lately.... > > > > On Sun, 10 Oct 1999, ken rhodes wrote: > > > > > Hi; > > > I was told to place this message to tutor instead of webmaster. > > > > > > Thank you; > > > Ken > > > > > > > -- > > _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net > > "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator > > "That's because the Martians keep shooting things down." -- Harlan Rosenthal > > , retorting in Risks Digest 20.60 > -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 --------------E573A113054D492C8D0BA593-- From deirdre@deirdre.net Mon Oct 11 18:22:48 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 11 Oct 1999 10:22:48 -0700 (PDT) Subject: [Tutor] [Fwd: Web programming catagory] In-Reply-To: <3801EAA3.B0760ED@webside.ca> Message-ID: Ken, thanks for forwarding your post to the list. :) Now that I'm at work and next to my Programming Python book I can see what pages you're talking about. On Mon, 11 Oct 1999, ken rhodes wrote: > I have been writing CGI's in Perl, but I am finding programming on > the back end very difficult, and I wanted to program at the front end, > through the Java Applet. (Java does not have the database functions I > would like to use) Recognize that this would make your pages unavailable to a lot of people who, like myself, either use web browsers without Java or with Java disabled. I have also not seen that screen readers are able to deal with Java applets correctly, so you'd likely be shutting off blind users as well. CGIs, though you may not prefer them, give you the widest audience. > I have the book Programming Python on page 719, 720 there is a question > program which is suppose to place a Button with a question on it in the > browser. ...only in Grail, which is an unmaintained web browser written in Python. > When I run the program out of Xterm it compiles and then puts a bunch of > commands on the screen with a message that it cannot connect to display. Yes, it requires that an X server be running. > I have a copy of the program on my server at > HTTP://Python.websice.ca/question.py and the webpage which calls it is > HTTP://Python.webside.ca The webpage comes up but there is no sign of it > running the applet. I think what you need is another solution to your problem as I don't think this is the solution you intended. Which brings us to the real question: what problem were you trying to solve ultimately? What did you want to happen when the user clicked the button? -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From muneer_bom3@hotmail.com Tue Oct 12 08:33:41 1999 From: muneer_bom3@hotmail.com (Muneer Ahmed Khan) Date: Tue, 12 Oct 1999 07:33:41 GMT Subject: [Tutor] Give Some Programming Tips Message-ID: <19991012073341.40705.qmail@hotmail.com> Hi I am downloaded python & its really very simple, can u Please Give me some programming tips like how write programs,idea,debug etc Thanking You Bye & Regards Muneer ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From vcardona@worldnet.att.net Tue Oct 12 09:20:39 1999 From: vcardona@worldnet.att.net (Victor R. Cardona) Date: Tue, 12 Oct 1999 04:20:39 -0400 Subject: [Tutor] off topic Message-ID: <99101204234403.00641@localhost.localdomain> Hi everyone, After programming with Python for a few months, I have started taking an interest in computer science. I was wondering if anyone could recommend any good CS programs in either Illinois or California. I am aware of the big schools, but I was wondering if anyone new anything about the smaller ones. Thanks, Victor From warren@nightwares.com Tue Oct 12 14:21:08 1999 From: warren@nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Tue, 12 Oct 1999 08:21:08 -0500 Subject: [Tutor] Give Some Programming Tips References: <19991012073341.40705.qmail@hotmail.com> Message-ID: <380335C4.30A907C0@nightwares.com> Muneer Ahmed Khan wrote: > Hi Howdy! > I am downloaded python & its really very simple, can u Please Give me some > programming tips like how write programs,idea,debug etc Well, if you are not familir with programming at *all*, you've found the right language. I suggest you surf the items and links to be found at http://www.python.org/ first. If you have some disposable income, consider purchasing Mark Lutz's _Programming Python_ from O'Reilly and Associates. It includes a CD and is a rather thorough introduction to both Python and programming in general. A good thing to do when you are beginning is to have a clear goal in mind. What kind of program do you want to write? That will help you focus on relevant topics. Enjoy! --WthmO From rbl@hal.EPBI.CWRU.Edu Tue Oct 12 14:50:38 1999 From: rbl@hal.EPBI.CWRU.Edu (Robin B. Lake) Date: Tue, 12 Oct 1999 09:50:38 -0400 (EDT) Subject: [Tutor] off topic Message-ID: <199910121350.JAA26102@hal.epbi.cwru.edu> > Hi everyone, > > After programming with Python for a few months, I have started taking an > interest in computer science. I was wondering if anyone could recommend any > good CS programs in either Illinois or California. I am aware of the big > schools, but I was wondering if anyone new anything about the smaller ones. > > Thanks, > Victor > Victor - Suggest you surf over to: http://www.csab.org/acrsch.html for a list of undergraduate CS programs accreditied by the Computer Sciences Accreditation Board. Note that many fine programs are NOT accredited, usually because of a minor conflict between the CSAB course distribution requirements and the University's distribution requirements. Cheers, Rob Lake rbl@hal.cwru.edu From alan.gauld@bt.com Tue Oct 12 15:15:19 1999 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 12 Oct 1999 15:15:19 +0100 Subject: [Tutor] GUI Toolkit? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF5E61@mbtlipnt02.btlabs.bt.co.uk> > I have decided to begin GUI programming, using Python. > All the Python books I have contain information on Tkinter > - but all the Tk apps I have used tend to be pretty drab > looking, and out-of-date. Not quite sure what the out of date bit means but Tk is a lowest common denominator toolkit so does suffer in its presentation because of that. It is possible to create your own widgets with all manner of sexy features but thats not really where Tk is at its best IMHO. Have you looked at JPython which might offer a better way forward... using Java's GUI vcapabilities but programming in Python. [Caveat: I haven't actually used JPython myself but that seems to be what it's about.] > I am just using poor applications, or is > Tkinter outdated? A bit of both. Most Tk apps are wrappers around commandline tools, they aren't designed with the latest and greatest GUI enhancements in mind. Tk is quick and easy to program which makes it ideal for quickly prototyping an idea or making a commandline tool easier to use in a GUI age. But its perfectly possible to create fairly sexy GUI apps using Tk, although finding a publicly available example isn't easy. > A guru friend of mine said that Tk is a bad choice - he > recommended gtk. Gtk is nice (as is Qt which I believe also has a Python interface). Again I haven't used it from Python, only C++ - and only the tutorial at that. > What about wxPython? How good is that? Dunno. Anyone else? As a C API it looked OK but again is fauirly 'lowest common denominator-ish' > I am primarily concerned primarily with appearence, and ease > of use for a newbie, followed by portability (ideally, *NIX, and Windows). Those two goals tend to be mutually exclusive :-( The more feature rich an API the harder it gets to use. The general techniques are similar however and maybe learning Tk would be a good start - You can use the knowlege in Tcl or Perl as well as Python. Then once comfortable move to GTk or JPython later. (depends to some extent if you have previous C GUI experience in say Windows MFC, Mac or X) Alan G. From krhodes@webside.ca Tue Oct 12 15:35:35 1999 From: krhodes@webside.ca (ken rhodes) Date: Tue, 12 Oct 1999 07:35:35 -0700 Subject: [Tutor] [Fwd: Web programming catagory] References: <38033E16.6CEE2EAA@webside.ca> Message-ID: <38034737.638848C9@webside.ca> ken rhodes wrote: > In reply to Deirdre; > > Maybe my problem is I took my programming in 1984 though 1989. From 1989 > till 1991 I programed in several languages including CLIPPER where I was > basically implementing Object oriented code to program rental and scheduling > systems. I quit programing in 1991 until 1998 when I started back with HTML > and March I started learning Perl, now I am Learning Python. > > My problem is security. I have about three projects I am working on. > 1) HTML get mail and send mail, because out clients are asking for it. > My current versions are at: HTTP://e-mails.WEBSIDE.Ca > (Using $input{"Password"}> is just to much of a security risk. and keeping the > password in your programs memory is impossible under all the CGI information I > have read. ) > > 2)My BBS program which I am waiting for my system administrator to get our > Postgrsql machine up and running. HTTP;// bbs.webside.ca > > 3) My Community Events schedualing system. > Under this I need the database also, but I will have to have security > for each new group who will enter there own information about there building. > > Thank you; > Ken > > Deirdre Saoirse wrote: > > > Ken, thanks for forwarding your post to the list. :) Now that I'm at work > > and next to my Programming Python book I can see what pages you're talking > > about. > > > > On Mon, 11 Oct 1999, ken rhodes wrote: > > > > > I have been writing CGI's in Perl, but I am finding programming on > > > the back end very difficult, and I wanted to program at the front end, > > > through the Java Applet. (Java does not have the database functions I > > > would like to use) > > > > Recognize that this would make your pages unavailable to a lot of people > > who, like myself, either use web browsers without Java or with Java > > disabled. I have also not seen that screen readers are able to deal with > > Java applets correctly, so you'd likely be shutting off blind users as > > well. > > > > CGIs, though you may not prefer them, give you the widest audience. > > > > > I have the book Programming Python on page 719, 720 there is a question > > > program which is suppose to place a Button with a question on it in the > > > browser. > > > > ...only in Grail, which is an unmaintained web browser written in Python. > > > > > When I run the program out of Xterm it compiles and then puts a bunch of > > > commands on the screen with a message that it cannot connect to display. > > > > Yes, it requires that an X server be running. > > > > > I have a copy of the program on my server at > > > HTTP://Python.websice.ca/question.py and the webpage which calls it is > > > HTTP://Python.webside.ca The webpage comes up but there is no sign of it > > > running the applet. > > > > I think what you need is another solution to your problem as I don't think > > this is the solution you intended. > > > > Which brings us to the real question: what problem were you trying to > > solve ultimately? What did you want to happen when the user clicked the > > button? > > > > -- > > _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net > > "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator > > "That's because the Martians keep shooting things down." -- Harlan Rosenthal > > , retorting in Risks Digest 20.60 From Alexandre Passos" This is a multi-part message in MIME format. ------=_NextPart_000_00BD_01BF14B3.F0019400 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How can I use the _def_ command to create an object? ------=_NextPart_000_00BD_01BF14B3.F0019400 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
How can I use the _def_ command to = create an=20 object?
 
------=_NextPart_000_00BD_01BF14B3.F0019400-- From joe@strout.net Tue Oct 12 17:26:32 1999 From: joe@strout.net (Joseph J. Strout) Date: Tue, 12 Oct 1999 09:26:32 -0700 Subject: [Tutor] The __def__ command In-Reply-To: <00c501bf14cd$1954c3e0$6b5bdfc8@the-user> References: <00c501bf14cd$1954c3e0$6b5bdfc8@the-user> Message-ID: At 1:16 PM -0300 10/12/99, Alexandre Passos wrote: >How can I use the _def_ command to create an object? Beats me. What's a _def_ (or __def__) command? I just create objects with: myObject = MyClass() ...what's wrong with this approach? Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From Alexandre Passos" This is a multi-part message in MIME format. ------=_NextPart_000_0101_01BF14B5.CDF22DA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I've tried to use the os.open module theese ways: #Command prompt command =3D raw_input("[shell]") import os os.open(command) and the error message was: 0 arguments needed 1 given #Command Prompt command =3D raw_input("[shell]") import os os.open() command error: Call of non function and finally #Command prompt command =3D raw_input("[shell]") import os os.open command and I obtained the following message: what shall I do?? ------=_NextPart_000_0101_01BF14B5.CDF22DA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I've tried to use the os.open module = theese=20 ways:
#Command prompt
command =3D=20 raw_input("[shell]")
import os
os.open(command)
 
 
and the error message = was:
0 arguments = needed 1=20 given
 
 
 
#Command Prompt
command =3D=20 raw_input("[shell]")
import os
os.open() command
 
error:
Call of non function
 
and finally
#Command prompt
command =3D = raw_input("[shell]")
import os
os.open command
 
and I obtained the following message:
<builtin function open>
 
what shall I do??
------=_NextPart_000_0101_01BF14B5.CDF22DA0-- From alan.gauld@bt.com Tue Oct 12 17:54:55 1999 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 12 Oct 1999 17:54:55 +0100 Subject: FW: [Tutor] GUI's Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF5E64@mbtlipnt02.btlabs.bt.co.uk> spiderman@nasachem.com wrote > I was wondering how you could make a GUI python program for Windows 95 Tkinter comes with Python. SpecPython is an addon to SpecTCL, a GUI builder for Tk/Java JPython implements the JAVA AWT (and Swing?) in Python Either approach will create a GUI running in Python. There are a couple of Tkinter tutorials on the Web. I personally prefer this one: http://www.pythonware.com/library/tkinter/introduction/index.htm Here's Python/Tkinter's minimal Hello world: #----------------------- # pull in all the widget names from Tkinter import * # create a label widget and add it to the root window w = Label(0, text="Hello, world!") # 0 => no parent window w.pack() # start processing user events w.mainloop() #----------------------- Alan G. From loewis@informatik.hu-berlin.de Tue Oct 12 19:33:22 1999 From: loewis@informatik.hu-berlin.de (Martin von Loewis) Date: Tue, 12 Oct 1999 20:33:22 +0200 Subject: [Tutor] Re: [Python-Help] ExpectPy Installation problem --- attached config.log In-Reply-To: <19990928182507.23170.rocketmail@web216.mail.yahoo.com> (message from ET on Tue, 28 Sep 1999 11:25:07 -0700 (PDT)) References: <19990928182507.23170.rocketmail@web216.mail.yahoo.com> Message-ID: <199910121833.UAA15569@pandora> > This file contains any messages produced by compilers while running > configure, to aid debugging if configure makes a mistake. Without investigating this in detail, it seems that there are serious bugs in the configure.in of ExpectPy. I recommend to contact the ExpectPy authors for help. If you want to fix those problems on your own, you'll need to investigate each problem in detail. > configure:1896: gcc -o conftest -g -O2 > -I/s1/sqa/edwardt/Python/Python-1.5.2/Include > -I/tools/2.5.1/local/lib > -L/s1/sqa/edwardt/Python/Python-1.5.2 > -L/tools/2.5.1/local/lib conftest.c > -lexpect5.26 -ldl -lm 1>&5 > /tools/2.5.1/local/lib/libexpect5.26.a(exp_clib.o): In > function `exp_spawnv': > /net/wrk/expect-5.26/exp_clib.c:282: undefined > reference to `Tcl_ErrnoMsg' I'm not surprised Tcl_ErrnoMsg is undefined - they don't attempt to link libtcl-something with the executable. Or, if this should get linked via -lexpect5.26 - perhaps the Tcl version and the expect version you use don't match? > configure:2043: gcc -o conftest -g -O2 > -I/s1/sqa/edwardt/Python/Python-1.5.2/Include > -I/tools/2.5.1/local/lib > -L/s1/sqa/edwardt/Python/Python-1.5.2 > -L/tools/2.5.1/local/lib conftest.c > -lpython1.5 -ldl -lm 1>&5 > /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): > In function > `setipaddr': > /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:404: > undefined > reference to `gethostbyname' Yes, they fail to link -lsocket, or anything else defined /usr/local/lib/python1.5/config/Makefile:MODLIBS I don't know whether there is autoconf support for that kind of stuff already there; however absolutely need to know what additional libraries to link when you want to embed Python. This, again, looks like a configure.in bug. Hope this helps, Martin From deirdre@deirdre.net Tue Oct 12 19:35:13 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Tue, 12 Oct 1999 11:35:13 -0700 (PDT) Subject: [Tutor] off topic In-Reply-To: <199910121350.JAA26102@hal.epbi.cwru.edu> Message-ID: On Tue, 12 Oct 1999, Robin B. Lake wrote: > Suggest you surf over to: > http://www.csab.org/acrsch.html > > for a list of undergraduate CS programs accreditied by the > Computer Sciences Accreditation Board. Note that many fine > programs are NOT accredited, usually because of a minor conflict > between the CSAB course distribution requirements and the > University's distribution requirements. LOL, most of the top-ranked schools in computer science *are not on the list.* Dartmouth? Nope Carnegie-Mellon? Nope Stanford? Nope UC Irvine? Nope University of Illinois at Urbana-Champaign? Nope Virginia Tech? Nope I suggest looking for a good regionally-accredited school. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From rbl@hal.EPBI.CWRU.Edu Tue Oct 12 20:28:28 1999 From: rbl@hal.EPBI.CWRU.Edu (Robin B. Lake) Date: Tue, 12 Oct 1999 15:28:28 -0400 (EDT) Subject: [Tutor] off topic Message-ID: <199910121928.PAA29874@hal.epbi.cwru.edu> > On Tue, 12 Oct 1999, Robin B. Lake wrote: > > > Suggest you surf over to: > > http://www.csab.org/acrsch.html > > > > for a list of undergraduate CS programs accreditied by the > > Computer Sciences Accreditation Board. Note that many fine > > programs are NOT accredited, usually because of a minor conflict > > between the CSAB course distribution requirements and the > > University's distribution requirements. > > LOL, most of the top-ranked schools in computer science *are not on the > list.* > > Dartmouth? Nope > Carnegie-Mellon? Nope > Stanford? Nope > UC Irvine? Nope > University of Illinois at Urbana-Champaign? Nope > Virginia Tech? Nope > > I suggest looking for a good regionally-accredited school. > > -- And, there are even MORE non-accredited programs at those institutions that DO have CASB-accreditation. There simply is not one mold that fits all institutions and education is more robust for it. Rob Lake rbl@hal.cwru.edu From tim_one@email.msn.com Wed Oct 13 05:02:51 1999 From: tim_one@email.msn.com (Tim Peters) Date: Wed, 13 Oct 1999 00:02:51 -0400 Subject: [Tutor] How do I use the os.open module? In-Reply-To: <010401bf14ce$f4012f00$6b5bdfc8@the-user> Message-ID: <000101bf152f$d2581f60$50a2143f@tim> [Alexandre Passos] > I've tried to use the os.open module theese ways: > #Command prompt > command = raw_input("[shell]") > import os > os.open(command) > > > and the error message was: > 0 arguments needed 1 given Please don't type in code or error msgs from memory -- cut and paste! The error msg for this one was much more likely: TypeError: function requires at least 2 arguments; 1 given Yes? > #Command Prompt > command = raw_input("[shell]") > import os > os.open() command > > error: > Call of non function Ditto. This one is a SyntaxError, as written. > and finally > #Command prompt > command = raw_input("[shell]") > import os > os.open command > > and I obtained the following message: > This is another syntax error. > what shall I do?? What do you want to do? I can't tell from the above what you think os.open() should do, but it clearly doesn't do what you think it does. os.open() is a low-level function used (very rarely) to open files. It seems more that you're trying to execute a command. If so, os.system() or os.popen() are what you're looking for. Make sure too that you're running Python 1.5.2 and have up-to-date documentation. From krhodes@webside.ca Wed Oct 13 15:36:59 1999 From: krhodes@webside.ca (ken rhodes) Date: Wed, 13 Oct 1999 07:36:59 -0700 Subject: [Tutor] How do you get python aplet to work? References: Message-ID: <3804990B.9462A15@webside.ca> Hi All; After talking with Deirdre I understand the program I thought might be my solution is not! I need a API which will work with Netscape. Being stuck using Grail is not what I wanted. Can someone point me in the right direction? I need help in this direction I realize that Java does have a limited amount of people, but the applications I want to write are for our ISP clients. I thought Python would be a good language to do applets in, but if it comes down to that the applets can only be read by the Grail browser, I guess I am stuck with ordering the Perl Resource Kit. Thank you; Ken Webmaster Webside Communications Ltd. Http://www.webside.ca From joe@strout.net Wed Oct 13 16:01:35 1999 From: joe@strout.net (Joseph J. Strout) Date: Wed, 13 Oct 1999 08:01:35 -0700 Subject: [Tutor] How do you get python aplet to work? In-Reply-To: <3804990B.9462A15@webside.ca> References: <3804990B.9462A15@webside.ca> Message-ID: At 7:36 AM -0700 10/13/99, ken rhodes wrote: > After talking with Deirdre I understand the program I thought might be >my solution is not! I need a API which will work with Netscape. > > I thought Python would be a good language to do applets in, but >if it comes down to that the applets can only be read by the Grail >browser, I guess I am stuck with ordering the Perl Resource Kit. Netscape can't run Perl applets either, can it? Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From python-list@teleo.net Wed Oct 13 16:55:52 1999 From: python-list@teleo.net (Patrick Phalen) Date: Wed, 13 Oct 1999 08:55:52 -0700 Subject: [Tutor] How do you get python aplet to work? In-Reply-To: <3804990B.9462A15@webside.ca> References: <3804990B.9462A15@webside.ca> Message-ID: <99101309015000.01516@quadra.teleo.net> [ken rhodes, on Wed, 13 Oct 1999]: :: I thought Python would be a good language to do applets in Put a "J" in front of "Python" and you'll be on the right track. http://www.developer.com/journal/techfocus/081798_jpython.html From krhodes@webside.ca Wed Oct 13 21:03:28 1999 From: krhodes@webside.ca (ken rhodes) Date: Wed, 13 Oct 1999 13:03:28 -0700 Subject: [Tutor] Java in Python Message-ID: <3804E590.14D8793E@webside.ca> Thank you for all your help; Joseph J Strout: Hi I do not know if Netscape can run Java applets , but the information on the Perl Resurse Kit says it has the modual to make it do so. Moshe Zadka: Thank you again it looks like the Jpython.org may have the information I am looking for. Thank you; Ken From Alexandre Passos" This is a multi-part message in MIME format. ------=_NextPart_000_0073_01BF15A2.A1E221A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How can I use the def command to create an object? ------=_NextPart_000_0073_01BF15A2.A1E221A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
How can I use the def command to = create an=20 object?
 
------=_NextPart_000_0073_01BF15A2.A1E221A0-- From joe@strout.net Wed Oct 13 21:53:16 1999 From: joe@strout.net (Joseph J. Strout) Date: Wed, 13 Oct 1999 13:53:16 -0700 Subject: [Tutor] The def command In-Reply-To: <007601bf15bb$c82b1ec0$0d5bdfc8@the-user> References: <007601bf15bb$c82b1ec0$0d5bdfc8@the-user> Message-ID: At 5:44 PM -0300 10/13/99, Alexandre Passos wrote: >How can I use the def command to create an object? You don't. "def" is used to define functions. To create an object, you just call the class name as if it's a function. E.g.: class Foo: def spam(self, n): print "spam "*n myFoo = Foo() HTH, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From deirdre@deirdre.net Wed Oct 13 21:55:05 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 13 Oct 1999 13:55:05 -0700 (PDT) Subject: [Tutor] How do you get python aplet to work? In-Reply-To: <3804990B.9462A15@webside.ca> Message-ID: Why the Perl Resource Kit? The problem is the same either way. Sorry I haven't had time for a lengthy reply: 1) I scratched my cornea again and I can barely read. 2) I'm on a rush project for work consuming all my time. On Wed, 13 Oct 1999, ken rhodes wrote: > Hi All; > After talking with Deirdre I understand the program I thought might be > my solution is not! I need a API which will work with Netscape. Being stuck > using Grail is not what I wanted. > > Can someone point me in the right direction? > > I need help in this direction > > I realize that Java does have a limited amount of people, but the > applications I want to write are for our ISP clients. > > I thought Python would be a good language to do applets in, but if it comes > down to that the applets can only be read by the Grail browser, I guess I am > stuck with ordering the Perl Resource Kit. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From ivanlan@callware.com Wed Oct 13 22:07:48 1999 From: ivanlan@callware.com (Ivan Van Laningham) Date: Wed, 13 Oct 1999 15:07:48 -0600 Subject: [Tutor] The def command Message-ID: <3804F4A4.EFB646FE@callware.com> Hi All-- You asked this earlier, as "how do I use the __def__ command to create an object." Alexandre Passos wrote: > > How can I use the def command to create an object? > Def is not a command. It's a statement. You use it to create function objects. Like this: def myfunction(s): print s Then you can call it like this: if __name__ == "__main__": myfunction("Hello, world!") You can also do things like this: xx = myfunction (note the absence of parentheses after the name of the function; parens after an object mean it is callable, like a function.) Then, you can do things like this: xx("Goodbye, Cruel World!") If you want to know about objects like classes, look at the docs at www.python.org, or as the tutor list some more specific question. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan@callware.com ivanlan@home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From krhodes@webside.ca Thu Oct 14 00:21:00 1999 From: krhodes@webside.ca (ken rhodes) Date: Wed, 13 Oct 1999 16:21:00 -0700 Subject: : [Tutor] How do you get python aplet to work? References: Message-ID: <380513DC.B4BE56D8@webside.ca> As my last reply to tutor@python.org and to Deirdre; In the back of my Programming Python book is a book listing: One of the books listed is Perl Resource Kit UNIX Edition. ISBN:1-56592-370-7 under the subtitle: Perl Software Tools All on One Convenient CD-ROM * A new Java/Perl interface that allows programmers to write Java classes with Perl implementations. This new tool was written specially for the Kit by Larry Wall I have not ordered the book because your friend Moshe Zadka pointed me to JPython My plans right now is to finish reading Programming Python, and maybe find a book on JPython, or start reading the text on line. I have enjoyed talking to you all; When I do get my first applet up, planning around Xmas, I will let you know. Thank you; Ken Deirdre Saoirse wrote: > Why the Perl Resource Kit? > > The problem is the same either way. > > Sorry I haven't had time for a lengthy reply: > > 1) I scratched my cornea again and I can barely read. > 2) I'm on a rush project for work consuming all my time. > > On Wed, 13 Oct 1999, ken rhodes wrote: > > > Hi All; > > After talking with Deirdre I understand the program I thought might be > > my solution is not! I need a API which will work with Netscape. Being stuck > > using Grail is not what I wanted. > > > > Can someone point me in the right direction? > > > > I need help in this direction > > > > I realize that Java does have a limited amount of people, but the > > applications I want to write are for our ISP clients. > > > > I thought Python would be a good language to do applets in, but if it comes > > down to that the applets can only be read by the Grail browser, I guess I am > > stuck with ordering the Perl Resource Kit. > > -- > _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net > "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator > "That's because the Martians keep shooting things down." -- Harlan Rosenthal > , retorting in Risks Digest 20.60 From michael@esm-software.com Wed Oct 13 15:44:13 1999 From: michael@esm-software.com (Michael McCormick) Date: Wed, 13 Oct 1999 09:44:13 -0500 Subject: [Tutor] GUI's Message-ID: <199910141510.LAA05374@python.org> alan.gauld@bt.com wrote: > JPython implements the JAVA AWT (and Swing?) in Python Just to clarify, JPython is Python implemented in Java, not the other way around. It's cool since you can instantiate Java classes and call Java functions without writing those extension modules yourself. It uses reflection & introspection to do it for you. find it at http://www.jpython.org Mike -- michael@esm-software.com From rayr@cats.ucsc.edu Fri Oct 15 19:32:10 1999 From: rayr@cats.ucsc.edu (Raymund Ramos) Date: Fri, 15 Oct 1999 11:32:10 -0700 (PDT) Subject: [Tutor] python as unix shell Message-ID: Has anyone tried having python as the login shell? Tips and scripts (esp. for reading email using imap) would be much appreciated. -raymund From bwinton@tor.dhs.org Fri Oct 15 19:52:03 1999 From: bwinton@tor.dhs.org (Blake Winton) Date: Fri, 15 Oct 1999 14:52:03 -0400 (EDT) Subject: [Tutor] python as unix shell In-Reply-To: from "Raymund Ramos" at Oct 15, 1999 11:32:10 AM Message-ID: <199910151852.OAA10718@tor.dhs.org> > Has anyone tried having python as the login shell? > Tips and scripts (esp. for reading email using imap) would be much > appreciated. Don't. When I first started using Python, I gave it a try, but having to type "os.system(" in front of every command convinced me that I was insane, and so I switched back to zsh, like God intended. ;) Of course, I've seen reference to a PythonShell since then, which I haven't tried. Maybe it's time to start that up again. But evidently not, since I can't find the url. :P If anyone else knows where I might find it, please email me. Thanks, Blake. From neilconway@home.com Fri Oct 15 21:47:36 1999 From: neilconway@home.com (neilconway@home.com) Date: Fri, 15 Oct 1999 20:47:36 -0000 (/etc/localtime Subject: [Tutor] Keyboard input Message-ID: Hello all. 2 part question for today: 1) I want to prompt for command-line input, and process that input - similar to 'scanf' in C. 2) I want to catch keyboard input while my program is running. How would I go about doing this? Do I have to wrap everything in a large try/except statement? That seems clumsy to me. I'll illaborate on #2. Lets say my program is running. For the sake of argumet, lets say it is counting up to 100000, printing every 100th number: ### count = 0 while count < 100000: if count % 100 == 0: print count count = count + 1 ### While this program is running, if the user presses ^Z, then it, say, prints "Hello". How would I go about coding this? The example doesn't matter, I am just trying to explain what I would like to be able to do. Thanks a lot in advance, Neil Conway neilconway@home.com From joe@strout.net Fri Oct 15 21:55:12 1999 From: joe@strout.net (Joseph J. Strout) Date: Fri, 15 Oct 1999 13:55:12 -0700 Subject: [Tutor] Keyboard input In-Reply-To: References: Message-ID: At 8:47 PM +0000 10/15/99, neilconway@home.com wrote: >1) I want to prompt for command-line input, and process that input - >similar to >'scanf' in C. foo = raw_input("bar:") >2) I want to catch keyboard input while my program is running. How would I go >about doing this? Do I have to wrap everything in a large try/except >statement? >While this program is running, if the user presses ^Z, then it, say, >prints "Hello". How would I go about coding this? You don't. This is not possible in general. On certain platforms, certain key combinations may be possible to check for or trap in certain ways. But it's not a platform-independent thing, so if you must do it, specify your platform. Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From hnowak@cuci.nl Sat Oct 16 08:07:14 1999 From: hnowak@cuci.nl (Hans Nowak) Date: Sat, 16 Oct 1999 09:07:14 +0200 Subject: [Tutor] python as unix shell In-Reply-To: <199910151852.OAA10718@tor.dhs.org> References: from "Raymund Ramos" at Oct 15, 1999 11:32:10 AM Message-ID: <199910160708.HAA21909@dionysus.fw.cuci.nl> On 15 Oct 99, at 14:52, Blake Winton wrote: > > Has anyone tried having python as the login shell? > > Tips and scripts (esp. for reading email using imap) would be much > > appreciated. > > Don't. > > When I first started using Python, I gave it a try, but having to type > "os.system(" in front of every command convinced me that I was insane, and > so I switched back to zsh, like God intended. ;) > > Of course, I've seen reference to a PythonShell since then, which I > haven't tried. Maybe it's time to start that up again. But evidently > not, since I can't find the url. :P If anyone else knows where I might > find it, please email me. I doubt you have seen references to it (was probably another shell), but I wrote an experimental pysh with lots of flaws. :) In fact it just simulates a Python interpreter session, but it accepts lines starting with an @, and passes such lines to the system. So you can do >>> x = "c*" >>> @ls (executes ls and displays output) >>> @ls $x$ (executes 'ls c*') Parts between $..$ will be substituted; in this case, the variable x is taken and its contents are placed in the command. I call it flawed because of several reasons... I wrote it in 1998, and in the meantime a better Python interpreter class has shown up in the standard library, if I'm not mistaken. Furthermore, there are things to worry about like redirection, piping and other common shell thingies. Then, most importantly, there's the problem of integration. This pysh can execute commands and substitute a bit, but that's about it. It would be nice if it could, for instance, work with a list of files, and feed that list to a command rather than using literal filenames in the command. It would be nice if commands like ls could return a list with files besides dumping output of screen (this would require writing all the common commands in Python, or maybe some filter function to scan the output). It would be nice if I could write something like def ls(opt): @ls $opt$ so, with the @ embedded in a function. And there's lots more to wish for. Which makes me think I am probably not the right person to write a serious pysh; this was a nice experiment, but not much more than that. Anyone wrote a better one? --Hans Nowak (zephyrfalcon@hvision.nl) Homepage: http://fly.to/zephyrfalcon Python Snippets: http://tor.dhs.org/~zephyrfalcon/snippets/ The Purple Kookaburra Forum: http://www.delphi.com/kookaburra/ From bowman@montana.com Sat Oct 16 06:00:38 1999 From: bowman@montana.com (bowman) Date: Fri, 15 Oct 1999 23:00:38 -0600 Subject: [Tutor] Re: Keyboard input (Joseph J. Strout References: <199910160506.BAA01048@python.org> Message-ID: <38080676.F48C60E6@montana.com> > > You don't. This is not possible in general. On certain platforms, > certain key combinations may be possible to check for or trap in > certain ways. I believe the solution the original poster is looking for involves threads. Typically, a long calculation would run as a separate thread. With suitable semaphores in place, keyboard input can be handled, and a semaphore raised if the background calculation should terminate itself. Less elegant, one could just kill the thread. It is true threads may not be usable on some of the more primitive OSes. see section 7.4 of the library reference. From spiderman@nasachem.com Sat Oct 16 16:22:15 1999 From: spiderman@nasachem.com (R Parker) Date: Sat, 16 Oct 1999 10:22:15 -0500 Subject: [Tutor] Questions, Questions, Questions Message-ID: <38089827.A7C9FAB1@ghg.net> Hello again, I have a few questions for you guys: 1.In the furure I plan to program games. 2.I know Python isnt that good for making games but, 3.What programming concepts should I focus on that would help me program games in the future? 4.Thank you in advance. From joe@strout.net Sat Oct 16 20:00:09 1999 From: joe@strout.net (Joseph J. Strout) Date: Sat, 16 Oct 1999 12:00:09 -0700 Subject: [Tutor] Re: Keyboard input (Joseph J. Strout In-Reply-To: <38080676.F48C60E6@montana.com> References: <199910160506.BAA01048@python.org> Message-ID: At 10:00 PM -0700 10/15/99, bowman wrote: >It is true threads may not be usable on some of the more primitive OSes. And even on some of the more sophisticated ones. Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From thebiglebowskico@hotmail.com Sun Oct 17 06:25:49 1999 From: thebiglebowskico@hotmail.com (oliver Coady) Date: Sun, 17 Oct 1999 05:25:49 GMT Subject: [Tutor] How do you use this program? Message-ID: <19991017052550.63325.qmail@hotmail.com> This is a multi-part message in MIME format. ------=_NextPart_000_57c9c631_6a14dd4f$4931e746 Content-Type: multipart/alternative; boundary="----=_NextPart_001_63eea7c8_6a14dd4f$4931e746" ------=_NextPart_001_63eea7c8_6a14dd4f$4931e746 Content-Type: text/plain; format=flowed How do you use this program? I have this so called friend who I thought was a champ untill he started hacking into my computer and it is now giving me the shits. When i asked him how did he do it or what is his program he said he can't say. So i am asking you if you could help me with this python I now have the program so can I have a hand please? It's not like I want to get back at him but if he does it again at least I will be prepared I red the manual and I didn't understand it so that is no help i have windows95 and it is working so just anything to help me would be nice thank you Oliver ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com ------=_NextPart_001_63eea7c8_6a14dd4f$4931e746 Content-type: text/html
                            
How do you use this program?
I have this so called friend who I thought was a champ untill he started hacking into my computer and it is now giving me the shits.  When i asked him how did he do it or what is his program he said he can't say. So i am asking you if you could help me with this python I now have the program so can I have a hand please?
It's not like I want to get back at him but if he does it again at least I will be prepared
I red the manual and I didn't understand it so that is no help i have windows95 and it is working so just anything to help me would be nice
thank you
Oliver


Get Your Private, Free Email at http://www.hotmail.com
------=_NextPart_001_63eea7c8_6a14dd4f$4931e746-- ------=_NextPart_000_57c9c631_6a14dd4f$4931e746 Content-Type: image/gif Content-Transfer-Encoding: base64 Content-ID: R0lGODlhQAZlAPcAAP////7+/v39/fz8/Pv7+/r6+vn5+fj4+Pf39/b29vX19fT09PPz8/Ly8vHx 8fDw8O/v7+7u7u3t7ezs7Ovr6+rq6unp6ejo6Ofn5+bm5uXl5ePj4+Li4uHh4eDg4N/f397e3t3d 3dzc3Nvb29ra2tnZ2djY2NfX19bW1tXV1dTU1NPT09LS0tHR0dDQ0M/Pz87Ozs3NzczMzMvLy8rK ysnJycjIyMfHx8bGxsXFxcTExMPDw8LCwsHBwcDAwL+/v76+vr29vby8vLu7u7q6urm5ubi4uLe3 t7a2trW1tbS0tLOzs7KysrGxsbCwsK+vr66urq2traysrKurq6qqqqmpqaioqKenp6ampqWlpaSk pKOjo6KioqGhoaCgoJ+fn56enp2dnZycnJubm5qampmZmZiYmJeXl5aWlpWVlZSUlJOTk5KSkpGR kZCQkI+Pj46Ojo2NjYyMjIuLi4qKiomJiYiIiIeHh4aGhoWFhYSEhIODg4KCgoGBgYCAgH9/f35+ fgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAQAZlAEAI/wBvXPlC sKDBgwgTKlxY8M2XK0duvDjxoaLFixgzntj44sWNHz+OPLky8Mybk3dS3nlz5ckPihAQIABAs6bN mzhz6tzJs6fPn0CDCh1KtKjRo0iTKl3KtKnTp1CjSp1KtarVq1izat3KtavXr2DDih1LtqzZs2hz nvD4YyRBk29S/pl75wzDu3ffnIH4YyLFjIADC764cW3HGxgSx5yZtrHjx5AjS55MubLly5gza97M ubPnz6BDmxVc2PDHkCNLmlQ5909dvAb18vU7uLZtwaJz697Nu7fv38CDCx9OvLjx48jT3rZd+jBI kQO/wGVN1+TeI303Lt9+O7n37+DDi/8fT768+fPo06tHzr194OYeP8L+csR9+/X48+vfz7+///8A BijggETZZyBpJ8yn4Bc/2EfggxBGKOGEFFZo4YUY9nfghhhttOCHsN1gUYYklmjiiSimqOKKLJqI 1xN/cYggiDTCNhEGEMTU4o489ujjj0AGKeSQT9Wo0BExbuehkUwm5NILH2AgE5FUVmnllVhmqeWW wzVpJJIVLenlmE9GOSWXaKap5ppstunmmziNSaZbq90xl0NywlamlIzB6eefgAYq6KCElpdnk3p9 8URENzT60RHQvYWSna3hyeSeZxaq6aacdurpp6BidSiTsmFH22CFHXbaE25JN2lrf1j/ehCmfYZq 66245qrrrmy+EFJJKtk1KkOlZpfkgRSlGl9I0EUH0g0n4Jgpr9RWa+212GYLoEUcsYUaSdLVSalr wpJ6nbEyuqftuuy26+678Oqm5AfKettsuHHJVZ1CxZ6a7nbxBizwwAQXbDBU/wIG32n3SpcQmAkv d/DEFFds8cXrRmygmDQ2+C/GIIcs8sgkr6mxfRwPa5DHuJXs8sswxyxzhQbBeDJzCaoM4rQz9+zz z0AHLVyNNqebss56RgQTz0I37fTTUEftFdIFQfxezlQrSKvUXHft9ddg/5S1gh9FNzZDW4et9tps ty3z2bAl+lBBZ0w3bqw6p+323nz3/+33u3Dj1a92YXbbKLOt2g2rrC/2ZWatf0cu+eSUF3pD4MSe 6y93yh4uEp12q3RHS47zWfnpqKeuOpYeHVES5rFpTjiyhq8K+kknLep4jpCv7vvvwAdPIVsj1dna a1kPfuy/nT8KqV+K9S789NRXb315HHnuumr5jou8nMrffPUJMpV//fnop68+cB12/lxq+FJHbo3h i9/y+vjnr//+lN1WL8OJE9fxyrWQ+tkPMPxLoAIXyECtbIxehrEXq94iwH01RHbLO2BFGsjBDnrw g0HRWPPeF526TcpSppqdBi8Cwha68IUMXGGysgfACS6kPivcIAx3yMMeUi+HCOoIiP9wqDEfGvGI SJQcEGvzAjmxzEBJjKIUp9i1Jc4IaU+sDRW3yMUuxsyKV4PdF0SUES+a8YxoPFjRwMgtrInxIGmM oxzniC2FrFGDR3vjF6TFNDr68Y+A9NOC7sg8N+qRID+AVpR0FMhGOvKRWfKS1VBmyEOSDkrSgqQm N8nJFulskqiqpB4v+QHedfKUqEzlhDBHRMKIUo9lWowqZ0nLWubnkFVrIi5rtjtG2vKXwAzmcXZZ ENS4inGBi2UfhcnMZjqTM8RMCFzyVamxxdKXz8ymNrcJmWh+IVGsgtTnSjipcSHzUrtbJjfXyc52 iiqaxZIIR9aivcSVs5o0uqb03Mn/z376MyneHBy9NJKqepKze/hEWzr3+c+GOvShcYInBpVUO9TY E6F34iWUTAnRjnoUor56wi4NyDkImsZ54DqmSlhiqsd99KUwdWfrrgAXAsKNpBuqaFsCeIZFKVJK MQ2qUJ9JPFdR6nvJm2jERggpVl2hUZiU5VCnStVZrsWY36SmBXWG06XW7iMViZ46q0rWstIxe1g1 ofz+YNMxdfVmzeGd+cxK17r60aQSBJda9TU/tyrVijNhqF0HS9gpttFwJOTeWtu6oLdqsLCQjSwX Fea+bymWr0idj2MPKNnOetaItflfYuPHV7Zq9q9L/KxqVwtCzkUQgCWsYF/5hVog/7L2trhN4MZe m9i6yda0B9ms/XJL3OKij0NMjRRpvScs4YrPuNCNLvASJlrLqlR0d5DObFRoW+l697uTg2tBYUtB 3NUMWhl8LHjXy9624bFbyxonQ0Cp3vba975SW+LCnIeXLD4XvwAOMNDYiNfDLKiVRRSwghfsMgIP FIK6BJF/OcTgClv4Yg4+rJcmrK4Le/jDAstwGw/F4e6A+MQo1paIC6ezEgcmxTCO8a5WDMGxuXhE Ms6xjjtF4zxi8X47DrKQ/dTjV46NjDgespKXnKYiE1NETI6ylK9EEELq18iwE+yUt8zlEyHEygf0 sRgXo+Uum/nMELpLer3qzUVKFf/NcI4zgeYDZqNhGXPy5KOc98xn/oCozrv1pktEpOc+G/rQhjIS oCnqTb4srcyIjrSkeyMn+m4nwrskHUVMN+lOe/o3w1o0Qb2pqNKN9dOoTvVlqGbp9pFab6qOtawr A7dWixl2pMzkrHfNa8eIcZK3ht2esNnrYhv7K7hE0loaDetjO/vZVvHmEQRtakhD+9rYJoo3P1I8 Sw7b2tkOt7h1Iu0JriZWjKXat8fN7naLLZokKcmr6HK2XJ/a3fgOtzfrZhATYtQ16q52vgee74Da pSWsuqhWAX6oXBOb4BDHtsEVhR2QIO6g8jtnPkv38Ih7/NgG54tEOhJf5YYuoSBosje4P85yT4fc VH5pjkEl9W+NKxST9265zjv98r5MpH00vDjNMw4bh69850jnc883B3R6PsqpQ+erzUsd1aMn/epo Xjp3FYbXmV/XnAdROdbHznOJbnfN43M6SKB+XddkVOxkj/uhAwIAOw== ------=_NextPart_000_57c9c631_6a14dd4f$4931e746-- From youngdick@990.net Sun Oct 17 15:20:39 1999 From: youngdick@990.net (Dickky Young) Date: Sun, 17 Oct 1999 22:20:39 +0800 Subject: [Tutor] subscription Message-ID: <3809DB36.1B63ADD9@990.net> Thank you... From youngdick@990.net Sun Oct 17 15:38:50 1999 From: youngdick@990.net (Dickky Young) Date: Sun, 17 Oct 1999 22:38:50 +0800 Subject: [Tutor] asking someone to helo with learning python... Message-ID: <3809DF79.AF6F98B9@990.net> Hello! I have just eagerly subscribed to this mailing list. I have no programming experience but really really wanna get into it. Someone suggested me to start with python. So, could any body help me? Thank you. From DOUGS@oceanic.com Mon Oct 18 02:42:04 1999 From: DOUGS@oceanic.com (Doug Stanfield) Date: Sun, 17 Oct 1999 15:42:04 -1000 Subject: [Tutor] asking someone to helo with learning python... Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0F08C@huina.oceanic.com> When you say you have no programming experience it leaves a lot to the imagination. A good place to start would be letting us know what you want to do with programming. What led you to subscribe to this list in the first place? Do you have any experience with application scripting? Are you interested in programming and computer science, or is it a means to an end? With some of these questions answered we can help you with the first steps along the road. -Doug- > -----Original Message----- > From: Dickky Young [mailto:youngdick@990.net] > Sent: Sunday, October 17, 1999 4:39 AM > To: tutor@python.org > Subject: [Tutor] asking someone to helo with learning python... > > > Hello! > I have just eagerly subscribed to this mailing list. I have no > programming experience but really really wanna get into it. Someone > suggested me to start with python. So, could any body help me? > Thank you. > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor > From alan.gauld@bt.com Mon Oct 18 10:44:44 1999 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 18 Oct 1999 10:44:44 +0100 Subject: [Tutor] GUI's Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF5E71@mbtlipnt02.btlabs.bt.co.uk> > alan.gauld@bt.com wrote: > > > JPython implements the JAVA AWT (and Swing?) in Python > > Just to clarify, JPython is Python implemented in Java, Yep, my mistake, or at least bad wording. However I believe the concept I described is correct - you write python code which can create AWT based UI's? Alan G. From teroc@zianet.com Mon Oct 18 14:04:30 1999 From: teroc@zianet.com (K P) Date: Mon, 18 Oct 1999 08:04:30 -0500 Subject: [Tutor] Keyboard input In-Reply-To: References: Message-ID: <12593710927712@zianet.com> This leads me to a question of my own. If I wrote this as part of my program: On 15 Oct 99, at 13:55, Joseph J. Strout wrote: > At 8:47 PM +0000 10/15/99, neilconway@home.com wrote: > > >1) I want to prompt for command-line input, and process that input - > >similar to > >'scanf' in C. > > foo = raw_input("bar:") then I later wanted to 'attach' it (or wrap it) to a GUI (using Tkinter for example), would that line (foo = raw_input("bar") still accept input from the GUI partion, or would it need to be re-written to accept input from the appropriate widget? ken From warren@nightwares.com Mon Oct 18 14:29:54 1999 From: warren@nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Mon, 18 Oct 1999 08:29:54 -0500 Subject: [Tutor] How do you use this program? References: <19991017052550.63325.qmail@hotmail.com> Message-ID: <380B20D2.D5D96E05@nightwares.com> For starters, Python is NOT a language used for "cracking", or performing malicious acts on others' computers, and you will receive no help from anyone on this list in performing those acts. Second, *never send HTML formatted notes* to listservs. Everyone on the list has to open you formatted, oversized, bandwidth-wasting spam. Finally, vulgar language is entirely unwelcome. -- Warren Ockrassa | Becker Communications | http://www.beckerinc.com/ From joe@strout.net Mon Oct 18 15:45:37 1999 From: joe@strout.net (Joseph J. Strout) Date: Mon, 18 Oct 1999 07:45:37 -0700 Subject: [Tutor] Keyboard input In-Reply-To: <12593710927712@zianet.com> References: <12593710927712@zianet.com> Message-ID: At 8:04 AM -0500 10/18/99, K P wrote: > > foo = raw_input("bar:") > > >then I later wanted to 'attach' it (or wrap it) to a GUI (using Tkinter >for example), would that line (foo = raw_input("bar") still accept >input from the GUI partion, or would it need to be re-written to >accept input from the appropriate widget? Depends on the GUI. If you're using the MacPython IDE, raw_input automatically pops up a dialog box to get the user's response. But I don't know about other GUIs. Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From a.mueller@icrf.icnet.uk Mon Oct 18 17:57:18 1999 From: a.mueller@icrf.icnet.uk (Arne Mueller) Date: Mon, 18 Oct 1999 17:57:18 +0100 Subject: [Tutor] __and_ and and_ Message-ID: <380B516E.D9E474CC@icrf.icnet.uk> Hi All, I've a problem with redefining the 'and' operator for a specific class. Here's some code that does not work: class Bool: def __init__(self, list=[]): self.list = list def __and__(self, other): list = filter(lambda x, y=self.list: x in y, other.list) return Bool(list) b = Bool([1, 2, 3, 4, 5]) a = Bool([2, 3, 10, 5]) c = a and b print c.list [1, 2, 3, 4, 5] The expected result is: [2, 3, 5] The following class definition works as expected: class Bool: def __init__(self, list=[]): self.list = list def and_(self, other): list = filter(lambda x, y=self.list: x in y, other.list) return Bool(list) b = Bool([1, 2, 3, 4, 5]) a = Bool([2, 3, 10, 5]) c = a.and_(b) print c.list [2, 3, 5] Why doesn't the 'in-operator' '__and__' behave the same way as 'and_'? It'd be much better object oriented desgin to say: c = a and b instead c = a.and_(b) # ugly :-( Any explanations or better any solutions? thank you very much for your help, Arne From joe@strout.net Mon Oct 18 18:24:00 1999 From: joe@strout.net (Joseph J. Strout) Date: Mon, 18 Oct 1999 10:24:00 -0700 Subject: [Tutor] __and_ and and_ In-Reply-To: <380B516E.D9E474CC@icrf.icnet.uk> References: <380B516E.D9E474CC@icrf.icnet.uk> Message-ID: At 5:57 PM +0100 10/18/99, Arne Mueller wrote: >Why doesn't the 'in-operator' '__and__' behave the same way as 'and_'? Because __and__ is the special method for overriding '&' (bitwise and), not 'and' (Boolean and). You didn't override the latter, so it does what it normally does -- if both arguments are true, it returns the first one. I don't see a way to override the 'and' or 'or' operators... you might be stuck using & and | instead. Anybody have a better idea? Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From da@ski.org Mon Oct 18 18:25:51 1999 From: da@ski.org (David Ascher) Date: Mon, 18 Oct 1999 10:25:51 -0700 (Pacific Daylight Time) Subject: [Tutor] __and_ and and_ In-Reply-To: Message-ID: > > >Why doesn't the 'in-operator' '__and__' behave the same way as 'and_'? > > Because __and__ is the special method for overriding '&' (bitwise > and), not 'and' (Boolean and). You didn't override the latter, so it > does what it normally does -- if both arguments are true, it returns > the first one. > > I don't see a way to override the 'and' or 'or' operators... you > might be stuck using & and | instead. Anybody have a better idea? There is no way to override and or or or not. --david From da@ski.org Mon Oct 18 18:29:02 1999 From: da@ski.org (David Ascher) Date: Mon, 18 Oct 1999 10:29:02 -0700 (Pacific Daylight Time) Subject: [Tutor] __and_ and and_ In-Reply-To: Message-ID: I should amend that -- one can define a special method which determines the truth value, which is then used by the and, or and not mechanisms. See the reference manual under __nonzero__: __nonzero__ (self) Called to implement truth value testing; should return 0 or 1. When this method is not defined, __len__() is called, if it is defined (see below). If a class defines neither __len__() nor __nonzero__(), all its instances are considered true. --david From a.mueller@icrf.icnet.uk Mon Oct 18 18:32:24 1999 From: a.mueller@icrf.icnet.uk (Arne Mueller) Date: Mon, 18 Oct 1999 18:32:24 +0100 Subject: [Tutor] RE: __and__ Message-ID: <380B59A8.67C2AF72@icrf.icnet.uk> Hi All, the manual is a bit confusing, in section 3.5 ( operator -- Standard operators as functions.) it says: and_ (a, b) __and__ (in operator) (a, b) Return the bitwise and of a and b. the same as add (a, b) __add__ (in operator) (a, b) Return a + b, for a and b numbers. So I thought __and__ it'd work the same way as __add__ ... :-( Arne -- Arne Mueller Biomolecular Modelling Laboratory Imperial Cancer Research Fund 44 Lincoln's Inn Fields London WC2A 3PX, U.K. phone : +44-(0)171 2693405 | fax :+44-(0)171-269-3534 email : a.mueller@icrf.icnet.uk | http://www.icnet.uk/bmm/ From YankoC@gspinc.com Mon Oct 18 18:42:06 1999 From: YankoC@gspinc.com (Yanko, Curtis (GSP)) Date: Mon, 18 Oct 1999 13:42:06 -0400 Subject: [Tutor] __and_ and and_ Message-ID: <23EF0668B5D3D111A0CF00805F9FDC44019FDCBB@SRV_EXCH1> Huh? Isn't there an example very similar to this in PP? It uses 'Unions' and 'Intersects' but overrides __and__ and __or__ on pages 31-32. -Curt > -----Original Message----- > From: David Ascher [SMTP:da@ski.org] > Sent: Monday, October 18, 1999 1:26 PM > To: Joseph J. Strout > Cc: Arne Mueller; tutor > Subject: Re: [Tutor] __and_ and and_ > > > > > > >Why doesn't the 'in-operator' '__and__' behave the same way as 'and_'? > > > > Because __and__ is the special method for overriding '&' (bitwise > > and), not 'and' (Boolean and). You didn't override the latter, so it > > does what it normally does -- if both arguments are true, it returns > > the first one. > > > > I don't see a way to override the 'and' or 'or' operators... you > > might be stuck using & and | instead. Anybody have a better idea? > > There is no way to override and or or or not. > > --david > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From joe@strout.net Mon Oct 18 18:55:04 1999 From: joe@strout.net (Joseph J. Strout) Date: Mon, 18 Oct 1999 10:55:04 -0700 Subject: [Tutor] RE: __and__ In-Reply-To: <380B59A8.67C2AF72@icrf.icnet.uk> References: <380B59A8.67C2AF72@icrf.icnet.uk> Message-ID: At 6:32 PM +0100 10/18/99, Arne Mueller wrote: >__and__ (in operator) (a, b) > Return the bitwise and of a and b. >__add__ (in operator) (a, b) > Return a + b, for a and b numbers. > >So I thought __and__ it'd work the same way as __add__ ... :-( It does. Perhaps you don't understand what "bitwise and" means? And that the operator for "bitwise and" is "&" rather than "and"? Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From a.mueller@icrf.icnet.uk Mon Oct 18 18:56:29 1999 From: a.mueller@icrf.icnet.uk (Arne Mueller) Date: Mon, 18 Oct 1999 18:56:29 +0100 Subject: [Tutor] RE: __and__ References: <380B59A8.67C2AF72@icrf.icnet.uk> Message-ID: <380B5F4D.4716C645@icrf.icnet.uk> "Joseph J. Strout" wrote: > > At 6:32 PM +0100 10/18/99, Arne Mueller wrote: > > >__and__ (in operator) (a, b) > > Return the bitwise and of a and b. > >__add__ (in operator) (a, b) > > Return a + b, for a and b numbers. > > > >So I thought __and__ it'd work the same way as __add__ ... :-( > > It does. Perhaps you don't understand what "bitwise and" means? And > that the operator for "bitwise and" is "&" rather than "and"? > Yes, but how can you modify the bitwise operator '&' ? As mentioned in some of the emails before changeing '&' would have an effect on '__and__' as well, wouldn't it? Arne From joe@strout.net Mon Oct 18 19:11:20 1999 From: joe@strout.net (Joseph J. Strout) Date: Mon, 18 Oct 1999 11:11:20 -0700 Subject: [Tutor] RE: __and__ In-Reply-To: <380B5F4D.4716C645@icrf.icnet.uk> References: <380B59A8.67C2AF72@icrf.icnet.uk> <380B5F4D.4716C645@icrf.icnet.uk> Message-ID: At 6:56 PM +0100 10/18/99, Arne Mueller wrote: >Yes, but how can you modify the bitwise operator '&' ? By overriding __and__. > As mentioned in >some of the emails before changeing '&' would have an effect on >'__and__' as well, wouldn't it? '&' and '__and__' are the same function -- one is an operator, and one is a method, and they are One. It's exactly analogous to '+' and '__add__'. operator method operation -------- ------ --------- + __add__ addition & __and__ bitwise and Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe@strout.net http://www.strout.net | `------------------------------------------------------------------' From Alexandre Passos" This is a multi-part message in MIME format. ------=_NextPart_000_001F_01BF19AA.672CFEC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How can I save some data achieved in some program into other file? ex: nm =3D raw_input("Name:") age =3D input("Age:") hob =3D raw_input("Favourite hobby:") persnon =3D """Name:%s Age:%d Favourite Hobby: %s""" ... how can I save some object on a separate file for future reference? ------=_NextPart_000_001F_01BF19AA.672CFEC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
How can I save some data achieved in = some=20 program into other file?
ex:
nm =3D raw_input("Name:")
age =3D input("Age:")
hob =3D raw_input("Favourite = hobby:")
persnon =3D """Name:%s
Age:%d
Favourite Hobby: %s"""
 
 
 
...
how can I save some object on a separate file for = future=20 reference?
 
------=_NextPart_000_001F_01BF19AA.672CFEC0-- From deirdre@deirdre.net Mon Oct 18 23:40:48 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 18 Oct 1999 15:40:48 -0700 (PDT) Subject: [Tutor] Saving data In-Reply-To: <002201bf19bb$2bb193e0$a25bdfc8@the-user> Message-ID: On Mon, 18 Oct 1999, Alexandre Passos wrote: > How can I save some data achieved in some program into other file? > ex: > > nm = raw_input("Name:") > age = input("Age:") > hob = raw_input("Favourite hobby:") > persnon = """Name:%s > Age:%d > Favourite Hobby: %s""" One simple way: f = open("savefile", "w+") z = "Name:" + nm + '\n' f.write(z) (etc) f.close() That way, each variable is listed on each line. Otherwise you have to make sure there's no returns in there. :) To retrieve, use f.read() or f.readline() after opening it for reading (the above example would be opening it for writing). -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From Emile van Sebille" Message-ID: <00bc01bf19cc$840e0f80$01ffffc0@worldnet.att.net> Arne, A little playing from where you started got me to this. You can then write c = a + b # to show the union --- or --- c = a - b # for the intersection #------------------- class Bool: def __init__(self, list=[]): self.list = list def __add__(self, other): list = self.list + filter(lambda x, y=self.list: x not in y, other.list) return Bool(list) def __sub__(self, other): list = filter(lambda x, y=self.list: x in y, other.list) return Bool(list) b = Bool([1, 2, 3, 4, 5]) a = Bool([2, 3, 10, 5]) print (a + b).list print (a - b).list #----------results [2, 3, 10, 5, 1, 4] [2, 3, 5] Emile van Sebille emile@fenx.com ------------------- ----- Original Message ----- From: Arne Mueller To: tutor Sent: Monday, October 18, 1999 9:57 AM Subject: [Tutor] __and_ and and_ > Hi All, > > I've a problem with redefining the 'and' operator for a specific class. > > Here's some code that does not work: > > class Bool: > > def __init__(self, list=[]): > self.list = list > > def __and__(self, other): > list = filter(lambda x, y=self.list: x in y, other.list) > return Bool(list) > > b = Bool([1, 2, 3, 4, 5]) > a = Bool([2, 3, 10, 5]) > c = a and b > print c.list > [1, 2, 3, 4, 5] > > The expected result is: > [2, 3, 5] > > The following class definition works as expected: > > class Bool: > > def __init__(self, list=[]): > self.list = list > > def and_(self, other): > list = filter(lambda x, y=self.list: x in y, other.list) > return Bool(list) > > b = Bool([1, 2, 3, 4, 5]) > a = Bool([2, 3, 10, 5]) > c = a.and_(b) > print c.list > [2, 3, 5] > > Why doesn't the 'in-operator' '__and__' behave the same way as 'and_'? > > It'd be much better object oriented desgin to say: > > c = a and b > > instead > > c = a.and_(b) # ugly > > > Any explanations or better any solutions? > > thank you very much for your help, > > Arne > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor > > From alan.gauld@bt.com Tue Oct 19 09:58:34 1999 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 19 Oct 1999 09:58:34 +0100 Subject: [Tutor] Saving data Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF5E7C@mbtlipnt02.btlabs.bt.co.uk> See my online tutorial at: http://members.xoom.com/alan_gauld/tutor/tutindex.htm Look in the chapter on 'Handling Files', specifically the example of creating a COPY command. Alan G. > -----Original Message----- > From: Alexandre Passos [mailto:atp@bahianet.com.br] > Sent: Monday, October 18, 1999 11:50 PM > To: TUtor > Subject: [Tutor] Saving data > > > How can I save some data achieved in some program into other file? > ex: > > nm = raw_input("Name:") > age = input("Age:") > hob = raw_input("Favourite hobby:") > persnon = """Name:%s > Age:%d > Favourite Hobby: %s""" > > > > ... > how can I save some object on a separate file for future reference? > > From bryan.hann@pobox.com Tue Oct 19 11:06:46 1999 From: bryan.hann@pobox.com (Bryan Hann) Date: Tue, 19 Oct 1999 18:06:46 +0800 Subject: [Tutor] __and_ and and_ References: <380B516E.D9E474CC@icrf.icnet.uk> <00bc01bf19cc$840e0f80$01ffffc0@worldnet.att.net> Message-ID: <380C42B6.97263EAF@pobox.com> Emile van Sebille wrote: > You can then write > c = a + b # to show the union > --- or --- > c = a - b # for the intersection Yes, though I would strongly recommend a * b for intersection, and reserve a - b for non-commutative set (or list) difference. >>>a=mySet([1,2,3,4,5]) >>>b=mySet([3,4,5,6,7]) >>>print a*b, a-b, b-a [3,4,5] [1,2] [6,7] (assuming appropriate definition of mySet.__repr__ of course!) --Bryan Hann From a.mueller@icrf.icnet.uk Tue Oct 19 11:56:33 1999 From: a.mueller@icrf.icnet.uk (Arne Mueller) Date: Tue, 19 Oct 1999 11:56:33 +0100 Subject: [Tutor] RE: __and__ Message-ID: <380C4E61.3F38F4A@icrf.icnet.uk> Emile van Sebille wrote: > > Arne, > > A little playing from where you started got me to this. > > You can then write > > c = a + b # to show the union > --- or --- > c = a - b # for the intersection > > #------------------- > > class Bool: > > def __init__(self, list=[]): > self.list = list > > def __add__(self, other): > list = self.list + filter(lambda x, y=self.list: x not in y, > other.list) > return Bool(list) > > def __sub__(self, other): > list = filter(lambda x, y=self.list: x in y, other.list) > return Bool(list) > > b = Bool([1, 2, 3, 4, 5]) > a = Bool([2, 3, 10, 5]) > > print (a + b).list > > print (a - b).list > > #----------results > > [2, 3, 10, 5, 1, 4] > [2, 3, 5] > > Emile van Sebille > emile@fenx.com > ------------------- > > ----- Original Message ----- > From: Arne Mueller > To: tutor > Sent: Monday, October 18, 1999 9:57 AM > Subject: [Tutor] __and_ and and_ > > > Hi All, > > > > I've a problem with redefining the 'and' operator for a specific > class. > > > > Here's some code that does not work: > > > > class Bool: > > > > def __init__(self, list=[]): > > self.list = list > > > > def __and__(self, other): > > list = filter(lambda x, y=self.list: x in y, other.list) > > return Bool(list) > > > > b = Bool([1, 2, 3, 4, 5]) > > a = Bool([2, 3, 10, 5]) > > c = a and b > > print c.list > > [1, 2, 3, 4, 5] > > > > The expected result is: > > [2, 3, 5] > > > > The following class definition works as expected: > > > > class Bool: > > > > def __init__(self, list=[]): > > self.list = list > > > > def and_(self, other): > > list = filter(lambda x, y=self.list: x in y, other.list) > > return Bool(list) > > > > b = Bool([1, 2, 3, 4, 5]) > > a = Bool([2, 3, 10, 5]) > > c = a.and_(b) > > print c.list > > [2, 3, 5] > > > > Why doesn't the 'in-operator' '__and__' behave the same way as 'and_'? > > > > It'd be much better object oriented desgin to say: > > > > c = a and b > > > > instead > > > > c = a.and_(b) # ugly > Hi Emile, thanks for your solution. The problem is that and, or, not sounds more natural for my problem than +, - . In practice: I have to catinate the results of SQL queries. Say A and B are lists of names returned by independant SQL queries then I want to get the intersection with 'AND' C = A and B or the any existing name with C = A or B or the xor with C = A bot B Anyway, I'm a little disappointed because that's againsts philosophy od object oriented programming since an object should be allowed to defined it's complete own world. tell me if I'm wrong, Arne -- Arne Mueller Biomolecular Modelling Laboratory Imperial Cancer Research Fund 44 Lincoln's Inn Fields London WC2A 3PX, U.K. phone : +44-(0)171 2693405 | fax :+44-(0)171-269-3534 email : a.mueller@icrf.icnet.uk | http://www.icnet.uk/bmm/ From Emile van Sebille" Message-ID: <08a001bf1a3d$47b47800$01ffffc0@worldnet.att.net> Arne, I agree that the object ought to define itself, but I don't think you really want to mess with the keywords 'and', 'not' or 'or'. I played with trying to define AND, OR and NOT as binding with *, -, +, but couldn't get it to work. I suspect that bytecodehacks may provide an answer, but I have no direct experience with it. If you use unbound methods, you could use AND(a,b) or OR(a,b), etc. I think that gets close to your intent and is certainly not hard on the eyes. Emile van Sebille emile@fenx.com ------------------- #------start code------ class Bool: def __init__(self, list=[]): self.list = list def __add__(self, other): list = self.list + filter(lambda x, y=self.list: x not in y, other.list) return Bool(list) def __sub__(self, other): list = filter(lambda x, y=(self * other).list: x not in y, (self + other).list) return Bool(list) def __mul__(self, other): list = filter(lambda x, y=self.list: x in y, other.list) return Bool(list) def AND(a,b): c = a*b return c b = Bool([1, 2, 3, 4, 5]) a = Bool([2, 3, 10, 5]) print '(a*b): ',(a * b).list print ' AND : ',AND(a,b).list print '(a+b): ',(a + b).list print '(a-b): ',(a - b).list #-------end code------- > > thanks for your solution. The problem is that and, or, not sounds more > natural for my problem than +, - . > > In practice: I have to catinate the results of SQL queries. Say A and B > are lists of names returned by independant SQL queries then I want to > get the intersection with 'AND' > > C = A and B > > or the any existing name with > > C = A or B > > or the xor with > > C = A bot B > > Anyway, I'm a little disappointed because that's againsts philosophy od > object oriented programming since an object should be allowed to defined > it's complete own world. > > tell me if I'm wrong, > > Arne > > From tim_one@email.msn.com Wed Oct 20 01:03:42 1999 From: tim_one@email.msn.com (Tim Peters) Date: Tue, 19 Oct 1999 20:03:42 -0400 Subject: [Tutor] RE: __and__ In-Reply-To: <380C4E61.3F38F4A@icrf.icnet.uk> Message-ID: <000201bf1a8e$92215740$252d153f@tim> [Arne Mueller] > ... > The problem is that and, or, not sounds more natural for my problem > than +, - . Overload & def__and__(self, other): ... | def __or__(self, other): ... ~ def __invert__(self): ... ^ def __xor__(self, other): ... "and" and "or" are control structures in Python, not operators. That's why you can't overload them. they-generate-branches-ly y'rs - tim From jgg813@bse.bg Wed Oct 20 16:40:44 1999 From: jgg813@bse.bg (Jakomo Mariachi) Date: Wed, 20 Oct 1999 18:40:44 +0300 Subject: [Tutor] Please Help me with this. Message-ID: <380DE27C.296E71B1@bse.bg> Hello ! I have just eagerly subscribed to this mailing list. I have not a big programming experience with Python, but really wanna learn it. When I read this : ( in the manual ) a, b = 0, 1 while b < 10: print b a, b = b, a+b and the outcome 1 1 2 3 5 8 13 21 . . . . . - I can't understand how it work. When I try this: a = 0 b = 0 while b < 10: print b a = b b = a + b the outcome is one, but : a = 0 b = 1 while b < 10: print b b = a + b a = b the outcome is different. So , please help me ! Thank you in advance ! --- Jako --- From DOUGS@oceanic.com Wed Oct 20 20:22:57 1999 From: DOUGS@oceanic.com (Doug Stanfield) Date: Wed, 20 Oct 1999 09:22:57 -1000 Subject: [Tutor] Please Help me with this. Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0F09A@huina.oceanic.com> For this type of thing you need to think like the computer. This example initializes some variables and then loops using the 'while' construct. Start going through the statements in order, writing down the value of each of the variables at each step. That should help your understanding of the output. If there are specific statements here that you don't understand or can't figure out what they do, first check the tutorial and the library reference, then ask more specific questions on the list. By the way, this is a troubleshooting technique that you will use in virtually every program you write so its a good discipline to train yourself in. Definately this will be time well spent. -Doug- > -----Original Message----- > From: Jakomo Mariachi [mailto:jgg813@bse.bg] > Sent: Wednesday, October 20, 1999 5:41 AM > To: tutor@python.org > Subject: [Tutor] Please Help me with this. > > > > Hello ! > > I have just eagerly subscribed to this mailing list. > I have not a big programming experience with Python, but really wanna > learn it. > > When I read this : ( in the manual ) > > a, b = 0, 1 > while b < 10: > print b > a, b = b, a+b > > and the outcome 1 1 2 3 5 8 13 21 . . . . . - I can't > understand how it work. > > > When I try this: > a = 0 > b = 0 > while b < 10: > print b > a = b > b = a + b > the outcome is one, but : > a = 0 > b = 1 > while b < 10: > print b > b = a + b > a = b > the outcome is different. > > So , please help me ! > Thank you in advance ! > > --- Jako --- > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor > From sven@gwelt.de Thu Oct 21 16:09:10 1999 From: sven@gwelt.de (Sven Goldschmidt) Date: Thu, 21 Oct 1999 17:09:10 +0200 Subject: [Tutor] Question concerning Python Documentation Tools Message-ID: <380F2C96.DF9166B@gwelt.de> I want to create a HTML-Documentation for my Python-Project. Having read the Python Tutorial and the conventions about the Documentation Strings (4.7.5), I thought there has to be a program like "javadoc" for JAVA that automatically creates HTML-Documents. In the Python Documentation there is some information on documenting Python but I did not find any program or source to create a documentation. Is there a program / script for creating Python Documentation? I am using Windows NT with Python 1.5.2. Thanks. SVEN. From teroc@zianet.com Thu Oct 21 18:34:40 1999 From: teroc@zianet.com (K P) Date: Thu, 21 Oct 1999 12:34:40 -0500 Subject: [Tutor] Please Help me with this. In-Reply-To: <380DE27C.296E71B1@bse.bg> Message-ID: <17300640615174@zianet.com> Sometimes I have a difficult time visualizing expressions in programs. Usually it is because I do not think the same way my computer (or even my programs :) think. In those cases, I attempt to make my program more verbose, thus I can see what it is doing. Try adding some print statements that show what each variable is at each stage, like this: a = 0 b = 1 while b < 10: print b b = a + b print 'b is now:', b print 'a is now:', a a = b print 'a = b is:', a That way you can learn how the assignment works, and at each stage what is occuring. That to me is a good learning aid. Of course don't go overboard with it. Ken On 20 Oct 99, at 18:40, Jakomo Mariachi wrote: > > Hello ! > > I have just eagerly subscribed to this mailing list. > I have not a big programming experience with Python, but really wanna > learn it. > > When I read this : ( in the manual ) > > a, b = 0, 1 > while b < 10: > print b > a, b = b, a+b > > and the outcome 1 1 2 3 5 8 13 21 . . . . . - I can't > understand how it work. > > > When I try this: > a = 0 > b = 0 > while b < 10: > print b > a = b > b = a + b > the outcome is one, but : > a = 0 > b = 1 > while b < 10: > print b > b = a + b > a = b > the outcome is different. > > So , please help me ! > Thank you in advance ! > > --- Jako --- > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From wilson@chemsun.chem.umn.edu Fri Oct 22 00:13:12 1999 From: wilson@chemsun.chem.umn.edu (Tim Wilson) Date: Thu, 21 Oct 1999 18:13:12 -0500 (CDT) Subject: [Tutor] fortify this code... Message-ID: Hi everyone, I'm working on a little portal-like feature for my Zope site. I'm going to download the local weather conditions from the nearest National Weather Service station and make them available for display on our Web page. This is based on the pyWeather program. Here's the code: --snip-- #!/usr/local/bin/python ################################################################## # This program gets the current weather conditions from NOAA. # # Change the 'metar_id' variable to match your nearest METAR station. # Check http://www.nws.noaa.gov/oso/siteloc.shtml for a listing # # This code for this program was derived in part from pyWeather by # "The Almighty Groundhog" (groundhog@linuxfreak.com) # # Current version by Tim Wilson (wilson@chem.umn.edu) ################################################################## from ftplib import * import string, os, getpass from sys import * # Do some variable inits noaa_url = "weather.noaa.gov" metar_dir = "/data/observations/metar/decoded/" station_id = 'KSGS' # South St. Paul, MN, USA tmp = '.metar_data' # Get .pyweatherdat file ready if os.path.exists(tmp) == 1: os.remove(tmp) data = open(tmp, 'w') # Do the FTP get ftp = FTP(noaa_url) ftp.login() ftp.cwd(metar_dir) ftp.retrbinary('RETR ' + station_id + '.TXT', data.write) ftp.quit data.close() --snip-- This code works well (assuming your interested in the local weather in St. Paul, MN :-). It crashes and burns, however, if the NOAA ftp server is busy or otherwise unavailable. How can I make this script retry the connection a few times and failing that, exit gracefully. I also notice that I'll have to change it so that the old file isn't overwritten until the new data is available. Thanks for any advice that any of you might have. -Tim -- Timothy Wilson | "The faster you | Check out: Henry Sibley H.S. | go, the shorter | http://slashdot.org/ W. St. Paul, MN, USA | you are." | http://linux.com/ wilson@chem.umn.edu | -Einstein | http://www.mn-linux.org/ From deirdre@deirdre.net Fri Oct 22 00:21:50 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 21 Oct 1999 16:21:50 -0700 (PDT) Subject: [Tutor] fortify this code... In-Reply-To: Message-ID: On Thu, 21 Oct 1999, Tim Wilson wrote: > # Do the FTP get > ftp = FTP(noaa_url) > ftp.login() > ftp.cwd(metar_dir) > ftp.retrbinary('RETR ' + station_id + '.TXT', data.write) > ftp.quit You need to put a try: before the ftp = line to help bulletproof it. > It crashes and burns, however, if the NOAA ftp server is busy or otherwise > unavailable. How can I make this script retry the connection a few times > and failing that, exit gracefully. I also notice that I'll have to change > it so that the old file isn't overwritten until the new data is available. > Thanks for any advice that any of you might have. You probably want a while loop around the ftp part that will retry the connection a few times. You may also wish to cache it locally. :) If it's available via http AND you have a caching proxy like squid, your reliability will improve. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From alan.gauld@bt.com Fri Oct 22 11:04:03 1999 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 22 Oct 1999 11:04:03 +0100 Subject: [Tutor] Please Help me with this. Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF5E89@mbtlipnt02.btlabs.bt.co.uk> > > a, b = 0, 1 > > while b < 10: > > print b > > a, b = b, a+b > > When I try this: > > a = 0 > > b = 0 > > while b < 10: > > print b > > a = b > > b = a + b This is not equivalenmt to the above. You must do: a = 0 b = 1 while b< 10 print b c = a # need a temporary variable a = b # coz we change a here b = c+b # and need to use the original value of a here Alan G. From gerrit.sere@lin.vlaanderen.be Fri Oct 22 11:31:55 1999 From: gerrit.sere@lin.vlaanderen.be (Sere Gerrit) Date: Fri, 22 Oct 1999 12:31:55 +0200 Subject: [Tutor] How to do it ??? Message-ID: <38103D1A.686E8CD4@lin.vlaanderen.be> Hi, I have the following problem. I want to go to another server (info). On that server there are a lot of users. I want to check if they use there home directory's. For doing this I need root account. How must I program this ?? Is it possible to give an example (little) ?? #! /usr/bin/python import os # search users on server linfo lijst_gebruikers = os.popen("rsh linfo ls /export/home").readlines() commando = "rsh linfo find /export/home/" for pipo in lijst_gebruikers: voeruit = commando + pipo + "-mtime -60" lijst = os.popen(commando).readlines() print pipo,len(lijst) Thankx, From deirdre@deirdre.net Fri Oct 22 18:08:23 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Fri, 22 Oct 1999 10:08:23 -0700 (PDT) Subject: [Tutor] How to do it ??? In-Reply-To: <38103D1A.686E8CD4@lin.vlaanderen.be> Message-ID: On Fri, 22 Oct 1999, Sere Gerrit wrote: > I have the following problem. I want to go to another server (info). On > that server there are a lot of users. I want to check if they use there > home directory's. For doing this I need root account. How must I program > this ?? Is it possible to give an example (little) ?? Generally speaking, rsh is unavailable as root (for very good reasons). -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From jgg813@bse.bg Sun Oct 24 20:32:04 1999 From: jgg813@bse.bg (Jakomo Mariachi) Date: Sun, 24 Oct 1999 22:32:04 +0300 Subject: [Tutor] How can ... ? Message-ID: <38135EB4.6F4D5F9E@bse.bg> Hi All , I have one guestion. How can I do this with Python : h = ' date | cut -c12-13 ' Thank you. From parkw@better.net Sun Oct 24 22:15:31 1999 From: parkw@better.net (William Park) Date: Sun, 24 Oct 1999 17:15:31 -0400 Subject: [Tutor] How can ... ? In-Reply-To: <38135EB4.6F4D5F9E@bse.bg> References: <38135EB4.6F4D5F9E@bse.bg> Message-ID: <19991024171531.A14223@better.net> On Sun, Oct 24, 1999 at 10:32:04PM +0300, Jakomo Mariachi wrote: > Hi All , > > I have one guestion. > How can I do this with Python : > h = ' date | cut -c12-13 ' 1. os.system('date | cut -c12-13') ;) 2. h = time.ctime(time.time()) # date h = h[11:13] # cut -c12-13 (python starts at 0) > Thank you. You are most welcome. William From arcege@shore.net Sun Oct 24 22:29:27 1999 From: arcege@shore.net (Michael P. Reilly) Date: Sun, 24 Oct 1999 17:29:27 -0400 (EDT) Subject: [Tutor] How can ... ? In-Reply-To: <38135EB4.6F4D5F9E@bse.bg> from Jakomo Mariachi at "Oct 24, 99 10:32:04 pm" Message-ID: <199910242129.RAA24002@northshore.shore.net> [Charset koi8-r unsupported, filtering to ASCII...] > I have one guestion. > How can I do this with Python : > h = ' date | cut -c12-13 ' I assume that you are talking about backquotes instead of forward single quotes. You will want to read the Library Reference Manual on the time module, but... >>> import time >>> now = time.localtime(time.time()) >>> now (1999, 10, 24, 17, 22, 41, 6, 297, 1) >>> h = now[3] >>> h1 = time.strftime('%H', now) >>> h, h1 17, '17' If you really must use a pipeline (which is less efficient), then you can use: >>> import os >>> h = os.popen('date').readline()[11:13] -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From th@alley.org Sun Oct 24 22:33:36 1999 From: th@alley.org (Trond Hanssen) Date: 24 Oct 1999 23:33:36 +0200 Subject: [Tutor] How can ... ? In-Reply-To: <38135EB4.6F4D5F9E@bse.bg> References: <38135EB4.6F4D5F9E@bse.bg> Message-ID: * Jakomo Mariachi | How can I do this with Python : | h = ' date | cut -c12-13 ' Something along the lines of ----- cut ----- import time h = time.strftime("%H", time.localtime(time.time())) ----- cut ----- perhaps, assuming that it is the hour you want. See section 6.3 in the Library Reference. -- From vball@erols.com Tue Oct 26 18:06:53 1999 From: vball@erols.com (Michael Perry) Date: Tue, 26 Oct 1999 13:06:53 -0400 Subject: [Tutor] import calendar not working Message-ID: <3815DFAD.AE2CBED9@erols.com> I can't figure out why this works: The filename is "cal.py" #!/usr/bin/python print "Content-type: text/html" # HTML is following print # blank line, end of headers import sys # import calendar print sys.path # calendar.prmonth(1999, 10) $ ./cal.py Content-type: text/html ['.', '/usr/lib/python1.5/', '/usr/lib/python1.5/test', '/usr/lib/python1.5/plat-linux-i386', '/usr/lib/python1.5/lib-tk', '/usr/lib/python1.5/lib-dynload', '/usr/lib/python1.5/site-packages', '/usr/lib/python1.5/site-packages/HTMLgen', '/usr/lib/python1.5/site-packages/NumPy', '/usr/lib/python1.5/site-packages/PIL', '/usr/lib/python1.5/site-packages/idle'] [mike@spin cgi-bin]$ And this does not work?: #!/usr/bin/python print "Content-type: text/html" # HTML is following print # blank line, end of headers import sys import calendar print sys.path $./cal.py Content-type: text/html Traceback (innermost last): File "./cal.py", line 8, in ? import calendar File "/home/httpd/cgi-bin/calendar.py", line 15, in ? import HTMLcalendar File "/usr/lib/python1.5/site-packages/HTMLgen/HTMLcalendar.py", line 25, in ? from calendar import day_name, month_name, mdays, weekday ImportError: cannot import name day_name [mike@spin cgi-bin]$ pwd /home/httpd/cgi-bin From hweaver@pdx.oneworld.com Tue Oct 26 17:18:57 1999 From: hweaver@pdx.oneworld.com (Harold Weaver) Date: Tue, 26 Oct 1999 16:18:57 +0000 Subject: [Tutor] import calendar not working References: <3815DFAD.AE2CBED9@erols.com> Message-ID: <3815D470.534DE636@pdx.oneworld.com> These both work the same for me using Python 1.5.2 and idle on Win98. Also from command line. -- Hal Michael Perry wrote: > I can't figure out why this works: > > The filename is "cal.py" > #!/usr/bin/python > > print "Content-type: text/html" # HTML is following > print # blank line, end of headers > > import sys > # import calendar > > print sys.path > # calendar.prmonth(1999, 10) > > $ ./cal.py > Content-type: text/html > > ['.', '/usr/lib/python1.5/', '/usr/lib/python1.5/test', > '/usr/lib/python1.5/plat-linux-i386', '/usr/lib/python1.5/lib-tk', > '/usr/lib/python1.5/lib-dynload', '/usr/lib/python1.5/site-packages', > '/usr/lib/python1.5/site-packages/HTMLgen', > '/usr/lib/python1.5/site-packages/NumPy', > '/usr/lib/python1.5/site-packages/PIL', > '/usr/lib/python1.5/site-packages/idle'] > [mike@spin cgi-bin]$ > > And this does not work?: > > #!/usr/bin/python > > print "Content-type: text/html" # HTML is following > print # blank line, end of headers > > import sys > import calendar > > print sys.path > > $./cal.py > Content-type: text/html > > Traceback (innermost last): > File "./cal.py", line 8, in ? > import calendar > File "/home/httpd/cgi-bin/calendar.py", line 15, in ? > import HTMLcalendar > File "/usr/lib/python1.5/site-packages/HTMLgen/HTMLcalendar.py", line > 25, in ? > from calendar import day_name, month_name, mdays, weekday > ImportError: cannot import name day_name > [mike@spin cgi-bin]$ pwd > /home/httpd/cgi-bin > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From vball@erols.com Wed Oct 27 00:24:40 1999 From: vball@erols.com (Michael Perry) Date: Tue, 26 Oct 1999 19:24:40 -0400 Subject: [Fwd: [Tutor] import calendar not working] Message-ID: <38163838.DC347ED4@erols.com> This is a multi-part message in MIME format. --------------6029D8F58CB429C034E37EFD Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I was under the (apparently mistaken) impression that calendar.py was part of the standard release. I did not develope it. If it is not part of the standard release it may have come with HTMLgen, although HTMLgen seems to install itself in pythton1.5/site-packages. Comparing the dates it looks like that module was installed the same time as everything else. I've attached a script where I've copied the file to /tmp, run it from my current dir, then run it from /tmp. It works in /tmp but not the current dir. It seems like its my environment but I don't see where. I've attached calendar.py also. The program runs fine from my home directory [mike@spin python1.5]$ ls -ld c* -rw-r--r-- 1 root root 4442 Mar 21 1999 calendar.py -rw-r--r-- 1 root root 6033 Mar 21 1999 calendar.pyc -rw-r--r-- 1 root root 5658 Mar 21 1999 calendar.pyo -rwxr-xr-x 1 root root 45830 Mar 21 1999 cgi.py* -rw-r--r-- 1 root root 52720 Mar 21 1999 cgi.pyc -rw-r--r-- 1 root root 50758 Mar 21 1999 cgi.pyo -rw-r--r-- 1 root root 2090 Mar 21 1999 cmd.py Here's the version information: Python 1.5.1 (#1, Mar 21 1999, 22:49:36) [GCC egcs-2.91.66 19990314/Li on linux-i386 [mike@spin mike]$ more cal.py #!/usr/bin/python print "Content-type: text/html" # HTML is following print # blank line, end of headers import calendar import HTMLcalendar calendar.prmonth(1999, 10) [mike@spin mike]$ ./cal.py Content-type: text/html October 1999 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [mike@spin mike]$ --------------6029D8F58CB429C034E37EFD Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline Received: from mx01.erols.com ([207.172.3.241]) by mta3.mail.erols.net (InterMail v03.02.07.03 118-128) with ESMTP id <19991026220405.KWQT2047@mx01.erols.com> for ; Tue, 26 Oct 1999 18:04:05 -0400 Received: from sundial.hujima (sundial.ma.huji.ac.il [132.64.32.5]) by mx01.erols.com (8.8.8-970530/MX-980323-gjp) with ESMTP id SAA06153 for ; Tue, 26 Oct 1999 18:04:00 -0400 (EDT) Received: from localhost (moshez@localhost) by sundial.hujima (8.9.1b+Sun/8.9.3) with SMTP id AAA02803 for ; Wed, 27 Oct 1999 00:01:38 +0200 (IST) Date: Wed, 27 Oct 1999 00:01:38 +0200 (IST) From: Moshe Zadka X-Sender: moshez@sundial Reply-To: Moshe Zadka To: Michael Perry Subject: Re: [Tutor] import calendar not working In-Reply-To: <3815DFAD.AE2CBED9@erols.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Mozilla-Status2: 00000000 On Tue, 26 Oct 1999, Michael Perry wrote: > The filename is "cal.py" > #!/usr/bin/python > > print "Content-type: text/html" # HTML is following > print # blank line, end of headers > > import sys > # import calendar > > print sys.path > # calendar.prmonth(1999, 10) > > $ ./cal.py > Content-type: text/html > > ['.', '/usr/lib/python1.5/', '/usr/lib/python1.5/test', > '/usr/lib/python1.5/plat-linux-i386', '/usr/lib/python1.5/lib-tk', > '/usr/lib/python1.5/lib-dynload', '/usr/lib/python1.5/site-packages', > '/usr/lib/python1.5/site-packages/HTMLgen', > '/usr/lib/python1.5/site-packages/NumPy', > '/usr/lib/python1.5/site-packages/PIL', > '/usr/lib/python1.5/site-packages/idle'] > [mike@spin cgi-bin]$ > > > And this does not work?: > > #!/usr/bin/python > > print "Content-type: text/html" # HTML is following > print # blank line, end of headers > > import sys > import calendar > > print sys.path > > > $./cal.py > Content-type: text/html > > Traceback (innermost last): > File "./cal.py", line 8, in ? > import calendar > File "/home/httpd/cgi-bin/calendar.py", line 15, in ? > import HTMLcalendar > File "/usr/lib/python1.5/site-packages/HTMLgen/HTMLcalendar.py", line > 25, in ? > from calendar import day_name, month_name, mdays, weekday > ImportError: cannot import name day_name The trouble seem to be with some non-standard Python module "calendar". It's hard to debug code you don't show us -- Moshe Zadka . INTERNET: Learn what you know. Share what you don't. --------------6029D8F58CB429C034E37EFD Content-Type: text/plain; charset=us-ascii; name="calprob" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="calprob" Script started on Tue Oct 26 19:12:39 1999 [httpd@spin cgi-bin]$ pwd /home/httpd/cgi-bin [httpd@spin cgi-bin]$ cp cal.py /tmp [httpd@spin cgi-bin]$ cat cal.py #!/usr/bin/python print "Content-type: text/html" # HTML is following print # blank line, end of headers import calendar import HTMLgen calendar.prmonth(1999, 10) [httpd@spin cgi-bin]$ ./cal.py Content-type: text/html Traceback (innermost last): File "./cal.py", line 7, in ? import calendar File "/home/httpd/cgi-bin/calendar.py", line 15, in ? import HTMLcalendar File "/usr/lib/python1.5/site-packages/HTMLgen/HTMLcalendar.py", line 25, in ? from calendar import day_name, month_name, mdays, weekday ImportError: cannot import name day_name [httpd@spin cgi-bin]$ /tmp/cal.py Content-type: text/html October 1999 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [httpd@spin cgi-bin]$ exit Script done on Tue Oct 26 19:13:27 1999 --------------6029D8F58CB429C034E37EFD Content-Type: text/plain; charset=us-ascii; name="calendar.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="calendar.py" ############################### # Calendar printing functions # ############################### # Revision 2: uses funtions from built-in time module # Import functions and variables from time module from time import gmtime, localtime, mktime, asctime, ctime # Exception raised for bad input (with string parameter for details) error = 'calendar.error' # Note when comparing these calendars to the ones printed by cal(1): # My calendars have Monday as the first day of the week, and Sunday as # the last! (I believe this is the European convention.) # Constants for months referenced later January = 1 February = 2 # Number of days per month (except for February in leap years) mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # Full and abbreviated names of weekdays day_name = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', \ 'Friday', 'Saturday', 'Sunday'] day_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] # Full and abbreviated names of months (1-based arrays!!!) month_name = ['', 'January', 'February', 'March', 'April', \ 'May', 'June', 'July', 'August', \ 'September', 'October', 'November', 'December'] month_abbr = [' ', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', \ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] # Return 1 for leap years, 0 for non-leap years def isleap(year): return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0) # Return number of leap years in range [y1, y2) # Assume y1 <= y2 and no funny (non-leap century) years def leapdays(y1, y2): return (y2+3)/4 - (y1+3)/4 # Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31) def weekday(year, month, day): secs = mktime((year, month, day, 0, 0, 0, 0, 0, 0)) tuple = localtime(secs) return tuple[6] # Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month def monthrange(year, month): if not 1 <= month <= 12: raise ValueError, 'bad month number' day1 = weekday(year, month, 1) ndays = mdays[month] + (month == February and isleap(year)) return day1, ndays # Return a matrix representing a month's calendar # Each row represents a week; days outside this month are zero def _monthcalendar(year, month): day1, ndays = monthrange(year, month) rows = [] r7 = range(7) day = 1 - day1 while day <= ndays: row = [0, 0, 0, 0, 0, 0, 0] for i in r7: if 1 <= day <= ndays: row[i] = day day = day + 1 rows.append(row) return rows # Caching interface to _monthcalendar _mc_cache = {} def monthcalendar(year, month): key = (year, month) if _mc_cache.has_key(key): return _mc_cache[key] else: _mc_cache[key] = ret = _monthcalendar(year, month) return ret # Center a string in a field def _center(str, width): n = width - len(str) if n <= 0: return str return ' '*((n+1)/2) + str + ' '*((n)/2) # XXX The following code knows that print separates items with space! # Print a single week (no newline) def prweek(week, width): for day in week: if day == 0: s = '' else: s = `day` print _center(s, width), # Return a header for a week def weekheader(width): str = '' if width >= 9: names = day_name else: names = day_abbr for i in range(7): if str: str = str + ' ' str = str + _center(names[i%7][:width], width) return str # Print a month's calendar def prmonth(year, month, w = 0, l = 0): w = max(2, w) l = max(1, l) print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1), print '\n'*l, print weekheader(w), print '\n'*l, for week in monthcalendar(year, month): prweek(week, w) print '\n'*l, # Spacing of month columns _colwidth = 7*3 - 1 # Amount printed by prweek() _spacing = ' '*4 # Spaces between columns # 3-column formatting for year calendars def format3c(a, b, c): print _center(a, _colwidth), print _spacing, print _center(b, _colwidth), print _spacing, print _center(c, _colwidth) # Print a year's calendar def prcal(year): header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if len(cal) > height: height = len(cal) data.append(cal) for i in range(height): for cal in data: if i >= len(cal): print ' '*_colwidth, else: prweek(cal[i], 2) print _spacing, print --------------6029D8F58CB429C034E37EFD-- From arcege@shore.net Wed Oct 27 02:52:43 1999 From: arcege@shore.net (Michael P. Reilly) Date: Tue, 26 Oct 1999 21:52:43 -0400 (EDT) Subject: [Tutor] import calendar not working In-Reply-To: <3815DFAD.AE2CBED9@erols.com> from Michael Perry at "Oct 26, 99 01:06:53 pm" Message-ID: <199910270152.VAA18355@northshore.shore.net> > I can't figure out why this works: [...] > And this does not work?: > > #!/usr/bin/python > > print "Content-type: text/html" # HTML is following > print # blank line, end of headers > > import sys > import calendar > > print sys.path > > > $./cal.py > Content-type: text/html > > Traceback (innermost last): > File "./cal.py", line 8, in ? > import calendar > File "/home/httpd/cgi-bin/calendar.py", line 15, in ? > import HTMLcalendar > File "/usr/lib/python1.5/site-packages/HTMLgen/HTMLcalendar.py", line > 25, in ? > from calendar import day_name, month_name, mdays, weekday > ImportError: cannot import name day_name > [mike@spin cgi-bin]$ pwd > /home/httpd/cgi-bin > This is a naming problem.. You have a module in your own software that is using the same name as a standard module "calendar". There can only be one module loaded with any given name. Either do not rely on the standard module being loadable or rename your local module to something other than "calendar". Hope that helps. -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From mcgov@interlinq.com Wed Oct 27 16:40:12 1999 From: mcgov@interlinq.com (Tom McGovern) Date: Wed, 27 Oct 1999 08:40:12 -0700 Subject: [Tutor] Comparing nested tuples of tuples Message-ID: <11E7F60C5479D3119E47009027CADC7D47B892@phtha.interlinq.com> The situation is two tuples of tuples (returned from a db) that I want to compare for differences and return the differences, including a mathematical expression. assume I have two tuples of tuples: i = (('chevy',30),('spam',500),('ford',60),('chrysler',90),('honda',45)) v = (('chevy',30),('ford',90),('chrysler',90),('honda',45),('eggs',30)) If I wanted to compare the two, I could simply do some filters: tuples the same: filter(lambda x: x in i,v) which would return me the nested chevy, honda and chrysler tuples tuples unique to i: filter(lambda x: x not in v,i) which would return me the nested ford and spam tuples tuples unique to v: filter(lambda x: x not in i,v) which would return me the nested ford and eggs tuples. But I want to go deeper in two ways: 1. I want to see those unique *first item* nested tuples within each tuple. i.e. I want to write a function that will return just spam (not include ford) as unique to i and another function that returns eggs (also not ford) unique to v when compared to i. 2. then an additional function would return the mathematical subtraction of second item nested tuples with identical first item nested tuples in both tuples. in this case only return 'ford' and 30 (+ or - depending upon direction of comparison). one caveat, is that the two tuples of tuples would *not* be of the same length or in any reasonable sort order. The first item in a nested tuple would not necessarily show up in the other. However, the first item within each nested tuple would be unique within each tuple. Also, each tuple could have many thousands of nested tuples. would my best bet be to use nested if statements and a step through each nested tuple and compare it to every nested tuple in the other tuple, albeit analyzing possible thousands of nested tuples over and over in the opposite tuple, or I was thinking of converting the tuples to dictionaries and then using keys? Though this seems like alot of overhead too. how would you approach this? From iknowinfo@freewwweb.com Wed Oct 27 17:37:15 1999 From: iknowinfo@freewwweb.com (Kelvin Peebles) Date: Wed, 27 Oct 1999 11:37:15 -0500 Subject: [Tutor] re: remove me from e-mail list Message-ID: <38172A3B.7A0C@freewwweb.com> hello: what is the proper procedure to remove me from your e-mail list. thankyou iknowinfo@freewwweb.com From Python679@aol.com Wed Oct 27 18:15:19 1999 From: Python679@aol.com (Python679@aol.com) Date: Wed, 27 Oct 1999 13:15:19 EDT Subject: [Tutor] um about ur program PYTHON!!!!!!!!!!!!!!!! A QUESTION FOR YOU Message-ID: <0.ba9b75f6.25488d27@aol.com> okay man sup but any way i dont know how to program stuff and when i click run module it saids save first so i go save and it still saids save how do i work with this thing and how do u like my screename when i found out bout this i was like hey im famous lol From Python679@aol.com Wed Oct 27 18:22:56 1999 From: Python679@aol.com (Python679@aol.com) Date: Wed, 27 Oct 1999 13:22:56 EDT Subject: [Tutor] um about ur program PYTHON!!!!!!!!!!!!!!!! A QUESTION FOR YOU Message-ID: <0.f5ce05c4.25488ef0@aol.com> --part1_0.f5ce05c4.25488ef0_boundary Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit i have the newset version --part1_0.f5ce05c4.25488ef0_boundary Content-Type: message/rfc822 Content-Disposition: inline Return-path: Python679@aol.com From: Python679@aol.com Full-name: Python 679 Message-ID: <0.ba9b75f6.25488d27@aol.com> Date: Wed, 27 Oct 1999 13:15:19 EDT Subject: um about ur program PYTHON!!!!!!!!!!!!!!!! A QUESTION FOR YOU To: tutor@python.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Windows AOL sub 41 okay man sup but any way i dont know how to program stuff and when i click run module it saids save first so i go save and it still saids save how do i work with this thing and how do u like my screename when i found out bout this i was like hey im famous lol --part1_0.f5ce05c4.25488ef0_boundary-- From Michael R. DeLorenzo" This is a multi-part message in MIME format. ------=_NextPart_000_000B_01BF20DF.BADCEDA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Python is a scripting language for the web? Is that correct? If I am = correct, I just upload it to what directory? For example, for a CGI = script you use the CGI-BIN. Thanks, Michael DeLorenzo www.mikedelo.com ------=_NextPart_000_000B_01BF20DF.BADCEDA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Python is a scripting language for the web? Is that=20 correct?  If I am correct, I just upload it to what = directory?  For=20 example, for a CGI script you use the CGI-BIN.
Thanks,
Michael DeLorenzo
www.mikedelo.com
=
------=_NextPart_000_000B_01BF20DF.BADCEDA0-- From parkw@better.net Thu Oct 28 11:50:13 1999 From: parkw@better.net (William Park) Date: Thu, 28 Oct 1999 06:50:13 -0400 Subject: [Tutor] A quick question In-Reply-To: <000e01bf2101$4694bd20$e183153f@y4x5g7> References: <000e01bf2101$4694bd20$e183153f@y4x5g7> Message-ID: <19991028065013.A10826@better.net> On Thu, Oct 28, 1999 at 12:59:47AM -0400, Michael R. DeLorenzo wrote: > Python is a scripting language for the web? Is that correct? Yes. > If I am correct, I just upload it to what directory? For example, for > a CGI script you use the CGI-BIN. If your web server has been configured to recognize *.py files as CGI script, then the server will execute it just like any other CGI scripts. > Thanks, > Michael DeLorenzo > www.mikedelo.com From cd_lambert@fetchmail.com Thu Oct 28 19:34:44 1999 From: cd_lambert@fetchmail.com (Jonathan Lambert) Date: Thu, 28 Oct 1999 19:34:44 0100 Subject: [Tutor] directions Message-ID: <199910281834.TAA22653@out.fetchmail.com> could you send me a list of good site addresses for me to learn ow to crack games and so forth. cheers Jon ___________________________________________________________________ Sent via Fetchmail - free email service at http://www.fetchmail.com From deirdre@deirdre.net Thu Oct 28 19:53:29 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 28 Oct 1999 11:53:29 -0700 (PDT) Subject: [Tutor] directions In-Reply-To: <199910281834.TAA22653@out.fetchmail.com> Message-ID: On Thu, 28 Oct 1999, Jonathan Lambert wrote: > could you send me a list of good site addresses for me to learn ow to crack > games and so forth. That is thankfully out of the scope of this mailing list. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From Alexandre Passos" Jonathan lambert wrote: >could you send me a list of good site addresses for me to learn ow to crack >games and so forth. This is no cracker-mail list. This is a mail list for those who wants to learn how to program. From alan.gauld@gssec.bt.co.uk Fri Oct 29 10:04:56 1999 From: alan.gauld@gssec.bt.co.uk (Alan Gauld) Date: Fri, 29 Oct 1999 10:04:56 +0100 Subject: [Tutor] RE: A quick question Message-ID: <38196338.64AB0819@gssec.bt.co.uk> > Python is a scripting language for the web? Is that correct? Could be. Python is a general purpose scripting language which includes being suitable for web work. > If I am correct, I just upload it to what directory? For > example, for a CGI script you use the CGI-BIN. That depends on your web server. Our local server runs any script with the extension of .cgi as a cgi script regard;less of location. Others have a special directory for cgi scripts which *by convention* is called cgi-bin - yours may be different. Other web servers have still other ways of doing things - for example Oracle Web Server... You need to talk to your site's webmaster. Alsoo the webserver will need python installed and your script will need to point to it - it may not be in the same location as on your local computer. All of this applies to Unix/Linux web servers, I've absolutely no idea how NT/IIS works! Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From deirdre@deirdre.net Fri Oct 29 20:11:20 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Fri, 29 Oct 1999 12:11:20 -0700 (PDT) Subject: [Tutor] RE: A quick question In-Reply-To: <38196338.64AB0819@gssec.bt.co.uk> Message-ID: On Fri, 29 Oct 1999, Alan Gauld wrote: > > Python is a scripting language for the web? Is that correct? > > Could be. Python is a general purpose scripting > language which includes being suitable for web work. Correction: Guido says, and he's quite right, that "Python is not a scripting language." It would be more correct to say that Python is a general-purpose language also suitable for scripting. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From bryan.hann@pobox.com Sat Oct 30 11:15:35 1999 From: bryan.hann@pobox.com (Bryan Hann) Date: Sat, 30 Oct 1999 18:15:35 +0800 Subject: [Tutor] RE: A quick question References: Message-ID: <381AC547.841B09D7@pobox.com> Hmmm... Is there a qualitative difference between a script and a "real" program? Has anyone tried to formally distinguish between the two? 'Twould be good to recognize if and how the two animals really are different, for the sake of good pedagogy. (Sorry, I teach comp sci!) Deirdre Saoirse wrote: > On Fri, 29 Oct 1999, Alan Gauld wrote: > > > Python is a scripting language for the web? Is that correct? > > Could be. Python is a general purpose scripting > > language which includes being suitable for web work. > Correction: Guido says, and he's quite right, that "Python is not a > scripting language." It would be more correct to say that Python is a > general-purpose language also suitable for scripting. From Python679@aol.com Sat Oct 30 15:32:56 1999 From: Python679@aol.com (Python679@aol.com) Date: Sat, 30 Oct 1999 10:32:56 EDT Subject: [Tutor] um about ur program PYTHON!!!!!!!!!!!!!!!! A QUESTION FOR YOU Message-ID: <0.de12bdf4.254c5b98@aol.com> --part1_0.de12bdf4.254c5b98_boundary Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit --part1_0.de12bdf4.254c5b98_boundary Content-Type: message/rfc822 Content-Disposition: inline Return-path: Python679@aol.com From: Python679@aol.com Full-name: Python 679 Message-ID: <0.f5ce05c4.25488ef0@aol.com> Date: Wed, 27 Oct 1999 13:22:56 EDT Subject: um about ur program PYTHON!!!!!!!!!!!!!!!! A QUESTION FOR YOU To: tutor@python.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="part2_0.de12bdf4.25488ef0_boundary" X-Mailer: Windows AOL sub 41 --part2_0.de12bdf4.25488ef0_boundary Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit i have the newset version --part2_0.de12bdf4.25488ef0_boundary Content-Type: message/rfc822 Content-Disposition: inline Return-path: Python679@aol.com From: Python679@aol.com Full-name: Python 679 Message-ID: <0.ba9b75f6.25488d27@aol.com> Date: Wed, 27 Oct 1999 13:15:19 EDT Subject: um about ur program PYTHON!!!!!!!!!!!!!!!! A QUESTION FOR YOU To: tutor@python.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Windows AOL sub 41 okay man sup but any way i dont know how to program stuff and when i click run module it saids save first so i go save and it still saids save how do i work with this thing and how do u like my screename when i found out bout this i was like hey im famous lol --part2_0.de12bdf4.25488ef0_boundary-- --part1_0.de12bdf4.254c5b98_boundary-- From deirdre@deirdre.net Sat Oct 30 22:01:21 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sat, 30 Oct 1999 14:01:21 -0700 (PDT) Subject: [Tutor] um about ur program PYTHON! In-Reply-To: <0.de12bdf4.254c5b98@aol.com> Message-ID: Do you have a specific question? I presume you're running on Windows? (I don't use it myself) On Sat, 30 Oct 1999 Python679@aol.com wrote: > > -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From Python679@aol.com Sun Oct 31 00:17:03 1999 From: Python679@aol.com (Python679@aol.com) Date: Sat, 30 Oct 1999 19:17:03 EDT Subject: [Tutor] um about ur program PYTHON! Message-ID: <0.e628653a.254cd66f@aol.com> --part1_0.e628653a.254cd66f_boundary Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit --part1_0.e628653a.254cd66f_boundary Content-Type: message/rfc822 Content-Disposition: inline Return-path: Python679@aol.com From: Python679@aol.com Full-name: Python 679 Message-ID: <0.634113e7.254cd638@aol.com> Date: Sat, 30 Oct 1999 19:16:08 EDT Subject: Re: [Tutor] um about ur program PYTHON! To: deirdre@deirdre.net MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Windows AOL sub 41 yes my question is how to make a prog i cant seem to program any thing --part1_0.e628653a.254cd66f_boundary-- From Python679@aol.com Sun Oct 31 00:19:13 1999 From: Python679@aol.com (Python679@aol.com) Date: Sat, 30 Oct 1999 19:19:13 EDT Subject: [Tutor] um about ur program PYTHON! Message-ID: <0.cfcbd3ce.254cd6f1@aol.com> --part1_0.cfcbd3ce.254cd6f1_boundary Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit yes i am using windows 95 --part1_0.cfcbd3ce.254cd6f1_boundary Content-Type: message/rfc822 Content-Disposition: inline Return-path: Python679@aol.com From: Python679@aol.com Full-name: Python 679 Message-ID: <0.e628653a.254cd66f@aol.com> Date: Sat, 30 Oct 1999 19:17:03 EDT Subject: um about ur program PYTHON! To: tutor@python.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="part2_0.cfcbd3ce.254cd66f_boundary" X-Mailer: Windows AOL sub 41 --part2_0.cfcbd3ce.254cd66f_boundary Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit --part2_0.cfcbd3ce.254cd66f_boundary Content-Type: message/rfc822 Content-Disposition: inline Return-path: Python679@aol.com From: Python679@aol.com Full-name: Python 679 Message-ID: <0.634113e7.254cd638@aol.com> Date: Sat, 30 Oct 1999 19:16:08 EDT Subject: Re: [Tutor] um about ur program PYTHON! To: deirdre@deirdre.net MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Windows AOL sub 41 yes my question is how to make a prog i cant seem to program any thing --part2_0.cfcbd3ce.254cd66f_boundary-- --part1_0.cfcbd3ce.254cd6f1_boundary-- From deirdre@deirdre.net Sun Oct 31 00:15:21 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sat, 30 Oct 1999 16:15:21 -0700 (PDT) Subject: [Tutor] um about ur program PYTHON! In-Reply-To: <0.cfcbd3ce.254cd6f1@aol.com> Message-ID: On Sat, 30 Oct 1999 Python679@aol.com wrote: > yes i am using windows 95 Sorry, I don't use Windows, so I'm not sure what to do about your question. Have you looked on the Python site (www.python.org) for instructions for setting up Python on windows? -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From atp@bahianet.com.br Sun Oct 31 12:42:37 1999 From: atp@bahianet.com.br (Alexandre Passos) Date: Sun, 31 Oct 1999 10:42:37 -0200 Subject: [Tutor] Is python just a scripting language? Message-ID: <004301bf239d$72091a20$935bdfc8@the-user> This is a multi-part message in MIME format. ------=_NextPart_000_0040_01BF238C.A5D422C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I=B4m looking at sources of programs in python and I noticed that there = are just scripts written in python. Can't I compile in an executable = file? ------=_NextPart_000_0040_01BF238C.A5D422C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I´m looking at sources of = programs in=20 python and I noticed that there are just scripts written in python. = Can't I=20 compile in an executable file?
------=_NextPart_000_0040_01BF238C.A5D422C0-- From deirdre@deirdre.net Sun Oct 31 21:24:05 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sun, 31 Oct 1999 13:24:05 -0800 (PST) Subject: [Tutor] Is python just a scripting language? In-Reply-To: <004301bf239d$72091a20$935bdfc8@the-user> Message-ID: On Sun, 31 Oct 1999, Alexandre Passos wrote: > I´m looking at sources of programs in python and I noticed that there > are just scripts written in python. Can't I compile in an executable > file? Python is an interpreted language. -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60 From da@ski.org Sun Oct 31 22:55:00 1999 From: da@ski.org (David Ascher) Date: Sun, 31 Oct 1999 14:55:00 -0800 (Pacific Standard Time) Subject: [Tutor] Is python just a scripting language? In-Reply-To: Message-ID: On Sun, 31 Oct 1999, Deirdre Saoirse wrote: > On Sun, 31 Oct 1999, Alexandre Passos wrote: > > > I´m looking at sources of programs in python and I noticed that there > > are just scripts written in python. Can't I compile in an executable > > file? > > Python is an interpreted language. Indeed. Alexandre might want to know about the freeze program, though, which makes an executable given a program. It's not 'compilation to native code', but for 99% of users, it's just as good. Look also for Gordon McMillan's Installer program, especially if you're using Windows. --david From deirdre@deirdre.net Sun Oct 31 22:47:50 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sun, 31 Oct 1999 14:47:50 -0800 (PST) Subject: [Tutor] Is python just a scripting language? In-Reply-To: Message-ID: On Sun, 31 Oct 1999, David Ascher wrote: > Indeed. Alexandre might want to know about the freeze program, though, > which makes an executable given a program. It's not 'compilation to > native code', but for 99% of users, it's just as good. Heh, reminds me something about how they build emacs -- force a core dump and, voila, there's your executable. (No, I don't know if this is how freeze works, but it seems like an educated guess). -- _Deirdre * http://www.linuxcabal.net * http://www.deirdre.net "Mars has been a tough target" -- Peter G. Neumann, Risks Digest Moderator "That's because the Martians keep shooting things down." -- Harlan Rosenthal , retorting in Risks Digest 20.60