From craig@osa.att.ne.jp  Wed Nov  1 05:40:05 2000
From: craig@osa.att.ne.jp (Craig Hagerman)
Date: Wed, 01 Nov 2000 14:40:05 +0900
Subject: [Tutor] OT- how to build Python 2.0 from source?
Message-ID: <200011010533.OAA10662@osa.att.ne.jp>

Hi,

A bit off target... Can anyone tell me exactly how to go about installing
Python 2.0 FROM THE SOURCE file on a Linux machine? I did try to install
using the RedHat RPMs (eg: rpm -ivh BeOpen-Python-2.0-1.i386.rpm) but this
caused an error about failed dependencies (libreadline.so.3 is needed ??) so
perhaps a source install would be better... if only I knew how to do that.

I have looked and looked all over the Python.org site and there doesn't seem
to be any instructions for actually installing Linux on platforms other than
Windows. I have not been using Linux for too long and don't know how to do
this. (I am using Mandrake 7.1 by the way.)

Ironically I did happen across this line on a page documenting installing
modules:

    "However, if such instructions exist at all, they are often woefully
    inadequate and targeted at experienced Python developers."

Seems to me that the installing instructions for Python itself are
inadequate.

Craig Hagerman 


From deirdre@deirdre.net  Wed Nov  1 05:36:24 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Tue, 31 Oct 2000 21:36:24 -0800 (PST)
Subject: [Tutor] OT- how to build Python 2.0 from source?
In-Reply-To: <200011010533.OAA10662@osa.att.ne.jp>
Message-ID: <Pine.LNX.4.10.10010312134570.469-100000@rockhopper.deirdre.org>

On Wed, 1 Nov 2000, Craig Hagerman wrote:

> A bit off target... 

Not at all.

> Can anyone tell me exactly how to go about installing Python 2.0 FROM
> THE SOURCE file on a Linux machine? I did try to install using the
> RedHat RPMs (eg: rpm -ivh BeOpen-Python-2.0-1.i386.rpm) but this
> caused an error about failed dependencies (libreadline.so.3 is needed
> ??) so perhaps a source install would be better... if only I knew how
> to do that.

Probably because those of us who are used to compiling things on Linux
didn't feel it needed to be said? It's pretty stock actually.

tar zxf <sourcefile.tar.gz>

cd <directory created, usually the sourcefile name without the .tar.gz>

./configure && make

su -c "make install"

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"You had thesaurus flakes for breakfast again, didn't you?"
                                                 -- Eric Williams



From dyoo@hkn.eecs.berkeley.edu  Wed Nov  1 05:56:39 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 31 Oct 2000 21:56:39 -0800 (PST)
Subject: [Tutor] OT- how to build Python 2.0 from source?
In-Reply-To: <200011010533.OAA10662@osa.att.ne.jp>
Message-ID: <Pine.LNX.4.21.0010312145070.24481-100000@hkn.eecs.berkeley.edu>

On Wed, 1 Nov 2000, Craig Hagerman wrote:

> A bit off target... Can anyone tell me exactly how to go about installing
> Python 2.0 FROM THE SOURCE file on a Linux machine? I did try to install
> using the RedHat RPMs (eg: rpm -ivh BeOpen-Python-2.0-1.i386.rpm) but this
> caused an error about failed dependencies (libreadline.so.3 is needed ??) so
> perhaps a source install would be better... if only I knew how to do that.

If you're new to compiling source code, it might be better to do an RPM
installation.  Python 2.0 is dependent on the readline library for making
the interpreter nice (command history and all), so that's why that
dependency exists.  Since the rpm is complaining about an uninstalled
libreadline, you'll probably need to first install the readline library.  
Here's a link to readline:

ftp://ftp.twoguys.org/pub/linux/distributions/mandrake/current/i586/Mandrake/RPMS/readline-4.1-9mdk.i586.rpm

(Sorry about the long link... if you have your install CD, you should be
able to find the readline RPM in the Mandrake/RPMS directory.)

After that, your Python-2.0 rpm should install ok.


---

> I have looked and looked all over the Python.org site and there doesn't seem
> to be any instructions for actually installing Linux on platforms other than
> Windows. I have not been using Linux for too long and don't know how to do
> this. (I am using Mandrake 7.1 by the way.)

Installing Python via the source distribution follows the conventions of a
lot of other Unix software.  When you unzip the .tar.gz, you'll see that
it creates a Python-2.0 directory.  Within there, there are a lot of
files, but the one that you'll be looking at is called "configure".

You'll definitely want to look at the README at least once, but the
compilation itself isn't too hard.  First, you need to prepare the source
for your linux machine with the command "./configure".  It'll do some
processing, to figure out platform dependent stuff.

Next, we want to actually compile the source code and install it!  You can
do this by running "make install" as root.  It should start compiling and
install itself on your machine after it's done.

After that, just try "python" and see if things work.

Good luck!



From jclevieux@sud2000.com  Wed Nov  1 08:46:05 2000
From: jclevieux@sud2000.com (Jean-Claude Levieux)
Date: Wed, 01 Nov 2000 09:46:05 +0100
Subject: [Tutor] Command history
Message-ID: <5.0.0.25.2.20001101093902.0252ee98@pop.sud2000.com>

Hi,

I compiled Python 2.0 with :

         ./configure  --prefix=/usr/home/mydir/python

It works fine, but I can't have the command history.
Any idea ?

Thanks in advance.
-----------------------------------------------
Jean-Claude Levieux
jclevieux@sud2000.com
www.sud2000.com/



From wheelege@tsn.cc  Wed Nov  1 09:35:59 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Wed, 1 Nov 2000 20:35:59 +1100
Subject: [Tutor] My Game-in-progress
Message-ID: <009901c043e7$25937120$a410fea9@glen>

This is a multi-part message in MIME format.

------=_NextPart_000_0096_01C04443.57C50080
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

  Hey all.

  I've run into a snag with my game I'm making.  Basically, the way it =
knows time has passes is through a loop.  The problem is, that for =
debugging purposes I made it print the iteration it was going through, =
and when I remove the print option the game goes too fast.
  So I thought I'd use the sleep function in the time module.  This was =
a loss however, it would do all the iterations in the loop and all the =
sleeps before it actually DREW anything on the canvas (gotta use a =
canvas).
  The thing I'm really asking for is a Python command which will make =
pythoin pause for a little bit (the times allowed in sleep were fine) =
but doesn't produce a nasty side effect like sleep does.  If you need to =
see the code I will post it.

  Thanks,
  Glen.

------=_NextPart_000_0096_01C04443.57C50080
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>&nbsp; Hey all.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; I've run into a snag with my game I'm making.&nbsp; =
Basically, the=20
way it knows time has passes is through a loop.&nbsp; The problem is, =
that for=20
debugging purposes I made it print the iteration it was going through, =
and when=20
I remove the print option the game goes too fast.</DIV>
<DIV>&nbsp; So I thought I'd use the sleep function in the time =
module.&nbsp;=20
This was a loss however, it would do all the iterations in the loop and =
all the=20
sleeps before it actually DREW anything on the canvas (gotta use a=20
canvas).</DIV>
<DIV>&nbsp; The thing I'm really asking for is a Python command which =
will make=20
pythoin pause for a little bit (the times allowed in sleep were fine) =
but=20
doesn't produce a nasty side effect like sleep does.&nbsp; If you need =
to see=20
the code I will post it.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Thanks,</DIV>
<DIV>&nbsp; Glen.</DIV></BODY></HTML>

------=_NextPart_000_0096_01C04443.57C50080--



From alan.gauld@bt.com  Wed Nov  1 18:07:24 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 1 Nov 2000 18:07:24 -0000
Subject: [Tutor] My Game-in-progress
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D3C6@mbtlipnt02.btlabs.bt.co.uk>

>   So I thought I'd use the sleep function in the time module. 
>  This was a loss however, it would do all the iterations in 
> the loop and all the sleeps before it actually DREW anything 
> on the canvas (gotta use a canvas).

Have you looked at the scheduler class in the sched module.

It looks like it might do it since it refers to threads.... 
I've never used sched however so no guarantees :-)

Alan G.


From kalle@gnupung.net  Wed Nov  1 19:06:49 2000
From: kalle@gnupung.net (Kalle Svensson)
Date: Wed, 1 Nov 2000 20:06:49 +0100
Subject: [Tutor] Command history
In-Reply-To: <5.0.0.25.2.20001101093902.0252ee98@pop.sud2000.com>; from jclevieux@sud2000.com on Wed, Nov 01, 2000 at 09:46:05AM +0100
References: <5.0.0.25.2.20001101093902.0252ee98@pop.sud2000.com>
Message-ID: <20001101200649.A9628@gnupung.net>

--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Sez Jean-Claude Levieux:
> Hi,

Hello!

> I compiled Python 2.0 with :
>=20
>          ./configure  --prefix=3D/usr/home/mydir/python
>=20
> It works fine, but I can't have the command history.
> Any idea ?

Maybe you haven't enabled readline support?
To do that, edit the file Modules/Setup in the python source directory and
uncomment the line
readline readline.c -lreadline -ltermcap
close to the top.
If the file doesn't exist, copy the file Modules/Setup.in to Modules/Setup
and edit.

HTH,
  Kalle
--=20
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD

--xHFwDpU9dbj6ez1V
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.2 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6AGnJdNeA1787sd0RAmw2AKDGBFmO8isDzMoYFKjlXCTV4yVd2wCgzUOf
3l5CQDY15Kyglx6iGU9Hejk=
=RiUd
-----END PGP SIGNATURE-----

--xHFwDpU9dbj6ez1V--


From gbaronio@siosistemi.it  Thu Nov  2 16:00:00 2000
From: gbaronio@siosistemi.it (Gianmarco Baronio)
Date: Thu, 02 Nov 2000 17:00:00 +0100
Subject: [Tutor] application name of a process
Message-ID: <3A018F80.8BDD3358@siosistemi.it>

This is a multi-part message in MIME format.
--------------B9288DD40961ACECF2A84B08
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello everybody,
I'm working with Pythonwin.
I know the PID associated with my process in this way:

>>> import os
>>> PID = os.getpid()

How can I have the name of the application associated with a process if
I know the PID?

Thanks

--------------B9288DD40961ACECF2A84B08
Content-Type: text/x-vcard; charset=us-ascii;
 name="gbaronio.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Gianmarco Baronio
Content-Disposition: attachment;
 filename="gbaronio.vcf"

begin:vcard 
n:Baronio;Gianmarco
tel;fax:+39 030 2209205
tel;work:+39 030 24411
x-mozilla-html:TRUE
org:<CENTER><B><I><FONT FACE="Arial,Helvetica" COLOR="#000000" SIZE="+2">Siosistemi</FONT></I></B><HR WIDTH="30%" NOSHADE SIZE=1><FONT FACE="Times" SIZE="-3">CONNECTING BUSINESS</FONT></CENTER>
version:2.1
email;internet:gbaronio@siosistemi.it
adr;quoted-printable:;;via Cefalonia 58=0D=0A25124 Brescia;Brescia;BS;25124;Italy
fn:Gianmarco Baronio
end:vcard

--------------B9288DD40961ACECF2A84B08--



From dsh8290@rit.edu  Fri Nov  3 01:06:03 2000
From: dsh8290@rit.edu (D-Man)
Date: Thu, 2 Nov 2000 20:06:03 -0500
Subject: [Tutor] application name of a process
In-Reply-To: <3A018F80.8BDD3358@siosistemi.it>; from gbaronio@siosistemi.it on Thu, Nov 02, 2000 at 11:00:00 -0500
References: <3A018F80.8BDD3358@siosistemi.it>
Message-ID: <20001102200603.A13099@dman.rh.rit.edu>


If you're talking about the name of the running process, sys.argv[0] would do it.

If you're talking about other processes,  I don't know.  Check the source for 'ps' ;-).  You can probably get it out of /proc if you're on a Linux (I don't know about other unices) system.

-D


On Thu, 02 Nov 2000 11:00:00 Gianmarco Baronio wrote:
 | Hello everybody,
 | I'm working with Pythonwin.
 | I know the PID associated with my process in this way:
 | 
 | >>> import os
 | >>> PID = os.getpid()
 | 
 | How can I have the name of the application associated with a process if
 | I know the PID?
 | 
 | Thanks
 | 
 | begin:vcard 
 | n:Baronio;Gianmarco
 | tel;fax:+39 030 2209205
 | tel;work:+39 030 24411
 | x-mozilla-html:TRUE
 | org:<CENTER><B><I><FONT FACE="Arial,Helvetica" COLOR="#000000" SIZE="+2">Siosistemi</FONT></I></B><HR WIDTH="30%" NOSHADE SIZE=1><FONT FACE="Times" SIZE="-3">CONNECTING BUSINESS</FONT></CENTER>
 | version:2.1
 | email;internet:gbaronio@siosistemi.it
 | adr;quoted-printable:;;via Cefalonia 58=0D=0A25124 Brescia;Brescia;BS;25124;Italy
 | fn:Gianmarco Baronio
 | end:vcard
 | 




From FxItAL@aol.com  Fri Nov  3 16:09:46 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Fri, 3 Nov 2000 11:09:46 EST
Subject: [Tutor] freeze
Message-ID: <4b.2fb38a2.27343d4a@aol.com>

Hello All,

    I've finally finished my timer program and would like to distribute it to 
my friends for some testing.  I've downloaded the py152.tar file to get the 
freeze.py and much to my disappointment it says:

     "Unfortunately, it is currently not possible to freeze programs that use 
Tkinter.  It    *seems* to work, but when you ship the frozen program to a 
site without a Tcl/Tk   installation, it will fail with a complaint about 
missing     Tcl/Tk initialization files."
    
    "A workaround would be possible, in which the Tcl/Tk library files are
    incorporated in a frozen Python module as string literals and written
    to a temporary location when the program runs; this is currently left
    as an exercise for the reader."

Can someone help me with this? 

Thanks Al


From jcosby@wolfenet.com  Sat Nov  4 16:47:55 2000
From: jcosby@wolfenet.com (Jon Cosby)
Date: Sat, 4 Nov 2000 08:47:55 -0800
Subject: [Tutor] Opening text file
Message-ID: <LPBBIFMLBAOCBOGCEMGAMEJDCAAA.jcosby@wolfenet.com>

This is strange. I have a text file named "count.dat" that consists of one
line, an integer. Each time I open it in Python, several new blank lines are
added, ending with a "Tf". It happens when I open and close the file in the
interpreter, nothing else. Can somebody tell me what's going on here?

Jon Cosby



From dyoo@hkn.eecs.berkeley.edu  Sun Nov  5 20:51:22 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 5 Nov 2000 12:51:22 -0800 (PST)
Subject: [Tutor] Opening text file
In-Reply-To: <LPBBIFMLBAOCBOGCEMGAMEJDCAAA.jcosby@wolfenet.com>
Message-ID: <Pine.LNX.4.21.0011051247190.16126-100000@hkn.eecs.berkeley.edu>

On Sat, 4 Nov 2000, Jon Cosby wrote:

> This is strange. I have a text file named "count.dat" that consists of
> one line, an integer. Each time I open it in Python, several new blank
> lines are added, ending with a "Tf". It happens when I open and close
> the file in the interpreter, nothing else. Can somebody tell me what's
> going on here?

This is weird!  Could you show us an example output, as well as
count.dat?  As a first guess, if you created count.dat on a different
system (like a Macintosh or UNIX), then it's possible that you're seeing
the result of a slightly different text file format.

In UNIX, newlines are represented as the string "\n", while on Windows
platforms, it's "\r\n".  However, I've never seen "Tf" before.




From Shawn K Parrish" <snsparrish@a-l-m-a.org  Sun Nov  5 23:36:13 2000
From: Shawn K Parrish" <snsparrish@a-l-m-a.org (Shawn K Parrish)
Date: Sun, 5 Nov 2000 18:36:13 -0500
Subject: [Tutor] Newbie
Message-ID: <001d01c04781$37f12e00$718f75d1@dabigdog>

Hello all,

Newbie here.  I've got zero experience.  Can anyone point me towards some
excellent resources to get started?

Thanks,
Shawn Parrish
ALMA
www.a-l-m-a.org





From dsh8290@rit.edu  Mon Nov  6 05:06:05 2000
From: dsh8290@rit.edu (D-Man)
Date: Mon, 6 Nov 2000 00:06:05 -0500
Subject: [Tutor] Newbie
In-Reply-To: <001d01c04781$37f12e00$718f75d1@dabigdog>; from snsparrish@a-l-m-a.org on Sun, Nov 05, 2000 at 18:36:13 -0500
References: <001d01c04781$37f12e00$718f75d1@dabigdog>
Message-ID: <20001106000605.B6094@dman.rh.rit.edu>

The tutorial on python.org is a great place to start.  If you have any specific questions you'll get lots of help here.

Welcome to Python.
-D

On Sun, 05 Nov 2000 18:36:13 Shawn K Parrish wrote:
 | Hello all,
 | 
 | Newbie here.  I've got zero experience.  Can anyone point me towards some
 | excellent resources to get started?
 | 
 | Thanks,
 | Shawn Parrish
 | ALMA
 | www.a-l-m-a.org
 | 





From dsh8290@rit.edu  Mon Nov  6 05:10:19 2000
From: dsh8290@rit.edu (D-Man)
Date: Mon, 6 Nov 2000 00:10:19 -0500
Subject: [Mailer-Daemon@kaplan.com: NDN: Re: [Tutor] Newbie]
In-Reply-To: <fc.0003a98401f2c7a53b9aca0034298439.1f2c7a6@kaplan.com>; from Mailer-Daemon@kaplan.com on Mon, Nov 06, 2000 at 03:05:44 -0500
References: <fc.0003a98401f2c7a53b9aca0034298439.1f2c7a6@kaplan.com>
Message-ID: <20001106001019.C6094@dman.rh.rit.edu>

To the maintainer (or other knowledgeable people):

I am curious to learn why I keep getting the following message whenever I send to the list.

Thanks,
-D

==============================================================================
On Mon, 06 Nov 2000 03:05:44 Mailer-Daemon wrote:
Sorry. Your message could not be delivered to:

matthew hand,Home Office (The name was not found at the
remote site. Check that the name has been entered
correctly.)




From deirdre@deirdre.net  Mon Nov  6 05:10:49 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Sun, 5 Nov 2000 21:10:49 -0800 (PST)
Subject: [Mailer-Daemon@kaplan.com: NDN: Re: [Tutor] Newbie]
In-Reply-To: <20001106001019.C6094@dman.rh.rit.edu>
Message-ID: <Pine.LNX.4.10.10011052109220.22199-100000@rockhopper.deirdre.org>

On Mon, 6 Nov 2000, D-Man wrote:

> To the maintainer (or other knowledgeable people):
> 
> I am curious to learn why I keep getting the following message
> whenever I send to the list.

I had trouble finding the subscription address (they weren't nice enough
to specify what email address it had been sent to). In any case, I believe
it's fixed now.

Either that, or I just unsubscribed the wrong person. :)

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"You had thesaurus flakes for breakfast again, didn't you?"
                                                 -- Eric Williams



From dyoo@hkn.eecs.berkeley.edu  Mon Nov  6 05:58:00 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 5 Nov 2000 21:58:00 -0800 (PST)
Subject: [Tutor] Newbie
In-Reply-To: <20001106000605.B6094@dman.rh.rit.edu>
Message-ID: <Pine.LNX.4.21.0011052150520.25966-100000@hkn.eecs.berkeley.edu>

On Mon, 6 Nov 2000, D-Man wrote:

> The tutorial on python.org is a great place to start.  If you have any
> specific questions you'll get lots of help here.
> 
> Welcome to Python.
> -D
> 
> On Sun, 05 Nov 2000 18:36:13 Shawn K Parrish wrote:
>  | Hello all,
>  | 
>  | Newbie here.  I've got zero experience.  Can anyone point me
>  | towards some excellent resources to get started?

Dear Shawn,

Time to start sowing internal discord... *grin*  I don't recommend the
official tutorial at:

    http://python.org/doc/current/tut/tut.html

At least, not until you're more familiar with programming.  It's ok to
take a brief glance at it, but it's the "deep end of the pool".


On the other hand, I think you're better off with the Introductions
section of python.org here:

    http://python.org/doc/Intros.html

You can get a lot out of the "Introductions to Python programming for
non-programmers" section on that page.


Good luck!



From amoreira@mercury.ubi.pt  Mon Nov  6 10:30:11 2000
From: amoreira@mercury.ubi.pt (Jose Amoreira)
Date: Mon, 06 Nov 2000 10:30:11 +0000
Subject: [Tutor] freeze
References: <4b.2fb38a2.27343d4a@aol.com>
Message-ID: <3A068832.F7870BDC@mercury.ubi.pt>

Hello!
Check out Gordon's installer at
 http://starship.python.net/crew/gmcm/install.html

According to the docs it solves your problem. I checked it with some code of
mine, and the distibuted version works fine in computers simmilar to the one
used to make it (linux), but segfaults in my laptop (also linux, but different
OS version number  and different libs). I think that this problem is addressed
in the docs (something about tksetup), but I just don't have the time to study
it in any detail.

I hope this helps
Ze
amoreira@mercury.ubi.pt


FxItAL@aol.com wrote:

> Hello All,
>
>     I've finally finished my timer program and would like to distribute it to
> my friends for some testing.  I've downloaded the py152.tar file to get the
> freeze.py and much to my disappointment it says:
>
>      "Unfortunately, it is currently not possible to freeze programs that use
> Tkinter.  It    *seems* to work, but when you ship the frozen program to a
> site without a Tcl/Tk   installation, it will fail with a complaint about
> missing     Tcl/Tk initialization files."
>
>     "A workaround would be possible, in which the Tcl/Tk library files are
>     incorporated in a frozen Python module as string literals and written
>     to a temporary location when the program runs; this is currently left
>     as an exercise for the reader."
>
> Can someone help me with this?
>
> Thanks Al
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor



From mbc2@netdoor.com  Mon Nov  6 14:24:02 2000
From: mbc2@netdoor.com (Brad Chandler)
Date: Mon, 6 Nov 2000 08:24:02 -0600
Subject: [Tutor] Where is PYTHONPATH set?
Message-ID: <001501c047fd$35f7bca0$111c0d0a@spb.state.ms.us>

I've recently installed Python 2.0, an upgrade from 1.6.  I believe I also
had 1.5 on the machine originally.  The systems seems to still be looking in
/usr/lib/python1.5 for the modules, however the new version put them in
/usr/local/lib/python2.0.

I'm trying to get cgi to work and also the postgresql integration.  When I
try to run a cgi script I get an error in my apache/logs/error.log file that
suggests I set $PYTHONPATH to something like [exec_prefix][prefix].  I don't
think that's the exact quote but its close.  I also get a similar message
when trying to install postgres integration (I can't remember the name of
the package right now, it seems that there are two packages that do this,
one of which I had working with 1.6).

With 1.6, I ended up creating a bunch of symlinks, but I'd rather not do
that.  How can I tell my system where to look in /usr/local/lib/python2.0
instead of /usr/lib/python1.5?



From dsh8290@rit.edu  Mon Nov  6 16:02:01 2000
From: dsh8290@rit.edu (D-Man)
Date: Mon, 6 Nov 2000 11:02:01 -0500
Subject: [Tutor] Newbie
In-Reply-To: <Pine.LNX.4.21.0011052150520.25966-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Mon, Nov 06, 2000 at 00:58:00 -0500
References: <20001106000605.B6094@dman.rh.rit.edu> <Pine.LNX.4.21.0011052150520.25966-100000@hkn.eecs.berkeley.edu>
Message-ID: <20001106110201.A7310@dman.rh.rit.edu>

Ok,  I think Daniel is a bit more experienced than I am.  I read the tutorial after I already knew Eiffel, C++, Java, and C (and was in my second year of Software Engineering here at RIT).

I liked the tutorial, but maybe I was familiar enough with programming to understand it.

:-)

-D

On Mon, 06 Nov 2000 00:58:00 Daniel Yoo wrote:
 | On Mon, 6 Nov 2000, D-Man wrote:
 | 
 | > The tutorial on python.org is a great place to start.  If you have any
 | > specific questions you'll get lots of help here.
 | > 
 | > Welcome to Python.
 | > -D
 | > 
 | > On Sun, 05 Nov 2000 18:36:13 Shawn K Parrish wrote:
 | >  | Hello all,
 | >  | 
 | >  | Newbie here.  I've got zero experience.  Can anyone point me
 | >  | towards some excellent resources to get started?
 | 
 | Dear Shawn,
 | 
 | Time to start sowing internal discord... *grin*  I don't recommend the
 | official tutorial at:
 | 
 |     http://python.org/doc/current/tut/tut.html
 | 
 | At least, not until you're more familiar with programming.  It's ok to
 | take a brief glance at it, but it's the "deep end of the pool".
 | 
 | 
 | On the other hand, I think you're better off with the Introductions
 | section of python.org here:
 | 
 |     http://python.org/doc/Intros.html
 | 
 | You can get a lot out of the "Introductions to Python programming for
 | non-programmers" section on that page.
 | 
 | 
 | Good luck!
 | 




From scott@zenplex.com  Mon Nov  6 16:59:07 2000
From: scott@zenplex.com (Scott Ralph)
Date: Mon, 06 Nov 2000 11:59:07 -0500
Subject: [Tutor] Hotfolder 1st attempt
Message-ID: <3A06E35B.C2FC6D22@zenplex.com>

Hello,  I am a newbie and this is really my first attempt at writing
something useful for myself.  It's a simple hotfolder. Basically place a
file in and dosomething with it.  In the example it's a move to /tmp
using os.open.    I used some  example code from the stat library ref.
program called walker.  Just thought I'd get some feedback from the
group.

#!/usr/bin/env python

import os, sys
from time import *
from stat import *

# Start loop  by passing in a folder to monitor.  Example:
./hotfolder.py /home/scott/in_coming
# Use if statement with a +20 seconds to compare against system clock.
Used to check if file modification has stopped when copying.

def getDirContents(dir):
  while 1:
      for f in os.listdir(dir):
           pathname = '%s%s' % (dir, f)
           mode = os.stat(pathname)[ST_MODE]
           S_ISREG(mode)
           t = time()
           f = os.stat(pathname)[ST_MTIME]
           if f+20 < t:
               os.popen('mv %s %s' % (pathname, '/tmp/'))
           else:
               print 'not yet'
      else:
          sleep(5)


if __name__ == '__main__':
   getDirContents(sys.argv[1])

Scott




From deirdre@deirdre.net  Mon Nov  6 19:26:01 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Mon, 6 Nov 2000 11:26:01 -0800 (PST)
Subject: [Tutor] Where is PYTHONPATH set?
In-Reply-To: <001501c047fd$35f7bca0$111c0d0a@spb.state.ms.us>
Message-ID: <Pine.LNX.4.10.10011061120210.12659-100000@rockhopper.deirdre.org>

On Mon, 6 Nov 2000, Brad Chandler wrote:

> I've recently installed Python 2.0, an upgrade from 1.6.  I believe I
> also had 1.5 on the machine originally.  The systems seems to still be
> looking in /usr/lib/python1.5 for the modules, however the new version
> put them in /usr/local/lib/python2.0.

Since you're talking a web server, in the script that starts the web
server (/etc/rc.d/init.d/httpd for Red Hat Linux), put:

export PYTHONPATH=/usr/local/lib/python2.0

You may need to fuss with the path to get it right (I've never needed the
PYTHONPATH set...), but that's what to do and where. You'll need to stop
and restart your web server to test it.

