From fellst@oppenheim.de Thu Mar 2 01:41:35 2000 From: fellst@oppenheim.de (fellst@oppenheim.de) Date: Thu, 2 Mar 2000 01:41:35 Subject: [Tutor] (no subject) Message-ID: <875.608257.76638@mail.mindspring.com> GET YOUR OWN 5 MEG WEBSITE FOR ONLY 12.95 PER MONTH TODAY! STOP PAYING 19.95 or more PER MONTH OR MORE TODAY for your web site! Thank you for subscribing to our mailing list. Remove instructions are below if you wish no further mailings in the future! DO YOU ALREADY HAVE A WEBSITE? ALL YOU HAVE TO DO IS TRANSFER THE DOMAIN TO OUR SERVERS AND UPLOAD YOUR DATA AND YOU ARE READY TO GO! YOUR NEW WEB SPACE CAN BE CREATED INSTANTLY WITH JUST A SIMPLE PHONE CALL OUR OFFICE. YOU CAN CHANGE YOUR SITE AS MUCH AS YOU WANT! A SET UP FEE OF $40.00 APPLIES for FIRST TIME CUSTOMERS. FOR DETAILS CALL 1 888 248 0765 THANK YOU to be removed email pro@natas.kfa.cx From David.Hicks@cna.com Wed Mar 1 17:18:51 2000 From: David.Hicks@cna.com (Hicks,David P.(NXI)) Date: Wed, 1 Mar 2000 11:18:51 -0600 Subject: [Tutor] Requesting input, waiting a fixed time Message-ID: <2DF4CF48CC53D211B84A0008C7280F3304D0D563@wch1xp04.cna.com> Is there a "standard" Python way of accomplishing this?: Ask the user to answer "Yes" or "No" If he/she responds, process the answer. If there is no response for 3 minutes, assume the answer is "Yes" and process. Any hints would be appreciated. Thanks. Dave Hicks david.hicks@cna.com From wesc@alpha.ece.ucsb.edu Wed Mar 1 17:44:09 2000 From: wesc@alpha.ece.ucsb.edu (Wesley J. Chun) Date: Wed, 1 Mar 2000 09:44:09 -0800 (PST) Subject: [Tutor] learning a Programming language Message-ID: <200003011744.JAA13436@alpha.ece.ucsb.edu> > Date: Tue, 29 Feb 2000 03:31:06 -0800 (PST) > From: Deirdre Saoirse > > On Wed, 1 Mar 2000, Legacy wrote: > > Visual Basic is best suited for GUI applications i'll add to deirdre's comments. altho VB is a good tool for GUI apps, so is Python and Tkinter (at a minimum). you can develop GUI apps in Python with Tkinter/Pmw or wxPython that will blow any VB GUIs apps away. hope this helps!! -wesley cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From danstar@execpc.com Wed Mar 1 19:23:43 2000 From: danstar@execpc.com (Dan Star) Date: Wed, 01 Mar 2000 13:23:43 -0600 Subject: [Fwd: [Tutor] learning a Programming language] Message-ID: <38BD6E3F.2A452562@execpc.com> This is a multi-part message in MIME format. --------------46D7C9091F8D85CC60001099 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit --------------46D7C9091F8D85CC60001099 Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Mozilla-Status2: 00000000 Message-ID: <38BD6E18.7A4BE968@execpc.com> Date: Wed, 01 Mar 2000 13:23:04 -0600 From: Dan Star Reply-To: danstar@execpc.com Organization: ETCO X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 To: "Wesley J. Chun" Subject: Re: [Tutor] learning a Programming language References: <200003011744.JAA13436@alpha.ece.ucsb.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit But there is no Grid support in Python or has this recently changes. VB has a multitude of grids which are critical to database oriented apps. -Dan P.S. Delphi is arguably as easy to learn as VB (BTW) and is much more powerful. "Wesley J. Chun" wrote: > > > Date: Tue, 29 Feb 2000 03:31:06 -0800 (PST) > > From: Deirdre Saoirse > > > > On Wed, 1 Mar 2000, Legacy wrote: > > > > Visual Basic is best suited for GUI applications > > i'll add to deirdre's comments. altho VB is a good tool > for GUI apps, so is Python and Tkinter (at a minimum). > > you can develop GUI apps in Python with Tkinter/Pmw or > wxPython that will blow any VB GUIs apps away. > > hope this helps!! > > -wesley > cyberweb.consulting :: silicon.valley, ca > http://www.roadkill.com/~wesc/cyberweb/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor --------------46D7C9091F8D85CC60001099-- From gerrit@nl.linux.org Wed Mar 1 19:35:27 2000 From: gerrit@nl.linux.org (Gerrit Holl) Date: Wed, 1 Mar 2000 20:35:27 +0100 Subject: [Tutor] Requesting input, waiting a fixed time In-Reply-To: <2DF4CF48CC53D211B84A0008C7280F3304D0D563@wch1xp04.cna.com>; from David.Hicks@cna.com on Wed, Mar 01, 2000 at 11:18:51AM -0600 References: <2DF4CF48CC53D211B84A0008C7280F3304D0D563@wch1xp04.cna.com> Message-ID: <20000301203527.B16094@nl.linux.org> > Is there a "standard" Python way of accomplishing this?: > > Ask the user to answer "Yes" or "No" > If he/she responds, process the answer. > If there is no response for 3 minutes, assume the answer is "Yes" and > process. > > Any hints would be appreciated. Thanks. Use the raw_input function: http://www.python.org/doc/current/lib/built-in-funcs.html raw_input ([prompt]) If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, EOFError is raised. Example: >>> s = raw_input('--> ') --> Monty Python's Flying Circus >>> s "Monty Python's Flying Circus" >>> If the readline module was loaded, then raw_input() will use it to provide elaborate line editing and history features. regards, Gerrit. -- Plis korekt eni ingglisj joe encounter in mai imeel meeasj! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From gerrit@nl.linux.org Wed Mar 1 19:56:45 2000 From: gerrit@nl.linux.org ('Gerrit Holl') Date: Wed, 1 Mar 2000 20:56:45 +0100 Subject: [Tutor] Requesting input, waiting a fixed time In-Reply-To: <2DF4CF48CC53D211B84A0008C7280F3304D0D566@wch1xp04.cna.com>; from David.Hicks@cna.com on Wed, Mar 01, 2000 at 01:45:00PM -0600 References: <2DF4CF48CC53D211B84A0008C7280F3304D0D566@wch1xp04.cna.com> Message-ID: <20000301205645.E16094@nl.linux.org> > Thanks for the prompt response. My understanding is that raw input will ask > for a response, but will not solve the problem of assuming a response after > 3 minutes. That is, the program will continue waiting forever. Am I correct? > Is there a way around this? http://www.python.org/doc/current/lib/module-signal.html alarm (time) If time is non-zero, this function requests that a SIGALRM signal be sent to the process in time seconds. Any previously scheduled alarm is canceled (i.e. only one alarm can be scheduled at any time). The returned value is then the number of seconds before any previously set alarm was to have been delivered. If time is zero, no alarm id scheduled, and any scheduled alarm is canceled. The return value is the number of seconds remaining before a previously scheduled alarm. If the return value is zero, no alarm is currently scheduled. (See the Unix man page alarm(2).) signal (signalnum, handler) Set the handler for signal signalnum to the function handler. handler can be a callable Python object taking two arguments (see below), or one of the special values signal.SIG_IGN or signal.SIG_DFL. The previous signal handler will be returned (see the description of getsignal() above). (See the Unix man page signal(2).) So: 1) read the manual on the signal module 2) create a function according to the manual 3) call the 'alarm' function with 300 (time in seconds) as argument, 4) use the raw_input function regards, Gerrit. -- Plis korekt eni ingglisj joe encounter in mai imeel meeasj! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From deirdre@deirdre.net Wed Mar 1 09:45:44 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 1 Mar 2000 01:45:44 -0800 (PST) Subject: [Fwd: [Tutor] learning a Programming language] In-Reply-To: <38BD6E3F.2A452562@execpc.com> Message-ID: On Wed, 1 Mar 2000, Dan Star wrote: > But there is no Grid support in Python or has this recently changes. VB > has a multitude of grids which are critical to database oriented apps. What do you mean by "grid"? I've never used a "grid" and I've written database apps for more than 20 years. They work fine. Thus, "grids," whatever you mean by the term, are NOT in fact critical. > P.S. Delphi is arguably as easy to learn as VB (BTW) and is much more > powerful. Not on my machine. :) In fact, they are both ZERO power applications on any of the machines I own. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net I've _never_ made a decision I've been happier with than quitting $FIRM. -- Rick Moen From danstar@execpc.com Wed Mar 1 21:00:23 2000 From: danstar@execpc.com (Dan Star) Date: Wed, 01 Mar 2000 15:00:23 -0600 Subject: [Fwd: [Tutor] learning a Programming language] References: Message-ID: <38BD84E7.FB1E29DE@execpc.com> Deirdre Saoirse wrote: > > On Wed, 1 Mar 2000, Dan Star wrote: > > > But there is no Grid support in Python or has this recently changes. VB > > has a multitude of grids which are critical to database oriented apps. > > What do you mean by "grid"? I've never used a "grid" and I've written > database apps for more than 20 years. They work fine. Thus, "grids," > whatever you mean by the term, are NOT in fact critical. > Well, a grid that shows records in a table format (with resizable columns etc). Very good for browsing many records at a time such as all the line items on an order. As far as I know this is very hard to do with Python. > > P.S. Delphi is arguably as easy to learn as VB (BTW) and is much more > > powerful. > > Not on my machine. :) In fact, they are both ZERO power applications on > any of the machines I own. > Delphi has a lot of built in power to make the the mundane tasks easier; however you have to conform to its model so it is a little restrictive if you use the IDE. BTW it will soon be on Linux under the name Kylix. --Dan From deirdre@deirdre.net Wed Mar 1 10:11:11 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 1 Mar 2000 02:11:11 -0800 (PST) Subject: [Fwd: [Tutor] learning a Programming language] In-Reply-To: <38BD84E7.FB1E29DE@execpc.com> Message-ID: On Wed, 1 Mar 2000, Dan Star wrote: > Well, a grid that shows records in a table format (with resizable > columns etc). Very good for browsing many records at a time such as all > the line items on an order. As far as I know this is very hard to do > with Python. No, not at all. In fact, I have code for sucking date into those using PyGnome. Remember that Python itself doesn't have a gui, so it may be hard in some GUIs. I prefer gnome-python with glade support. The relevant code in the base class: def DisplayList(self, recordList): self.recordList = recordList a = recordList[0] for i in xrange(0, len(recordList)): a = recordList[i] b = a.toStrArray() self.clist.append(b) A clist object is resizeable. Note that instances of the object do not need to override this; in fact, I suddenly had working lists for all my views. > > Not on my machine. :) In fact, they are both ZERO power applications on > > any of the machines I own. > > > > Delphi has a lot of built in power to make the the mundane tasks easier; > however you have to conform to its model so it is a little restrictive > if you use the IDE. BTW it will soon be on Linux under the name Kylix. Only half my machines run Linux. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net I've _never_ made a decision I've been happier with than quitting $FIRM. -- Rick Moen From danstar@execpc.com Wed Mar 1 21:11:51 2000 From: danstar@execpc.com (Dan Star) Date: Wed, 01 Mar 2000 15:11:51 -0600 Subject: [Fwd: [Tutor] learning a Programming language] References: Message-ID: <38BD8797.5A7543B7@execpc.com> Deirdre Saoirse wrote: > > On Wed, 1 Mar 2000, Dan Star wrote: > > > Well, a grid that shows records in a table format (with resizable > > columns etc). Very good for browsing many records at a time such as all > > the line items on an order. As far as I know this is very hard to do > > with Python. > > No, not at all. > > In fact, I have code for sucking date into those using PyGnome. Remember > that Python itself doesn't have a gui, so it may be hard in some GUIs. I > prefer gnome-python with glade support. > But what about on Windows? > The relevant code in the base class: > > def DisplayList(self, recordList): > self.recordList = recordList > a = recordList[0] > for i in xrange(0, len(recordList)): > a = recordList[i] > b = a.toStrArray() > self.clist.append(b) > > A clist object is resizeable. Note that instances of the object do not > need to override this; in fact, I suddenly had working lists for all my > views. > > > > Not on my machine. :) In fact, they are both ZERO power applications on > > > any of the machines I own. > > > > > > > Delphi has a lot of built in power to make the the mundane tasks easier; > > however you have to conform to its model so it is a little restrictive > > if you use the IDE. BTW it will soon be on Linux under the name Kylix. > > Only half my machines run Linux. > > -- > _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net > I've _never_ made a decision I've been happier with than quitting $FIRM. > -- Rick Moen > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From deirdre@deirdre.net Wed Mar 1 10:31:26 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 1 Mar 2000 02:31:26 -0800 (PST) Subject: [Fwd: [Tutor] learning a Programming language] In-Reply-To: <38BD8797.5A7543B7@execpc.com> Message-ID: On Wed, 1 Mar 2000, Dan Star wrote: > > In fact, I have code for sucking date into those using PyGnome. Remember > > that Python itself doesn't have a gui, so it may be hard in some GUIs. I > > prefer gnome-python with glade support. > > But what about on Windows? I've never been a windows user, but it's my understanding that there are other GUIs (including Gtk+ without the addition of gnome). -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net I've _never_ made a decision I've been happier with than quitting $FIRM. -- Rick Moen From arcege@shore.net Wed Mar 1 22:01:27 2000 From: arcege@shore.net (Michael P. Reilly) Date: Wed, 1 Mar 2000 17:01:27 -0500 (EST) Subject: [Fwd: [Tutor] learning a Programming language] In-Reply-To: <38BD6E3F.2A452562@execpc.com> from "Dan Star" at Mar 01, 2000 01:23:43 PM Message-ID: <200003012201.RAA20711@northshore.shore.net> Someone called "Dan Star" said to "Wesley J. Chun": > But there is no Grid support in Python or has this recently changes. VB > has a multitude of grids which are critical to database oriented apps. > > -Dan Correct.. Python does not have grid support because Python is a programming language not a graphics package. But a good many of the GUI packages for Python have grid geometry managers, including the "default" package, Tkinter. It's been there since Tk had grid managers (probably circa Python 1.4?). Please check before you mislead. -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From danstar@execpc.com Wed Mar 1 22:35:15 2000 From: danstar@execpc.com (Dan Star) Date: Wed, 01 Mar 2000 16:35:15 -0600 Subject: [Fwd: [Tutor] learning a Programming language] References: <200003012201.RAA20711@northshore.shore.net> Message-ID: <38BD9B23.D649ECF2@execpc.com> "Michael P. Reilly" wrote: > > Someone called "Dan Star" said to "Wesley J. Chun": > > But there is no Grid support in Python or has this recently changes. VB > > has a multitude of grids which are critical to database oriented apps. > > > > -Dan > > Correct.. Python does not have grid support because Python is a > programming language not a graphics package. But a good many of the > GUI packages for Python have grid geometry managers, including the > "default" package, Tkinter. It's been there since Tk had grid > managers (probably circa Python 1.4?). > > Please check before you mislead. > Didn't mean to mislead. Just repeating was I was told some months ago. --Dan :) From bill@libc.org Thu Mar 2 05:48:09 2000 From: bill@libc.org (Bill Anderson) Date: Wed, 01 Mar 2000 22:48:09 -0700 Subject: [Tutor] Re: Zope enabled web hosting (was: Need for pedestrian-levelexplanation) References: <008301bf8075$58d75820$42e60ecb@jstok> <38BC2D39.C2E019D0@carolo.net> Message-ID: <38BE0099.1E148395@libc.org> Bill Bedford wrote: > > At 8:34 pm +0000 29/02/00, Denis wrote: > > >Bill Bedford wrote: > > > >> Out of interest -- does anyone know of a Zope enabled web hosting > >> company in the UK? ... > > I'm pleased to submit you this URL : > > > >http://www.zope.org/Resources/ZSP > > > > So the answer is "No" > > Thanks for your time....... No, if you go to that link, you *will* find one. (It just may be better to actually check out the resources given before making assumptions) -- In flying I have learned that carelessness and overconfidence are usually far more dangerous than deliberately accepted risks. -- Wilbur Wright in a letter to his father, September 1900 From alan.gauld@bt.com Thu Mar 2 10:26:40 2000 From: alan.gauld@bt.com (Gauld,AJ,Alan,NEL1A GAULDAJ R) Date: Thu, 2 Mar 2000 10:26:40 -0000 Subject: [Tutor] Re: Zope enabled web hosting (was: Need for p edestrian-level explanation) Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6098@mbtlipnt02.btlabs.bt.co.uk> > >and I found your > >"Out of interest" at least unpleasant, > > Why? Is seems to me a perfectly common colloquialism for flagging a > casual enquiry. I think we have a language clash. For native (UK at least!) English 'out of interest' means 'because I'm interested' whereas taken literally it could mean 'I have no interest'... Bill was using the first meaning, I suspect Denis took it the second way... Or maybe its me thats missing a point somewhere :-) The joys of the internet. Alan G. From spirou@carolo.net Thu Mar 2 18:11:35 2000 From: spirou@carolo.net (Denis =?iso-8859-1?Q?Fr=E8re?=) Date: Thu, 02 Mar 2000 18:11:35 +0000 Subject: [Tutor] Re: Zope enabled web hosting (was: Need for p edestrian-level explanation) References: <5104D4DBC598D211B5FE0000F8FE7EB202DF6098@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <38BEAED7.7CE6935C@carolo.net> "Gauld,AJ,Alan,NEL1A GAULDAJ R" wrote: > > > >"Out of interest"  > > I think we have a language clash. > (...)> > Bill was using the first meaning, I suspect Denis took it > the second way... I felt I had misunderstood something when I read Bill's answer. So I sent (privately) some kind of excuses to Bill : ----------------------------------- partim --------------------------- Subject: Re: Zope enabled web hosting Date: Tue, 29 Feb 2000 23:23:13 +0000 From: Denis To: Bill Bedford Bill Bedford wrote: > Why? Is seems to me a perfectly common colloquialism for > flagging a casual enquiry. > Sorry, perhaps I misunderstood the "Out of interest" object. ---------------------------------------------------------------------- But the link had been checked :-) > The joys of the internet. Hmm, let's come back to our topic ... ;-) Denis From joks@ptt.yu Thu Mar 2 19:41:24 2000 From: joks@ptt.yu (Darth Vader) Date: Thu, 2 Mar 2000 20:41:24 +0100 Subject: [Tutor] (no subject) Message-ID: <000d01bf847f$4c3332c0$a5243ed4@draganjo> This is a multi-part message in MIME format. ------=_NextPart_000_000A_01BF8487.ACC97B00 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi! Can u help me with PYthon -im new user. Or tell me where can i (on Net) find documentation about starting with = this program language. ------=_NextPart_000_000A_01BF8487.ACC97B00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi!
Can u help me with PYthon -im new user.
Or tell me where can i (on Net) find documentation = about=20 starting with this program language.
------=_NextPart_000_000A_01BF8487.ACC97B00-- From andy.ciordia@goingv.com Thu Mar 2 19:56:45 2000 From: andy.ciordia@goingv.com (Andy Ciordia) Date: Thu, 2 Mar 2000 14:56:45 -0500 (EST) Subject: [Tutor] (no subject) In-Reply-To: <000d01bf847f$4c3332c0$a5243ed4@draganjo> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 um.. have you gone through the tutorials on python.org ? - -A On Thu, 2 Mar 2000, Darth Vader wrote: > Hi! > Can u help me with PYthon -im new user. > Or tell me where can i (on Net) find documentation about starting with this program language. > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: For info see http://www.gnupg.org iD4DBQE4vseAVO4/asVt7esRAioiAJdSFbYtZVHOBEfB5rTZL/4nqy5UAKCpta0V xdoXFMNEQjzzbYei4xdXPg== =RIEP -----END PGP SIGNATURE----- From HJCma3@aol.com Thu Mar 2 19:57:47 2000 From: HJCma3@aol.com (HJCma3@aol.com) Date: Thu, 2 Mar 2000 14:57:47 EST Subject: [Tutor] Help. Message-ID: <30.1f781ab.25f021bb@aol.com> --part1_30.1f781ab.25f021bb_boundary Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit --part1_30.1f781ab.25f021bb_boundary Content-Type: message/rfc822 Content-Disposition: inline Return-path: HJCma3@aol.com From: HJCma3@aol.com Full-name: HJCma3 Message-ID: Date: Thu, 2 Mar 2000 14:49:48 EST Subject: Help. To: webmaster@python.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Unknown (No Version) Dear Python, I have downloaded the Python 1.5.2 software for Windows 95/NT. I have not been able to download NumPY and I was wondering if this a critical piece of the Python software. I am really looking forward to learning this and I want to make sure I have all the necessary pieces before continuing. Here is what else I have downloaded from you site. If I am missing anything could you let me know. Thanks. py152.exe win32all.exe build 125 PIL 1.0 update (from the Python Image Library 1.0) I also downloaded: PYTHLP152-043099.zip (got from the following site: http://www.orgmf.com.ar/condor/pytstuff.html) --part1_30.1f781ab.25f021bb_boundary-- From alan.gauld@bt.com Thu Mar 2 17:44:40 2000 From: alan.gauld@bt.com (Gauld,AJ,Alan,NEL1A GAULDAJ R) Date: Thu, 2 Mar 2000 17:44:40 -0000 Subject: [Fwd: [Tutor] learning a Programming language] Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF60A8@mbtlipnt02.btlabs.bt.co.uk> > Someone called "Dan Star" said to "Wesley J. Chun": > > But there is no Grid support in Python or has this recently > Correct.. Python does not have grid support because Python is a > programming language not a graphics package. But a good many of the > GUI packages for Python have grid geometry managers, A grid geometry manager has no similarity to a grid (or probably more accurately called a table) control. The table/grid is a way of displaying data in tabular form like a spreadsheet. It emables the user to resize the columns at runtime, to sort the columns or rows, to swap columns and rows etc Most of them will display database data while in design mode too, which is a very powerful tool for making sure the right data is hooked up to the right control! A grid layout manager allows the developer to place controls in a tabular manner on a 'form'. VB uses what Tk would term an XYlayout manager. None of this is particularly relevant to the question of whether a beginner should use VB or Python however. VB allows you to build GUI apps without thinking about GUI programming. That's neat but not helpful when you move to a different environment where VBisn't available. Python focuses on making the fundamentals easy but you still have to understand what's going on. Beyond the GUI aspects VB is more verbose than Python and has a slightly more complex (and limited) OO mechanism. The question comes down to: Do you want to quickly turn out Windows GUI based programs or do you want to really understand what programming is all about? Alan G. Return-Path: Delivered-To: tutor-mailman@python.org Received: from danube.ccity.com (danube.circuitcity.com [12.26.69.4]) by dinsdale.python.org (Postfix) with SMTP id 99F6E1CD5F for ; Fri, 25 Feb 2000 13:04:36 -0500 (EST) Received: by danube.ccity.com(Lotus SMTP MTA v4.6.5 (863.2 5-20-1999)) id 85256890.0062B450 ; Fri, 25 Feb 2000 12:58:06 -0500 X-Lotus-FromDomain: CARMAX@CIRCUIT CITY@CCEXTERNAL From: David_Gadoury@ccnotes.ccity.com To: tutor%python.org@ccnotes.ccity.com Message-ID: <85256890.0062B3B5.00@danube.ccity.com> Date: Fri, 25 Feb 2000 13:06:06 -0500 Subject: Re: [Tutor] (no subject) Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Content-Disposition: inline Sender: tutor-admin@python.org Errors-To: tutor-admin@python.org X-BeenThere: tutor@python.org X-Mailman-Version: 1.2 (beta 1) Precedence: bulk List-Id: Discussion for learning programming with Python I recommend starting with the Alan Guald tutorial entitles "Learning to Program", then going to Learning Python. I have it. less than 100k zipped. email me "HARUN F.ABDULHAQ" on 02/25/2000 05:02:52 AM To: tutor@python.org cc: (bcc: David Gadoury/7001/Carmax) Subject: [Tutor] (no subject) HI, Which book should i get to learn Python programming language(beginner) thanks harun ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From Silkk247@aol.com Fri Mar 3 00:25:58 2000 From: Silkk247@aol.com (Silkk247@aol.com) Date: Thu, 2 Mar 2000 19:25:58 EST Subject: [Tutor] I need help! Message-ID: <8.1ede58d.25f06096@aol.com> Can you guys help me on how to read python language. im a beginner hacker and would like to know the system more and become a virus programmer. if there is anything u guys can do to help send me anything that would help me get started. thanx... From warren@nightwares.com Fri Mar 3 01:09:12 2000 From: warren@nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Thu, 02 Mar 2000 19:09:12 -0600 Subject: [Tutor] I need help! References: <8.1ede58d.25f06096@aol.com> Message-ID: <38BF10B8.666F94B4@nightwares.com> Silkk247@aol.com wrote: > Can you guys help me on how to read python language. im a beginner hacker > and would like to know the system more and become a virus programmer. Python is not the language for that, and this is not the group for that. --WthmO From dyoo@uclink4.berkeley.edu Fri Mar 3 09:28:46 2000 From: dyoo@uclink4.berkeley.edu (dyoo) Date: Fri, 3 Mar 2000 01:28:46 -0800 Subject: [Tutor] syntax checker for python? Message-ID: <00030301320700.04404@coffeetable.dwight> Hello! Out of curiosity, is there a switch or script that can check for trivial mistakes (like calling readLines instead of readlines)? I understand the flexibility in function calling is due to the dynamic-ness (is that a word?) of Python. It's nice, but it can also be a pain to find where one has mispelled something. Is there a stricter checker on Python? From gerrit@nl.linux.org Fri Mar 3 09:55:32 2000 From: gerrit@nl.linux.org (Gerrit Holl) Date: Fri, 3 Mar 2000 10:55:32 +0100 Subject: [Tutor] syntax checker for python? In-Reply-To: <00030301320700.04404@coffeetable.dwight>; from dyoo@uclink4.berkeley.edu on Fri, Mar 03, 2000 at 01:28:46AM -0800 References: <00030301320700.04404@coffeetable.dwight> Message-ID: <20000303105532.A23964@nl.linux.org> > Hello! Out of curiosity, is there a switch or script that can check for > trivial mistakes (like calling readLines instead of readlines)? I understand > the flexibility in function calling is due to the dynamic-ness (is that a > word?) of Python. It's nice, but it can also be a pain to find where one > has mispelled something. Is there a stricter checker on Python? No, there isn't. Some editors, however, highlight builtin functions - so 'int' is highlighted but 'Int' is not. But you can only find out runtime wheter something raises a NameError or not. BTW, it's not a syntax checker what you describe - functions aren't part of the syntax (statements are). regards, Gerrit. -- Plies korekt enie bet ingglisj joe encauntur in mai imil mesusj! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From jstok@bluedog.apana.org.au Fri Mar 3 06:24:35 2000 From: jstok@bluedog.apana.org.au (Jason Stokes) Date: Fri, 3 Mar 2000 17:24:35 +1100 Subject: [Tutor] Can't use builtin function objects like user defined objects Message-ID: <000201bf8502$dac47480$49e60ecb@jstok> Consider the following: >> testtext = ['Four', 'lines', 'of', 'text',] >> def myprint(item): ... print item ... >>> result = map(print, testtext) File "", line 1 map(print, testtext) ^ SyntaxError: invalid syntax >>> result = map(myprint, testtext) Four lines of text >>> Clearly I can't use "print" the same way I use "myprint". Why? From jstok@bluedog.apana.org.au Fri Mar 3 11:30:46 2000 From: jstok@bluedog.apana.org.au (Jason Stokes) Date: Fri, 3 Mar 2000 22:30:46 +1100 Subject: [Tutor] syntax checker for python? Message-ID: <00aa01bf8503$ec1a35c0$49e60ecb@jstok> From: dyoo >Hello! Out of curiosity, is there a switch or script that can check for >trivial mistakes (like calling readLines instead of readlines)? No. Once I achieve the status of Python guru I volunteer to work on a PyLint program that will catch all the annoying errors I'm making learning the language. From den@analyt.chem.msu.su Fri Mar 3 12:43:17 2000 From: den@analyt.chem.msu.su (Denis S. Otkidach) Date: Fri, 3 Mar 2000 15:43:17 +0300 (MSK) Subject: [Tutor] Cyclic references Message-ID: I need a set of classes which refere each to other. This causes objects living forever (they cannot be deleted). Can I walkaround this problem? From gerrit@nl.linux.org Fri Mar 3 12:25:43 2000 From: gerrit@nl.linux.org (Gerrit Holl) Date: Fri, 3 Mar 2000 13:25:43 +0100 Subject: [Tutor] Can't use builtin function objects like user defined objects In-Reply-To: <000201bf8502$dac47480$49e60ecb@jstok>; from jstok@bluedog.apana.org.au on Fri, Mar 03, 2000 at 05:24:35PM +1100 References: <000201bf8502$dac47480$49e60ecb@jstok> Message-ID: <20000303132542.A27910@nl.linux.org> > Consider the following: > > >> testtext = ['Four', 'lines', 'of', 'text',] > >> def myprint(item): > ... print item > ... > >>> result = map(print, testtext) > File "", line 1 > map(print, testtext) > ^ > SyntaxError: invalid syntax > >>> result = map(myprint, testtext) > Four > lines > of > text > >>> > > Clearly I can't use "print" the same way I use "myprint". Why? "print" is not a function, print is a statement. regards, Gerrit. -- Plies korekt enie bet ingglisj joe encauntur in mai imil mesusj! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From Emile van Sebille" <20000303132542.A27910@nl.linux.org> Message-ID: <0b3b01bf851b$8f446a60$01ffffc0@worldnet.att.net> As a follow up then, why doesn't this work: >>> testtext = ['Four', 'lines', 'of', 'text.'] >>> map(lambda x: x, testtext) ['Four', 'lines', 'of', 'text.'] >>> map(lambda x: print x, testtext) SyntaxError: invalid syntax Emile van Sebille emile@fenx.com ------------------- ----- Original Message ----- From: Gerrit Holl To: Jason Stokes Cc: Sent: Friday, March 03, 2000 4:25 AM Subject: Re: [Tutor] Can't use builtin function objects like user defined objects > ", line 1 > > map(print, testtext) > > ^ > > SyntaxError: invalid syntax > > >>> result = map(myprint, testtext) > > Four > > lines > > of > > text > > >>> > > > > Clearly I can't use "print" the same way I use "myprint". Why? > > "print" is not a function, print is a statement. > > > regards, > Gerrit. > > -- > Plies korekt enie bet ingglisj joe encauntur in mai imil mesusj! > -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com > Version: 3.12 > GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? > Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y > -----END GEEK CODE BLOCK----- > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor > From jcosby@wolfenet.com Fri Mar 3 15:11:01 2000 From: jcosby@wolfenet.com (Jon Cosby) Date: Fri, 3 Mar 2000 07:11:01 -0800 Subject: [Tutor] Virus Message-ID: <000701bf8522$b19864c0$87129fce@computer> This is a multi-part message in MIME format. ------=_NextPart_000_0004_01BF84DF.A1653080 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable If you received an email with an attachment from me yesterday, DON'Topen = it, it contains a virus. If you have already done so, the name of the = virus is "PrettyWorm", and it will send itself to all in your address = book within 30 minutes. There will be a file called "Files32.vxd" in = your Windows\System directory. Delete this if you can. This won.'t = completely take care of the problem; it will also infect your registry. = For more information on this, go to http://vil.mcafee.com/vil/wm98500.asp Sorry about this, folks Jon Cosby ------=_NextPart_000_0004_01BF84DF.A1653080 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
If you received an email with an attachment from me = yesterday,=20 DON'Topen it, it contains a virus. If you have already done so, the name = of the=20 virus is "PrettyWorm", and it will send itself to all in your address = book=20 within 30 minutes. There will be a file called "Files32.vxd" in your=20 Windows\System directory. Delete this if you can. This won.'t completely = take=20 care of the problem; it will also infect your registry. For more = information on=20 this, go to
 
