From atp@bahianet.com.br Wed Dec 1 20:12:09 1999 From: atp@bahianet.com.br (Alexandre Passos) Date: Wed, 1 Dec 1999 18:12:09 -0200 Subject: [Tutor] A good tkinter tutorial Message-ID: <001b01bf3c38$5a1935e0$6b5bdfc8@the-user> Has someone got a *complete* and *downloadable* tutorial on Tkinter? From ivanlan@callware.com Wed Dec 1 20:10:19 1999 From: ivanlan@callware.com (Ivan Van Laningham) Date: Wed, 01 Dec 1999 13:10:19 -0700 Subject: [Tutor] A good tkinter tutorial References: <001b01bf3c38$5a1935e0$6b5bdfc8@the-user> Message-ID: <384580AB.E4B90640@callware.com> Hi All-- Alexandre Passos wrote: > > Has someone got a *complete* and *downloadable* tutorial on Tkinter? > > No. Books are due out soon. If you can wait, that is. If you can't, keep plugging away at the references we've given the past couple of days (i.e., the downloadable *incomplete* tutorial at www.pythonware.com). Ask questions here. Start with a simple program. Modify it, see what it does. It won't bite. -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From picasso@videotron.ca Thu Dec 2 15:03:05 1999 From: picasso@videotron.ca (Oscar Picasso) Date: Thu, 02 Dec 1999 10:03:05 -0500 Subject: [Tutor] Regex with Python Message-ID: <3.0.6.32.19991202100305.0082d100@pop.videotron.ca> Hi, I don't know if the problem I have specific to Python or it is I misunderstand regexes. Here is my code: import re st='This is string. "With a quoted \\"string\\" inside it." A single quote ". Here is the end of the string.' s='("([^"]|(\\"))*")' pat=re.compile(s) r=pat.search(st) print r.group(0) >>> "With a quoted \"string\" inside it." A single quote " I expected: >>> "With a quoted \"string\" inside it." I don't see where is my mistake. Thanks ****************************************************** Oscar Picasso picasso@videotron.ca ****************************************************** From fflores@arnet.com.ar Thu Dec 2 18:30:44 1999 From: fflores@arnet.com.ar (FFlores) Date: Thu, 2 Dec 1999 15:30:44 -0300 Subject: [Tutor] Overloading + factoring Message-ID: <0780158010103c9MAIL1@mail1.arnet.com.ar> A question about class methods: Can you overload the definition of a method, especially __init__? And something else, though it's not Python-related: is there a nice method for factoring numbers, calculating lcd, gcd, and/or a good library of such functions for rational numbers? --Pablo Flores From joanca@typerware.com Fri Dec 3 11:46:04 1999 From: joanca@typerware.com (JoanCarles p Casas=?ISO-8859-1?Q?=edn?=) Date: Fri, 3 Dec 1999 12:46:04 +0100 Subject: [Tutor] Overloading + factoring Message-ID: <199912031140.GAA26837@python.org> FFlores wrote: >A question about class methods: >Can you overload the definition of a method, >especially __init__? Yes it is: class foo: def __init__(self): print '__init__ from foo' def printanother(self): print 'a foo method' def printsame(self): print 'same for both classes' a = foo() a.printanother() a.printsame() class fee (foo): def __init__(self): print '__init__ from fee (overloaded)' def printanother(self): print 'a fee method (overloaded)' b = fee() b.printanother() b.printsame() I hope it helps, JoanCarles :::!!!::: joanca@typerware.com http://www.typerware.com From gerrit@nl.linux.org Fri Dec 3 12:49:38 1999 From: gerrit@nl.linux.org (Gerrit Holl) Date: Fri, 3 Dec 1999 13:49:38 +0100 Subject: [Tutor] Regex with Python In-Reply-To: <3.0.6.32.19991202100305.0082d100@pop.videotron.ca>; from picasso@videotron.ca on Thu, Dec 02, 1999 at 10:03:05AM -0500 References: <3.0.6.32.19991202100305.0082d100@pop.videotron.ca> Message-ID: <19991203134938.A3034@stopcontact.palga.uucp> Oscar Picasso wrote: > Hi, > > I don't know if the problem I have specific to Python or it is I > misunderstand regexes. Here is my code: > > import re > > st='This is string. "With a quoted \\"string\\" inside it." A single quote > ". Here is the end of the string.' > > s='("([^"]|(\\"))*")' > > pat=re.compile(s) > r=pat.search(st) > print r.group(0) > >>> "With a quoted \"string\" inside it." A single quote " > > I expected: > >>> "With a quoted \"string\" inside it." > > I don't see where is my mistake. s=r'("([^"]|(\\"))*")' r=raw regards, Gerrit. -- "The world is beating a path to our door" -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates) 1:49pm up 1:23, 14 users, load average: 0.00, 0.00, 0.00 From parkw@better.net Fri Dec 3 15:52:48 1999 From: parkw@better.net (William Park) Date: Fri, 3 Dec 1999 10:52:48 -0500 Subject: [Tutor] Overloading + factoring In-Reply-To: <0780158010103c9MAIL1@mail1.arnet.com.ar> References: <0780158010103c9MAIL1@mail1.arnet.com.ar> Message-ID: <19991203105248.A454@better.net> On Thu, Dec 02, 1999 at 03:30:44PM -0300, FFlores wrote: > A question about class methods: > Can you overload the definition of a method, > especially __init__? Yes. For example, class first: def __init__(self): ... class second(first): # inherits from the first class def __init__(self): # this overrides the first one. ... > And something else, though it's not Python-related: > is there a nice method for factoring numbers, calculating > lcd, gcd, and/or a good library of such functions for rational > numbers? Not to my knowledge. But, you could probably write one yourself. --William Park From fflores@arnet.com.ar Sat Dec 4 01:39:27 1999 From: fflores@arnet.com.ar (FFlores) Date: Fri, 3 Dec 1999 22:39:27 -0300 Subject: [Tutor] Overloading + factoring Message-ID: <0c64719001604c9MAIL1@mail1.arnet.com.ar> William Park wrote: > class first: > def __init__(self): > ... > > class second(first): # inherits from the first class > def __init__(self): # this overrides the first one. > ... Well, that's another thing! I was referring to C++-like overloading (i. e. several definitions of the same method, to be tested in order until the parameters fit). But I've already been told that's not possible. > > And something else, though it's not Python-related: > > is there a nice method for factoring numbers, calculating > > lcd, gcd, and/or a good library of such functions for rational > > numbers? > > Not to my knowledge. But, you could probably write one yourself. Oh yes, I could make a function that gives me the prime numbers I need. But I'd become old and die while the interpreter is still calculating. :) Thanks anyway. --Pablo Flores From cwebster@nevada.edu Sat Dec 4 17:13:25 1999 From: cwebster@nevada.edu (Corran Webster) Date: Sat, 4 Dec 1999 09:13:25 -0800 Subject: [Tutor] Overloading + factoring In-Reply-To: <0c64719001604c9MAIL1@mail1.arnet.com.ar> Message-ID: At 10:39 PM -0300 3/12/99, FFlores wrote: > William Park wrote: > > > class first: > > def __init__(self): > > ... > > > > class second(first): # inherits from the first class > > def __init__(self): # this overrides the first one. > > ... > > Well, that's another thing! I was referring to C++-like > overloading (i. e. several definitions of the same method, > to be tested in order until the parameters fit). But I've > already been told that's not possible. Overloading in the C++ sense isn't possible, but it is possible to get the same functionality with a bit of introspection: class Rectangle: def __init__(self, *args): if len(args) == 4: self.top, self.left, self.bottom, self.right = args elif len(args) == 1 and len(args[0]) == 4: self.top, self.left, self.bottom, self.right = args[0] else: raise TypeError, "incorrect arguments" This can be used as folows: >>> x = Rectangle(1,2,3,4) >>> y = Rectangle((1,2,3,4)) >>> y = Rectangle((1,2)) Traceback (innermost last): File "", line 1, in ? File "", line 8, in __init__ TypeError: incorrect arguments Keyword arguments can also be a good way to do what you would do with overloading in C++. If you are trying to overload __init__, you may find that what you really want is a collection of factory functions (or one factory function which does argument testing as above). Also _operator_ overloading is strongly supported by Python by the double-underscored "magic" class methods like "__add__". > > > And something else, though it's not Python-related: > > > is there a nice method for factoring numbers, calculating > > > lcd, gcd, and/or a good library of such functions for rational > > > numbers? > > > > Not to my knowledge. But, you could probably write one yourself. > > Oh yes, I could make a function that gives me the prime numbers > I need. But I'd become old and die while the interpreter is still > calculating. :) Thanks anyway. There's likely a C library out there which you may be able to wrap. Regards, Corran From neilconway@home.com Sat Dec 4 19:09:26 1999 From: neilconway@home.com (Neil Conway) Date: Sat, 04 Dec 1999 14:09:26 -0500 (EST) Subject: [Tutor] Dictionary, sorting -> list Message-ID: Hello all. First off, thanks to everyone who has answered questions of mine in the past. You have all be very helpful. My problem today is that I have a dictionary, like so: >>> results = {} >>> results['page1'] = 2 >>> results['page2'] = 4 >>> results['page3'] = 7 Given input like the above, I would like to return input like so: ['page3','page2',page1'] #ranked from highest corresponding dict value to lowest I need to do this for a large dictionary, which could be 1000 or more items long. Is it possible to do this, somehow? Especially considering that this will be run via CGI (its part of a search engine), I would rather not have to do this in a slow, clumsy fashion. I realize that this example would seem stupid, but I AFAICT, this is the way it needs to be done - my actual dilemma is somewhat complex and difficult than my example, obviously. I've been thinking about this for a while, and haven't been able to come up with a good solution. Thanks in advance. -------------------------- Neil Conway neilconway@home.com Date: 04-Dec-1999 TIme: 13:59:47 For my GnuPG key, please see: http://24.112.188.210/mykey.asc -------------------------- From tim_one@email.msn.com Sat Dec 4 22:12:13 1999 From: tim_one@email.msn.com (Tim Peters) Date: Sat, 4 Dec 1999 17:12:13 -0500 Subject: [Tutor] Dictionary, sorting -> list In-Reply-To: Message-ID: <000001bf3ea4$9e5b3780$df2d153f@tim> [Neil Conway] > ... > My problem today is that I have a dictionary, like so: > > >>> results = {} > >>> results['page1'] = 2 > >>> results['page2'] = 4 > >>> results['page3'] = 7 > > Given input like the above, I would like to return input like so: > > ['page3','page2',page1'] > #ranked from highest corresponding dict value to lowest See http://www.python.org/doc/howto/sorting/sorting.html for a helpful tutorial about sorting in Python. > I need to do this for a large dictionary, which could be 1000 or more > items long. 1000 items is small to a computer! 1000000 would be pretty big, though. > ... > I've been thinking about this for a while, and haven't been able > to come up with a good solution. This is faster than you might expect: def keys_by_increasing_values(d): "d -> return list of dict d's keys k in increasing order of d[kj." result = [] for key, value in d.items(): result.append((value, key)) result.sort() # Strip out the values. for i in xrange(len(result)): result[i] = result[i][1] return result def keys_by_decreasing_values(d): "d -> return list of dict d's keys k in decreasing order of d[kj." result = keys_by_increasing_values(d) result.reverse() return result print keys_by_decreasing_values( {'page1': 2, 'page2': 4, 'page3': 7}) For large dicts, the single line results.sort() dominates the runtime, and since sort() is implemented in C via a near-optimal sorting algorithm, you're not going to find anything essentially faster than this. Faster methods are possible if you can put severe restrictions on the possible set of values (e.g., if you know in advance that 2, 4 and 7 are the only possible values -- stuff like that). orderedly y'rs - tim From ksipos@netaxs.com Mon Dec 6 11:34:23 1999 From: ksipos@netaxs.com (kalak) Date: Mon, 6 Dec 1999 06:34:23 -0500 (EST) Subject: [Tutor] list with attributes....examples Message-ID: <199912061134.GAA28962@mail.netaxs.com> I am trying to use a list of 10,000 items with various attributes so they can be sorted accordingly. are there any examples available or is an object database a better way to display the various combinations.. thanks ken Philadelphia python newbie... ksipos@netaxs.com From info@inexchange.net Wed Dec 8 04:04:13 1999 From: info@inexchange.net (Info Desk) Date: Tue, 7 Dec 1999 23:04:13 -0500 Subject: [Tutor] Special Webhosting and Dedicated Server Offer Message-ID: <19991208040413151.DFPQ130@infomail.inexchange.net@outbox.infowatch.net> If you wish to be excluded from any future mailings, reply with "remove" in the subject header. ------------------------------------------------------------ http://www.inexchange.net Internet Exchange would like to introduce our Special Hosting and Dedicated Server Plans * Budget Plans from $14.95 Mo. * E-commerce Plans from $49.95 Mo. * Dedicated Server Plan from $99.00 Mo. (Ask about YOUR FREE Server!) * Sign up for 6 months, and we'll WAIVE the setup fee * Sign up for 10 months, and we'll WAIVE the setup fee and give you 2 FREE months * Sign up for 12 months, and we'll give you a FULL FREE 2nd year of hosting * UNLIMITED E-mail, E-mail forwarding, auto responders and vacation reply * FREE registration of your domain with over 950 search engines * Multiple, Redundant, High-Speed connections to the web * INTERNATIONAL Hosting * Access to your account anytime from your own browser * Full Microsoft Front Page support * Unlimited FTP updates * Personal CGI directory for your own scripts (or use ours) * Comprehensive statistics program shows you everything * Domain name registration (www.yourname.com) * Friendly customer support * Additional plans also available If for any reason you are not satisfied with InfoWatch's service after 30 days, we will transfer you back to your original host and pay any transfer fees. http://www.inexchange.net info@inexchange.net From smu@archesis.it Wed Dec 8 15:18:39 1999 From: smu@archesis.it (Sergio Murru) Date: Wed, 08 Dec 1999 16:18:39 +0100 Subject: [Tutor] static method Message-ID: <1.5.4.32.19991208151839.00918ad8@mbox.archesis.it> My background is c++, so I tried to implement a static method like this -------------------------------------------------------------- class MyClass: def staticMethod(): print 'hi from static method' MyClass.staticMethod() -------------------------------------------------------------- but i get a "TypeError: unbound method must be called with class instance 1st argument". I understand that this makes sense when I try -------------------------------------------------------------- class MyClass: def method(): print 'hi from method' MyClass.method() # instead of myclass_instance = MyClass() MyClass.method(myclass_instance) #or myclass_instance.method() -------------------------------------------------------------- MyClass.method() without or myclass_instance.method() I also understand that I can use static memebers like this: ------------------------------------------------------------- class MyClass: memberstatic = 4 def metodo(self): print MyClass.memberstatic -------------------------------------------------------------- The question is: How can I implement a static method in python?? Thanks From joe@strout.net Wed Dec 8 15:25:31 1999 From: joe@strout.net (Joseph J. Strout) Date: Wed, 8 Dec 1999 07:25:31 -0800 Subject: [Tutor] static method In-Reply-To: <1.5.4.32.19991208151839.00918ad8@mbox.archesis.it> References: <1.5.4.32.19991208151839.00918ad8@mbox.archesis.it> Message-ID: At 4:18 PM +0100 12/8/99, Sergio Murru wrote: >The question is: How can I implement a static method in python?? You can't. But, a typical organization is to put one class (or a few closely related classes) into one file (aka one "module"). Put what you would have as a static method, as a "global" function in that module instead. It's not really global; it's in the module's scope, so it's really just as good as a static method. You can even make it "private" by starting its name with an underscore (names which start with an underscore are not normally imported by other modules). Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Check out the Mac Web Directory: | | joe@strout.net http://www.macwebdir.com/ | `------------------------------------------------------------------' From yuba@cyberback.com Fri Dec 10 19:42:37 1999 From: yuba@cyberback.com (Greg & Janet LINDSTROM) Date: Fri, 10 Dec 1999 13:42:37 -0600 Subject: [Tutor] Help with TKiniter Message-ID: <000801bf4346$b9c17ba0$26de3dd8@yuba> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01BF4314.6BBFC4C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Greetings- I am new to the python scene, but am quite excited about what I have = seen so far. I am a professional coder and want to be able to develop = prototypes quickly for proof-of-concept presentations. I am in the process of learning Tkinter and am having trouble with the = Dialog example on pages 36ff of Fredrik's manual (An Introduction to = Tkinter, copywrite 1999). In particular, the code appears to execute, = but no Dialog appears on the screen. What am I missing? Any help, or = further documentation, would be appreciated. Also, is there any tutorial help on the class aspect of Tkinter and/or = the Python Mega-Widgets? I would love to implement them, but need a = little more that just the source code. Thanks for any help you can provide, Greg Lindstrom yuba@cyberback.com ------=_NextPart_000_0005_01BF4314.6BBFC4C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Greetings-
 