(if bash isn't your default shell, you'll need to translate this into
whatever shell you're using)

> I'm trying to get cgi to work and also the postgresql integration.  
> When I try to run a cgi script I get an error in my
> apache/logs/error.log file that suggests I set $PYTHONPATH to
> something like [exec_prefix][prefix].  I don't think that's the exact
> quote but its close.  I also get a similar message when trying to
> install postgres integration (I can't remember the name of the package
> right now, it seems that there are two packages that do this, one of
> which I had working with 1.6).
> 
> With 1.6, I ended up creating a bunch of symlinks, but I'd rather not
> do that.  How can I tell my system where to look in
> /usr/local/lib/python2.0 instead of /usr/lib/python1.5?

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"You had thesaurus flakes for breakfast again, didn't you?"
                                                 -- Eric Williams



From dragon@etang.com  Tue Nov  7 12:48:12 2000
From: dragon@etang.com (dragon)
Date: Tue, 7 Nov 2000 20:48:12 +0800 (CST)
Subject: [Tutor] Help! I am a newbie with a fool question.
Message-ID: <3A07FA0C.04489@mail-smtp2>

I am using mailman 2.0

Follwing is log file  smtp-failures,

TrySMTPDelivery: To cja888@etang.com:
TrySMTPDelivery:    socket.error  / (111, 'Connection refused')  (deferred)
TrySMTPDelivery:  Maybe your MTA daemon needs restarting?

How should I do to?

HELP!
THX


-----------------------------------------
多一份惊喜,少一点风险
http://ecard.etang.com/progt/index.asp?s1=1&s2=1


From FxItAL@aol.com  Tue Nov  7 19:56:37 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Tue, 07 Nov 2000 14:56:37 EST
Subject: [Tutor] Making Python Script into Executable
Message-ID: <72.4a61e83.2739b875@aol.com>

Hello All,

Would someone please take my hand and walk me through the process of making a 
Python Script (w/Tkinter) into an executable that I can give to my friends
for testing.

I'm using 1.5.2 w/Windows ME

This is my first program and need some (alot of:-) help here.

Thanks Al     




From dyoo@hkn.eecs.berkeley.edu  Tue Nov  7 23:25:29 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 7 Nov 2000 15:25:29 -0800 (PST)
Subject: [Tutor] Help! I am a newbie with a fool question.
In-Reply-To: <3A07FA0C.04489@mail-smtp2>
Message-ID: <Pine.LNX.4.21.0011071519210.18323-100000@hkn.eecs.berkeley.edu>

This sounds like a mailman-specific question; you'll probably want to
talk to the people at:

    http://www.list.org

They have a mailing list where you can post your questions:

    http://www.python.org/mailman/listinfo/mailman-users/

You may want to mention the type of operating system, and what sort of MTA
you're using.  Is it sendmail, or qmail, or postfix?

In the meantime, I'll try to forward your message to the mailman-users
mailing list.

From a quick look, you probably want to make sure that your system can
send email; try seeing if you can use pine to send a message to another
email address.  Mailman depends on your MTA to handle passing mail out to
the network.

I hope you can find and fix your problem.  Good luck!


> I am using mailman 2.0
> 
> Follwing is log file  smtp-failures,
> 
> TrySMTPDelivery: To cja888@etang.com:
> TrySMTPDelivery:    socket.error  / (111, 'Connection refused')  (deferred)
> TrySMTPDelivery:  Maybe your MTA daemon needs restarting?
> 
> How should I do to?



From dyoo@hkn.eecs.berkeley.edu  Wed Nov  8 08:35:04 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 8 Nov 2000 00:35:04 -0800 (PST)
Subject: [Tutor] Where is PYTHONPATH set?
In-Reply-To: <001501c047fd$35f7bca0$111c0d0a@spb.state.ms.us>
Message-ID: <Pine.LNX.4.21.0011080030020.2346-100000@hkn.eecs.berkeley.edu>

On Mon, 6 Nov 2000, Brad Chandler wrote:

> With 1.6, I ended up creating a bunch of symlinks, but I'd rather not do
> that.  How can I tell my system where to look in /usr/local/lib/python2.0
> instead of /usr/lib/python1.5?

Has anyone answered you yet?  If not, sorry about the long delay!

As long as you're running the right executable, you shouldn't run into
difficulties with library locations.  Since you mentioned that you have
several versions of Python on your system, make sure that you're running:

    /usr/local/bin/python

instead of

    /usr/bin/python

My guess is that your PATH is set up so that binaries in /usr/bin take
precedence over those in /usr/local/bin.  You can check for this by doing:

    which python

at your prompt, and see which Python your system finds first.

You should definitely not need to modify symlinks or anything --- that's
precisely why the library directory has the version number appended onto
the pathname.

Good luck!



From dyoo@hkn.eecs.berkeley.edu  Wed Nov  8 08:46:28 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 8 Nov 2000 00:46:28 -0800 (PST)
Subject: [Tutor] Hotfolder 1st attempt
In-Reply-To: <3A06E35B.C2FC6D22@zenplex.com>
Message-ID: <Pine.LNX.4.21.0011080035540.2346-100000@hkn.eecs.berkeley.edu>

On Mon, 6 Nov 2000, Scott Ralph wrote:

> from time import *
> from stat import *

The only thing I could point out is that you might not want to import
everything within time or stat.  You can be more specific, like:

    from time import sleep

It's considered good practice to pull out only the functionality that you
need from modules; that way, people can see exactly which functions you're
using from other modules.

Another related reason is to avoid wacky problems with name conflicts: if
either the 'time' or 'stat' modules had shared the same function names,
one would have taken precedence over the other, which is tricky to detect.

Otherwise, from a quick look, I think that your program looks good.  You
might want to un-hardcode '20' from your code, and make it a parameter of
getDirContents.


I'm taking a local look into the statements now.

*** time passes ***


I'm not quite sure what:

>            S_ISREG(mode)

is doing; according to the documentation:

"""S_ISREG (mode) 
     Return non-zero if the mode is from a regular file."""

which means that it doesn't affect anything --- it only returns a true or
false value.  It looks mysterious, so you might want to check that
statement.


Hope this helps!



From wilkins@iinet.net.au  Tue Nov  7 22:27:31 2000
From: wilkins@iinet.net.au (Richard Wilkins)
Date: Wed, 8 Nov 2000 06:27:31 +0800
Subject: [Tutor] Newbie question
Message-ID: <MABBIFAJGJIHIKKDOGHOCEDICCAA.wilkins@iinet.net.au>

Hi,

Can someone please tell me how to change into degrees mode, I can't see
it in the math module...It's probably right under my nose.

Thanks, Andrew.




From scott@zenplex.com  Wed Nov  8 15:11:36 2000
From: scott@zenplex.com (Scott Ralph)
Date: Wed, 08 Nov 2000 10:11:36 -0500
Subject: [Tutor] Hotfolder 1st attempt
References: <Pine.LNX.4.21.0011080035540.2346-100000@hkn.eecs.berkeley.edu>
Message-ID: <3A096D27.1A017410@zenplex.com>

Daniel Yoo wrote:

> On Mon, 6 Nov 2000, Scott Ralph wrote:
>
> > from time import *
> > from stat import *
>
> The only thing I could point out is that you might not want to import
> everything within time or stat.  You can be more specific, like:
>
>     from time import sleep
>
> It's considered good practice to pull out only the functionality that you
> need from modules; that way, people can see exactly which functions you're
> using from other modules.
>
> Another related reason is to avoid wacky problems with name conflicts: if
> either the 'time' or 'stat' modules had shared the same function names,
> one would have taken precedence over the other, which is tricky to detect.
>
> Otherwise, from a quick look, I think that your program looks good.  You
> might want to un-hardcode '20' from your code, and make it a parameter of
> getDirContents.
>
> I'm taking a local look into the statements now.
>
> *** time passes ***
>
> I'm not quite sure what:
>
> >            S_ISREG(mode)
>
> is doing; according to the documentation:
>
> """S_ISREG (mode)
>      Return non-zero if the mode is from a regular file."""
>
> which means that it doesn't affect anything --- it only returns a true or
> false value.  It looks mysterious, so you might want to check that
> statement.
>
> Hope this helps!
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

Thanks for the feedback,  I removed the S_ISREG(mode) I didn't need it.  Does
your first suggestion also speed things up? from time import sleep.  Thanks
again for the feedback.
Scott





From amoreira@mercury.ubi.pt  Wed Nov  8 16:03:43 2000
From: amoreira@mercury.ubi.pt (Jose Amoreira)
Date: Wed, 08 Nov 2000 16:03:43 +0000
Subject: [Tutor] Newbie question
References: <MABBIFAJGJIHIKKDOGHOCEDICCAA.wilkins@iinet.net.au>
Message-ID: <3A09795F.51862915@mercury.ubi.pt>

Richard Wilkins wrote:

> Hi,
>
> Can someone please tell me how to change into degrees mode, I can't see
> it in the math module...It's probably right under my nose.
>
> Thanks, Andrew.
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

Hello!
I don't think that there is such a thing as a degrees mode. You have to
explicitly perform the conversions yourself in the input/output sections
of your code, if you want to talk to it using degrees instead of radians.

so long!
Ze
amoreira@mercury.ubi.pt




From jkillion@mipscorp.com  Wed Nov  8 19:10:57 2000
From: jkillion@mipscorp.com (Jerry Killion)
Date: Wed, 08 Nov 2000 14:10:57 -0500
Subject: [Tutor] Re: Tutor digest, Vol 1 #466 - 7 msgs
References: <20001028160107.8D5301CDDA@dinsdale.python.org>
Message-ID: <3A09A541.D1A5B5DA@mipscorp.com>

I ran the sleep method under pythonwin 1.5 and it doesn't act like what i would
expect - the sleep method seems to run prior to printing - can you explain why?

thanks

tutor-request@python.org wrote:

> Send Tutor mailing list submissions to
>         tutor@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://www.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>         tutor-request@python.org
>
> You can reach the person managing the list at
>         tutor-admin@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
> Today's Topics:
>
>    1. Re: I want to sign up... (Gerrit Haase)
>    2. Re: joining mailing list (Gerrit Haase)
>    3. tkinter newbie problem (wheelege)
>    4. Re: Python 2.0 newbie questions (Glenn T. Norton)
>    5. really really silly question (wheelege)
>    6. RE: really really silly question (Doug Stanfield)
>    7. Re: really really silly question (wheelege)
>
> --__--__--
>
> Message: 1
> From: "Gerrit Haase" <gerrit.haase@t-online.de>
> Organization: Esse keine toten Tiere
> To: Dania Lorena <danialorena@yahoo.com>, tutor@python.org
> Date: Sat, 28 Oct 2000 03:41:45 +0200
> Subject: Re: [Tutor] I want to sign up...
>
> Von:                    Dania Lorena <danialorena@yahoo.com>
> An:                     tutor@python.org
> Betreff:                [Tutor] I want to sign up...
> Datum:          Wed, 25 Oct 2000 14:27:03 -0700 (PDT)
>
> > For tutoring in python.
> > My name is Dania Martinez
> > danialorena@yahoo.com
> >
>
> I see, there is no answer yet, so I do it:
>
> look here to subscribe:
> http://www.python.org/mailman/listinfo/tutor
>
> - gph -
>
> --
> Gerrit Peter Haase
>
> --__--__--
>
> Message: 2
> From: "Gerrit Haase" <gerrit.haase@t-online.de>
> Organization: Esse keine toten Tiere
> To: "Stahl, Carissa" <Carissa.Stahl@icn.siemens.com>,
>         "'tutor@python.org'" <tutor@python.org>
> Date: Sat, 28 Oct 2000 03:44:57 +0200
> Subject: Re: [Tutor] joining mailing list
>
> Von:                    "Stahl, Carissa" <Carissa.Stahl@icn.siemens.com>
> An:                     "'tutor@python.org'" <tutor@python.org>
> Betreff:                [Tutor] joining mailing list
> Datum:          Mon, 23 Oct 2000 13:44:14 -0400
>
> > Please place me on your mailing list...
> > carissa.stahl@icn.siemens.com
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://www.python.org/mailman/listinfo/tutor
>
> I see, there is no answer yet, so I do it:
>
> look here to subscribe:
> http://www.python.org/mailman/listinfo/tutor
>
> - gph -
>
> --
> Gerrit Peter Haase
>
> --__--__--
>
> Message: 3
> From: "wheelege" <wheelege@tsn.cc>
> To: <tutor@python.org>
> Date: Sat, 28 Oct 2000 13:05:08 +1000
> Subject: [Tutor] tkinter newbie problem
>
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_0037_01C040DF.B2E04220
> Content-Type: text/plain;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
>   Hi all.  This is probably so mind-numbingly simple but hey - I'm a =
> newbie.
>
> can anyone see any problems with this?
>
> from Tkinter import *
> root =3D Tk()
> root.title("I'm a Tkinter Program !")
>
> mBar =3D Frame(root, relief=3DRAISED, borderwidth=3D2)
> mBar.pack(fill=3DX)
> CmdBtn =3D makeCommandMenu()
> mBar.tk_menuBar(CmdBtn)#, CasBtn, ChkBtn, RadBtn, NoMenu)
> def makeCommandMenu():
>     CmdBtn =3D Menubutton(mBar, text=3D'Button Commands', underline=3D0)
>     CmdBtn.pack(side=3DLEFT, padx=3D"2m")
>     CmdBtn.menu =3D Menu(CmdBtn)
>     CmdBtn.menu.add_command(label=3D"Undo")
>     CmdBtn.menu.entryconfig(0, state=3DDISABLED)
>     CmdBtn.menu.add_command(label=3D'New...', underline=3D0, =
> command=3Dnew_file)
>     CmdBtn.menu.add_command(label=3D'Open...', underline=3D0, =
> command=3Dopen_file)
>     CmdBtn.menu.add_command(label=3D'Wild Font', underline=3D0,
>                             font=3D('Tempus Sans ITC', 14), =
> command=3Dstub_action)
>     CmdBtn.menu.add_command(bitmap=3D"@bitmaps/RotateLeft")
>     CmdBtn.menu.add('separator')
>     CmdBtn.menu.add_command(label=3D'Quit', underline=3D0,
>                             background=3D'white', =
> activebackground=3D'green',
>                             command=3DCmdBtn.quit)
>     print 'bitch'
>     CmdBtn['menu'] =3D CmdBtn.menu
>     return CmdBtn
>
> root.mainloop()
>
> This is almost exactly copied from John Grayson's book, but I cut some =
> things from it.
> I'm using Python 2.0.  It keeps telling me there is an error with the =
> makeCommandMenu thing,
> says there is no such variable as mbar.
>
> Help!
>
> ------=_NextPart_000_0037_01C040DF.B2E04220
> Content-Type: text/html;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=3DContent-Type content=3D"text/html; =
> charset=3Diso-8859-1">
> <META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV>&nbsp; Hi all.&nbsp; This is probably so mind-numbingly simple but =
> hey -=20
> I'm a newbie.</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>can anyone see any problems with this?</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>from Tkinter import *<BR>root =3D Tk()<BR>root.title("I'm a Tkinter =
> Program=20
> !")</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>mBar =3D Frame(root, relief=3DRAISED,=20
> borderwidth=3D2)<BR>mBar.pack(fill=3DX)<BR>CmdBtn =3D=20
> makeCommandMenu()<BR>mBar.tk_menuBar(CmdBtn)#, CasBtn, ChkBtn, RadBtn,=20
> NoMenu)<BR>def makeCommandMenu():<BR>&nbsp;&nbsp;&nbsp; CmdBtn =3D=20
> Menubutton(mBar, text=3D'Button Commands', =
> underline=3D0)<BR>&nbsp;&nbsp;&nbsp;=20
> CmdBtn.pack(side=3DLEFT, padx=3D"2m")<BR>&nbsp;&nbsp;&nbsp; CmdBtn.menu =
> =3D=20
> Menu(CmdBtn)<BR>&nbsp;&nbsp;&nbsp;=20
> CmdBtn.menu.add_command(label=3D"Undo")<BR>&nbsp;&nbsp;&nbsp;=20
> CmdBtn.menu.entryconfig(0, state=3DDISABLED)<BR>&nbsp;&nbsp;&nbsp;=20
> CmdBtn.menu.add_command(label=3D'New...', underline=3D0,=20
> command=3Dnew_file)<BR>&nbsp;&nbsp;&nbsp; =
> CmdBtn.menu.add_command(label=3D'Open...',=20
> underline=3D0, command=3Dopen_file)<BR>&nbsp;&nbsp;&nbsp;=20
> CmdBtn.menu.add_command(label=3D'Wild Font',=20
> underline=3D0,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
> nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> font=3D('Tempus Sans ITC', 14), =
> command=3Dstub_action)<BR>&nbsp;&nbsp;&nbsp;=20
> CmdBtn.menu.add_command(bitmap=3D"@bitmaps/RotateLeft")<BR>&nbsp;&nbsp;&n=
> bsp;=20
> CmdBtn.menu.add('separator')<BR>&nbsp;&nbsp;&nbsp;=20
> CmdBtn.menu.add_command(label=3D'Quit',=20
> underline=3D0,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
> nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> background=3D'white',=20
> activebackground=3D'green',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
> nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> command=3DCmdBtn.quit)<BR>&nbsp;&nbsp;&nbsp; print =
> 'bitch'<BR>&nbsp;&nbsp;&nbsp;=20
> CmdBtn['menu'] =3D CmdBtn.menu<BR>&nbsp;&nbsp;&nbsp; return =
> CmdBtn<BR></DIV>
> <DIV>root.mainloop()<BR></DIV>
> <DIV>This is almost exactly copied from John Grayson's book, but I cut =
> some=20
> things from it.</DIV>
> <DIV>I'm using Python 2.0.&nbsp; It keeps telling me there is an error =
> with the=20
> makeCommandMenu thing,</DIV>
> <DIV>says there is no such variable as mbar.</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>Help!</DIV></BODY></HTML>
>
> ------=_NextPart_000_0037_01C040DF.B2E04220--
>
> --__--__--
>
> Message: 4
> Date: Fri, 27 Oct 2000 20:35:44 -0700
> From: "Glenn T. Norton" <gtnorton@earthlink.net>
> To: tutor@python.org
> Subject: Re: [Tutor] Python 2.0 newbie questions
>
> alan.gauld@bt.com wrote:
>
> > > First make sure your path is set. Here's what I have(on Win98): SET
> > > PATH=C:\PYTHON20;%PATH%
> >
> > > Create a folder in the Python directory, such as "mypython".
> > > Create the file, such as "hello.py"
> > > Save it in the "mypython" directory.
> >
> > >In which case you should also add to your AUTOEXEC:
> > >SET PYTHONPATH=C:\PYTHON20\MYPYTHON
>
>    > Then you don't need to do this:
>    > Go to the command line, IDLE or PythonWin and at the prompt, type...
>    > import os
>    > os.chdir('C:\PYTHON20\MYPYTHON')    #make sure to include the single
>    > quotes
>
>     Is this in anyway wrong? meaning is it dangerous or flatout wrong
>     to import modules this way?. I just find that it's a little quicker to
> use
>     "import os/os.chdir(' ')" and include the path in the IDLE path
> browser
>     than to add to my already bloated AUTOEXEC and reboot windows
>     everytime I create a new project folder.
>
>     Looking forward to the your book.
>     Regards,
>     gtnorton
>
> >
> >
> >
>
> --__--__--
>
> Message: 5
> From: "wheelege" <wheelege@tsn.cc>
> To: <tutor@python.org>
> Date: Sun, 29 Oct 2000 00:40:35 +1000
> Subject: [Tutor] really really silly question
>
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_0040_01C04140.DA25DA00
> Content-Type: text/plain;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
>   I saw the sleep command in the python documentation and tried to use =
> it - but no matter how hard I try I get an error saying the variable =
> 'sleep' does not exist.  Help!
>
> ------=_NextPart_000_0040_01C04140.DA25DA00
> Content-Type: text/html;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=3DContent-Type content=3D"text/html; =
> charset=3Diso-8859-1">
> <META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV>&nbsp; I saw the sleep command in the python documentation and =
> tried to use=20
> it - but no matter how hard I try I get an error saying the variable =
> 'sleep'=20
> does not exist.&nbsp; Help!</DIV></BODY></HTML>
>
> ------=_NextPart_000_0040_01C04140.DA25DA00--
>
> --__--__--
>
> Message: 6
> From: Doug Stanfield <DOUGS@oceanic.com>
> To: 'wheelege' <wheelege@tsn.cc>, tutor@python.org
> Subject: RE: [Tutor] really really silly question
> Date: Sat, 28 Oct 2000 04:57:07 -1000
>
> There are no silly or stupid questions in this group.  Feel free to ask
> away.
>
> >  I saw the sleep command in the python documentation
> > and tried to use it - but no matter how hard I try I
> > get an error saying the variable 'sleep' does not exist.
>
> Sleep is a part of the time module.  That means time has to be imported
> before sleep will be recognized as a valid name.  Here's an example
>
> #!/usr/bin/env python
> import time
>
> print "The beginning of time."
> time.sleep(5.9) # not sure the documents mention that fractions work too
> print "The end of time."
>
> > Help!
>
> Hope this did.
>
> -Doug-
>
> --__--__--
>
> Message: 7
> From: "wheelege" <wheelege@tsn.cc>
> To: <tutor@python.org>
> Subject: Re: [Tutor] really really silly question
> Date: Sun, 29 Oct 2000 03:01:20 +1100
>
> Thanks alot.
>
> Floating point integers work in the sleep function, otherwise I wouldn't be
> able to use it.  I'm making an arkanoid game - it's going pretty cool right
> now, and I am learning alot.
>
> Hope everyone can bear with me :)
>
> Glen
>
> --__--__--
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>
> End of Tutor Digest

--
Thank you and have a great day

Jerry Killion
Director - Client Services
MIPS Corporation
2 Clinton Square
Syracuse, NY 13202




From brett42@flex.com  Wed Nov  8 23:26:22 2000
From: brett42@flex.com (Brett)
Date: Wed, 08 Nov 2000 13:26:22 -1000
Subject: [Tutor] Anyone know any installer mirrors?
Message-ID: <4.3.2.7.0.20001108132205.00a93760@mail.flex.com>

	I was using something called installer on my old broken computer, its a 
program that lets you make python files into standalone .exes.  I went back 
to the python faq for the link, which pointed to 
http://starship.python.net/crew/gmcm/distribute.html, but the link seems to 
have been down for a while.  does anyone know of another place I could get 
this?
When Schrodinger's cat's away,
the mice may or may not play,
no one can tell.



From jcm@bigskytel.com  Thu Nov  9 01:41:06 2000
From: jcm@bigskytel.com (David Porter)
Date: Wed, 8 Nov 2000 18:41:06 -0700
Subject: [Tutor] Anyone know any installer mirrors?
In-Reply-To: <4.3.2.7.0.20001108132205.00a93760@mail.flex.com>; from brett42@flex.com on Wed, Nov 08, 2000 at 01:26:22PM -1000
References: <4.3.2.7.0.20001108132205.00a93760@mail.flex.com>
Message-ID: <20001108184106.B3259@bigskytel.com>

* Brett <brett42@flex.com>:
> 	I was using something called installer on my old broken computer, its a 
> program that lets you make python files into standalone .exes.  I went back 
> to the python faq for the link, which pointed to 
> http://starship.python.net/crew/gmcm/distribute.html, but the link seems to 
> have been down for a while.  does anyone know of another place I could get 
> this?

http://www.mcmillan-inc.com/install1.html



From jcm@bigskytel.com  Thu Nov  9 01:42:05 2000
From: jcm@bigskytel.com (David Porter)
Date: Wed, 8 Nov 2000 18:42:05 -0700
Subject: [Tutor] Re: Tutor digest, Vol 1 #466 - 7 msgs
Message-ID: <20001108184204.C3259@bigskytel.com>

* Jerry Killion <jkillion@mipscorp.com>:

> I ran the sleep method under pythonwin 1.5 and it doesn't act like what i
> would expect - the sleep method seems to run prior to printing - can you
> explain why?

I don't understand your question. time.sleep() will run prior to what is
after it and after what it before it.

import time
print 'before'
time.sleep(3)
print 'after'

If this code is executed, there will be a 3 second pause between the
printing of 'before' and 'after'. The pause occurs because we requested a 3
second pause in the execution of the script before proceeding to the next
line. 

> 
> thanks
> 

Please do not quote the entire digest. Most (all?) of it had nothing to do
with your question.

David




From mbc2@netdoor.com  Thu Nov  9 02:06:52 2000
From: mbc2@netdoor.com (mbc2@netdoor.com)
Date: Wed, 8 Nov 2000 20:06:52 -0600 (CST)
Subject: Web Scripting with Python. (was Re: [Tutor] Where is PYTHONPATH
 set?)
In-Reply-To: <Pine.LNX.4.21.0011080030020.2346-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.20.0011081946480.3473-100000@localhost.localdomain>


On Wed, 8 Nov 2000, Daniel Yoo wrote:

> As long as you're running the right executable, you shouldn't run into
> difficulties with library locations.  Since you mentioned that you have
> several versions of Python on your system, make sure that you're running:
> 
>     /usr/local/bin/python
> 
> instead of
> 
>     /usr/bin/python
> 
> My guess is that your PATH is set up so that binaries in /usr/bin take
> precedence over those in /usr/local/bin.  You can check for this by doing:
> 
>     which python
> 
> at your prompt, and see which Python your system finds first.

Yeah, that was the problem. Thanks! I actually had binaries for 1.5 and
1.6 in /usr/bin and a 2.0 binary in /usr/local/bin. Deleting the binaries
in /usr/bin did the trick. I can now get the cgi programs to work and I
was able to compile PgSQL and connect to my database, so I should be in
business.

Is there a best way to use python for web programming? I've used php in
the past to create small scripts that process user input or query a
database. But I'd like to start working on something larger and I'd 
like to use Python. Python looks more powerful, and the scripts I've
written in it so far have been cleaner looking that the same ones
php. I've looked at mod_python but I guess I don't understand what it does
(despite having read the documentation and installed it). Is something
like this recommended?



From deirdre@deirdre.net  Thu Nov  9 02:14:30 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Wed, 8 Nov 2000 18:14:30 -0800 (PST)
Subject: Web Scripting with Python. (was Re: [Tutor] Where is PYTHONPATH
 set?)
In-Reply-To: <Pine.LNX.4.20.0011081946480.3473-100000@localhost.localdomain>
Message-ID: <Pine.LNX.4.10.10011081812390.29939-100000@rockhopper.deirdre.org>

On Wed, 8 Nov 2000 mbc2@netdoor.com wrote:

> Is there a best way to use python for web programming? I've used php
> in the past to create small scripts that process user input or query a
> database. But I'd like to start working on something larger and I'd
> like to use Python. Python looks more powerful, and the scripts I've
> written in it so far have been cleaner looking that the same ones php.
> I've looked at mod_python but I guess I don't understand what it does
> (despite having read the documentation and installed it). Is something
> like this recommended?

I actually use PHP for web scripting and python for all the post and pre
processing (i.e. schlepping stuff into and out of databases). The display
is all PHP3 because I find it easier.

mod_python is a persistent python interpreter which will reduce the amount
of time your programs take to return a response (because it won't have to
launch an interpreter).

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"You had thesaurus flakes for breakfast again, didn't you?"
                                                 -- Eric Williams



From babyboy@oninet.pt  Thu Nov  9 02:32:09 2000
From: babyboy@oninet.pt (wilson edgar pinto)
Date: Thu, 9 Nov 2000 02:32:09 -0000
Subject: [Tutor] (no subject)
Message-ID: <001001c049f5$43886000$460c3ad5@x0q0w3>

This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C049F5.429EEA60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


hiya
hi i'm having a bit of a trouble understanding this error message, =
because i can't what's wrong in the code. this transposes almost all the =
code, and i get an error on the first print command (in bold) it =
"Invalid syntax, how come???, and since is correctly indented and in =
some previous version the same thing worked perfectly, i don't quite get =
why it doesn't work now.
oh this is was taken from a tutorial about using python in dynamic pages =
with apache.
help is welcomed
thankx in advance
wilson edgar

#!/python20/python
# calendin2.py - calend=E1rio dinamico - vers=E3o 2

print 'Content-type: text/html\n'