http://vil.mcafee.com/vil/= wm98500.asp
 
Sorry about this, folks
 
Jon Cosby
------=_NextPart_000_0004_01BF84DF.A1653080-- From gerrit@nl.linux.org Fri Mar 3 15:34:17 2000 From: gerrit@nl.linux.org (Gerrit Holl) Date: Fri, 3 Mar 2000 16:34:17 +0100 Subject: [Tutor] Can't use builtin function objects like user defined objects In-Reply-To: <0b3b01bf851b$8f446a60$01ffffc0@worldnet.att.net>; from emile@fenx.com on Fri, Mar 03, 2000 at 06:19:55AM -0800 References: <000201bf8502$dac47480$49e60ecb@jstok> <20000303132542.A27910@nl.linux.org> <0b3b01bf851b$8f446a60$01ffffc0@worldnet.att.net> Message-ID: <20000303163417.A1992@nl.linux.org> > As a follow up then, why doesn't this work: > > >>> testtext = ['Four', 'lines', 'of', 'text.'] > >>> map(lambda x: x, testtext) > ['Four', 'lines', 'of', 'text.'] > >>> map(lambda x: print x, testtext) > SyntaxError: invalid syntax Lambda's have an extremely strange syntax; you can't use statements from within lambda's. Try: >>> map(lambda x: sys.stdout.write(x), testtext) instead. Hope that helps! regards, Gerrit. -- Plies korekt enie bet ingglisj joe encauntur in mai imil mesusj! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From jstok@bluedog.apana.org.au Fri Mar 3 15:53:51 2000 From: jstok@bluedog.apana.org.au (Jason Stokes) Date: Sat, 4 Mar 2000 02:53:51 +1100 Subject: [Tutor] Can't use builtin function objects like user defined objects Message-ID: <006801bf8528$addd22c0$49e60ecb@jstok> -----Original Message----- From: Emile van Sebille To: Python Tutor Date: Thursday, March 02, 2000 8:11 PM Subject: Re: [Tutor] Can't use builtin function objects like user defined objects >As a follow up then, why doesn't this work: > >>>> testtext = ['Four', 'lines', 'of', 'text.'] >>>> map(lambda x: x, testtext) >['Four', 'lines', 'of', 'text.'] >>>> map(lambda x: print x, testtext) >SyntaxError: invalid syntax Because Python doesn't allow nested statements in lambda expression. At all. Jason (who figured out the print issue after soon posting, but still wonders *why*). From rbl@hal.cwru.edu Fri Mar 3 19:13:24 2000 From: rbl@hal.cwru.edu (Robin B. Lake) Date: Fri, 3 Mar 2000 14:13:24 -0500 (EST) Subject: [Tutor] Need help with a couple of concepts Message-ID: <200003031913.OAA06484@hal.epbi.cwru.edu> Long-time programming. Understand most of the Python *language*. Need help with some of the constructs to get a Python program going. Running Python on a Mac G3. 1. Am modifying some code. There is at the bottom: if __name__ == '__main__': main() and after the imports: def main(): What is this all about? 2. I have some code from a Python book that requires the kjbuckets extension module. I've downloaded the kjbuckets module. Where in the Mac directory tree should I put it so that Python will find it when needed? 3. I'm using BBEdit Lite 4.6 to edit the Python code. Any way to get line numbers in the source so that the Python error messages might be matched up better? Thanks, Rob Lake rbl@hal.cwru.edu From gerrit@nl.linux.org Fri Mar 3 19:32:17 2000 From: gerrit@nl.linux.org (Gerrit Holl) Date: Fri, 3 Mar 2000 20:32:17 +0100 Subject: [Tutor] Need help with a couple of concepts In-Reply-To: <200003031913.OAA06484@hal.epbi.cwru.edu>; from rbl@hal.cwru.edu on Fri, Mar 03, 2000 at 02:13:24PM -0500 References: <200003031913.OAA06484@hal.epbi.cwru.edu> Message-ID: <20000303203217.A10303@nl.linux.org> > Long-time programming. Understand most of the Python *language*. > Need help with some of the constructs to get a Python program going. > > Running Python on a Mac G3. > > 1. Am modifying some code. There is at the bottom: > > if __name__ == '__main__': > main() > > and after the imports: > > def main(): > > What is this all about? If a Python program is run as a script, the value of the __name__ variable is set to '__main__'; this is not executed if the program is imported as a Python module. regards, Gerrit. -- Plies korekt enie bet ingglisj joe encauntur in mai imil mesusj! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From parkw@better.net Fri Mar 3 19:45:39 2000 From: parkw@better.net (William Park) Date: Fri, 3 Mar 2000 14:45:39 -0500 Subject: [Tutor] Need help with a couple of concepts In-Reply-To: <200003031913.OAA06484@hal.epbi.cwru.edu>; from rbl@hal.EPBI.CWRU.Edu on Fri, Mar 03, 2000 at 02:13:24PM -0500 References: <200003031913.OAA06484@hal.epbi.cwru.edu> Message-ID: <20000303144539.B4341@better.net> On Fri, Mar 03, 2000 at 02:13:24PM -0500, Robin B. Lake wrote: > 1. Am modifying some code. There is at the bottom: > > if __name__ == '__main__': > main() > > and after the imports: > > def main(): > > What is this all about? If you call this module from command line, like $ python .py then, '__name__' variable will be '__main__' string. But, if you import into another module or program, then '__name__' variable will be its module name. By testing for how it was called, you can run 'main()' routine regardless. > 2. I have some code from a Python book that requires the kjbuckets > extension module. I've downloaded the kjbuckets module. Where in > the Mac directory tree should I put it so that Python will find it > when needed? Proper ways are - set 'PYTHONPATH=...' - install under "site-python" directory which usually is at the same level as standard "python1.5". To find out the standard path, >>> import sys >>> sys.path --William From rbl@hal.cwru.edu Fri Mar 3 20:18:55 2000 From: rbl@hal.cwru.edu (Robin B. Lake) Date: Fri, 3 Mar 2000 15:18:55 -0500 (EST) Subject: [Tutor] Moving right along ... Message-ID: <200003032018.PAA06953@hal.epbi.cwru.edu> Thanks to the several who replied to my earlier questions. Now, how do I keep the program from "running off the end"? I launch the source by double-clicking (Mac) and the code runs well, but the Python window closes before I can read the output! The Python Essential Reference book only shows a "pause" function for UNIX. Thanks, Rob Lake rbl@hal.cwru.edu From joanca@typerware.com Fri Mar 3 20:33:09 2000 From: joanca@typerware.com (JoanCarles p Casas=?ISO-8859-1?Q?=edn?=) Date: Fri, 3 Mar 2000 21:33:09 +0100 Subject: [Tutor] Need help with a couple of concepts Message-ID: <20000303203116.E9C591CD16@dinsdale.python.org> Robin B. Lake wrote: >Running Python on a Mac G3. > >1. Am modifying some code. There is at the bottom: > >if __name__ == '__main__': > main() > >and after the imports: > >def main(): > >What is this all about? Correct me somebody if I'm not right. But this is what I understand: #(your filename: "TestMain.py") def printastring(thestring): print thestring def main(): print "hello world!" if __name__ == '__main__': main() This means that: If you *run* the script you'll have "hello world" printed out. If you *import* (import TestMain) You won't have printed anything, but you'll be able to use any function defined: TestMain.printastring('yeaaah!') >2. I have some code from a Python book that requires the kjbuckets >extension module. I've downloaded the kjbuckets module. Where in >the Mac directory tree should I put it so that Python will find it >when needed? You can put it wherever you want, but you'be to say it to Python. Launch the applet "EditPythonPrefs" (i'm also using a Mac ;) and write there the path for the folder. I personally think that a good idea is to have it in the Extensions folder, then it should look something like: $(PYTHON):Extensions:kjbuckets '$(PYTHON)' is the folder where Python interpreter lives. >3. I'm using BBEdit Lite 4.6 to edit the Python code. Any way to >get line numbers in the source so that the Python error messages >might be matched up better? You've definitely move to the PythonIDE (great!) written by Just van Rossum. You'll have lot of Python oriented features (debugger, run as __main__ your scripts, a module browser... is C O O L !!). If you're using Python 1.5.2 it comes with the distribution, on top. If you've older version it's in the Contrib folder I think... ========== If you're using a Macintosh there's another list, Mac specific: Python-Mac http://www.python.org/mailman/listinfo/pythonmac-sig if you're a Python newbie don't worry, *any* question is welcome (I am too ;) Hope this helps, JoanCarles :::!!!::: joanca@typerware.com http://www.typerware.com From joanca@typerware.com Fri Mar 3 20:40:35 2000 From: joanca@typerware.com (JoanCarles p Casas=?ISO-8859-1?Q?=edn?=) Date: Fri, 3 Mar 2000 21:40:35 +0100 Subject: [Tutor] Moving right along ... Message-ID: <20000303203837.86E9C1CD16@dinsdale.python.org> Robin B. Lake wrote: >Now, how do I keep the program from "running off the end"? I >launch the source by double-clicking (Mac) and the code runs >well, but the Python window closes before I can read the output! I suppose there's a way for having the output window opened for a while (which I don't know), but It won't happen if you use the Python IDE (for Mac), you have a reporter window. Another way is using a Dialog message (if it's just for print a small comment at the end of the script and you want to see it -less than 256 characters). This works only in the Mac (it's Mac specific interface to dialogs toolbox): import EasyDialogs EasyDialogs.Message("Eooo, I'm hereee!!!") Hope this helps, JoanCarles :::!!!::: joanca@typerware.com http://www.typerware.com From rbl@hal.cwru.edu Fri Mar 3 20:42:57 2000 From: rbl@hal.cwru.edu (Robin B. Lake) Date: Fri, 3 Mar 2000 15:42:57 -0500 (EST) Subject: [Tutor] Moving right along ... Message-ID: <200003032042.PAA07097@hal.epbi.cwru.edu> Great help, thank you. The only problem is that the file selection dialog comes up on top of the Python window before I can move the Python window, then the program runs and the EasyDialog comes up on top of the Python window and I can't move anything to see what's hidden! I'll keep working on it ... Cheers, Rob Lake > > Robin B. Lake wrote: > > >Now, how do I keep the program from "running off the end"? I > >launch the source by double-clicking (Mac) and the code runs > >well, but the Python window closes before I can read the output! > > I suppose there's a way for having the output window opened for a while > (which I don't know), but It won't happen if you use the Python IDE (for > Mac), you have a reporter window. > > Another way is using a Dialog message (if it's just for print a small > comment at the end of the script and you want to see it -less than 256 > characters). > This works only in the Mac (it's Mac specific interface to dialogs > toolbox): > > import EasyDialogs > > EasyDialogs.Message("Eooo, I'm hereee!!!") > > Hope this helps, > > > > > JoanCarles > > > :::!!!::: > joanca@typerware.com > > http://www.typerware.com > > From gerrit@nl.linux.org Fri Mar 3 20:56:23 2000 From: gerrit@nl.linux.org (Gerrit Holl) Date: Fri, 3 Mar 2000 21:56:23 +0100 Subject: [Tutor] Moving right along ... In-Reply-To: <200003032018.PAA06953@hal.epbi.cwru.edu>; from rbl@hal.cwru.edu on Fri, Mar 03, 2000 at 03:18:55PM -0500 References: <200003032018.PAA06953@hal.epbi.cwru.edu> Message-ID: <20000303215623.B13231@nl.linux.org> > Thanks to the several who replied to my earlier questions. > > Now, how do I keep the program from "running off the end"? I > launch the source by double-clicking (Mac) and the code runs > well, but the Python window closes before I can read the output! > > The Python Essential Reference book only shows a "pause" function > for UNIX. Ugly, but... >>> raw_input("Press to continue... ") regards, Gerrit. -- Plies korekt enie bet ingglisj joe encauntur in mai imil mesusj! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From billbnor@mousa.demon.co.uk Fri Mar 3 21:32:44 2000 From: billbnor@mousa.demon.co.uk (Bill Bedford) Date: Fri, 3 Mar 2000 21:32:44 +0000 Subject: [Tutor] Moving right along ... In-Reply-To: <200003032018.PAA06953@hal.epbi.cwru.edu> References: <200003032018.PAA06953@hal.epbi.cwru.edu> Message-ID: At 3:18 pm -0500 03/03/00, Robin B. Lake wrote: >Thanks to the several who replied to my earlier questions. > >Now, how do I keep the program from "running off the end"? I >launch the source by double-clicking (Mac) and the code runs >well, but the Python window closes before I can read the output! > Two ways Universally -- Open "EditPythonPrefs" click on "Default startup options" and the check "keep stdio window open on normal exit" Or for a single script add the following import sys sys.exit(1) -- Bill Bedford mailto:billb@mousa.demon.co.uk When I said I had a memory leak, I wasn't referring to RAM... From craig@osa.att.ne.jp Fri Mar 3 22:50:10 2000 From: craig@osa.att.ne.jp (Craig Hagerman) Date: Sat, 4 Mar 2000 07:50:10 +0900 Subject: [Tutor] Need help with a couple of concepts In-Reply-To: <200003031913.OAA06484@hal.epbi.cwru.edu> Message-ID: > >3. I'm using BBEdit Lite 4.6 to edit the Python code. Any way to >get line numbers in the source so that the Python error messages >might be matched up better? > >Thanks, >Rob Lake >rbl@hal.cwru.edu > Rob, B.B. Edit is a great program. To add line numbers do this. Open a new file, notice that there are little icons on the top of that open window. Click on the second from the left (I think) it says things like "Soft wrap text", "Show philips bar" and somewhere in there "Show line numbers". Click on this and you will have line numbers. Alternately go to "Edit -> Preferences -> Window" Here there is a setting to turn on line numbering by default. Hope this helps. oh, and the MacPython SIG is a great resource for Mac specific questions. Craig Hagerman From joanca@typerware.com Fri Mar 3 23:19:48 2000 From: joanca@typerware.com (JoanCarles p Casas=?ISO-8859-1?Q?=edn?=) Date: Sat, 4 Mar 2000 00:19:48 +0100 Subject: [Tutor] Moving right along ... Message-ID: <20000303231750.0807A1CD6C@dinsdale.python.org> Robin B. Lake wrote: >Great help, thank you. The only problem is that the file selection >dialog comes up on top of the Python window before I can move the >Python window, then the program runs and the EasyDialog comes up >on top of the Python window and I can't move anything to see what's >hidden! I think you definitely have to run with the Python IDE. Open your script and push the 'Run all' button. If you're printing something to see what's happening with your script you'll see the printed strings in the reporter window, which you can move freely through your screen. Give it a try, it's nice. >I'll keep working on it ... Have a nice time! JoanCarles :::!!!::: joanca@typerware.com http://www.typerware.com From jstok@bluedog.apana.org.au Sat Mar 4 02:51:41 2000 From: jstok@bluedog.apana.org.au (Jason Stokes) Date: Sat, 4 Mar 2000 13:51:41 +1100 Subject: [Tutor] Need help with a couple of concepts Message-ID: <002701bf8584$928302e0$42e60ecb@jstok> Gerrit Holl > >> Long-time programming. Understand most of the Python *language*. >> Need help with some of the constructs to get a Python program going. >> >> Running Python on a Mac G3. >> >> 1. Am modifying some code. There is at the bottom: >> >> if __name__ == '__main__': >> main() >> >> and after the imports: >> >> def main(): >> >> What is this all about? > >If a Python program is run as a script, the value of the __name__ >variable is set to '__main__'; this is not executed if the program >is imported as a Python module. The purpose of this is to allow the same module to be used as a library, and as an application with its own top level. This is useful, for example, to give library modules their own test routines defined inside the module. From Moshe Zadka Sat Mar 4 09:35:05 2000 From: Moshe Zadka (Moshe Zadka) Date: Sat, 4 Mar 2000 11:35:05 +0200 (IST) Subject: [Tutor] Moving right along ... In-Reply-To: <200003032018.PAA06953@hal.epbi.cwru.edu> Message-ID: On Fri, 3 Mar 2000, Robin B. Lake wrote: > Thanks to the several who replied to my earlier questions. > > Now, how do I keep the program from "running off the end"? I > launch the source by double-clicking (Mac) and the code runs > well, but the Python window closes before I can read the output! Try import time time.sleep(30) At the end. Had you mentioned a platform, you'd probably get a better answer. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html From wesc@alpha.ece.ucsb.edu Sat Mar 4 10:22:14 2000 From: wesc@alpha.ece.ucsb.edu (Wesley J. Chun) Date: Sat, 4 Mar 2000 02:22:14 -0800 (PST) Subject: [Tutor] Moving right along ... Message-ID: <200003041022.CAA04092@alpha.ece.ucsb.edu> > Date: Sat, 4 Mar 2000 11:35:05 +0200 (IST) > From: Moshe Zadka > > On Fri, 3 Mar 2000, Robin B. Lake wrote: > > > Thanks to the several who replied to my earlier questions. > > > > Now, how do I keep the program from "running off the end"? I > > launch the source by double-clicking (Mac) and the code runs > > well, but the Python window closes before I can read the output! > > Try > > import time > time.sleep(30) on Windoze and perhaps the Mac, you can also try: raw_input('press RETURN to close') at the end, or just plain raw_input() for short. the window won't close until a keypress is received. -wesley From cwebster@nevada.edu Sat Mar 4 18:06:33 2000 From: cwebster@nevada.edu (Corran Webster) Date: Sat, 4 Mar 2000 10:06:33 -0800 Subject: [Tutor] Moving right along ... In-Reply-To: <200003032018.PAA06953@hal.epbi.cwru.edu> Message-ID: > Thanks to the several who replied to my earlier questions. > > Now, how do I keep the program from "running off the end"? I > launch the source by double-clicking (Mac) and the code runs > well, but the Python window closes before I can read the output! > > The Python Essential Reference book only shows a "pause" function > for UNIX. There's another method which doesn't seem to have been mentioned in any responses, which is perfect for quick checks. Hold the option key down when you double click the python script file - this will bring up a preferences dialog, which allows you to do things like: * tell the window to remain open when the program is done * set unix-style command line arguments to be passed in through argv * set a few options which on Unix versions are controlled by command-line options, such as entering interactive mode after the script has run. But as others have said, the best solution is probably to work within the IDE (with a few exceptions for GUI-based apps). Regards, Corran From bosahv@nhdpuk.zzn.com Mon Mar 6 17:20:13 2000 From: bosahv@nhdpuk.zzn.com (bosahv theo) Date: Mon, 6 Mar 2000 12:20:13 -0500 Subject: [Tutor] Hello to the list and a question Message-ID:
Hello, this is my first letter to the list

I am TREMENDOUSLY excited about python. It's my first programming language.

I just dutifully spent some of the weekend printing up the documentation and starting my
education, I HAVE A LOT TO LEARN. I bought _Quick Python_ and _Python and Tkinter
programming_?? published by Manning. Great books to compliment the online
documentation.

I was wonderring however,

The Python and Tkinter programming has a 'Hello World' program at the very beginning of the
book. When I typed the program into IDLE it brought up a window before I got to the close
statement of the program. (I'm at work, but I'll add the program tonight)

The program ran but then I couldn't close it or IDLE, just kept getting a message saying the
program was already running did I want to kill it. Then it wouldn't die. Now I like resilient
programs but is there something I should do to change this???

Bo







www.nhdp.nl/english/ Hardware drivers, Free Email, Discuss PC problems, etc
_____________________________________________________
Get your own Web-Based E-mail Service at http://www.zzn.com

From WoodDJ@hqmc.usmc.mil Tue Mar 7 15:49:29 2000 From: WoodDJ@hqmc.usmc.mil (Wood Sgt Dale J) Date: Tue, 7 Mar 2000 10:49:29 -0500 Subject: [Tutor] Question Message-ID: <93E115376C68D311B50200A024BB8F36053773@hqmail004.hqmc.usmc.mil> I am new to programming and was wondering if anyone can refer me to where I should start in learning how to program in Python. Thanks for any assistance given. From genius@idirect.com Tue Mar 7 17:14:05 2000 From: genius@idirect.com (Charles Takacs) Date: Tue, 7 Mar 2000 12:14:05 -0500 Subject: [Tutor] Question Message-ID: <001a01bf8858$8b7407c0$a90f9ad8@charlest> Since you've made this Post, it's obvious that you have already seen the Python Home page. Continue looking at the Tutorials found at; http://www.python.org/doc/Intros.html These Tutorials are the best you find anywhere. I sugest, that you start with "Alan Gauld's" Tutorial for Non-Programmers. Then try the other Tutorials. In addition: 1. There is a New Book which supposed to be a very good one for Beginners. It is expected to be available March-21. Published by "SAMS". The Title is: "Teach Yourself Python In 24-Hours" The Author is: Ivan Van Laningham 2. I also found (As a NEWBIE) "Learning Python" by Mark Lutz and David Ascher very good. But it's somewhat overwhealming for a Newbie. The best thing you can do as a Newbie is to go through the Tutorials Found at Python's Home Page. Then Go and buy the above mentioned books. In addition you will find the experts to be very helpful here at the "tutor-group" ;as well as, in the NG. "comp.os.python" Good Luck. Best regards; Snoopy :-)) -----Original Message----- From: Wood Sgt Dale J To: 'tutor@python.org' Date: Tuesday, March 07, 2000 10:49 AM Subject: [Tutor] Question >I am new to programming and was wondering if anyone can refer me to where I >should start in learning how to program in Python. > >Thanks for any assistance given. > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor From deirdre@deirdre.net Tue Mar 7 18:25:31 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Tue, 7 Mar 2000 10:25:31 -0800 (PST) Subject: [Tutor] Question In-Reply-To: <93E115376C68D311B50200A024BB8F36053773@hqmail004.hqmc.usmc.mil> Message-ID: On Tue, 7 Mar 2000, Wood Sgt Dale J wrote: > I am new to programming and was wondering if anyone can refer me to where I > should start in learning how to program in Python. > > Thanks for any assistance given. http://www.python.org/doc has a tutorial, which is of somewhat limited value if you don't know how to program. We get this question a lot and several of us are working on solving the problem. :) -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net I've _never_ made a decision I've been happier with than quitting $FIRM. -- Rick Moen From bosahv@nhdpuk.zzn.com Tue Mar 7 23:49:48 2000 From: bosahv@nhdpuk.zzn.com (bosahv theo) Date: Tue, 7 Mar 2000 18:49:48 -0500 Subject: [Tutor] Where to start Message-ID: <4CE7BA69FC3F3D11DA8D00807CFDCB89@bosahv.nhdpuk.zzn.com> I'm just starting. I found a whole bunch of info at www.python.org. Download the documentation you can find there. I took it as PDF files in ZIP format. There are hundreds of pages of stuff, to accompany the language. I think that is really the core of the language's documentation. -- Its free to download so you might as well start there. I'm working my way into the tutorial as we speak. After that I would suggest you get an Idea of what you want to do with Python and enable that task with whatever book you think will help. Most people suggest either the O'REILLY _Learning Python_ or _Quick Python_ published by Manning. I bought Quick python, which a friend reccomended. I bought it as much because I can pick his brain as I think it's a good book. Then I bought Python and TKinter Programming, also by Manning, because I think I'm going to use Python the most in a Windows environment. I think the first step however is undoubtably giving all the free documentation a try. Try this 'Cheat sheet' from the IBM site: http://www-4.ibm.com/software/developer/library/cheatsheet3.html Another good address for announcements is the daily Python Url: http://hem.passagen.se/eff/url.htm. I hope these help you, I'm finding them useful. Good luck, pass it on. Bo www.nhdp.nl/english/ Hardware drivers, Free Email, Discuss PC problems, etc ___________________________________________________________ Get your own Web-Based E-mail Service at http://www.zzn.com From Alexandre T. P." >From: Wood Sgt Dale J >To: "'tutor@python.org'" >Date: Tue, 7 Mar 2000 10:49:29 -0500 >charset="iso-8859-1" >Subject: [Tutor] Question > >I am new to programming and was wondering if anyone can refer me to where I >should start in learning how to program in Python. > >Thanks for any assistance given. There are many tutorials and reference guides, just search at www.python.org > > > >--__--__-- > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor > > >End of Tutor Digest_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor From sessile@in-gen.net Sat Mar 11 16:39:59 2000 From: sessile@in-gen.net (sessile@in-gen.net) Date: Sat, 11 Mar 2000 11:39:59 -0500 Subject: [Tutor] Stopping processes on Solaris-2.5.1 Message-ID: <3.0.6.32.20000311113959.007fb7e0@mail.in-gen.net> A couple of pranksters in my group at work have recently discovered that when remotely logged into another user's workstation they can start up various graphical programs (xclock, dtcalc, etc.) and thereby clutter up the other user's screen. Childish? Yes, but mildly funny when happening to someone else. :) I wrote a little program using Python-1.5.2 to scan for users other than myself (or root) being logged into my machine but I haven't figured out how to eliminate any of the offending processes. The 'kill' command doesn't want to stop processes owned by other users so I'm stuck manually clicking on the windows to shut them down. Any advice on how to do automate this through Python? Thanks, Dean. -- E-Mail: sessile@in-gen.net "I don't want the world... I just want your half." -- TMBG (Anna Ng) From Moshe Zadka Sat Mar 11 17:06:16 2000 From: Moshe Zadka (Moshe Zadka) Date: Sat, 11 Mar 2000 19:06:16 +0200 (IST) Subject: [Tutor] Stopping processes on Solaris-2.5.1 In-Reply-To: <3.0.6.32.20000311113959.007fb7e0@mail.in-gen.net> Message-ID: On Sat, 11 Mar 2000 sessile@in-gen.net wrote: > I wrote a little program using Python-1.5.2 to scan for > users other than myself (or root) being logged into my > machine but I haven't figured out how to eliminate any > of the offending processes. The 'kill' command doesn't > want to stop processes owned by other users so I'm stuck > manually clicking on the windows to shut them down. > > Any advice on how to do automate this through Python? Automate what? Python won't let you do anything C won't let you. As a solution to your problems, learn to use the "xhost" program. X's security mechanisms are shameful, but they do serve to keep off the kids. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html From sessile@in-gen.net Sat Mar 11 19:26:24 2000 From: sessile@in-gen.net (sessile@in-gen.net) Date: Sat, 11 Mar 2000 14:26:24 -0500 Subject: [Tutor] Stopping processes on Solaris-2.5.1 In-Reply-To: References: <3.0.6.32.20000311113959.007fb7e0@mail.in-gen.net> Message-ID: <3.0.6.32.20000311142624.007b2100@mail.in-gen.net> At 07:06 PM 3/11/2000 +0200, Moshe Zadka wrote: >On Sat, 11 Mar 2000 sessile@in-gen.net wrote: > >> I wrote a little program using Python-1.5.2 to scan for >> users other than myself (or root) being logged into my >> machine but I haven't figured out how to eliminate any >> of the offending processes. The 'kill' command doesn't >> want to stop processes owned by other users so I'm stuck >> manually clicking on the windows to shut them down. >> >> Any advice on how to do automate this through Python? > >Automate what? Python won't let you do anything C won't let you. >As a solution to your problems, learn to use the "xhost" program. X's >security mechanisms are shameful, but they do serve to keep off the kids. >-- >Moshe Zadka . >http://www.oreilly.com/news/prescod_0300.html > My original, somewhat impractical thought had been to automate the keystrokes required to manually close the unwanted program. The Python code would run in the background waiting for an X application to be started on my machine by one of the pranksters and then close it down. Dangerous if I make a mistake and start shutting down the wrong windows! My thanks to those who responded so quickly. Several people pointed me at the "xhost" program and I agree that this is the best solution. From deirdre@deirdre.net Sat Mar 11 20:25:42 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sat, 11 Mar 2000 12:25:42 -0800 (PST) Subject: [Tutor] Stopping processes on Solaris-2.5.1 In-Reply-To: <3.0.6.32.20000311113959.007fb7e0@mail.in-gen.net> Message-ID: On Sat, 11 Mar 2000 sessile@in-gen.net wrote: > I wrote a little program using Python-1.5.2 to scan for > users other than myself (or root) being logged into my > machine but I haven't figured out how to eliminate any > of the offending processes. The 'kill' command doesn't > want to stop processes owned by other users so I'm stuck > manually clicking on the windows to shut them down. It would have to run as root and then it could kill the processes. Otherwise, you're stuck. You might want to do xhost - to prevent anyone else from having access to your X session though. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "During my service in the United States Congress, I took the initiative in creating the Internet." -- Al Gore "If Al Gore invented the internet, I invented spell check." -- Dan Quayle From dyoo@uclink4.berkeley.edu Sat Mar 11 22:38:56 2000 From: dyoo@uclink4.berkeley.edu (dyoo) Date: Sat, 11 Mar 2000 14:38:56 -0800 Subject: [Tutor] Re: Tutor digest, Vol 1 #257 - 1 msg In-Reply-To: <20000311170010.EC3341CD4E@dinsdale.python.org> References: <20000311170010.EC3341CD4E@dinsdale.python.org> Message-ID: <00031114440902.01128@coffeetable.dwight> On Sat, 11 Mar 2000, you wrote: > A couple of pranksters in my group at work have recently > discovered that when remotely logged into another user's > workstation they can start up various graphical programs > (xclock, dtcalc, etc.) and thereby clutter up the other > user's screen. Childish? Yes, but mildly funny when > happening to someone else. :) Is this related to the use of xhost on your computer? 'xhost' will show which computers are allowed to run x stuff on the machine. In fact, I think xhost is used to prevent this sort of mischief. Your systems may have xhost set too loosely: check those settings first. This is not a python related answer... *grin* Python is great, but sometimes other approaches are necessary. From ajs@ix.netcom.com Sun Mar 12 17:27:33 2000 From: ajs@ix.netcom.com (Arthur Siegel) Date: Sun, 12 Mar 2000 12:27:33 -0500 Subject: [Tutor] Why thus? References: Message-ID: <000801bf8c48$416c1700$bae26dd1@eiconyc> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01BF8C1E.57711700 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Can't quite see what's happening here. counter=3D0 class Count: def __init__(self): print counter Count() gets : 0 Process completed successfully But: counter=3D0 class Count: def __init__(self): counter=3Dcounter+1 print counter Count() gets: Traceback (innermost last): File "C:\temp\test.py", line 6, in ? Count() File "C:\temp\test.py", line 4, in __init__ counter=3Dcounter+1 NameError: counter Process completed with exit code 1 ------=_NextPart_000_0005_01BF8C1E.57711700 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Can't quite see what's happening here.
 
counter=3D0
class Count:
 def=20 __init__(self):
    print = counter
Count()
 
gets :
 
0
Process completed successfully
But:
 
counter=3D0
class Count:
 def=20 __init__(self):
  counter=3Dcounter+1
  print=20 counter
Count()
gets:
 
Traceback (innermost last):
  File = "C:\temp\test.py",=20 line 6, in ?
    Count()
  File = "C:\temp\test.py",=20 line 4, in __init__
    = counter=3Dcounter+1
NameError:=20 counter
 
Process completed with exit code=20 1

------=_NextPart_000_0005_01BF8C1E.57711700-- From gerrit@nl.linux.org Sun Mar 12 19:00:48 2000 From: gerrit@nl.linux.org (Gerrit Holl) Date: Sun, 12 Mar 2000 20:00:48 +0100 Subject: [Tutor] Why thus? In-Reply-To: <000801bf8c48$416c1700$bae26dd1@eiconyc>; from ajs@ix.netcom.com on Sun, Mar 12, 2000 at 12:27:33PM -0500 References: <000801bf8c48$416c1700$bae26dd1@eiconyc> Message-ID: <20000312200048.C4043@nl.linux.org> > Can't quite see what's happening here. > > counter=0 > class Count: > def __init__(self): > print counter > Count() > > gets : > > 0 > Process completed successfully > > But: > > counter=0 > class Count: > def __init__(self): > counter=counter+1 > print counter > Count() > > gets: > > Traceback (innermost last): > File "C:\temp\test.py", line 6, in ? > Count() > File "C:\temp\test.py", line 4, in __init__ > counter=counter+1 > NameError: counter > > Process completed with exit code 1 Use the "global" statement, i.e. "global counter" within __init__. regards, Gerrit. -- 1011001 1101111 1110101 1110010 1110011 0101100 1000111 1100101 1110010 1110010 1101001 1110100 From python-list@teleo.net Sun Mar 12 19:14:00 2000 From: python-list@teleo.net (Patrick Phalen) Date: Sun, 12 Mar 2000 11:14:00 -0800 Subject: [Tutor] Why thus? In-Reply-To: <20000312200048.C4043@nl.linux.org> References: <000801bf8c48$416c1700$bae26dd1@eiconyc> <20000312200048.C4043@nl.linux.org> Message-ID: <00031211214600.02204@quadra.teleo.net> [Gerrit Holl, on Sun, 12 Mar 2000] :: :: > Can't quite see what's happening here. :: > :: > counter=0 :: > class Count: :: > def __init__(self): :: > print counter :: > Count() :: > :: > gets : :: > :: > 0 :: > Process completed successfully :: > :: > But: :: > :: > counter=0 :: > class Count: :: > def __init__(self): :: > counter=counter+1 :: > print counter :: > Count() :: > :: > gets: :: > :: > Traceback (innermost last): :: > File "C:\temp\test.py", line 6, in ? :: > Count() :: > File "C:\temp\test.py", line 4, in __init__ :: > counter=counter+1 :: > NameError: counter :: > :: > Process completed with exit code 1 :: :: :: Use the "global" statement, i.e. "global counter" within :: __init__. Additionally, Arthur, you would probably benefit from reading (rereading?) the Python Tutorial, Chapter 9, Section 2 -- "Python Scopes and Name Spaces," so as to have an overview of why global is necessary here. From ajs@ix.netcom.com Sun Mar 12 20:56:19 2000 From: ajs@ix.netcom.com (Arthur Siegel) Date: Sun, 12 Mar 2000 15:56:19 -0500 Subject: [Tutor] Why thus? References: <000801bf8c48$416c1700$bae26dd1@eiconyc> <20000312200048.C4043@nl.linux.org> <00031211214600.02204@quadra.teleo.net> Message-ID: <001101bf8c65$6c4f8700$91e06dd1@eiconyc> > :: Use the "global" statement, i.e. "global counter" within > :: __init__. > > > Additionally, Arthur, you would probably benefit from reading > (rereading?) the Python Tutorial, Chapter 9, Section 2 -- "Python Scopes > and Name Spaces," so as to have an overview of why global is necessary > here. The global statement clearly solves the practical problem. But having now reread the scope and name space section, I can't say I fully get it. My problem seems to be understanding the significant difference between the "print counter" statement - which can print the value of the "counter" variable from within the class __init__ and the "counter=counter+1" which generates the error saying I never heard of "counter". Then why can it print the value. See where my confusion lies? From tismer@tismer.com Sun Mar 12 21:29:57 2000 From: tismer@tismer.com (Christian Tismer) Date: Sun, 12 Mar 2000 22:29:57 +0100 Subject: [Tutor] Why thus? References: <000801bf8c48$416c1700$bae26dd1@eiconyc> Message-ID: <38CC0C55.1F0E4A87@tismer.com> Ok, let's see .-) > Arthur Siegel wrote: > > Can't quite see what's happening here. > > counter=0 yes, you made a global. > class Count: > def __init__(self): > print counter > Count() Ok, counter is not defined in Count, and it is correctly identified as a global. > counter=0 > class Count: > def __init__(self): > counter=counter+1 > print counter > Count() The difference is: When compiling your code, the compiler tries to figure out what is global and what not. Since counter is assigned to, it becomes a local. But the object does not yet exist when you request it: counter=counter+1 wants to retrieve the current value, and it isn't set yet. You are accessing a local variable which already has its slot and is ready to receive a value, but cannot until it is initialized. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From wesc@alpha.ece.ucsb.edu Sun Mar 12 21:51:44 2000 From: wesc@alpha.ece.ucsb.edu (Wesley J. Chun) Date: Sun, 12 Mar 2000 13:51:44 -0800 (PST) Subject: [Tutor] Why thus? Message-ID: <200003122151.NAA16723@alpha.ece.ucsb.edu> > Date: Sun, 12 Mar 2000 22:29:57 +0100 > From: Christian Tismer > > The difference is: When compiling your code, the compiler > tries to figure out what is global and what not. Since > counter is assigned to, it becomes a local. But the object > does not yet exist when you request it: > counter=counter+1 > wants to retrieve the current value, and it isn't set yet. > You are accessing a local variable which already has its > slot and is ready to receive a value, but cannot until > it is initialized. chris is absolutely right. when doing an assignment in a local scope, the compiler will search only for the local name, and since you haven't done a "counter = XXX" within __init__(), it will complain. here is an easier example of the exact same problem outside the class realm (since it really doesn't have anything to do with classes): # this works (no assignment) i = 4 def foo(): print i # print global 'i' # this fails (references local var that hasn't been # assigned/doesn't exist) i = 4 def foo(): print i # "print global 'i'" i = 6 # set local 'i' the result is a "NameError: i". upon seeing the presence of a local 'i' makes any previous code *think* it should access a local 'i' vs. the global one. i asked Guido to confirm this or to check if it was his way to punish the programmer for writing such horrid code? ;-) here was his reply: The compiler does an analysis of the whole func- tion body and decides that i is a local variable. Then all references to i are made into local vari- able references. Local refs are much faster than global variable references: locals are indexed in an array, globals are a dict lookup. So the ``print i'' accesses the local variable i but it isn't defined yet. In Python 1.6, this will raise UnboundLocalError (a subclass of NameError): >>> def f(): print i; i = 1 >>> f() Traceback (innermost last): File "", line 1, in ? File "", line 1, in f UnboundLocalError: i hope this helps!! -wesley "Core Python Programming", Prentice-Hall, TBP Summer 2000 (will have an example like this in here too!) wesley.j.chun :: wesc@alpha.ece.ucsb.edu cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From tismer@tismer.com Sun Mar 12 22:26:43 2000 From: tismer@tismer.com (Christian Tismer) Date: Sun, 12 Mar 2000 23:26:43 +0100 Subject: [Tutor] Why thus? References: <200003122151.NAA16723@alpha.ece.ucsb.edu> Message-ID: <38CC19A3.D3B90D66@tismer.com> "Wesley J. Chun" wrote: > > > Date: Sun, 12 Mar 2000 22:29:57 +0100 > > From: Christian Tismer > > > > The difference is: When compiling your code, the compiler > > tries to figure out what is global and what not. Since > > counter is assigned to, it becomes a local. But the object > > does not yet exist when you request it: > > counter=counter+1 > > wants to retrieve the current value, and it isn't set yet. > > You are accessing a local variable which already has its > > slot and is ready to receive a value, but cannot until > > it is initialized. > > chris is absolutely right. when doing an assignment in a > local scope, the compiler will search only for the local > name, and since you haven't done a "counter = XXX" within > __init__(), it will complain. Careful, in his exmple he wasn't referring to self at all, and __init__() wouldn't have helped. > # this fails (references local var that hasn't been > # assigned/doesn't exist) > i = 4 > def foo(): > print i # "print global 'i'" ++++++++++++++++++++++++ local > i = 6 # set local 'i' > > the result is a "NameError: i". upon seeing the presence > of a local 'i' makes any previous code *think* it should > access a local 'i' vs. the global one. +++Please try to avoid false comments, this confuses people who are not already sure what's right and what not. Short conclusion: A name in a function is either local or global. If it is assigned to, it is local, unless spelled in a "global" statement. Non-assigned names are always global. ... > "Core Python Programming", Prentice-Hall, TBP Summer 2000 > (will have an example like this in here too!) Also "Learning Python" can be recommended (not only because I translated it into German :-) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From jjiyi@netease.com Mon Mar 13 12:12:03 2000 From: jjiyi@netease.com (jin) Date: Mon, 13 Mar 2000 20:12:3 +0800 Subject: [Tutor] (no subject) Message-ID: <20000313121342.13ADC1C35C400@mx1.netease.com> Sir: why i type >>import stdwin it give me error? jin jjiyi@netease.com From alan.gauld@bt.com Mon Mar 13 17:47:27 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 13 Mar 2000 17:47:27 -0000 Subject: [Tutor] Why thus? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF60D9@mbtlipnt02.btlabs.bt.co.uk> > counter=0 > class Count: > def __init__(self): > print counter > Count() Uses the global counter > counter=0 > class Count: > def __init__(self): > counter=counter+1 creates a new counter - except it can't coz you are trying to use the thus far uncreated counter to initialiuse itself!!!! Try: class Count: def __init__(self): global counter # don't create local one counter = counter + 1 etc... Alan g. From Bruce Sass Mon Mar 13 21:13:32 2000 From: Bruce Sass (Bruce Sass) Date: Mon, 13 Mar 2000 14:13:32 -0700 (MST) Subject: [Tutor] btree problems Message-ID: Hello All, I read through the Tutorial, scanned the Library Reference and Language Reference, then decided to jump into it... I grabbed "Programming with Data Structure (Pascal version)" by Robert L. Kruse off my book shelf and started typing in the basic binary tree code. Here is a snippet of what I came up with: ----- tree-test2.py ----- class datapkg: def __init__(self): self.key = None self.data = None class node: def __init__(self): self.entry = datapkg() self.left = None self.right = None class btree: def __init__(self): self.tree = None def insert(self, newnode): self._InsertTree(self.tree, newnode) def _InsertTree(self, branch, newnode): if branch == None: branch = newnode elif newnode.entry.key < branch.entry.key: self._InsertTree(branch.left, newnode) else: self._InsertTree(branch.right, newnode) tree = btree() print "Created a tree: tree =", tree n = node() n.entry.key = "first" n.entry.data = ['some', 'data'] print "Created a node: n =", n print " n.entry =", n.entry print " n.entry.key =", n.entry.key print " n.entry.data =", n.entry.data tree.insert(n) print "Inserted the node into the tree:" print " tree =", tree print " tree.entry =", tree.entry print " tree.entry.key = ", tree.entry.key ----- end tree-test2.py ----- This is what it generates: ----- tree-test2.output.txt ----- Created a tree: tree = <__main__.btree instance at 83d7ce8> Created a node: n = <__main__.node instance at 83b3d58> n.entry = <__main__.datapkg instance at 83dda48> n.entry.key = first n.entry.data = ['some', 'data'] Inserted the node into the tree: tree = <__main__.btree instance at 83d7ce8> tree.entry = Traceback (innermost last): File "/home/bsass/usr/src/python/tree-test2.py", line 43, in ? print " tree.entry =", tree.entry AttributeError: entry ----- end trees-test2.output.txt ----- What am I doing wrong? later, Bruce From hnowak@cuci.nl Mon Mar 13 22:29:38 2000 From: hnowak@cuci.nl (Hans Nowak) Date: Mon, 13 Mar 2000 23:29:38 +0100 Subject: [Tutor] btree problems In-Reply-To: Message-ID: <200003132230.XAA24317@dionysus.fw.cuci.nl> Bruce Sass writes: > This is what it generates: > ----- tree-test2.output.txt ----- > Created a tree: tree = <__main__.btree instance at 83d7ce8> > Created a node: n = <__main__.node instance at 83b3d58> > n.entry = <__main__.datapkg instance at 83dda48> > n.entry.key = first > n.entry.data = ['some', 'data'] > Inserted the node into the tree: > tree = <__main__.btree instance at 83d7ce8> > tree.entry = > Traceback (innermost last): > File "/home/bsass/usr/src/python/tree-test2.py", line 43, in ? > print " tree.entry =", tree.entry > AttributeError: entry > ----- end trees-test2.output.txt ----- > > What am I doing wrong? Well, at a quick glance... The tree object does not have an attribute 'entry'. The node does, but not the tree, so tree.entry obviously will not work. Maybe tree.tree.entry will (I did not verify this though). HTH, --Hans Nowak (zephyrfalcon@hvision.nl) Homepage: http://www.hvision.nl/~ivnowa/newsite/ Python questions? See http://tor.dhs.org/~zephyrfalcon/snippets You call me a masterless man. You are wrong. I am my own master. From TMartin@megapath.net Mon Mar 13 23:44:55 2000 From: TMartin@megapath.net (Todd Martin) Date: Mon, 13 Mar 2000 15:44:55 -0800 Subject: [Tutor] secure connections Message-ID: Hello, I'm trying to figure out a way to make a secure connection (preferably via ssh) to another machine and run a couple of commands. I know how to open a socket and telnet to a machine to do this, however I need to be able to do it securely. Is there a module or something in Python for doing this? I found this URL http://www.python.org/workshops/1995-12/papers/kuchling.html which talks about SSLeay but I'm not to sure if this is what I'm looking for. Any thoughts? BTW these are UNIX machines, RedHat Linux 6.x to be specific. Thank you in advance for your time. -todd From SKNR@chevron.com Tue Mar 14 13:58:53 2000 From: SKNR@chevron.com (Keener, Sterling (SKNR)) Date: Tue, 14 Mar 2000 05:58:53 -0800 Subject: [Tutor] pythonw.exe - application error Message-ID: <19E91AD74FCBD111B6CD00805F6F7F7006977C40@chevron.com> Whenever I try to close IDLE I receive an error with pythonw.exe dealing with memory. I also get the error when I use the Tkinter GUI extension with python at the command line. The end result is it closes the application and python...most frustrating! I'm running WinNT wkst 4.0 SP5. Any ideas??? I'm extremely new... Sterling Keener, MCSE+I, CCNA Sprint - Enterprise Network Services Technical Solutions Consultant 713-754-3463 CTN 754-3463 From deirdre@deirdre.net Tue Mar 14 16:44:00 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Tue, 14 Mar 2000 08:44:00 -0800 (PST) Subject: [Tutor] Guido van Rossum to speak in Mountain View 3/15 at 8 pm Message-ID: Guido will be speaking to to BayPIGgies tomorrow evening (Wednesday, March 15) on several topics including 1.6 development. Last time Guido spoke to BayPIGgies, he spoke to a packed house. We now have a larger facility for him to speak in. :) For more information, see: http://www.baypiggies.org For public transit directions, see: http://linuxmafia.com/bale -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "During my service in the United States Congress, I took the initiative in creating the Internet." -- Al Gore "If Al Gore invented the internet, I invented spell check." -- Dan Quayle From alan.gauld@bt.com Tue Mar 14 18:18:37 2000 From: alan.gauld@bt.com (Gauld,AJ,Alan,NEL1A GAULDAJ R) Date: Tue, 14 Mar 2000 18:18:37 -0000 Subject: [Tutor] pythonw.exe - application error Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF60ED@mbtlipnt02.btlabs.bt.co.uk> How about giving us a clue? - like what error message do you get? Can you copy it into a message? Also what exactly are you doing with Tkinter? How about a code snippet that generates the error? Thanks, Alan G. From SKNR@chevron.com Tue Mar 14 18:29:04 2000 From: SKNR@chevron.com (Keener, Sterling (SKNR)) Date: Tue, 14 Mar 2000 10:29:04 -0800 Subject: [Tutor] pythonw.exe - application error Message-ID: <19E91AD74FCBD111B6CD00805F6F7F7006977C45@chevron.com> <<...>> NP...here it is...As for how I got the error, I closed (I assume) pythonw.exe which I started by using the IDLE shortcut. Another way I got the error was by using python @ the command line. Same error and here's the code I typed: * from Tkinter import * * w = Button(text="Hello", command='exit') * w.pack() * w.mainloop() or in other words pg. 22 from O'Reilly's Learning Python by Mark Lutz & David Ascher. I'm working on a NT 4.0 wkst with SP5. Anything else? > -----Original Message----- > From: Gauld,AJ,Alan,NEL1A GAULDAJ R [SMTP:alan.gauld@bt.com] > Sent: Tuesday, March 14, 2000 12:19 PM > To: 'Keener, Sterling (SKNR)'; 'tutor@python.org' > Subject: RE: [Tutor] pythonw.exe - application error > > How about giving us a clue? > - like what error message do you get? > > Can you copy it into a message? > > Also what exactly are you doing with Tkinter? > How about a code snippet that generates the error? > > Thanks, > > Alan G. > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From dyoo@uclink4.berkeley.edu Tue Mar 14 18:02:10 2000 From: dyoo@uclink4.berkeley.edu (dyoo) Date: Tue, 14 Mar 2000 10:02:10 -0800 Subject: [Tutor] Re: Tutor digest, Vol 1 #260 - 6 msgs In-Reply-To: <20000314170014.5544B1CE3F@dinsdale.python.org> References: <20000314170014.5544B1CE3F@dinsdale.python.org> Message-ID: <00031410302300.09477@coffeetable.dwight> On Tue, 14 Mar 2000, you wrote: The bug occurs when you initially insert the first element of the list -- Although you've set branch to the newnode, the tree reference in your self hasn't changed. In your _InsertTree(): if branch == None: branch = newnode will not affect your original tree. Likewise, _InsertTree repeats the same bug. Try out the following code that demonstrates the problem: class Number: def __init__(self, x): self.x = x # note - this is buggy: the swap won't work because references haven't changed def swap(a, b): t = a a = b b = a if __name__ == "__main__": firstnumber = Number(42) secondnumber = Number(17) print firstnumber.x print secondnumber.x swap(firstnumber, secondnumber) print firstnumber.x print secondnumber.x Once you understand why this doesn't work, you'll see why the Insert() code isn't working. If you don't want to spoil the solution for yourself, don't read below. ############## There's an easier way to build up your binary tree. Let's define _InsertTree to insert its element into the tree, and then _return_ itself. By using return, we can properly redirect our references. def _InsertTree(self, branch, newnode): if branch == None: return newnode elif newnode.entry.key < branch.entry.key: branch.left = self._InsertTree(branch.left, newnode) return branch else: branch.right = self._InsertTree(branch.right, newnode) return branch def Insert(self, newnode): self.tree = self._InsertTree(self.tree, newnode) Note -- I have not tested this code yet. *grin* From dyoo@uclink4.berkeley.edu Tue Mar 14 18:31:40 2000 From: dyoo@uclink4.berkeley.edu (dyoo) Date: Tue, 14 Mar 2000 10:31:40 -0800 Subject: [Tutor] Re: Tutor digest, Vol 1 #260 - 6 msgs In-Reply-To: <00031410302300.09477@coffeetable.dwight> References: <20000314170014.5544B1CE3F@dinsdale.python.org> <00031410302300.09477@coffeetable.dwight> Message-ID: <00031410322900.09516@coffeetable.dwight> > # note - this is buggy: the swap won't work because references haven't changed > def swap(a, b): > t = a > a = b > b = a Whoops, correction: t = a a = b b = t Sorry about that. From TMartin@megapath.net Tue Mar 14 20:36:30 2000 From: TMartin@megapath.net (Todd Martin) Date: Tue, 14 Mar 2000 12:36:30 -0800 Subject: [Tutor] telnetlib Message-ID: Anyone familiar with telnetlib? I'm trying to write a program that will telnet to a router, login in as a specified user and run a list of commands from a file. Right now I have a small telnetlib program that telnets to a mail server and passes a few arguments, but I don't see anyway for to login using a username and password to a router. I can do this in perl quite easily, but I'd like to do it in python as I am scripting a bunch of tools for my employees to use in python. Basically the below is what I have now, I haven't started working on passing commands because I can't even get it logged in yet: #!/usr/bin/python username = "name" password = "pass" from telnetlib import Telnet tn = Telnet('routername', 23) tn.write('%s\r\n' % username) tn.write('%s\r\n' % password) tn.write('show logging\r\n') tn.write('\r\n') print tn.read_all() tn.close() Any ideas? I don't get any error messages, it just hangs. -todd From deirdre@deirdre.net Tue Mar 14 20:31:14 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Tue, 14 Mar 2000 12:31:14 -0800 (PST) Subject: [Tutor] telnetlib In-Reply-To: Message-ID: On Tue, 14 Mar 2000, Todd Martin wrote: > Basically the below is what I have now, I haven't started working on > passing commands because I can't even get it logged in yet: You may find it necessary to wait for the prompt. :) -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "During my service in the United States Congress, I took the initiative in creating the Internet." -- Al Gore "If Al Gore invented the internet, I invented spell check." -- Dan Quayle From TMartin@megapath.net Tue Mar 14 20:44:14 2000 From: TMartin@megapath.net (Todd Martin) Date: Tue, 14 Mar 2000 12:44:14 -0800 Subject: [Tutor] telnetlib Message-ID: Ok so how do I do that? That was my biggest issue with Perl in that each router has a different prompt, meaning I had to change the script every time I needed to connect to a new router. You'll have to excuse me, I've been using perl for 3 years, python is very new to me. -todd -----Original Message----- From: Deirdre Saoirse [mailto:deirdre@deirdre.net] Sent: Tuesday, March 14, 2000 12:31 PM To: Todd Martin Cc: 'tutor@python.org' Subject: Re: [Tutor] telnetlib On Tue, 14 Mar 2000, Todd Martin wrote: > Basically the below is what I have now, I haven't started working on > passing commands because I can't even get it logged in yet: You may find it necessary to wait for the prompt. :) -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "During my service in the United States Congress, I took the initiative in creating the Internet." -- Al Gore "If Al Gore invented the internet, I invented spell check." -- Dan Quayle From deirdre@deirdre.net Tue Mar 14 20:44:48 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Tue, 14 Mar 2000 12:44:48 -0800 (PST) Subject: [Tutor] telnetlib In-Reply-To: Message-ID: On Tue, 14 Mar 2000, Todd Martin wrote: > Ok so how do I do that? That was my biggest issue with Perl in that each > router has a different prompt, meaning I had to change the script every time > I needed to connect to a new router. You'll have to excuse me, I've been > using perl for 3 years, python is very new to me. Well, one way to do it would be to have the names of each router in a dictionary with the prompts and responses for each. I can spend more time on this later but I'm under a code crunch at the moment. :) -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "During my service in the United States Congress, I took the initiative in creating the Internet." -- Al Gore "If Al Gore invented the internet, I invented spell check." -- Dan Quayle From wesc@alpha.ece.ucsb.edu Tue Mar 14 22:15:38 2000 From: wesc@alpha.ece.ucsb.edu (Wesley J. Chun) Date: Tue, 14 Mar 2000 14:15:38 -0800 (PST) Subject: [Tutor] Why thus? Message-ID: <200003142215.OAA09153@alpha.ece.ucsb.edu> > From tismer@tismer.com Sun Mar 12 14:26 PST 2000 > > "Wesley J. Chun" wrote: > > > > when doing an assignment in a > > local scope, the compiler will search only for the local > > name, and since you haven't done a "counter = XXX" within > > __init__(), it will complain. > > Careful, in his exmple he wasn't referring to self > at all, and __init__() wouldn't have helped. right. i meant to say that you haven't done set counter, i.e. "counter = XXX", within your function (whether it's __init__() or any other one). > > > # this fails (references local var that hasn't been > > # assigned/doesn't exist) > > i = 4 > > def foo(): > > print i # "print global 'i'" > ++++++++++++++++++++++++ local > > i = 6 # set local 'i' > > > +++Please try to avoid false comments, this confuses > people who are not already sure what's right and what not. sorry everyone. i thought that if i put it in "double quotes" you would see that *that* was the intention of the errorneous programmer: they *wanted* to access a global 'i', but sadly, that is not the case. what is really happening is that they were accessing a local variable that didn't exist yet, so: i = 4 def foo(): print i # print (uninitialized) local 'i' i = 6 # set local 'i' as others have already suggested, adding 'global i' will solve your problem. hope this helps!! -wesley "Core Python Programming", Prentice-Hall, TBP Summer 2000 wesley.j.chun :: wesc@alpha.ece.ucsb.edu cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From siegel@eico.com Tue Mar 14 22:25:32 2000 From: siegel@eico.com (Arthur Siegel) Date: Tue, 14 Mar 2000 17:25:32 -0500 Subject: [Tutor] Why thus? Message-ID: > > # this fails (references local var that hasn't been > > # assigned/doesn't exist) > > i = 4 > > def foo(): > > print i # "print global 'i'" > ++++++++++++++++++++++++ local > > i = 6 # set local 'i' I did see your point. It is taking the situation I posed one step further. Even with the print statement chronologically before the local assignment, it fails. It did help to bring home the point Christian was making about what the compiler is up to. Thanks. From wesc@alpha.ece.ucsb.edu Tue Mar 14 22:33:19 2000 From: wesc@alpha.ece.ucsb.edu (Wesley J. Chun) Date: Tue, 14 Mar 2000 14:33:19 -0800 (PST) Subject: [Tutor] new Python course Message-ID: <200003142233.OAA09485@alpha.ece.ucsb.edu> for those of you interested Python training and are able to make it to Northern California, due to the popularity of its first Python course, UC Santa Cruz has decided to offer this course again in Silicon Valley, so if you know anyone who wishes to get up-to-speed quickly on Python or those self-taught who perhaps would like to fill-in any missing gaps, this would be a good opportunity. the maximum enrollment is set at 50, and their rate ($400) is pretty reasonable, being a public institution and all. (shameless plug: i am also available to contract for corporate training services too if there too many people from your company or if you're too far away!) anyway, more info is available below. the website course description is not 100% accurate, but close enough. cheers! -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - another UC Santa Cruz Extension Python course in Silicon Valley, Spring quarter 2000 When: Tuesdays, April 4 - May 30, 2000, 6:30pm-9:30pm Where: Sunnyvale, CA Who: Wesley Chun What: intro to Python, data types, statements, errors and exception handling, functions and modules, OOP and classes, execution environment, regular expressions, network/Internet progamming, interfacing to your operating system, creating GUIs with Tkinter, intro to JPython, and Extending Python Info: for more info, see the UCSC Extension website for the next Python course: http://www.ucsc-extension.edu/knowledge_is_timeless/qd/softlist.taf?function=detail&X_Number=X444.3 From dworkin@ccs.neu.edu Tue Mar 14 22:51:05 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 14 Mar 2000 17:51:05 -0500 Subject: [Tutor] btree problems References: Message-ID: Bruce Sass writes: > Traceback (innermost last): > File "/home/bsass/usr/src/python/tree-test2.py", line 43, in ? > print " tree.entry =", tree.entry > AttributeError: entry Well, the error is telling you what's wrong: "tree" has no attribute named "entry". It is an instance of btree, and your btree classes do not have variables by that name. This is probably caused due to a confusion between trees and nodes. Personally, I would have used a single class to encompass the functionality of your "node" and "btree" classes, but that may not really be necessary to solve your problem. Your _InsertTree method is also flawed. It assigns the new node to the local variable "branch" instead of the relevant instance variable. While "branch" may have been a reference to the same thing as the instance variable you wanted to assign to, the assignment statement merely reassigns what "branch" refers to without looking at its previous value. Here is a version of that code that has been modified to take those changes into effect. It still has some imperfections, but it illustrates potential solutions to the problems I note above. -Justin class datapkg: def __init__(self, key=None, data=None): self.key = key self.data = data class btree: def __init__(self): self.entry = None self.left = None self.right = None def insert(self, newdata): if self.entry == None: self.entry = datapkg(newdata.key, newdata.data) elif newnode.entry.key < self.entry.key: if self.left == None: self.left = btree() self.left.insert(newnode) else: if self.right == None: self.right = btree() self.right.insert(newnode) tree = btree() print "Created a tree: tree =", tree n = datapkg() n.key = "first" n.data = ['some', 'data'] print "Created a datapkg: n =", n print " n.key =", n.key print " n.data =", n.data tree.insert(n) print "Inserted the datapkg into the tree:" print " tree =", tree print " tree.entry =", tree.entry print " tree.entry.key = ", tree.entry.key From louie1@adelphia.net Wed Mar 15 02:01:25 2000 From: louie1@adelphia.net (Luis) Date: Tue, 14 Mar 2000 21:01:25 -0500 Subject: [Tutor] Get me off this list Please!!!! Message-ID: <001001bf8e22$5f51eca0$5843fea9@dad.adelphia.net> This is a multi-part message in MIME format. ------=_NextPart_000_000D_01BF8DF8.75EC75E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable i would like to know how to get off this list can you please help me = PLEASE!!!!! thank you. Louie ------=_NextPart_000_000D_01BF8DF8.75EC75E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
i would like to know how to get off = this list can=20 you please help me PLEASE!!!!!
thank you.
Louie
------=_NextPart_000_000D_01BF8DF8.75EC75E0-- From genius@idirect.com Wed Mar 15 04:16:46 2000 From: genius@idirect.com (Charles Takacs) Date: Tue, 14 Mar 2000 23:16:46 -0500 Subject: [Tutor] Configure Problems Message-ID: <001c01bf8e35$5a0437e0$3b239ad8@charlest> This is a multi-part message in MIME format. ------=_NextPart_000_0019_01BF8E0B.5E4AAD40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am a Newbie with Linux as well as Programming. Trying to lean Python = as my First language I bought "Learning Python". Using RH-6.1. I am = trying to follow the book's instruction but things are not as they = supposed to be. The problems seem to be in configuring to use "Module = Files and Script Files. I would really appreciate some helping hand. This is what I did. 1. For the purpose of Practice in my home directory I created a = Sub-directory where I want to keep my practice .py files. as follows; /home/charly/Mydir 2. In also modified the /home/charly/.bsh_profile file by adding "/home/charly/Mydir:.:" 3.Using Emacs I created as Script file "myfile.py"=20 (since in my RH distribution Python is in /usr/bin and not in = /usr/local/bin) in the file according to the book I typed as follows: #!/usr/bin/python print 'Hello World' Then chmod +x myfile.py=20 could only be donw when I changed to the /home/charly/Mydir directory. The following problem seem to occur. 1. To run the file at the "Shell promt" (as a shell script) a. I can only do it if first I cd to the files directory (i.e = /home/charly/Python) b. I must also add the .py file extension otherwise an error = occures that=20 there is no suchfile. But according to the book the .py = extension is not=20 needed. I also get the error if I try to run the file when = I am in another dir. 2. If I am not in the Subdirectory /home/charly/Mydir when I run python = (in xterm) I type : python import myfile then python gives en error. Hoever if I first cd to the /Mydir = and type the above. then the Hello World is printed. I don't know what I am doing wrong to fix this seemingly basic problems. I was my understanding that Python would find a .py extension file = regardless of in which directory it is. also it is my understanding, = that if a Path is put into the bash_profile file the the shell would find it and it is not necessary to = give the .py extension. I am completely at loss and need some advice. Thanks in advance. Charles Takacs ------=_NextPart_000_0019_01BF8E0B.5E4AAD40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I am a Newbie with Linux as well as = Programming.=20 Trying to lean Python as my First language I bought "Learning=20 Python".  Using RH-6.1. I am trying to follow the book's = instruction=20 but things are not as they supposed to be.  The problems seem to be = in=20 configuring to use "Module Files and Script Files.  I would = really=20 appreciate some helping hand.
 