I am new to the python scene, but am = quite excited=20 about what I have seen so far.  I am a professional coder and want = to be=20 able to develop prototypes quickly for proof-of-concept=20 presentations.
 
I am in the process of learning Tkinter = and am=20 having trouble with the Dialog example on pages 36ff of Fredrik's manual = (An=20 Introduction to Tkinter, copywrite 1999).  In particular, the code = appears=20 to execute, but no Dialog appears on the screen. What am I = missing?  Any=20 help, or further documentation, would be appreciated.
 
Also, is there any tutorial help on the = class=20 aspect of Tkinter and/or the Python Mega-Widgets?  I would love to=20 implement them, but need a little more that just the source = code.
 
Thanks for any help you can = provide,
 
Greg Lindstrom
yuba@cyberback.com
------=_NextPart_000_0005_01BF4314.6BBFC4C0-- From create@picknowl.com.au Sat Dec 11 04:52:04 1999 From: create@picknowl.com.au (mark) Date: Sat, 11 Dec 1999 15:22:04 +1030 Subject: [Tutor] Quick Newbe Question Message-ID: <004f01bf4393$7a3dfec0$a9a226cb@create> How do I code a relative path for file in windoze with out hard coding it? I want it to be relive to the script that is running? Any help will be appreciated mark twiddy From Viagra@weeklysex.com Sat Dec 11 23:35:40 1999 From: Viagra@weeklysex.com (Viagra@weeklysex.com) Date: Sat, 11 Dec 1999 23:35:40 +0000 Subject: [Tutor] Natural Viagra Alternative! (Adv.) Message-ID: <22354079242356@napolionline.com> The Ultimate Sensation! Get your "Men's Ultra" Now, No Doctor's Prescription needed! 100 % Natural. Feel the Energy, Passion, Desire and the Power rushing back into your Life- Special Sale Price $39.95 - 60 Caplets Includes Shipping & Handling "30 Day Money Back Guarantee" Credit Cards, Money Orders & Checks Accepted Shop by Phone, Toll-Free 24 hours a day at (800) 480-8433 or (954) 969-3928 From warren@nightwares.com Mon Dec 13 14:17:54 1999 From: warren@nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Mon, 13 Dec 1999 08:17:54 -0600 Subject: [Tutor] Natural Viagra Alternative! (Adv.) References: <22354079242356@napolionline.com> Message-ID: <38550012.8BF16DAF@nightwares.com> Those of you who find this spam worthless, note these idiots included a toll free number. Make sure to call them -- at their expense -- and tell them precisely what you think of their worthless company. > Toll-Free 24 hours a day at (800) 480-8433 --WthmO Bad news hits hard. Only The Indigestible punches back. http://www.the-indigestible.com/ From aa8vb@yahoo.com Mon Dec 13 18:38:04 1999 From: aa8vb@yahoo.com (Randall Hopper) Date: Mon, 13 Dec 1999 13:38:04 -0500 Subject: [Tutor] Re: Help with TKiniter In-Reply-To: <000801bf4346$b9c17ba0$26de3dd8@yuba> References: <000801bf4346$b9c17ba0$26de3dd8@yuba> Message-ID: <19991213133804.A92898@vislab.epa.gov> | I am new to the python scene, but am quite excited about what I have | seen so far. I am a professional coder and want to be able to develop | prototypes quickly for proof-of-concept presentations. That's what got me interested as well. | I am in the process of learning Tkinter and am having trouble with the | Dialog example on pages 36ff of Fredrik's manual (An Introduction to | Tkinter, copywrite 1999). Are there page numbers? Are you referring to this HTML doc?: http://www.pythonware.com/fredrik/tkdraft/ If so, which example: 9-1, 9-2, 9-3, or 9-4? If you're referring to the PDF, the two snippets on pg 36 aren't intended to be stand-alone. | In particular, the code appears to execute, | but no Dialog appears on the screen. What am I missing? Any help, or | further documentation, would be appreciated. | | Also, is there any tutorial help on the class aspect of Tkinter and/or | the Python Mega-Widgets? I would love to implement them, but need a | little more that just the source code. Here are a few links on Tkinter (class ref, etc.) and Pmw: http://www.pythonware.com/library/tkinter/tkclass/index.htm http://www.python.org/topics/tkinter/doc.html http://www.pythonware.com/library.htm http://www.dscpl.com.au/pmw/ http://uvacs.cs.virginia.edu/~mjc4y/tkinter_examples -- Randall Hopper aa8vb@yahoo.com From tismer@appliedbiometrics.com Tue Dec 14 13:22:46 1999 From: tismer@appliedbiometrics.com (Christian Tismer) Date: Tue, 14 Dec 1999 14:22:46 +0100 Subject: [Tutor] static method References: <1.5.4.32.19991208151839.00918ad8@mbox.archesis.it> Message-ID: <385644A6.FBCD0A1B@appliedbiometrics.com> "Joseph J. Strout" wrote: > > At 4:18 PM +0100 12/8/99, Sergio Murru wrote: > > >The question is: How can I implement a static method in python?? > > You can't. You can. In addition to Joe's advice which is right, I'd like to explain: There is no direct support for class methods. Functions which appear to be defined in a class context are meant as methods which expect an instance of the class or a subclass as first parameter. When a method is called from an instance, a bound method is created with the usual "self" parameter set to the instance. When a method is called from a class, this binding does not happen, and you need to supply an instance of a subclass as first parameter explicitly. So far about the standard. But there are exceptions, for instance (for class:) >>> class funny: ... len = len ... >>> funny.len("weird") 5 >>> Ok, this is for builtin functions. For Python functions, the following trick is possible (although I fear Guido's slap:) >>> class class_method: ... def blush(self, arg): ... return arg+13 ... >>> class funny: ... cmeth = class_method().blush ... >>> funny.cmeth(29) 42 >>> What is going on here? The point is that a python function will be bound to a method once and only once. This is done by the class_method() instance creation. It will not happen again, and when I assign this bound method in my funny class, the binding has been satisfied already, and calling funny.cmeth is like calling an ordinary function. Not to say that one should do this, but it is in fact possible. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From YankoC@gspinc.com Tue Dec 14 14:06:27 1999 From: YankoC@gspinc.com (Yanko, Curtis (GSP)) Date: Tue, 14 Dec 1999 09:06:27 -0500 Subject: [Tutor] static method Message-ID: <23EF0668B5D3D111A0CF00805F9FDC4401E43EAD@SRV_EXCH1> How can we use this to implement a Singleton Pattern? > -----Original Message----- > From: Christian Tismer [SMTP:tismer@appliedbiometrics.com] > Sent: Tuesday, December 14, 1999 8:23 AM > To: Joseph J. Strout > Cc: Sergio Murru; tutor@python.org > Subject: Re: [Tutor] static method > > > > "Joseph J. Strout" wrote: > > > > At 4:18 PM +0100 12/8/99, Sergio Murru wrote: > > > > >The question is: How can I implement a static method in python?? > > > > You can't. > > You can. In addition to Joe's advice which is right, I'd like to > explain: > > There is no direct support for class methods. Functions which appear > to be defined in a class context are meant as methods which expect > an instance of the class or a subclass as first parameter. > > When a method is called from an instance, a bound method is > created with the usual "self" parameter set to the instance. > > When a method is called from a class, this binding does not > happen, and you need to supply an instance of a subclass > as first parameter explicitly. > > So far about the standard. > But there are exceptions, for instance (for class:) > > >>> class funny: > ... len = len > ... > >>> funny.len("weird") > 5 > >>> > > Ok, this is for builtin functions. For Python functions, the > following trick is possible (although I fear Guido's slap:) > > >>> class class_method: > ... def blush(self, arg): > ... return arg+13 > ... > >>> class funny: > ... cmeth = class_method().blush > ... > >>> funny.cmeth(29) > 42 > >>> > > What is going on here? > The point is that a python function will be bound to a method > once and only once. This is done by the class_method() instance > creation. It will not happen again, and when I assign this > bound method in my funny class, the binding has been satisfied > already, and calling funny.cmeth is like calling an ordinary > function. > > Not to say that one should do this, but it is in fact possible. > > ciao - chris > > -- > Christian Tismer :^) > Applied Biometrics GmbH : Have a break! Take a ride on Python's > Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net > 10553 Berlin : PGP key -> http://wwwkeys.pgp.net > PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF > we're tired of banana software - shipped green, ripens at home > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From tismer@appliedbiometrics.com Tue Dec 14 14:30:22 1999 From: tismer@appliedbiometrics.com (Christian Tismer) Date: Tue, 14 Dec 1999 15:30:22 +0100 Subject: [Tutor] static method References: <23EF0668B5D3D111A0CF00805F9FDC4401E43EAD@SRV_EXCH1> Message-ID: <3856547E.65DE3DB9@appliedbiometrics.com> "Yanko, Curtis (GSP)" wrote: > > How can we use this to implement a Singleton Pattern? Well, you can do it. I just looked singletons up at http://www.cs.monash.edu.au/~damian/CSC2050/Topics/09.18.OODesign4/html/text.html#the_singleton_pattern but if you just want a singleton, it really doesn't matter whether this is a class or an instance, so this thingie does it: >>> class Singleton: ... def __init__(self): ... global Singleton ... Singleton = self ... def __call__(self): ... return self ... >>> >>> y=Singleton() >>> x=Singleton() >>> x is y 1 Yes it is a cricular reference. Yes it is dynamic rewrite of a class. Yes it behaves right. >>> x.func = lambda x:x+1 >>> y.func(3) 4 >>> Why? Well, in this case I've put the idea upside down. Assigning a function to an instance does *not* try to bind it, and we are there :-) This all makes not much of sense if you need access to 'self', so put your real methods into the class before overwriting. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From tismer@appliedbiometrics.com Tue Dec 14 14:34:03 1999 From: tismer@appliedbiometrics.com (Christian Tismer) Date: Tue, 14 Dec 1999 15:34:03 +0100 Subject: [Tutor] static method References: <23EF0668B5D3D111A0CF00805F9FDC4401E43EAD@SRV_EXCH1> <3856547E.65DE3DB9@appliedbiometrics.com> Message-ID: <3856555B.DD33809D@appliedbiometrics.com> Christian Tismer wrote: ... > Yes it is a cricular reference. Sorry, no it isn't circular, it's just fine and will vanish when the module vanishes. And you *can* revive it by my_original_singleton = Singleton().__class__ ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From insyte@emt-p.org Tue Dec 14 16:44:55 1999 From: insyte@emt-p.org (Ben Beuchler) Date: Tue, 14 Dec 1999 10:44:55 -0600 (CST) Subject: [Tutor] First script... Message-ID: Well, I've written my very first Python script. Actually, it's my first script of any type... Haven't even had time to debug/test it. It is also a little more ambitious then would have been ideal for my first project, but cest la vie. Anyway, I would appreciate any comments, constructive or of the "you moron" variety. Here's a link to the code: http://www.squad51.net/convert2vpop.py It's designed to convert a mail server from sendmail using /etc/virtusertable to map virtual domains to qmail's vpopmail. This involves creating a whole different directory tree, with subdirectories for each domain and sub-subdirectories for each user and a ./Maildir/ under that. It also involves creating a vpasswd file in each domains subdirectory containing the passwords from /etc/shadow for each real user. I'm not worried about the security implications of this, because if it works we can eliminate all the real accounts required by sendmail and replace 'em with just ONE account for vpopmail. Anyway, that should be enough background to understand what the script is supposed to do. I'm interested in any feedback whatsoever, from bugfixes to overall design. Thanks, Ben -- "There is no spoon" -- The Matrix From fflores@arnet.com.ar Tue Dec 14 13:37:59 1999 From: fflores@arnet.com.ar (FFlores) Date: Tue, 14 Dec 1999 10:37:59 -0300 Subject: [Tutor] Clipboard support Message-ID: <0553c0511010fc9MAIL2@mail2.arnet.com.ar> Is there a way to interface Python with the Windows Clipboard? I'm using Python programs to do heavy text processing, but it's not comfortable to have it write output files constantly! --Pablo Flores http://draseleq.conlang.org/ From DOUGS@oceanic.com Wed Dec 15 17:42:09 1999 From: DOUGS@oceanic.com (Doug Stanfield) Date: Wed, 15 Dec 1999 07:42:09 -1000 Subject: [Tutor] Strings and the % Operator Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0F1BF@huina.oceanic.com> I'm trying to format some text to fit a box that is a variable width. Because its not at all obvious to me where to find the string formatting codes and the % operator in the Python documentation I'll ask here. This should illustrate what I need. This was modeled on an example in the 'Tutorial': [dougs@lawelawe pydev]$ python Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> myString = "A bunch of stuff that exceeds 10 characters" >>> otherString = "or not!" >>> new1 = "[1: %-10s ]" % myString >>> new1 '[1: A bunch of stuff that exceeds 10 characters ]' >>> new2 = "[1: %-10s ]" % otherString >>> new2 '[1: or not! ]' The second case does exactly what I want, but the first doesn't truncate. >>> width = 10 >>> new3 = "[1: %-width s ]" % myString Traceback (innermost last): File "", line 1, in ? ValueError: unsupported format character 'w' (0x77) >>> I've no clue how to proceed with using a variable to format. Regarding the documentation, the % operator doesn't appear in the index of the 'Library Reference'. The TOC has 'String Services' but it doesn't appear there. There is a reference in the index to 'operator' but no %. Its not the first time and won't be the last, but I'm confused. -Doug- From arcege@shore.net Wed Dec 15 19:44:39 1999 From: arcege@shore.net (Michael P. Reilly) Date: Wed, 15 Dec 1999 14:44:39 -0500 (EST) Subject: [Tutor] Strings and the % Operator In-Reply-To: <5650A1190E4FD111BC7E0000F8034D26A0F1BF@huina.oceanic.com> from Doug Stanfield at "Dec 15, 99 07:42:09 am" Message-ID: <199912151944.OAA23808@northshore.shore.net> [Charset iso-8859-1 unsupported, filtering to ASCII...] > I'm trying to format some text to fit a box that is a variable width. > Because its not at all obvious to me where to find the string formatting > codes and the % operator in the Python documentation I'll ask here. This > should illustrate what I need. This was modeled on an example in the > 'Tutorial': > > [dougs@lawelawe pydev]$ python > Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 > (egcs-1.1.1 on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> myString = "A bunch of stuff that exceeds 10 characters" > >>> otherString = "or not!" > >>> new1 = "[1: %-10s ]" % myString > >>> new1 > '[1: A bunch of stuff that exceeds 10 characters ]' > >>> new2 = "[1: %-10s ]" % otherString > >>> new2 > '[1: or not! ]' > > The second case does exactly what I want, but the first doesn't truncate. > > >>> width = 10 > >>> new3 = "[1: %-width s ]" % myString > Traceback (innermost last): > File "", line 1, in ? > ValueError: unsupported format character 'w' (0x77) > >>> > > I've no clue how to proceed with using a variable to format. > > Regarding the documentation, the % operator doesn't appear in the index of > the 'Library Reference'. The TOC has 'String Services' but it doesn't > appear there. There is a reference in the index to 'operator' but no %. > Its not the first time and won't be the last, but I'm confused. > > -Doug- You want to look at section 2.1.5.1 "More String Operations" in the Python Library Reference guide . It assumes some working knowledge of the string formatting used in C and many similar systems. What you want is the "*" directive: >>> myString = "A bunch of stuff that exceeds 10 characters" >>> fmt = '[1: %*.*s ]' >>> # +--- first "*" - width ... # | +--- second "*" - precision ... # | | +--- "s" ... # v v v ... >>> new1 = fmt % (-10, 10, myString) >>> new1 'A bunch of' >>> -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From hackalung@yahoo.com Wed Dec 15 20:51:06 1999 From: hackalung@yahoo.com (Jay Day) Date: Wed, 15 Dec 1999 12:51:06 -0800 (PST) Subject: [Tutor] Questions! Message-ID: <19991215205106.23765.qmail@web3101.mail.yahoo.com> To whom it may concerne, I have downloaded Python but I have no clue how to use it, learn how to use it, or learn the language. I guess you learn the language as you learn to use it but I don't know how to do that. I you could help me get started I would very much appreciate it. Thanx. hackalung __________________________________________________ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one place. Yahoo! Shopping: http://shopping.yahoo.com From deirdre@deirdre.net Wed Dec 15 20:35:02 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 15 Dec 1999 12:35:02 -0800 (PST) Subject: [Tutor] Questions! In-Reply-To: <19991215205106.23765.qmail@web3101.mail.yahoo.com> Message-ID: On Wed, 15 Dec 1999, Jay Day wrote: > I have downloaded Python but I have no clue how to > use it, learn how to use it, or learn the language. I > guess you learn the language as you learn to use it > but I don't know how to do that. I you could help me > get started I would very much appreciate it. Thanx. There is a tutorial at http://www.python.org/doc/ Also, you don't state what operating system you're using. Obviously, the directions *do* vary depending on what you're using. -- _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 hackalung@yahoo.com Wed Dec 15 21:32:55 1999 From: hackalung@yahoo.com (Jay Day) Date: Wed, 15 Dec 1999 13:32:55 -0800 (PST) Subject: [Tutor] ??? Message-ID: <19991215213255.13036.qmail@web3105.mail.yahoo.com> I am using Windows 98 but I have dowloaded and installed Python but I don't know how to use it. Help! I don't know where to begin. If you could help me get started I would very much appreciate it. hackalung __________________________________________________ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one place. Yahoo! Shopping: http://shopping.yahoo.com From irvine_14@yahoo.com Wed Dec 15 22:38:21 1999 From: irvine_14@yahoo.com (Nick) Date: Wed, 15 Dec 1999 14:38:21 -0800 (PST) Subject: [Tutor] (no subject) Message-ID: <19991215223821.7792.qmail@web1903.mail.yahoo.com> I would like to learn python and it looks like you are only website that might help. PLease e-mail me back. __________________________________________________ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one place. Yahoo! Shopping: http://shopping.yahoo.com From denis@carolo.net Thu Dec 16 11:40:15 1999 From: denis@carolo.net (Denis) Date: Thu, 16 Dec 1999 12:40:15 +0100 Subject: [Tutor] ??? References: <19991215213255.13036.qmail@web3105.mail.yahoo.com> Message-ID: <002701bf47ba$51d33ab0$19030a0a@technofutur3.be> > I am using Windows 98 but I have dowloaded and > installed Python but I don't know how to use it. > Help! I don't know where to begin. If you could help > me get started I would very much appreciate it. Why not start at %your python dir%\doc\index.html ? I wish all docs are as complete as this one. From skip@mojam.com (Skip Montanaro) Thu Dec 16 17:20:15 1999 From: skip@mojam.com (Skip Montanaro) (Skip Montanaro) Date: Thu, 16 Dec 1999 11:20:15 -0600 (CST) Subject: [Tutor] Strings and the % Operator In-Reply-To: <5650A1190E4FD111BC7E0000F8034D26A0F1BF@huina.oceanic.com> References: <5650A1190E4FD111BC7E0000F8034D26A0F1BF@huina.oceanic.com> Message-ID: <14425.8015.139431.928343@dolphin.mojam.com> >>> myString = "A bunch of stuff that exceeds 10 characters" >>> otherString = "or not!" >>> new1 = "[1: %-10s ]" % myString >>> new1 '[1: A bunch of stuff that exceeds 10 characters ]' >>> new2 = "[1: %-10s ]" % otherString >>> new2 '[1: or not! ]' Doug> The second case does exactly what I want, but the first doesn't Doug> truncate. Th %-10s doesn't truncate. It will only pad. If you want it truncated, you're going to have to add a precision specifier as Michael described or truncate the string: >>> import string >>> "<%-5s>" % string.digits '<0123456789>' >>> "<%-5.5s>" % string.digits '<01234>' >>> "<%-5s>" % string.digits[0:5] '<01234>' I suspect this might not be very intuitive, but it does match the behavior of C's printf family of functions, from which it's derived. On my Linux system, the printf man page states: In no case does a non-existent or small field width cause truncation of a field; if the result of a conversion is wider than the field width, the field is expanded to contain the conversion result. Cheers, Skip Montanaro | http://www.mojam.com/ skip@mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From skip@mojam.com (Skip Montanaro) Thu Dec 16 17:21:07 1999 From: skip@mojam.com (Skip Montanaro) (Skip Montanaro) Date: Thu, 16 Dec 1999 11:21:07 -0600 (CST) Subject: [Tutor] Strings and the % Operator In-Reply-To: <199912151944.OAA23808@northshore.shore.net> References: <5650A1190E4FD111BC7E0000F8034D26A0F1BF@huina.oceanic.com> <199912151944.OAA23808@northshore.shore.net> Message-ID: <14425.8067.477412.788439@dolphin.mojam.com> >> Regarding the documentation, the % operator doesn't appear in the >> index of the 'Library Reference'. The TOC has 'String Services' but >> it doesn't appear there. There is a reference in the index to >> 'operator' but no %. Its not the first time and won't be the last, >> but I'm confused. Michael> You want to look at section 2.1.5.1 "More String Operations" in Michael> the Python Library Reference guide Which, in my opinion, is the wrong place for it. The Library Reference should document the modules distributed with Python. The Language Reference and the Tutorial are the places to document the behavior of Python's operators. Skip Montanaro | http://www.mojam.com/ skip@mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... Return-Path: Delivered-To: tutor@dinsdale.python.org Received: from python.org (parrot.python.org [132.151.1.90]) by dinsdale.python.org (Postfix) with ESMTP id 5DBF91CED7 for ; Thu, 16 Dec 1999 11:47:00 -0500 (EST) Received: from imo26.mx.aol.com (imo26.mx.aol.com [152.163.225.70]) by python.org (8.9.1a/8.9.1) with ESMTP id LAA00694 for ; Thu, 16 Dec 1999 11:46:59 -0500 (EST) From: DOZBOTZ@aol.com Received: from DOZBOTZ@aol.com by imo26.mx.aol.com (mail_out_v24.6.) id 8.0.c4cc660f (4265) for ; Thu, 16 Dec 1999 11:47:06 -0500 (EST) Message-ID: <0.c4cc660f.258a718a@aol.com> Date: Thu, 16 Dec 1999 11:47:06 EST To: tutor@python.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Windows AOL sub 45 Subject: [Tutor] help Sender: tutor-admin@python.org Errors-To: tutor-admin@python.org X-BeenThere: tutor@python.org X-Mailman-Version: 1.2 (experimental) Precedence: bulk List-Id: Discussion for learning programming with Python i just want to learn the python langue.where can i go for that? From deirdre@deirdre.net Thu Dec 16 23:51:03 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 16 Dec 1999 15:51:03 -0800 (PST) Subject: [Tutor] help In-Reply-To: <0.c4cc660f.258a718a@aol.com> Message-ID: On Thu, 16 Dec 1999 DOZBOTZ@aol.com wrote: > i just want to learn the python langue.where can i go for that? http://www.python.org/doc is a good place to start. I'd especially recommend the tutorial. -- _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 rdatta@yahoo.com Fri Dec 17 02:11:12 1999 From: rdatta@yahoo.com (Raj) Date: Thu, 16 Dec 1999 18:11:12 -0800 Subject: [Tutor] Python port on Open Edition? Message-ID: <00cc01bf4833$fe2569e0$34caaec7@snigdha> I was unable to find the Python binaries for IBM OS390 Open Edition (a Unix variant running on IBM mainframes). Does anyone know if there is such a thing? Thanks, Raj-- To thine self be true. -- I am Rajorshi (Raj) Datta, Software Engineer & Bookworm & Father Hen to Aussie Shepherd Art Santa Clara, CA. USA email:rdatta@yahoo.com web: http://members.tripod.com/~rdatta From vcardona@worldnet.att.net Fri Dec 17 03:16:43 1999 From: vcardona@worldnet.att.net (Victor R . Cardona) Date: Thu, 16 Dec 1999 22:16:43 -0500 Subject: [Tutor] Python port on Open Edition? Message-ID: <19991216221643.A756@utopia.planetia.com> You might try compiling the source code for the latest Python release. I am not sure if there is a port for that particular OS. Victor On Thu, 16 Dec 1999 21:11:12 Raj wrote: > I was unable to find the Python binaries for IBM OS390 Open > Edition (a Unix variant running on IBM mainframes). Does > anyone know if there is such a thing? > > Thanks, > Raj-- > To thine self be true. > -- > I am Rajorshi (Raj) Datta, Software Engineer & Bookworm & Father Hen to > Aussie Shepherd Art > Santa Clara, CA. USA > email:rdatta@yahoo.com web: http://members.tripod.com/~rdatta > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From s349929@student.uq.edu.au Fri Dec 17 05:12:52 1999 From: s349929@student.uq.edu.au (Suzanne Little) Date: Fri, 17 Dec 1999 15:12:52 +1000 (GMT+1000) Subject: [Tutor] some tkinter questions Message-ID: Hello, I've been learning Python for a little over 3 weeks now and I've run into a couple of snags. 1. I've created a window that pops up using toplevel and I want to click 'cancel' in that window and close only that window. Specifically the code is w1 = Toplevel() w1.window = createWin(w1) w1.window.pack() 2. Communication between modules/classes: I've got a main gui window running with a listbox. In anther module I want to add/delete/access an item from the listbox and I'm having some problems. I've got two functions written in the main module which will get the selection and update the list both of which work successfully but I can't call them from the other module. I suspect that this may be because both the modules import each other. That is main imports the sub modules and the sub modules import main, therefore when I start the program by running main it tries to use one of the submodules and gets to the point in it where it tries to access a function in main and fails. What do you think? 3. Is there any easy way of getting the representation of an instance? For example if I create a = myClass() and add a to a kjset, can I then ask what is at some point in the set and get back a as opposed to or something? 4. I've also had some problems attaching a scroll to the listbox. I can get one showing but it will only move one position down. Any suggestions? 5. Can I implement drop down menus in tkinter? Thanks very much for any help anyone can provide. Just add that I'm finding Python a really nice language to work with. Suzanne ----------------------------------------------------------------------- "Contrariwise," continued Tweedledee, "If it was so, it might be; and if it were so, it would be; but as it isn't, it ain't. That's logic" -Lewis Carroll ------------------------------------------------------------------------ From shelton@custommachine.com Fri Dec 17 08:15:24 1999 From: shelton@custommachine.com (Jeffrey N. Shelton) Date: Fri, 17 Dec 1999 03:15:24 -0500 Subject: [Tutor] Regex confusion Message-ID: <003b01bf4866$e0121a10$0201a8c0@mylan.com> Hi! I'm looking at some Python code (from the DT_HTML.py module of Zope, actually) that uses a regex expression that I can't figure out. Perhaps you could point me in the right direction? name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match end_match=regex.compile('[\0- ]*\(/\|end\)',regex.casefold).match start_search=regex.compile('[<&]').search The phrase "[\0- ]" in the first two lines confuses me. Is this a group reference? And if so, what is group 0? I thought the numbering for match groups started at 1. Logically, it would seem that it this phrase is a means for grabbing up leading and trailing dashes and whitespace. But it's beyond me to figure out how "\0" figures into this. Also, the ampersand (&) in the third line is a problem for me. I've looked through my copy of "Mastering Regular Expressions" and can't find any reference to a "&" metacharacter. What am I overlooking? Thanks for the help! Jeff From arcege@shore.net Fri Dec 17 14:41:17 1999 From: arcege@shore.net (Michael P. Reilly) Date: Fri, 17 Dec 1999 09:41:17 -0500 (EST) Subject: [Tutor] Regex confusion In-Reply-To: <003b01bf4866$e0121a10$0201a8c0@mylan.com> from "Jeffrey N. Shelton" at "Dec 17, 99 03:15:24 am" Message-ID: <199912171441.JAA18697@northshore.shore.net> [Charset Windows-1252 unsupported, skipping...] > I'm looking at some Python code (from the DT_HTML.py module of Zope, > actually) that uses a regex expression that I can't figure out. Perhaps you > could point me in the right direction? > > name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match > end_match=regex.compile('[\0- ]*\(/\|end\)',regex.casefold).match > start_search=regex.compile('[<&]').search > > The phrase "[\0- ]" in the first two lines confuses me. Is this a group > reference? And if so, what is group 0? I thought the numbering for match > groups started at 1. Logically, it would seem that it this phrase is a means > for grabbing up leading and trailing dashes and whitespace. But it's beyond > me to figure out how "\0" figures into this. > > Also, the ampersand (&) in the third line is a problem for me. I've looked > through my copy of "Mastering Regular Expressions" and can't find any > reference to a "&" metacharacter. What am I overlooking? Hi Jeffrey, The regular expression [...] is commonly called a character class, it matches any one character against the characters inside the brackets. [<&] - one of the two characters "<" or "&" [\0- ] - any character with ASCII value between 0 ('\0') and 32 (' ') If you include a caret (^) immediately after the left bracket ([), then matching is against characters not in the class. -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From shelton@custommachine.com Fri Dec 17 15:52:29 1999 From: shelton@custommachine.com (Jeffrey N. Shelton) Date: Fri, 17 Dec 1999 10:52:29 -0500 Subject: [Tutor] Regex confusion References: <199912171441.JAA18697@northshore.shore.net> Message-ID: <007f01bf48a6$ba9dd4a0$0201a8c0@mylan.com> Michael P. Reilly wrote: > [Charset Windows-1252 unsupported, skipping...] > > I'm looking at some Python code (from the DT_HTML.py module of Zope, > > actually) that uses a regex expression that I can't figure out. Perhaps you > > could point me in the right direction? > > > > name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match > > end_match=regex.compile('[\0- ]*\(/\|end\)',regex.casefold).match > > start_search=regex.compile('[<&]').search > > > > The phrase "[\0- ]" in the first two lines confuses me. Is this a group > > reference? And if so, what is group 0? I thought the numbering for match > > groups started at 1. Logically, it would seem that it this phrase is a means > > for grabbing up leading and trailing dashes and whitespace. But it's beyond > > me to figure out how "\0" figures into this. > > > > Also, the ampersand (&) in the third line is a problem for me. I've looked > > through my copy of "Mastering Regular Expressions" and can't find any > > reference to a "&" metacharacter. What am I overlooking? > > Hi Jeffrey, > > The regular expression [...] is commonly called a character class, it > matches any one character against the characters inside the brackets. > [<&] - one of the two characters "<" or "&" > [\0- ] - any character with ASCII value between 0 ('\0') and 32 (' ') > > If you include a caret (^) immediately after the left bracket ([), then > matching is against characters not in the class. > > -Arcege Thanks for the help! The "&" usage is now obvious in the light of day. (Doh!) As is the "\0- " phrase, although I think I would have caught on a lot faster if it had been "\0-\32" or, even better, "\000-\032". Anyhow, I'm back on my feet again. Thanks! Jeff From taveren@bigfoot.com Fri Dec 17 21:10:42 1999 From: taveren@bigfoot.com (ge0desic) Date: Fri, 17 Dec 99 17:10:42 -0400 Subject: [Tutor] MacOS Message-ID: <199912172206.OAA18511@penguin.prod.itd.earthlink.net> Hi, First I'd like to say that after several half-hearted attempts (and much procrastination) at learning Perl, I decided to give Python a try based on ESR's recommendation in his book 'The Cathederal and the Bazaar'. I must say that I am very impressed. The language itself is easy to understand and the tutorials/examples I have been looking at are the best I have seen. I actually am beginning to understand alot of the concepts that other resources I have used could not explain coherently. Before I start asking alot of Mac related questions here, I wanted to find out if there are other Mac users on this list. I have discovered that some of the examples I try out don't work on the Mac but do work when I try them at work on Win NT. My interest lies more toward the WWW/CGI aspects of Python and at this time I don't have a *Nix server setup (though it won't be long now). Are there any HTTP servers I can run on top of MacOS that will allow me to play with Python? thanks for the time, David From hnowak@cuci.nl Fri Dec 17 23:08:25 1999 From: hnowak@cuci.nl (Hans Nowak) Date: Sat, 18 Dec 1999 00:08:25 +0100 Subject: [Tutor] some tkinter questions In-Reply-To: Message-ID: <199912172310.XAA06946@dionysus.fw.cuci.nl> On 17 Dec 99, at 15:12, Suzanne Little wrote: > Hello, > > I've been learning Python for a little over 3 weeks now and I've run into > a couple of snags. > > 1. I've created a window that pops up using toplevel and I want to click > 'cancel' in that window and close only that window. Specifically the code > is w1 = Toplevel() > w1.window = createWin(w1) > w1.window.pack() I've stumbled upon this problem last week; I used a slightly different approach, but I think you can use w1.destroy() or maybe w1.window.destroy(). w1.quit() will quit the whole application, as you will probably have found out. > 2. Communication between modules/classes: I've got a main gui window > running with a listbox. In anther module I want to add/delete/access > an item from the listbox and I'm having some problems. I've got two > functions written in the main module which will get the selection and > update the list both of which work successfully but I can't call them from > the other module. I suspect that this may be because both the modules > import each other. That is main imports the sub modules and the sub > modules import main, therefore when I start the program by running main it > tries to use one of the submodules and gets to the point in it where it > tries to access a function in main and fails. What do you think? Normally it should be perfectly possible for two modules to import each other. ----m1.py---- # m1.py def foo(x): return x import m2 m2.bar(1) ----end of m1.py ----m2.py---- # m2.py def bar(x): return x-1 import m1 m1.foo(2) ----end of m2.py This code works; I can start m1.py and m2.py. It doesn't seem to work if you move the import statements to the top, before the function definitions. ...Often, mutual importing is a sign of bad design. I'm not saying this is the case here (and I've had several projects myself where I was obliged to use such constructions), but if moving the import statements (like shown above) doesn't work, maybe you could consider and try redesigning the code. > 3. Is there any easy way of getting the representation of an instance? For > example if I create a = myClass() and add a to a kjset, can I then ask > what is at some point in the set and get back a as opposed to instance 1209ef> or something? I'm assuming a kjset behaves somewhat like a list? If you define the __repr__ method in myClass, you can define what will be printed: (Example IDLE session) >>> class MyClass: def __repr__(self): return "I am a happy class at " + str(id(self)) >>> a = MyClass() >>> a I am a happy class at 8430352 >>> > 4. I've also had some problems attaching a scroll to the listbox. I can > get one showing but it will only move one position down. Any suggestions? Did you try the example mentioned at http://www.pythonware.com/library/tkinter/introduction/x5075- patterns.htm ...? It works for me... > 5. Can I implement drop down menus in tkinter? I don't know if it is included with "standard" Tkinter... I know that Pmw has them though. Hope this helps, --Hans Nowak (zephyrfalcon@hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From steve@spvi.com Sat Dec 18 13:06:14 1999 From: steve@spvi.com (Steve Spicklemire) Date: Sat, 18 Dec 1999 08:06:14 -0500 (EST) Subject: [Tutor] MacOS In-Reply-To: <199912172206.OAA18511@penguin.prod.itd.earthlink.net> (message from ge0desic on Fri, 17 Dec 99 17:10:42 -0400) References: <199912172206.OAA18511@penguin.prod.itd.earthlink.net> Message-ID: <199912181306.IAA23035@acer.spvi.com> Hi David, I'm a "mac" user of python, but I'm not a Mac expert...really. I spend 97% of my 'mac' time running telnet. ;-) I do have a couple of projects that are totally mac though. If you have mac specific questions... I highly recommend the Mac Python sig. http://www.python.org/mailman/listinfo/pythonmac-sig -steve >>>>> "ge0desic" == ge0desic writes: ge0desic> Hi, ge0desic> First I'd like to say that after several half-hearted ge0desic> attempts (and much procrastination) at learning Perl, I ge0desic> decided to give Python a try based on ESR's ge0desic> recommendation in his book 'The Cathederal and the ge0desic> Bazaar'. I must say that I am very impressed. The ge0desic> language itself is easy to understand and the ge0desic> tutorials/examples I have been looking at are the best I ge0desic> have seen. I actually am beginning to understand alot ge0desic> of the concepts that other resources I have used could ge0desic> not explain coherently. ge0desic> Before I start asking alot of Mac related questions ge0desic> here, I wanted to find out if there are other Mac users ge0desic> on this list. I have discovered that some of the ge0desic> examples I try out don't work on the Mac but do work ge0desic> when I try them at work on Win NT. ge0desic> My interest lies more toward the WWW/CGI aspects of ge0desic> Python and at this time I don't have a *Nix server setup ge0desic> (though it won't be long now). Are there any HTTP ge0desic> servers I can run on top of MacOS that will allow me to ge0desic> play with Python? ge0desic> thanks for the time, David ge0desic> _______________________________________________ Tutor ge0desic> maillist - Tutor@python.org ge0desic> http://www.python.org/mailman/listinfo/tutor From fflores@arnet.com.ar Sat Dec 18 14:18:40 1999 From: fflores@arnet.com.ar (FFlores) Date: Sat, 18 Dec 1999 11:18:40 -0300 Subject: [Tutor] Clipboard interface Message-ID: <0d9b630041612c9MAIL1@mail1.arnet.com.ar> I'm sending this for the second time, since I think my mail program went wrong the first: Is there a way to interface Python with the Windows Clipboard? I'm using Python programs to do heavy text processing, but it's not comfortable to have it write output files constantly! --Pablo Flores http://www.geocities.com/pablo-david/index.html From spiderman@nasachem.com Mon Dec 20 02:53:15 1999 From: spiderman@nasachem.com (R Parker) Date: Sun, 19 Dec 1999 20:53:15 -0600 Subject: [Tutor] Classes!Classes!Classes! Message-ID: <385D9A1B.8CEA6111@ghg.net> Hello fellow members of this informative and helpful group. I have been having a lot of trouble with Python as of late and wondered if you could help me. I have studied and studied from books, tutorials and other such materials and have yet to figure how to use classes and what they do. I begin to understand and then there comes a concept that totally stumps me. So if you can..... I would like to know the basics of classes and all the features about them. I would really appreciate it if you can help me. Reminder: I am a first time programmer and Python is my first programming language(so try to make it as simple as possible) Thank you in advance! :-) From skip@mojam.com (Skip Montanaro) Mon Dec 20 17:09:25 1999 From: skip@mojam.com (Skip Montanaro) (Skip Montanaro) Date: Mon, 20 Dec 1999 11:09:25 -0600 (CST) Subject: [Tutor] Classes!Classes!Classes! In-Reply-To: <385D9A1B.8CEA6111@ghg.net> References: <385D9A1B.8CEA6111@ghg.net> Message-ID: <14430.25285.729094.413349@dolphin.mojam.com> RP> I have studied and studied from books, tutorials and other such RP> materials and have yet to figure how to use classes and what they RP> do. I begin to understand and then there comes a concept that RP> totally stumps me. You asked basically the same question just over a month ago (clipped from my response at that time): RP> Hello, I am experiencing trouble understanding classes. I don't RP> understand how they work, what they do and their purpose in RP> general. A couple people responded as I recall. Can you refine your request beyond what you asked then so that perhaps we can do a better job pinpointing your difficulties? That said, I will quote part of my previous post on this subject: There is a subtle shift in perspective from an action-centered view of things to a data-centered view of things that takes place somewhere along the way. When that happens I think most people have an "aha!" sort of experience. It suddenly gels and many problems seem to decompose naturally into objects. Until then (and perhaps frequently after) the world still looks like a bunch of functions with data getting passed around as an afterthought. It would seem you haven't hit the "aha!" point yet. It takes awhile. Go back and continue to study some simple examples. Skip Montanaro | http://www.mojam.com/ skip@mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From spirou@carolo.net Mon Dec 20 20:33:09 1999 From: spirou@carolo.net (Denis) Date: Mon, 20 Dec 1999 21:33:09 +0100 Subject: [Tutor] Classes!Classes!Classes! References: <385D9A1B.8CEA6111@ghg.net> Message-ID: <385E9285.4CF28007@carolo.net> R Parker wrote: > > Hello fellow members of this informative and helpful group. Go on, I love when you speak like this ... ;-) > I have been having a lot of trouble with Python as of late Not possible > and wondered if you could help me. It will not be as easy as learning python > I have studied and studied from books, tutorials and other such > materials and have yet to figure how to use classes and what they do. If that's true, don't shout it too loud ;-) > (...) I would like to know the basics of classes and all the features about > them. I would really appreciate it if you can help me. Reminder: I am a > first time programmer and Python is my first programming language(so try > to make it as simple as possible) I wrote a simple of example for my daughter. She's not yet 12. Tell us if it's that kind of example you're looking for. Of course, my daughter got all the explanations a cheerfull daddy can give. And you won't have those. Moreover you'll find french names as we are Belgian. Is it self explanatory ? If you love that kind of small example and you understand french, you could become a beta tester for my book : "Approach of programmation with Python" (yet to be written). For our children, Python is terrific for the homeworks ! :-) #!/usr/bin/python class rectangle: l = 0 L = 0 def __init__(self, longueur, largeur): self.L = longueur self.l = largeur def perimetre(self): return "(%d + %d) * 2 = %d" % (self.L, self.l, (self.L + self.l)*2) def surface(self): return "%d * %d = %d" % (self.L, self.l, self.L*self.l) def mesures(self): print """Un %s de %d sur %d""" % (self.__class__.__name__, self.L, self.l) print """a une surface de %s""" % (self.surface(),) print """et un perimetre de %s\n""" % (self.perimetre(),) class carre(rectangle): def __init__(self, cote): rectangle.__init__(self, cote, cote) if __name__ == "__main__": r1 = rectangle(15, 30) r1.mesures() r2 = rectangle(9, 17) r2.mesures() c1 = carre(10) c1.mesures() From s349929@student.uq.edu.au Tue Dec 21 00:51:22 1999 From: s349929@student.uq.edu.au (Suzanne Little) Date: Tue, 21 Dec 1999 10:51:22 +1000 (GMT+1000) Subject: [Tutor] some tkinter questions In-Reply-To: Message-ID: Thank you for your help Hans. My listbox is now scrolling happily, I've found some documentation on Pmw and it looks quite useful and I've worked out a way of getting instance representations into my listbox. Unfortunately though, I still can't access elements of my listbox or close my window. I've altered where I have my import statements but this hasn't made any difference. The modules appear to be importing each other correctly but I can't access the listbox. This could also be the problem with closing the window since I can't say w1.destroy because it doesn't know what w1 is. I've tried a number of different ways of calling things but nothing seems to have done anything. If anyone has any suggestions I'd be very grateful. Suzanne ----------------------------------------------------------------------- "Contrariwise," continued Tweedledee, "If it was so, it might be; and if it were so, it would be; but as it isn't, it ain't. That's logic" -Lewis Carroll ------------------------------------------------------------------------ From Taro.Ogawa.73439858@navy.gov.au Tue Dec 21 06:36:59 1999 From: Taro.Ogawa.73439858@navy.gov.au (Taro.Ogawa.73439858@navy.gov.au) Date: Tue, 21 Dec 1999 16:36:59 +1000 Subject: [Tutor] SEC: UNCLASSIFIED:-dynamic binding of functions Message-ID: <4A25684E.0021BC98.00@nschq-e-navy.navy.gov.au> Hi, How do I add a function ("method"?) to a class on the fly? ie: the name and contents of the function is unknown at compile time, but needs to be built at runtime from various bits of information. Alternatively, is there a way to run function foo at compile time to do the same thing? This is more than just macro expansion. (Probably not, but ... ) [This is needed for serious syntactic sugar to avoid the need for 10-50 lines per affected class (I can't just subclass since the needed functions are slightly different for each affected class) where 1 line would do; it'll be run-once for each affected class and I'm willing to have a small speed hit as part of the startup cost] Thanks, --OH. From alan.gauld@bt.com Tue Dec 21 11:14:21 1999 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 21 Dec 1999 11:14:21 -0000 Subject: [Tutor] Classes!Classes!Classes! Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF5F5B@mbtlipnt02.btlabs.bt.co.uk> > help me. I have studied and studied from books, tutorials and > other such Have you tried my tutorial for beginners: http://members.xoom.com/alan_gauld/tutor/tutindex.htm Look at the 'OO' page and the latter parts of the 'Event Driven' and 'Case Study' pages. > I would like to know the basics of classes and all the features about > them. I would really appreciate it if you can help me. Any deficiencies in my tutorial let me know - it can only get better if people tell me what they need! Alan G. From arcege@shore.net Tue Dec 21 13:19:12 1999 From: arcege@shore.net (Michael P. Reilly) Date: Tue, 21 Dec 1999 08:19:12 -0500 (EST) Subject: [Tutor] SEC: UNCLASSIFIED:-dynamic binding of functions In-Reply-To: <4A25684E.0021BC98.00@nschq-e-navy.navy.gov.au> from "Taro.Ogawa.73439858@navy.gov.au" at "Dec 21, 99 04:36:59 pm" Message-ID: <199912211319.IAA06419@northshore.shore.net> > Hi, > > How do I add a function ("method"?) to a class on the fly? > ie: the name and contents of the function is unknown at compile time, > but needs to be built at runtime from various bits of information. > > Alternatively, is there a way to run function foo at compile time to > do the same thing? This is more than just macro expansion. > (Probably not, but ... ) Everything in Python is dynamic, even module compilation is at runtime (the byte-code is cached to the .pyc for later import, but still... ;). Function definitions are statements, and so are class definitions. You can construct new ones and then evaluate them at runtime: >>> def make_multiplier(func_name, howmany, namespace): ... # template for a function, whitespace is important ... funcdef = '''\ ... def %(func_name)s (x): ... return %(howmany)d * x ... ''' % locals ... exec funcdef in namespace >>> make_multiplier('times_two', 2, globals() >>> print times_two(4) 8 >>> This creates functions, but functions are different from unbound methods. I'll leave that as an exercise, but a hint: classes are namespaces too. Then you can call this new method with: >>> spam = Food() >>> method = getattr(spam, 'times_two') >>> result = method(3) > [This is needed for serious syntactic sugar to avoid the need for > 10-50 lines per affected class (I can't just subclass since the > needed functions are slightly different for each affected class) > where 1 line would do; it'll be run-once for each affected class > and I'm willing to have a small speed hit as part of the startup > cost] It's likely that you can still handle the problem with subclassing. Think about what operations are different for the different data, have a generic function do that in the algorithm, then let the subclass override the function. But I won't dispute that it might be easier with a little syntax sugar, but there may be another as easy way. Sometimes it helps to put it away for a little while. :) Good luck, -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From fflores@arnet.com.ar Tue Dec 21 13:51:49 1999 From: fflores@arnet.com.ar (FFlores) Date: Tue, 21 Dec 1999 10:51:49 -0300 Subject: [Tutor] Classes!Classes!Classes! Message-ID: <0c9f541541315c9MAIL2@mail2.arnet.com.ar> R Parker wrote: > > I have studied and studied from books, tutorials and other such > materials and have yet to figure how to use classes and what they do. > OK, I'll try, since I'm just back from an OO Analysis final. (You don't want that!). In OOP (Object Oriented Programming) you organize all data and behaviour inside objects. An object can represent a concrete physical object, or an abstract entity. Examples of objects that can appear in a program: File, HtmlPage, List, Tree, Person. Each object has some data (attributes), like (for a File) name, size, descriptor, position of the pointer, opening mode (R/W etc.). It also has responsabilities, things that it must do when asked -- these are implemented by methods, which are like functions except they are inside the object (e. g. for a File, read(), write(), seek(), etc.). Now, you first identify the objects you need in your program. If you're programming an html page generator, you could have objects like HtmlPage, UnorderedList, Header, etc. But you don't have to specify the structure of each object; you define a class per each type of object you need. Each class is like a pattern for you to produce objects. After a class is defined, you can call it (object = ClassName()) and it will return an object (also called "instance" of the class). Objects are more useful than common variables because you don't have to link functions and values; the object is self-contained and knows what it can do. This saves you from type checking, and lets you do something called polymorphism, which is calling objects of different classes with the same method name, provided both can reply to it after their own fashion. Besides, with classes you can have inheritance. Suppose you have a class named Person, with attributes name, date of birth, social security number, etc. Now, if you need a class named Teacher, which has all the attributes in Person but also some extra ones like a list of courses, you can derive it from Person; it will inherit all attributes and methods, and you can define new ones. To do this you use class Teacher(Person): You can further derive more classes, creating a hierarchy. In the end you could have a lot of object classes, and your program will be composed of objects which call each other's methods, after being created and initialized by the main routine. Hope this helps... --Pablo Flores http://www.geocities.com/pablo-david/index.html http://www.geocities.com/pablo-david/draseleq.html From hnowak@cuci.nl Tue Dec 21 21:22:52 1999 From: hnowak@cuci.nl (Hans Nowak) Date: Tue, 21 Dec 1999 22:22:52 +0100 Subject: [Tutor] some tkinter questions Message-ID: <199912212125.VAA21074@dionysus.fw.cuci.nl> On 21 Dec 99, Suzanne Little wrote: > Thank you for your help Hans. My listbox is now scrolling happily, I've > found some documentation on Pmw and it looks quite useful and I've > worked out a way of getting instance representations into my listbox. > > Unfortunately though, I still can't access elements of my listbox or > close my window. I've altered where I have my import statements but this > hasn't made any difference. The modules appear to be importing each > other correctly but I can't access the listbox. This could also be the > problem with closing the window since I can't say w1.destroy because it > doesn't know what w1 is. I've tried a number of different ways of > calling things but nothing seems to have done anything. If anyone has > any suggestions I'd be very grateful. "It doesn't know what w1 is"... sounds like some variable names are messed up, or declared locally rather than as class attributes, or a missing self, or something like that. :) To be more specific, I need to see more code. If it's a lot, you can mail it to me privately, otherwise you can post it to the mailing list so others may shed their light on it too. --Hans Nowak (zephyrfalcon@hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From cgrove@execpc.com Tue Dec 21 23:10:21 1999 From: cgrove@execpc.com (Christopher Grove) Date: Tue, 21 Dec 1999 17:10:21 -0600 Subject: [Tutor] Re: Classes!Classes!Classes! References: <19991220170008.C8BAE1CDB5@dinsdale.python.org> Message-ID: <386008DD.56F17ECC@execpc.com> I have just started investigating Python, and want to jump in with class questions (to verify if I have gotten to the 'aha!' stage mentioned earlier. Can classes be composed of other (sub)classes? Can classes be composed of multiple copies of the same (sub)class? [I apologize for bastardizing any terminology here, I am trying to put it in my own words (because they are what I understand best).] My self-determined example is house design and definition: House(class) Living room(class) room(class)[1] light(class)[0..n] lr furniture (or would I have multiple classes here, sofas, chairs, tables, etc) color (or would these be attributes of the floor, ceiling, walls) Kitchen(class) room(class) light(class) kitchen furniture kitched appliances . Bathroom(class)[1..n] . Dining room(class) . Bedroom(class)[1..n] room(class) light(class) bedroom furniture . . Room(class) Ceiling(class)[1] Floor(class)[1] Wall(class)[1..n] description dimensions . . Ceiling(class) Composition Color Light(class)[0..n] Fan(class)[0..n] Dimension Wall(class) Composition Color Dimension Window(class)[0..n] Door(class)[0..n] Light(class)[0..n] Lights can be part of the ceiling or wall, or free standing. Can the (sub)class defintion be placed at different levels in the class heirarchy? Do I have to (should I) segment walls (i.e. composition, part of the wall painted, part wall papered, or part painted and part wainscoated, or part ...)? I suppose if I were designing a mansion, I'd have the opportunity for multiple kitchens, etc. From BobbMarly@aol.com Wed Dec 22 00:57:43 1999 From: BobbMarly@aol.com (BobbMarly@aol.com) Date: Tue, 21 Dec 1999 19:57:43 EST Subject: [Tutor] input command Message-ID: <0.a77b78a8.25917c07@aol.com> I am very new at this so please bear with me. When I try the "input" command it seems to automatically print when I try to go to the next line. example: a = input ("What was the score?") I can't get anything after this because it prints automatically when I hit enter. Please help. From s349929@student.uq.edu.au Wed Dec 22 01:19:38 1999 From: s349929@student.uq.edu.au (Suzanne Little) Date: Wed, 22 Dec 1999 11:19:38 +1000 (GMT+1000) Subject: [Tutor] some tkinter questions In-Reply-To: <199912212125.VAA21074@dionysus.fw.cuci.nl> Message-ID: On Tue, 21 Dec 1999, Hans Nowak wrote: > "It doesn't know what w1 is"... sounds like some variable names are > messed up, or declared locally rather than as class attributes, or a > missing self, or something like that. :) To be more specific, I need > to see more code. If it's a lot, you can mail it to me privately, > otherwise you can post it to the mailing list so others may shed > their light on it too. I've been working on a mini version/prototype/whatever you want to call it which just has a listbox and it pops up another window which has buttons. When you press the print button in the other window it should print the currently selected element. This is basically what I need in my 'big' application - to be able to get the currently selected element to perform functions with it. I've attached this trial listbox code to the end of this message. Unfortunately I am going home on Friday for the next 12 days and won't have any computer access. I'll be starting up again on the 4th of Jan but until that time I don't think I'll be able to check my email. Thanks very much for any advice and Merry Christmas everyone. Suzanne #####list.py##### from Tkinter import * from listComp import * class TrialListbox(Frame): def __init__(self, parent=None): Frame.__init__(self, parent) self.pack() self.createWidgets() self.master.title('A Listbox Trial') self.master.iconname('tkpython') def createWidgets(self): self.makeList() self.makeButtons() def makeList(self): frame = Frame(self) frame.pack() scrollbar = Scrollbar(frame, orient=VERTICAL) self.listbox = Listbox(frame, yscrollcommand=scrollbar.set) scrollbar.config(command=self.listbox.yview) scrollbar.pack(side=RIGHT, fill=Y) self.listbox.pack(side=LEFT, fill=BOTH, expand=1) self.listbox.insert(END, 'hello1') #etc etc def makeButtons(self): bframe = Frame(self) bframe.pack(side=BOTTOM) Button(bframe, text='Call Print', command=self.callPrint).pack(side=BOTTOM) Button(bframe, text='Quit', command=self.getOut).pack(side=BOTTOM) def callPrint(self): #open up the window with the print command button w1 = Toplevel() w1.window = ListComp(w1) w1.window.pack() def getOut(self): Frame.quit(self) if __name__ == '__main__': trialListbox().mainloop() #####listComp.py##### from Tkinter import * from list import * class ListComp(Frame): def __init__(self, parent=None): Frame.__init__(self, parent) self.pack() self.createWidgets() def createWidgets(self): bframe = Frame(self) bframe.pack() Button(bframe, text='Print', command=self.Iprint).pack(side=LEFT) Button(bframe, text='Quit', command=self.Iquit).pack(side=LEFT) def Iprint(self): #retreive the element currently selected in the listbox and #print it item = trialListbox.listbox.curselection() member = trialListbox.listbox.get(item) print 'Term: ' + member def Iquit(self): #close this window but not the one with the listbox w1.destroy() ----------------------------------------------------------------------- "Contrariwise," continued Tweedledee, "If it was so, it might be; and if it were so, it would be; but as it isn't, it ain't. That's logic" -Lewis Carroll ------------------------------------------------------------------------ From dragonmoon69@hotmail.com Wed Dec 22 02:22:58 1999 From: dragonmoon69@hotmail.com (alelacasta illalefuma) Date: Tue, 21 Dec 1999 21:22:58 EST Subject: [Tutor] What happens when you download Python??? Message-ID: <19991222022258.54330.qmail@hotmail.com> What happens when you download Python? Does it like replace you browser or something..? Also I heard Python was a language like HTML, if so is there anywhere i can go that will teach me how to read it? Thank You, dragonmoon69@hotmail.com ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From warren@nightwares.com Wed Dec 22 14:05:56 1999 From: warren@nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Wed, 22 Dec 1999 08:05:56 -0600 Subject: [Tutor] What happens when you download Python??? References: <19991222022258.54330.qmail@hotmail.com> Message-ID: <3860DAC4.F67A1857@nightwares.com> alelacasta illalefuma wrote: > What happens when you download Python? Does it like replace you browser or > something..? No. It's just a plain old executable like pretty much any other program or programming environment. You DL it, install it, and then basically do what you want with it. > Also I heard Python was a language like HTML, if so is there > anywhere i can go that will teach me how to read it? It is nothing like HTML; HTML is a method primarily of formatting text and images, whereas Python is used to issue commands to the computer. The two don't resemble each other either. It's got more in common with high-level languages such as HyperTalk, MetaTalk and Lingo. The Python site, www.python.org, is the very best place to start looking it over. Hope this helps! --WthmO Bad news hits hard. Only The Indigestible punches back. http://www.the-indigestible.com/ From tismer@appliedbiometrics.com Wed Dec 22 16:34:12 1999 From: tismer@appliedbiometrics.com (Christian Tismer) Date: Wed, 22 Dec 1999 17:34:12 +0100 Subject: [Tutor] Re: Classes!Classes!Classes! References: <19991220170008.C8BAE1CDB5@dinsdale.python.org> <386008DD.56F17ECC@execpc.com> Message-ID: <3860FD84.41618F6E@appliedbiometrics.com> Lessee :-) Christopher Grove wrote: > > I have just started investigating Python, and want to jump in with class > questions (to verify if I have gotten to the 'aha!' stage mentioned > earlier. First of all, I highly recommend to learn a lot about tuples, lists, dicts, and a couple of standard modules before diving into classes. Not that they are too difficult, but everything ismuch easier when you have your tools ready. For instance, you should not need to wonder what a dictionary is, when I advise you to look at your class's __dict__ at some time. > Can classes be composed of other (sub)classes? Yes. > Can classes be composed of multiple copies of the same (sub)class? There cannot be multiple copes of a subclass. It is the same subclass, or it is a different subclass. If it is the same, then it is identical. > [I apologize for bastardizing any terminology here, I am trying to put > it in my own words (because they are what I understand best).] > > My self-determined example is house design and definition: What you need to build your house is a bit different. The class system is not meant to build actual objects with classes as building blocks to fit together. What you need are instances (rooms) which are inserted into your house instance, as attributes. Houses do not inherit from rooms or vice versa, they "have" them. This is acquisition, not inheritance. > House(class) > Living room(class) > room(class)[1] > light(class)[0..n] > lr furniture (or would I have multiple classes here, > sofas, chairs, tables, etc) > color (or would these be attributes of the floor, > ceiling, walls) > Kitchen(class) > room(class) > light(class) > kitchen furniture > kitched appliances > . > Bathroom(class)[1..n] > . > Dining room(class) > . > Bedroom(class)[1..n] > room(class) > light(class) > bedroom furniture > . > . > > Room(class) > Ceiling(class)[1] > Floor(class)[1] > Wall(class)[1..n] > description > dimensions > . > . > Ceiling(class) > Composition > Color > Light(class)[0..n] > Fan(class)[0..n] > Dimension > Wall(class) > Composition > Color > Dimension > Window(class)[0..n] > Door(class)[0..n] > Light(class)[0..n] class Room: # static properties def __init__(self, arg1, arg2...): # dynamic, instance specific initilization class Bathroom(room): # like all rooms, but also with this: def __int__(self): Room.__init__(self) # inerited init self.occupied = 0 def occupy(self, who): self.occupied = who # no time for a better example :-) class Building: # set some generic default methods, perhaps def House(Building): # # now, without a special class, I assemble the house, simply by # adding pieces as attributes. # Of course one could invent a factory class which does this, # according to a plan. Try this as an exercise... # simply building a house: myHouse = House() myHouse.bath = Batchroom() mHouse.livingroom = Room() # ... > Lights can be part of the ceiling or wall, or free standing. Can the > (sub)class defintion be placed at different levels in the class > heirarchy? I think this would abuse the class idea, if possible at all. Where you put your lights in your object depends on what you intend to do on lights. Their position at other objects need not, but can be useful. You could attach a light instance as an attribute of an object, perhaps a wall if that is part of a room. You could then write a method which gives you a list of all lights in your house, or you inquire the rooms each. That's your design problem. You need to play with that and figure out. But it has very few to do with inheritance. These are attributes. Classes do not express "thing a contains thing b", they express "thing b is like thing a, but has the following different/additional properties". Classes are an abstract concept. It does not deal with your house directly, and with its particular rooms, walls and lights, but it tells "about houses". You build it by contructing instances. > Do I have to (should I) segment walls (i.e. composition, part of the > wall painted, part wall papered, or part painted and part wainscoated, > or part ...)? That's a matter of taste. Just make sure that you can pla with rooms as a whole, without having to deal with the walls. And with walls without having to care about wall paper. > I suppose if I were designing a mansion, I'd have the opportunity for > multiple kitchens, etc. Yes. And then you will recognize that this is not always a hierarchical system. In some houses, several parties are sharing two kitchens, and "belongs to" is not well-defined. Try to avoid strong hierarchy, since it will break anyway. It does make sense to enumerate and name the rooms of the house. If i tis of interest, their size can be kept as attributes, and the overall layout can be modelled by which walls are shared for instance. For starting, make everything as simple as possible, and think of what you are going to ask your house before you build it. There are so many possibilities, that you chance to get the wrong model at the first time is very likely. Again at your "multiple copies of the same subclass": What you mean is many similar rooms, with many similar but different walls. This should be done with a decent set of classes, and all your objects are instances. The "Multiple copy" issue is solved by instances, since a class can produce as many objects of that kind as you like. Then, you need to insert them into your house, as attributes [ myHouse.someroom = Room() ] or as elements of other structures: myHouse.rooms.append( Room() ) You can assemble your parts before of after inserting them: someRoom = Room(): # call some fuctions to modify the room, or # do it simply in this direct manner: someRoom.size = 40 # square meters # now add it to the house myHouse.livingroom = someRoom myHouse.livingroom.desk = Desk(color="brown") This is a matter of taste. Try it and get a feeling of it. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From alan.gauld@bt.com Wed Dec 22 17:47:57 1999 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 22 Dec 1999 17:47:57 -0000 Subject: [Tutor] input command Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF5F73@mbtlipnt02.btlabs.bt.co.uk> > I am very new at this so please bear with me. > > When I try the "input" command it seems to automatically > print when I try to > go to the next line. input is for numbers only! You may need raw_input()... But it sounds like you are typing this in the interactive prompt mode. You probably need to type your program into a separate file and then run that from the Unix/DOS prompt like: C:>python myprog.py Visit my tutor and look at the 'Talking to the user' and 'modules and functions' sections... http://members.xoom.com/alan_gauld/tutor/tutindex.htm If you really want to do it from the interactive prompt, simply type in your value and hit return. This will return you to the >>> where you can carry on inputting your program. The value you entered will be stored in 'a'. Thus: >>>a = input ("Hit it: ") Hit it: 12 >>>print a 12 >>> Alan G. From markus.barthbellot@ctv.es Thu Dec 23 15:38:30 1999 From: markus.barthbellot@ctv.es (Barth Bellot, S.L.) Date: Thu, 23 Dec 1999 16:38:30 +0100 Subject: [Tutor] (no subject) Message-ID: <3.0.6.32.19991223163830.007bd8d0@pop.ctv.es> I have just started to get familiar with Python - Python may soon become what once used to be Turbo Pascal on the 80286/80386 platforms... My problem: I would like to get the main window app packed in its own class and every other window packed in a different class. Unfortunately all docs I have found treat these subject in a functional and not object oriented style. The biggest problem is the Main Window Menu. I would be very graceful for a couple of example lines which show how this can be done. From skip@mojam.com (Skip Montanaro) Thu Dec 23 18:01:56 1999 From: skip@mojam.com (Skip Montanaro) (Skip Montanaro) Date: Thu, 23 Dec 1999 12:01:56 -0600 (CST) Subject: [Tutor] Re: Classes!Classes!Classes! In-Reply-To: <386008DD.56F17ECC@execpc.com> References: <19991220170008.C8BAE1CDB5@dinsdale.python.org> <386008DD.56F17ECC@execpc.com> Message-ID: <14434.25492.127513.721379@dolphin.mojam.com> CG> Can classes be composed of other (sub)classes? CG> Can classes be composed of multiple copies of the same (sub)class? In a manner of speaking. What you're asking about is generally called aggregation. The technique you'd normally use in Python (as Chris Tismer pointed out) would be to define one or more instance attributes that reference different pieces of the aggregate. Depending how you want to structure things you might have something simple (one instance attribute, rooms) like class Room: def __init__(self, width, length, height=8): self.width = width self.length = length self.height = height def dimensions(self): return (self.width, self.length, self.height) class House: def __init__(self): self.rooms = [] def addroom(self, room): self.rooms.append(room) def dimensions(self): dims = [] for r in self.rooms: dims.append((r.__class__.__name__, r.dimensions())) return dims def getRoomsOfType(self, cls): rooms = [] for r in self.rooms: if r.__class__ == cls: rooms.append(r) return rooms class LivingRoom(Room): pass ; class BedRoom(Room): pass ; class BathRoom(Room): pass ; class Kitchen(Room): pass ; class Garage(Room): pass ; house = House() house.addroom(LivingRoom(20,20)) house.addroom(BedRoom(15,15)) house.addroom(BedRoom(10,10)) house.addroom(BedRoom(12,13)) house.addroom(BathRoom(6,8)) house.addroom(BathRoom(10,10)) house.addroom(Kitchen(9,15)) house.addroom(Garage(22,22,10)) print house.dimensions() print house.getRoomsOfType(BedRoom) (which most Americans will recognize as the standard 3-bedroom, 2-bath ranch style home. ;-) You can, of course, get more complex defining individual instance attributes for each of the different types of rooms. The House.dimensions method demonstrates one way to delegate a method call to the aggregate object (the house) to a collection of subobjects (in this case, the rooms). The House.getRoomsOfType method demonstrates one way to select those rooms of a particular type. Skip Montanaro | http://www.mojam.com/ skip@mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From eroubinc@u.washington.edu Thu Dec 23 21:50:11 1999 From: eroubinc@u.washington.edu (Evgeny Roubinchtein) Date: Thu, 23 Dec 1999 13:50:11 -0800 (PST) Subject: [Tutor] some tkinter questions In-Reply-To: Message-ID: On Wed, 22 Dec 1999, Suzanne Little wrote: >I've been working on a mini version/prototype/whatever you want to call it >which just has a listbox and it pops up another window which has >buttons. When you press the print button in the other window it should >print the currently selected element. This is basically what I need in my >'big' application - to be able to get the currently selected element to >perform functions with it. I've made a couple simple changes to your code, and it appears to do what you want now. It is sort of "Java-style" (in that I am passing reference to the listbox window around) -- there have to be better ways to do this with Python. #####listComp.py##### from Tkinter import * from list import * class ListComp(Frame): def __init__(self, parent=None, listBox=None): Frame.__init__(self, parent) # save a reference to the listBox we're # getting the items from self.trialListbox = listBox # save a reference to our parent window self.w1 = parent self.pack() self.createWidgets() def createWidgets(self): bframe = Frame(self) bframe.pack() Button(bframe, text='Print', command=self.Iprint).pack(side=LEFT) Button(bframe, text='Quit', command=self.Iquit).pack(side=LEFT) def Iprint(self): #retreive the element currently selected in the listbox and #print it # here, we use the reference we saved in the constructor if self.trialListbox != None: item = self.trialListbox.listbox.curselection() member = self.trialListbox.listbox.get(item) print 'Term: ' + member def Iquit(self): #close this window but not the one with the listbox # actually, close our parent, again we saved the reference # in the constructor. self.w1.destroy() #####list.py##### from Tkinter import * from listComp import * class TrialListbox(Frame): def __init__(self, parent=None): Frame.__init__(self, parent) self.pack() self.createWidgets() self.master.title('A Listbox Trial') self.master.iconname('tkpython') def createWidgets(self): self.makeList() self.makeButtons() def makeList(self): frame = Frame(self) frame.pack() scrollbar = Scrollbar(frame, orient=VERTICAL) self.listbox = Listbox(frame, yscrollcommand=scrollbar.set) scrollbar.config(command=self.listbox.yview) scrollbar.pack(side=RIGHT, fill=Y) self.listbox.pack(side=LEFT, fill=BOTH, expand=1) self.listbox.insert(END, 'hello1') #etc etc def makeButtons(self): bframe = Frame(self) bframe.pack(side=BOTTOM) Button(bframe, text='Call Print', command=self.callPrint).pack(side=BOTTOM) Button(bframe, text='Quit', command=self.getOut).pack(side=BOTTOM) def callPrint(self): #open up the window with the print command button w1 = Toplevel() # pass a reference to ourselves to the # ListComp, so it can get at our listbox w1.window = ListComp(w1, self) w1.window.pack() def getOut(self): Frame.quit(self) if __name__ == '__main__': app = TrialListbox() app.mainloop() -- Evgeny Performance is easier to add than clarity. From insyte@ender.squad51.net Fri Dec 24 03:57:54 1999 From: insyte@ender.squad51.net (Ben Beuchler) Date: Thu, 23 Dec 1999 21:57:54 -0600 (CST) Subject: [Tutor] dbg Message-ID: I've read the documentation on the debugging module but a lot of it went right over my head. I've written a rather large (for me, anyway) script that I would like to step through to make sure it's working properly. Is there a nice, simple way to step through a python program while monitoring the state of a few variables? Thanks, Ben From eroubinc@u.washington.edu Fri Dec 24 03:49:46 1999 From: eroubinc@u.washington.edu (Evgeny Roubinchtein) Date: Thu, 23 Dec 1999 19:49:46 -0800 (PST) Subject: [Tutor] dbg In-Reply-To: Message-ID: On Thu, 23 Dec 1999, Ben Beuchler wrote: >Is there a nice, simple way to step through a python program while >monitoring the state of a few variables? Use the debugger that comes with IDLE? -- Evgeny RDRI: Rotate Disk Right Immediate From FIRSTSTEP822@aol.com Fri Dec 24 04:17:26 1999 From: FIRSTSTEP822@aol.com (FIRSTSTEP822@aol.com) Date: Thu, 23 Dec 1999 23:17:26 EST Subject: [Tutor] =?ISO-8859-1?Q?Fwd:=20=95Python=20with=20networking=95?= Message-ID: <0.c1d9afbb.25944dd6@aol.com> --part1_0.c1d9afbb.25944dd6_boundary Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Subj: python hi, I'm really don't know much about python..right.!. i'm planing to get into the Networking field, I waant to ask if learning Python would help me in anyway as a network engineer. thanks for your time... ray. --part1_0.c1d9afbb.25944dd6_boundary Content-Type: message/rfc822 Content-Disposition: inline Return-path: FIRSTSTEP822@aol.com From: FIRSTSTEP822@aol.com Full-name: FIRSTSTEP822 Message-ID: <0.53ae17db.25944b9c@aol.com> Date: Thu, 23 Dec 1999 23:07:56 EST Subject: =?ISO-8859-1?Q?=95Python=20with=20networking=95?= To: webmaster@python.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: AOL 4.0 for Windows sub 243 Subj: python hi, I'm really don't know much about python..right.!. i'm planing to get into the Networking field, I waant to ask if learning Python would help me in anyway as a network engineer. thanks for your time... ray. --part1_0.c1d9afbb.25944dd6_boundary-- From Sam LeFlore" I would like to have recommendations on which version of Linux to purchase. I would like to learn the Python Language and would like the opportunity to read open source code but I am unfamiliar with any other operating system except windows. Thanks Sam LeFlore From insyte@emt-p.org Sat Dec 25 03:55:23 1999 From: insyte@emt-p.org (Ben Beuchler) Date: Fri, 24 Dec 1999 21:55:23 -0600 (CST) Subject: [Tutor] dbg In-Reply-To: Message-ID: On Thu, 23 Dec 1999, Evgeny Roubinchtein wrote: > >Is there a nice, simple way to step through a python program while > >monitoring the state of a few variables? > > Use the debugger that comes with IDLE? I'm sorry. What is IDLE? I believe I've heard it mentioned before but searching on that term obviously would be non-productive. ;-) Ben -- "There is no spoon" -- The Matrix From eroubinc@u.washington.edu Sat Dec 25 06:55:47 1999 From: eroubinc@u.washington.edu (Evgeny Roubinchtein) Date: Fri, 24 Dec 1999 22:55:47 -0800 (PST) Subject: [Tutor] dbg In-Reply-To: Message-ID: On Fri, 24 Dec 1999, Ben Beuchler wrote: >On Thu, 23 Dec 1999, Evgeny Roubinchtein wrote: > >> >Is there a nice, simple way to step through a python program while >> >monitoring the state of a few variables? >> >> Use the debugger that comes with IDLE? > >I'm sorry. What is IDLE? I believe I've heard it mentioned before but >searching on that term obviously would be non-productive. ;-) It's the integraded development environment(IDE) for Python written in Python. It uses Tkinter, so you need to have Tkinter and TCL/TK installed. What platform are running on? I believe the Windows installer puts an icon to start IDLE in the Python program group, and installs TCL/TK if you just "take the default". Under Un*x/Linux, it lives below the "Tools" directory in the source distribution. I saw a mention of a separate idle tarball on the Python web site (www.python.org), but I don't remember much more than that. If you need more detailed instructions, you should probably say what platform you are using (Windows, Linux, other Unix, Mac ?) -- Evgeny "Virtual" means never knowing where your next byte is coming from. From alan.gauld@freenet.co.uk Sat Dec 25 22:52:33 1999 From: alan.gauld@freenet.co.uk (Alan Gauld) Date: Sat, 25 Dec 1999 22:52:33 +0000 Subject: [Tutor] Tkinter radio buttons Message-ID: <3.0.1.32.19991225225233.008735c0@mail.freenet.co.uk> I tried a simple radiobutton app but the suggested behaviour didn't happen. I needed to add a command function. Is this normal in Tkinter or am I missing something? The code below doesn't work, but will if you uncomment the commented out lines. I thought Tk should update the variable automagically...? Alan G. -------------------------------------- from Tkinter import * rv=0 def DoIt(): print rv #def doZero(): # global rv # rv = 0 #def doOne(): # global rv # rv = 1 app = Frame() r1 = Radiobutton(app, variable=rv, value=0, text="Zero", # command=doZero ) r1.pack() r2 = Radiobutton(app, variable=rv, value=1, text="One", # command=doOne ) r2.pack() r1.select() b = Button(app, text="Showme", command=DoIt) b.pack() app.pack() app.mainloop() From ivanlan@callware.com Sun Dec 26 00:33:51 1999 From: ivanlan@callware.com (Ivan Van Laningham) Date: Sat, 25 Dec 1999 17:33:51 -0700 Subject: [Tutor] Tkinter radio buttons References: <3.0.1.32.19991225225233.008735c0@mail.freenet.co.uk> Message-ID: <3865626F.FA4CBD81@callware.com> Hi All-- Alan Gauld wrote: > > I tried a simple radiobutton app but the suggested > behaviour didn't happen. I needed to add a command > function. Is this normal in Tkinter or am I missing > something? > > The code below doesn't work, but will if you > uncomment the commented out lines. I thought Tk > should update the variable automagically...? > If you change the variable from a Python variable to a Tkinter variable, it will work. ... -ly y'rs, Ivan > -------------------------------------- > from Tkinter import * > > rv=0 > > def DoIt(): > print rv > > #def doZero(): > # global rv > # rv = 0 > > #def doOne(): > # global rv > # rv = 1 > > app = Frame() > r1 = Radiobutton(app, > variable=rv, value=0, > text="Zero", # command=doZero > ) > r1.pack() > r2 = Radiobutton(app, > variable=rv, value=1, > text="One", # command=doOne > ) > r2.pack() > r1.select() > > b = Button(app, text="Showme", command=DoIt) > b.pack() > > app.pack() > app.mainloop() > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor -- ---------------------------------------------- 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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From warren@nightwares.com Sun Dec 26 00:44:36 1999 From: warren@nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Sat, 25 Dec 1999 18:44:36 -0600 Subject: [Tutor] Python References: <001201bf4e27$421dbf00$1aea5e18@mmcable.com> Message-ID: <386564F4.3A4539C4@nightwares.com> Sam LeFlore wrote: > I would like to have recommendations on which version of Linux to purchase. Red Hat seems to be the most popular, partly I guess because of name presence, and partly because it makes admin relatively easy. I've heard good things about SuSE though, as well. What I've found with Red Hat is that you need to be careful if you're using relatively new, high-end, flashy hardware, since odds are pretty good the drivers haven't been produced for such stuff yet. So while you might be able to get a more or less functional GUI going, you may not be able to take it out of 16-color 640x480 mode without a little experimenting with the config files for the monitor card. What I'd recommend is installing it on its own computer rather than on the main one you use. If you can pick up a decent pre-owned box for a relatively low price, it's probably a good start to try it out on, epsecially if it's already running Win95, since it should be able to handle Lin as well. I say this because you might get into a tangle with the install procedure and it's good to have another machine so you can go online and seek help if you need it. Here I dualboot Lin and NT, but generally stay on the NT side because of my software development needs. > I would like to learn the Python Language and would like the opportunity to > read open source code but I am unfamiliar with any other operating system > except windows. Well bear in mind that open source is just that -- raw, uncompiled C or C++. It can be hairy. If you're more interested in Python, there's no reason you can't DL the Windows version of that and use it in the environment whith which you are the most comfortable, and then move on to Linux when you feel ready. Linux is, after all, UNIX, and UNIX is a monster of an OS. Terribly powerful but very confusing if you've had little or no experience with it. Hope this helps! -- warren ockrassa | nightwares | mailto:warren@nightwares.com Bad news hits hard. Only The Indigestible punches back. http://www.the-indigestible.com/ From deirdre@deirdre.net Sun Dec 26 19:54:00 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sun, 26 Dec 1999 11:54:00 -0800 (PST) Subject: [Tutor] Python In-Reply-To: <386564F4.3A4539C4@nightwares.com> Message-ID: On Sat, 25 Dec 1999, Warren 'The Howdy Man' Ockrassa wrote: > Sam LeFlore wrote: > > > I would like to have recommendations on which version of Linux to purchase. > > Red Hat seems to be the most popular, partly I guess because of name > presence, and partly because it makes admin relatively easy. > > I've heard good things about SuSE though, as well. What I've found with > Red Hat is that you need to be careful if you're using relatively new, > high-end, flashy hardware, since odds are pretty good the drivers > haven't been produced for such stuff yet. So while you might be able to > get a more or less functional GUI going, you may not be able to take it > out of 16-color 640x480 mode without a little experimenting with the > config files for the monitor card. While I personally love SuSE and have been using it as my creature comfort distro for a long time, y'all might consider the new Corel distro. It looks like it has everything SuSE does and is wrapped around Debian which has cool tools like: apt-get dist-upgrade ...for upgrading everything at once. :) -- _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@teleo.net Sun Dec 26 21:25:23 1999 From: python@teleo.net (Patrick Phalen) Date: Sun, 26 Dec 1999 13:25:23 -0800 Subject: [Tutor] Python In-Reply-To: References: Message-ID: <99122613270501.01988@quadra.teleo.net> [Deirdre Saoirse, on Sun, 26 Dec 1999] :: While I personally love SuSE and have been using it as my creature comfort :: distro for a long time, y'all might consider the new Corel distro. It :: looks like it has everything SuSE does and is wrapped around Debian which :: has cool tools like: :: :: apt-get dist-upgrade :: :: ...for upgrading everything at once. :) RedHat's Update Agent does this too, with a nice GUI (since 6.1) From spirou@carolo.net Sun Dec 26 21:35:10 1999 From: spirou@carolo.net (Denis) Date: Sun, 26 Dec 1999 22:35:10 +0100 Subject: [Tutor] Python References: <99122613270501.01988@quadra.teleo.net> Message-ID: <38668A0E.7E376536@carolo.net> Patrick Phalen wrote: > > [Deirdre Saoirse, on Sun, 26 Dec 1999] > > :: While I personally love SuSE and have been using it as my creature > :: comfort distro for a long time, y'all might consider the new Corel > :: distro. It looks like it has everything SuSE does and is wrapped > :: around Debian which (...) > > RedHat's (...)does this too (...) There are so many truthes ! :-) If you have a friend who can help you, choose the same distribution as he uses. Or keep your OS while you're learning Python. Python doesn't care. You should perhaps go a step at a time. Denis From tinja@hotmail.com Wed Dec 29 21:02:36 1999 From: tinja@hotmail.com (Brack Hall) Date: Wed, 29 Dec 1999 21:02:36 GMT Subject: [Tutor] Start me off please.. Message-ID: <19991229210236.88601.qmail@hotmail.com> Hi ..my name is Brack. I am a beginer at learning Python language. Could someone please tell me where do i begin on preparing to learn this language? Thanks for your time. Sincerly, Brack ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From warren@nightwares.com Wed Dec 29 21:22:39 1999 From: warren@nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Wed, 29 Dec 1999 15:22:39 -0600 Subject: [Tutor] Start me off please.. References: <19991229210236.88601.qmail@hotmail.com> Message-ID: <386A7B9F.96A9F01B@nightwares.com> Brack Hall wrote: > Hi ..my name is Brack. Howdy, Brack! > I am a beginer at learning Python language. Could > someone please tell me where do i begin on preparing to learn this language? Well, if you're familiar with other programming or scripting environments you're most of the way home conceptually already. A great place to begin general net surfing for tutorials, book references and so on is http://www.python.org/ -- a massive cache of very useful data. There are also a couple of usenet groups dedicated to Python, though the most commonly trafficked one seems to be comp.lang.python. Does that help? -- warren ockrassa | nightwares | mailto:warren@nightwares.com Bad news hits hard. Only The Indigestible punches back. http://www.the-indigestible.com/ From deirdre@deirdre.net Wed Dec 29 21:05:47 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 29 Dec 1999 13:05:47 -0800 (PST) Subject: [Tutor] Start me off please.. In-Reply-To: <19991229210236.88601.qmail@hotmail.com> Message-ID: On Wed, 29 Dec 1999, Brack Hall wrote: > Hi ..my name is Brack. I am a beginer at learning Python language. > Could someone please tell me where do i begin on preparing to learn > this language? There's a good tutorial at: http://www.python.org/doc/current/tut/tut.html -- _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