try:
    from time import time, localtime
    from calendar import monthcalendar
    from string import join

    ano, mes, hoje =3D localtime(localtime(time())[:3]

    print '<HTML><TITLE>Calend=E1rio dinamico</TITLE>'
    print '<BODY>'
    print '<CENTER>'
    print '<H1>Calend=E1rio de %s/%s</H1>' % (ano,mes)
    print '<TABLE>'
    print '<TR>'
    for dia_sem in ['seg','ter','qua','qui','sex','sab','dom']:
        if dia_sem in ['sab','dom']: bgcolor =3D 'green'
        else: bgcolor =3D 'blue'
        print '<th width=3D"45" BGCOLOR=3D"%s">'% bgcolor
        print '<H3>%s</H3></TH>' % dia_sem
    print '</TR>'
    for semana in monthcalendar(ano,mes):
        print'<TR>'
        num_dia_sem =3D 0
        for dia in semana:
            if dia =3D=3D hoje:
                bgclor=3D 'pink'
            elif num_dia_sem >=3D 5:
                bgcolor =3D 'ligthgreen'
            else:
                bgcolor =3D 'ligthblue'
            print '<td align=3D"rigth" bgcolor=3D"%s">' % bgcolor
            if dia !=3D 0:
                print '0<H2>%2d</H2>' % dia
            print '</TD>'
            num_dia_sem =3D num_ida_sem + 1
        print '</TR>'
    print '</TABLE></CENTER>'

except:
    import sys
    from traceback import print_exc
    sys.stderr =3D sys.stdout
    print '<HR><H3>Erro no CGI:</H3><PRE>'
    print_exc()
    print '</PRE>'
           =20



------=_NextPart_000_000D_01C049F5.429EEA60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>hiya<BR>hi i'm having a bit of a =
trouble=20
understanding this error message, because i can't what's wrong in the =
code. this=20
transposes almost all the code, and i get an error on the first print =
command=20
(in bold) it "Invalid syntax, how come???,&nbsp;and since is correctly =
indented=20
and in some previous version the same thing worked perfectly, i don't =
quite get=20
why it doesn't work now.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>oh this is was taken from a tutorial =
about using=20
python in dynamic pages with apache.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>help is welcomed</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>thankx in advance</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>wilson edgar</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#!/python20/python<BR># calendin2.py - =
calend=E1rio=20
dinamico - vers=E3o 2</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>print 'Content-type: =
text/html\n'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>try:<BR>&nbsp;&nbsp;&nbsp; from time =
import time,=20
localtime<BR>&nbsp;&nbsp;&nbsp; from calendar import=20
monthcalendar<BR>&nbsp;&nbsp;&nbsp; from string import join</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; ano, mes, hoje =3D=20
localtime(localtime(time())[:3]</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; <FONT =
size=3D3><STRONG>print=20
'&lt;HTML&gt;&lt;TITLE&gt;Calend=E1rio=20
dinamico&lt;/TITLE&gt;'</STRONG></FONT><BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;BODY&gt;'<BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;CENTER&gt;'<BR>&nbsp;&nbsp;&nbsp; print '&lt;H1&gt;Calend=E1rio de=20
%s/%s&lt;/H1&gt;' % (ano,mes)<BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;TABLE&gt;'<BR>&nbsp;&nbsp;&nbsp; print =
'&lt;TR&gt;'<BR>&nbsp;&nbsp;&nbsp;=20
for dia_sem in=20
['seg','ter','qua','qui','sex','sab','dom']:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;=20
if dia_sem in ['sab','dom']: bgcolor =3D=20
'green'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else: bgcolor =3D=20
'blue'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print '&lt;th =
width=3D"45"=20
BGCOLOR=3D"%s"&gt;'% =
bgcolor<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'&lt;H3&gt;%s&lt;/H3&gt;&lt;/TH&gt;' % dia_sem<BR>&nbsp;&nbsp;&nbsp; =
print=20
'&lt;/TR&gt;'<BR>&nbsp;&nbsp;&nbsp; for semana in=20
monthcalendar(ano,mes):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
print'&lt;TR&gt;'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
num_dia_sem =3D=20
0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for dia in=20
semana:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; if=20
dia =3D=3D=20
hoje:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
bgclor=3D=20
'pink'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
elif num_dia_sem &gt;=3D=20
5:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;=20
bgcolor =3D=20
'ligthgreen'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
bgcolor =3D=20
'ligthblue'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
print '&lt;td align=3D"rigth" bgcolor=3D"%s"&gt;' %=20
bgcolor<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; if=20
dia !=3D=20
0:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;=20
print '0&lt;H2&gt;%2d&lt;/H2&gt;' %=20
dia<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 print=20
'&lt;/TD&gt;'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
num_dia_sem =3D num_ida_sem + =
1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
print '&lt;/TR&gt;'<BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;/TABLE&gt;&lt;/CENTER&gt;'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>except:<BR>&nbsp;&nbsp;&nbsp; import=20
sys<BR>&nbsp;&nbsp;&nbsp; from traceback import =
print_exc<BR>&nbsp;&nbsp;&nbsp;=20
sys.stderr =3D sys.stdout<BR>&nbsp;&nbsp;&nbsp; print =
'&lt;HR&gt;&lt;H3&gt;Erro no=20
CGI:&lt;/H3&gt;&lt;PRE&gt;'<BR>&nbsp;&nbsp;&nbsp;=20
print_exc()<BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;/PRE&gt;'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_000D_01C049F5.429EEA60--



From DOUGS@oceanic.com  Thu Nov  9 02:39:48 2000
From: DOUGS@oceanic.com (Doug Stanfield)
Date: Wed, 8 Nov 2000 16:39:48 -1000
Subject: [Tutor] (no subject)
Message-ID: <8457258D741DD411BD3D0050DA62365907A3FB@huina.oceanic.com>

[wilson edgar pinto asked:]
>hi i'm having a bit of a trouble understanding this error message, because 
>i can't what's wrong in the code. this transposes almost all the code, and 
>i get an error on the first print command (in bold) it "Invalid syntax, how
come???, 

You need to look at the number of parentheses.  Because you have an unclosed
parentheses Python thinks the next line, your print statement, is part of
the line:

ano, mes, hoje = localtime(localtime(time())[:3]

HTH,

-Doug-


From DOUGS@oceanic.com  Thu Nov  9 02:47:55 2000
From: DOUGS@oceanic.com (Doug Stanfield)
Date: Wed, 8 Nov 2000 16:47:55 -1000
Subject: Web Scripting with Python. (was Re: [Tutor] Where is PYTHONPA
 TH set?)
Message-ID: <8457258D741DD411BD3D0050DA62365907A3FC@huina.oceanic.com>

[You asked:]
> Is there a best way to use python for web programming? I've 
> used php in
> the past to create small scripts that process user input or query a
> database. But I'd like to start working on something larger and I'd 
> like to use Python. Python looks more powerful, and the scripts I've
> written in it so far have been cleaner looking that the same ones
> php. I've looked at mod_python but I guess I don't understand 
> what it does
> (despite having read the documentation and installed it). Is something
> like this recommended?

I wouldn't get wrapped up in looking at stuff like mod-python and the like
at this stage in your work.  Those are primarily useful to give a high
demand web site a boost in performance.  If you're just learning, by
definition you're not there.

The biggest problem at this point is reconceptualizing what you know from
using other systems (php) to use Python.

[Before I can hit the send button Deirdre S. imparts wisdom:]
> I actually use PHP for web scripting and python for all the post and pre
> processing (i.e. schlepping stuff into and out of databases). The display
> is all PHP3 because I find it easier.

Which is probably great advice for you, coming from PHP.  I personally would
look at the various Python based systems that are being developed.  One that
looks promising to me is:

Webware for Python, http://webware.sourceforge.net

-Doug-


From deirdre@deirdre.net  Thu Nov  9 02:45:07 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Wed, 8 Nov 2000 18:45:07 -0800 (PST)
Subject: Web Scripting with Python. (was Re: [Tutor] Where is PYTHONPA
 TH set?)
In-Reply-To: <8457258D741DD411BD3D0050DA62365907A3FC@huina.oceanic.com>
Message-ID: <Pine.LNX.4.10.10011081843500.29939-100000@rockhopper.deirdre.org>

On Wed, 8 Nov 2000, Doug Stanfield wrote:

> [Before I can hit the send button Deirdre S. imparts wisdom:]
> > I actually use PHP for web scripting and python for all the post and pre
> > processing (i.e. schlepping stuff into and out of databases). The display
> > is all PHP3 because I find it easier.
> 
> Which is probably great advice for you, coming from PHP. 

Actually, I went the other way. I knew Python two years prior to learning
PHP.

> I personally would look at the various Python based systems that are
> being developed.  One that looks promising to me is:

Noted.

But PHP really IS very much web-optimized, which is why I like it for
that.

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"You had thesaurus flakes for breakfast again, didn't you?"
                                                 -- Eric Williams



From rmallett@rational.com  Thu Nov  9 07:56:59 2000
From: rmallett@rational.com (Mallett, Roger)
Date: Wed, 8 Nov 2000 23:56:59 -0800
Subject: [Tutor] Why does L[3:2] =['test'] differ from L[3]=['test']
Message-ID: <D1F8EEAA065FD411B7E200D0B73EB0EA0108402B@CUPEX2.rational.com>

If a list L=[1, 2, 3, 4, 5]

then L[3:2]=['test'] yields -> [1, 2, 3, 'test', 5]

however, L[3]=['test'] yields -> [1, 2, 3, ['test'], 5]

Why do the results differ?  (one inserts a string into the list, but the
other inserts a list into the list.)

Roger Mallett


From wheelege@tsn.cc  Thu Nov  9 08:25:54 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Thu, 9 Nov 2000 19:25:54 +1100
Subject: [Tutor] Why does L[3:2] =['test'] differ from L[3]=['test']
References: <D1F8EEAA065FD411B7E200D0B73EB0EA0108402B@CUPEX2.rational.com>
Message-ID: <013a01c04a26$b1fc79a0$a410fea9@glen>

The results differ so you can still reference the nested list, I believe.
In case it has more than one value.

Like if the list you were putting in was [1, 2, 3] then the resultant would
be [1, 2, 3, [1, 2, 3], 5] and then it would be significant.

Sorry I'm still new to this.  Hope I helped.

Glen.

----- Original Message ----- 
From: Mallett, Roger <rmallett@rational.com>
To: <tutor@python.org>
Sent: Thursday, November 09, 2000 6:56 PM
Subject: [Tutor] Why does L[3:2] =['test'] differ from L[3]=['test']


> If a list L=[1, 2, 3, 4, 5]
> 
> then L[3:2]=['test'] yields -> [1, 2, 3, 'test', 5]
> 
> however, L[3]=['test'] yields -> [1, 2, 3, ['test'], 5]
> 
> Why do the results differ?  (one inserts a string into the list, but the
> other inserts a list into the list.)
> 
> Roger Mallett
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor



From arcege@shore.net  Thu Nov  9 12:46:22 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Thu, 9 Nov 2000 07:46:22 -0500 (EST)
Subject: [Tutor] Why does L[3:2] =['test'] differ from L[3]=['test']
In-Reply-To: <D1F8EEAA065FD411B7E200D0B73EB0EA0108402B@CUPEX2.rational.com> from "Mallett, Roger" at Nov 08, 2000 11:56:59 PM
Message-ID: <200011091246.HAA28062@northshore.shore.net>

> 
> If a list L=[1, 2, 3, 4, 5]
> 
> then L[3:2]=['test'] yields -> [1, 2, 3, 'test', 5]
> 
> however, L[3]=['test'] yields -> [1, 2, 3, ['test'], 5]
> 
> Why do the results differ?  (one inserts a string into the list, but the
> other inserts a list into the list.)
> 
> Roger Mallett

Hi Roger,

The difference is between "indexing" and "slicing".  Specifying a range
of indices in a sequence will return a subsequence.

>>> L = [ 1, 2, 3, 4, 5 ]
>>> L[3:2]
[]
>>> L[3:4]
[4]
>>> L[3]
4
>>> L[3:]
[4, 5]
>>>

Notice the difference in the value returned by L[3:4] (a slice) and
L[3] (an index), the first returns a list containing an element, the
second returns the element itself.  When you assign, you will be
replacing that part of the list.  For an index, just the element is
changed; for a slice, the subsequence is replaced.  It is important to
also notice that L[3:2], where the first index is greater than or
equal to the second index, will return an empty list - because you are
looking _between_ the elements.

>>> L[3] = 'spam'
>>> L
[1, 2, 3, 'spam', 5]
>>> L[3] = [2, 3]
>>> L
[1, 2, 3, [2, 3], 5]
>>> L[3:4] = [2, 3]
>>> L
[1, 2, 3, 2, 3, 5]
>>> L[3:2] = ['eggs', 'spam']
>>> L
[1, 2, 3, 'eggs', 'spam', 2, 3, 5]

In the second assignment (using an index) a list is being set, so the
list contains a sublist.  In the third (using a slice), the sublist
is replaced with two elements, instead of one (length increases by one).

Also notice that the assignment to the slice that was _between_
elements, L[3:2] (or L[3:3]), inserts new elements instead of replacing
them.

  -Arcege

References:
* Python Tutorial, section 3.1.4 Lists
<URL:http://www.python.org/doc/current/tut/node5.html>
* Python Library Reference, section 2.1.5.4 Mutable Sequence Types
<URL:http://www.python.org/doc/current/lib/typesseq-mutable.html>
* Python Reference Manual, section 5.3.3 Slicings
<URL:http://www.python.org/doc/current/ref/slicings.html>
* Python Reference Manual, section 6.3 Assignment statements
<URL:http://www.python.org/doc/current/ref/assignment.html>

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------


From FxItAL@aol.com  Thu Nov  9 14:26:40 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Thu, 9 Nov 2000 09:26:40 EST
Subject: [Tutor] Installer
Message-ID: <f2.45f8edb.273c0e20@aol.com>

Hello All,

    I've downloaded the windows installer from 
http://www.mcmillan-inc.com/install1.html.  While running SetupTk.py I 
received the following Error Messages:

analyzing _tkinter
    found kernel32.dll
    found tcl80.dll
    lib not found:  tcl80.dll dependency of found tk80.dll
    lib not found:  tk80.dll dependency of found python15.dll
    found MSVCRT.DLL
Could not find tcl binarys!
Operation aborted

Thanks for any help with this,
Al


From jcosby@wolfenet.com  Fri Nov 10 00:42:26 2000
From: jcosby@wolfenet.com (Jon Cosby)
Date: Thu, 9 Nov 2000 16:42:26 -0800
Subject: [Tutor] CGI call
Message-ID: <LPBBIFMLBAOCBOGCEMGAEEJNCAAA.jcosby@wolfenet.com>

I have a simple hit counter and I don't know how to call it from my web
page. Looking at a similar script, I've tried the line

<!--#include virtual="cgi-bin/counter.py" -->,

but this doesn't do it. The script only runs when I link directly to it. The
counter script is below. What do I need to change?


Jon Cosby

-----------------------------------------------------------
print "Content-type: text/html"
print
print "<HEAD><TITLE>Python Hit Counter</TITLE></HEAD>"
print "<BODY>"

InFile = open("C:\Inetpub\wwwroot\cgi-bin\count.dat", "r")
Hits = InFile.readline()
x = int(Hits) + 1
InFile.close()
OutFile = open(DataFile, "w")
OutFile.write(str(x))
OutFile.close()

print "<P><H2>Jon Cosby's web page - Total hits: ", str(x)
print "</H2></BODY>"
------------------------------------------------------------


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.209 / Virus Database: 99 - Release Date: 11/2/2000



From FxItAL@aol.com  Sat Nov 11 00:16:02 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Fri, 10 Nov 2000 19:16:02 EST
Subject: [Tutor] Simple Question, pun intended :-)
Message-ID: <c4.b8163fe.273de9c2@aol.com>

Hello All,

    I cannot fully express my elation at successfully getting simple to run 
and take  the first steps to distribution.

    After Simple.py created the distribution files I installed it in a test 
directory,  when I ran the .exe the DOS box still appears in the background.  
What do I need to do to eliminate it?

Thanks for all the help. I'd be completely lost without the Tutors.
Al


From dyoo@hkn.eecs.berkeley.edu  Sat Nov 11 00:51:01 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 10 Nov 2000 16:51:01 -0800 (PST)
Subject: [Tutor] Hotfolder 1st attempt
In-Reply-To: <3A096D27.1A017410@zenplex.com>
Message-ID: <Pine.LNX.4.21.0011101627550.8695-100000@hkn.eecs.berkeley.edu>

> Daniel Yoo wrote:
> 
> > On Mon, 6 Nov 2000, Scott Ralph wrote:
> >
> > > from time import *
> > > from stat import *
> >
> > The only thing I could point out is that you might not want to import
> > everything within time or stat.  You can be more specific, like:
> >
> >     from time import sleep
> >
> > It's considered good practice to pull out only the functionality that you
> > need from modules; that way, people can see exactly which functions you're
> > using from other modules.

> Thanks for the feedback, I removed the S_ISREG(mode) I didn't need it.  
> Does your first suggestion also speed things up? from time import
> sleep.  Thanks again for the feedback.


It's not really a matter of a speedup.  The main reason for importing
those functions explicitly is to get in the habit.  Otherwise, you might
get bitten by naming conflicts between modules later on.  These conflicts
can occur more regularly than you'd expect.  For example, you take a look
at the index of all functions here:

    http://python.org/doc/current/lib/genindex.html

and you'll see that at least 20 separate modules define their own
open() method!


This makes more sense with a small example with the math and cmath
modules.

    http://python.org/doc/current/lib/module-math.html
    http://python.org/doc/current/lib/module-cmath.html

cmath does almost the same stuff as math, except that cmath's functions
can work with complex numbers.  If we look, we'll notice that they have
exactly the same function names.  So if we did something like this:

###
>>> from cmath import exp
>>> from math import *   # <--- bad, bad!
>>> print exp(10 + 2j)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: can't convert complex to float; use e.g. abs(z)
###

we'd get confused for a long time, until we see that exp() is math's
definition of exp(), not cmath's.  This is obviously an artificial
example, but I've seen many situations like this to be wary.

Perhaps the Python implementers would be willing to define a safer
importing scheme that would give a warning if naming conflicts occur.  
Until then, you'll need to be careful, and avoid using 'from module import
*' unless that module is designed well.

Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Sat Nov 11 00:58:03 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 10 Nov 2000 16:58:03 -0800 (PST)
Subject: [Tutor] Simple Question, pun intended :-)
In-Reply-To: <c4.b8163fe.273de9c2@aol.com>
Message-ID: <Pine.LNX.4.21.0011101651360.9819-100000@hkn.eecs.berkeley.edu>

On Fri, 10 Nov 2000 FxItAL@aol.com wrote:

>     I cannot fully express my elation at successfully getting simple
> to run and take the first steps to distribution.

Cool!  I'm glad that it's working well.


>     After Simple.py created the distribution files I installed it in a
> test directory, when I ran the .exe the DOS box still appears in the
> background.  What do I need to do to eliminate it?

There's a specific program called 'pythonw.exe' that's designed to execute
python programs without bringing up the dos window.  I'm not sure how you
froze the programs, but see if there's a way for it to work with
pythonw.exe instead of python.exe.

As a first guess, try to rename your python scripts from '.py' files to
'.pyw' files, and apply Simple.py on that.  Perhaps that will
automatically bundle pythonw.exe into your program.

Good luck!



From devanshd@yahoo.com  Sat Nov 11 16:31:51 2000
From: devanshd@yahoo.com (Devansh)
Date: Sat, 11 Nov 2000 10:31:51 -0600
Subject: [Tutor] Undrawing text
Message-ID: <00d601c04bfc$e5758560$771511ac@wartburg.edu>

This is a multi-part message in MIME format.

------=_NextPart_000_00D3_01C04BCA.9A5C6F80
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hi everyone.....
i have a kinda small prob.=20
in my graphics window i want to update a count for every mouse click i =
make.......
what my code is doing is just drawing the new numbers on top the of the =
old ones so it becomes illegible after the 2nd cklick already......

heres a section of the code.
count=3Dcount+1
counter=3DText(Point(320,240),count).draw(win1)

if i use counter.undraw(win1) it gives me an attribute error.......
pls advise.....thanx

Devansh Dhutia
P.O.Box 105
222 Ninth St. N.W.
Waverly, Iowa 50677-0903
Tel: 319-352-7302
@ : dhutiad@wartburg.edu
       devanshd@yahoo.com
ICQ UIN- 5674041
http://www.desktopdollars.com/default.asp?id=3Ddevanshd


------=_NextPart_000_00D3_01C04BCA.9A5C6F80
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4207.2601" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>hi everyone.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i have a kinda small prob. =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>in my graphics window i want to update =
a count for=20
every mouse click i make.......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>what my code is doing is just drawing =
the new=20
numbers on top the of the old ones so it becomes illegible after the 2nd =
cklick=20
already......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>heres a section of the =
code.</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>count=3Dcount+1<BR>counter=3DText(Point(320,240),count).draw(win=
1)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>if i use counter.undraw(win1) it gives =
me an=20
attribute error.......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>pls advise.....thanx</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Devansh Dhutia<BR>P.O.Box 105<BR>222 =
Ninth St.=20
N.W.<BR>Waverly, Iowa 50677-0903<BR>Tel: 319-352-7302<BR>@ : <A=20
href=3D"mailto:dhutiad@wartburg.edu">dhutiad@wartburg.edu</A><BR>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<A href=3D"mailto:devanshd@yahoo.com">devanshd@yahoo.com</A><BR>ICQ UIN- =

5674041<BR><A=20
href=3D"http://www.desktopdollars.com/default.asp?id=3Ddevanshd">http://w=
ww.desktopdollars.com/default.asp?id=3Ddevanshd</A><BR></FONT></DIV></BOD=
Y></HTML>

------=_NextPart_000_00D3_01C04BCA.9A5C6F80--


__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com


From FxItAL@aol.com  Sat Nov 11 20:42:11 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Sat, 11 Nov 2000 15:42:11 EST
Subject: [Tutor] Making Smaller Executables with Simple.py?
Message-ID: <9e.c15f15c.273f0923@aol.com>

Hello Again,

    OK, I've used the following to create an executable without a console:
                python simple.py script.pyw -tk

My original Script file is only 6KB after running simple.py I have over 
1.5MG, how can I streamline this or is there another (easy:-) way to create 
an .exe

Python 1.5.2 on Win ME

Thanks for your time, AL


From dyoo@hkn.eecs.berkeley.edu  Sat Nov 11 21:52:07 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 11 Nov 2000 13:52:07 -0800 (PST)
Subject: [Tutor] Re: Making Smaller Executables with Simple.py?
In-Reply-To: <9e.c15f15c.273f0923@aol.com>
Message-ID: <Pine.LNX.4.21.0011111345100.23879-100000@hkn.eecs.berkeley.edu>

On Sat, 11 Nov 2000 FxItAL@aol.com wrote:

>     OK, I've used the following to create an executable without a console:
>                 python simple.py script.pyw -tk
> 
> My original Script file is only 6KB after running simple.py I have over 
> 1.5MG, how can I streamline this or is there another (easy:-) way to create 
> an .exe

Did the '.pyw' actually get it to build it with pythonw.exe?  If so, I'm
glad; I was making a wild guess that it would work... *grin*

The problem with making Python binaries is that Simple.py needs to include
enough of the runtime system to work.  Unfortunately, the runtime system
is itself a little large, and that's probably the part that's taking up
the most space.

Unless your friends are willing to install Python, I'm not sure if there's
any way of getting around the large binary size.



From DOUGS@oceanic.com  Sat Nov 11 22:23:26 2000
From: DOUGS@oceanic.com (Doug Stanfield)
Date: Sat, 11 Nov 2000 12:23:26 -1000
Subject: [Tutor] Re: Making Smaller Executables with Simple.py?
Message-ID: <8457258D741DD411BD3D0050DA62365907A40B@huina.oceanic.com>

[FxItAL@aol.com wrote:]
> 
> >     OK, I've used the following to create an executable 
> without a console:
> >                 python simple.py script.pyw -tk
> > 
> > My original Script file is only 6KB after running simple.py 
> I have over 
> > 1.5MG, how can I streamline this or is there another 
> (easy:-) way to create 
> > an .exe

[to which Daniel Yoo replied:]
> The problem with making Python binaries is that Simple.py 
> needs to include
> enough of the runtime system to work.  Unfortunately, the 
> runtime system
> is itself a little large, and that's probably the part that's 
> taking up the most space.
> 
> Unless your friends are willing to install Python, I'm not 
> sure if there's
> any way of getting around the large binary size.

Exactly.  But consider that alternative.  The Python 2.0 download is about
5.5 MB and seems to expand to fill almost 18 MB.  Your 1.5MB seems
reasonable in comparison.

I may be wrong, but I thing what Gordon's installer does is strip as much in
the way of unused libraries as it can before packaging things.  It may be
possible to do better by compiling a more stripped down core Python than the
standard distribution, keeping only those things you need.  I doubt this
would be worth the time.  At any rate, as you build bigger and more
complicated programs to package, your distribution size shouldn't increase
all that much.

-Doug-


From deng@ms.shlftdc.net.cn  Mon Nov 13 07:24:29 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Mon, 13 Nov 2000 15:24:29 +0800
Subject: [Tutor] issue about startup file of python
Message-ID: <00f401c04d42$c36f3780$d7c809c0@deng>

hello,every:
    I am using python in command mode under windows98.
I don't know how to write a startup file in this situation.
I always starting python using following methods,assuming the python was
installed at c:\python.
c:\>python
copyright,notice.....etc
>>>import mystartup.py
>>>

  How can i do? thanks.




From dyoo@hkn.eecs.berkeley.edu  Mon Nov 13 12:16:27 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Mon, 13 Nov 2000 04:16:27 -0800 (PST)
Subject: [Tutor] issue about startup file of python
In-Reply-To: <00f401c04d42$c36f3780$d7c809c0@deng>
Message-ID: <Pine.LNX.4.21.0011130415430.20762-100000@hkn.eecs.berkeley.edu>

On Mon, 13 Nov 2000, deng wei wrote:

> hello,every:
>     I am using python in command mode under windows98.
> I don't know how to write a startup file in this situation.
> I always starting python using following methods,assuming the python was
> installed at c:\python.
> c:\>python
> copyright,notice.....etc
> >>>import mystartup.py
> >>>
> 
>   How can i do? thanks.

You don't need to append '.py' when you do imports.

    import mystartup

should be enough, assuming that 'mystartup.py' is in your c:\>
directory.  Hope this helps!



From SBrunning@trisystems.co.uk  Mon Nov 13 12:19:23 2000
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Mon, 13 Nov 2000 12:19:23 -0000
Subject: [Tutor] issue about startup file of python
Message-ID: <31575A892FF6D1118F5800600846864D5B140D@intrepid>

If you have a module called site.py in your Python path, it gets run on
startup.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk

> -----Original Message-----
> From:	deng wei [SMTP:deng@ms.shlftdc.net.cn]
> Sent:	Monday, November 13, 2000 7:24 AM
> To:	tutor@python.org
> Subject:	[Tutor] issue about startup file of python
> 
> hello,every:
>     I am using python in command mode under windows98.
> I don't know how to write a startup file in this situation.
> I always starting python using following methods,assuming the python was
> installed at c:\python.
> c:\>python
> copyright,notice.....etc
> >>>import mystartup.py
> >>>
> 
>   How can i do? thanks.
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 
> 
> 
> 
-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.


From dyoo@hkn.eecs.berkeley.edu  Mon Nov 13 20:52:17 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Mon, 13 Nov 2000 12:52:17 -0800 (PST)
Subject: [Tutor] Undrawing text
In-Reply-To: <00d601c04bfc$e5758560$771511ac@wartburg.edu>
Message-ID: <Pine.LNX.4.21.0011131248310.23423-100000@hkn.eecs.berkeley.edu>

On Sat, 11 Nov 2000, Devansh wrote:

> in my graphics window i want to update a count for every mouse click i
> make....... what my code is doing is just drawing the new numbers on
> top the of the old ones so it becomes illegible after the 2nd cklick
> already......

> heres a section of the code.
> count=count+1
> counter=Text(Point(320,240),count).draw(win1)
> 
> if i use counter.undraw(win1) it gives me an attribute error.......
> pls advise.....thanx

Text widgets don't have an undraw() as far as I can tell.  However, they
do have a delete() method that works.  Here's a way of clearing your Text
widget:

   counter.delete("@0,0", END)

which means "Delete everything starting from position 0,0 to the END".  I
have to admit that I have absolutely NO experience with the Text widget,
so there may be a better way of doing this.  (I've only glanced at my
"Python and Tkinter Programming" book.)

Again, sorry for the long wait on that one; I was hoping someone else
would be familiar with Tkinter... *sigh*



From alan.gauld@freenet.co.uk  Mon Nov 13 23:05:26 2000
From: alan.gauld@freenet.co.uk (Alan Gauld)
Date: Mon, 13 Nov 2000 23:05:26 +0000
Subject: [Tutor] Spanish tutor complete
Message-ID: <3.0.1.32.20001113230526.0156ee40@mail.freenet.co.uk>

Just to announce that Martin Pozzi has completed the Spanish 
translation of my tutor. My thanks to him for all his hard work.

The Spanish site is at:

http://www.crosswinds.net/~agauld/spanish/

The main English tutor has been getting updated with lots more 
QBASIC and Tcl examples and some new Python bits too. Martin 
will be folding some of the changes into the Spanish version 
in due course but is taking a well deserved break first.

Enjoy,

Alan G.
Currently struggling with Java (again)
- who would invent a language without an easy way to read 
  stdin!!! sheesh!



From wilkins@iinet.net.au  Mon Nov 13 12:16:10 2000
From: wilkins@iinet.net.au (Richard Wilkins)
Date: Mon, 13 Nov 2000 20:16:10 +0800
Subject: [Tutor] TKinter - mouse -> text
Message-ID: <MABBIFAJGJIHIKKDOGHOMEEECCAA.wilkins@iinet.net.au>

Hi,

I'm no expert on TKinter...actually I'm as newbie as they get, but for
this exercise, why not use the Label widget. I know Label has a 'text'
option, which when updated does the obvious and updates the text in your
window.

http://www.pythonware.com/library/tkinter/introduction/x4880-options.htm

Hope this helps, have fun,
Andrew Wilkins

> in my graphics window i want to update a count for every mouse click i
> make....... what my code is doing is just drawing the new numbers on
> top the of the old ones so it becomes illegible after the 2nd cklick
> already......

> heres a section of the code.
> count=count+1
> counter=Text(Point(320,240),count).draw(win1)
>
> if i use counter.undraw(win1) it gives me an attribute error.......
> pls advise.....thanx




From dsh8290@rit.edu  Tue Nov 14 01:24:06 2000
From: dsh8290@rit.edu (D-Man)
Date: Mon, 13 Nov 2000 20:24:06 -0500
Subject: [Tutor] CGI and other stuff
Message-ID: <20001113202406.A18291@dman.rh.rit.edu>

Hi all.

I'm trying to write a couple of cgi scripts to dynamically create some web pages.  I have finally figured out how to access the query string.  Now I would like some suggestions as to the best way to parse it.  The parsing method as well as the format of the string is completely at my discretion.  

Does tkinter ship with python 2.0?  I have a RH7.0 box and I recently built Pyrhon 2.0 but it doesn't seem to have the tkinter module so I can't run some programs I have.  Also, how can I make sure stuff works with and installs to version 2.0?  I have installed some modules (ex pygtk and postgresql-python) but they are in /usr/lib/python1.5/... (where the 1.5.2 interpreter used to be).

Thanks in advance for all of your expert advice ;-).

-D



From jcm@bigskytel.com  Tue Nov 14 03:10:17 2000
From: jcm@bigskytel.com (David Porter)
Date: Mon, 13 Nov 2000 20:10:17 -0700
Subject: [Tutor] CGI and other stuff
In-Reply-To: <20001113202406.A18291@dman.rh.rit.edu>; from dsh8290@rit.edu on Mon, Nov 13, 2000 at 08:24:06PM -0500
References: <20001113202406.A18291@dman.rh.rit.edu>
Message-ID: <20001113201017.A17938@bigskytel.com>

* D-Man <dsh8290@rit.edu>:

> I'm trying to write a couple of cgi scripts to dynamically create some web
> pages.  I have finally figured out how to access the query string.  Now I
> would like some suggestions as to the best way to parse it.  The parsing
> method as well as the format of the string is completely at my discretion.

If I understand you correctly, something like this is what you want:

import cgi
form = cgi.FieldStorage()

Then you can use form as you would a dictionary with key/value pairs:

if form.has_key("edit"):
    if form["edit"].value == "add":
        add_node()
    elif form["edit"].value == "delete":
        delete_node()

http://url/script?edit=add would then cause the function add_node() to run.


hth,
David


From babyboy@oninet.pt  Tue Nov 14 03:31:14 2000
From: babyboy@oninet.pt (wilson edgar pinto)
Date: Tue, 14 Nov 2000 03:31:14 -0000
Subject: [Tutor] (no subject)
Message-ID: <001301c04deb$57ffa940$560d3ad5@x0q0w3>

This is a multi-part message in MIME format.

------=_NextPart_000_000E_01C04DEB.572D1700
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


hiya
running a code on DOS window, everything runs perfectly alrigth except =
of=20
'import site' failed; use -v for traceback
what does it means, and why does it appears if everything is alrigth??
thankx in advance

------=_NextPart_000_000E_01C04DEB.572D1700
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>hiya<BR>running a code on DOS window, =
everything=20
runs perfectly alrigth except of </FONT></DIV>
<DIV><FONT face=3DArial size=3D2><EM>'import site' failed; use -v for=20
traceback</EM><BR>what does it means, and why does it appears if =
everything is=20
alrigth??</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>thankx in =
advance</FONT></DIV></BODY></HTML>

------=_NextPart_000_000E_01C04DEB.572D1700--



From SBrunning@trisystems.co.uk  Tue Nov 14 09:32:21 2000
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Tue, 14 Nov 2000 09:32:21 -0000
Subject: [Tutor] (no subject)
Message-ID: <31575A892FF6D1118F5800600846864D5B141E@intrepid>

> From:	wilson edgar pinto [SMTP:babyboy@oninet.pt]
> hiya
> running a code on DOS window, everything runs perfectly alrigth except of 
> 'import site' failed; use -v for traceback
> what does it means, and why does it appears if everything is alrigth??
> thankx in advance
 
If you have a file called site.py in your python path, it is automatically
imported when you start up Python. In your case, you have such a file, but
there is something wrong with it. Python is being helpful here - it isn't
falling over or anything, it just tells you that there is a problem.

To diagnose the problem, you could either invoke Python with the -v switch
as suggested, or just type 'import site' at the python prompt. Either way,
you should get a traceback, which should (hopefully) enable you to sort out
your site.py file.

Good hunting!

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.


From alan.gauld@bt.com  Tue Nov 14 15:18:58 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 14 Nov 2000 15:18:58 -0000
Subject: [Tutor] Undrawing text
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D3F3@mbtlipnt02.btlabs.bt.co.uk>

> in my graphics window i want to update a count for every 
> mouse click i make.......

OK, What graphics system are you using? It doesn't 
look like the default Python toolkit of Tkinter...

That'll get us started.  :-)

> count=count+1
> counter=Text(Point(320,240),count).draw(win1)

Alan G.


From dsh8290@rit.edu  Tue Nov 14 15:34:44 2000
From: dsh8290@rit.edu (D-Man)
Date: Tue, 14 Nov 2000 10:34:44 -0500
Subject: [Tutor] CGI and other stuff
In-Reply-To: <20001113201017.A17938@bigskytel.com>; from jcm@bigskytel.com on Mon, Nov 13, 2000 at 22:10:17 -0500
References: <20001113202406.A18291@dman.rh.rit.edu> <"from dsh8290"@rit.edu> <20001113201017.A17938@bigskytel.com>
Message-ID: <20001114103444.A24573@dman.rh.rit.edu>

That may work, although I'm not using forms (at least in this part of the site).

The library reference doc for the cgi module says:

It's best to use the FieldStorage class. The other classes defined in this module are provided mostly for backward compatibility. Instantiate it exactly once, without arguments. This reads the form contents from standard input or the environment (depending on the value of various environment variables set according to the CGI standard). Since it may consume standard input, it should be instantiated only once. 


but it doesn't say what those environment variables are or how they affect FieldStorage.  It also mentions reading form contents, but all I want to read is a query string.

In looking through the cgi.py file to see what arguments FieldStorage might take I found the function "parse_qs(qs, keep_blank_values=0, strict_parsing=0)".  Maybe this is what I want?

Do query strings need to have "name=value" format, or can I just have "value" if I only have 1 value?  (ok, this is a dumb question: if I only have "value", I don't need to parse, only to get it from the environment)

Thanks,
-D


On Mon, 13 Nov 2000 22:10:17 David Porter wrote:
 | * D-Man <dsh8290@rit.edu>:
 | 
 | > I'm trying to write a couple of cgi scripts to dynamically create some web
 | > pages.  I have finally figured out how to access the query string.  Now I
 | > would like some suggestions as to the best way to parse it.  The parsing
 | > method as well as the format of the string is completely at my discretion.
 | 
 | If I understand you correctly, something like this is what you want:
 | 
 | import cgi
 | form = cgi.FieldStorage()
 | 
 | Then you can use form as you would a dictionary with key/value pairs:
 | 
 | if form.has_key("edit"):
 |     if form["edit"].value == "add":
 |         add_node()
 |     elif form["edit"].value == "delete":
 |         delete_node()
 | 
 | http://url/script?edit=add would then cause the function add_node() to run.
 | 
 | 
 | hth,
 | David
 | 
 | _______________________________________________
 | Tutor maillist  -  Tutor@python.org
 | http://www.python.org/mailman/listinfo/tutor
 | 




From dyoo@hkn.eecs.berkeley.edu  Tue Nov 14 16:26:45 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 14 Nov 2000 08:26:45 -0800 (PST)
Subject: [Tutor] CGI and other stuff
In-Reply-To: <20001114103444.A24573@dman.rh.rit.edu>
Message-ID: <Pine.LNX.4.21.0011140819410.18165-100000@hkn.eecs.berkeley.edu>

On Tue, 14 Nov 2000, D-Man wrote:

> but it doesn't say what those environment variables are or how they
> affect FieldStorage.  It also mentions reading form contents, but all
> I want to read is a query string.

Forms create URLS with query strings embedded into them.  If you manually
enter the query strings, you should still be able to use FieldStorage to
get at them.


> In looking through the cgi.py file to see what arguments FieldStorage
> might take I found the function "parse_qs(qs, keep_blank_values=0,
> strict_parsing=0)".  Maybe this is what I want?

If you didn't want to use FieldStorage, then you could use parse_qs on
os.environ['QUERY_STRING'].  CGI's set up your inputs within environmental
variables; try writing a CGI that prints out os.environ, and you'll see
a LOT of variables.


> Do query strings need to have "name=value" format, or can I just have
> "value" if I only have 1 value?  (ok, this is a dumb question: if I
> only have "value", I don't need to parse, only to get it from the
> environment)

From what I remember, they have to be in name/value pairs.  Since there's
a module that automatically parses the query string, you should use it; it
isn't too hard to use.

I hope this helps!



From bdempsey@charter.net  Tue Nov 14 17:25:13 2000
From: bdempsey@charter.net (Bob Dempsey)
Date: Tue, 14 Nov 2000 12:25:13 -0500
Subject: [Tutor] PythonWin history
Message-ID: <000001c04e5f$d9170cc0$0100a8c0@dempsey>

This is a multi-part message in MIME format.