This is what I did.
1.  For the purpose of Practice = in my home=20 directory I created a Sub-directory where I want to keep my practice .py files.
as follows; =20 /home/charly/Mydir
2. In also modified the=20 /home/charly/.bsh_profile  file by adding
       =20 "/home/charly/Mydir:.:"
3.Using Emacs = I created as=20 Script file "myfile.py"
        (since in = my RH=20 distribution Python is in /usr/bin and not in = /usr/local/bin)
in the file according to the book I typed as=20 follows:
#!/usr/bin/python
print 'Hello World'
 
Then chmod +x myfile.py
could only be donw when I changed to the = /home/charly/Mydir=20 directory.
 
The following problem seem to occur.
1.  To run the file at the "Shell = promt" (as a=20 shell script)
   =20 a.   I can only do it if first I cd to the files directory = (i.e=20 /home/charly/Python)
    b.   I = must also=20 add the .py file extension otherwise an error occures that
          &nbs= p; there=20 is no suchfile.  But according to the book the .py extension is not =
          &nbs= p;=20 needed.  I also get the error if I try to run the file when I am in = another=20 dir.
 
2.  If I am not in the Subdirectory = /home/charly/Mydir=20 when I run python (in xterm)
        I type = :
python
import myfile
        =20 then python gives en error. Hoever if I first cd to the /Mydir and type = the=20 above. then the Hello World is printed.
 
I don't know what I am doing wrong to fix this = seemingly basic=20 problems.
I was my understanding that Python would find a .py = extension=20 file regardless of in which directory it is.  also it is my = understanding,=20 that if a Path is put into the
bash_profile file the the shell would find it and it = is not=20 necessary to give the
.py extension.
 
I am completely at loss and need some advice. Thanks = in=20 advance.
Charles Takacs
 
 
 
------=_NextPart_000_0019_01BF8E0B.5E4AAD40-- From dsh8290@rit.edu Wed Mar 15 04:34:41 2000 From: dsh8290@rit.edu (D-Man) Date: Tue, 14 Mar 2000 23:34:41 -0500 Subject: [Tutor] Configure Problems References: <001c01bf8e35$5a0437e0$3b239ad8@charlest> Message-ID: <38CF12E1.D80D886F@dman.rh.rit.edu> You aren't doing anything wrong. Any file can only be found under one of 3 conditions: 1) it is in the path 2) you are in the directory containing the file 3) you specify the path to the directory containing the file All you need to do is make sure you are in your directory (/home/charly/Mydir) when you work with the python files. I haven't read the book that you referred to, but in my experience, if running the program as a script the .py is necessary. It is also necessary when invoking the python interpreter and providing the file as a command line argument. Where the .py extension is not required is in the import statements in the python files. -D > Charles Takacs wrote: > > I am a Newbie with Linux as well as Programming. Trying to lean Python > as my First language I bought "Learning Python". Using RH-6.1. I am > trying to follow the book's instruction but things are not as they > supposed to be. The problems seem to be in configuring to use "Module > Files and Script Files. I would really appreciate some helping hand. > > This is what I did. > 1. For the purpose of Practice in my home directory I created a > Sub-directory where I want to keep my practice .py files. > as follows; /home/charly/Mydir > 2. In also modified the /home/charly/.bsh_profile file by adding > "/home/charly/Mydir:.:" > 3.Using Emacs I created as Script file "myfile.py" > (since in my RH distribution Python is in /usr/bin and not in > /usr/local/bin) > in the file according to the book I typed as follows: > #!/usr/bin/python > print 'Hello World' > > Then chmod +x myfile.py > could only be donw when I changed to the /home/charly/Mydir directory. > > The following problem seem to occur. > 1. To run the file at the "Shell promt" (as a shell script) > a. I can only do it if first I cd to the files directory (i.e > /home/charly/Python) > b. I must also add the .py file extension otherwise an error > occures that > there is no suchfile. But according to the book the .py > extension is not > needed. I also get the error if I try to run the file > when I am in another dir. > > 2. If I am not in the Subdirectory /home/charly/Mydir when I run > python (in xterm) > I type : > python > import myfile > then python gives en error. Hoever if I first cd to the > /Mydir and type the above. then the Hello World is printed. > > I don't know what I am doing wrong to fix this seemingly basic > problems. > I was my understanding that Python would find a .py extension file > regardless of in which directory it is. also it is my understanding, > that if a Path is put into the > bash_profile file the the shell would find it and it is not necessary > to give the > .py extension. > > I am completely at loss and need some advice. Thanks in advance. > Charles Takacs > > > From genius@idirect.com Wed Mar 15 05:12:28 2000 From: genius@idirect.com (Charles Takacs) Date: Wed, 15 Mar 2000 00:12:28 -0500 Subject: [Tutor] Configure Problems Message-ID: <007d01bf8e3d$2183d3a0$3b239ad8@charlest> Thanks for the quick reply. It clears it clears things up a bit. especially where you refering to the fact, that working with python files I have to be in the file's directory. That is the only way I was able use the import command. The book "Learning Python" supposed to be for Novices. I must be even in a lower classification since I find it over-whelming. I've read the 1st.chapter about 4-5 times and I am still confused. regarding what supposed to be a simple procedure with the "Script and Module Files". I am going to clear my head a bit and go over things again. Once again thanks for your reply. Best regards Charles -----Original Message----- From: D-Man To: tutor@python.org Date: Tuesday, March 14, 2000 11:31 PM Subject: Re: [Tutor] Configure Problems >You aren't doing anything wrong. Any file can only be found under one >of 3 conditions: > 1) it is in the path > 2) you are in the directory containing the file > 3) you specify the path to the directory containing the file > >All you need to do is make sure you are in your directory >(/home/charly/Mydir) when you work with the python files. > >I haven't read the book that you referred to, but in my experience, if >running the program as a script the .py is necessary. It is also >necessary when invoking the python interpreter and providing the file as >a command line argument. Where the .py extension is not required is in >the import statements in the python files. > >-D > > >> Charles Takacs wrote: >> >> I am a Newbie with Linux as well as Programming. Trying to lean Python >> as my First language I bought "Learning Python". Using RH-6.1. I am >> trying to follow the book's instruction but things are not as they >> supposed to be. The problems seem to be in configuring to use "Module >> Files and Script Files. I would really appreciate some helping hand. >> >> This is what I did. >> 1. For the purpose of Practice in my home directory I created a >> Sub-directory where I want to keep my practice .py files. >> as follows; /home/charly/Mydir >> 2. In also modified the /home/charly/.bsh_profile file by adding >> "/home/charly/Mydir:.:" >> 3.Using Emacs I created as Script file "myfile.py" >> (since in my RH distribution Python is in /usr/bin and not in >> /usr/local/bin) >> in the file according to the book I typed as follows: >> #!/usr/bin/python >> print 'Hello World' >> >> Then chmod +x myfile.py >> could only be donw when I changed to the /home/charly/Mydir directory. >> >> The following problem seem to occur. >> 1. To run the file at the "Shell promt" (as a shell script) >> a. I can only do it if first I cd to the files directory (i.e >> /home/charly/Python) >> b. I must also add the .py file extension otherwise an error >> occures that >> there is no suchfile. But according to the book the .py >> extension is not >> needed. I also get the error if I try to run the file >> when I am in another dir. >> >> 2. If I am not in the Subdirectory /home/charly/Mydir when I run >> python (in xterm) >> I type : >> python >> import myfile >> then python gives en error. Hoever if I first cd to the >> /Mydir and type the above. then the Hello World is printed. >> >> I don't know what I am doing wrong to fix this seemingly basic >> problems. >> I was my understanding that Python would find a .py extension file >> regardless of in which directory it is. also it is my understanding, >> that if a Path is put into the >> bash_profile file the the shell would find it and it is not necessary >> to give the >> .py extension. >> >> I am completely at loss and need some advice. Thanks in advance. >> Charles Takacs >> >> >> > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor From python-list@teleo.net Wed Mar 15 07:01:25 2000 From: python-list@teleo.net (Patrick Phalen) Date: Tue, 14 Mar 2000 23:01:25 -0800 Subject: [Tutor] Configure Problems In-Reply-To: <007d01bf8e3d$2183d3a0$3b239ad8@charlest> References: <007d01bf8e3d$2183d3a0$3b239ad8@charlest> Message-ID: <00031423201607.03205@quadra.teleo.net> [Charles Takacs, on Tue, 14 Mar 2000] :: Thanks for the quick reply. :: It clears it clears things up a bit. especially where you refering to the :: fact, that working with python files I have to be in the file's directory. To clarify: you do not *have* to be in the file's directory. If the file is not on your path, you can still call it from wherever your current working directory is by specifying the full path to the file or the relative path from where you are. e.g., from anywhere, you can type this at the command prompt: # /home/charly/myfile.py See? You're specifying exactly where to find the script relative to the root directory. Similarly, if your cwd is /home, you could type: # charly/myfile.py (or /home/charly/myfile.py) There's a nice little Unix beginner's handbook from O'Reilly called Learning the Unix Operating System that covers very basic matters like this. Recommended. :: The book "Learning Python" supposed to be for Novices. Yes -- Python novices; the authors have stated that they expect folks to have a little prior experience with other languages. It's too bad, but the bookstores are crammed with programming books geared to readers who have already learned how to program, but there never seem to be any books for people who haven't cracked that first language. :: I am going to clear my head a bit and go over things again. That's the spirit! Still, to me, the best answer anyone can give to someone who asks "how can I learn to program?" is this: Write a simple program. Run it. If it delivers an error or doesn't work, debug it. Write another program. Run it. ... you get the idea. :) From alan.gauld@bt.com Wed Mar 15 10:14:58 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 15 Mar 2000 10:14:58 -0000 Subject: [Tutor] Configure Problems Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF60F0@mbtlipnt02.btlabs.bt.co.uk> > I am a Newbie with Linux as well as Programming. Welcome to the funny farm :-) > but things are not as they supposed to be. The problems seem > to be in configuring to use "Module Files and Script Files. > I would really appreciate some helping hand. You need to set two paths in your shell login files. Your normal unix path needs to be set to include your python project directory. This will allow you to execute your programs from abnywhere on the system. You need to set the PYTHONPATH environment variable to include your directory. This will allow python to find your modules from anyewhere on the system. eg if you fire up the >>> prompt. > Then chmod +x myfile.py > could only be donw when I changed to the /home/charly/Mydir Or if you gave the full path to your file... > The following problem seem to occur. > 1. To run the file at the "Shell promt" (as a shell script) > a. I can only do it if first I cd to the files That should be ficxed by adding your directory to the unix PATH. try $ env|grep PATH to see if it has been set correctly > b. I must also add the .py file extension You shouldn't need to if the #! /usr/bin/python is set correctly > 2. If I am not in the Subdirectory /home/charly/Mydir when I > run python (in xterm) > import myfile > then python gives en error. That needs the PYTHONPATH fix. > I was my understanding that Python would find a .py extension > file regardless of in which directory it is. Nope, you need to tell it. > understanding, that if a Path is put into the > bash_profile file the the shell would find it and it is not You need to add it to the PATH variable, I assume - I use tcsh myself! Alan G. From jzd3v8@hqs.mid.gmeds.com Wed Mar 15 16:20:15 2000 From: jzd3v8@hqs.mid.gmeds.com (Huang John 810-575-1934) Date: Wed, 15 Mar 2000 11:20:15 -0500 Subject: [Tutor] question Message-ID: <200003151620.LAA14936@hqs.mid.gmeds.com> Hi, folks, I am new here. When I use os.listdir(os.curdir) to list the current directory, I get a list with the elements being files or subdirectories. My question is how to distiguish files from subdirectories. Thanks in advance! Jun From python-list@teleo.net Wed Mar 15 16:21:46 2000 From: python-list@teleo.net (Patrick Phalen) Date: Wed, 15 Mar 2000 08:21:46 -0800 Subject: [Tutor] Configure Problems In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB202DF60F0@mbtlipnt02.btlabs.bt.co.uk> References: <5104D4DBC598D211B5FE0000F8FE7EB202DF60F0@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <00031508445600.03571@quadra.teleo.net> [alan.gauld@bt.com, on Wed, 15 Mar 2000] :: > understanding, that if a Path is put into the :: > bash_profile file the the shell would find it and it is not :: :: You need to add it to the PATH variable, :: I assume - I use tcsh myself! Yes. PATH=$PATH:whatever:whatever:whatever PYTHONPATH=$PYTHONPATH:whatever:whatever Note that whatever you add won't take effect until the file is reread when you log out and back in. Also, there are (presumably) three files in your home directory that have special meaning to bash, providing a way for you to set up your environment the way you want. .bash_profile .bashrc .bash_logout And there should be a global bashrc in /etc. .bash_profile is read/executed only by the login shell. If you start up a new shell (a subshell), it will attempt to read commands from .bashrc. This scheme allows you some flexibility in differentiating startup commands from those needed later. If you need the same commands run regardless, you need to use the source command from within .bash_profile to execute .bashrc. If .bashrc doesn't exist, then /etc/bashrc will be executed. If neither exists, no commands are executed. Once again, these are not Python questions. I encourage you to invest in a good basic book on working with Unix or Linux and the shells or search the Internet for information. From amoreira@mercury.ubi.pt Wed Mar 15 16:44:17 2000 From: amoreira@mercury.ubi.pt (amoreira@mercury.ubi.pt) Date: Wed, 15 Mar 2000 16:44:17 +0000 Subject: [Tutor] question References: <200003151620.LAA14936@hqs.mid.gmeds.com> Message-ID: <38CFBDE1.86515A9C@mercury.ubi.pt> Hello! Try os.path.isdir, as in for fname in os.listdir(os.curdir) if os.path.isdir(fname): print fname+'/' else: print fname This will produce a file listing with directories signalled by a "/" following their name. Check the Library Reference sections 6.1 and 6.2 for more info. Hope it helps! Ze Huang John 810-575-1934 wrote: > Hi, folks, > > I am new here. When I use os.listdir(os.curdir) to list the current directory, I > get a list with the elements being files or subdirectories. My question is how > to distiguish files from subdirectories. Thanks in advance! > > Jun From Bruce Sass Wed Mar 15 19:57:01 2000 From: Bruce Sass (Bruce Sass) Date: Wed, 15 Mar 2000 12:57:01 -0700 (MST) Subject: [Tutor] btree problems In-Reply-To: <200003132230.XAA24317@dionysus.fw.cuci.nl> Message-ID: On Mon, 13 Mar 2000, Hans Nowak wrote: > Well, at a quick glance... The tree object does not have an attribute > 'entry'. The node does, but not the tree, so tree.entry obviously will not > work. Maybe tree.tree.entry will (I did not verify this though). Using "tree.tree.entry" results in "tree.insert(n)" failing with "TypeError: too many arguments; expected 3, got 4" at "self._InsertTree(self, self.tree, newnode)". I've had a similar error from a different route; I'm sure when I figure out how I generated it again I'll be able to figure out what went wrong that time (a two equations, one unknown problem ;)... thanks. I'm not sure where my head was at when I let that obvious error slip by (couldn't see the forest for the trees, perhaps... sorry, couldn't resist the pun). I fixed that error in a hurry, only to run up against the one that was the real problem (but it didn't spit out any error messages, which is why I started thrashing around, got flustered, and sent a less than ideal example to the list, sorry 'bout that). What confused me was the Tutorial's statements that Python doesn't need the two kinds of parameters like Pascal, and that passing an object was cheap because only a pointer was passed... I figured that passing an object was equivalent to Pascal's "var variable:type" parameters. Thanks for your help with that... perhaps you can also help with this: I tried to get rid of the (uhm) header functions (the "def insert..." in the example I sent) by doing: def Insert(self, newnode, branch=self.tree) ... but it fails, complaining about the "self" portion of the "self.tree" object... Why can't the compiler see the self.tree in the __init__ a few lines previous? i.e., class btree: def __init__(self): self.tree = None def Insert(self, newnode, branch=self.tree): ... fails. I was not too surprised that this, class btree: self.tree = None def Insert(self, newnode, branch=self.tree): ... failed at "self.tree = None", because there is no object called "self" in the scope of the btree class. Am I being silly, expecting the compiler to look inside __init__? After all, if __init__ exists, it will be run first thing whenever an instance of a class is created, so it should be valid to reference stuff in __init__ when defining methods of the class, right. Is there a technical reason for the compiler not looking inside __init__, or was it just an oversight that may be fixed in future versions of Python? later, Bruce From genius@idirect.com Wed Mar 15 19:59:05 2000 From: genius@idirect.com (Snoopy :-))) Date: Wed, 15 Mar 2000 14:59:05 -0500 Subject: [Tutor] Configure Problems References: <5104D4DBC598D211B5FE0000F8FE7EB202DF60F0@mbtlipnt02.btlabs.bt.co.uk> <00031508445600.03571@quadra.teleo.net> Message-ID: <38CFEB89.570EAA21@idirect.com> Thanks for the reply Patrick. I think I am starting to get the picture. Actually I have purchased several books Re Linux., and also studying the Tutorials, including the ones recommended on the Python Page. I find Linux absolutely fascinating. But learning a New OS and a Programming language at the same time to say the least is Challenging. I guess in order to become a GeNiUs :-)) one has to be ready for a little inconvenience, like tolerating the changes of the internal and external pressure in one's poor little head. Actually something happened to me last night which indicates that purhaps I should slow down my enthusiasm a bit. I was in the middle of dreaming about Python and woke up finding myself in the bath room pissing in the sink instead of the toilet bowl and saw a green snake coming out of the drain hole. So what's you opinion? Do you think maybe there is a need for some "time-out". Any way keep this info a secret since I don't want to be Spammed.:-) Just a couple more questions to claarify things. 1. Am I correct in uderstanding, that your reference to the PATH variables below are to be included in my Home directory in the "bash_profile file ?(Iam using the bash shell) For Example: PATH=$PATH:/HOME/bin:.:/home/charly/Python PYTHONPATH=$PYTHONPATH:.:/home/charly/Mydir:/usr/lib/python 2. Would both of the above PATH variables should be put in the /etc/profile as well? Best regards Charles Patrick Phalen wrote: > [alan.gauld@bt.com, on Wed, 15 Mar 2000] > :: > understanding, that if a Path is put into the > :: > bash_profile file the the shell would find it and it is not > :: > :: You need to add it to the PATH variable, > :: I assume - I use tcsh myself! > > Yes. > > PATH=$PATH:whatever:whatever:whatever > PYTHONPATH=$PYTHONPATH:whatever:whatever > > Note that whatever you add won't take effect until the file is reread > when you log out and back in. > > Also, there are (presumably) three files in your home directory that > have special meaning to bash, providing a way for you to set up your > environment the way you want. > > .bash_profile > .bashrc > .bash_logout > > And there should be a global bashrc in /etc. > > .bash_profile is read/executed only by the login shell. If you start up > a new shell (a subshell), it will attempt to read commands from > .bashrc. This scheme allows you some flexibility in differentiating > startup commands from those needed later. If you need the same commands > run regardless, you need to use the source command from within > .bash_profile to execute .bashrc. If .bashrc doesn't exist, then > /etc/bashrc will be executed. If neither exists, no commands are > executed. > > Once again, these are not Python questions. I encourage you to invest > in a good basic book on working with Unix or Linux and the shells or > search the Internet for information. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From dworkin@ccs.neu.edu Wed Mar 15 20:11:52 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 15 Mar 2000 15:11:52 -0500 Subject: [Tutor] btree problems In-Reply-To: Bruce Sass's message of "Wed, 15 Mar 2000 12:57:01 -0700 (MST)" References: Message-ID: Bruce Sass writes: > def Insert(self, newnode, branch=self.tree) > ... > but it fails, complaining about the "self" portion of the "self.tree" > object... Why can't the compiler see the self.tree in the __init__ a > few lines previous? Default parameters are computed when the function definition is evaluated. As this is before the object is instantiated, self.tree has not yet been created. > Am I being silly, expecting the compiler to look inside __init__? > After all, if __init__ exists, it will be run first thing whenever an > instance of a class is created, so it should be valid to reference stuff > in __init__ when defining methods of the class, right. > Is there a technical reason for the compiler not looking inside > __init__, or was it just an oversight that may be fixed in future > versions of Python? Since you can subclass a class and then override methods, one cannot guarantee that all of the methods of a given object will always be the same as when a given class was originally defined. It would be a drawback if the compiler were to treat __init__ specially in this regard. -Justin From python-list@teleo.net Wed Mar 15 20:17:01 2000 From: python-list@teleo.net (Patrick Phalen) Date: Wed, 15 Mar 2000 12:17:01 -0800 Subject: [Tutor] Configure Problems In-Reply-To: <38CFEB89.570EAA21@idirect.com> References: <5104D4DBC598D211B5FE0000F8FE7EB202DF60F0@mbtlipnt02.btlabs.bt.co.uk> <00031508445600.03571@quadra.teleo.net> <38CFEB89.570EAA21@idirect.com> Message-ID: <0003151221360G.03571@quadra.teleo.net> [Snoopy :-)), on Wed, 15 Mar 2000] :: Actually something happened to me last night which indicates that purhaps :: I should slow down my enthusiasm a bit. I was in the middle of dreaming :: about Python and woke up finding myself in the bath room pissing in the :: sink instead of the toilet bowl and saw a green snake coming out of the :: drain hole. :: So what's you opinion? Do you think maybe there is a need for some :: "time-out". Any way keep this info a secret since I don't want to be :: Spammed.:-) No -- forge ahead. Sounds like you're starting to act like a real programmer. As for your 'secret', since you posted it to the list, I guess it will just be between you and the thousand or so other folks reading it. ;) :: Just a couple more questions to claarify things. :: 1. Am I correct in uderstanding, that your reference to the PATH :: variables below are to be included in my Home directory in the :: "bash_profile file ?(Iam using the bash shell) :: For Example: :: PATH=$PATH:/HOME/bin:.:/home/charly/Python :: PYTHONPATH=$PYTHONPATH:.:/home/charly/Mydir:/usr/lib/python Yes :: 2. Would both of the above PATH variables should be put in the :: /etc/profile as well? No From TMartin@megapath.net Wed Mar 15 20:28:44 2000 From: TMartin@megapath.net (Todd Martin) Date: Wed, 15 Mar 2000 12:28:44 -0800 Subject: [Tutor] Configure Problems Message-ID: At least you make it to the bathroom, I've had to invest in a carpet cleaner!! :) -todd -----Original Message----- From: Snoopy :-)) [mailto:genius@idirect.com] Sent: Wednesday, March 15, 2000 11:59 AM To: Patrick Phalen Cc: tutor@python.org Subject: Re: [Tutor] Configure Problems Thanks for the reply Patrick. I think I am starting to get the picture. Actually I have purchased several books Re Linux., and also studying the Tutorials, including the ones recommended on the Python Page. I find Linux absolutely fascinating. But learning a New OS and a Programming language at the same time to say the least is Challenging. I guess in order to become a GeNiUs :-)) one has to be ready for a little inconvenience, like tolerating the changes of the internal and external pressure in one's poor little head. Actually something happened to me last night which indicates that purhaps I should slow down my enthusiasm a bit. I was in the middle of dreaming about Python and woke up finding myself in the bath room pissing in the sink instead of the toilet bowl and saw a green snake coming out of the drain hole. So what's you opinion? Do you think maybe there is a need for some "time-out". Any way keep this info a secret since I don't want to be Spammed.:-) Just a couple more questions to claarify things. 1. Am I correct in uderstanding, that your reference to the PATH variables below are to be included in my Home directory in the "bash_profile file ?(Iam using the bash shell) For Example: PATH=$PATH:/HOME/bin:.:/home/charly/Python PYTHONPATH=$PYTHONPATH:.:/home/charly/Mydir:/usr/lib/python 2. Would both of the above PATH variables should be put in the /etc/profile as well? Best regards Charles Patrick Phalen wrote: > [alan.gauld@bt.com, on Wed, 15 Mar 2000] > :: > understanding, that if a Path is put into the > :: > bash_profile file the the shell would find it and it is not > :: > :: You need to add it to the PATH variable, > :: I assume - I use tcsh myself! > > Yes. > > PATH=$PATH:whatever:whatever:whatever > PYTHONPATH=$PYTHONPATH:whatever:whatever > > Note that whatever you add won't take effect until the file is reread > when you log out and back in. > > Also, there are (presumably) three files in your home directory that > have special meaning to bash, providing a way for you to set up your > environment the way you want. > > .bash_profile > .bashrc > .bash_logout > > And there should be a global bashrc in /etc. > > .bash_profile is read/executed only by the login shell. If you start up > a new shell (a subshell), it will attempt to read commands from > .bashrc. This scheme allows you some flexibility in differentiating > startup commands from those needed later. If you need the same commands > run regardless, you need to use the source command from within > .bash_profile to execute .bashrc. If .bashrc doesn't exist, then > /etc/bashrc will be executed. If neither exists, no commands are > executed. > > Once again, these are not Python questions. I encourage you to invest > in a good basic book on working with Unix or Linux and the shells or > search the Internet for information. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From genius@idirect.com Wed Mar 15 20:22:23 2000 From: genius@idirect.com (Snoopy :-))) Date: Wed, 15 Mar 2000 15:22:23 -0500 Subject: [Tutor] Configure Problems References: <5104D4DBC598D211B5FE0000F8FE7EB202DF60F0@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <38CFF0FF.D7AFCB85@idirect.com> Hi Alan. Thanks for the reply and the "welcome message". Aam I correct in the Understanding, that the two Paths which you are talking about are the PATH & PYTHONPATH. and ,that they Should be setup in /home/.bash-profile File ?? BTY. I am also studying Your-Tutorial and find it very helpful. It's somehow easier to understand than the book "Learning Python". I guess i have a long way to go yet. So back to the "Salt-Mine". Best regards; Charles :-)) alan.gauld@bt.com wrote: > > I am a Newbie with Linux as well as Programming. > > Welcome to the funny farm :-) > > > but things are not as they supposed to be. The problems seem > > to be in configuring to use "Module Files and Script Files. > > I would really appreciate some helping hand. > > You need to set two paths in your shell login files. > > Your normal unix path needs to be set to include > your python project directory. This will allow you > to execute your programs from abnywhere on the system. > > You need to set the PYTHONPATH environment variable > to include your directory. This will allow python > to find your modules from anyewhere on the system. > eg if you fire up the >>> prompt. > > > Then chmod +x myfile.py > > could only be donw when I changed to the /home/charly/Mydir > > Or if you gave the full path to your file... > > > The following problem seem to occur. > > 1. To run the file at the "Shell promt" (as a shell script) > > a. I can only do it if first I cd to the files > > That should be ficxed by adding your directory to the > unix PATH. > > try > $ env|grep PATH > > to see if it has been set correctly > > > b. I must also add the .py file extension > > You shouldn't need to if the #! /usr/bin/python > is set correctly > > > 2. If I am not in the Subdirectory /home/charly/Mydir when I > > run python (in xterm) > > import myfile > > then python gives en error. > > That needs the PYTHONPATH fix. > > > I was my understanding that Python would find a .py extension > > file regardless of in which directory it is. > > Nope, you need to tell it. > > > understanding, that if a Path is put into the > > bash_profile file the the shell would find it and it is not > > You need to add it to the PATH variable, > I assume - I use tcsh myself! > > Alan G. From bsass@freenet.edmonton.ab.ca Wed Mar 15 20:40:03 2000 From: bsass@freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 15 Mar 2000 13:40:03 -0700 (MST) Subject: [Tutor] btree problems In-Reply-To: Message-ID: On 15 Mar 2000, Justin Sheehy wrote: > Bruce Sass writes: > > def Insert(self, newnode, branch=self.tree) > > ... > > but it fails, complaining about the "self" portion of the "self.tree" > > object... Why can't the compiler see the self.tree in the __init__ a > > few lines previous? > > Default parameters are computed when the function definition is > evaluated. As this is before the object is instantiated, self.tree > has not yet been created. ok > > Am I being silly, expecting the compiler to look inside __init__? > > After all, if __init__ exists, it will be run first thing whenever an > > instance of a class is created, so it should be valid to reference stuff > > in __init__ when defining methods of the class, right. > > Is there a technical reason for the compiler not looking inside > > __init__, or was it just an oversight that may be fixed in future > > versions of Python? > > Since you can subclass a class and then override methods, one cannot > guarantee that all of the methods of a given object will always be the > same as when a given class was originally defined. > > It would be a drawback if the compiler were to treat __init__ > specially in this regard. Hmmm, ok, sounds like a good technical reason... thanks, again. Is Python a good first introduction to OOP, or does it have quirks that will cause problems/confusion when I delve into C++? - Bruce From deirdre@deirdre.net Wed Mar 15 20:35:20 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 15 Mar 2000 12:35:20 -0800 (PST) Subject: [Tutor] question In-Reply-To: <38CFBDE1.86515A9C@mercury.ubi.pt> Message-ID: On Wed, 15 Mar 2000 amoreira@mercury.ubi.pt wrote: > Hello! > > Try os.path.isdir, as in > > for fname in os.listdir(os.curdir) > if os.path.isdir(fname): > print fname+'/' > else: > print fname Please note that this is not portable across operating systems. Specifically, it'll break on Windows and MacOS. A more portable version: if os.path.isdir(fname): print fname + os.sep else: print fname -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "In /dev/null, no one can hear you scream" From dworkin@ccs.neu.edu Wed Mar 15 20:43:59 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 15 Mar 2000 15:43:59 -0500 Subject: [Tutor] btree problems In-Reply-To: Bruce Sass's message of "Wed, 15 Mar 2000 13:40:03 -0700 (MST)" References: Message-ID: Bruce Sass writes: > Is Python a good first introduction to OOP, or does it have quirks that > will cause problems/confusion when I delve into C++? If what you want is to learn OOP, Python is an excellent choice. I know a few people who felt that they didn't really grok OOP for a while, but picked up the basic concepts very quickly once they started using Python. I wouldn't recommend C++ as a learning tool for learning anything other than C++. -Justin From deirdre@deirdre.net Wed Mar 15 20:40:57 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 15 Mar 2000 12:40:57 -0800 (PST) Subject: [Tutor] btree problems In-Reply-To: Message-ID: On Wed, 15 Mar 2000, Bruce Sass wrote: > Is Python a good first introduction to OOP, or does it have quirks that > will cause problems/confusion when I delve into C++? You know, I've written commercial apps in C++ but it's such a behemoth that it's hard to learn fully. In fact, I doubt anyone DOES know it fully, not even Stroustrop. :) Anyway, I think Python's a really GOOD way to learn the basics of OOP without the cruft. I just wish I'd learned in the opposite order myself. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "In /dev/null, no one can hear you scream" From TMartin@megapath.net Wed Mar 15 21:27:00 2000 From: TMartin@megapath.net (Todd Martin) Date: Wed, 15 Mar 2000 13:27:00 -0800 Subject: [Tutor] btree problems Message-ID: I would actually consider Delphi a better learning language and stepping stone into OOP. Delphi is nothing more than Object Pascal which was created as a learning tool in the first place. I would count Python as second best in the learning realm, however Python kicks Delphi's booty in the cross platform department. The advantages of Python as a tool in general far exceed that of Delphi, it's just that Delphi is easier to learn. -todd -----Original Message----- From: Deirdre Saoirse [mailto:deirdre@deirdre.net] Sent: Wednesday, March 15, 2000 12:41 PM To: Bruce Sass Cc: Justin Sheehy; tutor@python.org Subject: Re: [Tutor] btree problems On Wed, 15 Mar 2000, Bruce Sass wrote: > Is Python a good first introduction to OOP, or does it have quirks that > will cause problems/confusion when I delve into C++? You know, I've written commercial apps in C++ but it's such a behemoth that it's hard to learn fully. In fact, I doubt anyone DOES know it fully, not even Stroustrop. :) Anyway, I think Python's a really GOOD way to learn the basics of OOP without the cruft. I just wish I'd learned in the opposite order myself. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "In /dev/null, no one can hear you scream" _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From hnowak@cuci.nl Wed Mar 15 23:22:25 2000 From: hnowak@cuci.nl (Hans Nowak) Date: Thu, 16 Mar 2000 00:22:25 +0100 Subject: [Tutor] btree problems In-Reply-To: Message-ID: <200003152323.AAA10588@dionysus.fw.cuci.nl> On 15 Mar 00, at 13:27, Todd Martin wrote: > I would actually consider Delphi a better learning language and stepping > stone into OOP. [...] Hmm, I'm not so sure about that... We have a lot of cool application programmers at my office, working with Delphi, but they don't know jack about OOP. I think this is because Delphi lets you get away with only *using* the already existing objects and components. It doesn't particularly encourage you to create or derive new classes, and in this respect I don't see the benefits of Delphi over Python. On the other hand, Delphi is of course an excellent example about what you can do with OOP... Maybe someday such a system will also be available for Python. Preferably affordable. ;-) --Hans Nowak (zephyrfalcon@hvision.nl) Homepage: http://www.hvision.nl/~ivnowa/newsite/ Python questions? See http://tor.dhs.org/~zephyrfalcon/snippets You call me a masterless man. You are wrong. I am my own master. From TMartin@megapath.net Wed Mar 15 23:33:40 2000 From: TMartin@megapath.net (Todd Martin) Date: Wed, 15 Mar 2000 15:33:40 -0800 Subject: [Tutor] btree problems Message-ID: I agree, Delphi perhaps makes things a bit too easy. I wouldn't think it to be so hard to develop an IDE such as Delphi, I wonder if anyone has started such a project. -todd -----Original Message----- From: Hans Nowak [mailto:hnowak@cuci.nl] Sent: Wednesday, March 15, 2000 3:22 PM To: Todd Martin Cc: tutor@python.org Subject: RE: [Tutor] btree problems On 15 Mar 00, at 13:27, Todd Martin wrote: > I would actually consider Delphi a better learning language and stepping > stone into OOP. [...] Hmm, I'm not so sure about that... We have a lot of cool application programmers at my office, working with Delphi, but they don't know jack about OOP. I think this is because Delphi lets you get away with only *using* the already existing objects and components. It doesn't particularly encourage you to create or derive new classes, and in this respect I don't see the benefits of Delphi over Python. On the other hand, Delphi is of course an excellent example about what you can do with OOP... Maybe someday such a system will also be available for Python. Preferably affordable. ;-) --Hans Nowak (zephyrfalcon@hvision.nl) Homepage: http://www.hvision.nl/~ivnowa/newsite/ Python questions? See http://tor.dhs.org/~zephyrfalcon/snippets You call me a masterless man. You are wrong. I am my own master. _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From danstar@execpc.com Wed Mar 15 23:40:12 2000 From: danstar@execpc.com (Dan Star) Date: Wed, 15 Mar 2000 17:40:12 -0600 Subject: [Tutor] btree problems References: <200003152323.AAA10588@dionysus.fw.cuci.nl> Message-ID: <38D01F5C.3F0DDF62@execpc.com> Delphi is not pure OOP. You can still write structured non-OOP code. -Dan Hans Nowak wrote: > > On 15 Mar 00, at 13:27, Todd Martin wrote: > > > I would actually consider Delphi a better learning language and stepping > > stone into OOP. [...] > > Hmm, I'm not so sure about that... We have a lot of cool application > programmers at my office, working with Delphi, but they don't know jack > about OOP. I think this is because Delphi lets you get away with only > *using* the already existing objects and components. It doesn't > particularly encourage you to create or derive new classes, and in this > respect I don't see the benefits of Delphi over Python. > > On the other hand, Delphi is of course an excellent example about what you > can do with OOP... Maybe someday such a system will also be available for > Python. Preferably affordable. ;-) > > --Hans Nowak (zephyrfalcon@hvision.nl) > Homepage: http://www.hvision.nl/~ivnowa/newsite/ > Python questions? See http://tor.dhs.org/~zephyrfalcon/snippets > You call me a masterless man. You are wrong. I am my own master. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From TMartin@megapath.net Wed Mar 15 23:46:28 2000 From: TMartin@megapath.net (Todd Martin) Date: Wed, 15 Mar 2000 15:46:28 -0800 Subject: [Tutor] btree problems Message-ID: It's still OOP, you can do the same in C++, that doesn't mean C++ isn't OOP. -todd -----Original Message----- From: Dan Star [mailto:danstar@execpc.com] Sent: Wednesday, March 15, 2000 3:40 PM Cc: tutor@python.org Subject: Re: [Tutor] btree problems Delphi is not pure OOP. You can still write structured non-OOP code. -Dan Hans Nowak wrote: > > On 15 Mar 00, at 13:27, Todd Martin wrote: > > > I would actually consider Delphi a better learning language and stepping > > stone into OOP. [...] > > Hmm, I'm not so sure about that... We have a lot of cool application > programmers at my office, working with Delphi, but they don't know jack > about OOP. I think this is because Delphi lets you get away with only > *using* the already existing objects and components. It doesn't > particularly encourage you to create or derive new classes, and in this > respect I don't see the benefits of Delphi over Python. > > On the other hand, Delphi is of course an excellent example about what you > can do with OOP... Maybe someday such a system will also be available for > Python. Preferably affordable. ;-) > > --Hans Nowak (zephyrfalcon@hvision.nl) > Homepage: http://www.hvision.nl/~ivnowa/newsite/ > Python questions? See http://tor.dhs.org/~zephyrfalcon/snippets > You call me a masterless man. You are wrong. I am my own master. > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From genius@idirect.com Thu Mar 16 02:15:35 2000 From: genius@idirect.com (Snoopy :-))) Date: Wed, 15 Mar 2000 21:15:35 -0500 Subject: [Tutor] Configure Problems References: <5104D4DBC598D211B5FE0000F8FE7EB202DF60F0@mbtlipnt02.btlabs.bt.co.uk> <00031508445600.03571@quadra.teleo.net> <38CFEB89.570EAA21@idirect.com> <0003151221360G.03571@quadra.teleo.net> Message-ID: <38D043C7.538394AA@idirect.com> Hi Patrick :-)) Thanks for the reply and for confirming my questions. You made my day. I think I am begining to understand the Procedures. So now I am going to finish the configuration after which I have to find some other things to bug you guys with. Best regards Charles :-)) Patrick Phalen wrote: > [Snoopy :-)), on Wed, 15 Mar 2000] > > :: Actually something happened to me last night which indicates that purhaps > :: I should slow down my enthusiasm a bit. I was in the middle of dreaming > :: about Python and woke up finding myself in the bath room pissing in the > :: sink instead of the toilet bowl and saw a green snake coming out of the > :: drain hole. > :: So what's you opinion? Do you think maybe there is a need for some > :: "time-out". Any way keep this info a secret since I don't want to be > :: Spammed.:-) > > No -- forge ahead. Sounds like you're starting to act like a real > programmer. > > As for your 'secret', since you posted it to the list, I guess it will > just be between you and the thousand or so other folks reading it. ;) > > :: Just a couple more questions to claarify things. > :: 1. Am I correct in uderstanding, that your reference to the PATH > :: variables below are to be included in my Home directory in the > :: "bash_profile file ?(Iam using the bash shell) > :: For Example: > :: PATH=$PATH:/HOME/bin:.:/home/charly/Python > :: PYTHONPATH=$PYTHONPATH:.:/home/charly/Mydir:/usr/lib/python > > Yes > > :: 2. Would both of the above PATH variables should be put in the > :: /etc/profile as well? > > No > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From pm@dis.ro Thu Mar 16 09:37:05 2000 From: pm@dis.ro (Marcel Preda) Date: Thu, 16 Mar 2000 10:37:05 +0100 Subject: [Tutor] python + Oracle Message-ID: <000201bf8f2c$f477fb20$1301000a@punto.it> Hi Does someone know about a python module (linux platform) for connecting to Oracle8i server? Now we have PostgreSQL , but we want to change it. Thanks! Marcel From genius@idirect.com Thu Mar 16 23:04:05 2000 From: genius@idirect.com (Snoopy :-))) Date: Thu, 16 Mar 2000 18:04:05 -0500 Subject: [Tutor] Question Re:PYTHONPATH Message-ID: <38D16864.6C32079D@idirect.com> Here I am again: I am Trying to learn Python as my FIRST Language and am using the book "Learning Python" In setting up the PYTHONPATH showing the following Example: setenv PYTHONPATH .:/usr/local/lib/python:/usr/local/lib/python/tkinter I am using RH6.1 (as a Linux NEWBIEas well) and the above subdirectories (python & tkinter) don't exist. Also there is nothing in the /usr/local directories. However there is /usr/lib/python1.5 and /usr/lib/python1.5/lib-tk which seems to be the libraries being referred to above. Using the "Bash-Shell" " I've put the following in my Home dir "bash_profile File. PYTHONPATH=$PYTHONPATH::/usr/lib/python1.5:/usr/lib/python1.5/lib-tk:.:/home/charly ( I want to use for the purpose of Practice the directory /home/charly) My question are; 1. Have I found the right Libraries and is my solution above correct? 2. What goes in the /usr/local Directories? (Since all the Subdirectories are empty? Best regards Charles Takacs From wilson@visi.com Fri Mar 17 03:25:43 2000 From: wilson@visi.com (Timothy Wilson) Date: Thu, 16 Mar 2000 21:25:43 -0600 (CST) Subject: [Tutor] catching cheaters w/ Python Message-ID: Hi everyone, I'm a high school teacher who would like to use a more high tech. approach to catching students who are attempting to "recycle" research papers. My colleagues and I assign a research paper every spring for which the students are to analyze a source of energy (e.g., gasoline, nuclear fission) and determine whether it meets a set of criteria that they define. We grade about 350 of these per year and save copies of all of them in case questions arise later. How reasonable would it be to use Python to examine a table (using a text file or RDBMS) listing names, topics, and thesis statements and search for thesis statements that are identical or nearly so? -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ wilson@visi.com | | http://linux.com/ From bdempsey@charter.net Sun Mar 19 03:55:07 2000 From: bdempsey@charter.net (Bob Dempsey) Date: Sat, 18 Mar 2000 22:55:07 -0500 Subject: [Tutor] Can the Window key be used? Message-ID: <000301bf9156$ea63fea0$ae15d818@Dempsey> This is a multi-part message in MIME format. ------=_NextPart_000_0004_01BF912D.018DF6A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I was wondering if anyone knew how to use the Window Key in a script. = For example with the {Window Key + F} without the braces; the keystroke = combination will open up the search window. I do not believe = NaturallySpeaking will see the Window Key as a system key. I thought = perhaps there might be a way using python to take advantage of the = Window Key functionality. If anyone has any thoughts or ideas I would appreciate the information. Regards, Bob Dempsey ------=_NextPart_000_0004_01BF912D.018DF6A0 Content-Type: application/ms-tnef; name="winmail.dat" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="winmail.dat" eJ8+IgcDAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy b3NvZnQgTWFpbC5Ob3RlADEIAQ2ABAACAAAAAgACAAEGgAMADgAAANAHAwASABYANwAAAAYAPwEB A5AGADwGAAAnAAAACwACAAEAAAALACMAAAAAAAMAJgAAAAAACwApAAAAAAADADYAAAAAAB4AcAAB AAAAHAAAAENhbiB0aGUgV2luZG93IGtleSBiZSB1c2VkPwACAXEAAQAAABYAAAABv5FW6jEN/bWL GklOxLMcKsb2hn9GAAACAR0MAQAAABoAAABTTVRQOkJERU1QU0VZQENIQVJURVIuTkVUAAAACwAB DgAAAABAAAYOAALn5VaRvwECAQoOAQAAABgAAAAAAAAASwS98uVR0hGSTQBgZwh3+8KAAAALAB8O AQAAAAMABhDmWE5oAwAHEHEBAAAeAAgQAQAAAGUAAABJV0FTV09OREVSSU5HSUZBTllPTkVLTkVX SE9XVE9VU0VUSEVXSU5ET1dLRVlJTkFTQ1JJUFRGT1JFWEFNUExFV0lUSFRIRVdJTkRPV0tFWStG V0lUSE9VVFRIRUJSQUNFUztUAAAAAAIBCRABAAAA4AEAANwBAABhAgAATFpGdSpCKrMDAAoAcmNw ZzEyNRYyAPgLYG4OEDAzM08B9wKkA+MCAGNoCsBzsGV0MCAHEwKAfQqBknYIkHdrC4BkNAxgDmMA UAsDC7MxNiBJ6CB3YQQgdwIgBIELgFRnIAaQIABweQIgZUwgaxVAB+BobwfgdFhvIHURIBXwaBVQ V2MScRXRS2V5FMADoGFCIAT0LiAgRgWxZfh4YW0LUBVQA/AWcBZjlFx7FrkrGDBcfRjzZwhgBUAW cmJyANAHkDtlFmNrFzBzdANgHEAgxwWgBtALgGF0aQIgGPGybAMgb3AJ8BYgcBZj/xEgCsAQ4Bjx FtIYERPQFuCIIG5vBUBiZWwIkDp2FVBOHUAIcAdAbHn6Ux4AYRJhFLAdoxEgFl/nFAEXkRxhZW0c Mh+DGuKsZ2gFQB4AchDwcAQg4xZxCXAgbWkk4iBAF4HPE/AXQBYwFJJweRrhA6DHFgEBkByxYWR2 AHABkBpnFVBvFOAWfWZ1bn5jHVIHQBkQJEAKogqASX8U5xDwI3EVECSWBCAFsWlPAQAUARPRCGBs ZBTwcPpwCXBjBzAj4BZjC4ACEB5yAMAdUirVKuRSZWcJCxFzLC+6Qm9iIL5EI/AlcBcwKuQR4QAz AAMAEBAAAAAAAwAREAAAAAALAACACCAGAAAAAADAAAAAAAAARgAAAAADhQAAAAAAAAMAAoAIIAYA AAAAAMAAAAAAAABGAAAAABCFAAAAAAAAAwAFgAggBgAAAAAAwAAAAAAAAEYAAAAAUoUAAPATAAAe ACWACCAGAAAAAADAAAAAAAAARgAAAABUhQAAAQAAAAQAAAA4LjUAAwAmgAggBgAAAAAAwAAAAAAA AEYAAAAAAYUAAAAAAAALAC+ACCAGAAAAAADAAAAAAAAARgAAAAAOhQAAAAAAAAMAMIAIIAYAAAAA AMAAAAAAAABGAAAAABGFAAAAAAAAAwAygAggBgAAAAAAwAAAAAAAAEYAAAAAGIUAAAAAAAAeAEGA CCAGAAAAAADAAAAAAAAARgAAAAA2hQAAAQAAAAEAAAAAAAAAHgBCgAggBgAAAAAAwAAAAAAAAEYA AAAAN4UAAAEAAAABAAAAAAAAAB4AQ4AIIAYAAAAAAMAAAAAAAABGAAAAADiFAAABAAAAAQAAAAAA AAALAMaACyAGAAAAAADAAAAAAAAARgAAAAAAiAAAAAAAAAsAyIALIAYAAAAAAMAAAAAAAABGAAAA AAWIAAAAAAAACwDVgAggBgAAAAAAwAAAAAAAAEYAAAAABoUAAAAAAAALANmACCAGAAAAAADAAAAA AAAARgAAAACChQAAAQAAAAIB+A8BAAAAEAAAAEsEvfLlUdIRkk0AYGcId/sCAfoPAQAAABAAAABL BL3y5VHSEZJNAGBnCHf7AgH7DwEAAABIAAAAAAAAADihuxAF5RAaobsIACsqVsIAAFBTVFBSWC5E TEwAAAAAAAAAAE5JVEH5v7gBAKoAN9luAAAARTpcb3V0bG9vay5wc3QAAwD+DwUAAAADAA00/TcA AAIBfwABAAAAMQAAADAwMDAwMDAwNEIwNEJERjJFNTUxRDIxMTkyNEQwMDYwNjcwODc3RkI0NEY2 MjcwMAAAAADSPw== ------=_NextPart_000_0004_01BF912D.018DF6A0-- From tescoil@rtpro.net Sun Mar 19 18:21:20 2000 From: tescoil@rtpro.net (Tesla Coil) Date: Sun, 19 Mar 2000 12:21:20 -0600 Subject: [Tutor] CBNC control loop. Message-ID: <38D51AA0.73702336@rtpro.net> # Desired result: keyword TOMATO generates idxlist # [3, 9, 15, 21, 2, 8, 14, 20, 26, 1, 7, 13, 19, 25, 5, 11, 17, 23, # 0, 6, 12, 18, 24, 4, 10, 16, 22] # Close-But-No-Cigar control loop results in: # [9, 15, 21, 27, 8, 14, 20, 26, 32, 7, 13, 19, 25, 31, 11, 17, 23, # 29, 6, 12, 18, 24, 30, 10, 16, 22, 28] import string keystring = raw_input ('keyword please: ') keystring = string.upper(keystring) keylist = list(keystring) seqlist = [] message = string.uppercase def unstray(listinput): for stray in listinput: if stray not in string.uppercase: listinput.remove(stray) def keysequence(alphakey): for letter in range(len(string.uppercase)): for item in range(len(alphakey)): if string.uppercase[letter]==alphakey[item]: seqlist.append(item) unstray(keylist) keysequence(keylist) idxlist=[] # CBNC control loop here: for n in range(len(seqlist)): idxpos = seqlist[n] while idxpos <= len(message): idxpos = idxpos+len(seqlist) idxlist.append(idxpos) print idxlist From tescoil@rtpro.net Sun Mar 19 21:28:24 2000 From: tescoil@rtpro.net (Tesla Coil) Date: Sun, 19 Mar 2000 15:28:24 -0600 Subject: [Tutor] CBNC control loop. References: <38D51AA0.73702336@rtpro.net> Message-ID: <38D54678.B5EC86F9@rtpro.net> > # Desired result: keyword TOMATO generates idxlist > # [3, 9, 15, 21, 2, 8, 14, 20, 26, 1, 7, 13, 19, 25, 5, 11, 17, 23, > # 0, 6, 12, 18, 24, 4, 10, 16, 22] > # Close-But-No-Cigar control loop results in: > # [9, 15, 21, 27, 8, 14, 20, 26, 32, 7, 13, 19, 25, 31, 11, 17, 23, > # 29, 6, 12, 18, 24, 30, 10, 16, 22, 28] > > # CBNC control loop here: > for n in range(len(seqlist)): > idxpos = seqlist[n] > while idxpos <= len(message): > idxpos = idxpos+len(seqlist) > idxlist.append(idxpos) # I guess I just needed a nap... for n in range(len(seqlist)): idxpos = seqlist[n] idxlist.append(idxpos) while idxpos+len(seqlist)<= len(message): idxpos = idxpos+len(seqlist) idxlist.append(idxpos) I'll probably be back later to ask if there's a better way to do what I'm doing (and to explain what I'm doing). From tescoil@rtpro.net Sun Mar 19 23:36:15 2000 From: tescoil@rtpro.net (Tesla Coil) Date: Sun, 19 Mar 2000 17:36:15 -0600 Subject: [Tutor] Columnar Transposition Cipher. Message-ID: <38D5646F.67E2EA0A@rtpro.net> The technique is described in opening paragraphs of: http://www.cwi.nl/people/enigma/jsavard/pp0102.htm The author has errored their example key, taking 'O' for occurring alphabetically before 'N.' The result should have been HECRN CEYI ISEP SGDI RNTO AAES RMPN SSRO EEBT ETIA EEHS. Here's my little program to do it correctly. I don't know that this is the best approach, style is awful, still lacking a decipher function, and telegraph should output in five letter groups (HECRN CEYII SEPSG DIRNT etc)--appreciate comments in these regards. #coltrans.py - Columnar Transposition Cipher import string keystring = raw_input ('keyword please: ') keylist = list(string.upper(keystring)) seqlist = [] idxlist=[] messagestring = raw_input ('message please: ') message = list(string.upper(messagestring)) print ' ' def unstray(listinput): for stray in listinput: if stray not in string.uppercase: listinput.remove(stray) def keysequence(alphakey): for letter in range(len(string.uppercase)): for item in range(len(alphakey)): if string.uppercase[letter]==alphakey[item]: seqlist.append(item) def transequence(numberkey): for number in range(len(numberkey)): idxpos = numberkey[number] idxlist.append(idxpos) while idxpos+len(numberkey)<= (len(message)-1): idxpos = idxpos+len(numberkey) idxlist.append(idxpos) def transpose(transkey): for number in range(len(transkey)): transkey[number]=message[transkey[number]] def telegraph(output): for number in range(len(output)): print output[number], def encipher(): unstray(keylist) unstray(message) keysequence(keylist) transequence(seqlist) transpose(idxlist) telegraph(idxlist) encipher() From uncle_wiggly@bigfoot.com Mon Mar 20 18:17:23 2000 From: uncle_wiggly@bigfoot.com (K P) Date: Mon, 20 Mar 2000 13:17:23 -0500 Subject: [Tutor] Embedding Python Message-ID: <200003201819.NAA19249@solaris1.mysolution.com> Greetings, after reading the standard extending/embedding documents, questions are still plagueing me. Please, could someone help. Here is my situation: A small sized c++ class wrapping basic (n)curses functions. Here is a quick view of the header file(if you feel the source file is needed also, please let me know): class screen { private: int myROWS; //max number of rows(lines) on screen int myCOLS; //max number of columns on screen int dispTop; //top boundary int dispBottom; //bottom boundary int dispLeft; //left boundary int dispRight; //right boundary bool hasColours; //not used, yet public: screen(); ~screen(); void clearScreen(); void clearLine(); int getChar(); //used to get keyboard input void update(); //update, or refresh the screen void clearDisplay(); //clears only the display window void moveChar(int row, int col, char c); //moves cursor to row x col and prints c void placeCursor(int row, int col); //position cursor at row x col void movePlayer(int key, int row, int col, me *); //used to move player, check for boundaries, etc. bool checkBoundary(int row, int col); //upon movement, will player collide with boundary(ies)? void addMessage(string); //insert a message into message bar }; This has already been tested with a small c++ program, to verify it works. Simply, it allows me to specific a 'window' on screen in which the player (specified by a character) can move. When a boundary is encountered, a message is printed on screen (via addMessage) telling the player what boundary was 'touched'. Still with me? Now, I want to learn to embed Python in this small program. The purpose is varied: use Python to control the player, create instances of class screen, etc. Finally, my questions: From the docs, it seems I have to create wrapper classes/functions for my class screen. Is this true? Can I rather change the class so it can accept direct python objects(etc) without use of a wrapper function? If a wrapper is necessary, can I make the wrapper as a c++ class, or must it be standard functions? If it seems I am totally off-base with these questions ("Did he actually read the docs? Or is he jsut saying he did?") Please point out my errors. Also, are there good, simple examples of Python embedded in a c++ program. Especially a small program with source I can study. Thank you, Ken From dworkin@ccs.neu.edu Tue Mar 21 03:31:27 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 20 Mar 2000 22:31:27 -0500 Subject: [Tutor] Columnar Transposition Cipher. References: <38D5646F.67E2EA0A@rtpro.net> Message-ID: Tesla Coil writes: > keystring = raw_input ('keyword please: ') I suggest not placing any spaces between a function and the opening parenthesis that follows it. This is a matter of personal taste, however. > seqlist = [] > idxlist=[] You modify these globals within your functions, but you don't really seem to need them as globals. I suggest avoiding globals when you can. > def unstray(listinput): > for stray in listinput: > if stray not in string.uppercase: > listinput.remove(stray) > def keysequence(alphakey): > for letter in range(len(string.uppercase)): > for item in range(len(alphakey)): > if string.uppercase[letter]==alphakey[item]: > seqlist.append(item) You don't comment the code, so it is hard to tell your intent. If this function is intended to provide the column numbers when given the key word, it is incorrect. If the keyword is 'CONVENIENCE', the column numbers should be: [1, 10, 7, 11, 3, 8, 6, 4, 9, 2, 5] Your function provides: [0, 9, 4, 7, 10, 6, 2, 5, 8, 1, 3] If you increment by 1 to match the example, it is still not correct: [1, 10, 5, 8, 11, 7, 3, 6, 9, 2, 4] A simpler keyword to test on would be 'ZAB'. Your function places 'Z' before 'A' in the column numbers of that string. Here is a function that provides the correct encoding, and avoids the global variable: def keysequence(alphakey): # given an all-uppercase keyword, generate column key numbers values = {} seqlist = [] nextvalue = 1 # this could be 0, but 1 matches the description given indices = range(len(alphakey)) for letter in string.uppercase: # assign values first by alpha order for i in indices: # then by position in the keyword if letter == alphakey[i]: values[i] = nextvalue nextvalue = nextvalue + 1 for i in indices: seqlist.append(values[i]) return seqlist Given more time, I might do this differently, but this is the first thing I thought of that provides correct output. You should be able to use it as a starting point. > def transequence(numberkey): > for number in range(len(numberkey)): > idxpos = numberkey[number] > idxlist.append(idxpos) > while idxpos+len(numberkey)<= (len(message)-1): > idxpos = idxpos+len(numberkey) > idxlist.append(idxpos) This function has invalid syntax (the 'while' is indented for no apparent reason) which makes it even harder to figure out. Like the above function, it also uses a global variable to store its result. Here is a function that will break up a message into rows: def message_to_rows(message, rowlength): # given an all-uppercase message, break it up into rows msglength = len(message) rows = [] index = 0 while index < msglength: next_index = index+rowlength rows.append(message[index:next_index]) index = next_index return rows I might as well complete it, since the work has been done. To pull a column out of the rows is simple enough. I would have done it slightly shorter with a map and a lambda, but those can sometimes confuse people. def one_column(rows, index): # given a list of rows and an index, pick out the corresponding column index = index - 1 # to cater to the 1-based example given result = [] for row in rows: if len(row) > index: result.append(row[index]) return string.join(result, '') Then, given the numeric encoding of your key and the set of rows, you simply pull out the columns in order: def transpose(rows, column_ids): # given a list of rows, produce the list of columns, # ordered by key number values_by_id = {} columns = [] for i in column_ids: columns.append(one_column(rows, i)) return columns Your two wrapper functions would then look like this: def telegraph(columns): for col in columns: print col, def encipher(message, key): telegraph(transpose(message_to_rows(message, len(key)), keysequence(key))) You can then test these out like so: >>> encipher('ABCDEFGHIJK', 'ZAB') CFI ADGJ BEHK People can easily point out the shortcomings in my Python style, for I have not yet become truly Pythonic. For instance, my first though is still to use a comment instead of a docstring at the start of a function. Now you should write the decoder! -Justin From tescoil@rtpro.net Tue Mar 21 17:53:43 2000 From: tescoil@rtpro.net (Tesla Coil) Date: Tue, 21 Mar 2000 11:53:43 -0600 Subject: [Tutor] Columnar Transposition Cipher. References: <38D5646F.67E2EA0A@rtpro.net> Message-ID: <38D7B727.6B6684DA@rtpro.net> 20 Mar 2000, Justin Sheehy wrote: > You don't comment the code, so it is hard to tell your intent. > If this function is intended to provide the column numbers > when given the key word, it is incorrect. If the keyword is > 'CONVENIENCE', the column numbers should be: > > [1, 10, 7, 11, 3, 8, 6, 4, 9, 2, 5] > > Your function provides: > > [0, 9, 4, 7, 10, 6, 2, 5, 8, 1, 3] The two lists express the same thing from different angles. pencilkey=[1, 10, 7, 11, 3, 8, 6, 4, 9, 2, 5] indexkey=[0, 9, 4, 7, 10, 6, 2, 5, 8, 1, 3] for n in range(len(indexkey)): print pencilkey[indexkey[n]], Will return: 1 2 3 4 5 6 7 8 9 10 11 The indexkey can be iterated through directly and spares search through a pencilkey. Strangely, the word 'PYTHON' has the same sequence either way: [3, 5, 4, 0, 2, 1]. >> def transequence(numberkey): >> for number in range(len(numberkey)): >> idxpos = numberkey[number] >> idxlist.append(idxpos) >> while idxpos+len(numberkey)<= (len(message)-1): >> idxpos = idxpos+len(numberkey) >> idxlist.append(idxpos) > > This function has invalid syntax (the 'while' is indented for no > apparent reason) which makes it even harder to figure out. > Like the above function, it also uses a global variable to store > its result. The entire 'while' block inadvertently got an extra tab in copying to email. That function was an embarrassing kludge anyhow. Haven't eliminated storage in global variables yet, and the telegraph function still doesn't output in telegraphic standard (five letter groups), but... #coltrans.py - Columnar Transposition Cipher import string keystring = raw_input('keyword please: ') keylist = list(string.upper(keystring)) seqlist = [] idxlist = [] messagestring = raw_input('message please: ') messagelist = list(string.upper(messagestring)) print ' ' def unstray(listinput): for stray in listinput: if stray not in string.uppercase: listinput.remove(stray) def keysequence(alphakey): for letter in range(len(string.uppercase)): for item in range(len(alphakey)): if string.uppercase[letter] == alphakey[item]: seqlist.append(item) def transpose(keyseq, message): for number in range(len(keyseq)): for letter in range(keyseq[number], len(message), len(keyseq)): idxlist.append(message[letter]) def telegraph(result): for number in range(len(result)): print result[number], def encipher(): unstray(keylist) unstray(messagelist) keysequence(keylist) transpose(seqlist, messagelist) telegraph(idxlist) encipher() > Now you should write the decoder! Yeah, that too... From rbl@hal.cwru.edu Tue Mar 21 22:02:00 2000 From: rbl@hal.cwru.edu (Robin B. Lake) Date: Tue, 21 Mar 2000 17:02:00 -0500 (EST) Subject: [Tutor] "Indenting" Message-ID: <200003212202.RAA08891@hal.epbi.cwru.edu> I've RTFM'ed and searched in three Python books (Internet, Learning, Essential Reference) --- and only found the issue of indenting mentioned in passing. What DOES constitute an "indent"? I know from Essential Reference (pg 13) that a Tab gets set every 8 spaces within Python, but does a single space constitute an "indent"? I was surprised not to find the answer by Search at www.python.org. Thanks, Rob Lake rbl@hal.cwru.edu From deirdre@deirdre.net Tue Mar 21 22:00:57 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Tue, 21 Mar 2000 14:00:57 -0800 (PST) Subject: [Tutor] "Indenting" In-Reply-To: <200003212202.RAA08891@hal.epbi.cwru.edu> Message-ID: On Tue, 21 Mar 2000, Robin B. Lake wrote: > I've RTFM'ed and searched in three Python books (Internet, Learning, > Essential Reference) --- and only found the issue of indenting mentioned > in passing. What DOES constitute an "indent"? I know from Essential > Reference (pg 13) that a Tab gets set every 8 spaces within Python, > but does a single space constitute an "indent"? Either a tab or a space (actually, I think it's up to three spaces) is an indent. I personally prefer a single space indent. Mixing tabs and spaces will, with newer versions, give a syntax error, mostly because it can make things appear to be more or less indented depnding on the tab settings. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "In /dev/null, no one can hear you scream" From rbl@hal.cwru.edu Tue Mar 21 22:06:27 2000 From: rbl@hal.cwru.edu (Robin B. Lake) Date: Tue, 21 Mar 2000 17:06:27 -0500 (EST) Subject: [Tutor] Need some concepts re reading in lines of data Message-ID: <200003212206.RAA08920@hal.epbi.cwru.edu> The following code (spaces, not tabs) does not print out the "line" data: # Read the input file into a list of line-strings: for line in fp.readlines(): print line # Get the line-per-string into a list of words: if len(line) != 0: words = string.split(line) # line is a string; words is a list of strings print "words=", words but DOES print out the words data. What subtle aspect of Python have I missed, please? Thanks, Rob Lake rbl@hal.cwru.edu From dworkin@ccs.neu.edu Tue Mar 21 23:43:38 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 21 Mar 2000 18:43:38 -0500 Subject: [Tutor] "Indenting" In-Reply-To: "Robin B. Lake"'s message of "Tue, 21 Mar 2000 17:02:00 -0500 (EST)" References: <200003212202.RAA08891@hal.epbi.cwru.edu> Message-ID: "Robin B. Lake" writes: > does a single space constitute an "indent"? Yes. An increase in indentation level is an indent. The level of increase is not important, but all code at one level must have the same amount of indentation. A tab is equivalent to 8 spaces for these purposes. I tend to use 4-space indents. Do not mix spaces and tabs. -Justin From dworkin@ccs.neu.edu Tue Mar 21 23:44:27 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 21 Mar 2000 18:44:27 -0500 Subject: [Tutor] "Indenting" In-Reply-To: Deirdre Saoirse's message of "Tue, 21 Mar 2000 14:00:57 -0800 (PST)" References: Message-ID: Deirdre Saoirse writes: > Either a tab or a space (actually, I think it's up to three spaces) is an > indent. I personally prefer a single space indent. It can certainly be more than three spaces. Most people use more, in fact. -Justin From deirdre@deirdre.net Tue Mar 21 23:43:01 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Tue, 21 Mar 2000 15:43:01 -0800 (PST) Subject: [Tutor] "Indenting" In-Reply-To: Message-ID: On 21 Mar 2000, Justin Sheehy wrote: > Deirdre Saoirse writes: > > > Either a tab or a space (actually, I think it's up to three spaces) is an > > indent. I personally prefer a single space indent. > > It can certainly be more than three spaces. Most people use more, in fact. Ah, OK. For anything more than a single space I use a tab (tab being the convention at work; a space being my personal pref). That way, others can view it as they choose. :) -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "In /dev/null, no one can hear you scream" From dworkin@ccs.neu.edu Tue Mar 21 23:52:39 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 21 Mar 2000 18:52:39 -0500 Subject: [Tutor] "Indenting" In-Reply-To: Deirdre Saoirse's message of "Tue, 21 Mar 2000 15:43:01 -0800 (PST)" References: Message-ID: Deirdre Saoirse writes: > Ah, OK. For anything more than a single space I use a tab (tab being the > convention at work; a space being my personal pref). That way, others can > view it as they choose. :) I use four spaces per indent. That way others see what was written. -Justin From cko@chyden.net Wed Mar 22 01:35:23 2000 From: cko@chyden.net (Charles Evans) Date: Tue, 21 Mar 2000 20:35:23 -0500 Subject: [Tutor] Python 1.5.2 on iBook running Mac OS 9 Message-ID: <38D8235A.4BD9857@chyden.net> Long ago, on an older Mac, I puttered around with Programming Python with moderate success, and was able to get Tkinter examples to run. Today, I installed Python 1.5.2 on my iBook, running Mac OS 9, and when I try to import Tkinter, I get an error code indicating that no such module exists. I installed Tkinter, and verified that it is in Lib/lib-tkinter. Am I doing something wrong, or has anyone encountered problems with OS 9 and Python 1.5.2? C.Evans From Moshe Zadka Wed Mar 22 06:04:11 2000 From: Moshe Zadka (Moshe Zadka) Date: Wed, 22 Mar 2000 08:04:11 +0200 (IST) Subject: [Tutor] "Indenting" In-Reply-To: <200003212202.RAA08891@hal.epbi.cwru.edu> Message-ID: On Tue, 21 Mar 2000, Robin B. Lake wrote: > I've RTFM'ed and searched in three Python books (Internet, Learning, > Essential Reference) --- and only found the issue of indenting mentioned > in passing. What DOES constitute an "indent"? I know from Essential > Reference (pg 13) that a Tab gets set every 8 spaces within Python, > but does a single space constitute an "indent"? An "indentation" of a line is simply the number of initial spaces, after the usual tab->8 aligned spaces conversion is performed. For formal parsing rules for Python, have a look at the Python Reference Manual, from the documentation. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From hvrosen@hotmail.com Wed Mar 22 09:50:17 2000 From: hvrosen@hotmail.com (Henning von Rosen) Date: Wed, 22 Mar 2000 01:50:17 PST Subject: [Tutor] (no subject) Message-ID: <20000322095017.16587.qmail@hotmail.com> I am learing Python on my own. I am a CS first year student, interested in OO, good habits of development, CS principles and their application. What help can I get from "tutor"? How does tutor work? ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From alan.gauld@bt.com Wed Mar 22 17:41:58 2000 From: alan.gauld@bt.com (Gauld,AJ,Alan,NEL1A GAULDAJ R) Date: Wed, 22 Mar 2000 17:41:58 -0000 Subject: [Tutor] (no subject) Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF610C@mbtlipnt02.btlabs.bt.co.uk> > I am learing Python on my own. > I am a CS first year student, interested in OO, good habits > of development, CS principles and their application. Good background, you should have few problems. > What help can I get from "tutor"? Ask speific questions and get specific answers! When asking try to include the actual error messages and code snippets. > How does tutor work? People ask questions, other people answer. By reading all the questions and all the answers you learn. When your stuck ask your own questions. Pretty easy. Alan g. From spirou@carolo.net Thu Mar 23 11:09:18 2000 From: spirou@carolo.net (Denis =?iso-8859-1?Q?Fr=E8re?=) Date: Thu, 23 Mar 2000 11:09:18 +0000 Subject: [Tutor] Re: Need some concepts re reading in lines of data References: <200003212206.RAA08920@hal.epbi.cwru.edu> Message-ID: <38D9FB5E.E39660F@carolo.net> "Robin B. Lake" wrote: > > The following code (spaces, not tabs) does not print out the "line" > data: > > # Read the input file into a list of line-strings: > for line in fp.readlines(): > print line > # Get the line-per-string into a list of words: > if len(line) != 0: > words = string.split(line) # line is a string; words is a list of strings > print "words=", words > > but DOES print out the words data. > > What subtle aspect of Python have I missed, please? I tried your code in a small "testread.py" (I simply added a hrule to get a clearer output) : it works just fine with Python 1.5.2 and Debian GNU/Linux. I join the file and its output beneath. Don't see why it wouldn't work for you. (Which OS, which version, ... ?) Did you sing the Great Python Incantations ? ;-) -----------------testread.py----------------------------- #! /usr/bin/python import os, string mydir = """/home/spirou/src/python""" myfile = "testread.py" hrule = '=' * 70 fp = open(os.path.join(mydir, myfile), 'r') for line in fp.readlines(): print line # Get the line-per-string into a list of words: if len(line) != 0: words = string.split(line) # line is a string; words is a list of strings print "words=", words print hrule -----------------testread's output------------------------ #! /usr/bin/python words= ['#!', '/usr/bin/python'] ====================================================================== words= [] ====================================================================== import os, string words= ['import', 'os,', 'string'] ====================================================================== mydir = """/home/spirou/src/python""" words= ['mydir', '=', '"""/home/spirou/src/python"""'] ====================================================================== myfile = "testread.py" words= ['myfile', '=', '"testread.py"'] ====================================================================== hrule = '=' * 70 words= ['hrule', '=', "'='", '*', '70'] ====================================================================== words= [] ====================================================================== fp = open(os.path.join(mydir, myfile), 'r') words= ['fp', '=', 'open(os.path.join(mydir,', 'myfile),', "'r')"] ====================================================================== words= [] ====================================================================== for line in fp.readlines(): words= ['for', 'line', 'in', 'fp.readlines():'] ====================================================================== print line words= ['print', 'line'] ====================================================================== # Get the line-per-string into a list of words: words= ['#', 'Get', 'the', 'line-per-string', 'into', 'a', 'list', 'of', 'words:'] ====================================================================== if len(line) != 0: words= ['if', 'len(line)', '!=', '0:'] ====================================================================== words = string.split(line) words= ['words', '=', 'string.split(line)'] ====================================================================== # line is a string; words is a list of strings words= ['#', 'line', 'is', 'a', 'string;', 'words', 'is', 'a', 'list', 'of', 'strings'] ====================================================================== print "words=", words words= ['print', '"words=",', 'words'] ====================================================================== print hrule words= ['print', 'hrule'] ====================================================================== -- Denis Frère COLnet : Internet - Intranets - Réseaux - Formations P3B : Club Free-Pytho-Linuxien Carolorégien http://www.carolo.net From jesus@hacha.telecaqueta.com.co Thu Mar 23 15:58:03 2000 From: jesus@hacha.telecaqueta.com.co (Familia Ramírez Cataño -=CARC X=-) Date: Thu, 23 Mar 2000 15:58:03 GMT Subject: [Tutor] (no subject) Message-ID: <200003231556.KAA03278@telecaqueta.com.co> Hi! I'm new using Python, I know some C programming... but I want to learn Python. I think it's cool, I tried some stuff, but i don't know how to compile it... Will you help me telling me how to make the .exe files? Thanks, carcx@hotmail.com From bthomas@hirevelocity.com Thu Mar 23 16:17:53 2000 From: bthomas@hirevelocity.com (Bill Thomas) Date: Thu, 23 Mar 2000 11:17:53 -0500 Subject: [Tutor] Quick Question Message-ID: <009c01bf94e3$57282900$c71aa4d8@atw.pa.cable.rcn.com> Thursday, 3/23/00 Hi, I got your name from the SF Web Firmlist. Any Idea where the best place is, to find Consultant level Salespeople for a San Fran based Web Sales Company. We've been trying for a while and no luck... Can you help, thanks, Bill Thomas From cwebster@nevada.edu Thu Mar 23 18:51:23 2000 From: cwebster@nevada.edu (Corran Webster) Date: Thu, 23 Mar 2000 10:51:23 -0800 Subject: [Tutor] Python 1.5.2 on iBook running Mac OS 9 In-Reply-To: <38D8235A.4BD9857@chyden.net> Message-ID: This is a question which perhaps belongs in the MacPython SIG - you will certainly be able to find help there on technical mac-related issues like this. At 8:35 PM -0500 21/3/00, Charles Evans wrote: > Long ago, on an older Mac, I puttered around with Programming Python > with moderate success, and was able to get Tkinter examples to run. > > Today, I installed Python 1.5.2 on my iBook, running Mac OS 9, and when > I try to import Tkinter, I get an error code indicating that no such > module exists. > > I installed Tkinter, and verified that it is in Lib/lib-tkinter. > > Am I doing something wrong, or has anyone encountered problems with OS 9 > and Python 1.5.2? Unfortunately, in 1.5.2 the locations that modules are stored in were changed, and in that change the location of _tkinter was omitted from the standard path. To make things work, you need to find _tkinter.ppc.slb (which is, I believe, somewhere in the :Extensions:Imaging folder) and move it to somewhere in your python search path (:Mac:Plugins is the usual location). After you have done this, you will need to make sure that :Lib:lib-tk is in your python path. Run the "EditPythonPrefs" file and add the line $(PYTHON):Lib:lib-tk to the list if it is not already there. This should get you back to the same amount of support for Tk as previous versions of Python for the Mac. Also, you will have to run Tkinter based scripts using the interpreter, rather than the IDE. Regards, Corran From genius@idirect.com Thu Mar 23 20:22:51 2000 From: genius@idirect.com (Snoopy :-))) Date: Thu, 23 Mar 2000 15:22:51 -0500 Subject: [Tutor] (no subject) References: <200003231556.KAA03278@telecaqueta.com.co> Message-ID: <38DA7D1B.42E5EF62@idirect.com> It seems, that you are talking about the win95/98 version. Since you are Posting here you've alrady know about the Python Home page. So go to it after clicking on win95/98 follow the link to Mark Hammond's "Starship Page and get the "win32all" package. This will include everything including Tutorials etc. You don't need to compile anything. Spend a litle time at this Page and you will Know everything very quickly. Best regards Snoopy :-)) "Familia Ramírez Cataño -=CARC X=-" wrote: > > Hi! > I'm new using Python, I know some C programming... but I want to learn Python. I think it's cool, I tried some stuff, but i don't know how to compile it... > Will you help me telling me how to make the .exe files? > > Thanks, > > carcx@hotmail.com > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From deirdre@deirdre.net Thu Mar 23 20:46:46 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 23 Mar 2000 12:46:46 -0800 (PST) Subject: [Tutor] Re: Need some concepts re reading in lines of data In-Reply-To: <38D9FB5E.E39660F@carolo.net> Message-ID: On Thu, 23 Mar 2000, Denis [iso-8859-1] Fr=E8re wrote: > I tried your code in a small "testread.py" (I simply added a hrule to > get a clearer output) : it works just fine with Python 1.5.2 and Debian > GNU/Linux.=20 The problem is the Mac's different end-of-line character (cr only). --=20 _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "In /dev/null, no one can hear you scream" From rc@mlode.com Sat Mar 25 19:12:12 2000 From: rc@mlode.com (Rick Christian) Date: Sat, 25 Mar 2000 11:12:12 -0800 Subject: [Tutor] Playing different animations Message-ID: <000701bf968e$0751ff80$0293a8c0@pavilion> This is a multi-part message in MIME format. ------=_NextPart_000_0004_01BF964A.F81168A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I want to create an object that will run different animations when it = performs different actions, how do I tell it to play different = animations with PlayAnim()? ------=_NextPart_000_0004_01BF964A.F81168A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I want to create an object that will = run=20 different animations when it performs different actions, how do I tell = it to=20 play different animations with PlayAnim()?
------=_NextPart_000_0004_01BF964A.F81168A0-- From ordieth@home.com Sun Mar 26 03:49:49 2000 From: ordieth@home.com (Brian Morud) Date: Sat, 25 Mar 2000 21:49:49 -0600 Subject: [Tutor] Win '98 python Message-ID: <38DD88DD.AC114EA4@home.com> How do I run a script-like text file? I've tried python my_python_script.py but that didn't print out like it was supposed to. Thanks, Ordieth From jcm@bigskytel.com Sun Mar 26 10:29:48 2000 From: jcm@bigskytel.com (David Porter) Date: Sun, 26 Mar 2000 03:29:48 -0700 Subject: [Tutor] Win '98 python In-Reply-To: <38DD88DD.AC114EA4@home.com>; from ordieth@home.com on Sat, Mar 25, 2000 at 09:49:49PM -0600 References: <38DD88DD.AC114EA4@home.com> Message-ID: <20000326032948.A24732@novara.avenue> * Brian Morud : > How do I run a script-like text file? > I've tried python my_python_script.py > but that didn't print out like it was > supposed to. it should... You should also be able to double click the script. When you type python does it start the interpreter (i.e. is python in your path)? It would help if you explain what it does do to give an idea of what might be wrong though. -David From infonuovo@email.com Sun Mar 26 17:03:11 2000 From: infonuovo@email.com (Dennis E. Hamilton) Date: Sun, 26 Mar 2000 09:03:11 -0800 Subject: [Tutor] Win '98 python In-Reply-To: <38DD88DD.AC114EA4@home.com> Message-ID: Brian, That is the way to run a script from a file. Tell us 1. What platform and version you are running on. 2. More about what didn't work. 3. When it ever did work. Or how much works. (you might want to build the script up in parts and confirm the steps along the way for whatever the script does) Also, Try, from the same directory or folder, doing python >>> import my_python_script and see if it does anything differently. -- Dennis -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Brian Morud Sent: Saturday, March 25, 2000 19:50 To: tutor@python.org; tutor@python.org Subject: [Tutor] Win '98 python How do I run a script-like text file? I've tried python my_python_script.py but that didn't print out like it was supposed to. Thanks, Ordieth _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From ordieth@home.com Sun Mar 26 19:48:20 2000 From: ordieth@home.com (Brian Morud) Date: Sun, 26 Mar 2000 13:48:20 -0600 Subject: [Tutor] Win '98 python References: Message-ID: <38DE6983.3F135CC0@home.com> Sorry for not including enough details. It's a really short, easy script, written as a text file, saved with a .py extension. The script is: import string phrase = "some phrase here" i = 0 while ( i < 100 ) print phrase,i i = i + 1 That's it. When I am in the python directory, which is also where the script is located, I type "python my_python.py" and nothing gets printed out. I've tried it with both "print phrase,i" and "printf("%s %s" %(phrase,i))" but when I run it from the MSDOS promtp, nothing prints out, ever. Thanks for taking a look at this. Brian "Dennis E. Hamilton" wrote: > > Brian, > > That is the way to run a script from a file. > > Tell us > > 1. What platform and version you are running on. > 2. More about what didn't work. > 3. When it ever did work. Or how much works. > (you might want to build the script up > in parts and confirm the steps along the > way for whatever the script does) > > Also, > Try, from the same directory or folder, doing > > python > >>> import my_python_script > > and see if it does anything differently. > > -- Dennis > > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > Brian Morud > Sent: Saturday, March 25, 2000 19:50 > To: tutor@python.org; tutor@python.org > Subject: [Tutor] Win '98 python > > How do I run a script-like text file? > I've tried python my_python_script.py > but that didn't print out like it was > supposed to. > > Thanks, > Ordieth > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From Tim Condit Sun Mar 26 20:11:07 2000 From: Tim Condit (Tim Condit) Date: Sun, 26 Mar 2000 20:11:07 +0000 (GMT) Subject: [Tutor] input processing question Message-ID: Hello, I am having some trouble figuring out how to do something simple in a few steps: + open a file for reading + find the number of lines in the file, to use in a loop + process the lines As an example, I want to find out user information at work, and to do this, I want to get usernames from /etc/passwd -- it's the first field. I'm using Python 1.5.1 on Solaris. The first thing that I got hung up on was this: >>> f = open('/etc/passwd', 'r') >>> len(f.readlines()) 864 >>> len(f.readlines()) 0 Okay, I realize that I'm trying to read the same file twice. How can I get the number of lines in the file _without_ reading it? Is there a better approach? But that is kind of an aside. I'm really wondering about the tasks listed above. I have tried several different approaches, with an amazing consistency. Not a single thing I've tried has worked. :) I have deleted and redefined f each time, by the way. >>> import string >>> f = open('/etc/passwd', 'r') >>> for i in f.readline(): ... string.split(i, ':') ... ['r'] ['o'] ['o'] ['t'] ['', ''] Again, one line, and I'm splitting the output at the character level rather than at the field separator. Actually, it appears to be doing something funny at the field separator too, but I'm at a loss. What am I doing wrong here? By this point I'm feeling amused (because otherwise I'd be getting frustrated.) I've tried a few other approaches, that also didn't work. Any help would be appreciated. TIA, Tim From deirdre@deirdre.net Sun Mar 26 20:59:58 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sun, 26 Mar 2000 12:59:58 -0800 (PST) Subject: [Tutor] input processing question In-Reply-To: Message-ID: On Sun, 26 Mar 2000, Tim Condit wrote: > + open a file for reading This you've gotten. > + find the number of lines in the file, to use in a loop You don't need to know actually. For a way around this: lines = f.readlines() for i in lines: print i > + process the lines > Okay, I realize that I'm trying to read the same file twice. How can I get > the number of lines in the file _without_ reading it? Is there a better > approach? No, you need to read the contents of a file to know what's in the file. :) -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "The year after I was born, we walked on the moon. Now, 31 years later, it's considered an impressive feat of science to grow tomatoes in low Earth orbit." -- John Miles From andre@beta.telenordia.se Sun Mar 26 23:31:18 2000 From: andre@beta.telenordia.se (=?ISO-8859-1?Q?Andr=E9_Dahlqvist?=) Date: Mon, 27 Mar 2000 01:31:18 +0200 (CEST) Subject: [Tutor] Re: [python-studies] input processing question In-Reply-To: Message-ID: Hi Tim >>> import string >>> f =3D open('/etc/passwd', 'r') >>> for i in f.readline(): =2E.. string.split(i, ':') =2E..=20 >['r'] >['o'] >['o'] >['t'] I think I know what happens here. readline() returns a string, which is one type of sequence. All sequences consists of elements, and a strings elements are characters. When you iterate over this string using a for loop, 'i' will be assigned each character (element) of the string=20 (sequence). And if you try to split the varialbe 'i', which only contains one character, it will return a list containing that character: string.split('r') ['r'] Using readlines() instead of readline() seams to do the trick: import string f.open('/etc/passwd') for line in f.readlines(): =09wordList =3D string.split(line, ':') =09print wordList[0] I'm not sure this is the best approach, but it works. // Andr=E9 From andre@beta.telenordia.se Sun Mar 26 23:55:57 2000 From: andre@beta.telenordia.se (=?ISO-8859-1?Q?Andr=E9_Dahlqvist?=) Date: Mon, 27 Mar 2000 01:55:57 +0200 (CEST) Subject: [Tutor] Win '98 python In-Reply-To: <38DE6983.3F135CC0@home.com> Message-ID: >while ( i < 100 ) >=09print phrase,i >=09i =3D i + 1 Common misstake, you left out the ':' in your loop. Also, in Python you don't need to use parenthesis if you don't want to. This works: while i < 100: =09print phrase, i =09i =3D i + 1 // Andr=E9 From ordieth@home.com Sun Mar 26 21:57:05 2000 From: ordieth@home.com (Brian Morud) Date: Sun, 26 Mar 2000 15:57:05 -0600 Subject: [Tutor] Win '98 python References: Message-ID: <38DE87B1.ED0C6648@home.com> Oops. I'm so sorry. I forgot to include them when I was transcribing (I didn't copy and paste). But yes, they're in the script file. What is interesting is that I am able to run my script within python (by typing everything in by hand) but not from the command line. Thanks, Brian André Dahlqvist wrote: > >while ( i < 100 ) > > print phrase,i > > i = i + 1 > > Common misstake, you left out the ':' in your loop. Also, in Python you > don't need to use parenthesis if you don't want to. This works: > > while i < 100: > print phrase, i > i = i + 1 > > // André From infonuovo@email.com Sun Mar 26 22:03:31 2000 From: infonuovo@email.com (Dennis E. Hamilton) Date: Sun, 26 Mar 2000 14:03:31 -0800 Subject: [Tutor] Win '98 python In-Reply-To: <38DE6983.3F135CC0@home.com> Message-ID: OK, I see I overlooked the notorious missing colon. But there are other things going on. Let's take it apart. 1. I pasted your text literally into an empty text file. There appeared to be a stray indented line after the i=i+1 so I deleted that. Then I saved it in a working directory as my_python.py. 2. Working in the same directory, I did > python my_python.py and I got a syntax error report on the while ( i < 100 ), with a marker below the )-character: File "my_python.py", line 4 while ( i < 100 ) ^ SyntaxError: invalid syntax Ahah! Missing ":" after the while clause. I know that because I've made that mistake before and this is what it looks like. Tip: all Python statements that prefix a statement sequence have a :-character between them and the statement sequence. You'll learn to recognize when you've forgotten that. 3. I made that change to my_python.py and ran it again. This time I got File "my_python.py", line 6 i = i + 1 ^ SyntaxError: invalid syntax which I suppose is progress of a sort. 4. So I did some cleanup on the program that I pasted. I notice that I had the i = i + 1 indented to the right of the print statement's beginning, which accounts for the error in (3). I don't know if your file had the error or not. In any case, I got rid of all leading white space, made sure there was no trailing white space that I didn't know about, then re-indented the while-body using spaces, no tabs. Then I ran it again. This is like a craft thing. Rather than find out I had more indentation problems, I simply did a reset and cleanup all of the indentation so I wouldn't have that to deal with any more. It's an obsessive-compulsive thing. I can't promise that it will ever make any difference. Voila! some phrase here 0 ... some phrase here 99 5. Here's what puzzles me. I don't know why, from the MS-DOS prompt, you didn't get the error messages that I saw in (2), above. It makes me think that the error output from the Python engine is not going to the MS-DOS console on your machine. When python is silent, does it get you back to the MS-DOS prompt? I would try this. Clean up the while statement, supplying the missing ":" and see if the program runs. If python is silent, try > python Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import my_python Because it sure as heck should run from there, with the identical result either way. You didn't say which version you are running. I am running Python 1.5.2 on Windows 98 SE. If you can't get error messages to appear on your display, it is going to be difficult to get very far in Python. Let us know what you discover. -- Dennis -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Brian Morud Sent: Sunday, March 26, 2000 11:48 To: infonuovo@email.com Cc: Python-tutor Subject: Re: [Tutor] Win '98 python Sorry for not including enough details. It's a really short, easy script, written as a text file, saved with a .py extension. The script is: import string phrase = "some phrase here" i = 0 while ( i < 100 ) print phrase,i i = i + 1 That's it. When I am in the python directory, which is also where the script is located, I type "python my_python.py" and nothing gets printed out. I've tried it with both "print phrase,i" and "printf("%s %s" %(phrase,i))" but when I run it from the MSDOS promtp, nothing prints out, ever. Thanks for taking a look at this. Brian From ordieth@home.com Sun Mar 26 22:24:26 2000 From: ordieth@home.com (Brian Morud) Date: Sun, 26 Mar 2000 16:24:26 -0600 Subject: [Tutor] Win '98 python References: Message-ID: <38DE8E1A.8809F97E@home.com> Thanks to your guys hints, I was able to figure out what the whole problem was, and how I should be able to fix it. :) Firstly, I was confused as to why the script wouldn't run out of the text file, when it ran in the python interpreter. The answer is that I mistranscribed it. I had i < 0 instead of i < 100. Silly me, I feel really sheepish now, baaaaaah. Then, it appears that when I was transcribing it from the file to the email, I added another typo, I forgot the semi-colon. Thank you all for your help. Brian "Dennis E. Hamilton" wrote: > > OK, I see I overlooked the notorious missing colon. > > But there are other things going on. > > Let's take it apart. > > 1. I pasted your text literally into an empty text file. There appeared to > be a stray indented line after the i=i+1 so I deleted that. Then I saved it > in a working directory as my_python.py. > > 2. Working in the same directory, I did > > > python my_python.py > > and I got a syntax error report on the while ( i < 100 ), with a marker > below the )-character: > > File "my_python.py", line 4 > while ( i < 100 ) > ^ > SyntaxError: invalid syntax > > Ahah! Missing ":" after the while clause. I know that because I've made > that mistake before and this is what it looks like. > Tip: all Python statements that prefix a statement sequence have a > :-character between them and the statement sequence. You'll learn to > recognize when you've forgotten that. > > 3. I made that change to my_python.py and ran it again. This time I got > > File "my_python.py", line 6 > i = i + 1 > ^ > SyntaxError: invalid syntax > > which I suppose is progress of a sort. > > 4. So I did some cleanup on the program that I pasted. I notice that I had > the i = i + 1 indented to the right of the print statement's beginning, > which accounts for the error in (3). I don't know if your file had the > error or not. In any case, I got rid of all leading white space, made sure > there was no trailing white space that I didn't know about, then re-indented > the while-body using spaces, no tabs. Then I ran it again. This is like a > craft thing. Rather than find out I had more indentation problems, I simply > did a reset and cleanup all of the indentation so I wouldn't have that to > deal with any more. It's an obsessive-compulsive thing. I can't promise > that it will ever make any difference. > > Voila! > > some phrase here 0 > ... > some phrase here 99 > > 5. Here's what puzzles me. I don't know why, from the MS-DOS prompt, you > didn't get the error messages that I saw in (2), above. It makes me think > that the error output from the Python engine is not going to the MS-DOS > console on your machine. When python is silent, does it get you back to the > MS-DOS prompt? > > I would try this. Clean up the while statement, supplying the missing ":" > and see if the program runs. If python is silent, try > > > python > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import my_python > > Because it sure as heck should run from there, with the identical result > either way. You didn't say which version you are running. I am running > Python 1.5.2 on Windows 98 SE. If you can't get error messages to appear on > your display, it is going to be difficult to get very far in Python. > > Let us know what you discover. > > -- Dennis > > -----Original Message----- > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > Brian Morud > Sent: Sunday, March 26, 2000 11:48 > To: infonuovo@email.com > Cc: Python-tutor > Subject: Re: [Tutor] Win '98 python > > Sorry for not including enough details. It's a really short, easy > script, written as a text file, saved with a .py extension. The script > is: > > import string > phrase = "some phrase here" > i = 0 > while ( i < 100 ) > print phrase,i > i = i + 1 > > That's it. When I am in the python directory, which is also where the > script is located, I type "python my_python.py" and nothing gets printed > out. I've tried it with both "print phrase,i" and "printf("%s %s" > %(phrase,i))" but when I run it from the MSDOS promtp, nothing prints > out, ever. > > Thanks for taking a look at this. > > Brian From rc@mlode.com Sun Mar 26 23:26:05 2000 From: rc@mlode.com (Rick Christian) Date: Sun, 26 Mar 2000 15:26:05 -0800 Subject: [Tutor] Playing Different Animations Message-ID: <001801bf977a$bce82d00$0293a8c0@pavilion> I want to create an object that will run different animations at different times, how do I tell it to play different animations with PlayAnim()? NOTE: I believe I am using a different type of Python language, it's called TsxPython. I think it's meant specially for a program I have, called TrueSpace. From rc@mlode.com Mon Mar 27 00:00:18 2000 From: rc@mlode.com (Rick Christian) Date: Sun, 26 Mar 2000 16:00:18 -0800 Subject: [Tutor] One object looking at another at alll times Message-ID: <000d01bf977f$82b1e2c0$0293a8c0@pavilion> I keep getting an error with the following script: #--------------------------------------------------------------------------- -------------- # This function is called on every time the time ticks changes def ontimechanged(): yrot = target.Position[0] # Variable "yrot" equals Target's x coordinate, view.Direction = (yrot, 0, 0) # Target is the name of another object pass #--------------------------------------------------------------------------- ------------- What I'm trying to do is make one object look at another at all times, do you know how I could do this? NOTE: I am using a version of Python called TsxPython that is meant for a program I have, called TrueSpace. From princeshinji@xoommail.com Mon Mar 27 05:44:43 2000 From: princeshinji@xoommail.com (Walter Hanagriff) Date: Sun, 26 Mar 2000 21:44:43 -0800 Subject: [Tutor] tkinter help 1 Message-ID: <200003270544.VAA32071@www1.xoommail.com> greetings to all i am pretty new to programming, and just started teaching myself python in january when i found out about it, and i am having lots of fun with it First question: how do i install tcl 8.3 and make it work with tkinter on windows 95 i have been reading the python newsgroups and have seen something about a patch to fix it so that tkinter can use tcl8.2, which is just fine but there is no link that i have found pointing to this patch, where is it located? also are there instructions how to use it? if i was misunderstanding about having apatch then how do i fix the install problem Another question: in tkinter how do i load a picture? i have seen people use PhotoImage but how is it done? where is there a good example shown at? or can somebody show me how to add a bmp, jpg, or gif to a button? and if there is a different way to show a gif, jpg and bmp then whats the difference? also i read that you can load a bitmap from an xbm file, which i understand is x-bitmap, but what is that, how do i make a picture of that kind or turn a bitmap into it also what are its benefits or why might i use it? or should i just not worry about using it? ______________________________________________________ Get your free web-based email at http://www.xoom.com Birthday? Anniversary? Send FREE animated greeting cards for any occasion at http://greetings.xoom.com From princeshinji@xoommail.com Mon Mar 27 06:18:10 2000 From: princeshinji@xoommail.com (Walter Hanagriff) Date: Sun, 26 Mar 2000 22:18:10 -0800 Subject: [Tutor] tkinter help 2 Message-ID: <200003270618.WAA24507@www2.xoommail.com> greetings to all: in my program i want the next button to go to a certain frame depending on the value of a radiobutton, here is the code: class Frames: # this function makes the first frame for the program def __init__(self, master): frame = Frame(root, width = 285, height = 400) frame.pack() Label(frame, text = "this program figures the area, perimeter, and power of n \n" "____________________________________________").pack() v = IntVar() Radiobutton(frame, text = "1 = Find the power of a number", variable = v, value = 1).pack(anchor = W) Radiobutton(frame, text = "2 = Find the area of a shape", variable = v, value = 2).pack(anchor = W) Radiobutton(frame, text = "3 = Find the perimeter of a shape", variable = v, value = 3).pack(anchor = W) next = Button(frame, text = "Next", padx = 10, command = ifpick(v)) next.pack(side = LEFT, padx = 5) close = Button(frame, text = "Close", padx = 10, command = root.quit) close.pack(side = LEFT, padx = 5) # this says which frame to open depending on which radiobutton above is picked by user def ifpick(self, v): if v == 1: frame2() elif v == 2: frame3() elif v == 3: frame4() i cant seem to get the value of v in ifpick though, i try many things and get different errors everytime, how do i get the value? and is anything wrong with this code so far? i just started learning tkinter a few weeks ago and still learning the basics ______________________________________________________ Get your free web-based email at http://www.xoom.com Birthday? Anniversary? Send FREE animated greeting cards for any occasion at http://greetings.xoom.com From princeshinji@xoommail.com Mon Mar 27 06:20:50 2000 From: princeshinji@xoommail.com (Walter Hanagriff) Date: Sun, 26 Mar 2000 22:20:50 -0800 Subject: [Tutor] what is foo bar? Message-ID: <200003270620.WAA08833@www1.xoommail.com> greetings to all yet again: the words foo and bar are used so much in examples, why? there is even this example: 'from foo import *' does this do something, i got it from an example of importing a package, and the comment on it was that it was poor style, does foo and bar, or just foo or bar actually do something or just useful as example names of variables, modules and such? ______________________________________________________ Get your free web-based email at http://www.xoom.com Birthday? Anniversary? Send FREE animated greeting cards for any occasion at http://greetings.xoom.com From deirdre@deirdre.net Mon Mar 27 06:46:26 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Sun, 26 Mar 2000 22:46:26 -0800 (PST) Subject: [Tutor] what is foo bar? In-Reply-To: <200003270620.WAA08833@www1.xoommail.com> Message-ID: On Sun, 26 Mar 2000, Walter Hanagriff wrote: > the words foo and bar are used so much in examples, why? Tradition. Just like using x for a variable name or i for a counter. > was that it was poor style, does foo and bar, or just foo or > bar actually do something > or just useful as example names of variables, modules and > such? fubar = "f*cked up beyond all recognition" probably had something to do with splitting it into foo + bar. :) -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "The year after I was born, we walked on the moon. Now, 31 years later, it's considered an impressive feat of science to grow tomatoes in low Earth orbit." -- John Miles From tescoil@rtpro.net Mon Mar 27 15:58:39 2000 From: tescoil@rtpro.net (Tesla Coil) Date: Mon, 27 Mar 2000 09:58:39 -0600 Subject: [Tutor] what is foo bar? References: Message-ID: <38DF852F.84D02821@rtpro.net> 26 Mar 2000, Deirdre Saoirse replied to Walter Hanagriff: >> the words foo and bar are used so much in examples, why? > > Tradition. Just like using x for a variable name or i for a counter. > >> was that it was poor style, does foo and bar, or just foo or >> bar actually do something or just useful as example names >> of variables, modules and such? > > fubar = "f*cked up beyond all recognition" probably had > something to do with splitting it into foo + bar. :) Goes back to the early days of the Tech Model Railroad Club at MIT (http://web.mit.edu/tmrc/www/). "Foo" seems to have come into use first, possibly picked up from frequent appearance in the Smokey Stover comic strip. The acronym FUBAR made "bar" a natural compliment. Other longtime MIT favorites see heavy use in Guy L. Steele's _Common Lisp: The Language_. From deirdre@deirdre.net Mon Mar 27 16:08:23 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 27 Mar 2000 08:08:23 -0800 (PST) Subject: [Tutor] what is foo bar? In-Reply-To: <38DF852F.84D02821@rtpro.net> Message-ID: On Mon, 27 Mar 2000, Tesla Coil wrote: > Goes back to the early days of the Tech Model Railroad Club > at MIT (http://web.mit.edu/tmrc/www/). "Foo" seems to have > come into use first, possibly picked up from frequent appearance > in the Smokey Stover comic strip. The acronym FUBAR made > "bar" a natural compliment. Other longtime MIT favorites see > heavy use in Guy L. Steele's _Common Lisp: The Language_. Fubar was in common use in the military (US anyway) during WW2, so I doubt it originated at MIT. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "The year after I was born, we walked on the moon. Now, 31 years later, it's considered an impressive feat of science to grow tomatoes in low Earth orbit." -- John Miles From infonuovo@email.com Mon Mar 27 19:18:11 2000 From: infonuovo@email.com (Dennis E. Hamilton) Date: Mon, 27 Mar 2000 11:18:11 -0800 Subject: [Tutor] what is foo bar? In-Reply-To: <200003270620.WAA08833@www1.xoommail.com> Message-ID: Great question! I can't remember when I first saw foo and bar used in examples. It was a long time ago. I have this sense that it was quite popular around MIT and maybe even the DEC crowd and in the Multics community. It is typically used in composing file names in code examples about file processing. There is also a potential pun, from the days when connections to files had funny names, like A01, C05, F00 (those are zeroes). It is a mild joke. There is an old US military acronym, FUBAR (other military organizations will have their own versions). In the context of Python it means something like "Friendlied Up Beyond All Recognition". Cf. RTFM. Once you've seen it, it becomes difficult not to use it. The continued use of it is for the same reason that it was used in the first place: "Where can I get some easy, meaningless file names to use in an example?" It's easier than inventing new names. And it is automatic. And there is tacit knowledge of it in the community, like recognizing a recuring character in your favorite series of novels. I'd be amazed if FOO and BAR are *not* mentioned in the Hackers Dictionary. I'm grateful that you asked. It reminds us of how much is taken for granted that, for a neophyte, is not easily distinguished as having material or only incidental importance. With the wonderful international nature of computing today, it is an important challenge for those of us who are already "in the know" to provide clarity and simplicity. -- Dennis ------------------ Dennis E. Hamilton InfoNuovo mailto:infonuovo@email.com tel. +1-206-779-9430 (gsm) fax. +1-425-793-0283 http://www.infonuovo.com -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Walter Hanagriff Sent: Sunday, March 26, 2000 22:21 To: tutor@python.org; tutor@python.org Subject: [Tutor] what is foo bar? greetings to all yet again: the words foo and bar are used so much in examples, why? there is even this example: 'from foo import *' does this do something, i got it from an example of importing a package, and the comment on it was that it was poor style, does foo and bar, or just foo or bar actually do something or just useful as example names of variables, modules and such? ______________________________________________________ Get your free web-based email at http://www.xoom.com Birthday? Anniversary? Send FREE animated greeting cards for any occasion at http://greetings.xoom.com _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From mercury@gystics.com Mon Mar 27 19:41:39 2000 From: mercury@gystics.com (D. Goyette) Date: Mon, 27 Mar 2000 14:41:39 -0500 Subject: [Tutor] what is foo bar? In-Reply-To: Message-ID: <20000327193834.F00E11CDD0@dinsdale.python.org> On 3/27/00 2:18 PM, Dennis E. Hamilton wrote: > I'd be amazed if FOO and BAR are *not* mentioned in the Hackers Dictionary. ...and indeed they are: and -- Don From dyoo@uclink4.berkeley.edu Mon Mar 27 21:54:50 2000 From: dyoo@uclink4.berkeley.edu (Danny Yoo) Date: Mon, 27 Mar 2000 13:54:50 -0800 (PST) Subject: [Tutor] Re: Tutor digest, Vol 1 #273 - 17 msgs In-Reply-To: <20000327160556.7329A1CDC7@dinsdale.python.org> Message-ID: > Sorry for not including enough details. It's a really short, easy > script, written as a text file, saved with a .py extension. The script > is: > > import string > phrase = "some phrase here" > i = 0 > while ( i < 100 ) > print phrase,i > i = i + 1 If your code is verbatim, then you forgot a colon at the end of your while statement: while i < 100: Otherwise, everything else looks good. From sabertooth1979@email.com Tue Mar 28 12:20:03 2000 From: sabertooth1979@email.com (robby sunata) Date: Tue, 28 Mar 2000 07:20:03 -0500 (EST) Subject: [Tutor] advice about hacker, for beginner Message-ID: <384873530.954246003707.JavaMail.root@web11.mail.com> would you like to teach me? i want to be a good hacker,please inform me about anything relate to the thing. thanks ----------------------------------------------- FREE! The World's Best Email Address @email.com Reserve your name now at http://www.email.com From dworkin@ccs.neu.edu Tue Mar 28 17:35:50 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 28 Mar 2000 12:35:50 -0500 Subject: [Tutor] One object looking at another at alll times In-Reply-To: rc@mlode.com's message of "Sun, 26 Mar 2000 16:00:18 -0800" References: <000d01bf977f$82b1e2c0$0293a8c0@pavilion> Message-ID: rc@mlode.com (Rick Christian) writes: > I keep getting an error with the following script: I suggest posting the error message here. That would make diagnosis a lot easier. > def ontimechanged(): > yrot = target.Position[0] # Variable "yrot" equals Target's x > view.Direction = (yrot, 0, 0) # Target is the name of another object > pass Are "target" and "view" globals? You can probably leave out the "pass" here. -Justin From tourinho@descartes.ucpel.tche.br Tue Mar 28 17:52:29 2000 From: tourinho@descartes.ucpel.tche.br (Gustavo Passos Tourinho) Date: Tue, 28 Mar 2000 14:52:29 -0300 (EST) Subject: [Tutor] Some help with classes Message-ID: Hi all! I would like to know a way to encapusated a method that belows to a especific class. Something like it(ig in C++): class number { private: int n; public: void attribut (void) ...(continue) } My question is: How can I do something like 'private' in python? There a way? Thanks for any help, Gustavo Tourinho From arcege@shore.net Tue Mar 28 18:34:58 2000 From: arcege@shore.net (Michael P. Reilly) Date: Tue, 28 Mar 2000 13:34:58 -0500 (EST) Subject: [Tutor] Some help with classes In-Reply-To: from "Gustavo Passos Tourinho" at Mar 28, 2000 02:52:29 PM Message-ID: <200003281834.NAA08431@northshore.shore.net> > Hi all! > I would like to know a way to encapusated a method that belows to a > especific class. > Something like it(ig in C++): > class number > { > private: > int n; > public: > void attribut (void) > ...(continue) > } > > My question is: How can I do something like 'private' in python? There a > way? You cannot get 'private' attributes (variables and methods) in Python, but there are two conventions: 1) Attributes preceeded with a single underscore, eg. "_n", are to be viewed as internal variables, not to be used externally. In C++, these are more like 'protected', since that name is still accessible to subclasses. class Number: def __init__(self, value): self._n = value def __repr__(self): return '%s(%s)' % (self.__class__.__name, self._n) def add(self, value): self._n = self._n + value def IncrNum(Number): def incr(self): self._n = self._n + 1 2) Attributes starting with two underschores, eg. "__n" are renamed when byte-compiled to "_CLASS__VARNAME". Since the class's name is used as part of the variable name, the variable "__n" in a subclass would not be the same as in the superclass. This is probably the closest to 'private' as you will get. class Number: def __init__(self, value): self.__n = value def add(self, value): self.__n = self.__n + value def IncrNum(Number): def p_incr(self): self.__n = self.__n + 1 def incr(self): self.add(1) Calling IncrNum(3).p_incr() would raise an AttributeError accessing the non-existant attribute "_IncrNum__n". But calling "incr" would work with both examples. I could also still access IncrNum(3)._Number__n with no errors (though this would be bad style). Remember that nothing in Python is "private" (unless it is hidden within a C extension type, but that's C :). -Arcege References: 1. Python Tutorial, 9.6 Private Variables, http://www.python.org/doc/current/tut/node11.html 2. Python Reference Manual, 2.3.2 Reserved classes of identifiers, http://www.python.org/doc/current/ref/id-classes.html -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From rbl@hal.cwru.edu Tue Mar 28 19:09:55 2000 From: rbl@hal.cwru.edu (Robin B. Lake) Date: Tue, 28 Mar 2000 14:09:55 -0500 (EST) Subject: [Tutor] Monitoring what a Web browser sends out Message-ID: <200003281909.OAA10265@hal.epbi.cwru.edu> The situation is that I'm trying to script Python to download a large number of Web pages from an on-line government database. I can get the HTTP source for the page that controls the selection of the pages to be presented next in the browser, but I don't know of a way to actually see what gets sent "up" to the government site from the browser once I click on "Submit". I'm on a Mac G3, OS 8.6. Any tools to "watch" the uplink out there? Thanks, Rob Lake rbl@hal.cwru.edu From Moshe Zadka Tue Mar 28 22:55:33 2000 From: Moshe Zadka (Moshe Zadka) Date: Wed, 29 Mar 2000 00:55:33 +0200 (IST) Subject: [Tutor] Monitoring what a Web browser sends out In-Reply-To: <200003281909.OAA10265@hal.epbi.cwru.edu> Message-ID: On Tue, 28 Mar 2000, Robin B. Lake wrote: > The situation is that I'm trying to script Python to download > a large number of Web pages from an on-line government database. > I can get the HTTP source for the page that controls the selection > of the pages to be presented next in the browser, but I don't know > of a way to actually see what gets sent "up" to the government site > from the browser once I click on "Submit". I'm on a Mac G3, OS 8.6. > > Any tools to "watch" the uplink out there? Why not use a proxy? I'm not sure on any for MacOS, though. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From jcm@bigskytel.com Mon Mar 27 20:32:39 2000 From: jcm@bigskytel.com (David Porter) Date: Mon, 27 Mar 2000 13:32:39 -0700 Subject: [Tutor] advice about hacker, for beginner In-Reply-To: <384873530.954246003707.JavaMail.root@web11.mail.com>; from sabertooth1979@email.com on Tue, Mar 28, 2000 at 07:20:03AM -0500 References: <384873530.954246003707.JavaMail.root@web11.mail.com> Message-ID: <20000327133239.A9796@bigskytel.com> * robby sunata : > i want to be a good hacker,please inform me about anything relate to the > thing. You might want to read this to orient yourself: http://www.tuxedo.org/~esr/faqs/hacker-howto.html /David From guyfriend32@hotmail.com Wed Mar 29 10:56:55 2000 From: guyfriend32@hotmail.com (Guy Friend32) Date: Wed, 29 Mar 2000 02:56:55 PST Subject: [Tutor] 'continue' inside a 'try' Message-ID: <20000329105655.62923.qmail@hotmail.com> Hi- I'm new to exceptions in Python, and I am stuck because I want a continue inside a try statement. I read FAQ 6.28 that says this is broken. Does anyone have a work-around for this? The only thing I could do is a "special" exception: ...some loop... try: raise 'continue' print "skip this" except 'continue': # do my continue continue except: # for all "real" errors pass Thank you very much! -Guy ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From curtis.larsen@Covance.Com Wed Mar 29 15:09:08 2000 From: curtis.larsen@Covance.Com (Curtis Larsen) Date: Wed, 29 Mar 2000 09:09:08 -0600 Subject: [Tutor] HTML --> TXT? Message-ID: Is there a fairly simple Python-ish way to convert an HTML file to text? I'm not even talking about reformatting the text (where applicable) based on the tags -- though that'd be pretty cool -- I'm just looking for a good way to rip out the tags and make the file more human-friendly. HTMLLIB and URLLIB don't seem to have it -- is there another module that does this? Thanks! Curtis begin 644 TEXT.htm M/"%$3T-465!%($A434P@4%5"3$E#("(M+R]7,T,O+T141"!(5$U,(#0N,"!4 M7!E/@T*/$U%5$$@8V]N=&5N=#TB35-(5$U,(#4N,#`N,CDQ M.2XV,S`W(B!N86UE/4=%3D52051/4CX\+TA%040^#0H\0D]$62!B9T-O;&]R M/2-F9F9F9F8@#0IS='EL93TB1D].5#H@,3!P="!!#L@34%21TE.+51/4#H@,G!X(CX-"CQ$258^27,@=&AE2!C;V]L("TM($DG;2!J=7-T M(&QO;VMI;F<@9F]R(&$@9V]O9"!W87D@#0IT;R!R:7`@;W5T('1H92!T86=S M(&%N9"!M86ME('1H92!F:6QE(&UO2XF M;F)S<#L@2%1-3$Q)0B`-"F%N9"!54DQ,24(@9&]N)W0@ TXT? In-Reply-To: "Curtis Larsen"'s message of "Wed, 29 Mar 2000 09:09:08 -0600" References: Message-ID: "Curtis Larsen" writes: > Is there a fairly simple Python-ish way to convert an HTML file to text? Check out the htmllib and formatter modules. The HTMLParser and DumbWriter classes in those respective modules should do what you need. -Justin From deirdre@deirdre.net Wed Mar 29 17:24:59 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 29 Mar 2000 09:24:59 -0800 (PST) Subject: [Tutor] HTML --> TXT? In-Reply-To: Message-ID: On Wed, 29 Mar 2000, Curtis Larsen wrote: > Is there a fairly simple Python-ish way to convert an HTML file to text? > > I'm not even talking about reformatting the text (where applicable) > based on the tags -- though that'd be pretty cool -- I'm just looking > for a good way to rip out the tags and make the file more > human-friendly. HTMLLIB and URLLIB don't seem to have it -- is there > another module that does this? Funny you should ask. I had just done this late last night for my own amusement. :) I picked a very simple way of solving the problem, which may not be an optimal way, but it was good enough for my purposes. #!/usr/bin/python import string def untag(line): true = 1 false = 0 startTag = '<' endTag = '>' copyChar = true result = '' for i in line: if i == startTag: copyChar = false elif i == endTag: copyChar = true elif copyChar == true: result = result + i return result def untaglines(file): result = '' lines = f.readlines() for i in lines: result = result + untag(i) return result if __name__ == '__main__': import sys fname = sys.argv[1] f = open(fname, 'r') result = untaglines(f) print result -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "The year after I was born, we walked on the moon. Now, 31 years later, it's considered an impressive feat of science to grow tomatoes in low Earth orbit." -- John Miles From parkw@better.net Wed Mar 29 18:20:11 2000 From: parkw@better.net (William Park) Date: Wed, 29 Mar 2000 13:20:11 -0500 Subject: [Tutor] HTML --> TXT? In-Reply-To: ; from curtis.larsen@Covance.Com on Wed, Mar 29, 2000 at 09:09:08AM -0600 References: Message-ID: <20000329132011.A1054@better.net> On Wed, Mar 29, 2000 at 09:09:08AM -0600, Curtis Larsen wrote: > Is there a fairly simple Python-ish way to convert an HTML file to text? > > I'm not even talking about reformatting the text (where applicable) > based on the tags -- though that'd be pretty cool -- I'm just looking > for a good way to rip out the tags and make the file more > human-friendly. HTMLLIB and URLLIB don't seem to have it -- is there > another module that does this? If you have Linux, then 'lynx -dump ...' will do it. From python-tutor@teleo.net Wed Mar 29 18:34:31 2000 From: python-tutor@teleo.net (Patrick Phalen) Date: Wed, 29 Mar 2000 10:34:31 -0800 Subject: [Tutor] HTML --> TXT? In-Reply-To: <20000329132011.A1054@better.net> References: <20000329132011.A1054@better.net> Message-ID: <00032910375203.02853@quadra.teleo.net> [William Park, on Wed, 29 Mar 2000] :: If you have Linux, then 'lynx -dump ...' will do it. Did you mean 'If you have Lynx...'? Lynx is available for all Unices (not just Linux), VMS, Win95/98/NT, OS/2 EMX, and DOS. From deirdre@deirdre.net Wed Mar 29 18:42:09 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 29 Mar 2000 10:42:09 -0800 (PST) Subject: [Tutor] HTML --> TXT? In-Reply-To: <20000329132011.A1054@better.net> Message-ID: On Wed, 29 Mar 2000, William Park wrote: > On Wed, Mar 29, 2000 at 09:09:08AM -0600, Curtis Larsen wrote: > > Is there a fairly simple Python-ish way to convert an HTML file to text? > If you have Linux, then 'lynx -dump ...' will do it. There are n ways to skin the cat, but this does not answer the question asked. If someone asks for a way to do it in *python*, given that this is a tutor list, please try and offer a solution in python. Very often, a person is trying to grasp concepts of how to do things in python. Furthermore, they may be trying to do it in platforms that don't have the other tools called for. Since someone else has responded to the issue of lynx and availability on more platforms than Linux, I won't. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "The year after I was born, we walked on the moon. Now, 31 years later, it's considered an impressive feat of science to grow tomatoes in low Earth orbit." -- John Miles From drivel_drool@bigfoot.com Wed Mar 29 19:20:37 2000 From: drivel_drool@bigfoot.com (Charlie Derr) Date: Wed, 29 Mar 2000 14:20:37 -0500 Subject: [Tutor] HTML --> TXT? In-Reply-To: Message-ID: okay then, how about: import os os.system('lynx -dump ... ') (if you have linux of course) heh -- okay, i admit, i'm baiting -- the thing is that i found that info about lynx useful and probably wouldn't have thought of it myself -- i'm not in favor of people being browbeaten into "only" discussing python just my .019999999999... ~c ~ -----Original Message----- ~ From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of ~ Deirdre Saoirse ~ Sent: Wednesday, March 29, 2000 1:42 PM ~ To: William Park ~ Cc: Curtis Larsen; tutor@python.org ~ Subject: Re: [Tutor] HTML --> TXT? ~ ~ ~ On Wed, 29 Mar 2000, William Park wrote: ~ ~ > On Wed, Mar 29, 2000 at 09:09:08AM -0600, Curtis Larsen wrote: ~ > > Is there a fairly simple Python-ish way to convert an HTML ~ file to text? ~ ~ > If you have Linux, then 'lynx -dump ...' will do it. ~ ~ There are n ways to skin the cat, but this does not answer the question ~ asked. ~ ~ If someone asks for a way to do it in *python*, given that this is a tutor ~ list, please try and offer a solution in python. Very often, a person is ~ trying to grasp concepts of how to do things in python. Furthermore, they ~ may be trying to do it in platforms that don't have the other tools called ~ for. ~ ~ Since someone else has responded to the issue of lynx and availability on ~ more platforms than Linux, I won't. ~ ~ -- ~ _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net ~ "The year after I was born, we walked on the moon. Now, 31 years later, ~ it's considered an impressive feat of science to grow tomatoes in low ~ Earth orbit." -- John Miles ~ ~ ~ _______________________________________________ ~ Tutor maillist - Tutor@python.org ~ http://www.python.org/mailman/listinfo/tutor ~ ~ From cwebster@nevada.edu Wed Mar 29 19:10:42 2000 From: cwebster@nevada.edu (Corran Webster) Date: Wed, 29 Mar 2000 11:10:42 -0800 Subject: [Tutor] HTML --> TXT? In-Reply-To: References: "Curtis Larsen"'s message of "Wed, 29 Mar 2000 09:09:08 -0600" Message-ID: At 11:47 AM -0500 29/3/00, Justin Sheehy wrote: > "Curtis Larsen" writes: > > > Is there a fairly simple Python-ish way to convert an HTML file to text? > > Check out the htmllib and formatter modules. The HTMLParser and > DumbWriter classes in those respective modules should do what you need. In particular, the following should do the trick for a basic text-dump to standard output: ---- from htmllib import HTMLParser from formatter import AbstractFormatter, DumbWriter source = open("myfile.html") parser = HTMLParser(AbstractFormatter(DumbWriter())) parser.feed(source.read()) parser.close() ---- 'source' can be replaced by any file-like object (such as the file-like objects returned by urllib.urlopen). For example: ---- from htmllib import HTMLParser from formatter import AbstractFormatter, DumbWriter from urllib import urlopen source = urlopen('http://www.yahoo.com/') parser = HTMLParser(AbstractFormatter(DumbWriter())) parser.feed(source.read()) parser.close() ---- You can also specify an output file for DumbWriter, and adjust the way that lines wrap. More sophisticated behaviour can be achieved by subclassing the Writer and/or Formatter classes from the formatter module; or the HTMLParser class (usually overriding the start_tag, end_tag or do_tag methods for specific tags). See the documentation for details of the interfaces. Regards, Corran From curtis.larsen@Covance.Com Wed Mar 29 19:13:13 2000 From: curtis.larsen@Covance.Com (Curtis Larsen) Date: Wed, 29 Mar 2000 13:13:13 -0600 Subject: [Tutor] HTML --> TXT? Message-ID: Justin - Thanks, but I tried looking at those, but they were about as clear as mud to me. If they really are for translations such as this, would someone please post a more straight-forward example? Deirdre - Thanks for the code -- its very helpful and gives me a starting point. It was what I was originally thought would need to be done, but thought there might be an easier way. Would the "re" module be a good use for something like this, or would it be overkill? Thanks! Curtis >>> Justin Sheehy 03/29/00 10:47AM >>> "Curtis Larsen" writes: > Is there a fairly simple Python-ish way to convert an HTML file to text? Check out the htmllib and formatter modules. The HTMLParser and DumbWriter classes in those respective modules should do what you need. -Justin _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor begin 644 TEXT.htm M/"%$3T-465!%($A434P@4%5"3$E#("(M+R]7,T,O+T141"!(5$U,(#0N,"!4 M7!E/@T*/$U%5$$@8V]N=&5N=#TB35-(5$U,(#4N,#`N,CDQ M.2XV,S`W(B!N86UE/4=%3D52051/4CX\+TA%040^#0H\0D]$62!B9T-O;&]R M/2-F9F9F9F8@#0IS='EL93TB1D].5#H@,3!P="!!#L@34%21TE.+51/4#H@,G!X(CX-"CQ$258^2G5S=&EN("T@5&AA M;FMS+"!B=70@22!T2!W M97)E(&%B;W5T(&%S(&-L96%R(`T*87,@;75D('1O(&UE+CPO1$E6/@T*/$1) M5CY)9B!T:&5Y(')E86QL>2!A&%M<&QE/SPO1$E6/@T*/$1)5CXF;F)S<#L\+T1) M5CX-"CQ$258^#0H\1$E6/D1E:7)D2!T:&]U9VAT)FYB71H;VXM:7-H('=A M>2!T;R!C;VYV97)T(&%N($A434P@#0IF:6QE('1O('1E>'0_/$)2/CQ"4CY# M:&5C:R!O=70@=&AE(&AT;6QL:6(@86YD(&9O6]U(`T*;F5E9"X\0E(^/$)2/BU*=7-T:6X\0E(^/$)2/CQ"4CX\0E(^ M7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]? M7U\\0E(^5'5T;W(@#0IM86EL;&ES="9N8G-P.R`M)FYB71H;VXN;W)G M+VUA:6QM86XO;&ES=&EN9F\O='5T;W(\+T$^/$)2/CPO1$E6/CPO0D]$63X\ (+TA434P^#0I% ` end ----------------------------------------------------- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender, so that Covance can arrange for proper delivery, and then please delete the message from your inbox. Thank you. From parkw@better.net Wed Mar 29 20:30:42 2000 From: parkw@better.net (William Park) Date: Wed, 29 Mar 2000 15:30:42 -0500 Subject: [Tutor] HTML --> TXT? In-Reply-To: ; from deirdre@deirdre.net on Wed, Mar 29, 2000 at 10:42:09AM -0800 References: <20000329132011.A1054@better.net> Message-ID: <20000329153042.A1272@better.net> On Wed, Mar 29, 2000 at 10:42:09AM -0800, Deirdre Saoirse wrote: > On Wed, 29 Mar 2000, William Park wrote: > > > On Wed, Mar 29, 2000 at 09:09:08AM -0600, Curtis Larsen wrote: > > > Is there a fairly simple Python-ish way to convert an HTML file to text? > > > If you have Linux, then 'lynx -dump ...' will do it. > > There are n ways to skin the cat, but this does not answer the question > asked. > > If someone asks for a way to do it in *python*, given that this is a tutor > list, please try and offer a solution in python. Very often, a person is > trying to grasp concepts of how to do things in python. Furthermore, they > may be trying to do it in platforms that don't have the other tools called > for. > > Since someone else has responded to the issue of lynx and availability on > more platforms than Linux, I won't. Dear Deirdre, I usually find that searching for variation on existing solution is good way to learn, especially for beginner. Original message wasn't clear how HTML tags should be removed -- deleting everything between '<' and '>', formating into ASCII text, or what. 'lynx' and 'w3m' are both text-based browser. So, I offered my advice. I shall try get your approval, next time I answer questions posted to this mailing-list. Your friend, William From dworkin@ccs.neu.edu Wed Mar 29 21:40:22 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 29 Mar 2000 16:40:22 -0500 Subject: [Tutor] HTML --> TXT? In-Reply-To: "Curtis Larsen"'s message of "Wed, 29 Mar 2000 13:13:13 -0600" References: Message-ID: "Curtis Larsen" writes: > Justin - Thanks, but I tried looking at those, but they were about > as clear as mud to me. If they really are for translations such as > this, would someone please post a more straight-forward example? import htmllib, formatter p = htmllib.HTMLParser(formatter.AbstractFormatter(formatter.DumbWriter())) f = open('yourfile.html') p.feed(f.read()) That will send the contents of the HTML file, without the markup, to stdout. A very similar question was asked and answered (not by me) on python-list recently. -Justin Return-Path: Delivered-To: tutor@python.org Received: from dci.patni.com (dci.patni.com [199.92.248.1]) by dinsdale.python.org (Postfix) with ESMTP id 518F41CD15 for ; Wed, 29 Mar 2000 04:37:15 -0500 (EST) Received: from pcsbom.patni.com (pcsspz.patni.com [204.165.186.20]) by dci.patni.com (8.8.5/SCO5) with ESMTP id EAA14696 for ; Wed, 29 Mar 2000 04:36:35 -0500 (EST) Received: from sbm5501.patni.com (sbm5501.patni.com [204.165.186.17]) by pcsbom.patni.com (8.8.8/8.8.8) with SMTP id PAA13847 for ; Wed, 29 Mar 2000 15:09:27 +0530 (IST) Date: Wed, 29 Mar 2000 15:06:24 +0530 (IST) From: "CH.Nagaraja Rao" X-Sender: raonagar@sbm5501.patni.com To: tutor@python.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [Tutor] help Sender: tutor-admin@python.org Errors-To: tutor-admin@python.org X-BeenThere: tutor@python.org X-Mailman-Version: 2.0beta1 Precedence: bulk List-Id: Discussion for learning programming with Python Please let me know how to link compile and link a module from VC++ platform.It is giving errors like Py_ParseTuple undecl pam.obj : error LNK2001: unresolved external symbol __imp__Py_BuildValue spam.obj : error LNK2001: unresolved external symbol __imp__PyArg_ParseTuple spam.obj : error LNK2001: unresolved external symbol __imp__Py_InitModule4 Debug/spam.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. regards nagaraj From rc@mlode.com Wed Mar 29 22:25:41 2000 From: rc@mlode.com (Rick Christian) Date: Wed, 29 Mar 2000 14:25:41 -0800 Subject: [Tutor] Re: Re: One object looking at another at all times Message-ID: <000c01bf99cd$b8584040$0293a8c0@pavilion> This is a multi-part message in MIME format. ------=_NextPart_000_0009_01BF998A.A9532BC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Here is the script rewriten: # Tank Turret def ontimechanged(): Target =3D doc.Object("Target") # The Target is a little red cube TankTurret =3D doc.Object("TankTurret") # This line is here for = later use yrot =3D Target.Position[0] me.Direction =3D (0,0,yrot) # End of script Here is the error I get, what does it mean?: SystemErrorNULL result without error in call_object:=20 ------=_NextPart_000_0009_01BF998A.A9532BC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Here is the script rewriten:

# Tank Turret

def = ontimechanged():

    Target =3D doc.Object("Target")    # The Target is a little red cube

    TankTurret =3D doc.Object("TankTurret")    # This line is here for = later use

    yrot =3D Target.Position[0]

    me.Direction =3D (0,0,yrot)

# End of script

 

Here is the error I get, what does it mean?:

SystemErrorNULL result without error in call_object:=20

------=_NextPart_000_0009_01BF998A.A9532BC0-- From SKIBUM2421@aol.com Thu Mar 30 06:04:26 2000 From: SKIBUM2421@aol.com (SKIBUM2421@aol.com) Date: Thu, 30 Mar 2000 01:04:26 EST Subject: [Tutor] (no subject) Message-ID: HOW DO I GET OFF THIS MAILING LIST??????????????????? please let me know.....thanx From princeshinji@xoommail.com Thu Mar 30 07:08:50 2000 From: princeshinji@xoommail.com (Walter Hanagriff) Date: Wed, 29 Mar 2000 23:08:50 -0800 Subject: [Tutor] i am new to Mailing lists Message-ID: <200003300708.XAA32351@www1.xoommail.com> i am new to mailing lists and maybe done something wrong, if i have can i please be told what? i sent in 3 posts in a row because each one was long, and i figured if i put them all as one post they would be too long besides, each had a different subject, the last one about foo bar was answered but the first 2 werent answered at all, were they not seen, is no answer known yet, or as i am writing this for, did i do something wrong? it has been a few days and the response to the foo bar question only took less then a day to get 3 answers to so i figured the other 2 would get an answer by now, should i repost in a few days or what? ______________________________________________________ Get your free web-based email at http://www.xoom.com Birthday? Anniversary? Send FREE animated greeting cards for any occasion at http://greetings.xoom.com From deirdre@deirdre.net Thu Mar 30 07:15:05 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 29 Mar 2000 23:15:05 -0800 (PST) Subject: [Tutor] i am new to Mailing lists In-Reply-To: <200003300708.XAA32351@www1.xoommail.com> Message-ID: On Wed, 29 Mar 2000, Walter Hanagriff wrote: > it has been a few days and the response to the foo bar > question only took less then a day to get 3 answers to so i > figured the other 2 would get an answer by now, should i > repost in a few days or what? Because this is staffed by volunteers, we tend to answer questions that are specific enough for us to give answers to. For example, I don't answer any questions that seem to be Windows-related as I've never owned a Windows machine. As 99% of the "how do I run a script" type of problem seems to come from Windows users, I tend to overlook them personally. I am mostly familiar with Python on Unix and, to some extent, on a Macintosh. Occasionally, questions slip through the cracks. While we try, we certainly don't guarantee answers. You're free to ask again, though perhaps the problem was too little information? -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "The year after I was born, we walked on the moon. Now, 31 years later, it's considered an impressive feat of science to grow tomatoes in low Earth orbit." -- John Miles From dworkin@ccs.neu.edu Thu Mar 30 17:58:59 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 30 Mar 2000 12:58:59 -0500 Subject: [Tutor] (no subject) In-Reply-To: SKIBUM2421@aol.com's message of "Thu, 30 Mar 2000 01:04:26 EST" References: Message-ID: Read the entirely of any message on it, and pay attention to that URL at the bottom. -Justin SKIBUM2421@aol.com writes: > HOW DO I GET OFF THIS MAILING LIST??????????????????? > > > please let me know.....thanx > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From matheusrodrigues@hotmail.com Thu Mar 30 18:49:40 2000 From: matheusrodrigues@hotmail.com (Matheus Rodrigues) Date: Thu, 30 Mar 2000 18:49:40 GMT Subject: [Tutor] Python x ibook Message-ID: <20000330184940.4366.qmail@hotmail.com> Is there anyone here that could tell me what are the Python features that I will not have in a ibook (notebook from apple) ? What are my limits once I try to run Python on this machine ? Thanks Matheus ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From cwebster@nevada.edu Thu Mar 30 19:37:59 2000 From: cwebster@nevada.edu (Corran Webster) Date: Thu, 30 Mar 2000 11:37:59 -0800 Subject: [Tutor] Python x ibook In-Reply-To: <20000330184940.4366.qmail@hotmail.com> Message-ID: At 6:49 PM +0000 30/3/00, Matheus Rodrigues wrote: > Is there anyone here that could tell me what are the Python features that I > will not have in a ibook (notebook from apple) ? > What are my limits once I try to run Python on this machine ? Although I don't have an iBook, Python should run on it in the same manner it would on any other Macintosh. The most noticable differences from the Unix and Windows versions are: * none of the standard POSIX features (pipes, forking, access to command-line interfaces, etc) since the Mac does not have these. * no threading (although this is being worked on) * Tkinter is not as well supported as it could be (although it does work once you tell Python where it is) * Support for C extension modules is patchier because most are written for Unix or Windows. Basically, most pure Python code will work fine on the mac, assuming it has been written in a cross-platform way. Code which assumes the existence of certain features found only on Unix or Windows systems generally won't work without major modification. Precisely details on the differences in the standard distribution can be found in the Python Documentation - if a module or feature is not compatible with the mac, it will say so there. On the other hand, you will have access to much of the underlying Macintosh system, plus a rather nice IDE to play with. The Numerical and Imaging modules also come precompiled with the standard mac distribution. For more technical details, you may want to ask in the MacPython SIG. Regards, Corran From deirdre@deirdre.net Thu Mar 30 19:42:41 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 30 Mar 2000 11:42:41 -0800 (PST) Subject: [Tutor] Python x ibook In-Reply-To: Message-ID: On Thu, 30 Mar 2000, Corran Webster wrote: > At 6:49 PM +0000 30/3/00, Matheus Rodrigues wrote: > > Is there anyone here that could tell me what are the Python features that I > > will not have in a ibook (notebook from apple) ? > > What are my limits once I try to run Python on this machine ? > > Although I don't have an iBook, Python should run on it in the same manner > it would on any other Macintosh. It does. I have an iBook and have Python on it. > The most noticable differences from the Unix and Windows versions are: > * none of the standard POSIX features (pipes, forking, access > to command-line interfaces, etc) since the Mac does not have these. Well, the Mac *does* have forking, but through its process manager and it's simply not the same. Since MacOS X will have it (and MacOS X Server already does), it may not be worth bothering to write. -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "The year after I was born, we walked on the moon. Now, 31 years later, it's considered an impressive feat of science to grow tomatoes in low Earth orbit." -- John Miles From rc@mlode.com Thu Mar 30 19:48:46 2000 From: rc@mlode.com (Rick Christian) Date: Thu, 30 Mar 2000 11:48:46 -0800 Subject: [Tutor] Re: One object looking at another at all times Message-ID: <002e01bf9a80$f6b7df40$0293a8c0@pavilion> This is a multi-part message in MIME format. ------=_NextPart_000_002B_01BF9A3D.E7CB34C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Here is the script rewriten: # Tank Turret def ontimechanged(): Target =3D doc.Object("Target") # The Target is a little red cube TankTurret =3D doc.Object("TankTurret") # This line is here for = later use yrot =3D Target.Position[0] me.Direction =3D (0,0,yrot) # End of script=20 Here is the error I get, what does it mean?: SystemErrorNULL result without error in call_object:=20 ------=_NextPart_000_002B_01BF9A3D.E7CB34C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Here is the script rewriten:

# Tank Turret

def = ontimechanged():

    Target =3D doc.Object("Target")    # The Target is a little red cube

    TankTurret =3D doc.Object("TankTurret")    # This line is here for = later use

    yrot =3D Target.Position[0]

    me.Direction =3D (0,0,yrot)

# End of script=20

 

Here is the error I get, what does it mean?:

SystemErrorNULL result without error in call_object:=20

------=_NextPart_000_002B_01BF9A3D.E7CB34C0-- From christianlean@hotmail.com Thu Mar 30 23:20:53 2000 From: christianlean@hotmail.com (christian lean) Date: Thu, 30 Mar 2000 23:20:53 GMT Subject: [Tutor] Is this code right? Message-ID: <20000330232053.15299.qmail@hotmail.com> I was wondering if this code is right i ran idle's debug on it and no errors came up but i cant seem to use the function when i import the module it is in. The function is meant to create a list of random numbers, im new at this so i dont know if i'm doing something wrong. Any help is greatly apprietiated. I'm running Win 98 and Python 1.5.2. import whrandom def rand_strng(x, y, z): while x > 0: w = randint(y, z) list[x] = w x = x - 1 return x return list ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From arcege@shore.net Thu Mar 30 23:38:44 2000 From: arcege@shore.net (Michael P. Reilly) Date: Thu, 30 Mar 2000 18:38:44 -0500 (EST) Subject: [Tutor] Is this code right? In-Reply-To: <20000330232053.15299.qmail@hotmail.com> from "christian lean" at Mar 30, 2000 11:20:53 PM Message-ID: <200003302338.SAA25635@northshore.shore.net> > I was wondering if this code is right i ran idle's debug on it and no errors > came up but i cant seem to use the function when i import the module it is > in. The function is meant to create a list of random numbers, im new at this > so i dont know if i'm doing something wrong. Any help is greatly > apprietiated. I'm running Win 98 and Python 1.5.2. > > import whrandom > > def rand_strng(x, y, z): > while x > 0: > w = randint(y, z) > list[x] = w > x = x - 1 > return x > return list The "randint" function is in the whrandom function, not this module (or in the __builtin__ module). You will want to either a) change "import whrandom" to "from whrandom import randint"; or b) reference the randint() function expicitly as "w = whrandom.randint(y, z)". Also, you do not define the variable "list" in your function. Unless it is a global variable (of a mutable sequence of at least `x' elements, or a mapping), then you will get an error there. You probably do not want to use the name "list" either since it is the same name as the built-in function. How about: from whrandom import randint def rand_strng(x, y, z): list = [0] * x while x > 0: w = randint(y, z) list[x] = w x = x - 1 return list (I noticed that you have `return x' inside the while loop, before the `return list', I assume that's a mistake and removed it.) Hope this helps, -Arcege PS, the source documentation for whrandom says that you should use randrange instead of randint. No real harm, but randint might be removed in a future release. -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From wesc@alpha.ece.ucsb.edu Thu Mar 30 23:49:18 2000 From: wesc@alpha.ece.ucsb.edu (Wesley J. Chun) Date: Thu, 30 Mar 2000 15:49:18 -0800 (PST) Subject: [Tutor] Is this code right? Message-ID: <200003302349.PAA06586@alpha.ece.ucsb.edu> > From: "christian lean" > Date: Thu, 30 Mar 2000 23:20:53 GMT > > I was wondering if this code is right i ran idle's debug on it and > no errors came up but i cant seem to use the function when i import > the module it is in. The function is meant to create a list of random > numbers, im new at this so i dont know if i'm doing something wrong. > Any help is greatly apprietiated. I'm running Win 98 and Python 1.5.2. > > import whrandom > > def rand_strng(x, y, z): > while x > 0: > w = randint(y, z) > list[x] = w > x = x - 1 > return x > return list syntactically, the code is right, but what are you trying to do? it looks like you are trying to stuff a set of random numbers into a list backwards. there are numerous logical problems with the code though: 1. the biggest problem in your code is the presence of two return statements. 2. the first return (return x) is guaranteed to return a zero when the list is done (you also lost your list)... probably not what you are looking for. 3. the second return will result in a NameError because you are accessing an uninitialized local variable (list). this return statement will be called if x == 0 or x < 0, also something you are probably not shooting for. 4. it is probably not a good idea to use a built-in variable name as the name of a local variable. "list" is the name for the built-in list() function, which you will override if you use it. 5. unless a list called 'list' exists as a global variable, your "list[x] = w" statement will fail because you are changing existing list elements as opposed to creating a new list and adding elements to it. 6. you are not calling randint() correctly. you need to either bring it into your namespace to call it directly (use from- import), or give the full attribute name (whrandom.randint). other issues: 7. why are you counting backwards? 8. you might want to improve the naming of your variables. in this relatively short example, we can figure out what x, y, and z are, but if your application grows in size, these may not be the best choices for easy readibility. below is a shorter solution. the main differences are: a. counting forwards b. creating a new list and appending values to it c. returning the new list instead of x - - - - - - - - - - - - - - - - - - - - - - - - import whrandom def rand_strng(x, y, z): randlist = [] for eachVal in range(x): w = whrandom.randint(y, z) randlist.append(w) return randlist - - - - - - - - - - - - - - - - - - - - - - - - you can also remove the assignment to w and add the random number directly to the list with: randlist.append(whrandom.randint(y, z)) this just saves the memory of one local variable, not necessary, but since w is not used for any- thing else, may make sense. hope this helps!! -wesley "Core Python Programming", Prentice-Hall, TBP Summer 2000 wesley.j.chun :: wesc@alpha.ece.ucsb.edu cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From dklutch@worldnet.att.net Fri Mar 31 02:08:06 2000 From: dklutch@worldnet.att.net (David Kaye) Date: Thu, 30 Mar 2000 21:08:06 -0500 Subject: [Tutor] IDLE - working in windows Message-ID: <002b01bf9ab5$f67cdf00$7b405b0c@hellas> Why do so many on-line tutorials constantly suggest working in a DOS window when working on Python? I'm just learning the basics now and IDLE seems to work fine; it allows me to create a new file and save it while my Python command line interface is running. Am I going to run into trouble as I get into different programs? From christianlean@hotmail.com Fri Mar 31 02:47:46 2000 From: christianlean@hotmail.com (christian lean) Date: Fri, 31 Mar 2000 02:47:46 GMT Subject: [Tutor] Is this code right? Message-ID: <20000331024746.23126.qmail@hotmail.com> Thanks for the help guys ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From jcm@bigskytel.com Fri Mar 31 03:42:39 2000 From: jcm@bigskytel.com (David Porter) Date: Thu, 30 Mar 2000 20:42:39 -0700 Subject: [Tutor] IDLE - working in windows In-Reply-To: <002b01bf9ab5$f67cdf00$7b405b0c@hellas>; from dklutch@worldnet.att.net on Thu, Mar 30, 2000 at 09:08:06PM -0500 References: <002b01bf9ab5$f67cdf00$7b405b0c@hellas> Message-ID: <20000330204239.A28254@bigskytel.com> * David Kaye : > Why do so many on-line tutorials constantly suggest working in a DOS window > when working on Python? Maybe they refer to older versions of IDLE? The latest version is supposed to be much improved. > I'm just learning the basics now and IDLE seems to work fine; it allows me > to create a new file and save it while my Python command line interface is > running. Am I going to run into trouble as I get into different programs? I don't see any reason why you should use a DOS window instead of IDLE, especially if you like IDLE. |David| From princeshinji@xoommail.com Fri Mar 31 04:57:53 2000 From: princeshinji@xoommail.com (Walter Hanagriff) Date: Thu, 30 Mar 2000 20:57:53 -0800 Subject: [Tutor] i need help!!! Message-ID: <200003310457.UAA23774@www1.xoommail.com> i am using win95 and python version 1.5.2 i understand that an answer isnt guaranteed, thought i would try one more time though i just need to know how to get the value of a radiobutton class Radiobutton: v = IntVar() v.set("1") Radiobutton(frame, text = "1 = Find the power of a number", variable = v, value = 1).pack(anchor = W) Radiobutton(frame, text = "2 = Find the area of a shape", variable = v, value = 2).pack(anchor = W) Radiobutton(frame, text = "3 = Find the perimeter of a shape", variable = v, value = 3).pack(anchor = W) def ifpick(self, v): if v == 1: frame2() elif v == 2: frame3() elif v == 3: frame4() i thought maybe tkinter works the same across platforms, an introduction to tkinter doesnt talk like there is a difference, if so can somebody tell me where i should go to get an answer to my question ______________________________________________________ Get your free web-based email at http://www.xoom.com Birthday? Anniversary? Send FREE animated greeting cards for any occasion at http://greetings.xoom.com From infonuovo@email.com Fri Mar 31 05:40:27 2000 From: infonuovo@email.com (Dennis E. Hamilton) Date: Thu, 30 Mar 2000 21:40:27 -0800 Subject: [Tutor] i am new to Mailing lists In-Reply-To: <200003300708.XAA32351@www1.xoommail.com> Message-ID: Walter, the more specialized or complex your question, the less likely you are to get an immediate response, especially if it isn't at the getting-started tutor level. In the case of the question about tkinter integration with TCL8.3 (which I did save, in case I ran across something), I think you are better off asking it on the main python list. [My suggestion is to leave tkinter alone and use the tcl/tk libraries that are installed by the latest stable python, version 1.5.2.] I didn't have any obvious thing to say about your other question and I have now forgotten it. I didn't keep it because I saw no prospect or reason to respond. That's what I do with a lot of messages I see. I don't know what others do. I suggest that when you don't receive a response, you might want to find another way to ask the question, or even ask if there is another place to ask the question. That might provide more responses. Also, you never know who is looking at the [tutor] messages on any given day. You have done nothing wrong. There is simply no assurance of a response to any posting on any list. It is all about what people voluntarily choose to respond to. What you are assured of is a place to ask. Thanks for following up. -- Dennis -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Walter Hanagriff Sent: Wednesday, March 29, 2000 23:09 To: tutor@python.org; tutor@python.org Subject: [Tutor] i am new to Mailing lists i am new to mailing lists and maybe done something wrong, if i have can i please be told what? i sent in 3 posts in a row because each one was long, and i figured if i put them all as one post they would be too long besides, each had a different subject, the last one about foo bar was answered but the first 2 werent answered at all, were they not seen, is no answer known yet, or as i am writing this for, did i do something wrong? it has been a few days and the response to the foo bar question only took less then a day to get 3 answers to so i figured the other 2 would get an answer by now, should i repost in a few days or what? ______________________________________________________ Get your free web-based email at http://www.xoom.com Birthday? Anniversary? Send FREE animated greeting cards for any occasion at http://greetings.xoom.com _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From infonuovo@email.com Fri Mar 31 06:06:28 2000 From: infonuovo@email.com (Dennis E. Hamilton) Date: Thu, 30 Mar 2000 22:06:28 -0800 Subject: [Tutor] IDLE - working in windows In-Reply-To: <002b01bf9ab5$f67cdf00$7b405b0c@hellas> Message-ID: It is so that the command-line use of python can be demonstrated. E.g., >python hello.py and that sort of thing. It matches the unix-ly discussions that are based on operating within a command shell (ignoring the differents in the shell languages themselves). There are some programs that won't run properly inside of an interactive window (having to do with the ways that windows operate), but this shouldn't matter at first. As far as edit / run / edit / run / save ... kinds of development, use idle if it works for you. For some people, it is useful to build up that model in cruder steps. You may already be past that and be able to translate between the two approaches without difficulty. -- Dennis -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of David Kaye Sent: Thursday, March 30, 2000 18:08 To: tutor@python.org Subject: [Tutor] IDLE - working in windows Why do so many on-line tutorials constantly suggest working in a DOS window when working on Python? I'm just learning the basics now and IDLE seems to work fine; it allows me to create a new file and save it while my Python command line interface is running. Am I going to run into trouble as I get into different programs? _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From l.steinborn@4c-ag.de Fri Mar 31 08:47:50 2000 From: l.steinborn@4c-ag.de (Lutz Steinborn) Date: Fri, 31 Mar 2000 10:47:50 +0200 Subject: [Tutor] subscibe Message-ID: <001101bf9aed$cbfc4ee0$8e2965d4@k6win98> From Yogesh.Naik@sbm5501.patni.com Thu Mar 30 18:58:21 2000 From: Yogesh.Naik@sbm5501.patni.com (Yogesh Naik) Date: Fri, 31 Mar 2000 04:58:21 +1000 Subject: [Tutor] how to import? Message-ID: <01BF9ACD.BD136000@creatixnt.patni.com> i have a problem in importing an extended module.The dsw file is = generated and build is used in MSVC++5.0 But when i tried to use import = on the command line,it gave an error sayin module does't exist.How to = overcome this? regards ____________________________________________________ Yogesh Naik =20 email : naikyoge@pcsbom.patni.com Office : 91-022-8291454 ext 176 Visit us at : http://www.patni.com From alan.gauld@bt.com Fri Mar 31 11:58:17 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 31 Mar 2000 12:58:17 +0100 Subject: [Tutor] HTML --> TXT? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6122@mbtlipnt02.btlabs.bt.co.uk> > If you have Linux, then 'lynx -dump ...' will do it. Or MS DOS. Lynx works there too... but of course it ain't Python which was the question :-) Alan g. From alan.gauld@bt.com Fri Mar 31 11:06:46 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 31 Mar 2000 12:06:46 +0100 Subject: [Tutor] what is foo bar? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF611E@mbtlipnt02.btlabs.bt.co.uk> > > Goes back to the early days of the Tech Model Railroad Club > > at MIT (http://web.mit.edu/tmrc/www/). "Foo" seems to have > > come into use first, .....The acronym FUBAR made > > "bar" a natural compliment. > Fubar was in common use in the military (US anyway) during > WW2, so I doubt it originated at MIT. TC didn't say FUBAR originated at MIT rather that the use of FOO as a generic variable name originated there. Somebody at MIT then made the association with the existing FUBAR to come up with BAR as a secondary name... Thats the history of the terms I've seen in the past (all 3 terms!) - I wasn't there so its all 2nd hand news :-) Alan G. From alan.gauld@bt.com Fri Mar 31 11:24:11 2000 From: alan.gauld@bt.com (Gauld,AJ,Alan,NEL1A GAULDAJ R) Date: Fri, 31 Mar 2000 12:24:11 +0100 Subject: [Tutor] HTML --> TXT? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6121@mbtlipnt02.btlabs.bt.co.uk> > Is there a fairly simple Python-ish way to convert an HTML > file to text? There is an html parser around which might do it for you but a quick n' dirty solution is to use the re module and simply parse out everything between '<' and '>'. Make sure the regex you use covers line breaks etc tho'... Alan G. From tescoil@rtpro.net Fri Mar 31 14:46:57 2000 From: tescoil@rtpro.net (Tesla Coil) Date: Fri, 31 Mar 2000 08:46:57 -0600 Subject: [Tutor] what is foo bar? References: <5104D4DBC598D211B5FE0000F8FE7EB202DF611E@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <38E4BA61.5A82C3BF@rtpro.net> On 31 Mar 2000 alan.gauld@bt.com wrote: > TC didn't say FUBAR originated at MIT rather that the > use of FOO as a generic variable name originated there. > Somebody at MIT then made the association with the > existing FUBAR to come up with BAR as a secondary name... > > Thats the history of the terms I've seen in the past > (all 3 terms!) - I wasn't there so its all 2nd hand news :-) Me neither. Besides, Python's namesake offers such a rich source of metasyntactic variables, it's rather sorry we end up using 'spam' all the time. Why is it that nobody remembers the name of Johann Gambolputty de von Ausfern-schplenden- schlitter-crasscrenbon-fried-digger-dingle-dangle-dongle- dungle-burstein-von-knacker-thrasher-applebanger- horowitz-ticolensic-grander-knotty-spelltinkle-grandlich- grumblemeyer-spelterwasser-kurstlich-himbleeisen- bahnwagen-gutenabend-bitte-ein-nurnburger-bratwustle- gernspurten-mitz-weimache-luber-hundsfut-gumberaber- shonedanker-kalbsfleisch-mittler-aucher von Hautkopft of Ulm? From alan.gauld@bt.com Fri Mar 31 14:47:22 2000 From: alan.gauld@bt.com (Gauld,AJ,Alan,NEL1A GAULDAJ R) Date: Fri, 31 Mar 2000 15:47:22 +0100 Subject: [Tutor] what is foo bar? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF612A@mbtlipnt02.btlabs.bt.co.uk> > Me neither. Besides, Python's namesake offers such a rich > source of metasyntactic variables, it's rather sorry we end > up using 'spam' all the time. Indeed. In my book I try to use others thus there are variables called 'petshop' and 'parrot' as well as a lumberjack function :-) > Why is it that nobody remembers > the name of Johann ..... I remember him all the time I just don't have the time to even use his initials!! :-) Alan G. PS One book reviewer did suggest that the publisher might need to get permission from the company who owns the Spam trademark if I used 'spam' too often.... :-( From charlie@intelligenesis.net Fri Mar 31 15:08:19 2000 From: charlie@intelligenesis.net (Charlie Derr) Date: Fri, 31 Mar 2000 10:08:19 -0500 Subject: [Tutor] IDLE - working in windows In-Reply-To: <002b01bf9ab5$f67cdf00$7b405b0c@hellas> Message-ID: David Kaye wrote: | |Why do so many on-line tutorials constantly suggest working in a DOS window |when working on Python? I'm just learning the basics now and IDLE seems to |work fine; it allows me to create a new file and save it while my Python |command line interface is running. Am I going to run into trouble as I get |into different programs? | | One thing i prefer about the dos prompt is that i have a history of commands i've typed available w/the up arrow. I haven't found that feature in idle, and while not absolutely necessary it is quite handy to have (especially if you make as many mistakes as i do, and would prefer to "edit" rather than retype. ~c p.s. unless i haven't found the keystroke that accesses history in idle From alan.gauld@bt.com Fri Mar 31 15:19:47 2000 From: alan.gauld@bt.com (Gauld,AJ,Alan,NEL1A GAULDAJ R) Date: Fri, 31 Mar 2000 16:19:47 +0100 Subject: [Tutor] IDLE - working in windows Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF612C@mbtlipnt02.btlabs.bt.co.uk> The old version of IDLE had several problems/bugs in my experience. The new 0.5 version works very well and I now use it constantly. Altho' I suspect its still not happy with Tkinter programs - but haven't tried yet. But at the end of the day running from a command line prompt is how the program will be executed ultimately so you still need to prove it works there. Also for long coding sessions a better editor than IDLE might be desirable - I use vim... but emacs or PFE etc all offer more advanced features than IDLE. Alan g. > -----Original Message----- > From: tutor-admin@python.org > [mailto:tutor-admin@python.org]On Behalf Of > David Kaye > Sent: Friday, March 31, 2000 3:08 AM > To: tutor > Subject: [Tutor] IDLE - working in windows > > > Why do so many on-line tutorials constantly suggest working > in a DOS window > when working on Python? I'm just learning the basics now and > IDLE seems to > work fine; it allows me to create a new file and save it > while my Python > command line interface is running. Am I going to run into > trouble as I get > into different programs? > > > From charlie@intelligenesis.net Fri Mar 31 19:28:09 2000 From: charlie@intelligenesis.net (Charlie Derr) Date: Fri, 31 Mar 2000 14:28:09 -0500 Subject: [Tutor] complete list of "special" methods Message-ID: Hi all, I was wondering if anyone knows where i might find a full and complete list of any special methods that a python class (module?) is capable of having? Some of the more obvious are __init__, __or__, __repr__ but i'm wondering how many of these there are in total. A short description of what each one is would also be helpful (but not necessary). TMIA, ~c From python-tutor@teleo.net Fri Mar 31 19:52:33 2000 From: python-tutor@teleo.net (Patrick Phalen) Date: Fri, 31 Mar 2000 11:52:33 -0800 Subject: [Tutor] complete list of "special" methods In-Reply-To: References: Message-ID: <00033111542802.03599@quadra.teleo.net> [Charlie Derr, on Fri, 31 Mar 2000] :: Hi all, :: I was wondering if anyone knows where i might find a full and :: complete list of any special methods that a python class (module?) :: is capable of having? :: :: Some of the more obvious are __init__, __or__, __repr__ but i'm wondering :: how many of these there are in total. A short description of what each one :: is :: would also be helpful (but not necessary). Chapter 3 Section 3 of the Python Reference Manual From arcege@shore.net Fri Mar 31 19:53:47 2000 From: arcege@shore.net (Michael P. Reilly) Date: Fri, 31 Mar 2000 14:53:47 -0500 (EST) Subject: [Tutor] complete list of "special" methods In-Reply-To: from "Charlie Derr" at Mar 31, 2000 02:28:09 PM Message-ID: <200003311953.OAA13368@northshore.shore.net> > I was wondering if anyone knows where i might find a full and > complete list of any special methods that a python class (module?) > is capable of having? > > Some of the more obvious are __init__, __or__, __repr__ but i'm wondering > how many of these there are in total. A short description of what each one > is > would also be helpful (but not necessary). These are fully documented in section "3.3 Special method names" in the Python Reference Manual (). There are approximately 53 of these 'special methods'. You can also find descriptions of these in most of the books ("Python Pocket Reference", "Python Essential Reference", "Programming Python", etc.) -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From argoldman@mindspring.com Fri Mar 31 23:18:38 2000 From: argoldman@mindspring.com (A. R. Goldman) Date: Fri, 31 Mar 2000 18:18:38 -0500 Subject: [Tutor] Help with looping... Message-ID: <38E5324D.ABBA0F53@mindspring.com> --------------5FB52E9E112C10EF21F1C327 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Greetings... I have been working on a simple number guessing game... and I would like to add the ability to keep playing games repeatedly. I suspect that this is done with the 'continue' command... but I am either wrong in that assumption... or can't get the syntax... I'm including my code as it stands... any help would be gratefully appreciated... Many Thanks Rick Goldman and here's the script: > lower = 1 > upper = 200 > while 1: > print "lower", lower, "upper", upper > if lower > upper: > print "cheetas never prosper" > break > guess = (lower + upper) /2 > print "Is it", guess, "?" > outcome = raw_input("Is the number higher, lower, or equal to my guess?") > if outcome == "lower": > upper = guess -1 > elif outcome == "higher": > lower = guess + 1 > elif outcome == "equal": > answer = raw_input("That was fun. Another?" )# I assume that I need something here... but what? > if answer == "no": > print "Thank you" > break > else: > print "lower, higher or yes, you Hoser" > > --------------5FB52E9E112C10EF21F1C327 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Greetings...
I have been working on a simple number guessing game... and I would like to add the ability to keep playing games repeatedly. I suspect that this is done with the 'continue' command... but I am either wrong in that assumption... or can't get the syntax... I'm including my code as it stands... any help would be gratefully appreciated...
Many Thanks
Rick Goldman

and here's the script:

lower = 1
upper = 200
while 1:
        print "lower", lower, "upper", upper
        if lower > upper:
                print "cheetas never prosper"
                break
        guess = (lower + upper) /2      
        print "Is it", guess, "?"
        outcome = raw_input("Is the number higher, lower, or equal to my guess?")
        if outcome == "lower":
                upper = guess -1
        elif outcome == "higher":
                lower = guess + 1
        elif outcome == "equal":
                answer = raw_input("That was fun. Another?" )# I assume that I need something here... but what?
                if answer == "no":
                        print "Thank you"
                        break                   
        else:
                print "lower, higher or yes, you Hoser"
        
--------------5FB52E9E112C10EF21F1C327--