------=_NextPart_000_0001_01C04E35.F04104C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am using PythonWin-Python IDE and GUI Framework For Windows.  When in =
the interactive window I can use the keystroke combination {Ctrl+Up =
Arrow} for {Ctrl+Down Arrow} to recall the history.  Is there a way to =
know how many entries there are in the history?  Or, a way to capture =
them?

Thanks, Bob
bdempsey@charter.net


------=_NextPart_000_0001_01C04E35.F04104C0
Content-Type: application/ms-tnef;
	name="winmail.dat"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="winmail.dat"

eJ8+Ig0RAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy
b3NvZnQgTWFpbC5Ob3RlADEIAQ2ABAACAAAAAgACAAEGgAMADgAAANAHCwAOAAwAGQAAAAIAFwEB
A5AGAOAFAAAnAAAACwACAAEAAAALACMAAAAAAAMAJgAAAAAACwApAAAAAAADADYAAAAAAB4AcAAB
AAAAEgAAAFB5dGhvbldpbiBoaXN0b3J5AAAAAgFxAAEAAAAWAAAAAcBOX9fhVMGnwDK2S4uswy1t
1irc9AAAAgEdDAEAAAAaAAAAU01UUDpCREVNUFNFWUBDSEFSVEVSLk5FVAAAAAsAAQ4AAAAAQAAG
DgB+5tBfTsABAgEKDgEAAAAYAAAAAAAAAEsEvfLlUdIRkk0AYGcId/vCgAAACwAfDgEAAAADAAYQ
t3/paQMABxABAQAAHgAIEAEAAABlAAAASUFNVVNJTkdQWVRIT05XSU4tUFlUSE9OSURFQU5ER1VJ
RlJBTUVXT1JLRk9SV0lORE9XU1dIRU5JTlRIRUlOVEVSQUNUSVZFV0lORE9XSUNBTlVTRVRIRUtF
WVNUUk9LRUNPTQAAAAACAQkQAQAAAIkBAACFAQAA8QEAAExaRnUOg0TeAwAKAHJjcGcxMjUWMgD4
C2BuDhAwMzP/AfcCpAPkBxMCgwBQA9QCAIRjaArAc2V0MBDGSn0KgXYIkHdrC4BkOjQMYGMAUAsD
C7UgSWAgYW0gdQCQDyAgUFB5dGgCIFcLgC0zFbQU8ERFFRATsCBHclUVAEZyFSAH0AWwawcXcAWx
FhFkb3dzLqogGFBoCfAgC4AgFdAaZRlBdASQANB0aXbvGaAD8BiCFPFjA5EVUBmgwRmCa2V5c3QD
YBvQaxsAA3BiC4BhGjAWkVyEe0McEGwrVXAQweEDYHdcfSACEArRHUSORBigA6Ad1nRvIAlwbRsQ
bAMgGYJoBAAf0HL6eRjRSQQgGYEJcBUQGnDkYXkfwmtuGsEV4Afg/wOBIiAJ8BwQCJAhZyGxGVXF
ILU/GOBPciwh2BsQ5wUwCHAbc20/CqIKhAqAIlQSIG5rcyWgQm9LDDAnM2IBAG1wElB55kASEhnh
Lm4SYCcoFGFZEXIxNickExEALAAAAAADABAQAAAAAAMAERAAAAAACwAAgAggBgAAAAAAwAAAAAAA
AEYAAAAAA4UAAAAAAAADAAKACCAGAAAAAADAAAAAAAAARgAAAAAQhQAAAAAAAAMABYAIIAYAAAAA
AMAAAAAAAABGAAAAAFKFAADwEwAAHgAlgAggBgAAAAAAwAAAAAAAAEYAAAAAVIUAAAEAAAAEAAAA
OC41AAMAJoAIIAYAAAAAAMAAAAAAAABGAAAAAAGFAAAAAAAACwAvgAggBgAAAAAAwAAAAAAAAEYA
AAAADoUAAAAAAAADADCACCAGAAAAAADAAAAAAAAARgAAAAARhQAAAAAAAAMAMoAIIAYAAAAAAMAA
AAAAAABGAAAAABiFAAAAAAAAHgBBgAggBgAAAAAAwAAAAAAAAEYAAAAANoUAAAEAAAABAAAAAAAA
AB4AQoAIIAYAAAAAAMAAAAAAAABGAAAAADeFAAABAAAAAQAAAAAAAAAeAEOACCAGAAAAAADAAAAA
AAAARgAAAAA4hQAAAQAAAAEAAAAAAAAACwDGgAsgBgAAAAAAwAAAAAAAAEYAAAAAAIgAAAAAAAAL
AMiACyAGAAAAAADAAAAAAAAARgAAAAAFiAAAAAAAAAsA1YAIIAYAAAAAAMAAAAAAAABGAAAAAAaF
AAAAAAAACwDZgAggBgAAAAAAwAAAAAAAAEYAAAAAgoUAAAEAAAACAfgPAQAAABAAAABLBL3y5VHS
EZJNAGBnCHf7AgH6DwEAAAAQAAAASwS98uVR0hGSTQBgZwh3+wIB+w8BAAAASAAAAAAAAAA4obsQ
BeUQGqG7CAArKlbCAABQU1RQUlguRExMAAAAAAAAAABOSVRB+b+4AQCqADfZbgAAAEU6XG91dGxv
b2sucHN0AAMA/g8FAAAAAwANNP03AAACAX8AAQAAADEAAAAwMDAwMDAwMDRCMDRCREYyRTU1MUQy
MTE5MjREMDA2MDY3MDg3N0ZCRTRBQzI5MDAAAAAAryE=

------=_NextPart_000_0001_01C04E35.F04104C0--



From alan.gauld@bt.com  Tue Nov 14 17:16:00 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 14 Nov 2000 17:16:00 -0000
Subject: [Tutor] Undrawing text
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D3F9@mbtlipnt02.btlabs.bt.co.uk>

> > in my graphics window i want to update a count for every 
> > mouse click i make.......
> 
> OK, What graphics system are you using? It doesn't 
> look like the default Python toolkit of Tkinter...

Hmm, I see from other posts that it is Tkinter...

> > count=count+1
> > counter=Text(Point(320,240),count).draw(win1)

So what does the draw method of the Text widget 
return? I'm curious but too lazy to go online 
and check :-/

Alan G.


From arcege@shore.net  Tue Nov 14 17:42:21 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Tue, 14 Nov 2000 12:42:21 -0500 (EST)
Subject: [Tutor] Undrawing text
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D3F9@mbtlipnt02.btlabs.bt.co.uk> from "alan.gauld@bt.com" at Nov 14, 2000 05:16:00 PM
Message-ID: <200011141742.MAA04254@northshore.shore.net>

> > > in my graphics window i want to update a count for every 
> > > mouse click i make.......
> > 
> > OK, What graphics system are you using? It doesn't 
> > look like the default Python toolkit of Tkinter...
> 
> Hmm, I see from other posts that it is Tkinter...
> 
> > > count=count+1
> > > counter=Text(Point(320,240),count).draw(win1)
> 
> So what does the draw method of the Text widget 
> return? I'm curious but too lazy to go online 
> and check :-/

That is because there is no "draw" method for Tkinter.  The initial
poster didn't mention what GUI package was being used, but I figured
out right away that it wasn't Tkinter.

  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------


From information@technojobs.co.uk  Wed Nov 15 18:38:04 2000
From: information@technojobs.co.uk (information@technojobs.co.uk)
Date: Wed, 15 Nov 2000 18:38:04 -0000
Subject: [Tutor] Search the recruitment agencies for technical jobs on-line.
Message-ID: <E13w7Qo-0007bP-00@clustermail.minx.net.uk>

Search the recruitment agencies for technical jobs on-line.

at:       http://www.technojobs.co.uk

Hundreds of new technical jobs posted every day...............

Technojobs New Advanced Site Now On-Line

Dear Job Seeker

Searching the recruitment agencies for technical jobs on-line has never been easier; our new site interface is now on line. Your new look new feel technojobs has been
updated with some top job-hunting tools. www.technojobs.co.uk

Search The Agencies
Our new advanced intelligent search tool is fast as it is accurate. Once you have used our CV centre to register your CV, simply click the link in a job add, and technojobs will automatically send your CV with a covering letter directly to that agency in reply to their job add.

CV Centre
Upload your CV via our secure site, logon at any time with your personal ID to update your CV, Activate it de-activate it, or if you're in work and looking to further your career use the Head Hunter Mode.

Jobs By Email
Our jobs by email keyword filter system, now employees the same technology that drives our main search.

Agencies
Technojobs hosts jobs for over 400 agencies, including some of the world top names in IT recruitment. We receive around 300 new technology jobs a day. If you have registered your CV with our CV centre then our agencies can search for you, we also distribute your CV when activated to agencies automatically, what's more your CV is scanned and sent to consultants that are specifically looking for candidates with your skill set.

Technojobs.co.uk Limited

Remove yourself from this mail list
Send a blank email to mailto:remove_097463@technojobs.co.uk , and place the word remove in the subject field.


From arthur.watts@gbst.com  Thu Nov 16 01:30:10 2000
From: arthur.watts@gbst.com (Arthur Watts)
Date: Thu, 16 Nov 2000 11:30:10 +1000
Subject: [Tutor] Does anyone have any hard data on Unix resource usage under Pytho
 n 2.0 ?
Message-ID: <1CDB101F0CB6D311882F0000F8063924020B372F@aquarius.bne.star.com.au>

Fellow Toilers,

	If we are to implement our 'Global Environment Management (GEM)'
system using Python, one of the questions we have to answer is 'how much
memory/CPU is this thing going to chew ?'. From past experience with Perl,
we know that every instance of a Perl process (which carries the overhead of
an interpreter) adds to the overall load on the system. This can soon bring
even a large Unix machine to its knees.

	I've started collecting some basic info from simple tools like 'ps'
and 'pmap' on Solaris and Tru64, and this is the sort of data which I
currently have -

	Note : Figures below are for 'virtual usage' (VSZ in the BSD ps
output) :

	Solaris 2.6 (total memory usage from 'pmap' command, except where
stated) :
	Perl (5.00503) - we have several processes which run almost
constantly, and ps reports that they use anywhere from 3 to 6 MB per
process. pmap reports 2.5MB for the interpreter alone. 
	Python 1.5.2 - approx 3MB for the interpreter alone
	Python 2.0 - 5.3MB for the interpreter alone

	Compaq Tru64 Unix : 'virtual memory usage' (VSZ in the BSD ps
output) :

	Perl (5.005_03) - same jobs as on the Solaris box, varying between
3MB and 7.5MB per process
	Python 1.5.2 - approx 4MB for the interpreter alone
	Python 2.0 - 7.34MB for the interpreter alone

	Freezing 'Hello.py' into a stand-alone executable produced a 1.1MB
file and reduced the memory usage from 7.34MB of virtual memory to 5.26MB.
This is still too large for a scenario where we want to fork off at least
one process for each of our users. Threading, anyone ?

	In defense of the Python 2.0 usage, this release was compiled with
static support for Tkinter : I do not believe GUI capabilities will be
required on our client sites. The above figures need a lot more examination
- using ps etc is far from conclusive - but I would be interested in any
feedback from the Python community re. their experiences with resource usage
under 2.0, particularly in cases where Python may be called upon to spawn
several hundred processes on a single Unix box. 

	The issue of benchmarking is a controversial one, whether we are
talking hardware, compilers or whatever. I realize that no development
environment can mask poor design / coding practices, and this request isn't
a Perl vs Python vs Java thing ! I don't want to get dragged into that
quagmire, but I'm more than happy to take a look at any figures that you
guys have collected using Python at the coal face.

Thanks in advance,

Arthur

Arthur Watts
Systems Integrator
GBST Holdings Ltd

'Good programmers know what to use, great programmers know what to re-use' :
Old Jungle Saying


	
 	
	


From dyoo@hkn.eecs.berkeley.edu  Thu Nov 16 09:46:52 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Thu, 16 Nov 2000 01:46:52 -0800 (PST)
Subject: [Tutor] Does anyone have any hard data on Unix resource usage
 under Pytho n 2.0 ?
In-Reply-To: <1CDB101F0CB6D311882F0000F8063924020B372F@aquarius.bne.star.com.au>
Message-ID: <Pine.LNX.4.21.0011160143090.1599-100000@hkn.eecs.berkeley.edu>

On Thu, 16 Nov 2000, Arthur Watts wrote:

> 	If we are to implement our 'Global Environment Management (GEM)'
> system using Python, one of the questions we have to answer is 'how much
> memory/CPU is this thing going to chew ?'. From past experience with Perl,
> we know that every instance of a Perl process (which carries the overhead of
> an interpreter) adds to the overall load on the system. This can soon bring
> even a large Unix machine to its knees.

> talking hardware, compilers or whatever. I realize that no development
> environment can mask poor design / coding practices, and this request isn't
> a Perl vs Python vs Java thing ! I don't want to get dragged into that
> quagmire, but I'm more than happy to take a look at any figures that you
> guys have collected using Python at the coal face.


Hello!  Hmmm... I'm not sure if anyone has compiled hard numbers on
Python's resource requirements.  You may want to talk to the pythonlabs
people to see if they've done some benchmarking; I'm sure they would be
glad to help pinpoint areas to optimize memory use.  Perhaps your input
will help them to improve Python's resource management.



From chetumal23@excite.com  Thu Nov 16 20:43:43 2000
From: chetumal23@excite.com (john smith smith)
Date: Thu, 16 Nov 2000 12:43:43 -0800 (PST)
Subject: [Tutor] newbie  needs help
Message-ID: <31975529.974407423640.JavaMail.imail@doby.excite.com>

i might seem really stupid here but i tried to create the command line
enviroment in notepad.i was following the directions in the python tutorials
for beginners and i was almost finish,but i keep getting this message about
can't open the file hello.py.i am not sure how to check the directory.any
help would be sincerely appreciated.i'm using windows 98 se and the version
of python is 1.5.2 Thanks once again.





_______________________________________________________
Tired of slow Internet? Get @Home Broadband Internet
http://www.home.com/xinbox/signup.html



From FxItAL@aol.com  Fri Nov 17 03:32:17 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Thu, 16 Nov 2000 22:32:17 EST
Subject: [Tutor] A little Listbox help please?
Message-ID: <60.8cfc45c.274600c1@aol.com>

Hello All,

    How do I get a value returned when I make a single selection in a list 
box? Here's what I have so far:

from Tkinter import *
import os
import glob
root=Tk()
list=Listbox(root, width=30, selectmode=SINGLE,                               
 exportselection=0)
scroll=Scrollbar(root, command=list.yview)
list.configure(yscrollcommand=scroll.set)
list.pack(side=LEFT)
scroll.pack(side=RIGHT, fill=Y)
os.chdir('C:\\windows\\media')
x=glob.glob('*.wav')
for item in x:
    list.insert(END, item)

root.mainloop()


Thanks for your help, Al


From dyoo@hkn.eecs.berkeley.edu  Fri Nov 17 04:15:22 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Thu, 16 Nov 2000 20:15:22 -0800 (PST)
Subject: [Tutor] newbie  needs help
In-Reply-To: <31975529.974407423640.JavaMail.imail@doby.excite.com>
Message-ID: <Pine.LNX.4.21.0011162010500.20818-100000@hkn.eecs.berkeley.edu>

On Thu, 16 Nov 2000, john smith smith wrote:

> i might seem really stupid here but i tried to create the command line
> enviroment in notepad.i was following the directions in the python
> tutorials for beginners and i was almost finish,but i keep getting
> this message about can't open the file hello.py.i am not sure how to
> check the directory.any help would be sincerely appreciated.i'm using
> windows 98 se and the version of python is 1.5.2 Thanks once again.

Could you copy and past that error to us?  Having it verbatim will help us
understand the situation better.  Also, when you're saving the file,
you'll probably want to save it in a directory that's easy to find later.

As a quick reference, if you're on a DOS prompt, you can type:

  cd \

to go to the very bottom of your directory tree.  You'll probably want to
keep all your Python work in a dedicated directory like "C:\pywork".  In
that case, you can type:

  cd \pywork

Also, you may want to try working with IDLE, which is a nicer text editor
for Python than notepad.  It's included with Python 2.0 and Python 1.52,
and should already be installed under the Python group.  Good luck!



From srichter@cbu.edu  Fri Nov 17 06:47:42 2000
From: srichter@cbu.edu (Stephan Richter)
Date: Fri, 17 Nov 2000 00:47:42 -0600
Subject: [Tutor] Adding method to class after class initialization
Message-ID: <5.0.0.25.0.20001117003938.00a6d8b0@198.78.130.6>

Hello everyone,

here a hard nut to crack:
Let's say I do the following:

 >>> def add(self, x, y):
...        return x+y
 >>> class Test:
...        pass
 >>> t = Test()
 >>> t.add = add

But if I now call 'a.add(3, 3)' I did not pass enough arguments, since self 
is not passed automatically. How can I fix that? Is there something like 
setattr just for a method?

Thanks for your help.

Regards,
Stephan

--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management



From scarblac@pino.selwerd.nl  Fri Nov 17 07:02:07 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 17 Nov 2000 08:02:07 +0100
Subject: [Tutor] Adding method to class after class initialization
In-Reply-To: <5.0.0.25.0.20001117003938.00a6d8b0@198.78.130.6>; from srichter@cbu.edu on Fri, Nov 17, 2000 at 12:47:42AM -0600
References: <5.0.0.25.0.20001117003938.00a6d8b0@198.78.130.6>
Message-ID: <20001117080207.A13369@pino.selwerd.nl>

On Fri, Nov 17, 2000 at 12:47:42AM -0600, Stephan Richter wrote:
> Hello everyone,
> 
> here a hard nut to crack:
> Let's say I do the following:
> 
>  >>> def add(self, x, y):
> ...        return x+y
>  >>> class Test:
> ...        pass
>  >>> t = Test()
>  >>> t.add = add
> 
> But if I now call 'a.add(3, 3)' I did not pass enough arguments, since self 
> is not passed automatically. How can I fix that? Is there something like 
> setattr just for a method?

If you define a method in a class, it is a "bound method", meaning that
the self is passed automatically. Setting it as t.add=add means that t.add
is just another variable, where its value happens to be a function.

You can make new codeobjects with the 'new' module. Use new.instancemethod
here:

>>> t.add = new.instancemethod(add, t, Test)

-- 
Remco Gerlich


From srichter@cbu.edu  Fri Nov 17 07:26:22 2000
From: srichter@cbu.edu (Stephan Richter)
Date: Fri, 17 Nov 2000 01:26:22 -0600
Subject: [Tutor] Adding method to class after class initialization
In-Reply-To: <20001117080207.A13369@pino.selwerd.nl>
References: <5.0.0.25.0.20001117003938.00a6d8b0@198.78.130.6>
 <5.0.0.25.0.20001117003938.00a6d8b0@198.78.130.6>
Message-ID: <5.0.0.25.0.20001117012528.00a6dc90@198.78.130.6>

>If you define a method in a class, it is a "bound method", meaning that
>the self is passed automatically. Setting it as t.add=add means that t.add
>is just another variable, where its value happens to be a function.
>
>You can make new codeobjects with the 'new' module. Use new.instancemethod
>here:
>
> >>> t.add = new.instancemethod(add, t, Test)

THANK YOU. That was exactly what I needed. :-)

Regards,
Stephan


--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management



From taisto@summa.krt.turku.fi  Fri Nov 17 11:01:35 2000
From: taisto@summa.krt.turku.fi (Taisto Pihlajamaa)
Date: Fri, 17 Nov 2000 13:01:35 +0200
Subject: [Tutor] noise(s)
Message-ID: <3A15100F.A19AED1D@summa.krt.turku.fi>

Hi,
I am searching command(s) for taking noise(s) from PC with Python. Can
anyone help me to start..

Thanks!

taisto@iki.fi



From zep@indigo.org  Fri Nov 17 13:54:15 2000
From: zep@indigo.org (Matthew Pike)
Date: Fri, 17 Nov 2000 06:54:15 -0700
Subject: [Tutor] os.system call
Message-ID: <200011170654.AA433062168@webpipe.net>

Hey All,
   Is there a way to run an os.system type call and capture the ouput in python.  The only way I have found is to redirect the output of the system call to a file, then open the file and read in the results.  Any help is appreciated.

Thanks,
Matthew

--
--
Matthew Pike
zep@indigo.org
Running On Linux, Edited By VI.
--

_______________________________________________________
Site Design, Hosting, and E-Commerce at www.webpipe.net


From sancho.panza@talk21.com  Fri Nov 17 14:38:25 2000
From: sancho.panza@talk21.com (Mariah)
Date: Fri, 17 Nov 2000 14:38:25
Subject: [Tutor] (no subject)
Message-ID: <20001117144145.5F29B1CE17@dinsdale.python.org>

http://www.ssp.co.uk
http://www.tip-ex.com
http://www.betex.com


From amoreira@mercury.ubi.pt  Fri Nov 17 15:56:58 2000
From: amoreira@mercury.ubi.pt (Jose Amoreira)
Date: Fri, 17 Nov 2000 15:56:58 +0000
Subject: [Tutor] __getslice__
Message-ID: <3A15554A.A505B5E@mercury.ubi.pt>

Hi.
I read in the official Python Reference Manual that in Python 2.0 the
__getslice__  and related methods are deprecated, and that one should
instead use the __getitem__ and related methods. I've been giving it a
try, but I don't seem to be able to get a slice of an user defined
sequence object, using the __getitem__ method, and I can't find any help
in the docs (or else I find it but i don't get it, sorry)...
Can anybody help?
tia,
Ze amoreira
amoreira@mercury.ubi.pt



From arcege@shore.net  Fri Nov 17 15:09:53 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Fri, 17 Nov 2000 10:09:53 -0500 (EST)
Subject: [Tutor] os.system call
In-Reply-To: <200011170654.AA433062168@webpipe.net> from "Matthew Pike" at Nov 17, 2000 06:54:15 AM
Message-ID: <200011171509.KAA18388@northshore.shore.net>

> 
> Hey All,
>    Is there a way to run an os.system type call and capture the ouput in python.  The only way I have found is to redirect the output of the system call to a file, then open the file and read in the results.  Any help is appreciated.
> 
> Thanks,
> Matthew

You can either use os.popen() to get just the output.  Or the popen2
module which can handle all the input/output streams.

>>> f = os.popen('prog arg1', 'r')
>>> line = f.readline()
>>> while line:
...   do_something_with(line)
...   line = f.readline()
...
>>> error_in_prog = f.close()
>>> if error_in_prog:
...   print '"prog arg1" returned with an error code of', error_in_prog
...

The popen2 module has two functons, popen2 and popen3.  The popen2
function returns two file objects, one to read the output and one to
write input to the program.  The popen3 function returns those two and
the error channel from the program.  But it sounds like the os.popen()
function does what you want.

References:
Python Library Reference, section 6.1.2 File Object Creation
  <URL: http://www.python.org/doc/current/lib/os-newstreams.html>
Python Library Reference, section 6.8 popen2
  <URL: http://www.python.org/doc/current/lib/module-popen2.html>

Good luck.

  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------


From arcege@shore.net  Fri Nov 17 15:30:26 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Fri, 17 Nov 2000 10:30:26 -0500 (EST)
Subject: [Tutor] __getslice__
In-Reply-To: <3A15554A.A505B5E@mercury.ubi.pt> from "Jose Amoreira" at Nov 17, 2000 03:56:58 PM
Message-ID: <200011171530.KAA22493@northshore.shore.net>

> Hi.
> I read in the official Python Reference Manual that in Python 2.0 the
> __getslice__  and related methods are deprecated, and that one should
> instead use the __getitem__ and related methods. I've been giving it a
> try, but I don't seem to be able to get a slice of an user defined
> sequence object, using the __getitem__ method, and I can't find any help
> in the docs (or else I find it but i don't get it, sorry)...
> Can anybody help?
> tia,
> Ze amoreira
> amoreira@mercury.ubi.pt

Hi there.  I don't feel that they really documented this well in the
release notes for 2.0, so I can see where there is some confusion.

The new "preferred" idiom is to only have a __getitem__ (and the like)
method.  Previously, there was partial support in the __[dgs]etitem__
methods,  mostly to handle the Ellipsis object ("..."), but it would
handle the Slice type (which was in there in 1.5.2).

Python 1.5.2 (#2, May 11 1999, 17:14:37)  [GCC 2.7.2.1] on freebsd3
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> class A:
...   def __getitem__(self, index):
...     print type(index), repr(index), str(index)
...
>>> a = A()
>>> a[...]
<type 'ellipsis'> Ellipsis Ellipsis
>>> a[1]
<type 'int'> 1 1

Try to give a regular subscript or the special ellipses ('...'), and
the getitem/setitem/delitem methods are used.  But...

>>> a[:]
Traceback (innermost last):
  File "<stdin>", line 1, in ?
AttributeError: __getslice__
>>> slice
<built-in function slice>
>>> slice(0, 3, 4)
slice(0, 3, 4)
>>> type(slice(0, 3, 4))
<type 'slice'>
>>> s = slice(0, 100, 4)
>>> s
slice(0, 100, 4)
>>> s.start
0
>>> s.stop
100
>>> s.step
4
>>> a[s]
<type 'slice'> slice(0, 100, 4) slice(0, 100, 4)
>>>

Slice objects were used in Python 1.5.2; part of the language allowed
for the step to be specified.

>>> a[::2]
<type 'slice'> slice(None, None, 2) slice(None, None, 2)
>>>

In Python 2.0, this slice object is now given to the __getitem__,
__setitem__ and __delitem__ methods even when there is not step given.

Python 2.0 (#7, Nov 14 2000, 11:06:28)
[GCC 2.7.2.1] on freebsd3
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> class A:
...   def __getitem__(self, index):
...     print type(index), repr(index), str(index)
...
>>> a = A()
>>> a[1]
<type 'int'> 1 1
>>> a[...]
<type 'ellipsis'> Ellipsis Ellipsis
>>>
>>> a[:]
<type 'slice'> slice(0, 2147483647, None) slice(0, 2147483647, None)
>>> sys.maxint
2147483647
>>>

But when you and a __getslice__ method, things change back to how they
worked in Python 1.x:

>>> def getslice(self, lo, hi):
...   print (type(lo), repr(lo), str(lo)), (type(hi), repr(hi), str(hi))
...
>>> A.__getslice__ = getslice
>>> a[:]
(<type 'int'>, '0', '0') (<type 'int'>, '2147483647', '2147483647')
>>>

This means that as long as there is a __getslice__ method in the class,
the system will use that instead of __getitem__.

I hope this helps you figure out what you need.

  -Arcege

References:
Python Reference Manual, section 3.3.4 Emulating sequence and mapping types
  <URL: http://www.python.org/doc/current/ref/sequence-types.html>
Python Reference Manual, section 5.3.3 Slicings
  <URL: http://www.python.org/doc/current/ref/slicings.html>

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------


From amoreira@mercury.ubi.pt  Fri Nov 17 17:57:00 2000
From: amoreira@mercury.ubi.pt (Jose Amoreira)
Date: Fri, 17 Nov 2000 17:57:00 +0000
Subject: [Tutor] __getslice__
References: <200011171530.KAA22493@northshore.shore.net>
Message-ID: <3A15716C.D8D72FE1@mercury.ubi.pt>

Hello!

"Michael P. Reilly" wrote:

>
> I hope this helps you figure out what you need.
>

Yes, thanks a lot! Have a nice weekend!



From alan.gauld@bt.com  Fri Nov 17 17:11:12 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 17 Nov 2000 17:11:12 -0000
Subject: [Tutor] Adding method to class after class initialization
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D40D@mbtlipnt02.btlabs.bt.co.uk>

> You can make new codeobjects with the 'new' module. Use 
> new.instancemethod here:
> 
> >>> t.add = new.instancemethod(add, t, Test)

Wow. Thanks for that one Remco. I haven't looked at the new 
module yet but I can feel some experimentation coming on. 
Python just keeps on amazing me with its openness.

Alan G.


From wheelege@tsn.cc  Sat Nov 18 08:41:39 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Sat, 18 Nov 2000 19:41:39 +1100
Subject: [Tutor] time.sleep problems
Message-ID: <001e01c0513b$5f7e31c0$a410fea9@glen>

This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C05197.91FA85C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hey guys.  I was just fiddling with threads and my code kept locking up. =
 So I deicided to strip down the code.  I did so, and it still locks up. =
 I think the culprit is the time.sleep command.  The code has been =
stripped to very simple (actually it as simple before too, but it kept =
erroring on me)

Anywho, here it is.  I use a windows computer, and Python 2.0.

import thread
from time import sleep

print "Hi this is to show some thread stuff\n"

def thred(arg):
    for i in range(10):
        print arg
        print i
        sleep(0.0001)

t =3D raw_input('Hi! --> ')

if t =3D=3D 't' :
    thread.start_new_thread(thred, (1,))

Thanks,
Glen.

------=_NextPart_000_001B_01C05197.91FA85C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>Hey guys.&nbsp; I was just fiddling with threads and my code kept =
locking=20
up.&nbsp; So I deicided to strip down the code.&nbsp; I did so, and it =
still=20
locks up.&nbsp; I think the culprit is the time.sleep command.&nbsp; The =
code=20
has been stripped to very simple (actually it as simple before too, but =
it kept=20
erroring on me)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Anywho, here it is.&nbsp; I use a windows computer, and Python =
2.0.</DIV>
<DIV>&nbsp;</DIV>
<DIV>import thread<BR>from time import sleep</DIV>
<DIV>&nbsp;</DIV>
<DIV>print "Hi this is to show some thread stuff\n"</DIV>
<DIV>&nbsp;</DIV>
<DIV>def thred(arg):<BR>&nbsp;&nbsp;&nbsp; for i in=20
range(10):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
arg<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(0.0001)</DIV>
<DIV><BR>t =3D raw_input('Hi! --&gt; ')</DIV>
<DIV>&nbsp;</DIV>
<DIV>if t =3D=3D 't' :<BR>&nbsp;&nbsp;&nbsp; =
thread.start_new_thread(thred,=20
(1,))</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks,</DIV>
<DIV>Glen.</DIV></BODY></HTML>

------=_NextPart_000_001B_01C05197.91FA85C0--



From webmaster@cgiscriptsonline.com  Sat Nov 18 09:01:27 2000
From: webmaster@cgiscriptsonline.com (webmaster@cgiscriptsonline.com)
Date: Sat, 18 Nov 2000 04:01:27 -0500
Subject: [Tutor] New Search Engine Requires Your Input.
Message-ID: <200011180901.eAI91RO20737@coloc2.premium-host.com>

You were identified as a potential contributor to our search engine database. We are opening up a new site dedicated to CGI scripts, programming, web development resources and all information relating to these topics. 

You have received this email because we believe you have a skill, an opportunity, site URL or other information you can contribute to the script and programing related database which will be the focus of our search engine.

Our site will basically be a directory type of search engine based on the Yahoo model but specifically focused on what is CGI script related. 

We have presently categorized our main sections as Applescript Scripts, Books & Tutorials, C Scripts, CGI News Groups, CGI Script Related Jobs,
Custom Script Programers, FAQs & Documentation, Java Scripts, Other Scripts, Other Web Resources,
PHP Scripts, Perl Scripts, Python Scripts, Remotely Hosted Scripts, Script Installation Services, Virtual Basic Scripts.

If you can contribute to any of the categories mentioned above we encourage you to go to http://www.cgiscriptsonline.com and to add your URL to our search engine. Submission of URLs are totally free.

We welcome any comment from you and hope to be able to build a mutually rewarding association in the immediate future.

If this message has reached you in error and you do not have anything to contribute to a search engine focused on CGI Scripts, Programing and/or Web Resources then please accept our appologies and click on the link below to remove yourself from our mailng list. If you simply want to be removed from our mailing list for whatever reason then please click on the link below and you will automatically be removed.

Thank You,

Norm

Admin@CGIScriptsOnline.com
http://www.CGIScriptsOnline.com

---------------------------------------------------------------------
Click on the link below to be removed from the 
CGI Scripts Online Mailing List.

http://www.cgiscriptsonline.com/cgi-bin/mail/mailmachine.cgi?tutor@python.org
---------------------------------------------------------------------


From dyoo@hkn.eecs.berkeley.edu  Sat Nov 18 22:48:48 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 18 Nov 2000 14:48:48 -0800 (PST)
Subject: [Tutor] noise(s)
In-Reply-To: <3A15100F.A19AED1D@summa.krt.turku.fi>
Message-ID: <Pine.LNX.4.21.0011181444570.1687-100000@hkn.eecs.berkeley.edu>

On Fri, 17 Nov 2000, Taisto Pihlajamaa wrote:

> I am searching command(s) for taking noise(s) from PC with Python. Can
> anyone help me to start..

There's a "winsound" module that allows you to handle sound.  There's
quite a few functions you can call that will let you do beeps and play
sound files.  However, I'm not quite sure how it works, since I don't work
with Windows too often.  You may want to ask people on the main discussion
newsgroup at comp.lang.python about it.

Take a look here:

    http://www.python.org/doc/current/lib/module-winsound.html

It describes how to use the winsound module.

Good luck!



From dyoo@hkn.eecs.berkeley.edu  Sun Nov 19 10:32:06 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 19 Nov 2000 02:32:06 -0800 (PST)
Subject: [Tutor] time.sleep problems
In-Reply-To: <001e01c0513b$5f7e31c0$a410fea9@glen>
Message-ID: <Pine.LNX.4.21.0011190228300.15828-100000@hkn.eecs.berkeley.edu>

On Sat, 18 Nov 2000, Glen Wheeler wrote:

> Hey guys.  I was just fiddling with threads and my code kept locking
> up.  So I deicided to strip down the code.  I did so, and it still
> locks up.  I think the culprit is the time.sleep command.  The code
> has been stripped to very simple (actually it as simple before too,
> but it kept erroring on me)

Hmmm... Strange!  I tried it on my Linux machine, and it appears to work
ok.  Can you remove the time.sleep() command and see if it locks up
still?  It's very possible that Python 2.0 has a glitch with its threads,
so let's make sure that sleep() really is causing the problem.



From din22@home.com  Sun Nov 19 17:20:18 2000
From: din22@home.com (sheri)
Date: Sun, 19 Nov 2000 11:20:18 -0600
Subject: [Tutor] basic universe simulating for dummies
Message-ID: <000a01c0524c$fd64aec0$134d0141@dstn1.fl.home.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C0521A.B26EB140
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hello everybody! i am a newbie programmer wannabe and i am trying to =
learn to=20
program in python by studying joe strout's basic universe simulator. its =
the only
code i've ever seen that does something non-trivial and interesting that =
i think i=20
could actually understand how it works. i have been rewriting it and i'm =
at the
point where i can type look and see whats in a room. next step is to =
move from
one room to another. anyway i have been looking at this code for a while =
and i'm
still mystified by


# declare some constants
the =3D 1
a =3D 2
The =3D 101
A =3D 102

# get name
 def GetName(self, article=3D0):
  if not article: return self.name
  if article=3D=3Dthe:
   if hasattr(self,'the'): return self.the + ' ' + self.name
   return 'the ' + self.name
  if article=3D=3Da:
   if hasattr(self,'a'): return self.a + ' ' + self.name
   return 'a ' + self.name=20
  if article=3D=3DThe:
   if hasattr(self,'the'): return cap(self.the) + ' ' + self.name
   return 'The ' + self.name
  if article=3D=3DA:
   if hasattr(self,'A'): return cap(self.a) + ' ' + self.name
   return 'A ' + self.name=20
   return self.name


why assign different numbers? what does this code do?
for me this is the most opaque part of the program except
for the parser which i'm treating like a black box for now.
anyway sorry i tend to ramble but if someone could comment
on this code i would really appreciate it.=20

------=_NextPart_000_0007_01C0521A.B26EB140
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>hello everybody! i am a newbie =
programmer wannabe=20
and i am trying to learn to </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>program in python by studying joe =
strout's basic=20
universe simulator. its the only</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>code i've ever seen that does something =
non-trivial=20
and</FONT><FONT face=3DArial size=3D2> interesting that i think i =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>could actually</FONT><FONT face=3DArial =
size=3D2>=20
understand how it works. i have been rewriting it and i'm at =
the</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>point where i can type look and see =
whats in a=20
room. next step is to move from</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>one room to another. anyway i have been =
looking at=20
this code for a while and i'm</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>still mystified by</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR># declare some constants<BR>the =3D =
1<BR>a =3D=20
2<BR>The =3D 101<BR>A =3D 102</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2># get name<BR>&nbsp;def GetName(self,=20
article=3D0):<BR>&nbsp;&nbsp;if not article: return =
self.name<BR>&nbsp;&nbsp;if=20
article=3D=3Dthe:<BR>&nbsp;&nbsp;&nbsp;if hasattr(self,'the'): return =
self.the + ' '=20
+ self.name<BR>&nbsp;&nbsp;&nbsp;return 'the ' + =
self.name<BR>&nbsp;&nbsp;if=20
article=3D=3Da:<BR>&nbsp;&nbsp;&nbsp;if hasattr(self,'a'): return self.a =
+ ' ' +=20
self.name<BR>&nbsp;&nbsp;&nbsp;return 'a ' + =
self.name&nbsp;<BR>&nbsp;&nbsp;if=20
article=3D=3DThe:<BR>&nbsp;&nbsp;&nbsp;if hasattr(self,'the'): return =
cap(self.the)=20
+ ' ' + self.name<BR>&nbsp;&nbsp;&nbsp;return 'The ' +=20
self.name<BR>&nbsp;&nbsp;if article=3D=3DA:<BR>&nbsp;&nbsp;&nbsp;if=20
hasattr(self,'A'): return cap(self.a) + ' ' +=20
self.name<BR>&nbsp;&nbsp;&nbsp;return 'A ' +=20
self.name&nbsp;<BR>&nbsp;&nbsp;&nbsp;return self.name</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>why assign different numbers? what does =
this code=20
do?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>for me this is the most opaque part of =
the program=20
except</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>for the parser which i'm treating like =
a black box=20
for now.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>anyway sorry i tend to ramble but if =
someone could=20
comment</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>on this code i would really appreciate =
it.=20
</FONT></DIV></BODY></HTML>

------=_NextPart_000_0007_01C0521A.B26EB140--



From dyoo@hkn.eecs.berkeley.edu  Sun Nov 19 19:12:09 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 19 Nov 2000 11:12:09 -0800 (PST)
Subject: [Tutor] basic universe simulating for dummies
In-Reply-To: <000a01c0524c$fd64aec0$134d0141@dstn1.fl.home.com>
Message-ID: <Pine.LNX.4.21.0011191051410.26672-100000@hkn.eecs.berkeley.edu>

On Sun, 19 Nov 2000, sheri wrote:

> hello everybody! i am a newbie programmer wannabe and i am trying to
> learn to program in python by studying joe strout's basic universe
> simulator. its the only code i've ever seen that does something
> non-trivial and interesting that i think i could actually understand
> how it works. i have been rewriting it and i'm at the point where i
> can type look and see whats in a room. next step is to move from one
> room to another. anyway i have been looking at this code for a while


Just to make sure: the code that you're looking at appears to be here:

    http://www.strout.net/python/pub/pubcore.py


> # declare some constants
> the = 1
> a = 2
> The = 101
> A = 102

Here, the code appears to be assigning the important articles to numbers.  
From what I can tell, these numbers are completely arbitrary --- they just
have to be different from each other.


> # get name
>  def GetName(self, article=0):
>   if not article: return self.name
>   if article==the:
>    if hasattr(self,'the'): return self.the + ' ' + self.name
>    return 'the ' + self.name
>   if article==a:
>    if hasattr(self,'a'): return self.a + ' ' + self.name
>    return 'a ' + self.name 
>   if article==The:
>    if hasattr(self,'the'): return cap(self.the) + ' ' + self.name
>    return 'The ' + self.name
>   if article==A:
>    if hasattr(self,'A'): return cap(self.a) + ' ' + self.name
>    return 'A ' + self.name 
>    return self.name
> 
> 
> why assign different numbers? what does this code do?
> for me this is the most opaque part of the program except
> for the parser which i'm treating like a black box for now.


The numbers are different just so that we can say something like:

    myThing.getName(The)

instead of:

    myThing.getName("The")

It's easier to type.  That's pretty much what I can tell.  *grin* At the
same time, this stuff is tied slightly to the parser.  The parser appears
to call getName() with the proper article, depending on the kind of
message it'll needs to send.  We need to look at something like

    http://www.strout.net/python/pub/pubverbs.py

to find a reason why they're doing this sort of stuff.  Let's take a look:

    self.atsucc = 'You ' + x + ' at <the dirobj>.'
    self.atosucc = '<The actor> ' + x + 's at <the dirobj>.'

We can guess that "<the dirobj>" will be replaced with a call to
getName(the).  Likewise, "<The actor>" should be replaced with the results
of actor(The).  I'm not quite sure how or when the program does this
stuff, but that's probably the most likely reason why getName takes an
article.

Hope this helps!



From wheelege@tsn.cc  Sun Nov 19 22:40:14 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 20 Nov 2000 09:40:14 +1100
Subject: [Tutor] time.sleep problems
References: <Pine.LNX.4.21.0011181444570.1687-100000@hkn.eecs.berkeley.edu>
Message-ID: <001301c05279$b0ba6560$a410fea9@glen>

  Well when I remove that line the computer locks up with an illegal
operation...damn windows :(

  Anyone who has used threads in python 2 on windows encountered a similar
problem??



From wheelege@tsn.cc  Mon Nov 20 03:16:42 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 20 Nov 2000 14:16:42 +1100
Subject: [Tutor] time.sleep problems (fwd)
References: <Pine.LNX.4.21.0011191906190.6269-200000@hkn.eecs.berkeley.edu>
Message-ID: <000b01c052a0$4eb36ac0$a410fea9@glen>

Damn that's exactly what I wanted it to do grrrrrr...

By locking up I mean only the program, I have to ctrl+alt+del and then close
it to regain control of my system.

Awww this doens't mean I have to install Linux does it?  (again :)

I was designing for windows not Linux...there has to be a solution to this
problem :)

----- Original Message -----
From: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>
To: <python-help@python.org>
Cc: wheelege <wheelege@tsn.cc>
Sent: Monday, November 20, 2000 2:11 PM
Subject: Re: [Tutor] time.sleep problems (fwd)


>
> Dear Glen,
>
> By locking up, do you mean your program, or the whole machine altogether?
> Also, this does seem to be a Windows specific thing --- I've just run your
> program, and this is what I get:
>
> ###
> Hi this is to show some thread stuff
>
> Hi! --> t
> prog
> 0
> prog
> 1
> 2
> prog
> prog
> 3
> prog
> 4
> prog
> 5
> prog
> 6
> prog
> 7
> prog
> 8
> prog
> 9
> ###
>
> So if it's any consolation, it's working on Linux.  *grin*  I hope one of
> the other helpers has access to a Win2k machine.
>
>
> ---------- Forwarded message ----------
> Date: Mon, 20 Nov 2000 13:59:39 +1100
> From: Glen Wheeler <wheelege@tsn.cc>
> To: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>
> Subject: Re: [Tutor] time.sleep problems
>
> Sure thing.  The program is attached.
>
> It doesn't do an illegal operation anymore, it just locks up.  I added
> another loop to it.
>
> When I change the sleep commands around it goes funny, and the output
> changes.
>
> My system is an Athlon 600 Mhz with mainly standard hardware (17" monitor,
> big speakers, external modem, cd writer, 17GB HDD).
>
> I had no other software running.
>
> Thanks,
> Glen.
>



From FxItAL@aol.com  Mon Nov 20 04:42:11 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Sun, 19 Nov 2000 23:42:11 EST
Subject: [Tutor] Variable Question
Message-ID: <3f.cd4cf91.274a05a4@aol.com>

Hello All,
   I'm sure this is an easy one but I am quite perplexed over it.  In the 
following script, how do I get the value of "optSound" out of the function to 
be used in another module.

Thanks for any help you can offer, Al

from Tkinter import *
import os
import glob
import string

root=Tk()
list=Listbox(root, width=30,exportselection=0)
scroll=Scrollbar(root, command=list.yview)
list.configure(yscrollcommand=scroll.set)
list.pack(side=LEFT)
scroll.pack(side=RIGHT, fill=Y)
os.chdir('C:\\windows\\media')
x=glob.glob('*.wav')
for item in x:
    list.insert(END, item)  

def test():
    items=list.curselection()
    items=map(int, items) 
    z=items[0]         
    optSound = "C:\\windows\\media\\" +x[z]



OKBut = Button(root, activebackground='GREY', text='OK', command=test, 
width=10)
OKBut.pack()
root.mainloop()



From dsh8290@rit.edu  Mon Nov 20 06:07:52 2000
From: dsh8290@rit.edu (D-Man)
Date: Mon, 20 Nov 2000 01:07:52 -0500
Subject: [Tutor] time.sleep problems (fwd)
In-Reply-To: <000b01c052a0$4eb36ac0$a410fea9@glen>; from wheelege@tsn.cc on Sun, Nov 19, 2000 at 22:16:42 -0500
References: <Pine.LNX.4.21.0011191906190.6269-200000@hkn.eecs.berkeley.edu> <000b01c052a0$4eb36ac0$a410fea9@glen>
Message-ID: <20001120010752.D8486@westsidecnc.rh.rit.edu>

Sure, install Linux.  Sleep works fine for me on RH7.0, Python 2.0, GCC 2.96
(you know, the devel version gcc that redhat shipped with).

-D

On Sun, 19 Nov 2000 22:16:42 Glen Wheeler wrote:
 | Damn that's exactly what I wanted it to do grrrrrr...
 | 
 | By locking up I mean only the program, I have to ctrl+alt+del and then close
 | it to regain control of my system.
 | 
 | Awww this doens't mean I have to install Linux does it?  (again :)
 | 
 | I was designing for windows not Linux...there has to be a solution to this
 | problem :)
 | 
 | ----- Original Message -----
 | From: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>
 | To: <python-help@python.org>
 | Cc: wheelege <wheelege@tsn.cc>
 | Sent: Monday, November 20, 2000 2:11 PM
 | Subject: Re: [Tutor] time.sleep problems (fwd)
 | 
 | 
 | >
 | > Dear Glen,
 | >
 | > By locking up, do you mean your program, or the whole machine altogether?
 | > Also, this does seem to be a Windows specific thing --- I've just run your
 | > program, and this is what I get:
 | >
 | > ###
 | > Hi this is to show some thread stuff
 | >
 | > Hi! --> t
 | > prog
 | > 0
 | > prog
 | > 1
 | > 2
 | > prog
 | > prog
 | > 3
 | > prog
 | > 4
 | > prog
 | > 5
 | > prog
 | > 6
 | > prog
 | > 7
 | > prog
 | > 8
 | > prog
 | > 9
 | > ###
 | >
 | > So if it's any consolation, it's working on Linux.  *grin*  I hope one of
 | > the other helpers has access to a Win2k machine.
 | >
 | >
 | > ---------- Forwarded message ----------
 | > Date: Mon, 20 Nov 2000 13:59:39 +1100
 | > From: Glen Wheeler <wheelege@tsn.cc>
 | > To: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>
 | > Subject: Re: [Tutor] time.sleep problems
 | >
 | > Sure thing.  The program is attached.
 | >
 | > It doesn't do an illegal operation anymore, it just locks up.  I added
 | > another loop to it.
 | >
 | > When I change the sleep commands around it goes funny, and the output
 | > changes.
 | >
 | > My system is an Athlon 600 Mhz with mainly standard hardware (17" monitor,
 | > big speakers, external modem, cd writer, 17GB HDD).
 | >
 | > I had no other software running.
 | >
 | > Thanks,
 | > Glen.
 | >
 | 
 | 
 | _______________________________________________
 | Tutor maillist  -  Tutor@python.org
 | http://www.python.org/mailman/listinfo/tutor
 | 




From wheelege@tsn.cc  Mon Nov 20 06:26:24 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 20 Nov 2000 17:26:24 +1100
Subject: [Tutor] Variable Question
References: <3f.cd4cf91.274a05a4@aol.com>
Message-ID: <002b01c052ba$d0029a00$a410fea9@glen>

You could use 'return' couldn't you?



From dyoo@hkn.eecs.berkeley.edu  Mon Nov 20 08:49:37 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Mon, 20 Nov 2000 00:49:37 -0800 (PST)
Subject: [Tutor] time.sleep problems (fwd)
In-Reply-To: <20001120010752.D8486@westsidecnc.rh.rit.edu>
Message-ID: <Pine.LNX.4.21.0011200035150.21128-100000@hkn.eecs.berkeley.edu>

On Mon, 20 Nov 2000, D-Man wrote:

> Sure, install Linux.  Sleep works fine for me on RH7.0, Python 2.0, GCC 2.96
> (you know, the devel version gcc that redhat shipped with).

This is good long term advice, but this isn't helpful for him in the short
term.  Ideally, he really shouldn't need to worry about stability issues
on Windows, especially with basic threads.

I'm actually planning to install Win2k tonight.  I should be able to test
your sleep program before I sleep.  *grin*



From dyoo@hkn.eecs.berkeley.edu  Mon Nov 20 09:20:03 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Mon, 20 Nov 2000 01:20:03 -0800 (PST)
Subject: [Tutor] Variable Question
In-Reply-To: <3f.cd4cf91.274a05a4@aol.com>
Message-ID: <Pine.LNX.4.21.0011200106460.22287-100000@hkn.eecs.berkeley.edu>

On Sun, 19 Nov 2000 FxItAL@aol.com wrote:

> Hello All,
>    I'm sure this is an easy one but I am quite perplexed over it.  In the 
> following script, how do I get the value of "optSound" out of the function to 
> be used in another module.

The easiest way to do this would be to make a global variable within your
module.  Something like:

###
optSound = ""
###

in the beginning of your program will define a global variable.  Later on
in your test() function, you can make changes to optSound:

###
def test():
    global optSound    # This line is important.  Try taking it out.
    items=list.curselection()
    items=map(int, items) 
    z=items[0]         
    optSound = "C:\\windows\\media\\" +x[z]
###

Afterwards, you should be able to access optSound from other modules.


Normally after saying this, I would recommend against global variables.  
*grin* However, since your code is short and appears to be a one-shot
thing, this is managable.  As a warning, when your program gets larger,
you'll notice that it's harder to figure out where and when your variables
change.

You'll definitely want to look into object oriented stuff when you get the
chance, because it'll let you write code that's less dependent on global
variables to maintain the state of your program.

Good luck!



From wheelege@tsn.cc  Mon Nov 20 09:32:59 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 20 Nov 2000 20:32:59 +1100
Subject: [Tutor] time.sleep problems (fwd)
References: <Pine.LNX.4.21.0011200035150.21128-100000@hkn.eecs.berkeley.edu>
Message-ID: <001d01c052d4$e26e55c0$a410fea9@glen>

> On Mon, 20 Nov 2000, D-Man wrote:
>
> > Sure, install Linux.  Sleep works fine for me on RH7.0, Python 2.0, GCC
2.96
> > (you know, the devel version gcc that redhat shipped with).
>
> This is good long term advice, but this isn't helpful for him in the short
> term.  Ideally, he really shouldn't need to worry about stability issues
> on Windows, especially with basic threads.
>
> I'm actually planning to install Win2k tonight.  I should be able to test
> your sleep program before I sleep.  *grin*
>
>


  Thanks Daniel, it should help you with alot of other problems people have
too (I hope!)

  Damn I'll look the fool if the prog works fine.  I have basically stopped
development cos of this silly problem with really simple threads...

  Sure I'm not in a big company but it's important, and isn't python
designed to be really stable?

  Thanks again,
  Glen.



From scott@zenplex.com  Mon Nov 20 18:33:45 2000
From: scott@zenplex.com (Scott Ralph Comboni)
Date: Mon, 20 Nov 2000 13:33:45 -0500
Subject: [Tutor] ftplib or popen?
Message-ID: <00112013334508.14039@scoot.zenplex.com>

Im trying to use the ftplib for sending a file to a remote location.  I'm 
having trouble and Im wondering if it would be easier just to use os.open 
instead of this module.  What are the pro's and con's to doing this?
The files that I'm sedning are very large 100Meg+
Scott


From wilson@visi.com  Tue Nov 21 04:09:12 2000
From: wilson@visi.com (Timothy Wilson)
Date: Mon, 20 Nov 2000 22:09:12 -0600 (CST)
Subject: [Tutor] exercise is recursion
Message-ID: <Pine.GSO.4.21.0011202205360.14171-100000@isis.visi.com>

Hi everyone,

I thought I would write a little progam that would factor a given integer
into its primes. This seemed like a good time to use recursion, but I'm
having trouble making it work. Anyone see the problem here? I've added a few
lines of debugging code, and there's a function to determine if a number is
prime, but I don't think I'll need it. Any suggestions would be appreciated.

--snip--
#!/usr/bin/python

# This python factors a number into its primes.

from math import *

def isPrime(number):
	for j in [2] + range(3, sqrt(number)+1, 2):
		if number in [1, 2]:
			return 1
		if  number % j == 0:
			return 0
	return 1

def factor(factors, number, i=2):
	while i < sqrt(number):
		if number % i == 0:
			factor(factors, number/i, i)
			factors.append(i)
#			if number/i == i:
		i = i + 1
	print str(number) + '\t' + str(i) + '\t' + str(factors) # debugging
code
	return factors

def primeFactors(number):
	factors = []
	print 'number' + '\t' + 'i' + '\t' + 'factors' # debugging header
	print str(number) + '\t' + '2' + '\t' + str(factors)
	factor(factors, number)
#	factors.sort()
#	print factors

if __name__ == '__main__':
	number = raw_input('Factor what number into primes? ')
	primeFactors(int(number))

--snip--

Thanks,
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 |   <dtml-var pithy_quote>     | http://linux.com/



From wheelege@tsn.cc  Tue Nov 21 05:12:37 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Tue, 21 Nov 2000 16:12:37 +1100
Subject: [Tutor] exercise is recursion (more problems with my comp)
References: <Pine.GSO.4.21.0011202205360.14171-100000@isis.visi.com>
Message-ID: <000501c05379$aaf97fc0$a410fea9@glen>

  Well while looking at your code I thought I'd run it on my comp.  When I
run this particular code on my computer if I enter any number bigger than 1
the interpreter stops responding, but I can still use anything else (such as
other applications).  Is this the error your talking about?  I can't really
tell anymore with these strange things happenning with my computer.
  I guess we both need help,

  Glen.

----- Original Message -----
From: Timothy Wilson <wilson@visi.com>
To: <tutor@python.org>
Sent: Tuesday, November 21, 2000 3:09 PM
Subject: [Tutor] exercise is recursion


> Hi everyone,
>
> I thought I would write a little progam that would factor a given integer
> into its primes. This seemed like a good time to use recursion, but I'm
> having trouble making it work. Anyone see the problem here? I've added a
few
> lines of debugging code, and there's a function to determine if a number
is
> prime, but I don't think I'll need it. Any suggestions would be
appreciated.
>
> --snip--
> #!/usr/bin/python
>
> # This python factors a number into its primes.
>
> from math import *
>
> def isPrime(number):
> for j in [2] + range(3, sqrt(number)+1, 2):
> if number in [1, 2]:
> return 1
> if  number % j == 0:
> return 0
> return 1
>
> def factor(factors, number, i=2):
> while i < sqrt(number):
> if number % i == 0:
> factor(factors, number/i, i)
> factors.append(i)
> # if number/i == i:
> i = i + 1
> print str(number) + '\t' + str(i) + '\t' + str(factors) # debugging
> code
> return factors
>
> def primeFactors(number):
> factors = []
> print 'number' + '\t' + 'i' + '\t' + 'factors' # debugging header
> print str(number) + '\t' + '2' + '\t' + str(factors)
> factor(factors, number)
> # factors.sort()
> # print factors
>
> if __name__ == '__main__':
> number = raw_input('Factor what number into primes? ')
> primeFactors(int(number))
>
> --snip--
>
> Thanks,
> 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 |   <dtml-var pithy_quote>     | http://linux.com/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 21 11:30:16 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 21 Nov 2000 03:30:16 -0800 (PST)
Subject: [Tutor] Variable Question
In-Reply-To: <4a.dc82ec1.274b2cf0@aol.com>
Message-ID: <Pine.LNX.4.21.0011210322020.28195-100000@hkn.eecs.berkeley.edu>

On Mon, 20 Nov 2000 FxItAL@aol.com wrote:

> Thanks for all your responses. Where's the best source for a BEGINNER
> to learn this Object Oriented stuff.

Alan Gauld's tutorial at:

    http://www.crosswinds.net/~agauld/

has a tutorial on object oriented programming, and it seems to be a good
introduction for object orientation stuff.


I wrote a quicky introduction to object oriented stuff here:

    http://www.python.org/pipermail/tutor/2000-June/004134.html

and there are other messages in the archives that talk about OOP
stuff.  Can anyone else recommend good resources on OOP?


Of course, the tutor@python.org list is always a receptive audience for
your questions.  *grin*  You can always ask us about it.



From Claudiu Chiculita" <cchiculita@psgl.ro  Tue Nov 21 11:42:57 2000
From: Claudiu Chiculita" <cchiculita@psgl.ro (Chiculita Claudiu)
Date: Tue, 21 Nov 2000 13:42:57 +0200
Subject: [Tutor] Library Reference for PRINT
Message-ID: <000a01c053b0$31b30820$100aa8c0@claudiu>

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C053C0.F4FD4880
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Where can I find Python Library Reference
in a more compact form sa I can=20
arrange it and print it.
I know there is also a PDF, but I cannot
afford to print 450 pag. (I need to shrink=20
and rearrange it to take less sapce)

------=_NextPart_000_0007_01C053C0.F4FD4880
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2919.6307" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Where can I find&nbsp;Python Library=20
Reference</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>in a more compact form sa I can =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>arrange it and print it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I know there is also a PDF, but I=20
cannot</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>afford to print 450 pag. (I need to =
shrink=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and rearrange it to take less=20
sapce)</FONT></DIV></BODY></HTML>

------=_NextPart_000_0007_01C053C0.F4FD4880--



From Moshe Zadka <moshez@math.huji.ac.il>  Tue Nov 21 12:44:40 2000
From: Moshe Zadka <moshez@math.huji.ac.il> (Moshe Zadka)
Date: Tue, 21 Nov 2000 14:44:40 +0200 (IST)
Subject: [Tutor] Library Reference for PRINT
In-Reply-To: <000a01c053b0$31b30820$100aa8c0@claudiu>
Message-ID: <Pine.GSO.4.10.10011211444070.16334-100000@sundial>

On Tue, 21 Nov 2000, Chiculita Claudiu wrote:

> Where can I find Python Library Reference
> in a more compact form sa I can 
> arrange it and print it.
> I know there is also a PDF, but I cannot
> afford to print 450 pag. (I need to shrink 
> and rearrange it to take less sapce)

I think there is also postscrip versions. There are programs which 
arrange postscript to fit on less pages.
--
Moshe Zadka <moshez@math.huji.ac.il> -- 95855124
http://advogato.org/person/moshez



From wilson@visi.com  Tue Nov 21 13:11:47 2000
From: wilson@visi.com (Timothy Wilson)
Date: Tue, 21 Nov 2000 07:11:47 -0600 (CST)
Subject: [Tutor] exercise is recursion (more problems with my comp)
In-Reply-To: <000501c05379$aaf97fc0$a410fea9@glen>
Message-ID: <Pine.GSO.4.21.0011210706550.25490-100000@isis.visi.com>

On Tue, 21 Nov 2000, Glen Wheeler wrote:

>   Well while looking at your code I thought I'd run it on my comp.  When I
> run this particular code on my computer if I enter any number bigger than 1
> the interpreter stops responding, but I can still use anything else (such as
> other applications).  Is this the error your talking about?

I realized later that the subject line is supposed to be "exercise *in*
recursion." How embarrassing. I also should have included some sample
output. Here's what I get:

wilsont@galileo:~/python$ python primefactor.py
Factor what number into primes? 100
number  i       factors
100     2       []
25      5       []
10      5       [2]
50      8       [2, 5]
25      5       [2, 5, 2]
20      5       [2, 5, 2, 4]
100     10      [2, 5, 2, 4, 5]

Notice the '4' in the list of prime factors. The program works correctly
sometimes, however:

wilsont@galileo:~/python$ python primefactor.py
Factor what number into primes? 12
number  i       factors
12      2       []
3       2       []
6       3       [2]
4       3       [2, 2]
12      4       [2, 2, 3]

It's been a very long time since I wrote a program that used recursion
(Hmmm...college...Pascal). I'd forgotten what a pain in the butt it is to
debug. Any hints?

-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 |   <dtml-var pithy_quote>     | http://linux.com/




From scarblac@pino.selwerd.nl  Tue Nov 21 13:48:06 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 21 Nov 2000 14:48:06 +0100
Subject: [Tutor] exercise is recursion
In-Reply-To: <Pine.GSO.4.21.0011202205360.14171-100000@isis.visi.com>; from wilson@visi.com on Mon, Nov 20, 2000 at 10:09:12PM -0600
References: <Pine.GSO.4.21.0011202205360.14171-100000@isis.visi.com>
Message-ID: <20001121144806.A3004@pino.selwerd.nl>

On Mon, Nov 20, 2000 at 10:09:12PM -0600, Timothy Wilson wrote:
> I thought I would write a little progam that would factor a given integer
> into its primes. This seemed like a good time to use recursion, but I'm
> having trouble making it work. Anyone see the problem here? I've added a few
> lines of debugging code, and there's a function to determine if a number is
> prime, but I don't think I'll need it. Any suggestions would be appreciated.
> 
> --snip--
> #!/usr/bin/python
> 
> # This python factors a number into its primes.
> 
> from math import *

Ick, I hate import *.

> def isPrime(number):
> 	for j in [2] + range(3, sqrt(number)+1, 2):
> 		if number in [1, 2]:
> 			return 1
> 		if  number % j == 0:
> 			return 0
> 	return 1
> 
> def factor(factors, number, i=2):
> 	while i < sqrt(number):
> 		if number % i == 0:
> 			factor(factors, number/i, i)
> 			factors.append(i)
> #			if number/i == i:
> 		i = i + 1
> 	print str(number) + '\t' + str(i) + '\t' + str(factors) # debugging
> code
> 	return factors

I think the problem is that the while continues after you've found a factor,
and i is also increased after that. You should break after the append(i); any
other factors have already been found by the recursive call to factor().

Also, I think it should say <= not < in the while guard.

I would write it like this:

import math

def factors(n, highestsofar=2):
   for i in range(highestsofar, math.sqrt(n)+1):
      if n % i == 0:
         return [i] + factors(n/i, i)
   return [n]

I don't use a mutable list but add function results together because I
think that's a bit clearer. Instead of range(), you'd want to use a function
that only returns the primes in that range; you can adapt that from
Demo/scripts/primes.py in Python's source distribution. The highestsofar
variable is an optimization (you also use it).

Adding further optimization and unrolling it to an iterative version are
left as an excercise for the reader ;-).

-- 
Remco Gerlich


From Moshe Zadka <moshez@math.huji.ac.il>  Tue Nov 21 14:22:25 2000
From: Moshe Zadka <moshez@math.huji.ac.il> (Moshe Zadka)
Date: Tue, 21 Nov 2000 16:22:25 +0200 (IST)
Subject: [Tutor] exercise is recursion
In-Reply-To: <20001121144806.A3004@pino.selwerd.nl>
Message-ID: <Pine.GSO.4.10.10011211618520.16334-100000@sundial>

On Tue, 21 Nov 2000, Remco Gerlich wrote:

> I would write it like this:
> 
> import math
> 
> def factors(n, highestsofar=2):
>    for i in range(highestsofar, math.sqrt(n)+1):
>       if n % i == 0:
>          return [i] + factors(n/i, i)
>    return [n]

def factors(n, highestsofar=2, factorssofar=None):
	if factorssofar is None:
		factorssofar = []
	for i in range(highestsofar, math.sqrt(n)+1):
		if n % i == 0:
			factorssofar.append(i)
			return factors(n/i, i, factorssofar)
	factorssofar.append(n)
	return factorssofar

Is more efficient, and almost as clear.

--
Moshe Zadka <moshez@math.huji.ac.il> -- 95855124
http://advogato.org/person/moshez



From dsh8290@rit.edu  Tue Nov 21 14:50:35 2000
From: dsh8290@rit.edu (D-Man)
Date: Tue, 21 Nov 2000 09:50:35 -0500
Subject: [Tutor] exercise is recursion
In-Reply-To: <Pine.GSO.4.10.10011211618520.16334-100000@sundial>; from moshez@math.huji.ac.il on Tue, Nov 21, 2000 at 09:22:25 -0500
References: <20001121144806.A3004@pino.selwerd.nl> <Pine.GSO.4.10.10011211618520.16334-100000@sundial>
Message-ID: <20001121095035.B12719@westsidecnc.rh.rit.edu>

On Tue, 21 Nov 2000 09:22:25 Moshe Zadka wrote:
 | On Tue, 21 Nov 2000, Remco Gerlich wrote:
 | 
 | > I would write it like this:
 | > 
 | > import math
 | > 
 | > def factors(n, highestsofar=2):
 | >    for i in range(highestsofar, math.sqrt(n)+1):
 | >       if n % i == 0:
 | >          return [i] + factors(n/i, i)
 | >    return [n]
 | 
 | def factors(n, highestsofar=2, factorssofar=None):
 | 	if factorssofar is None:
 | 		factorssofar = []
 | 	for i in range(highestsofar, math.sqrt(n)+1):
 | 		if n % i == 0:
 | 			factorssofar.append(i)
 | 			return factors(n/i, i, factorssofar)
 | 	factorssofar.append(n)
 | 	return factorssofar
 | 
 | Is more efficient, and almost as clear.
 | 

Why not 

def factors( n , highestsofar=2 , factorssofar=[] ) :
	...

Then when the client calls it
	result = factors( number , factorssofar=[] )
The list will be empty.  One less arg to pass in the recursion and also removes
the need for the "if ( factorssofar == None )"  check.  (I know the default arg
is only evaluated once, but that can be useful in this case)

 | --
 | Moshe Zadka <moshez@math.huji.ac.il> -- 95855124
 | http://advogato.org/person/moshez
 | 
 
Does python do tail-recursion yet?  If so, then Moshe's is definitely more
efficient (read better).  If not, I think the previous solution is easier to
read, but both are quite clear.

Just my $0.02.

-D




From scarblac@pino.selwerd.nl  Tue Nov 21 15:18:10 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 21 Nov 2000 16:18:10 +0100
Subject: [Tutor] exercise is recursion
In-Reply-To: <20001121095035.B12719@westsidecnc.rh.rit.edu>; from dsh8290@rit.edu on Tue, Nov 21, 2000 at 09:50:35AM -0500
References: <20001121144806.A3004@pino.selwerd.nl> <Pine.GSO.4.10.10011211618520.16334-100000@sundial> <20001121095035.B12719@westsidecnc.rh.rit.edu>
Message-ID: <20001121161810.A5497@pino.selwerd.nl>

On Tue, Nov 21, 2000 at 09:50:35AM -0500, D-Man wrote:
> Why not 
> 
> def factors( n , highestsofar=2 , factorssofar=[] ) :
> 	...
> 
> Then when the client calls it
> 	result = factors( number , factorssofar=[] )
> The list will be empty.  One less arg to pass in the recursion and also removes
> the need for the "if ( factorssofar == None )"  check.  (I know the default arg
> is only evaluated once, but that can be useful in this case)

That's a common gotcha, the [] is only evaluated once, when the function
is defined.

That means that if you call the function more than once, factorssofar will
not be an empty list anymore, since you changed it! Don't see how that
is useful.

Moshe's factorssofar=None (and then set it to [] if still None) is the
standard workaround.

> Does python do tail-recursion yet?  If so, then Moshe's is definitely more
> efficient (read better).  If not, I think the previous solution is easier to
> read, but both are quite clear.

Python does tail recursion just fine, just not tail recursion *optimization*
;-)

-- 
Remco Gerlich


From dsh8290@rit.edu  Tue Nov 21 16:01:49 2000
From: dsh8290@rit.edu (D-Man)
Date: Tue, 21 Nov 2000 11:01:49 -0500
Subject: [Tutor] exercise is recursion
In-Reply-To: <20001121161810.A5497@pino.selwerd.nl>; from scarblac@pino.selwerd.nl on Tue, Nov 21, 2000 at 10:18:10 -0500
References: <20001121144806.A3004@pino.selwerd.nl> <Pine.GSO.4.10.10011211618520.16334-100000@sundial> <20001121095035.B12719@westsidecnc.rh.rit.edu> <"from dsh8290"@rit.edu> <20001121161810.A5497@pino.selwerd.nl>
Message-ID: <20001121110149.A12914@westsidecnc.rh.rit.edu>

On Tue, 21 Nov 2000 10:18:10 Remco Gerlich wrote:
 | On Tue, Nov 21, 2000 at 09:50:35AM -0500, D-Man wrote:
 | > Why not 
 | > 
 | > def factors( n , highestsofar=2 , factorssofar=[] ) :
 | > 	...
 | > 
 | > Then when the client calls it
 | > 	result = factors( number , factorssofar=[] )
 | > The list will be empty.  One less arg to pass in the recursion and also
 | removes
 | > the need for the "if ( factorssofar == None )"  check.  (I know the default
 | arg
 | > is only evaluated once, but that can be useful in this case)
 | 
 | That's a common gotcha, the [] is only evaluated once, when the function
 | is defined.
 | 
 | That means that if you call the function more than once, factorssofar will
 | not be an empty list anymore, since you changed it! Don't see how that
 | is useful.

I realized that.  That's why I said the client would pass it the empty list when
it called it,  or maybe make a function that set's it to the empty list.  It
would be useful b/c the function doesn't have to pass itself the modified list.

Just a tradeoff and style decision.

 | 
 | Moshe's factorssofar=None (and then set it to [] if still None) is the
 | standard workaround.
 | 
 | > Does python do tail-recursion yet?  If so, then Moshe's is definitely more
 | > efficient (read better).  If not, I think the previous solution is easier
 | to
 | > read, but both are quite clear.
 | 
 | Python does tail recursion just fine, just not tail recursion *optimization*
 | ;-)

Yes, I meant *optimization*.  :-)

 | 
 | -- 
 | Remco Gerlich


-D



From scarblac@pino.selwerd.nl  Tue Nov 21 16:14:58 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 21 Nov 2000 17:14:58 +0100
Subject: [Tutor] exercise is recursion
In-Reply-To: <20001121110149.A12914@westsidecnc.rh.rit.edu>; from dsh8290@rit.edu on Tue, Nov 21, 2000 at 11:01:49AM -0500
References: <20001121144806.A3004@pino.selwerd.nl> <Pine.GSO.4.10.10011211618520.16334-100000@sundial> <20001121095035.B12719@westsidecnc.rh.rit.edu> <"from <20001121161810.A5497@pino.selwerd.nl> <20001121110149.A12914@westsidecnc.rh.rit.edu>
Message-ID: <20001121171458.A5590@pino.selwerd.nl>

On Tue, Nov 21, 2000 at 11:01:49AM -0500, D-Man wrote:
> I realized that.  That's why I said the client would pass it the empty list when
> it called it,  or maybe make a function that set's it to the empty list.  It
> would be useful b/c the function doesn't have to pass itself the modified list.
> 
> Just a tradeoff and style decision.

Passing it the empty list when calling it doesn't work, since then the default
argument of the recursive calls would still be the same list as when it
was def'd. Unless you also pass the list to the recursive calls, and then
you're using a default argument that has to be filled in all the time...

A wrapper function that sets it to the empty list could work, but it couldn't
do 'l = []', it'd have to do 'l[:]=[]' so it stays the same list. Very
confusing. And you don't really save anything, you just pass the list
implicitly instead of explicitly...

You're basically using the default argument as a global variable for all
the function calls, except that it has to be cleared in an awkward way.

I think it's a style decision alright, with a very clear outcome ;-)

-- 
Remco Gerlich


From gubitz@netcologne.de  Tue Nov 21 17:34:34 2000
From: gubitz@netcologne.de (Hans Gubitz)
Date: Tue, 21 Nov 2000 18:34:34 +0100
Subject: [Tutor] urlopen
Message-ID: <20001121183434.A31213@pumuckl.red.suelz>

I want to access to a web-site by
  urllib.urlopen(url).read()

How can I manage that while sitting behind a proxy?

hg

-- 
Hans Gubitz <gubitz@netcologne.de>



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 21 18:00:36 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 21 Nov 2000 10:00:36 -0800 (PST)
Subject: [Tutor] Library Reference for PRINT
In-Reply-To: <000a01c053b0$31b30820$100aa8c0@claudiu>
Message-ID: <Pine.LNX.4.21.0011210958200.31780-100000@hkn.eecs.berkeley.edu>

On Tue, 21 Nov 2000, Chiculita Claudiu wrote:

> Where can I find Python Library Reference
> in a more compact form sa I can 
> arrange it and print it.
> I know there is also a PDF, but I cannot
> afford to print 450 pag. (I need to shrink 
> and rearrange it to take less sapce)

Apologies in advance for sounding like a commercial.  *grin*

You may want to buy David Beazley's "Python Essential Reference"; it's
published by New Riders, and is one of the best references I've seen.  
Beazley condensed the library reference and somehow managed to squeeze the
library core into his book.



From charlie@webmind.com  Tue Nov 21 18:16:38 2000
From: charlie@webmind.com (Charlie Derr)
Date: Tue, 21 Nov 2000 13:16:38 -0500
Subject: [Tutor] urlopen
In-Reply-To: <20001121183434.A31213@pumuckl.red.suelz>
Message-ID: <NDBBLJJLLFOJMLCMJPLOCEDKFNAA.charlie@webmind.com>

I think if you set an environment variable named http_proxy this will work.

in windoze:

set http_proxy=http://<address_of_your_proxy_machine>

w/bash:

export http_proxy=http://<address_of_your_proxy_machine>

	good luck,
		~c

|-----Original Message-----
|From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
|Hans Gubitz
|Sent: Tuesday, November 21, 2000 12:35 PM
|To: tutor@python.org
|Subject: [Tutor] urlopen
|
|
|I want to access to a web-site by
|  urllib.urlopen(url).read()
|
|How can I manage that while sitting behind a proxy?
|
|hg
|
|-- 
|Hans Gubitz <gubitz@netcologne.de>
|
|
|_______________________________________________
|Tutor maillist  -  Tutor@python.org
|http://www.python.org/mailman/listinfo/tutor
|


From deirdre@deirdre.net  Tue Nov 21 18:45:53 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Tue, 21 Nov 2000 10:45:53 -0800 (PST)
Subject: [Tutor] Library Reference for PRINT
In-Reply-To: <Pine.LNX.4.21.0011210958200.31780-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.10.10011211043230.8988-100000@rockhopper.deirdre.org>

On Tue, 21 Nov 2000, Daniel Yoo wrote:

> Apologies in advance for sounding like a commercial.  *grin*
> 
> You may want to buy David Beazley's "Python Essential Reference"; it's
> published by New Riders, and is one of the best references I've seen.  
> Beazley condensed the library reference and somehow managed to squeeze
> the library core into his book.

All I have to say is that, of all the books on computers I've got (some of
which I wrote), it's the one I reach for most frequently.

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"You had thesaurus flakes for breakfast again, didn't you?"
                                                 -- Eric Williams



From FxItAL@aol.com  Tue Nov 21 18:30:45 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Tue, 21 Nov 2000 13:30:45 EST
Subject: [Tutor] Cancelling Threads
Message-ID: <d9.c9130c2.274c1955@aol.com>

--part1_d9.c9130c2.274c1955_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Hi All,

       I've a small program that uses one thread which is invoked with a 
"Start" Button.  I can cancel this thread with a "Cancel & Close" Button. My 
Question is how do I associate the "Cancel & Close" command function with the 
Windows Close Program "X" in the upper right hand corner of the program box?

"Cancel & Close" function:

def EndProg2():
    UserEntryMin.set("0")
    UserEntryHour.set("0")
    end.set("2")
    ActionButCmd()
    root.destroy()

Thanks for any help, Al

--part1_d9.c9130c2.274c1955_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

<HTML><FONT  SIZE=2>Hi All,
<BR>
<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I've a small program that uses one thread which is invoked with a <BR>"Start" Button. &nbsp;I can cancel this thread with a "Cancel &amp; Close" Button. My <BR>Question is how do I associate the "Cancel &amp; Close" command function with the <BR>Windows Close Program "X" in the upper right hand corner of the program box?
<BR>
<BR>"Cancel &amp; Close" function:
<BR>
<BR>def EndProg2():
<BR> &nbsp;&nbsp;&nbsp;UserEntryMin.set("0")
<BR> &nbsp;&nbsp;&nbsp;UserEntryHour.set("0")
<BR> &nbsp;&nbsp;&nbsp;end.set("2")
<BR> &nbsp;&nbsp;&nbsp;ActionButCmd()
<BR> &nbsp;&nbsp;&nbsp;root.destroy()
<BR>
<BR>Thanks for any help, Al</FONT></HTML>

--part1_d9.c9130c2.274c1955_boundary--


From rick@niof.net  Tue Nov 21 20:27:56 2000
From: rick@niof.net (Rick Pasotto)
Date: Tue, 21 Nov 2000 15:27:56 -0500
Subject: [Tutor] TKinter event binding
Message-ID: <20001121152755.D2644@tc.niof.net>

Why would the second binding work but not the first? These two lines are
shown just as they are in my program. Double clicking the left mouse
button calls the function but pressing the return key does not. This is
within a Listbox.

		self.lb.bind("<Return>",self.got_sel)
		self.lb.bind("<Double-Button-1>",self.got_sel)

-- 
"The suppression of unnecessary offices, of useless establishments and
expenses, enabled us to discontinue our internal taxes.   These
covering our land with officers and opening our doors to their
intrusions, had already begun that process of domiciliary vexation
which once entered is scarcely to be restrained from reaching,
successively, every article of property and produce."
		-- Thomas Jefferson
		   Rick Pasotto email: rickp@telocity.com


From lkuhn@internews.org  Tue Nov 21 23:59:39 2000
From: lkuhn@internews.org (Larry Kuhn)
Date: Tue, 21 Nov 2000 15:59:39 -0800
Subject: [Tutor] newbie questions
Message-ID: <NDBBIAJMGKMMNOPFLJOCMELOCGAA.lkuhn@internews.org>

Hi,

I am familiar with some scripting languages and have done some programming
in the past (not in C++ or at the systems level). Python has come to my
attention and has been highly endorsed by other professionals whom I
respect. Although I am determined to  give the effort it takes to learn
Python, however, I'm having trouble doing some simple things;

My initial goal; to be able to specify a Windows directory (and all
directories beneath it) and have file listings returned as a text file based
on modification date(s) that a user specifies.

It doesn't seem that hard, but thusfar, I'm only able to get os.path to
work, and listdir(pathInaVarName)to work. I have Mark Hammond's Win32api's
installed, and it seems like I need to be using something called PyIDLobject
that a returns GetFileAttributes()function, but I'm not sure if there's an
easy way to do what I want.

In theory, I should be able to assign a path to a variable, assign a date to
another variable, create a loop that compares the file modification time to
the date in the variable, write the name and path of a file that matches the
date to a text file, increment the loop, and walk the directory tree to the
bottom. I realize theory and practice are often different from each other.

Perhaps I'm starting off over my head, or maybe I need to realize this is
all pretty low-level stuff and just get used to it being so cryptic.

Any help or pointers would be appreciated.


Best,

Larry Kuhn




From spirou@carolo.com  Wed Nov 22 00:56:40 2000
From: spirou@carolo.com (Denis)
Date: Wed, 22 Nov 2000 01:56:40 +0100
Subject: [Tutor] newbie questions (directory listing)
In-Reply-To: <NDBBIAJMGKMMNOPFLJOCMELOCGAA.lkuhn@internews.org>; from lkuhn@internews.org on Tue, Nov 21, 2000 at 03:59:39PM -0800
References: <NDBBIAJMGKMMNOPFLJOCMELOCGAA.lkuhn@internews.org>
Message-ID: <20001122015638.D4815@carolo.com>

Le Tue, Nov 21, 2000 at 03:59:39PM -0800, Larry Kuhn pianota:
> In theory, I should be able to assign a path to a variable,
> assign a date to another variable, create a loop that compares
> the file modification time to the date in the variable, write
> the name and path of a file that matches the date to a text
> file, increment the loop, and walk the directory tree to the
> bottom. I realize theory and practice are often different
> from each other.

Have a look at os.path.walk() and os.stat()

>>> import os
>>> print os.path.walk.__doc__
walk(top,func,args) calls func(arg, d, files) for each directory "d" 
in the tree  rooted at "top" (including "top" itself).  "files" is a list
of all the files and subdirs in directory "d".

>>> print os.stat.__doc__
stat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)
Perform a stat system call on the given path.
>>> 

Have fun
-- 
Denis FRERE
P3B    : Club Free-Pytho-Linuxien Caroloregien http://www.p3b.org
Aragne : Internet - Reseaux - Formations  http://www.aragne.com


From bimal291@hotmail.com  Wed Nov 22 10:31:20 2000
From: bimal291@hotmail.com (bimal shah)
Date: Wed, 22 Nov 2000 10:31:20 -0000
Subject: [Tutor] (no subject)
Message-ID: <F3ikieqXItMcx4vvsGO0000165e@hotmail.com>

Hi actually i was executing the follwing code:


# \user\local\bin\python

import dbi, odbc     # ODBC modules

try:
        s = odbc.odbc('bimal/bimal/bimal')

# i have given SYSTEM DSN= "bimal"
# and also during advanced setting of DSN
# login="bimal" and password="bimal"

        cur = s.cursor()
        cur.execute('select * from bimal1')

#bimal1 is my table from database="bimal"
#i had set the path of system database "bimal" during setting of system #DSN
        print cur.description
        for tup in cur.description:
                print tup[0],
        print
        while 1:
                rec = cur.fetchmany(10)
                if not rec: break
                print rec
except NameError,e:
        print 'error ', e, 'undefined'

#  I put my .py file in d:/python20/win32/ where dbi.dll and odbc.pyd #is 
exists.

After executing files i am getting following traceback:


Traceback (most recent call last):
File "d:\python20\pythonwin\pywin\framework\scriptutils.py", line 301, in 
RunScript
    exec codeObject in __main__.__dict__
  File "D:\Python20\win32\python fiels\dbtest.py", line 10, in ?
    s = odbc.odbc('bimal/bimal/bimal')
dbi.operation-error: [Microsoft][ODBC Microsoft Access Driver]General error 
Not enough information to connect to this DSN with SQLConnect.   Use 
SQLDriverConnect. in LOGIN
>>>

          i am feeling that some thing problem is with importing module.
so  please direct me for solving my problem.



_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com



From alan.gauld@bt.com  Wed Nov 22 11:33:48 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 22 Nov 2000 11:33:48 -0000
Subject: [Tutor] exercise is recursion (more problems with my comp)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D41A@mbtlipnt02.btlabs.bt.co.uk>

> It's been a very long time since I wrote a program that used recursion
> (Hmmm...college...Pascal). I'd forgotten what a pain in the 
> butt it is to
> debug. Any hints?

To debug recursive routines I always put in an entry and exit 
print statement:

def recursingfunc(p1,p2):
    print "entering recursingfunc(%s,%s)" % (p1,p2)
    # ... so it here ...
    print "returning %s from recursingfunc" % retvalue

The trace from that is usually enough to show me where 
I've gone wrong.

Alan G.



From alan.gauld@bt.com  Wed Nov 22 11:28:36 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 22 Nov 2000 11:28:36 -0000
Subject: [Tutor] Variable Question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D419@mbtlipnt02.btlabs.bt.co.uk>

> Alan Gauld's tutorial at:
> 
    http://www.crosswinds.net/~agauld/

has a tutorial on object oriented programming, and it seems to be a good
introduction for object orientation stuff.

Shucks, thank you :-)

The page has a link to the cetus-links website:

http://www.cetus-links.org/

which has lots of tutorials and articles and zillions of links 
to other OO resources.

Bruce Eckel's pages have some electronic books that are good too, 
but they are full size books of several hundered pages each.

If you can afford to buy a book then I strongly recommend 
Timothy Budd's OOP book.

HTH,

Alan G.


From alan.gauld@bt.com  Wed Nov 22 17:06:01 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 22 Nov 2000 17:06:01 -0000
Subject: [Tutor] Library Reference for PRINT
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D41C@mbtlipnt02.btlabs.bt.co.uk>

> > You may want to buy David Beazley's "Python Essential 
> > the library core into his book.
> 
> All I have to say is that, of all the books on computers I've 
> got (some of which I wrote), it's the one I reach for most frequently.

I just bought this last week - following the recommendations here.

Yes, it is very good and quite small (too small IMHO, I'd like the 
font 1 point size bigger!). Unfortunately it doesn't cover more 
than about 50% of the Library, but it is the 50% you use 80% of 
the time.

It goes straight to the top of my 'Python books for experienced 
programmers' list.

Alan G.



From alan.gauld@bt.com  Wed Nov 22 17:36:31 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 22 Nov 2000 17:36:31 -0000
Subject: [Tutor] newbie questions
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D41D@mbtlipnt02.btlabs.bt.co.uk>

> It doesn't seem that hard, but thusfar, I'm only able to get 
> os.path to work, and listdir(pathInaVarName)to work. 

See the previous reply about using os.stat too.

> I have Mark Hammond's Win32api's
> installed, and it seems like I need to be using something 
> called PyIDLobject that a returns GetFileAttributes()function, 

I suspect you need GetFileTimes() since thats whjat the Win32 API 
recommends for reading times. [The former returns whether its a 
read only, system file etc...]

> Perhaps I'm starting off over my head, or maybe I need to 
> realize this is all pretty low-level stuff and just get used 
> to it being so cryptic.

It is pretty low level but Python does make most of this 
easy via the os, glob modules etc.

Alan g.


From rmallett@rational.com  Wed Nov 22 18:47:21 2000
From: rmallett@rational.com (Mallett, Roger)
Date: Wed, 22 Nov 2000 10:47:21 -0800
Subject: [Tutor] time.sleep
Message-ID: <D1F8EEAA065FD411B7E200D0B73EB0EA01231DAC@CUPEX2.rational.com>

Concerning the time.sleep function I have a couple of questions.

In TEST 1 (below), I placed a sleep between two prints.  However, when the
code was executed, the sleep occurred before the first print displayed to
the screen.
	Question:  Why did the sleep occur before "line 1" was printed to
the screen?

In TEST 2 (below), I attempted to pass in a value to sleep which resulted in
an error.  I also tried passing in a long, same results.  
	Question:  Why the error?  How should I pass a value into sleep?

Any assistance is greatly appreciated.

Thank you,
Roger Mallett


TEST 1
	>>> def test1():
	... 	print 'line 1'
	... 	time.sleep(2)
	... 	print 'line 2'
	... 	
	>>> test1()
	line 1
	line 2


TEST 2
	>>> def test2(time):
	... 	print 'line 1'
	... 	time.sleep(time)
	... 	print 'line 2'
	... 	
	>>> test2(1)
	line 1
	Traceback (innermost last):
	  File "<interactive input>", line 1, in ?
	  File "<interactive input>", line 3, in test2
	AttributeError: 'int' object has no attribute 'sleep'
	>>> 


From scarblac@pino.selwerd.nl  Wed Nov 22 19:03:28 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 22 Nov 2000 20:03:28 +0100
Subject: [Tutor] time.sleep
In-Reply-To: <D1F8EEAA065FD411B7E200D0B73EB0EA01231DAC@CUPEX2.rational.com>; from rmallett@rational.com on Wed, Nov 22, 2000 at 10:47:21AM -0800
References: <D1F8EEAA065FD411B7E200D0B73EB0EA01231DAC@CUPEX2.rational.com>
Message-ID: <20001122200328.A7256@pino.selwerd.nl>

On Wed, Nov 22, 2000 at 10:47:21AM -0800, Mallett, Roger wrote:
> Concerning the time.sleep function I have a couple of questions.
> 
> In TEST 1 (below), I placed a sleep between two prints.  However, when the
> code was executed, the sleep occurred before the first print displayed to
> the screen.
> 	Question:  Why did the sleep occur before "line 1" was printed to
> the screen?

Hmm, this doesn't happen when I try it. But then, I don't know about your
platform, how exactly you try it, etc. The output is probably buffered; it's
still in the buffer when the program sleeps, you only see the print when
the buffer is flushed later.

Two options that come to mind:
- Flush stdout before the sleep with sys.stdout.flush()
- Start Python with the -u option to disable all buffering on stdin, stdout
  and stderr


> In TEST 2 (below), I attempted to pass in a value to sleep which resulted in
> an error.  I also tried passing in a long, same results.  
> 	Question:  Why the error?  How should I pass a value into sleep?
>
> TEST 2
> 	>>> def test2(time):
> 	... 	print 'line 1'
> 	... 	time.sleep(time)
> 	... 	print 'line 2'
> 	... 	
> 	>>> test2(1)
> 	line 1
> 	Traceback (innermost last):
> 	  File "<interactive input>", line 1, in ?
> 	  File "<interactive input>", line 3, in test2
> 	AttributeError: 'int' object has no attribute 'sleep'
> 	>>> 

You called your local variable "time". So "time.sleep" is not the function
"sleep" in module "time", but instead the method "sleep" on the number 1...
Give your variable a name that doesn't clash with the module's name.

Remco Gerlich


From deirdre@deirdre.net  Wed Nov 22 20:39:47 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Wed, 22 Nov 2000 12:39:47 -0800 (PST)
Subject: [Tutor] time.sleep
In-Reply-To: <20001122200328.A7256@pino.selwerd.nl>
Message-ID: <Pine.LNX.4.10.10011221238280.14942-100000@rockhopper.deirdre.org>

On Wed, 22 Nov 2000, Remco Gerlich wrote:

> Hmm, this doesn't happen when I try it. But then, I don't know about
> your platform, how exactly you try it, etc. The output is probably
> buffered; it's still in the buffer when the program sleeps, you only
> see the print when the buffer is flushed later.

Yes, I also get the expected results. I've noticed that the result is held
in a buffer if the print line ends in a comma, but I've not seen it if it
doesn't.

> Two options that come to mind:
> - Flush stdout before the sleep with sys.stdout.flush()
> - Start Python with the -u option to disable all buffering on stdin, stdout
>   and stderr

Good workarounds.

-- 
_Deirdre      *      http://www.sfknit.org      *      http://www.deirdre.net
"Our society has not yet gone so far as to place blind faith in machines. In 
almost all endeavors, humans routinely correct the errors of machines."
                                                     - Florida Supreme Court



From arcege@shore.net  Wed Nov 22 20:42:34 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Wed, 22 Nov 2000 15:42:34 -0500 (EST)
Subject: [Tutor] newbie questions
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D41D@mbtlipnt02.btlabs.bt.co.uk> from "alan.gauld@bt.com" at Nov 22, 2000 05:36:31 PM
Message-ID: <200011222042.PAA05569@northshore.shore.net>

> > Perhaps I'm starting off over my head, or maybe I need to 
> > realize this is all pretty low-level stuff and just get used 
> > to it being so cryptic.
> 
> It is pretty low level but Python does make most of this 
> easy via the os, glob modules etc.

There is also the standard function os.path.getmtime(), which
simplifies this (and at one time was going to use GetFileTimes() if the
win32api module was importable).

  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------


From dyoo@hkn.eecs.berkeley.edu  Wed Nov 22 21:36:23 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 22 Nov 2000 13:36:23 -0800 (PST)
Subject: [Tutor] exercise is recursion (more problems with my comp)
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D41A@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.LNX.4.21.0011221334090.3427-100000@hkn.eecs.berkeley.edu>

On Wed, 22 Nov 2000 alan.gauld@bt.com wrote:

> > It's been a very long time since I wrote a program that used
> recursion > (Hmmm...college...Pascal). I'd forgotten what a pain in
> the > butt it is to > debug. Any hints?

One of the obvious things to do is make sure that your function works on
base cases.  Also, you can try really simple cases where you already know
the answer, and make sure that your function duplicates these answers.  If
you compare outputs, that will often make it easier to see where the bug
is occuring.



From babyboy@oninet.pt  Wed Nov 22 23:45:45 2000
From: babyboy@oninet.pt (wilson edgar pinto)
Date: Wed, 22 Nov 2000 23:45:45 -0000
Subject: [Tutor] (no subject)
Message-ID: <00d201c054de$56033ea0$170c3ad5@x0q0w3>

This is a multi-part message in MIME format.

------=_NextPart_000_00CD_01C054DE.55323300
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


hiya
this migth sound like a stupid question, but how do i start=20
Tcl from a DOS promt.=20

------=_NextPart_000_00CD_01C054DE.55323300
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4207.2601" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>hiya</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>this migth sound like a stupid =
question, but how do=20
i start </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Tcl from a DOS promt. =
</FONT></DIV></BODY></HTML>

------=_NextPart_000_00CD_01C054DE.55323300--



From scarblac@pino.selwerd.nl  Thu Nov 23 00:08:09 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 23 Nov 2000 01:08:09 +0100
Subject: [Tutor] (no subject)
In-Reply-To: <00d201c054de$56033ea0$170c3ad5@x0q0w3>; from babyboy@oninet.pt on Wed, Nov 22, 2000 at 11:45:45PM -0000
References: <00d201c054de$56033ea0$170c3ad5@x0q0w3>
Message-ID: <20001123010809.A7651@pino.selwerd.nl>

On Wed, Nov 22, 2000 at 11:45:45PM -0000, wilson edgar pinto wrote:
> this migth sound like a stupid question, but how do i start 
> Tcl from a DOS promt. 

Hmm. This is a Python list you know, not a Tcl list ;).

But anyway, Tcl's interactive shell is called "tclsh". Try typing that
into a DOS prompt. If it doesn't work, your path isn't setup correctly;
try to cd to the directory with tclsh in it.

If you actually wanted to post a Python question, try again :)

-- 
Remco Gerlich


From gtnorton@earthlink.net  Thu Nov 23 07:35:36 2000
From: gtnorton@earthlink.net (Glenn T. Norton)
Date: Wed, 22 Nov 2000 23:35:36 -0800
Subject: [Tutor] (no subject)
References: <00d201c054de$56033ea0$170c3ad5@x0q0w3>
Message-ID: <3A1CC8C8.194381EC@earthlink.net>


wilson edgar pinto wrote:

>  hiyathis migth sound like a stupid question, but how do i startTcl
> from a DOS promt.
>
> O.K....
> Open the DOS prompt window.
> You should get C:\WINDOWS>.
> My TCL shell is located in Program Files\TCL\BIN
> So, at the prompt type..
> cd C:\progra~1\tcl\bin
> When you get to this path name, type:
> tclsh80 (Or whatever version of the shell you have)
>
> Hope this helps.
> Good luck,
> GTNorton



From wilkins@iinet.net.au  Thu Nov 23 10:17:56 2000
From: wilkins@iinet.net.au (Richard Wilkins)
Date: Thu, 23 Nov 2000 18:17:56 +0800
Subject: [Tutor] Class stuff
Message-ID: <MABBIFAJGJIHIKKDOGHOEEFJCCAA.wilkins@iinet.net.au>

Hello everyone,

I'm _positive_ it's a newbie question, so brace yourselves.

I have a regular old dictionary called Rooms, and a class called Room.

Room is defined as follows -

class Room:
	def __init__(self,x,y,z):
	self.Position=(x,y,z)
	self.this=self
	if Rooms.has_key(str(x)+','+str(y)+','+str(z)):
		print 'Room already exists'
	else:
		Rooms[str(x)+','+str(y)+','+str(z)]=self


When I create an object it all works fine. When I type Rooms at the
interpreter prompt, it says:
"call of non-function (type None)"

I've debugged it down to the last line, so that referencing the class as
self does not work. I need to know how to reference the class from
within itself. I don't want to have to provide a function that wraps the
class...:(

Can someone please help me with my problem?

Thanks,
Andrew Wilkins




From rob@jam.rr.com  Thu Nov 23 15:27:48 2000
From: rob@jam.rr.com (R. A.)
Date: Thu, 23 Nov 2000 09:27:48 -0600
Subject: [Tutor] Class stuff
References: <MABBIFAJGJIHIKKDOGHOEEFJCCAA.wilkins@iinet.net.au>
Message-ID: <3A1D3774.7B3FAC31@jam.rr.com>

I saved your snip of code as Room.py on my 'puter and typed "import
Room" in IDLE.  After making a change to indentation, it ran without
complaint.

Rob A.

Richard Wilkins wrote:
> 
> Hello everyone,
> 
> I'm _positive_ it's a newbie question, so brace yourselves.
> 
> I have a regular old dictionary called Rooms, and a class called Room.
> 
> Room is defined as follows -
> 
> class Room:
>         def __init__(self,x,y,z):
>         self.Position=(x,y,z)
>         self.this=self
>         if Rooms.has_key(str(x)+','+str(y)+','+str(z)):
>                 print 'Room already exists'
>         else:
>                 Rooms[str(x)+','+str(y)+','+str(z)]=self
> 
> When I create an object it all works fine. When I type Rooms at the
> interpreter prompt, it says:
> "call of non-function (type None)"
> 
> I've debugged it down to the last line, so that referencing the class as
> self does not work. I need to know how to reference the class from
> within itself. I don't want to have to provide a function that wraps the
> class...:(
> 
> Can someone please help me with my problem?
> 
> Thanks,
> Andrew Wilkins
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor


From alan.gauld@bt.com  Thu Nov 23 17:29:44 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 23 Nov 2000 17:29:44 -0000
Subject: [Tutor] Class stuff
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D429@mbtlipnt02.btlabs.bt.co.uk>

> I have a regular old dictionary called Rooms, and a class called Room.

I assume you have actually created an empty dictionary somewhere:

Rooms = {}

> Room is defined as follows -
> 
> class Room:
> 	def __init__(self,x,y,z):
> 	self.Position=(x,y,z)
> 	self.this=self
> 	if Rooms.has_key(str(x)+','+str(y)+','+str(z)):
> 		print 'Room already exists'
> 	else:
> 		Rooms[str(x)+','+str(y)+','+str(z)]=self

Assuming the indentation is only wrong in the mail 
- otherwise youd get a syntax err I suspect....

it looks OK.

How exactly are you using this? Is it in a module?
Is the Rooms declaration in the same module, in other 
words are you doing something like this:

>>> import room
>>> Rooms = {}
>>> for i in range(5):
       Room(i,i+1,i+2)

>>> Rooms


Or is it all in a single file? Or even all at the >>> prompt?

> When I create an object it all works fine. When I type Rooms at the
> interpreter prompt, it says:
> "call of non-function (type None)"

I'm not clear what your doing, Heres a snapshot of an interactive session:

>>> r = {}
>>> class c:
...  def __init__(s,i):
...    r[i] = s
...
>>> r
{}
>>> c(1)
<__main__.c instance at 7f77c0>
>>> r
{1: <__main__.c instance at 7f77c0>}

Seems to do what you are trying to do?


> 
> I've debugged it down to the last line, so that referencing 
> the class as self does not work. 

It should do.

Alan G.


From kalle@gnupung.net  Thu Nov 23 19:40:22 2000
From: kalle@gnupung.net (Kalle Svensson)
Date: Thu, 23 Nov 2000 20:40:22 +0100
Subject: [Tutor] Class stuff
In-Reply-To: <MABBIFAJGJIHIKKDOGHOEEFJCCAA.wilkins@iinet.net.au>; from wilkins@iinet.net.au on Thu, Nov 23, 2000 at 06:17:56PM +0800
References: <MABBIFAJGJIHIKKDOGHOEEFJCCAA.wilkins@iinet.net.au>
Message-ID: <20001123204022.A803@gnupung.net>

--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Sez Richard Wilkins:
> Hello everyone,

Hi!

> I'm _positive_ it's a newbie question, so brace yourselves.
>=20
> I have a regular old dictionary called Rooms, and a class called Room.

This dictionary is created somewhere else?  I would suggest passing it as a
parameter to the constructor.  Otherwise it'll have to be a global, and you
never know about globals... ;)  Anyway, look at the bottom for another
solution.

Also, it think it is customary not to use capital letters in variable names,
at least not the first character.  This is a matter of taste, of course, but
I find it helps to save the capitals for class names.

> Room is defined as follows -
>=20
> class Room:
> 	def __init__(self,x,y,z):
> 	        self.Position=3D(x,y,z)
> 	        self.this=3Dself

What is this for?  It creates a circular reference:
self has a reference to this that is a reference to self that has a
reference to this that is a reference to self that ...

> 	        if Rooms.has_key(str(x)+','+str(y)+','+str(z)):
> 		        print 'Room already exists'
> 	        else:
> 		        Rooms[str(x)+','+str(y)+','+str(z)]=3Dself
>=20
>=20
> When I create an object it all works fine. When I type Rooms at the
> interpreter prompt, it says:
> "call of non-function (type None)"
>=20
> I've debugged it down to the last line, so that referencing the class as
> self does not work. I need to know how to reference the class from
> within itself. I don't want to have to provide a function that wraps the
> class...:(

The class and the instance are two different things.  If you want to
reference tha instance, self should work.  The class (Room, in this case)
is available through instance.__class__.  An example *might* make it cleare=
r:

>>> class Point:
=2E..     def __init__(self, x, y):
=2E..         self.x, self.y =3D x, y
=2E..         print "Created with x =3D", x, ", y =3D", y
=2E..     def pp(self):
=2E..         print "Coordinates are", self.x, "and", self.y
=2E..     def hi(self):
=2E..         print self, "is an instance of", self.__class__
=2E..=20
>>> p =3D Point(1, 1)
Created with x =3D 1 , y =3D 1
>>> p.hi()
<__main__.Point instance at 8072688> is an instance of __main__.Point
>>> p.pp()
Coordinates are 1 and 1
>>> p.__class__
<class __main__.Point at 80722f8>
>>> p
<__main__.Point instance at 8072688>
>>> p.x
1
>>>=20


> Can someone please help me with my problem?
>=20

I don't know if it is much help, but:
Your code checks if the room exists in the dictionary, and adds it if not,
right?  To me, it feels a bit weird to let the class handle where it is
stored.  I'd suggest another method of controlling your rooms, introducing
another class.  You might call it Dungeon or House or something.
Example:

class House:
    def __init__(self):
        self.rooms =3D {}
    def add_room(self, room):
        if self.rooms.has_key("%s,%s,%s" % room.position):
	    print 'Room already exists'
	else:
	    self.rooms["%s,%s,%s" % room.position] =3D room
	    print 'OK'
	   =20
class Room:
    def __init__(self, x, y, z):
        self.position =3D (x, y, z)

Then, you could do something like:
>>> h =3D House()
>>> r =3D Room(1, 1, 1)
>>> h.add_room(r)
OK
>>> h.add_room(r)
Room already exists
>>> h.rooms["1,1,1"]
<__main__.Room instance at 8073298>
>>> r
<__main__.Room instance at 8073298>
>>>=20

HTH,
  Kalle
--=20
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD

--oyUTqETQ0mS9luUI
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.2 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6HXKmdNeA1787sd0RAmTAAJ9EXleR0gEfbTnG2QUa3jJu+nuJNwCcDycp
u+f+DvjouiM7xvlFIJ38d2A=
=gsHC
-----END PGP SIGNATURE-----

--oyUTqETQ0mS9luUI--


From wilkins@iinet.net.au  Fri Nov 24 01:54:27 2000
From: wilkins@iinet.net.au (Richard Wilkins)
Date: Fri, 24 Nov 2000 09:54:27 +0800
Subject: [Tutor] Re:Class stuff (fixed)
Message-ID: <MABBIFAJGJIHIKKDOGHOGEFLCCAA.wilkins@iinet.net.au>

Hi people,

thanks for you help people, I've actually fixed it, foolish me forgot to
mention he was deriving from his own dictionary class. It's all fixed
now, I just hadn't implemented a method...sorry guys!

Regards, Andrew Wilkins




From chetumal23@excite.com  Fri Nov 24 20:02:14 2000
From: chetumal23@excite.com (john smith smith)
Date: Fri, 24 Nov 2000 12:02:14 -0800 (PST)
Subject: [Tutor] newbie question
Message-ID: <7034622.975096134118.JavaMail.imail@doby.excite.com>

Can someone explain to me how to set the python path in windows98,cause no
one in my neck of the woods seems to be sure.I have more confidence in you
guys anyway.Ive been following the tutorials but it seems i can't import any
of my own modules if i don't have the path.please help.

john.





_______________________________________________________
Tired of slow Internet? Get @Home Broadband Internet
http://www.home.com/xinbox/signup.html



From fjodor@mindless.com  Fri Nov 24 20:12:14 2000
From: fjodor@mindless.com (Joakim Nordin)
Date: Fri, 24 Nov 2000 21:12:14 +0100
Subject: [Tutor] newbie question
References: <7034622.975096134118.JavaMail.imail@doby.excite.com>
Message-ID: <017c01c05652$d62aa580$a21610ac@soderhamnnet.com>

Just add:
SET PATH=C:\Program\Python
(or wherever you installed it)

To your autoexec.bat file. You will need to restart your computor to active
the new path.

Cheers
/jocke


----- Original Message -----
From: "john smith smith" <chetumal23@excite.com>
To: <tutor@python.org>
Sent: Friday, November 24, 2000 9:02 PM
Subject: [Tutor] newbie question


> Can someone explain to me how to set the python path in windows98,cause no
> one in my neck of the woods seems to be sure.I have more confidence in you
> guys anyway.Ive been following the tutorials but it seems i can't import
any
> of my own modules if i don't have the path.please help.
>
> john.
>
>
>
>
>
> _______________________________________________________
> Tired of slow Internet? Get @Home Broadband Internet
> http://www.home.com/xinbox/signup.html
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>



From dyoo@hkn.eecs.berkeley.edu  Fri Nov 24 20:21:29 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 24 Nov 2000 12:21:29 -0800 (PST)
Subject: [Tutor] newbie question
In-Reply-To: <7034622.975096134118.JavaMail.imail@doby.excite.com>
Message-ID: <Pine.LNX.4.21.0011241211421.6126-100000@hkn.eecs.berkeley.edu>

On Fri, 24 Nov 2000, john smith smith wrote:

> Can someone explain to me how to set the python path in windows98,cause no
> one in my neck of the woods seems to be sure.I have more confidence in you
> guys anyway.Ive been following the tutorials but it seems i can't import any
> of my own modules if i don't have the path.please help.

Sure; it sounds like you'll want to set up your PYTHONPATH to point to a
directory that you have saved your modules.  To do this, add a line in
C:\autoexec.bat that says something like:

    SET PYTHONPATH=.;C:\python-2.0\Lib;C:\mymodules;

That period in the beginning makes sure that the current directory is also
accessible for module imports.  You can indicate several paths --- just
separate them with semicolons.

Finally, you may need to restart your computer to reload PYTHONPATH
settings: your system looks at autoexec.bat on system reboots.

Hope this helps!



From craig@osa.att.ne.jp  Sat Nov 25 15:18:23 2000
From: craig@osa.att.ne.jp (Craig Hagerman)
Date: Sun, 26 Nov 2000 00:18:23 +0900
Subject: [Tutor] Freezing a GUI program in Windows?
Message-ID: <200011251511.AAA23345@osa.att.ne.jp>

Hi,

I read in some documentation that 'freezing' a python program that used
Tkinter would not work... but that was documentation for the 1.5 release. I
am wondering if it is possible to freeze a Tkinter-using program under
Python2.0?

More importantly, can someone tell me how to make an executable program? I
hope this isn't a too-trivial question. I usually use Python on Mac
computers (which includes a mac utility "BuildApplication") or Linux, but I
have never had cause to want to make an executable within Linux and I have
never used Python in Windows --- until now. I want to send an executable
program to my brother (who uses Windows). My understanding is that I should
use a "freeze.py" module to create an executable. However, I can not find a
"freeze.py" module anywhere within the standard Windows distribution, nor
can I find any documents to tell me where to go from here.

Help please?

Craig Hagerman


From rob@jam.rr.com  Sat Nov 25 18:27:33 2000
From: rob@jam.rr.com (R. A.)
Date: Sat, 25 Nov 2000 12:27:33 -0600
Subject: [Tutor] Freezing a GUI program in Windows?
References: <200011251511.AAA23345@osa.att.ne.jp>
Message-ID: <3A200495.C0B463CB@jam.rr.com>

You may find the direction you're looking for in the FAQ at the below
URL.  Just go there and search the page for the word freeze.

http://www.python.org/doc/FAQ.html

Rob A

Craig Hagerman wrote:
> 
> Hi,
> 
> I read in some documentation that 'freezing' a python program that used
> Tkinter would not work... but that was documentation for the 1.5 release. I
> am wondering if it is possible to freeze a Tkinter-using program under
> Python2.0?
> 
> More importantly, can someone tell me how to make an executable program? I
> hope this isn't a too-trivial question. I usually use Python on Mac
> computers (which includes a mac utility "BuildApplication") or Linux, but I
> have never had cause to want to make an executable within Linux and I have
> never used Python in Windows --- until now. I want to send an executable
> program to my brother (who uses Windows). My understanding is that I should
> use a "freeze.py" module to create an executable. However, I can not find a
> "freeze.py" module anywhere within the standard Windows distribution, nor
> can I find any documents to tell me where to go from here.
> 
> Help please?
> 
> Craig Hagerman
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor


From rmallett@rational.com  Sat Nov 25 19:38:09 2000
From: rmallett@rational.com (Mallett, Roger)
Date: Sat, 25 Nov 2000 11:38:09 -0800
Subject: [Tutor] escape codes and filenames
Message-ID: <D1F8EEAA065FD411B7E200D0B73EB0EA01231EFF@CUPEX2.rational.com>

I have a series of files that need to be opened.  Several of the files start
with characters normally reserved as Escape codes.

Using
	for filename in filelist:
		x=open(filename,'r')

fails anytime anypart of *filename* contains a "\<escape_code>" sequence.
For example:  if filename is set to "c:\trash.txt", then the file will not
open with the open command above because the "\t" is perceived as an escape
code.

I have therefore written code to scrub each instance of filename to ensure
no escape sequences exist before the open command is executed.

Is there another way to handle this?  I found information about *raw*
commands in the python documentation but couldn't figure out how to work it.

Any ideas of how this type of situation should be handled?

Thank you for your help,

Roger Mallett







From steve@spvi.com  Sat Nov 25 20:02:19 2000
From: steve@spvi.com (Steve Spicklemire)
Date: Sat, 25 Nov 2000 15:02:19 -0500 (EST)
Subject: [Tutor] escape codes and filenames
In-Reply-To: <D1F8EEAA065FD411B7E200D0B73EB0EA01231EFF@CUPEX2.rational.com>
 (rmallett@rational.com)
References: <D1F8EEAA065FD411B7E200D0B73EB0EA01231EFF@CUPEX2.rational.com>
Message-ID: <200011252002.PAA44569@mercury.spvi.com>

Hi Roger,

How did you get filelist? If you type a string into the
interpreter and you want an explicit '\' you need to escape it
thusly: 

filename = "c:\\trash.txt"

If you read a string from a file or keyboard, no escape is required

try the following code:

x = raw_input('enter a string with a "\\" in it... ')
print `x`

does that work for you?
-steve


>>>>> "Mallett," == Mallett, Roger <rmallett@rational.com> writes:

    Mallett,> I have a series of files that need to be opened.
    Mallett,> Several of the files start with characters normally
    Mallett,> reserved as Escape codes.

    Mallett,> Using for filename in filelist: x=open(filename,'r')

    Mallett,> fails anytime anypart of *filename* contains a
    Mallett,> "\<escape_code>" sequence.  For example: if filename is
    Mallett,> set to "c:\trash.txt", then the file will not open with
    Mallett,> the open command above because the "\t" is perceived as
    Mallett,> an escape code.

    Mallett,> I have therefore written code to scrub each instance of
    Mallett,> filename to ensure no escape sequences exist before the
    Mallett,> open command is executed.

    Mallett,> Is there another way to handle this?  I found
    Mallett,> information about *raw* commands in the python
    Mallett,> documentation but couldn't figure out how to work it.

    Mallett,> Any ideas of how this type of situation should be
    Mallett,> handled?

    Mallett,> Thank you for your help,

    Mallett,> Roger Mallett






    Mallett,> _______________________________________________ Tutor
    Mallett,> maillist - Tutor@python.org
    Mallett,> http://www.python.org/mailman/listinfo/tutor



From rmallett@rational.com  Sat Nov 25 20:37:13 2000
From: rmallett@rational.com (Mallett, Roger)
Date: Sat, 25 Nov 2000 12:37:13 -0800
Subject: [Tutor] escape codes and filenames
Message-ID: <D1F8EEAA065FD411B7E200D0B73EB0EA01231F02@CUPEX2.rational.com>

Steve, Richard,

Steve asked: "How did you get filelist?"

My code is below.  The file being read by the code below is a text file
loaded with fully qualified filenames obtained from a DOS dir /s/b command.
I use readlines() to put each line in the text file into a list and then
return the list.


-----------
CODE HERE
-----------

def ReadLinesFromFileIntoList(filename):
    filez=open(filename,'r')
    lines=filez.readlines()
    
    return lines



SAMPLE ENTRIES from the text file are in the following format:
	C:\__test\dir1\xray.htm
	C:\__test\dir1\1234.htm
	C:\__test\dir2\fred.htm
	C:\__test\dir2\apex_declaration_class.htm
	...
	...


I don't understand how raw_input is applied in the situation I am trying
above.  I would like to know more about it.

Using Richard's suggestion of "/" rather than "\" sounds interesting.
However, I still have to process each element in the list before opening any
of the files to ensure that it is scrubbed of escape codes.

Roger Mallett


-----Original Message-----
From: Steve Spicklemire [mailto:steve@spvi.com]
Sent: Saturday, November 25, 2000 12:02 PM
To: rmallett@Rational.Com
Cc: tutor@python.org; steve@spvi.com
Subject: Re: [Tutor] escape codes and filenames



Hi Roger,

How did you get filelist? If you type a string into the
interpreter and you want an explicit '\' you need to escape it
thusly: 

filename = "c:\\trash.txt"

If you read a string from a file or keyboard, no escape is required

try the following code:

x = raw_input('enter a string with a "\\" in it... ')
print `x`

does that work for you?
-steve


>>>>> "Mallett," == Mallett, Roger <rmallett@rational.com> writes:

    Mallett,> I have a series of files that need to be opened.
    Mallett,> Several of the files start with characters normally
    Mallett,> reserved as Escape codes.

    Mallett,> Using for filename in filelist: x=open(filename,'r')

    Mallett,> fails anytime anypart of *filename* contains a
    Mallett,> "\<escape_code>" sequence.  For example: if filename is
    Mallett,> set to "c:\trash.txt", then the file will not open with
    Mallett,> the open command above because the "\t" is perceived as
    Mallett,> an escape code.

    Mallett,> I have therefore written code to scrub each instance of
    Mallett,> filename to ensure no escape sequences exist before the
    Mallett,> open command is executed.

    Mallett,> Is there another way to handle this?  I found
    Mallett,> information about *raw* commands in the python
    Mallett,> documentation but couldn't figure out how to work it.

    Mallett,> Any ideas of how this type of situation should be
    Mallett,> handled?

    Mallett,> Thank you for your help,

    Mallett,> Roger Mallett






    Mallett,> _______________________________________________ Tutor
    Mallett,> maillist - Tutor@python.org
    Mallett,> http://www.python.org/mailman/listinfo/tutor


From steve@spvi.com  Sat Nov 25 21:12:27 2000
From: steve@spvi.com (Steve Spicklemire)
Date: Sat, 25 Nov 2000 16:12:27 -0500 (EST)
Subject: [Tutor] escape codes and filenames
In-Reply-To: <D1F8EEAA065FD411B7E200D0B73EB0EA01231F02@CUPEX2.rational.com>
 (rmallett@rational.com)
References: <D1F8EEAA065FD411B7E200D0B73EB0EA01231F02@CUPEX2.rational.com>
Message-ID: <200011252112.QAA44858@mercury.spvi.com>

Hi Roger,

   Hmm... something is really wierd!

I cooked up the following code:

----------------------------------------------------------------------

f = open('foo.txt')

lines = f.readlines()

for line in lines:
    print `line`

----------------------------------------------------------------------

I saved the following in foo.txt

C:\__test\dir1\xray.htm
C:\__test\dir1\1234.htm
C:\__test\dir2\fred.htm
C:\__test\dir2\apex_declaration_class.htm

When I run my code I get:

'C:\\__test\\dir1\\xray.htm\012'
'C:\\__test\\dir1\\1234.htm\012'
'C:\\__test\\dir2\\fred.htm\012'
'C:\\__test\\dir2\\apex_declaration_class.htm\012'

Which is exactly what I expect....  what do you get?

-steve

>>>>> "RM" == Mallett, Roger <rmallett@rational.com> writes:

    RM> Steve, Richard,

    RM> Steve asked: "How did you get filelist?"



From rmallett@rational.com  Sat Nov 25 21:25:39 2000
From: rmallett@rational.com (Mallett, Roger)
Date: Sat, 25 Nov 2000 13:25:39 -0800
Subject: [Tutor] escape codes and filenames
Message-ID: <D1F8EEAA065FD411B7E200D0B73EB0EA01231F04@CUPEX2.rational.com>

Steve,

I get the same results you do.  I am obviously misinterpreting something.

The fragment below is exactly where things are breaking.  Since my last
response, I wrote code to replace backslashes with forward slashes so my
input is slightly different but it breaks in the same way at the same place.


I call the following function with a list of filenames:

def CheckFileForConditionalText(filename):
    print '\tCheckFileForConditionalText entered'   #for testing only
    print '\t\tfilename:  ',filename   #for testing only
    x=open('c:\\trash.txt','r')  #for testing only
    print '\ttrash opened'       #for testing only
    x=open(filename,'r')      #THINGS BREAK HERE, THE FILE DOESN'T OPEN




RESULTING PRINTOUTS FROM THE FUNCTION
-------------------------------------
CheckFileForConditionalText entered
filename:
C:/__HelpFiles/SoDA/teamtest/teamtest_verificationpoint_class.htm
trash opened



If I use similar commands at the interpreter, everything is fine
------------------
>>> a='c:/__helpfiles/soda/teamtest/teamtest_variant_class.htm'
>>> x=open(a,'r')
>>> z=x.readlines()
>>> z
['<HTML>\012', '<HEAD>\012', ' <TITLE>TeamTest Variant Class</TITLE>\012',
....... and so on



Why do things appear to work in the interpreter but don't work when executed
from the function?

Roger Mallett



-----Original Message-----
From: Steve Spicklemire [mailto:steve@spvi.com]
Sent: Saturday, November 25, 2000 1:12 PM
To: rmallett@Rational.Com
Cc: tutor@python.org; steve@spvi.com
Subject: Re: [Tutor] escape codes and filenames



Hi Roger,

   Hmm... something is really wierd!

I cooked up the following code:

----------------------------------------------------------------------

f = open('foo.txt')

lines = f.readlines()

for line in lines:
    print `line`

----------------------------------------------------------------------

I saved the following in foo.txt

C:\__test\dir1\xray.htm
C:\__test\dir1\1234.htm
C:\__test\dir2\fred.htm
C:\__test\dir2\apex_declaration_class.htm

When I run my code I get:

'C:\\__test\\dir1\\xray.htm\012'
'C:\\__test\\dir1\\1234.htm\012'
'C:\\__test\\dir2\\fred.htm\012'
'C:\\__test\\dir2\\apex_declaration_class.htm\012'

Which is exactly what I expect....  what do you get?

-steve

>>>>> "RM" == Mallett, Roger <rmallett@rational.com> writes:

    RM> Steve, Richard,

    RM> Steve asked: "How did you get filelist?"


From rmallett@rational.com  Sat Nov 25 21:35:31 2000
From: rmallett@rational.com (Mallett, Roger)
Date: Sat, 25 Nov 2000 13:35:31 -0800
Subject: [Tutor] escape codes and filenames  (FALSE ALARM
Message-ID: <D1F8EEAA065FD411B7E200D0B73EB0EA01231F05@CUPEX2.rational.com>

Steve, Richard,

Appears I have a false alarm.  I prostrate myself and receiving my flogging.

Switching the backslashes for forward slashes DID WORK for me.  What I
failed to notice in the python error message was that I didn't remove the
"\012" from the end of each file name before attempting to open the file.

My greatest apologies.

Thank you very much for the help you did provide, for it was applied to
solve my original problem.


Roger Mallett


-----Original Message-----
From: Mallett, Roger 
Sent: Saturday, November 25, 2000 1:30 PM
To: 'tutor@python.org'
Subject: RE: [Tutor] escape codes and filenames


Steve,

I get the same results you do.  I am obviously misinterpreting something.

The fragment below is exactly where things are breaking.  Since my last
response, I wrote code to replace backslashes with forward slashes so my
input is slightly different but it breaks in the same way at the same place.


I call the following function with a list of filenames:

def CheckFileForConditionalText(filename):
    print '\tCheckFileForConditionalText entered'   #for testing only
    print '\t\tfilename:  ',filename   #for testing only
    x=open('c:\\trash.txt','r')  #for testing only
    print '\ttrash opened'       #for testing only
    x=open(filename,'r')      #THINGS BREAK HERE, THE FILE DOESN'T OPEN




RESULTING PRINTOUTS FROM THE FUNCTION
-------------------------------------
CheckFileForConditionalText entered
filename:
C:/__HelpFiles/SoDA/teamtest/teamtest_verificationpoint_class.htm
trash opened



If I use similar commands at the interpreter, everything is fine
------------------
>>> a='c:/__helpfiles/soda/teamtest/teamtest_variant_class.htm'
>>> x=open(a,'r')
>>> z=x.readlines()
>>> z
['<HTML>\012', '<HEAD>\012', ' <TITLE>TeamTest Variant Class</TITLE>\012',
....... and so on



Why do things appear to work in the interpreter but don't work when executed
from the function?

Roger Mallett



-----Original Message-----
From: Steve Spicklemire [mailto:steve@spvi.com]
Sent: Saturday, November 25, 2000 1:12 PM
To: rmallett@Rational.Com
Cc: tutor@python.org; steve@spvi.com
Subject: Re: [Tutor] escape codes and filenames



Hi Roger,

   Hmm... something is really wierd!

I cooked up the following code:

----------------------------------------------------------------------

f = open('foo.txt')

lines = f.readlines()

for line in lines:
    print `line`

----------------------------------------------------------------------

I saved the following in foo.txt

C:\__test\dir1\xray.htm
C:\__test\dir1\1234.htm
C:\__test\dir2\fred.htm
C:\__test\dir2\apex_declaration_class.htm

When I run my code I get:

'C:\\__test\\dir1\\xray.htm\012'
'C:\\__test\\dir1\\1234.htm\012'
'C:\\__test\\dir2\\fred.htm\012'
'C:\\__test\\dir2\\apex_declaration_class.htm\012'

Which is exactly what I expect....  what do you get?

-steve

>>>>> "RM" == Mallett, Roger <rmallett@rational.com> writes:

    RM> Steve, Richard,

    RM> Steve asked: "How did you get filelist?"


From dyoo@hkn.eecs.berkeley.edu  Sun Nov 26 01:03:56 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 25 Nov 2000 17:03:56 -0800 (PST)
Subject: [Tutor] escape codes and filenames  (FALSE ALARM
In-Reply-To: <D1F8EEAA065FD411B7E200D0B73EB0EA01231F05@CUPEX2.rational.com>
Message-ID: <Pine.LNX.4.21.0011251648530.25748-100000@hkn.eecs.berkeley.edu>

On Sat, 25 Nov 2000, Mallett, Roger wrote:

> Thank you very much for the help you did provide, for it was applied to
> solve my original problem.

If you have time, try to switch the slashes in your filelist back to
backslashes and see if your program still works --- I think it was just
those terminating newlines that were causing problems.


Also, the way that Python prints out strings depends if you ask it for a
its string or representation conversion.  For example:

###
>>> name = "Roger\\Mallet"

>>> print name
Roger\Mallet
>>> print str(name)
Roger\Mallet

>>> name
'Roger\\Mallet'
>>> print repr(name)
'Roger\\Mallet'
###

Here's something strange --- one way prints with '\\', while the other way
with '\'.  The reason for this is because repr() (ideally) returns the
representation of the string: it's what you'd literally type into the
interpreter to get that same value.

repr() doesn't always give different results.  For example:

###
>>> f = open('foobar.txt')
>>> print f
<open file 'foobar.txt', mode 'r' at 0x81c76e8>
>>> print repr(f)
<open file 'foobar.txt', mode 'r' at 0x81c76e8>
##


What's important to see is that repr() does give different results for
strings, which can be confusing at first, but useful:

###
>>> print repr("\ttest\tagain")
'\011test\011again'
>>> print str("\ttest\tagain")
	test	again
###

The reason you were getting different results when you were printing out
those strings is because when you ask Python for a variable, it'll return
its representation: escaped backslashes, quotes and all.  So getting a
variable's value is not the same thing as getting its string form.  In
most cases, it looks very similar, so be careful.

I hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Sun Nov 26 01:06:42 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 25 Nov 2000 17:06:42 -0800 (PST)
Subject: [Tutor] Freezing a GUI program in Windows?
In-Reply-To: <200011251511.AAA23345@osa.att.ne.jp>
Message-ID: <Pine.LNX.4.21.0011251704310.25748-100000@hkn.eecs.berkeley.edu>

On Sun, 26 Nov 2000, Craig Hagerman wrote:

> More importantly, can someone tell me how to make an executable program? I
> hope this isn't a too-trivial question. I usually use Python on Mac
> computers (which includes a mac utility "BuildApplication") or Linux, but I
> have never had cause to want to make an executable within Linux and I have
> never used Python in Windows --- until now. I want to send an executable
> program to my brother (who uses Windows). My understanding is that I should
> use a "freeze.py" module to create an executable. However, I can not find a
> "freeze.py" module anywhere within the standard Windows distribution, nor
> can I find any documents to tell me where to go from here.

You may want to look here:

    http://www.mcmillan-inc.com/install1.html

It has some information on distributing your Python programs as
binaries.  Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Sun Nov 26 05:44:35 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 25 Nov 2000 21:44:35 -0800 (PST)
Subject: [Tutor] time.sleep problems (fwd)
In-Reply-To: <000b01c052a0$4eb36ac0$a410fea9@glen>
Message-ID: <Pine.LNX.4.21.0011252140550.29083-100000@hkn.eecs.berkeley.edu>

On Mon, 20 Nov 2000, Glen Wheeler wrote:

> Damn that's exactly what I wanted it to do grrrrrr...
> 
> By locking up I mean only the program, I have to ctrl+alt+del and then close
> it to regain control of my system.
> 
> Awww this doens't mean I have to install Linux does it?  (again :)
> 
> I was designing for windows not Linux...there has to be a solution to this
> problem :)


Dear Glen,

I want to apologize for not emailing in a while --- unfortunately, my
cdrom drive died while I was trying to install Win2k, so I won't be able
to test your thread problem until my new drive comes in.  I just bought
one from buy.com, so I should be able to try installing Win2k again by
Tuesday.

Again, I'm sorry about not emailing you about this before; I just felt
embarrased about not being able to install an operating system... *sigh*



From wheelege@tsn.cc  Sun Nov 26 08:43:47 2000
From: wheelege@tsn.cc (Glen Wheeler)
Date: Sun, 26 Nov 2000 19:43:47 +1100
Subject: [Tutor] time.sleep problems (fwd)
References: <Pine.LNX.4.21.0011252140550.29083-100000@hkn.eecs.berkeley.edu>
Message-ID: <001a01c05785$056d7420$a410fea9@glen>

  No prob, please tell me the results when you try it.

  Thanks for going to all the trouble,
  Glen.


----- Original Message -----
From: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>
To: Glen Wheeler <wheelege@tsn.cc>
Cc: <tutor@python.org>
Sent: Sunday, November 26, 2000 4:44 PM
Subject: Re: [Tutor] time.sleep problems (fwd)


> On Mon, 20 Nov 2000, Glen Wheeler wrote:
>
> > Damn that's exactly what I wanted it to do grrrrrr...
> >
> > By locking up I mean only the program, I have to ctrl+alt+del and then
close
> > it to regain control of my system.
> >
> > Awww this doens't mean I have to install Linux does it?  (again :)
> >
> > I was designing for windows not Linux...there has to be a solution to
this
> > problem :)
>
>
> Dear Glen,
>
> I want to apologize for not emailing in a while --- unfortunately, my
> cdrom drive died while I was trying to install Win2k, so I won't be able
> to test your thread problem until my new drive comes in.  I just bought
> one from buy.com, so I should be able to try installing Win2k again by
> Tuesday.
>
> Again, I'm sorry about not emailing you about this before; I just felt
> embarrased about not being able to install an operating system... *sigh*
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor



From georg.simon@bnmsp.de  Sun Nov 26 12:57:10 2000
From: georg.simon@bnmsp.de (Georg Simon)
Date: Sun, 26 Nov 2000 13:57:10 +0100
Subject: [Tutor] Windows 98 Tkinter binding event <Return> fails
Message-ID: <3A210870.7035C0F5@bnmsp.de>

I took bind1.py from Fredrik Lundhs Introduction to Tkinter and
altered it slightly to wait for the Enter key instead of a mouse button
:
---------------------------------------------
from Tkinter import *

root = Tk ()

def callback ( event ) :
    print 'called the callback!'

frame = Frame ( root, width=100, height=100 )
frame.bind ( '<Return>', callback )
frame.pack ()

root.mainloop ()
---------------------------------------------
It does not work. Does that mean that it is impossible to use unbuffered
keyboard input with Tkinter under Windows ?

Georg Simon


From arcege@shore.net  Sun Nov 26 14:19:06 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Sun, 26 Nov 2000 09:19:06 -0500 (EST)
Subject: [Tutor] Windows 98 Tkinter binding event <Return> fails
In-Reply-To: <3A210870.7035C0F5@bnmsp.de> from "Georg Simon" at Nov 26, 2000 01:57:10 PM
Message-ID: <200011261419.JAA29078@northshore.shore.net>

> 
> I took bind1.py from Fredrik Lundhs Introduction to Tkinter and
> altered it slightly to wait for the Enter key instead of a mouse button
> :
> ---------------------------------------------
> from Tkinter import *
> 
> root = Tk ()
> 
> def callback ( event ) :
>     print 'called the callback!'
> 
> frame = Frame ( root, width=100, height=100 )
> frame.bind ( '<Return>', callback )
> frame.pack ()
> 
> root.mainloop ()
> ---------------------------------------------
> It does not work. Does that mean that it is impossible to use unbuffered
> keyboard input with Tkinter under Windows ?

Try putting the focus into the frame:
  frame.bind ( '<Return>', callback )
  frame.pack ()
  frame.focus ()

The system needs to know which window (or in this case, which sub-window)
to direct the keystrokes to.

  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------


From devanshd@yahoo.com  Mon Nov 27 15:37:36 2000
From: devanshd@yahoo.com (Devansh Dhutia)
Date: Mon, 27 Nov 2000 09:37:36 -0600
Subject: [Tutor] (no subject)
Message-ID: <002301c05887$f843dc40$5f1511ac@wartburg.edu>

This is a multi-part message in MIME format.

------=_NextPart_000_0020_01C05855.AD1B8420
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hi everyone,
i was wondering if its possible in python to be able to read the =
keystrokes
from a keyboard??
for example, if a user was to input a sequence of numbers or letters, i =
want
to be able to display them elsewhere on the screen immediately after the
user presses a key.

Devansh Dhutia



------=_NextPart_000_0020_01C05855.AD1B8420
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff><FONT face=3DArial size=3D2>hi everyone,<BR>i =
was wondering if=20
its possible in python to be able to read the keystrokes<BR>from a=20
keyboard??<BR>for example, if a user was to input a sequence of numbers =
or=20
letters, i want<BR>to be able to display them elsewhere on the screen=20
immediately after the<BR>user presses a key.<BR><BR>Devansh=20
Dhutia<BR><BR></FONT></BODY></HTML>

------=_NextPart_000_0020_01C05855.AD1B8420--


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



From scott@zenplex.com  Mon Nov 27 15:57:48 2000
From: scott@zenplex.com (Scott Ralph Comboni)
Date: Mon, 27 Nov 2000 10:57:48 -0500
Subject: [Tutor] sys.argv?
Message-ID: <00112710574802.02424@scoot.zenplex.com>

Question about using sys.argv

Example of problem:

#!/usr/bin/env python
import sys

def test(name, n):
       print name, n + 1

test(sys.argv[1], sys.argv[2])

./test.py Foo 3

my problem is when I'm using sys.argv to pass in a number it converts to a 
string..  Is there a way around this using sys.argv or do I have to use 
string.atoi(n) to convert it back to int?
Most likely something stupid on my part.
Thanks Scott



From SBrunning@trisystems.co.uk  Mon Nov 27 16:00:29 2000
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Mon, 27 Nov 2000 16:00:29 -0000
Subject: [Tutor] sys.argv?
Message-ID: <31575A892FF6D1118F5800600846864D5B14F8@intrepid>

> From:	Scott Ralph Comboni [SMTP:scott@zenplex.com]
> my problem is when I'm using sys.argv to pass in a number it converts to a
> 
> string..  Is there a way around this using sys.argv or do I have to use 
> string.atoi(n) to convert it back to int?
 
You aren't really passing it a number - you are passing it a string which
happens to contain a number. So yes, basically, you are going to have to
convert  to a number using atio or some such.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk





-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.


From FxItAL@aol.com  Mon Nov 27 16:14:38 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Mon, 27 Nov 2000 11:14:38 EST
Subject: [Tutor] Displaying MsgBox
Message-ID: <c0.c373bdb.2753e26e@aol.com>

--part1_c0.c373bdb.2753e26e_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Hi All,

       When a selection is made from a menu drop down list, a list box is 
displayed with a list of sound files to be used.  If there are no files , I 
have an error message that displays.  My problem is that the error message 
displays behind the file box instead of ontop of it.

Any help will be greatly appreciated,
Thanks, Al

--part1_c0.c373bdb.2753e26e_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

<HTML><FONT  SIZE=2>Hi All,
<BR>
<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;When a selection is made from a menu drop down list, a list box is <BR>displayed with a list of sound files to be used. &nbsp;If there are no files , I <BR>have an error message that displays. &nbsp;My problem is that the error message <BR>displays behind the file box instead of ontop of it.
<BR>
<BR>Any help will be greatly appreciated,
<BR>Thanks, Al</FONT></HTML>

--part1_c0.c373bdb.2753e26e_boundary--


From scarblac@pino.selwerd.nl  Mon Nov 27 16:14:00 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Mon, 27 Nov 2000 17:14:00 +0100
Subject: [Tutor] sys.argv?
In-Reply-To: <00112710574802.02424@scoot.zenplex.com>; from scott@zenplex.com on Mon, Nov 27, 2000 at 10:57:48AM -0500
References: <00112710574802.02424@scoot.zenplex.com>
Message-ID: <20001127171400.A10594@pino.selwerd.nl>

On Mon, Nov 27, 2000 at 10:57:48AM -0500, Scott Ralph Comboni wrote:
> Question about using sys.argv
> 
> Example of problem:
> 
> #!/usr/bin/env python
> import sys
> 
> def test(name, n):
>        print name, n + 1
> 
> test(sys.argv[1], sys.argv[2])
> 
> ./test.py Foo 3
> 
> my problem is when I'm using sys.argv to pass in a number it converts to a 
> string..  Is there a way around this using sys.argv or do I have to use 
> string.atoi(n) to convert it back to int?
> Most likely something stupid on my part.

It never was an int, command line arguments are strings. So yes, use
int() or another function like that.

Remco Gerlich


From alan.gauld@bt.com  Mon Nov 27 17:20:04 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 27 Nov 2000 17:20:04 -0000
Subject: [Tutor] (no subject)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D43D@mbtlipnt02.btlabs.bt.co.uk>

> i was wondering if its possible in python to be able to read 
> the keystrokes from a keyboard??

Yes but it's platform dependent at present.

A Tkinter solution is presented in my tutor:

http://www.crosswinds.net/~agauld/

Look under Advanced Topics at "Event Driven Systems"
the second example.

The msvcrt(sp?) module does it for Windoze, curses does 
it on *nix

HTH,

Alan g.


From alan.gauld@bt.com  Mon Nov 27 17:22:41 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 27 Nov 2000 17:22:41 -0000
Subject: [Tutor] sys.argv?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D43E@mbtlipnt02.btlabs.bt.co.uk>

> test(sys.argv[1], sys.argv[2])
> 
> ./test.py Foo 3
> 
> my problem is when I'm using sys.argv to pass in a number it 
> converts to a string.

No it doesn't, argv is a list of strings...

> Is there a way around this using sys.argv or do I 
> have to use string.atoi(n) to convert it back to int?

test(sys.argv[1],int(sys.argv[2]))

could be used, but you should wrap in try/except in 
case its not compatible and of course check that there 
are at least 2 arguments present!

Alan G.


From scott@zenplex.com  Mon Nov 27 18:01:25 2000
From: scott@zenplex.com (Scott Comboni)
Date: Mon, 27 Nov 2000 13:01:25 -0500
Subject: [Tutor] sys.argv?
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D43E@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D43E@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <00112713012503.02424@scoot.zenplex.com>

On Monday 27 November 2000 12:22, you wrote:
> > test(sys.argv[1], sys.argv[2])
> >
> > ./test.py Foo 3
> >
> > my problem is when I'm using sys.argv to pass in a number it
> > converts to a string.
>
> No it doesn't, argv is a list of strings...
>
> > Is there a way around this using sys.argv or do I
> > have to use string.atoi(n) to convert it back to int?
>
> test(sys.argv[1],int(sys.argv[2]))
>
> could be used, but you should wrap in try/except in
> case its not compatible and of course check that there
> are at least 2 arguments present!
>
> Alan G.
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

Thanks everyone.... Using the method Alan suggested saves me a step. 
Should have tried that before submitting to the group...
Scott



From rmallett@rational.com  Mon Nov 27 19:38:43 2000
From: rmallett@rational.com (Mallett, Roger)
Date: Mon, 27 Nov 2000 11:38:43 -0800
Subject: [Tutor] passing a function's name to another function
Message-ID: <D1F8EEAA065FD411B7E200D0B73EB0EA01232116@CUPEX2.rational.com>

> I would like to pass the name of a function to another function.  However,
> since the function's name may change I would like to pass a variable
> rather than a hardcoded name.
> 
> I look in the help file and discovered a reference to an obsolete function
> named codehack.  It apparently has been replaced by "func.func_name".  The
> problem is I want the liberty to change the function's name without having
> to change "func.func_name" as well.
> 
> 
> For example, I have two functions, one named "Test" and one named
> "NotImplementedYet".  I would like to have the freedom to change the name
> of "Test" without having to change the argument it passes to
> NotImplementedYet.  So, if I change the name of "Test" to "Apple" I don't
> want to have to change "Test.func_name" to "Apple.func_name".
> 
> 
> def NotImplementedYet(funcname):
> 	print funcname, 'is Not Implemented Yet'
> 
> 
> 
> def Test():
> 	NotImplementedYet(Test.func_name)  <<--it is the "Test" which
> produces the maintenance issue
> 
> 
> 
> What might I use?
> 
> Roger Mallett
> 
> 
> 
> 


From scarblac@pino.selwerd.nl  Mon Nov 27 23:05:37 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 28 Nov 2000 00:05:37 +0100
Subject: [Tutor] passing a function's name to another function
In-Reply-To: <D1F8EEAA065FD411B7E200D0B73EB0EA01232116@CUPEX2.rational.com>; from rmallett@rational.com on Mon, Nov 27, 2000 at 11:38:43AM -0800
References: <D1F8EEAA065FD411B7E200D0B73EB0EA01232116@CUPEX2.rational.com>
Message-ID: <20001128000537.A10945@pino.selwerd.nl>

On Mon, Nov 27, 2000 at 11:38:43AM -0800, Mallett, Roger wrote:
> > I would like to pass the name of a function to another function.  However,
> > since the function's name may change I would like to pass a variable
> > rather than a hardcoded name.
> > 
> > I look in the help file and discovered a reference to an obsolete function
> > named codehack.  It apparently has been replaced by "func.func_name".  The
> > problem is I want the liberty to change the function's name without having
> > to change "func.func_name" as well.

Huh?

> > For example, I have two functions, one named "Test" and one named
> > "NotImplementedYet".  I would like to have the freedom to change the name
> > of "Test" without having to change the argument it passes to
> > NotImplementedYet.  So, if I change the name of "Test" to "Apple" I don't
> > want to have to change "Test.func_name" to "Apple.func_name".
> > 
> > 
> > def NotImplementedYet(funcname):
> > 	print funcname, 'is Not Implemented Yet'
> > 
> > 
> > 
> > def Test():
> > 	NotImplementedYet(Test.func_name)  <<--it is the "Test" which
> > produces the maintenance issue

Ah right, I get you.

I think you need to raise some exception, catch it, and look at the current
stack frame (the information that is usually printed when an error occurs).
This leads to the following black magic:

import sys

def NotImplementedYet():
  try:
    raise "Dummy Error"
  except "Dummy Error":
    traceback = sys.exc_info()[2]
    lastframe = traceback.tb_frame.f_back
    name = lastframe.f_code.co_name
    print name, "is not implemented yet."
  

def SomeFunction():
   NotImplementedYet()
   

I hope this works. You can get some more info like the line number too. It's
pretty ugly, but does what you want. Use at your own risk.

The other, much simpler solution is to just not implement the function
at all. Python will give an error when you try to call it ;-).


-- 
Remco Gerlich


From rmallett@rational.com  Tue Nov 28 00:01:01 2000
From: rmallett@rational.com (Mallett, Roger)
Date: Mon, 27 Nov 2000 16:01:01 -0800
Subject: [Tutor] passing a function's name to another function
Message-ID: <D1F8EEAA065FD411B7E200D0B73EB0EA0123221E@CUPEX2.rational.com>

Thank You Very Much Remco!!

Your help opens up a whole new area for me to explore!

Roger Mallett

-----Original Message-----
From: Remco Gerlich [mailto:scarblac@pino.selwerd.nl]
Sent: Monday, November 27, 2000 3:06 PM
To: tutor@python.org
Subject: Re: [Tutor] passing a function's name to another function


On Mon, Nov 27, 2000 at 11:38:43AM -0800, Mallett, Roger wrote:
> I would like to pass the name of a function to another function.  However,
> since the function's name may change I would like to pass a variable
> rather than a hardcoded name.
> 
> I look in the help file and discovered a reference to an obsolete function
> named codehack.  It apparently has been replaced by "func.func_name".  The
> problem is I want the liberty to change the function's name without having
> to change "func.func_name" as well.

Huh?

> For example, I have two functions, one named "Test" and one named
> "NotImplementedYet".  I would like to have the freedom to change the name
> of "Test" without having to change the argument it passes to
> NotImplementedYet.  So, if I change the name of "Test" to "Apple" I don't
> want to have to change "Test.func_name" to "Apple.func_name".
> 
> 
> def NotImplementedYet(funcname):
> 	print funcname, 'is Not Implemented Yet'
> 
> 
> 
> def Test():
> 	NotImplementedYet(Test.func_name)  <<--it is the "Test" which
> produces the maintenance issue

Ah right, I get you.

I think you need to raise some exception, catch it, and look at the current
stack frame (the information that is usually printed when an error occurs).
This leads to the following black magic:

import sys

def NotImplementedYet():
  try:
    raise "Dummy Error"
  except "Dummy Error":
    traceback = sys.exc_info()[2]
    lastframe = traceback.tb_frame.f_back
    name = lastframe.f_code.co_name
    print name, "is not implemented yet."
  

def SomeFunction():
   NotImplementedYet()
   

I hope this works. You can get some more info like the line number too. It's
pretty ugly, but does what you want. Use at your own risk.

The other, much simpler solution is to just not implement the function
at all. Python will give an error when you try to call it ;-).


-- 
Remco Gerlich

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://www.python.org/mailman/listinfo/tutor


From accounts@internews.org  Tue Nov 28 01:26:49 2000
From: accounts@internews.org (temp)
Date: Mon, 27 Nov 2000 17:26:49 -0800
Subject: [Tutor] directory listing and file mod times
Message-ID: <000801c058da$4792ed20$17c9cb3f@pacbell.net>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C05897.394E1B60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm making some progress with Mark Hammonds Win32 book, but on pp =
311-312 there are listings that look like they would help in doing basic =
file/directory file mod time feedback, but I get this error.=20

I actually understand the code up to the point of the 'decode_stat' part =
which Python gripes about anyway. I assume that there's a function or =
module that it refers to that I don't have?


>>> os.stat('C:\Updates')
(16895, 0, 2, 1, 0, 0, 0, 973065600, 973117026, 973117024)

I get this far just fine...roll your own path, use os.stat on it and get =
the items back calculated since epoch.

Now I write the function listed in the book, I just call my function =
'fileinfo' instead of 'getfileinfo', which I hope is no grevous crime. I =
also didn't put in the code pertaining to file size or access, since my =
mission is geared to when last changes were made. (it should be simpler, =
right?)

>>> import os, time, stat
>>> def fileinfo(filename):
...  modified =3D stats[stat.ST_MTIME]
...  print 'last modified :' + time.ctime(modified)
... =20
>>> decode_stat.fileinfo('C:\Updates')
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
NameError: There is no variable named 'decode_stat'

It blows up here. I don't understand where 'decode_stat' came from and =
apparantly neither does Python.=20

Any ideas? (this could be 'operator error' related)

Once I get this figured out, I can go on to working with 'walk'..which =
may generate as many questions..;)

Thanks in advance,

Larry Kuhn
lkuhn@internews.org or=20
codepuppy@internews.org


------=_NextPart_000_0005_01C05897.394E1B60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3019.2500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I'm making some progress with Mark =
Hammonds Win32=20
book, but on pp 311-312 there are listings that look like they would =
help in=20
doing basic file/directory file mod time feedback, but I get this error. =

</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I actually understand the code up to =
the point of=20
the 'decode_stat' part which Python gripes about anyway. I assume that =
there's a=20
function or module that it refers to that I don't have?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>&gt;&gt;&gt; =
os.stat('C:\Updates')<BR>(16895,=20
0, 2, 1, 0, 0, 0, 973065600, 973117026, 973117024)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I get this far just fine...roll your =
own path, use=20
os.stat on it and get the items back calculated since =
epoch.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I write the function listed in the =
book, I just=20
call my function 'fileinfo' instead of 'getfileinfo', which I hope is no =
grevous=20
crime. I also didn't put in the code pertaining to file size or access, =
since my=20
mission is geared to when last changes were made. (it should be simpler, =

right?)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&gt;&gt;&gt; import os, time,=20
stat<BR>&gt;&gt;&gt; def fileinfo(filename):<BR>... &nbsp;modified =3D=20
stats[stat.ST_MTIME]<BR>... &nbsp;print 'last modified :' +=20
time.ctime(modified)<BR>... &nbsp;<BR>&gt;&gt;&gt;=20
decode_stat.fileinfo('C:\Updates')<BR>Traceback (innermost =
last):<BR>&nbsp; File=20
"&lt;interactive input&gt;", line 1, in ?<BR>NameError: There is no =
variable=20
named 'decode_stat'</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>It blows up here. I don't understand =
where=20
'decode_stat' came from and apparantly neither does Python. =
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any ideas? (this could be 'operator =
error'=20
related)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Once I get this figured out, I can go =
on to working=20
with 'walk'..which may generate as many questions..;)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Larry Kuhn</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"mailto:lkuhn@internews.org">lkuhn@internews.org</A> or =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"mailto:codepuppy@internews.org">codepuppy@internews.org</A><BR></=
DIV></FONT></BODY></HTML>

------=_NextPart_000_0005_01C05897.394E1B60--



From jcm@bigskytel.com  Tue Nov 28 01:47:56 2000
From: jcm@bigskytel.com (David Porter)
Date: Mon, 27 Nov 2000 18:47:56 -0700
Subject: [Tutor] directory listing and file mod times
In-Reply-To: <000801c058da$4792ed20$17c9cb3f@pacbell.net>; from accounts@internews.org on Mon, Nov 27, 2000 at 05:26:49PM -0800
References: <000801c058da$4792ed20$17c9cb3f@pacbell.net>
Message-ID: <20001127184756.A12525@bigskytel.com>

* temp <accounts@internews.org>:
> 
> >>> import os, time, stat
> >>> def fileinfo(filename):
> ...  modified = stats[stat.ST_MTIME]
> ...  print 'last modified :' + time.ctime(modified)
> ...  
> >>> decode_stat.fileinfo('C:\Updates')
> Traceback (innermost last):
>   File "<interactive input>", line 1, in ?
> NameError: There is no variable named 'decode_stat'
> 
> It blows up here. I don't understand where 'decode_stat' came from and
> apparantly neither does Python. 

And neither do I! It is useless in the context of your code, and is probably 
just leftovers from the book. 

Another thing that wont work is this:

modified = stats[stat.ST_MTIME]

This calls a dictionary that doesn't exist. 

> Any ideas? (this could be 'operator error' related)

Changing the two problems above and making two cosmetic changes (fixing the
indention level and altering the print line) Yields:

import os, time, stat
def fileinfo(filename):
    modified = os.stat(filename)[stat.ST_MTIME]
    print 'last modified:', time.ctime(modified)

fileinfo('C:\Updates')    


David


From kbb140679@icqmail.com  Tue Nov 28 04:25:45 2000
From: kbb140679@icqmail.com (K)
Date: 27 Nov 2000 20:25:45 -0800
Subject: [Tutor] (no subject)
Message-ID: <20001128042545.28296.cpmta@c005.sfo.cp.net>

necesito saber como debe ser el cuerpo de un programa  en python urgentemente...........

i need to know  hot must be the  body  python program quickly........
   




-------------------------------------------------------------
Sign up for ICQmail at http://www.icq.com/icqmail/signup.html


From Claudiu Chiculita" <cchiculita@psgl.ro  Tue Nov 28 08:31:57 2000
From: Claudiu Chiculita" <cchiculita@psgl.ro (Chiculita Claudiu)
Date: Tue, 28 Nov 2000 10:31:57 +0200
Subject: [Tutor] Why so many pythons?
Message-ID: <000901c05915$aba7f3b0$100aa8c0@claudiu>

Why are so many versions of Python?
1. py152.exe
1'. BeOpen-Python-2.0.exe
2. ActivePython-2.0.0.202.msi
3. vpython-1.0
Am am intrested what are the differences.




From Moshe Zadka <moshez@math.huji.ac.il>  Tue Nov 28 08:52:33 2000
From: Moshe Zadka <moshez@math.huji.ac.il> (Moshe Zadka)
Date: Tue, 28 Nov 2000 10:52:33 +0200 (IST)
Subject: [Tutor] Why so many pythons?
In-Reply-To: <000901c05915$aba7f3b0$100aa8c0@claudiu>
Message-ID: <Pine.GSO.4.10.10011281050580.18132-100000@sundial>

On Tue, 28 Nov 2000, Chiculita Claudiu wrote:

> Why are so many versions of Python?
> 1. py152.exe

This is an old version of PYthon (18 months). It's working great thouhg,
and is probably the version of Python with the largest installed base.

> 1'. BeOpen-Python-2.0.exe
> 2. ActivePython-2.0.0.202.msi

Those two are different versions of Python 2.0. They should function the
same to all intents and purposes.

> 3. vpython-1.0

I haven't heard about this one.
--
Moshe Zadka <moshez@math.huji.ac.il> -- 95855124
http://advogato.org/person/moshez



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 28 10:41:50 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 28 Nov 2000 02:41:50 -0800 (PST)
Subject: [Tutor] (no subject)
In-Reply-To: <20001128042545.28296.cpmta@c005.sfo.cp.net>
Message-ID: <Pine.LNX.4.21.0011280240040.16624-100000@hkn.eecs.berkeley.edu>

On 27 Nov 2000, K wrote:

> necesito saber como debe ser el cuerpo de un programa en python
> urgentemente...........
> 
> i need to know  hot must be the  body  python program quickly........

You might want to read the Python tutorial here:

    http://www.crosswinds.net/~agauld/spanish/index.htm

I'm guessing that you speak and read Spanish more easily than English, so 
the link points to a Spanish translation of Alan Gauld's Python tutorial.

Good luck!



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 28 12:17:56 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 28 Nov 2000 04:17:56 -0800 (PST)
Subject: [Tutor] (no subject)
In-Reply-To: <002301c05887$f843dc40$5f1511ac@wartburg.edu>
Message-ID: <Pine.LNX.4.21.0011280410230.16701-100000@hkn.eecs.berkeley.edu>

On Mon, 27 Nov 2000, Devansh Dhutia wrote:

> i was wondering if its possible in python to be able to read the keystrokes
> from a keyboard??
> for example, if a user was to input a sequence of numbers or letters, i want
> to be able to display them elsewhere on the screen immediately after the
> user presses a key.

Hello!  You can do rudimentary input with the functions:

    raw_input()
    input()

Here's a sample interpreter session that shows how to use raw_input():

###
>>> def queryAndGreet():
...     name = raw_input("Please enter your name here: ")
...     print "Hello", name, "nice to meet you."
... 
>>> queryAndGreet()
Please enter your name here: Devansh
Hello Devansh nice to meet you.
###

You'll probably want to use raw_input() to read in your strings; input()
has a more specialized purpose.

However, I get the feeling that your question asked for more control over
screen input and output.  If you want fine-tuned control over what happens
on the screen, you might want to look at the curses library:

    http://python.org/doc/current/lib/module-curses.html

The curses library will let you position characters at any coordinate of
your text screen.  You might need to learn a little more Python before
using it, but you'll definitely have some fun with it.

    http://www.python.org/doc/howto/curses/curses.html

Finally, I wrote some hideously ugly code that works with the curses
library, if you want an example.  Take a look here:

    http://hkn.eecs.berkeley.edu/~dyoo/python/circularwriting.py




From dyoo@hkn.eecs.berkeley.edu  Tue Nov 28 12:19:53 2000
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 28 Nov 2000 04:19:53 -0800 (PST)
Subject: [Tutor] sys.argv?
In-Reply-To: <31575A892FF6D1118F5800600846864D5B14F8@intrepid>
Message-ID: <Pine.LNX.4.21.0011280418110.16701-100000@hkn.eecs.berkeley.edu>

On Mon, 27 Nov 2000, Simon Brunning wrote:

> > From:	Scott Ralph Comboni [SMTP:scott@zenplex.com]
> > my problem is when I'm using sys.argv to pass in a number it converts to a
> > 
> > string..  Is there a way around this using sys.argv or do I have to use 
> > string.atoi(n) to convert it back to int?
>  
> You aren't really passing it a number - you are passing it a string which
> happens to contain a number. So yes, basically, you are going to have to
> convert  to a number using atio or some such.


Also, you don't have to use the string module; one of the easier ways to
convert types is to use the builtin functions "int()", "float()", and
"str()":

    x = int(sys.argv[1])
    print "%d squared is %d" % (x, x**2)



From FxItAL@aol.com  Thu Nov 30 14:54:12 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Thu, 30 Nov 2000 09:54:12 EST
Subject: [Tutor] Installer SetupTK.py
Message-ID: <99.d43b303.2757c414@aol.com>

--part1_99.d43b303.2757c414_boundary
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,

I was able to use simple.py previously, but now it won't work. The only thin=
g=20
I've changed is that i've upgraded to Python Be Open 2.0. =A0I've downloaded=
=20
the most recent version of the installer (installer_b_03f.exe) and tried=20
running SetupTK.py again.  I receive an AssertionError while running=20
SetupTK.py. =A0

Please help.

Thanks Al

--part1_99.d43b303.2757c414_boundary
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><FONT  SIZE=3D2>Hello,
<BR>
<BR>I was able to use simple.py previously, but now it won't work. The only=20=
thing <BR>I've changed is that i've upgraded to Python Be Open 2.0. =A0I've=20=
downloaded <BR>the most recent version of the installer (installer_b_03f.exe=
) and tried <BR>running SetupTK.py again. &nbsp;I receive an AssertionError=20=
while running <BR>SetupTK.py. =A0
<BR>
<BR>Please help.
<BR>
<BR>Thanks Al</FONT></HTML>

--part1_99.d43b303.2757c414_boundary--


From dbrogdon@valinux.com  Thu Nov 30 16:37:07 2000
From: dbrogdon@valinux.com (Darrell Brogdon)
Date: Thu, 30 Nov 2000 11:37:07 -0500
Subject: [Tutor] Strange class behavior
Message-ID: <3A268233.350F79BD@valinux.com>

Why is it that when I run the following script:

class myTestClass:
    def myTestMethod(self):
        print "Test, Test, 1-2-3"


b = myTestClass
b.myTestMethod()


I get the following error:

Traceback (most recent call last):
  File "./test2.py", line 9, in ?
    b.myTestMethod()
TypeError: unbound method must be called with class instance 1st
argument


Clearly I'm doing something wrong with the method definition but I've
not been able to determine what?



From SBrunning@trisystems.co.uk  Thu Nov 30 16:38:47 2000
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Thu, 30 Nov 2000 16:38:47 -0000
Subject: [Tutor] Strange class behavior
Message-ID: <31575A892FF6D1118F5800600846864D5B151E@intrepid>

> From:	Darrell Brogdon [SMTP:dbrogdon@valinux.com]
> Why is it that when I run the following script:
> 
> class myTestClass:
>     def myTestMethod(self):
>         print "Test, Test, 1-2-3"
> 
> 
> b = myTestClass
> b.myTestMethod()
> 
> 
> I get the following error:
> 
> Traceback (most recent call last):
>   File "./test2.py", line 9, in ?
>     b.myTestMethod()
> TypeError: unbound method must be called with class instance 1st
> argument
> 
> 
> Clearly I'm doing something wrong with the method definition but I've
> not been able to determine what?
 
Your method definition is fine. The problem is with the line where you
instantiate your object, or rather, don't. You need this:

b= myTestClass()

rather than:

b= myTestClass

The latter creates new reference to the myTestClass class, rather than
creating on object belonging to that class.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk





-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.