From pdeluca@sia.net.au  Fri Jun  1 09:28:09 2001
From: pdeluca@sia.net.au (Paul De Luca)
Date: Fri, 01 Jun 2001 18:28:09 +1000
Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ?
Message-ID: <4.3.2.7.2.20010601175652.00adabe0@mail.sia.net.au>

Hi,
     I was wondering if there was a FAQ for this mailing list? I have been 
a subscriber to this list for a few months now, and regularly see the same 
questions come up on the list and get answered with the same answers. Since 
it seems like there are a lot of newbie programmers subscribing to this 
list (including myself ;) it would seem like a good idea to create a FAQ or 
some sought of Python Resource Index with answers to questions that 
frequent this list, information on books available (with readers opinions) 
as well as links to sites that are useful and get frequently mentioned. 
Since this list often gets questions which are not purely about python it 
seems logical that a FAQ for this mailing list should exist.

If one does not exist I would be willing to contribute my time. I have 
space on one of those free web hosts, and despite being a newbie 
programmer, I have been coding HTML for the past year.

Any answers/comments/advice on this matter would be appreciated.





-------------------------------------------
Paul De Luca
Email: pdeluca@sia.net.au
Ph: 0414 225561
-------------------------------------------



From GADGILP@INFOTECH.ICICI.com  Fri Jun  1 09:30:28 2001
From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH)
Date: Fri, 1 Jun 2001 14:00:28 +0530
Subject: [Tutor] captering output of a cmd run using os.system.
Message-ID: <718A0962DFC2D4119FF80008C7289E4701032D42@ICICIBACK3>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C0EA75.1D3AA630
Content-Type: text/plain;
	charset="iso-8859-1"

hello,

a cmd that I run using os.sustem() gives the output that I want to assign to
a var 
and use later in prog. How do I do that ?

regards,
prasad


. 


------_=_NextPart_001_01C0EA75.1D3AA630
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>captering output of a cmd run using os.system.</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>hello,</FONT>
</P>

<P><FONT SIZE=2>a cmd that I run using os.sustem() gives the output that I want to assign to a var </FONT>
<BR><FONT SIZE=2>and use later in prog. How do I do that ?</FONT>
</P>

<P><FONT SIZE=2>regards,</FONT>
<BR><FONT SIZE=2>prasad</FONT>
</P>
<BR>

<P><B><FONT SIZE=2>.. </FONT></B>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C0EA75.1D3AA630--


From karimy@nipltd.com  Fri Jun  1 09:44:16 2001
From: karimy@nipltd.com (Karim Yaici)
Date: Fri, 1 Jun 2001 09:44:16 +0100
Subject: [Tutor] [Fwd: [Python-Help] Dos command line]
References: <3B1587FE.CCA19B58@nts-inc.com>
Message-ID: <006501c0ea77$0addf4e0$a5020a0a@private.nipltd.com>

Steve,
I usually use popen to run DOS commands.  In the following, I'll try to run
a Python script and capture the output:

import os
script_path = "c:\\python\\mydoc\\test_popen.py"
operating_system = os.name
if operating_system == 'nt': # yeah! you may not need this check, but I
prefer to use the 'commands' module for
#  *nix
  fd = os.popen('python %s'%script_path)
 outtext = fd.read()
 fd.close()

The same thing if you want to run other commands (dir, cd...).
Keep in mind that if  you are running python 1.52, according to the docs,
this method is unreliable(it does not seem to work on IDE's). I think this
has been fixed in 2.0 (& 2.1). Last thing, if your script (test_popen.py)
contains any errors then the output will be empty under Windows( correct me
if I am wrong , guys:-) )

Cheers,

Karim


----- Original Message -----
From: "steve tran" <steve.tran@nts-inc.com>
To: <tutor@python.org>
Sent: Thursday, May 31, 2001 12:53 AM
Subject: [Tutor] [Fwd: [Python-Help] Dos command line]


> Hi,
>
> Can I have an example for os.open to run dos comand line or batch file?
>
> thanks,
>
> Steve
>



From r.b.rigilink@chello.nl  Fri Jun  1 10:03:31 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Fri, 01 Jun 2001 11:03:31 +0200
Subject: [Tutor] captering output of a cmd run using os.system.
References: <718A0962DFC2D4119FF80008C7289E4701032D42@ICICIBACK3>
Message-ID: <3B175A63.9EF11D10@chello.nl>

> GADGIL PRASAD /INFRA/INFOTECH wrote:
> 
> hello,
> 
> a cmd that I run using os.sustem() gives the output that I want to
> assign to a var
> and use later in prog. How do I do that ?
> 
> regards,
> prasad
> 
> ..

have a look at the os.popen() family of commands.
In stead of

os.system('some_command')

you'll want something like

pipe = os.popen('some_command', 'r')

The pipe is connected to the standard output of 'some_command'. It is a
file-like object, so you can read from it.

output = pipe.readlines()   

reads everything that 'some_command' would normally have written to
screen and assigns it to output. You can parse this to find the values
you're interested in.

Have a look at he documentation for further info.

PS. before Python 2.0, os.popen() worked somewhat unreliable under
windows. If you use Python 1.5.2 under windows, maybe someone else canb
give you additional info.

Hope this helps,

Roeland

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From dyoo@hkn.eecs.berkeley.edu  Fri Jun  1 09:54:40 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 01:54:40 -0700 (PDT)
Subject: [Tutor] captering output of a cmd run using os.system.
In-Reply-To: <718A0962DFC2D4119FF80008C7289E4701032D42@ICICIBACK3>
Message-ID: <Pine.LNX.4.21.0106010145280.6472-100000@hkn.eecs.berkeley.edu>

On Fri, 1 Jun 2001, GADGIL PRASAD     /INFRA/INFOTECH wrote:

> a cmd that I run using os.sustem() gives the output that I want to
> assign to a var and use later in prog. How do I do that ?

Ah, that's where you'll want to use os.popen().  It does pretty much the
same thing as os.system() --- it executes an external command from the
system.  The only difference is that it allows us to grab the output
directly.


For example, if we wanted to store the output of a 'dir' command, we can
do something like this:

###
# Small program to demonstrate os.popen().
import os

f = os.popen('dir')
output = f.read()

print "Here's what we got back:", output
###


What os.popen() does is return something that looks like a file: we can
read() from it in one sitting, or pull out lines at a time with
readline().  os.popen() is mentioned in the reference docs here:

    http://python.org/doc/current/lib/os-newstreams.html


If you're curious, you might want to see what sort of things we'd expect
files to do:

    http://python.org/doc/current/lib/bltin-file-objects.


Good luck!



From dyoo@hkn.eecs.berkeley.edu  Fri Jun  1 10:03:03 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 02:03:03 -0700 (PDT)
Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ?
In-Reply-To: <4.3.2.7.2.20010601175652.00adabe0@mail.sia.net.au>
Message-ID: <Pine.LNX.4.21.0106010156030.6472-100000@hkn.eecs.berkeley.edu>

On Fri, 1 Jun 2001, Paul De Luca wrote:

>      I was wondering if there was a FAQ for this mailing list? I have
> been a subscriber to this list for a few months now, and regularly see
> the same questions come up on the list and get answered with the same
> answers. Since it seems like there are a lot of newbie programmers
> subscribing to this

This isn't off topic at all; a FAQ would be a wonderful thing for this
list.  We don't have a dedicated one for beginning Python programmers, but
it would definitely be a great resource.

Let's have it separated from the official FAQ.  The official Python FAQ is
good, but it's overwhelming!  (It also deals with questions that beginners
probably don't frequently ask in their wildest imaginations.  *grin*)



From ppathiyi@cisco.com  Fri Jun  1 10:08:52 2001
From: ppathiyi@cisco.com (Praveen Pathiyil)
Date: Fri, 1 Jun 2001 14:38:52 +0530
Subject: [Tutor] captering output of a cmd run using os.system.
References: <718A0962DFC2D4119FF80008C7289E4701032D42@ICICIBACK3>
Message-ID: <011901c0ea7a$7ab229a0$37ef87c0@ppathiyipc>

This is a multi-part message in MIME format.

------=_NextPart_000_0116_01C0EAA8.943C9EE0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

captering output of a cmd run using os.system.You can use the os.popen3 =
command instead.
This gives you access to the stdin, stdout and stderr of the command.

                std_out, std_in, std_err =3D popen2.popen3(line)
                resp_suc =3D std_out.readlines()
                resp_err =3D std_err.readlines()
Where "line" will be your command.

Rgds,
Praveen.

  ----- Original Message -----=20
  From: GADGIL PRASAD /INFRA/INFOTECH=20
  To: 'tutor@python.org'=20
  Sent: Friday, June 01, 2001 2:00 PM
  Subject: [Tutor] captering output of a cmd run using os.system.


  hello,=20

  a cmd that I run using os.sustem() gives the output that I want to =
assign to a var=20
  and use later in prog. How do I do that ?=20

  regards,=20
  prasad=20



  ..=20


------=_NextPart_000_0116_01C0EAA8.943C9EE0
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><TITLE>captering output of a cmd run using =
os.system.</TITLE>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>You can use the os.popen3 command=20
instead.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>This gives you access to the stdin, =
stdout and=20
stderr of the command.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
std_out, std_in, std_err =3D=20
popen2.popen3(line)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
resp_suc =3D=20
std_out.readlines()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
resp_err =3D std_err.readlines()<BR>Where "line" will be your=20
command.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Rgds,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Praveen.</FONT></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A href=3D"mailto:GADGILP@INFOTECH.ICICI.com"=20
  title=3DGADGILP@INFOTECH.ICICI.com>GADGIL PRASAD /INFRA/INFOTECH</A> =
</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
href=3D"mailto:'tutor@python.org'"=20
  title=3Dtutor@python.org>'tutor@python.org'</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, June 01, 2001 =
2:00 PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] captering =
output of a=20
  cmd run using os.system.</DIV>
  <DIV><BR></DIV>
  <P><FONT size=3D2>hello,</FONT> </P>
  <P><FONT size=3D2>a cmd that I run using os.sustem() gives the output =
that I=20
  want to assign to a var </FONT><BR><FONT size=3D2>and use later in =
prog. How do=20
  I do that ?</FONT> </P>
  <P><FONT size=3D2>regards,</FONT> <BR><FONT size=3D2>prasad</FONT> =
</P><BR>
  <P><B><FONT size=3D2>.. </FONT></B></P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0116_01C0EAA8.943C9EE0--



From GADGILP@INFOTECH.ICICI.com  Fri Jun  1 10:16:54 2001
From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH)
Date: Fri, 1 Jun 2001 14:46:54 +0530
Subject: [Tutor] captering output of a cmd run using os.system.
Message-ID: <718A0962DFC2D4119FF80008C7289E4701032D43@ICICIBACK3>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C0EA7B.99B448A0
Content-Type: text/plain;
	charset="iso-8859-1"


hi,

that works! thanks daniel, roeland, lindsey.

regards,
prasad

> -----Original Message-----
> From: Daniel Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
> Sent: Friday, June 01, 2001 2:25 PM
> To: GADGIL PRASAD /INFRA/INFOTECH
> Cc: 'tutor@python.org'
> Subject: Re: [Tutor] captering output of a cmd run using os.system.
> 
> 
> On Fri, 1 Jun 2001, GADGIL PRASAD     /INFRA/INFOTECH wrote:
> 
> > a cmd that I run using os.sustem() gives the output that I want to
> > assign to a var and use later in prog. How do I do that ?
> 
> Ah, that's where you'll want to use os.popen().  It does 
> pretty much the
> same thing as os.system() --- it executes an external command from the
> system.  The only difference is that it allows us to grab the output
> directly.
> 
> 
> For example, if we wanted to store the output of a 'dir' 
> command, we can
> do something like this:
> 
> ###
> # Small program to demonstrate os.popen().
> import os
> 
> f = os.popen('dir')
> output = f.read()
> 
> print "Here's what we got back:", output
> ###
> 
> 
> What os.popen() does is return something that looks like a 
> file: we can
> read() from it in one sitting, or pull out lines at a time with
> readline().  os.popen() is mentioned in the reference docs here:
> 
>     http://python.org/doc/current/lib/os-newstreams.html
> 
> 
> If you're curious, you might want to see what sort of things 
> we'd expect
> files to do:
> 
>     http://python.org/doc/current/lib/bltin-file-objects.
> 
> 
> Good luck!
> 


. 


------_=_NextPart_001_01C0EA7B.99B448A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [Tutor] captering output of a cmd run using =
os.system.</TITLE>
</HEAD>
<BODY>
<BR>

<P><FONT SIZE=3D2>hi,</FONT>
</P>

<P><FONT SIZE=3D2>that works! thanks daniel, roeland, lindsey.</FONT>
</P>

<P><FONT SIZE=3D2>regards,</FONT>
<BR><FONT SIZE=3D2>prasad</FONT>
</P>

<P><FONT SIZE=3D2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=3D2>&gt; From: Daniel Yoo [<A =
HREF=3D"mailto:dyoo@hkn.eecs.berkeley.edu">mailto:dyoo@hkn.eecs.berkeley=
.edu</A>]</FONT>
<BR><FONT SIZE=3D2>&gt; Sent: Friday, June 01, 2001 2:25 PM</FONT>
<BR><FONT SIZE=3D2>&gt; To: GADGIL PRASAD /INFRA/INFOTECH</FONT>
<BR><FONT SIZE=3D2>&gt; Cc: 'tutor@python.org'</FONT>
<BR><FONT SIZE=3D2>&gt; Subject: Re: [Tutor] captering output of a cmd =
run using os.system.</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; On Fri, 1 Jun 2001, GADGIL =
PRASAD&nbsp;&nbsp;&nbsp;&nbsp; /INFRA/INFOTECH wrote:</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; a cmd that I run using os.sustem() gives =
the output that I want to</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; assign to a var and use later in prog. How =
do I do that ?</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Ah, that's where you'll want to use =
os.popen().&nbsp; It does </FONT>
<BR><FONT SIZE=3D2>&gt; pretty much the</FONT>
<BR><FONT SIZE=3D2>&gt; same thing as os.system() --- it executes an =
external command from the</FONT>
<BR><FONT SIZE=3D2>&gt; system.&nbsp; The only difference is that it =
allows us to grab the output</FONT>
<BR><FONT SIZE=3D2>&gt; directly.</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; For example, if we wanted to store the output =
of a 'dir' </FONT>
<BR><FONT SIZE=3D2>&gt; command, we can</FONT>
<BR><FONT SIZE=3D2>&gt; do something like this:</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; ###</FONT>
<BR><FONT SIZE=3D2>&gt; # Small program to demonstrate =
os.popen().</FONT>
<BR><FONT SIZE=3D2>&gt; import os</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; f =3D os.popen('dir')</FONT>
<BR><FONT SIZE=3D2>&gt; output =3D f.read()</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; print &quot;Here's what we got back:&quot;, =
output</FONT>
<BR><FONT SIZE=3D2>&gt; ###</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; What os.popen() does is return something that =
looks like a </FONT>
<BR><FONT SIZE=3D2>&gt; file: we can</FONT>
<BR><FONT SIZE=3D2>&gt; read() from it in one sitting, or pull out =
lines at a time with</FONT>
<BR><FONT SIZE=3D2>&gt; readline().&nbsp; os.popen() is mentioned in =
the reference docs here:</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; <A =
HREF=3D"http://python.org/doc/current/lib/os-newstreams.html" =
TARGET=3D"_blank">http://python.org/doc/current/lib/os-newstreams.html</=
A></FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; If you're curious, you might want to see what =
sort of things </FONT>
<BR><FONT SIZE=3D2>&gt; we'd expect</FONT>
<BR><FONT SIZE=3D2>&gt; files to do:</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; <A =
HREF=3D"http://python.org/doc/current/lib/bltin-file-objects" =
TARGET=3D"_blank">http://python.org/doc/current/lib/bltin-file-objects</=
A>.</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Good luck!</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
</P>
<BR>

<P><B><FONT SIZE=3D2>.. </FONT></B>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C0EA7B.99B448A0--


From dyoo@hkn.eecs.berkeley.edu  Fri Jun  1 10:16:29 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 02:16:29 -0700 (PDT)
Subject: [Tutor] Lists...  [book recommendation]
In-Reply-To: <FPEHJJPEEOIPMAHOADBKGENHCDAA.toodles@yifan.net>
Message-ID: <Pine.LNX.4.21.0106010205400.6472-100000@hkn.eecs.berkeley.edu>

On Thu, 31 May 2001, Andrew Wilkins wrote:

> > If it's possible to sort both lists of numbers, then taking the
> > intersection of two sorted lists isn't too bad either; what kind of things
> > will your lists contain?
> 
> They'll just contain positive integers, sorry for not mentioning
> earlier...I'll try to be a little less abstract in future! But it
> really doesn't need to be sorted, I just want to know whether any of
> list a's elements are contained in list b. The solutions I've got
> already are great, so don't worry about this one anymore. Thanks!


It's an interesting problem though; it almost reminds me of something I
saw from the book, "Programming Pearls", by Jon Bentley.  Bentley's
introductory problem is similar because it deals with sorting a lot of
phone numbers.  His program was expected to deal with millions of numbers,
so he needed to do something really cute to get it to sort quickly.

Just wanted to throw that book recommendation out in the open.  *grin*
"Programming Pearls" is a very nice book though and a good read!



From toodles@yifan.net  Fri Jun  1 10:29:56 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Fri, 1 Jun 2001 17:29:56 +0800
Subject: [Tutor] captering output of a cmd run using os.system.
In-Reply-To: <3B175A63.9EF11D10@chello.nl>
Message-ID: <FPEHJJPEEOIPMAHOADBKGENNCDAA.toodles@yifan.net>

Sorry to do a thread takeover here, but I'm going to anyway :o)
I asked not too long ago but I don't think I got a reply, so I'll just try
again.

(FYI I'm using WinME, with Python 2.1)

I'm not familiar with popen, and I looked through the docs and couldn't find
anything, so I would like to know how this works...

With popen when you pipe to a program, it doesn't bring up the stdout - it
goes straight to the pipe. Is it possible for the output to be directed both
to the pipe and to stdout?

Let's say I have the following:

pipe = os.popen('python t','r')
print pipe.read()

############
t.py should look like:

while 1:
 x=raw_input('')
 print x

How can I get the above to come up as visible? With popen it seems to work
in the background.
Is it possible to also collect input from stdin as well as the pipe? Say if
I wanted to send a response to the raw_input bit through the pipe, or
through the actual stdin...

TIA,
Andrew Wilkins




From NHYTRO@compuserve.com  Fri Jun  1 10:30:03 2001
From: NHYTRO@compuserve.com (Sharriff Aina)
Date: Fri, 1 Jun 2001 05:30:03 -0400
Subject: [Tutor] String puzzle...
Message-ID: <200106010531_MC3-D3E6-4CB4@compuserve.com>

Hi guys!

This tiny bug hast stopped me releasing my online HTML Page editor for
testing. I am retrieveng per python/CGI HTML code from a clients browser
and storing in a databse on a remote server. The same client can edit his=

and save hispages. To facilitate the bility to edit existing pages, I jus=
t
retrieve the content from the databse and present it in a content editor =
in
a browser client automatically.

THE BUG
----------------------

As long as the the HTML is written with out carriage returns from the use=
r,
everything is fine. The carriage return or "<P>" tag is entered by the us=
er
from the browser by tapping the enter key. The editor on its part fails t=
o
display any text or HTML code that is not written in the same line, it
complains of an "Unterminated String" error.

I have stripped spaces, by database entry, and database access for writin=
g,
but the cgi always writes the TEXT/HTML in separte lines if he user has
inputted a carriage return in the entry/edit form.

THE QUESTION
-----------------------------

How do I strip a a carriage return? is it really a carriage return thats
tripping my code up?


Sorry for rambling, but the problem was too difficult to descibe in fewer=

sentences.


Best regards


Sharriff


From alan.gauld@bt.com  Fri Jun  1 10:46:40 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 1 Jun 2001 10:46:40 +0100
Subject: [Tutor] starting tcl?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7E9@mbtlipnt02.btlabs.bt.co.uk>

> I'm on windows 98 IE and have python 2.1
> On Alan Gaulds webpage lessons it says to type tclsh80 
> at the dos prompt to start tcl. 

Yes, unfortunately from Python 2.0(*) they stopped shipping 
tcl with Python, they only include the DLLs needed to 
run Tkinter. From the python users point of view thats 
great. From my tutors point of view thats bad... 

I need to mention that somewhere on the site I guess...
You can download the real Tcl (for free) from the tcl
web link on the intro page

http://www.scriptics.com

Scriptics no longer exists but the url redirects to 
the correct site...

Sorry about that,

Alan G.

(*)It might be from v1.6 I never used it...


From alan.gauld@bt.com  Fri Jun  1 10:51:04 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 1 Jun 2001 10:51:04 +0100
Subject: [Tutor] Lists...
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EA@mbtlipnt02.btlabs.bt.co.uk>

> Is there a way of returning the intersection of two lists?
> Eg. [1,2,'3',4.0,'x'] & [1,8,'3',9,10,'x'] to return [1,'3','x']

Several ways. The easiest for me is:

L1 = [1,2,'3',4.0,'x']
L2 = [1,8,'3',9,10,'x']
intersect = filter(lambda x: (x in L2), L1)

The (x in L2) parens are not needed but I like to use them
to clarify the extent of the lambda expression

Alan G


From lonetwin@yahoo.com  Fri Jun  1 11:10:00 2001
From: lonetwin@yahoo.com (steve)
Date: Fri, 1 Jun 2001 15:40:00 +0530
Subject: [Tutor] captering output of a cmd run using os.system.
In-Reply-To: <718A0962DFC2D4119FF80008C7289E4701032D43@ICICIBACK3>
References: <718A0962DFC2D4119FF80008C7289E4701032D43@ICICIBACK3>
Message-ID: <01060115400002.03175@mercury.in.cqsl.com>

Hey there,

> > > a cmd that I run using os.sustem() gives the output that I want to
> > > assign to a var and use later in prog. How do I do that ?
> >

A lil' bit too late in the thread , 'cos I didn't chk my mail,.....but I=20
prefer to use the commands module, commands.getoutput(),=20
commands.getstatusoutput()....stuff like that,...just thought I'd mention=
=20
that, even tho' the Ques. is Ans'ed

Peace
Steve

--=20
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||=09
|||/\##|||||||||##/\||=09
|/    \#########/    \=09
|\     \#######/     /=09
||\____/#######\____/|=09
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=09
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


From dyoo@hkn.eecs.berkeley.edu  Fri Jun  1 11:07:20 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 03:07:20 -0700 (PDT)
Subject: [Tutor] captering output of a cmd run using os.system.
In-Reply-To: <FPEHJJPEEOIPMAHOADBKGENNCDAA.toodles@yifan.net>
Message-ID: <Pine.LNX.4.21.0106010251120.6472-100000@hkn.eecs.berkeley.edu>

On Fri, 1 Jun 2001, Andrew Wilkins wrote:


> Let's say I have the following:
> 
> pipe = os.popen('python t','r')
> print pipe.read()
> 
> ############
> t.py should look like:
> 
> while 1:
>  x=raw_input('')
>  print x
> 
> How can I get the above to come up as visible? With popen it seems to
> work in the background.

> Is it possible to also collect input from stdin as well as the pipe?
> Say if I wanted to send a response to the raw_input bit through the
> pipe, or through the actual stdin...


Yes: you'll want to use the extended popen(): os.popen2().  It gives back
two file-like objects, one for input, and the other for output.  For
reference, let's look at the documentation:

"""
popen2(cmd[, bufsize[, mode]]) 
Executes cmd as a sub-process. Returns the file objects (child_stdin,
child_stdout). New in version 2.0. 
"""

    http://python.org/doc/current/lib/os-newstreams.html

Warning!  They switched the order of the arguments "bufsize" and "mode"
between os.popen() and os.popen2().  By default, though, it's in text
mode, so there's usually less of a need to tell Python to override the
defaults.


What we can do, then, might look something like this:

###
input_pipe, output_pipe = os.popen2('python t')
input_pipe.write("Hello world, this is a test.\n")
print output_pipe.read()
###


I have not been able to test this on Windows though, so I'm not sure how
successful this will be... *grin* Try it out, and if you run into
problems, email us again.

Good luck!



From alan.gauld@bt.com  Fri Jun  1 11:01:46 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 1 Jun 2001 11:01:46 +0100
Subject: [Tutor] Python syntax highligting with Vim
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EB@mbtlipnt02.btlabs.bt.co.uk>

> and would like to implement it in gvim under windows. 

It should already work

> cannot find any documentation on turning on syntax 
> highligting. 

Try :help syntax

But put simply its:

:syntax on

Or put the line 

syntax on 

in your .gvimrc file.

Alan g


From alan.gauld@bt.com  Fri Jun  1 11:05:27 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 1 Jun 2001 11:05:27 +0100
Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EC@mbtlipnt02.btlabs.bt.co.uk>

> If one does not exist I would be willing to contribute my 
> time. 

You said the magic words.
Feel free, I'm pretty sure there iusn't a tutor-faq yet
and yes we do get a lot of duplication. Just nobody 
else has time...

So I say go for it.

Alan G.


From alan.gauld@bt.com  Fri Jun  1 11:09:11 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 1 Jun 2001 11:09:11 +0100
Subject: [Tutor] captering output of a cmd run using os.system.
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7ED@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C0EA82.E7A76810
Content-type: text/plain; charset="ISO-8859-1"

> You can use the os.popen3 command instead. 
 
You might need to use the version of popwen in 
the winall package if you are on NT/W9x 
- it seems to work better...
 
Alan g
 
 
 

------_=_NextPart_001_01C0EA82.E7A76810
Content-type: text/html; charset="ISO-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<TITLE>captering output of a cmd run using os.system.</TITLE>

<META content="MSHTML 5.00.3013.2600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"><FONT 
size=2><FONT color=#0000ff><FONT face="Courier New"><SPAN 
class=440351310-01062001>&gt;&nbsp;</SPAN>You can use the os.popen3 command 
instead.<SPAN class=440351310-01062001>&nbsp;</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001>You might need to use the version of popwen in 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001>the winall package if you are on NT/W9x 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001>- it seems to work 
better...</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001>Alan g</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=440351310-01062001>&nbsp;</SPAN></FONT></FONT></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01C0EA82.E7A76810--


From dyoo@hkn.eecs.berkeley.edu  Fri Jun  1 11:18:18 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 03:18:18 -0700 (PDT)
Subject: [Tutor] String puzzle...
In-Reply-To: <200106010531_MC3-D3E6-4CB4@compuserve.com>
Message-ID: <Pine.LNX.4.21.0106010314380.6472-100000@hkn.eecs.berkeley.edu>

On Fri, 1 Jun 2001, Sharriff Aina wrote:

> How do I strip a a carriage return? is it really a carriage return
> thats tripping my code up?

Might be; we'd probably need to see the exact error message to be more
sure about it.

The carriage return character can be written as "\r" in Python, if you
have your form output, you can do something like a replace():


###
>>> myform = '''this is a test form

with some carriage\r\n returns in it.'''
>>> myform = myform.replace('\r', '')
###



From craig@osa.att.ne.jp  Fri Jun  1 11:39:19 2001
From: craig@osa.att.ne.jp (Craig Hagerman)
Date: Fri, 01 Jun 2001 19:39:19 +0900
Subject: [Tutor] bitwise operations
Message-ID: <E155mHW-0001gK-00@mail.python.org>

Hi,

Could anyone tell me all there is to know about bit manipulation; that is,
how and why a person would want to be fiddling with bits. I have several
books on Python (as well as some other languages) and they tell me what the
bitwise operators are but don't tell me how I would use them, or in what
cases such use would be benificial. Any bit guru's up to such an explainatio
for me?

Craig Hagerman


From arcege@speakeasy.net  Fri Jun  1 12:45:31 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Fri, 1 Jun 2001 07:45:31 -0400 (EDT)
Subject: [Tutor] captering output of a cmd run using os.system.
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D7ED@mbtlipnt02.btlabs.bt.co.uk> from "alan.gauld@bt.com" at Jun 01, 2001 11:09:11 AM
Message-ID: <200106011145.f51BjVO02073@dsl092-074-184.bos1.dsl.speakeasy.net>

alan.gauld@bt.com wrote
> 
> ------_=_NextPart_001_01C0EA82.E7A76810
> Content-type: text/plain; charset="ISO-8859-1"
> 
> > You can use the os.popen3 command instead. 
>  
> You might need to use the version of popwen in 
> the winall package if you are on NT/W9x 
> - it seems to work better...

WinXX os.popen also has a bug in GUI environments and will fail anyways
(which is why it doesn't work in the IDEs).

One win32all solution is:
>>> import win32pipe
>>> file = win32pipe.popen("echo Hello from Python", "r")
>>> file.read()
'Hello from Python\012'
>>>
There are other modules to help spawn programs this way.

If you wish to do a lot of WinXX Python programming, you might want to
get Hammond&Robinson's _Python Programming on Win32_.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From NHYTRO@compuserve.com  Fri Jun  1 12:48:11 2001
From: NHYTRO@compuserve.com (Sharriff Aina)
Date: Fri, 1 Jun 2001 07:48:11 -0400
Subject: [Tutor] Thanks
Message-ID: <200106010748_MC3-D3EC-C6FD@compuserve.com>

I would like to thank all the members of this list that helped me through=

the bumpy ride of coding an online HTML editor, I hope one day to be a
proficient as you all in order to help others as you have helped me.

My application is still "Raw", it its far from being finished, but its
something I can show my boss to underline Pythons feasibility in such a
project.


Best regards


Sharriff


From alan.gauld@bt.com  Fri Jun  1 13:18:42 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 1 Jun 2001 13:18:42 +0100
Subject: [Tutor] bitwise operations
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7F1@mbtlipnt02.btlabs.bt.co.uk>

> Could anyone tell me all there is to know about bit 
> manipulation; 

No, I doubt it. I don'ty think anyone has figured 
that out yet... Some things you might like to do 
a search on the net for are 'Boolean Algenra' 
and 'Bitmasks'

> why a person would want to be fiddling with bits. 

Bits are a compact way of storing a lot of data which 
is boolean by nature.
For example software used for bulk processing of a 
long list of items might keep a note of which items 
have changed(and hence need reprocessing) by adding 
a boolean value flag to the reords - but that (a) 
changes the records and (b) takes up a byte per 
record. An altrernative solution is to store a block 
of memory with a single bit representing each record, 
then simply switch that bit on if the reord changes.

The bulk processor then scans the bits and processes 
the records with a bit set.

This scheme is what is used in practice for 
synchronising mirrored hard disks in large 
data centres etc... the bits represent the 
raw sectors of the disk and the OS updates 
the bit image after every write.

> bitwise operators are but don't tell me how 
> I would use them, or in what cases such use 
> would be benificial. 

But there are myriad other uses for these, 
usually in a low level systems context and 
often in situations where storage space is 
expensive - like networking protocols etc.

I'll leave explaining how to use "bit masks"
to read/write individual bits within a block 
of storage to someone else... :-)

Alan G.



From shalehperry@home.com  Fri Jun  1 15:14:49 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Fri, 01 Jun 2001 07:14:49 -0700 (PDT)
Subject: [Tutor] String puzzle...
In-Reply-To: <Pine.LNX.4.21.0106010314380.6472-100000@hkn.eecs.berkeley.edu>
Message-ID: <XFMail.20010601071449.shalehperry@home.com>

>###
>>>> myform = '''this is a test form
> 
> with some carriage\r\n returns in it.'''
>>>> myform = myform.replace('\r', '')
>###
> 

or simply use strip(), which will remove leading and trailing whitespace of any
kind.  Which, in this instance seems like the right thing to do.  There is also
rstrip() which only strips from the right.


From BlakeW@rpmtec.com  Fri Jun  1 14:53:24 2001
From: BlakeW@rpmtec.com (Blake Winton (Screaming))
Date: Fri, 1 Jun 2001 09:53:24 -0400
Subject: [Tutor] bitwise operations
Message-ID: <8551136CB6F6D311811B00508B8B92E0C897C0@mail.rpmtec.com>

> > Could anyone tell me all there is to know about bit 
> > manipulation; 
> No, I doubt it. I don'ty think anyone has figured 
> that out yet... Some things you might like to do 
> a search on the net for are 'Boolean Algenra' 
> and 'Bitmasks'

Okay, but surely we could give Craig a short overview...
(See the bottom of the message for descriptions of
 setting bits, clearing bits, and checking if bits are
 set.)

> > why a person would want to be fiddling with bits. 
> Bits are a compact way of storing a lot of data which 
> is boolean by nature.

[ some good examples snipped... ]

> But there are myriad other uses for these, 
> usually in a low level systems context and 
> often in situations where storage space is 
> expensive - like networking protocols etc.

I also saw a neat application of them in a financial
application I'm looking at.  Basically, you can set
up Pre-Authorized Cash Transfers to happen once or
twice a month, on any days you choose.  As a compact
(and easy?) way of representing those pieces of
information, the coders chose to use an integer, as
a bit mask.  So, if we look at some examples of the
individual bits, we can see what's going on.

If you wanted the transfers to occur on the 3rd and
the 7th, you would set those bits to one, and leave
the rest as 0, to get:
   01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 ...
    0  0  1  0  0  0  1  0  0  0  0  0  0  0  0 ...
(which I've wrote backwards, so we'll flip it to
 be 1000100 (base 2) which equals 68 (base 10).)

Or, if you only wanted stuff transfered on the 5th
of each month, you you set the 5th bit to one, and
the rest to 0, to get:
   01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 ...
    0  0  0  0  1  0  0  0  0  0  0  0  0  0  0 ...
(which I've wrote backwards, so we'll flip it to
 be 10000 (base 2) which equals 16 (base 10).)

Then, to see if a current day has any scheduled
transfers, all the calling program has to do is
take that day number, and check if the bit is set.

> I'll leave explaining how to use "bit masks"
> to read/write individual bits within a block 
> of storage to someone else... :-)

I'll try it...

First, we'll need a short course in hexadecimal numbers,
because they're easier to print out.

If you take a binary number, like 100100 (which equals
36), we can break the digits of it up into groups of 4,
to get 10 0100, and add a couple of 0s at the front to
make 4 digits, and we get 0010 0100.  Now, each of these
groups can be turned into a number with the following
chart:
0000 = 0       1000 = 8
0001 = 1       1001 = 9
0010 = 2       1010 = A (10)
0011 = 3       1011 = B (11)
0100 = 4       1100 = C (12)
0101 = 5       1101 = D (13)
0110 = 6       1110 = E (14)
0111 = 7       1111 = F (15)

These are the hexadecimal numbers.  And if we look them
up, we find that our number 0010 0100 turns into 24 (hex).
To make it easy for us to tell the difference between 24
(decimal) and 24 (hex), we stick a "0x" onto the front of
the hex number, to get "0x24".  And if we start python,
we can see that it works.
>>> print hex(36)
0x24

So, from here on in, I'm just going to print out the hex
numbers.  If you want to know the binary, you can look it
up...

I should probably also tell you about the << operator.
It takes a number, and shifts it left by another number.
So, if we have 1 << 4, in binary, it makes 1 turn into
10000 (think of adding 4 0s onto the end of the number
in binary).  This gives us an easy way of selecting the
4th bit, just use 1<<3.  (Because 1<<0 is the first bit.)
Now, on to the actual stuff...

To set a bit in a bit mask, you use the "or" operator,
(written "|").  But then we need to assign it back to
the variable we're testing.  So, lets start with an x 
of 0, and set some bits in it.

Jython 2.0 on java1.2.2 (JIT: symcjit)
Type "copyright", "credits" or "license" for more information.
>>> x = 0
>>> print hex(x)
0x0
>>> x = x | 1 << 4
>>> print hex(x)
0x10
>>> # in binary 0001 0000, so the 5th bit is set.
>>> x = x | 1 << 2
>>> print hex(x)
0x14
>>> # in binary 0001 0100, so the 5th and 3rd bits are set.

It sort of looks like we're just adding here, but if
we try to set the second bit again, we get:
>>> x = x | 1 << 2
>>> print hex(x)
0x14

If we want to clear a bit, it's a little more complicated.
We want to use the "and" operator, written "&", but with
all the bits set except for the one we want.  To get that,
we need the "not" operator, written "~".  So, to clear the
3rd bit, we use x = x & ~(1 << 2)
>>> x = x & ~(1 << 2)
>>> print hex(x)
0x10
>>> # And we're back to 0001 0000, so the 5th bit is set.

Finally, to test if the 5th bit is set, we again use the
"and" operator ("&"), but this time, we check that the
result is not equal to 0.
>>> print (x & (1<<4)) != 0
1

It's probably useful to you to make three functions.
def setBit( x, bitNum ):
  return x | 1 << bitNum
def clearBit( x, bitNum ):
  return x & ~( 1 << bitNum )
def checkBit( x, bitNum ):
  return (x & (1<<bitNum)) != 0

Then, as long as you remember to start your bitNums 
from 0, you can just use the three functions, and
everyone will know what you are doing.

So, clear as mud?  ;)

Seriously, if you have any questions, just ask, and I'll
see what I can do.  I would like to explain more in this
email, but I've got a deadline coming up, and I've
probably spent too much time on this email as it is.
I can answer more specific questions, if you have them,
but I've really got to cut this particular explanation
off here.

Later,
Blake.


From NHYTRO@compuserve.com  Fri Jun  1 23:09:50 2001
From: NHYTRO@compuserve.com (Sharriff Aina)
Date: Fri, 1 Jun 2001 18:09:50 -0400
Subject: [Tutor] Tutor digest, Vol 1 #846 - 3 msgs
Message-ID: <200106011810_MC3-D3F7-5EA@compuserve.com>



Actually I had tried "stripping" even on both sides, before database acce=
ss
and after, no difference. This worked:

##
result =3D string.replace(myform,'\n', '')

it was a NEWLINE that tripped me up the whole time :-))


Thanks for the tip all the same

Best regards


Sharriff



Nachricht geschrieben von INTERNET:tutor@python.org
>>###
>>>> myform =3D '''this is a test form
> =

> with some carriage\r\n returns in it.'''
>>>> myform =3D myform.replace('\r', '')
>###
> =


or simply use strip(), which will remove leading and trailing whitespace =
of
any
kind.  Which, in this instance seems like the right thing to do.  There i=
s
also
rstrip() which only strips from the right.<



From clickron@webtv.net  Fri Jun  1 23:32:23 2001
From: clickron@webtv.net (clickron@webtv.net)
Date: Fri, 1 Jun 2001 18:32:23 -0400 (EDT)
Subject: [Tutor] starting tcl? Thanks
Message-ID: <23824-3B1817F7-115@storefull-167.iap.bryant.webtv.net>

Thanks for the help. As I try to learn this stuff it can be kind of
confusing and frustrating, but it's coming slow but sure.

Ron



From lgwb@home.com  Sat Jun  2 05:25:26 2001
From: lgwb@home.com (Michael Schmitt)
Date: Fri, 1 Jun 2001 23:25:26 -0500
Subject: [Tutor] Lists...
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EA@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <00e901c0eb1c$0cb9aac0$0a0a0a0a@mntp1.il.home.com>

Just for fun I added a function using Alan G method to the Roeland's timing
code as follows:

def intersect1(l1, l2):
    '''brute force intersection of two lists'''
    if len(l1) > 1000:
        print 'forget about it...\n brute force number invalid!'
        return l1
    return [item for item in l1 if item in l2]

def intersect2(l1, l2):
    '''intersection of two lists, using dicts'''
    dict = {}
    for item in l2:
        dict[item] = None
    return [item for item in l1 if dict.has_key(item)]

def intersect2a(l1, l2):
    '''using dicts with filter, thanks to Remco Gehrlich'''
    dict = {}
    for item in l2:
        dict[item] = 1
    return filter(dict.has_key, l1)

def intersect3(l1, l2):
    '''intersection of two sorted lists of unique items'''
    result = []
    lo = 0
    hi = len(l2)
    for i in l1:
        for j in xrange(lo, hi):
            n = cmp(l2[j], i)
            if n==-1:
                lo = j
            elif n==1:
                break
            else:
                lo = j
                result.append(i)
                break
    return result

def intersect_eas(L1, L2):
    '''The easiest way for Alan G'''
    return filter(lambda x: (x in L2), L1)


def make_list(n):
    '''Make a sorted list of unique ints larger than 1'''
    import random
    l = []
    x = 1
    for i in xrange(n):
        x = x+random.randrange(1, 5)
        l.append(x)
    return l

def time_func(intersect_func, l1, l2):
    import time
    t1 = time.time()
    l = intersect_func(l1, l2)
    t2 = time.time()-t1
#    print l[0:10]
    return t2

def test(n):
    l1 = make_list(n)
    l2 = make_list(n)
    print 'Brute force (n=%i), t=%f' % (n, time_func(intersect1, l1,
l2))
    print 'Dict lookup (n=%i), t=%f' % (n, time_func(intersect2, l1,
l2))
    print 'Dict filter (n=%i), t=%f' % (n, time_func(intersect2a, l1,
l2))
    print 'Sorted list (n=%i), t=%f' % (n, time_func(intersect3, l1,
l2))
    print 'Sort easy (n=%i), t=%f' % (n, time_func(intersect_eas, l1,l2))

if __name__=='__main__':
    test(10)
    test(100)
    test(1000)
    test(10000)

and the results.....
Brute force (n=10), t=0.000000
Dict lookup (n=10), t=0.000000
Dict filter (n=10), t=0.000000
Sorted list (n=10), t=0.000000
Sort easy (n=10), t=0.000000
Brute force (n=100), t=0.000000
Dict lookup (n=100), t=0.010000
Dict filter (n=100), t=0.000000
Sorted list (n=100), t=0.000000
Sort easy (n=100), t=0.000000
Brute force (n=1000), t=0.631000
Dict lookup (n=1000), t=0.030000
Dict filter (n=1000), t=0.021000
Sorted list (n=1000), t=0.060000
Sort easy (n=1000), t=0.010000
forget about it...
 brute force number invalid!
Brute force (n=10000), t=0.131000
Dict lookup (n=10000), t=0.270000
Dict filter (n=10000), t=0.210000
Sorted list (n=10000), t=0.681000
Sort easy (n=10000), t=0.210000

Thanks guys... that was cool.

Question regarding running the brute force method  with values of 10000 for
n under IDLE, "how do I stop the code from running with out shuting down
IDLE?"

Michael Schmitt




From dyoo@hkn.eecs.berkeley.edu  Sat Jun  2 06:39:47 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 22:39:47 -0700 (PDT)
Subject: [Tutor] Lists...  [book recommendation for Programming Pearls]
In-Reply-To: <00f101c0eb1c$724ffbf0$0a0a0a0a@mntp1.il.home.com>
Message-ID: <Pine.LNX.4.21.0106012227060.25896-100000@hkn.eecs.berkeley.edu>

On Fri, 1 Jun 2001, Michael Schmitt wrote:

> So is the book programming language independent?  Will I get anything
> out of it if I don't know C and only Python?

It uses a bit of C, C++, and pseudocode, but the ideas are very
transferable to Python.  The focus of the book is conceptual. Here's part
of his Preface:


"""The columns in this book are about a more glamorous aspect of the
profession: programming pearls whose origins lie beyond solid engineering,
in the realm of insight and creativity.  Just as natural pearls grow from
grains of sand that have irritated oysters, these programming pearls have
grown from real problems that have irritated real programmers.  The
programs are fun, and they teach important programming techniques and
fundamental design principles.

Most of these essays originally appeared in my "Programming Pearls" column
in Communications of the Association for Computing Machinery.  They were
collected, revised, and published as the first edition of this book in
1986.  Twelve of the thirteen pieces in the first edition have been edited
substantially for this edition, and three new columns hav ebeen added.

The only backgorund the book assumes is programming experience in a
high-level language.  Advanced techniques (such as templates in C++) show
up now and then, but the reader unfamiliar with such topics will be able
to skip to the next section with impunity.

Although each column may be read by itself, there is a logical grouping to
the complete set.  columns 1 through 5 form Part I of the book.  They
review programming fundamentals: problem definition, algorithms, data
structures and program verification and testing.  Part II is built around
the theme of efficiency, which is sometimes important in itself and is
always a fine springboard into interesting programming problems.  Part III
applies those techniques to several substantial problems in sorting,
searching and strings."""


Whew!  Anyway, I recommend taking a look at it in your local bookstore,
and see if it's useful for you.  It's one of the books I really wish
someone had recommended to me years ago, so that's why I'm recommending it
now.  *grin*

Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Sat Jun  2 06:55:28 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 22:55:28 -0700 (PDT)
Subject: [Tutor] Re: [Python-Help] a number and control char stored in a single char.
 !
In-Reply-To: <20010602052713.3595.qmail@web13607.mail.yahoo.com>
Message-ID: <Pine.LNX.4.21.0106012242450.25896-100000@hkn.eecs.berkeley.edu>

On Fri, 1 Jun 2001, kaha aham wrote:


> I am running & capturing screen output of a command using os.popen as
> helped by tuto@python.org ppl. However the value i capture which
> should be a number like something like 22345 is displayed as
> '22345\012'

Yes, this means that what you're getting back is the string "21345"
followed by the newline, '\012'.  What you'll need to do is convert it
with the int() function.



> I need to numerically compare this value later in program. I tried
> slicing it to remove the last control char using var[:-1], on which it
> prints []. I then trid using len(), it tells size as 1 char. I tried
> printing just 1st char using var[0], and it shows '22345\012'

Ah!  You had the right idea: what you'll want to do is:

    var[0][:-1]

instead.  You want to get all but the last character from var[0], your
first line of the output.  This is probably what was preventing you from
converting to integer.  Try int()'ing with var[0][:-1], and you should be
ok.  But if you're converting with int(), you don't need to strip out the
newline character; int() knows how to deal with it already.


Let's look at what happened before... I'm guessing that when you used
os.popen(), you used the readlines() method to get at all the lines of
output.  What this means is that "var" stands for all the lines of input,
and "var[0]" stands for the first line.  However, "var[:-1]" stands for
all but the last line --- but if your output only consists of one line,
that means you'll get the empty list, [].  That should explain the weird
error messages.


> That's baffling me. How can it put all that number and control char in
> 1 char. I currently can't post to tutor maillist as I did earlier.

Hmmm... that's strange!  Try posting your question again; perhaps the mail
host was down.  In the meantime, I'll forward your message to
tutor@python.org.

I just checked, and from what I can tell, you're not subscribed to the
tutor list yet.  You'll probably need to subscribe to post to tutor.  You
can subscribe here:

    http://mail.python.org/mailman/listinfo/tutor


If you run into difficulties again, feel free to email again.  I'll talk
to you later!



From dyoo@hkn.eecs.berkeley.edu  Sat Jun  2 06:55:39 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 22:55:39 -0700 (PDT)
Subject: [Tutor] [Python-Help] a number and control char stored in a single char.
 ! (fwd)
Message-ID: <Pine.LNX.4.21.0106012255300.25896-100000@hkn.eecs.berkeley.edu>


---------- Forwarded message ----------
Date: Fri, 1 Jun 2001 22:27:13 -0700 (PDT)
From: kaha aham <wishleshak@yahoo.com>
To: help@python.org
Subject: [Python-Help] a number and control char stored in a single char.  !


hello,

I am running & capturing screen output of a command using os.popen
as helped by tuto@python.org ppl. However the value i capture which should 
be a number like something like 22345 is displayed as '22345\012'

I need to numerically compare this value later in program.
I tried slicing it to remove the last control char using var[:-1],
on which it prints []. I then trid using len(), it tells size as 1 char.
I tried printing just 1st char using var[0], and it shows '22345\012'

That's baffling me. How can it put all that number and control char in 1 char.
I currently can't post to tutor maillist as I did earlier. 

I tried int(var) and it says, object cant be converted to int.

Can you give a hint how do I resolve this and get the numeric out of it.


/psg



---------------------------------
Do You Yahoo!?
Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail.



From dyoo@hkn.eecs.berkeley.edu  Sat Jun  2 07:01:50 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Fri, 1 Jun 2001 23:01:50 -0700 (PDT)
Subject: [Tutor] bitwise operations
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D7F1@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.LNX.4.21.0106011351040.19793-100000@hkn.eecs.berkeley.edu>

On Fri, 1 Jun 2001 alan.gauld@bt.com wrote:

> > Could anyone tell me all there is to know about bit 
> > manipulation; 
> 
> No, I doubt it. I don'ty think anyone has figured that out yet... Some
> things you might like to do a search on the net for are 'Boolean
> Algenra' and 'Bitmasks'
> 
> > why a person would want to be fiddling with bits. 
> 
> Bits are a compact way of storing a lot of data which is boolean by
> nature.

> For example software used for bulk processing of a long list of items
> might keep a note of which items have changed(and hence need
> reprocessing) by adding a boolean value flag to the reords - but that
> (a)  changes the records and (b) takes up a byte per record. An
> altrernative solution is to store a block of memory with a single bit
> representing each record, then simply switch that bit on if the reord
> changes.


Using a bit-wise notation is also a natural way of representing sets.  
For example, let's say that we'd like to find the intersection of two
lists of numbers.  For example, let's try to find the intersection
between:

    L1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    L2 = [2, 4, 6, 8, 10, 12]

Of course, we know that intersect(L1, L2) = [2, 4, 6, 8, 10], but let's
pretend that we didn't know that initially.  A way that we can represent
L1 is as a list of bits:

    ---------------------------------------------------------
     pos  0   1   2   3   4   5   6   7   8   9   10  11  12
    ---------------------------------------------------------
     L1 = 0   1   1   1   1   1   1   1   1   1   1   0   0
     L2 = 0   0   1   0   1   0   1   0   1   0   1   0   1

(Traditionally, the bits are listed in reverse order.)

The reason that representing L1 and L2 as a bunch of bits is useful is
because taking the intersection just involves looking for places where L1
and L2 both have 1: that is, we perform the AND logical operation:

    ---------------------------------------------------------
     pos  0   1   2   3   4   5   6   7   8   9   10  11  12
    ---------------------------------------------------------     
     L1 = 0   1   1   1   1   1   1   1   1   1   1   0   0
     L2 = 0   0   1   0   1   0   1   0   1   0   1   0   1
    --------------------------------------------------------
L1 & L2 = 0   0   1   0   1   0   1   0   1   0   1   0   0


And that's exactly what we want to get: by doing the AND, we now know that
the intersection between L1 and L2 is [2, 4, 6, 8, 10].


To actually represent L1 in Python is where all those bit operations come
into play.  The idea in bit manipulation is that we'll try to "pack" a
bunch of bits into a Python integer.  Every Python integer is actually
made up of 32 bits --- that gives us 32 little switches to work with.  If
we want more bits, we can use another integer to get a block of 32 more
bits.

Blake Winton's message talks a little more about bit-fiddling stuff, so
I'll stop here... *grin*



From r.b.rigilink@chello.nl  Sat Jun  2 08:05:10 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Sat, 02 Jun 2001 09:05:10 +0200
Subject: [Tutor] Lists...
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EA@mbtlipnt02.btlabs.bt.co.uk> <00e901c0eb1c$0cb9aac0$0a0a0a0a@mntp1.il.home.com>
Message-ID: <3B189026.18DAFC5A@chello.nl>

Michael Schmitt wrote:
> 
> Just for fun I added a function using Alan G method to the Roeland's timing
> code as follows:
> 
Hi Michael,

I don't know why our numbers differ so much (you got 0.00000 in a lot of
your timing measurements)
Anyway, Alan's method is strictly brute force, just written somewhat
differently.
Here's what I get (Code follows at the end)

Brute force (n=10), t=0.000137
List filter (n=10), t=0.000212	# Alan's code
Dict lookup (n=10), t=0.000150
Dict filter (n=10), t=0.000119
Sorted list (n=10), t=0.000426

Brute force (n=100), t=0.006812
List filter (n=100), t=0.006745
Dict lookup (n=100), t=0.001056
Dict filter (n=100), t=0.000680
Sorted list (n=100), t=0.003793

Brute force (n=1000), t=0.831248
List filter (n=1000), t=0.837468
Dict lookup (n=1000), t=0.017591
Dict filter (n=1000), t=0.007191
Sorted list (n=1000), t=0.055949

Brute force (n=10000), t=92.381026
List filter (n=10000), t=92.870684
Dict lookup (n=10000), t=0.151935
Dict filter (n=10000), t=0.124802
Sorted list (n=10000), t=0.532801

i.e Quadratic time behaviour for brute force, linear time for
dictinonary based methods and using sorted lists.

-- the code 

from __future__ import nested_scopes

def intersect1(l1, l2):
    '''brute force intersection of two lists'''
    return [item for item in l1 if item in l2]

def intersect2(l1, l2):
    '''intersection of two lists, using dicts'''
    dict = {}
    for item in l2:
        dict[item] = None
    return [item for item in l1 if dict.has_key(item)]

def intersect2a(l1, l2):
    '''using dicts with filter, thanks to Remco Gehrlich'''
    dict = {}
    for item in l2:
        dict[item] = 1
    return filter(dict.has_key, l1)

def intersect3(l1, l2):
    '''intersection of two sorted lists of unique items'''
    result = []
    lo = 0
    hi = len(l2)
    for i in l1:
        for j in xrange(lo, hi):
            n = cmp(l2[j], i)
            if n==-1:
                lo = j
            elif n==1:
                break
            else:
                lo = j
                result.append(i)
                break
    return result

def intersect_eas(L1, L2):
    '''The easiest way for Alan G, requires nested_scopes'''
    return filter(lambda x: (x in L2), L1)

def make_list(n):
    '''Make a sorted list of unique ints larger than 1'''
    import random
    l = []
    x = 1
    for i in xrange(n):
        x = x+random.randrange(1, 5)
        l.append(x)
    return l

def time_func(intersect_func, l1, l2):
    import time
    t1 = time.time()
    l = intersect_func(l1, l2)
    t2 = time.time()-t1
#    print l[0:10]
    return t2

def test(n):
    l1 = make_list(n)
    l2 = make_list(n)
    print 'Brute force (n=%i), t=%f' % (n, time_func(intersect1, l1,
l2))
    print 'List filter (n=%i), t=%f' % (n, time_func(intersect_eas, l1,
l2))
    print 'Dict lookup (n=%i), t=%f' % (n, time_func(intersect2, l1,
l2))
    print 'Dict filter (n=%i), t=%f' % (n, time_func(intersect2a, l1,
l2))
    print 'Sorted list (n=%i), t=%f' % (n, time_func(intersect3, l1,
l2))
    print
if __name__=='__main__':
    test(10)
    test(100)
    test(1000)
    test(10000)


-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From rickyp1@frontiernet.net  Sat Jun  2 19:49:05 2001
From: rickyp1@frontiernet.net (Ricky Parks)
Date: Sat, 2 Jun 2001 13:49:05 -0500
Subject: [Tutor] Unsubsciption
Message-ID: <001c01c0eb94$b3ab2980$6601a8c0@Parks>

This is a multi-part message in MIME format.

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

I thought this tuter thing would help me out, I am a beginner but =
instead I am getting alot of messages in my mail box that I dont want. =
Please give me the unsubscrition web address. You should add the =
unsubscrition address to off email sent.
                                        Richard E Parks 2
                                        RickyP1@frontiernet.net
=20

------=_NextPart_000_0019_01C0EB6A.C9C89380
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>I thought this tuter thing would help =
me out, I am=20
a beginner but instead I am getting alot of messages in my mail box that =
I dont=20
want. Please give me the unsubscrition web address. You should add the=20
unsubscrition address to off email sent</FONT><FONT face=3DArial=20
size=3D2>.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
Richard E Parks 2</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; <A=20
href=3D"mailto:RickyP1@frontiernet.net">RickyP1@frontiernet.net</A></FONT=
></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0019_01C0EB6A.C9C89380--



From rickyp1@frontiernet.net  Sat Jun  2 19:54:18 2001
From: rickyp1@frontiernet.net (Ricky Parks)
Date: Sat, 2 Jun 2001 13:54:18 -0500
Subject: [Tutor] Please?
Message-ID: <003d01c0eb95$6e56a340$6601a8c0@Parks>

This is a multi-part message in MIME format.

------=_NextPart_000_003A_01C0EB6B.84C7F9A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am a beginner and I am unsubscribing to tuter because I am getting to =
many emails at once and none of them are helping me, could you posiblie =
try to teach personaly? I am realy eger to learn!
                                        Richard E Parks 2
                                        RickyP1@frontiernet.net


------=_NextPart_000_003A_01C0EB6B.84C7F9A0
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>I am a beginner and I am unsubscribing =
to tuter=20
because I am getting to many emails at once and none of them are helping =
me,=20
could you posiblie try to teach personaly? I am realy eger to=20
learn!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
Richard E Parks 2</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; <A=20
href=3D"mailto:RickyP1@frontiernet.net">RickyP1@frontiernet.net</A></FONT=
></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_003A_01C0EB6B.84C7F9A0--



From phil@xfr.co.uk  Sat Jun  2 20:24:11 2001
From: phil@xfr.co.uk (Philip Kilner)
Date: Sat, 02 Jun 2001 20:24:11 +0100
Subject: [Tutor] Unsubsciption
In-Reply-To: <001c01c0eb94$b3ab2980$6601a8c0@Parks>
References: <001c01c0eb94$b3ab2980$6601a8c0@Parks>
Message-ID: <VA.00000079.06d9bbb0@xfr.co.uk>

Ricky,

The unsubscribe info is in the header of every email!

In article <001c01c0eb94$b3ab2980$6601a8c0@Parks>, Ricky Parks wrote:
> List-Help: <mailto:tutor-request@python.org?subject=help>
> List-Post: <mailto:tutor@python.org>
> List-Subscribe: <http://mail.python.org/mailman/listinfo/tutor>,
>  <mailto:tutor-request@python.org?subject=subscribe>
> List-Id: Discussion for learning programming with Python <tutor.python.org>
> List-Unsubscribe: <http://mail.python.org/mailman/listinfo/tutor>,
>  <mailto:tutor-request@python.org?subject=unsubscribe>
> List-Archive: <http://mail.python.org/pipermail/tutor/>
>

You might be better staying on the list - you'll learn by watching others 
learn, and others will learn watching you learn. It's a community thing - 
it's also more efficient!

There are some v. Helpful people on this list, including authors of 
introductory Python books. It's worth sticking around.

HTH,

PhilK





From sarnold@earthling.net  Sat Jun  2 20:37:10 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Sat, 2 Jun 2001 12:37:10 -0700
Subject: [Tutor] Unsubsciption
In-Reply-To: <001c01c0eb94$b3ab2980$6601a8c0@Parks>
Message-ID: <20010602193710.EC3FF1F62A@shiva.arnolds.bogus>

On 2 Jun 01, at 13:49, Ricky Parks wrote:

> I thought this tuter thing would help me out, I am a beginner
> but instead I am getting alot of messages in my mail box that I
> dont want. Please give me the unsubscrition web address. You
> should add the unsubscrition address to off email sent. 

Tips:

1) keep the list option emails you receive when you sign up for a 
list.

2) use a better mailer (like Pegasus) with straight-forward 
filtering and other options to help you manage mail.

3) don't forget to turn off M$-richcrap-text or html mail (in your 
mailer settings) - the RFCs define internet email as ASCII text 
only.

4) stop whining and go here:

http://mail.python.org/mailman/listinfo/tutor


*************************************************************
Steve Arnold                            sarnold@earthling.net
                                       http://arnolds.dhs.org
Java is for staying up late while you program in Python...


From sarnold@earthling.net  Sat Jun  2 20:55:53 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Sat, 2 Jun 2001 12:55:53 -0700
Subject: [Tutor] Unsubsciption
In-Reply-To: <20010602193710.EC3FF1F62A@shiva.arnolds.bogus>
References: <001c01c0eb94$b3ab2980$6601a8c0@Parks>
Message-ID: <20010602195554.0AB7D1F62A@shiva.arnolds.bogus>

On 2 Jun 01, at 12:37, Stephen L Arnold wrote:

> 1) keep the list option emails you receive when you sign up for a 
> list.
> 
> 2) use a better mailer (like Pegasus) with straight-forward 
> filtering and other options to help you manage mail.
> 
> 3) don't forget to turn off M$-richcrap-text or html mail (in your 
> mailer settings) - the RFCs define internet email as ASCII text 
> only.
> 
> 4) stop whining and go here:
> 
> http://mail.python.org/mailman/listinfo/tutor

Sorry, I didn't intend that last one to sound mean (I've been 
dealing with a particularly recalcitrant 8 year old all morning).

However, the first three are still useful...

Steve

*************************************************************
Steve Arnold                           http://arnolds.dhs.org

"We've gotta protect our phony-balony jobs, gentlemen!"
  - Mel Brooks


From rickyp1@frontiernet.net  Sat Jun  2 20:57:06 2001
From: rickyp1@frontiernet.net (Ricky Parks)
Date: Sat, 2 Jun 2001 14:57:06 -0500
Subject: [Tutor] Ok
Message-ID: <003d01c0eb9e$341c3d80$6601a8c0@Parks>

This is a multi-part message in MIME format.

------=_NextPart_000_003A_01C0EB74.4A85F2C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

    Ok, I am going to stick with it, I will say this agian I am a =
beginer an know nothing about programming, so half the stuff that is =
sent I will not undersand! Thank you.
                                        Richard E Parks 2
                                        RickyP1@frontiernet.net
 =20

------=_NextPart_000_003A_01C0EB74.4A85F2C0
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>&nbsp;&nbsp;&nbsp; Ok, I am going to =
stick with it,=20
I will say this agian I am a beginer an know nothing about programming, =
so half=20
the stuff that&nbsp;is sent I will not undersand! Thank =
you.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
Richard E Parks 2</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; <A=20
href=3D"mailto:RickyP1@frontiernet.net">RickyP1@frontiernet.net</A></FONT=
></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; </FONT></DIV></BODY></HTML>

------=_NextPart_000_003A_01C0EB74.4A85F2C0--



From sarnold@earthling.net  Sat Jun  2 21:18:24 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Sat, 2 Jun 2001 13:18:24 -0700
Subject: [Tutor] Ok - here're some resources
In-Reply-To: <003d01c0eb9e$341c3d80$6601a8c0@Parks>
Message-ID: <20010602201825.3E5121F62A@shiva.arnolds.bogus>

On 2 Jun 01, at 14:57, Ricky Parks wrote:

> Ok, I am going to stick with it, I will say this agian I am a
> beginer an know nothing about programming, so half the stuff that
> is sent I will not undersand! Thank you. 

If you're really starting from scratch, then Python is definitely 
the language to start with (then later you could check out Ada :)  
Try the Non-Programmers Tutorial For Python:

http://www.honors.montana.edu/~jjc/easytut/easytut/easytut.html

How to think like a computer scientist:

http://www.ibiblio.org/obp/thinkCSpy/

Learning to program:

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

(this guy is also on the Tutor list)

There's also the regular Python Tutorial:

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

A Python Short Course:

http://www.wag.caltech.edu/home/rpm/python_course/

The What, Why, Who, and Where of Python:

http://www.networkcomputing.com/unixworld/tutorial/005/005.html

Programming Resources:

http://www.cyberramp.net/~fdavid/programming.html

and last but not least, John English's Brighton University Resource 
Kit for Students of computer science (BURKS - its's both a website 
and a set of inexpensive CD-ROMs).  Highly recommended:

http://burks.brighton.ac.uk/

That ought to keep you busy for a while ;-)

Steve

-- 
Think of the Linux community as a niche economy isolated by its beliefs.  
Kind of like the Amish, except that our religion requires us to use 
_higher_ technology than everyone else.
            -- Donald B. Marti Jr.


From r.b.rigilink@chello.nl  Sat Jun  2 21:33:00 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Sat, 02 Jun 2001 22:33:00 +0200
Subject: [Tutor] Ok
References: <003d01c0eb9e$341c3d80$6601a8c0@Parks>
Message-ID: <3B194D7C.F2936AED@chello.nl>

> Ricky Parks wrote:
> 
>     Ok, I am going to stick with it, I will say this agian I am a
> beginer an know nothing about programming, so half the stuff that is
> sent I will not undersand! Thank you.
>                                         Richard E Parks 2
>                                         RickyP1@frontiernet.net
> 

Hi Ricky,

Glad you decided to stick with it.

If you run into anything specific you'd like to get help with I hope
you'll feel confident enough to send your questions to the list. In that
way others will benefit from our answers. 

If you feel more comfortable with that, I for one don't mind if you send
questions privately.

Don't worry to much about the stuff that seems way over your head now
(we do get carried away sometimes) I think you'll find that things will
be much more comprehensible in a few months. Also, don't worry about
asking for explanations.

Have fun,

Roeland Rengelink
-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From sak@nwlink.com  Sat Jun  2 18:38:42 2001
From: sak@nwlink.com (Sak)
Date: Sat, 2 Jun 2001 13:38:42 -0400
Subject: [Tutor] Ok
In-Reply-To: <003d01c0eb9e$341c3d80$6601a8c0@Parks>
References: <003d01c0eb9e$341c3d80$6601a8c0@Parks>
Message-ID: <01060213384200.02128@ci>

On Saturday 02 June 2001 15:57, Ricky Parks wrote:
>     Ok, I am going to stick with it, I will say this agian I am a beginer
> an know nothing about programming, so half the stuff that is sent I will
> not undersand! Thank you. Richard E Parks 2
>                                         RickyP1@frontiernet.net

I can relate Ricky, and I was just thinking about this earlier this morning.  
I subscribed to this list a couple days ago, with equal fear that I wouldn't 
understand what the heck was going on.  But then I remembered that no 
knowledge comes as easy as we would like it to.

My goal is to work through my Learning Python book (O'Reilly) the tutorial 
from Python.org, and continue reading the posts to this list.  Eventually, 
it'll make sense.  I just think what we complete newbies are feeling is akin 
to culture-shock.  After we immerse ourselves in the stuff for a while it'll 
make more sense; and that will be a great sense of accomplishment.

Thanks,
-- 
Sak.


From rob@jam.rr.com  Sat Jun  2 22:02:34 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sat, 02 Jun 2001 16:02:34 -0500
Subject: [Tutor] Ok
References: <003d01c0eb9e$341c3d80$6601a8c0@Parks>
Message-ID: <3B19546A.A98FA32@jam.rr.com>

> Ricky Parks wrote:
> 
>     Ok, I am going to stick with it, I will say this agian I am a
> beginer an know nothing about programming, so half the stuff that is
> sent I will not undersand! Thank you.
>                                         Richard E Parks 2
>                                         RickyP1@frontiernet.net
> 

Even if learning sometimes takes time (certainly in my case), it's at
least always good to be exposed to really decent people. We have plenty
of 'em on this list.

my $.02 worth,
Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From Tutor@python.org  Sat Jun  2 22:19:16 2001
From: Tutor@python.org (Tim Peters)
Date: Sat, 2 Jun 2001 17:19:16 -0400
Subject: [Tutor] Ok
In-Reply-To: <3B19546A.A98FA32@jam.rr.com>
Message-ID: <LNBBLJKPBEHFEDALKOLCIECDKGAA.tim.one@home.com>

[Ricky Parks]
>     Ok, I am going to stick with it, I will say this agian I am a
> beginer an know nothing about programming, so half the stuff that is
> sent I will not undersand! Thank you.

If you only see stuff you already understand, how would you learn?  I've
been programming for decades, and I don't understand half of what I see
either:  it's a very big world out there <wink>.

Questions at all levels are welcome here.  So if the list goes through a
period where everything seems over your head, feel free to start new topics
on things *you're* wondering about!  The biggest problem beginners have is
not that they ask "stupid questions", but that too many are nervous about
asking any questions at all.  Programming is a lot of fun, but there's a lot
to learn too.



From budgester@budgester.com  Sat Jun  2 22:54:39 2001
From: budgester@budgester.com (Martin Stevens)
Date: Sat, 2 Jun 2001 22:54:39 +0100
Subject: [Tutor] Mailing List.
Message-ID: <20010602225439.A17781@budgester.com>

Hi,

Probably should be mailing the admins directly but,

We use the Mailman software for this list ?

On another list I belong to they have set the Reply-to 
address as the list address, is there a reason we don't
do this ?

I'm sure it would make things easier, when replying to queries

BTW I'm using Mutt on Debian, so there maybe a way of replying
to the list automatically.

Thanks

Martin Stevens a.k.a. Budgester
http://www.budgester.com

P.S. To all the newbies, keep at it, and have a look at the 
useless python site, there is some of my code on it  
that is really simple.

Rob, just an idea how about giving the scripts a grade of
simple to complex ?


From rick@niof.net  Sat Jun  2 22:43:07 2001
From: rick@niof.net (Rick Pasotto)
Date: Sat, 2 Jun 2001 17:43:07 -0400
Subject: [Tutor] Mailing List.
In-Reply-To: <20010602225439.A17781@budgester.com>; from budgester@budgester.com on Sat, Jun 02, 2001 at 10:54:39PM +0100
References: <20010602225439.A17781@budgester.com>
Message-ID: <20010602174307.A2841@tc.niof.net>

On Sat, Jun 02, 2001 at 10:54:39PM +0100, Martin Stevens wrote:
> 
> BTW I'm using Mutt on Debian, so there maybe a way of replying
> to the list automatically.

Put in your .muttrc

subscribe tutor

and then when you want to reply press 'L' (that's capital-L)
for List-reply.

-- 
If man were perfect, if he were infallible, society would present
a very different kind of harmony from that which we may actually
expect it to offer us. Our idea of harmony is not Fourier's. It
does not exclude the existence of evil; it leaves room for
discord; and yet we shall recognize that harmony nonetheless
exists, provided that discord serves to prepare the way and to
lead us back to harmony.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From rickyp1@frontiernet.net  Sat Jun  2 22:50:37 2001
From: rickyp1@frontiernet.net (Ricky Parks)
Date: Sat, 2 Jun 2001 16:50:37 -0500
Subject: [Tutor] Prompt
Message-ID: <003401c0ebae$0fd618a0$6601a8c0@Parks>

This is a multi-part message in MIME format.

------=_NextPart_000_0031_01C0EB84.26615FA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thank you all for the suport. My bigest problem right now is getiing the =
software to run. I downloaded python 2.0 Windows Installer from the =
python.org web site. I am still having a problem  with the prompt screen =
closing too fast I can even read what is says! =20

------=_NextPart_000_0031_01C0EB84.26615FA0
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>Thank you all for the suport. My bigest =
problem=20
right now is getiing the software to run.&nbsp;I downloaded python 2.0=20
Windows&nbsp;Installer from the python.org web site. I am still having a =

problem&nbsp;&nbsp;with the prompt screen closing too fast I can =
even&nbsp;read=20
what is says!&nbsp; </FONT></DIV></BODY></HTML>

------=_NextPart_000_0031_01C0EB84.26615FA0--



From bdupire@seatech.fau.edu  Sat Jun  2 23:10:47 2001
From: bdupire@seatech.fau.edu (Benoit Dupire)
Date: Sat, 02 Jun 2001 18:10:47 -0400
Subject: [Tutor] Prompt
References: <003401c0ebae$0fd618a0$6601a8c0@Parks>
Message-ID: <3B196467.D2A98C5A@seatech.fau.edu>

--------------A213E01662C4705C0DE07A03
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I think we need some more indications to answer your question.....
What are you trying to do to get a prompt screen in Windows ?

if you have installed python 2.0 on Windows, you should have in Start >
Programs> Python 2.0    the  following icons:
* IDLE (GUI)
* Command line
* Python manuals
* Uninstall Python


if you click on the first one, a windows pops up, where you can enter
Python commands interactively.
If you click on the second one, a MS DOS command windows pops up, where
you can enter Python commands interactively too.
But it's not closing when you enter a command, such as 3+5.

What have you done so far ?


Ricky Parks wrote:

> Thank you all for the suport. My bigest problem right now is getiing
> the software to run. I downloaded python 2.0 Windows Installer from
> the python.org web site. I am still having a problem  with the prompt
> screen closing too fast I can even read what is says!

--
Benoit Dupire


--------------A213E01662C4705C0DE07A03
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
I think we need some more indications to answer your question.....
<br>What are you trying to do to get a prompt screen in Windows ?
<p>if you have installed python 2.0 on Windows, you should have in Start
>&nbsp; Programs> Python 2.0&nbsp;&nbsp;&nbsp; the&nbsp; following icons:
<br>* IDLE (GUI)
<br>* Command line
<br>* Python manuals
<br>* Uninstall Python
<br>&nbsp;
<p>if you click on the first one, a windows pops up, where you can enter
Python commands interactively.
<br>If you click on the second one, a MS DOS command windows pops up, where
you can enter Python commands interactively too.
<br>But it's not closing when you enter a command, such as 3+5.
<p>What have you done so far ?
<br>&nbsp;
<p>Ricky Parks wrote:
<blockquote TYPE=CITE><style></style>
<font face="Arial"><font size=-1>Thank
you all for the suport. My bigest problem right now is getiing the software
to run. I downloaded python 2.0 Windows Installer from the python.org web
site. I am still having a problem&nbsp; with the prompt screen closing
too fast I can even read what is says!</font></font></blockquote>

<p>--
<br>Benoit Dupire
<br>&nbsp;
</body>
</html>

--------------A213E01662C4705C0DE07A03--



From bdupire@seatech.fau.edu  Sat Jun  2 23:22:31 2001
From: bdupire@seatech.fau.edu (Benoit Dupire)
Date: Sat, 02 Jun 2001 18:22:31 -0400
Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ?
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D7EC@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <3B196727.7C4FA55D@seatech.fau.edu>

alan.gauld@bt.com wrote:

> > If one does not exist I would be willing to contribute my
> > time.
>
> You said the magic words.
> Feel free, I'm pretty sure there iusn't a tutor-faq yet
> and yes we do get a lot of duplication. Just nobody
> else has time...
>
> So I say go for it.
>
> Alan G.

yep.. i began to do such a faq !!!! (but i am late at reading the tutor
list!)
my first idea was to sumarize the most common  threads..
and the best answers

but I quickly stopped, because i found that
http://python.faqts.com
looks a lot  like what i was looking for......

the first draft (quite basic) of what i did is at
http://www.oe.fau.edu/~bdupire/python/index.html

but i figured out i wouldn't have enough time....


All suggestions are welcome...
Alan, you can of course use what i did if you want....




>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

--
Benoit Dupire




From sarnold@earthling.net  Sat Jun  2 23:25:37 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Sat, 2 Jun 2001 15:25:37 -0700
Subject: [Tutor] Prompt
In-Reply-To: <003401c0ebae$0fd618a0$6601a8c0@Parks>
Message-ID: <20010602222538.4E8F11F62A@shiva.arnolds.bogus>

On 2 Jun 01, at 16:50, Ricky Parks wrote:

> Thank you all for the suport. My bigest problem right now is
> getiing the software to run. I downloaded python 2.0 Windows
> Installer from the python.org web site. I am still having a
> problem  with the prompt screen closing too fast I can even read
> what is says!  

Are you calling a script from the Start|Run menu, from a DOS box, 
or IDLE?  I'm not sure I can visualize what you're doing.  If the 
pythonwin interface is dying right away, then there's a problem.  
You might have a corrupted installation, dll problems, etc.  You 
could try the old un-installing/re-installing trick...

You might want to try the ActiveState Python distribution for 
win32.  Check out:

http://aspn.activestate.com/ASPN/Downloads/ActivePython/

for nice windoze installers for both Python 2.0 and 2.1 (and their 
Komodo IDE is pretty cool, but it needs some horsepower to run 
well).

Steve

************************************************
Steve Arnold  CLE (Certifiable Linux Evangelist)

http://arnolds.dhs.org


From budgester@budgester.com  Sat Jun  2 23:54:05 2001
From: budgester@budgester.com (Martin Stevens)
Date: Sat, 2 Jun 2001 23:54:05 +0100
Subject: [Tutor] Mailing List.
In-Reply-To: <20010602174307.A2841@tc.niof.net>; from rick@niof.net on Sat, Jun 02, 2001 at 05:43:07PM -0400
References: <20010602225439.A17781@budgester.com> <20010602174307.A2841@tc.niof.net>
Message-ID: <20010602235405.A18003@budgester.com>

On Sat, Jun 02, 2001 at 05:43:07PM -0400, Rick Pasotto wrote:
> On Sat, Jun 02, 2001 at 10:54:39PM +0100, Martin Stevens wrote:
> > 
> > BTW I'm using Mutt on Debian, so there maybe a way of replying
> > to the list automatically.
> 
> Put in your .muttrc
> 
> subscribe tutor
> 
> and then when you want to reply press 'L' (that's capital-L)
> for List-reply.
> 
That did the trick thanks !




From budgester@budgester.com  Sun Jun  3 00:18:03 2001
From: budgester@budgester.com (Martin Stevens)
Date: Sun, 3 Jun 2001 00:18:03 +0100
Subject: [Tutor] Newbie Project
Message-ID: <20010603001803.A18034@budgester.com>

Hi all,

Okay I've had an idea and they are fairly rare !

A little while ago I was writing a python program
to update my diary entries on my website.

I'd got it 95% complete when my hard drive went down
and me with no backups (D'oh).

Whilst working on this project I learnt a bit about 
python and found it quite a good project to learn on.

So when a few of the people on the list said they are new
to programming I thought about this project.

Now comes the idea, what i have done is put a bit of psuedo
code on my website that people learning python can contribute
to without getting overwhelmed by masses of code.

So anybody (even if you've just started) should be able to
contribute, but what I don't want to happen is the really good
people just pick it up and complete it in 2 hours :-) so how about
the Guru people adding to the Ideas section or adding a bit more
pseudo code to it so there are extra little challenges ?

Hopefully I'm not wasting peoples time with this. let me know 
what you think.

Thanks

Martin Stevens.

BTW here's the URL http://www.budgester.com/diaryupdate.htm


From rickyp1@frontiernet.net  Sun Jun  3 00:16:49 2001
From: rickyp1@frontiernet.net (Ricky Parks)
Date: Sat, 2 Jun 2001 18:16:49 -0500
Subject: [Tutor] Prompt 2
Message-ID: <002001c0ebba$1a4be600$6601a8c0@Parks>

This is a multi-part message in MIME format.

------=_NextPart_000_001D_01C0EB90.30DECE20
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

    OK, I am going to tell you step by step what I do.I write an small =
program in a text editor, save it, there is a problem with my computer =
that make me have to associate these kinds of files every time I load it =
so I associate it with the Python (command line) and run it. That is =
when the prompt screen opens and then closes so fast that I can not read =
what is says. Could that have some thing to do with my properties =
setting? Python is so confusing to run compared to Qbasic, which I have =
been using.
                                        Richard E. Parks 2  =20

------=_NextPart_000_001D_01C0EB90.30DECE20
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>&nbsp;&nbsp;&nbsp; OK, I am going to =
tell you step=20
by step what I do.I write an small program in a text editor, save it, =
there is a=20
problem with my computer that make me have to&nbsp;associate these kinds =
of=20
files every time I load it so I associate it with the Python (command =
line) and=20
run it.&nbsp;That is when the prompt screen opens and then closes so =
fast that I=20
can not read what is says. Could that have some thing to do with my =
properties=20
setting? Python is so confusing to run compared to Qbasic, which I have =
been=20
using.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
Richard E. Parks 2&nbsp;&nbsp; </FONT></DIV></BODY></HTML>

------=_NextPart_000_001D_01C0EB90.30DECE20--



From tescoil@irtc.net  Sun Jun  3 00:19:29 2001
From: tescoil@irtc.net (Tesla Coil)
Date: Sat, 02 Jun 2001 18:19:29 -0500
Subject: [Tutor] Prompt
References: <003401c0ebae$0fd618a0$6601a8c0@Parks>
Message-ID: <3B197481.CE8930C1@irtc.net>

On 2 June 2001, Ricky Parks wrote:
> I downloaded python 2.0 Windows Installer from the
> python.org web site. I am still having a problem
> with the prompt screen closing too fast I can even
> read what is says!  

This would qualify for a Tutor FAQ, although I think
it's been a few months since it was last asked:

See:
http://mail.python.org/pipermail/tutor/2001-January/003073.html
and:
http://mail.python.org/pipermail/tutor/2001-January/003139.html



From cynic@mail.cz  Sun Jun  3 00:17:33 2001
From: cynic@mail.cz (cynic@mail.cz)
Date: Sat, 2 Jun 2001 19:17:33 -0400
Subject: [Tutor] Newbie Project
Message-ID: <200106021917610.SM00784@m2w059>

what is the reasoning behing the idea of downloading the current webpage and 
modifying it instead of interaction with a RDBMS or a flat file? Looks like the path suggested by you would require sort =
of an XML parser.

Original Message:
-----------------
From: Martin Stevens budgester@budgester.com
Date: Sun, 3 Jun 2001 00:18:03 +0100
To: tutor@python.org
Subject: [Tutor] Newbie Project


Hi all,

Okay I've had an idea and they are fairly rare !

A little while ago I was writing a python program
to update my diary entries on my website.

I'd got it 95% complete when my hard drive went down
and me with no backups (D'oh).

Whilst working on this project I learnt a bit about 
python and found it quite a good project to learn on.

So when a few of the people on the list said they are new
to programming I thought about this project.

Now comes the idea, what i have done is put a bit of psuedo
code on my website that people learning python can contribute
to without getting overwhelmed by masses of code.

So anybody (even if you've just started) should be able to
contribute, but what I don't want to happen is the really good
people just pick it up and complete it in 2 hours :-) so how about
the Guru people adding to the Ideas section or adding a bit more
pseudo code to it so there are extra little challenges ?

Hopefully I'm not wasting peoples time with this. let me know 
what you think.

Thanks

Martin Stevens.

BTW here's the URL http://www.budgester.com/diaryupdate.htm

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

--------------------------------------------------------------------
Mail2Web - Check your email from the web at
http://www.mail2web.com/ .



From budgester@budgester.com  Sun Jun  3 00:59:42 2001
From: budgester@budgester.com (Martin Stevens)
Date: Sun, 3 Jun 2001 00:59:42 +0100
Subject: [Tutor] Newbie Project
In-Reply-To: <200106021917610.SM00784@m2w059>; from cynic@mail.cz on Sat, Jun 02, 2001 at 07:17:33PM -0400
References: <200106021917610.SM00784@m2w059>
Message-ID: <20010603005942.A18119@budgester.com>

On Sat, Jun 02, 2001 at 07:17:33PM -0400, cynic@mail.cz wrote:
> what is the reasoning behing the idea of downloading the current webpage and 
> modifying it instead of interaction with a RDBMS or a flat file? Looks like the path suggested by you would require sort of an XML parser.
> 

Ok, the way I had it working before was something along these lines.

The .htm file is basically a text file and I had a mark in it, 
the .htm file was read in with readline(s) and the mark was replaced
with the new update and a new mark, then reuploaded, this was due to
not having any cgi availability on the web server, so while I was 
downloading my e-mail I could run the program and update the diary.

The mark would be something like <!-- Mark --> i.e. a html comment
that a browser would ignore.

The reason for using python was so that I could run it at work on
a windows machine, and at home on Linux, so it had to be cross 
platform and the only place that I could guarantee had the most
recent version of my diary was the actual web page itself.

As for XML, I don't really know a great deal about it, I suppose
i should really look into it, but this solution worked fine for
my purposes and I thought it might be of use to other people.
(I also hate web based forms ;-)



From gman_95@hotmail.com  Sun Jun  3 00:52:15 2001
From: gman_95@hotmail.com (Daryl G)
Date: Sat, 02 Jun 2001 23:52:15 -0000
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <F30BEzJvlZGdOZofu450000d210@hotmail.com>

Hi,  I am having difficulty in saving and loading data that I created in a 
simple Address book program. I  am using 3 list variables for First and Last 
name and phone number and an interger that counts the total number of 
entries.  I first tried using the 'write' but that wouldn't work with lists. 
I discovered the pickle module and
I am able to save my data, but when I load it back up and then try to view 
it in my program, its not there.

variables
import pickle, string

F_Name=[]
L_Name=[]
PH_num=[]
total=0

#savedata method
def savedata():
    filename= raw_input("Enter the name you wish to give this address book: 
")
    object=(F_Name, L_Name, PH_num, total)
    file=open(filename, 'w')
    pickle.dump(object, file)

#opendata method
def opendata():
    filename=raw_input("Enter the name of the Addressbook you wish to open: 
")
    file = open(filename,'r')
    (F_Name,L_Name, PH_num, total)=pickle.load(file)


What am I doing wrong?
Another question that I have is how do I format data that I want to display 
in specific
columns in standerd output, like that can be done in C ?
Thanks
Daryl
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From cynic@mail.cz  Sun Jun  3 01:36:09 2001
From: cynic@mail.cz (cynic@mail.cz)
Date: Sat, 2 Jun 2001 20:36:09 -0400
Subject: [Tutor] Newbie Project
Message-ID: <200106022036909.SM00692@m2w033>

ok, that sounds reasonable. as long as you don't need to update anything previously inserted, I guess. but that wasn't th=
e goal, right?



Original Message:
-----------------
From: Martin Stevens budgester@budgester.com
Date: Sun, 3 Jun 2001 00:59:42 +0100
To: tutor@python.org
Subject: Re: [Tutor] Newbie Project


On Sat, Jun 02, 2001 at 07:17:33PM -0400, cynic@mail.cz wrote:
> what is the reasoning behing the idea of downloading the current webpage and 
> modifying it instead of interaction with a RDBMS or a flat file? Looks like the path suggested by you would require sor=
t of an XML parser.
> 

Ok, the way I had it working before was something along these lines.

The .htm file is basically a text file and I had a mark in it, 
the .htm file was read in with readline(s) and the mark was replaced
with the new update and a new mark, then reuploaded, this was due to
not having any cgi availability on the web server, so while I was 
downloading my e-mail I could run the program and update the diary.

The mark would be something like <!-- Mark --> i.e. a html comment
that a browser would ignore.

The reason for using python was so that I could run it at work on
a windows machine, and at home on Linux, so it had to be cross 
platform and the only place that I could guarantee had the most
recent version of my diary was the actual web page itself.

As for XML, I don't really know a great deal about it, I suppose
i should really look into it, but this solution worked fine for
my purposes and I thought it might be of use to other people.
(I also hate web based forms ;-)


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

--------------------------------------------------------------------
Mail2Web - Check your email from the web at
http://www.mail2web.com/ .



From deirdre@deirdre.net  Sun Jun  3 01:36:46 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Sat, 2 Jun 2001 17:36:46 -0700
Subject: [Tutor] Mailing List.
In-Reply-To: <20010602225439.A17781@budgester.com>
References: <20010602225439.A17781@budgester.com>
Message-ID: <a05100e00b73f35ade70b@[10.0.1.8]>

>On another list I belong to they have set the Reply-to
>address as the list address, is there a reason we don't
>do this ?

Yes -- because it's a bad idea.

http://www.unicom.com/pw/reply-to-harmful.html

http://marc.merlins.org/perso/listreplyto.txt

-- 
_Deirdre     Stash-o-Matic: http://weirdre.com      http://deirdre.net
Macintosh Developer (seeking work): Will work for Cocoa
"I love deadlines. I like the whooshing sound they make as they fly by."
                                                          - Douglas Adams


From budgester@budgester.com  Sun Jun  3 02:07:14 2001
From: budgester@budgester.com (Martin Stevens)
Date: Sun, 3 Jun 2001 02:07:14 +0100
Subject: [Tutor] Mailing List.
In-Reply-To: <a05100e00b73f35ade70b@[10.0.1.8]>; from deirdre@deirdre.net on Sat, Jun 02, 2001 at 05:36:46PM -0700
References: <20010602225439.A17781@budgester.com> <a05100e00b73f35ade70b@[10.0.1.8]>
Message-ID: <20010603020714.A18507@budgester.com>

On Sat, Jun 02, 2001 at 05:36:46PM -0700, Deirdre Saoirse Moen wrote:
> >On another list I belong to they have set the Reply-to
> >address as the list address, is there a reason we don't
> >do this ?
> 
> Yes -- because it's a bad idea.
> 
> http://www.unicom.com/pw/reply-to-harmful.html
> 
> http://marc.merlins.org/perso/listreplyto.txt
> 
Ooops, Ok read that, and I'll go back and hide under my rock again :-)

Found the group reply option in mutt now.



From budgester@budgester.com  Sun Jun  3 02:12:36 2001
From: budgester@budgester.com (Martin Stevens)
Date: Sun, 3 Jun 2001 02:12:36 +0100
Subject: [Tutor] Newbie Project
In-Reply-To: <200106022036909.SM00692@m2w033>; from cynic@mail.cz on Sat, Jun 02, 2001 at 08:36:09PM -0400
References: <200106022036909.SM00692@m2w033>
Message-ID: <20010603021236.B18507@budgester.com>

On Sat, Jun 02, 2001 at 08:36:09PM -0400, cynic@mail.cz wrote:
> ok, that sounds reasonable. as long as you don't need to update anything previously inserted, I guess. but that wasn't the goal, right?
> 
You've got it, probably didn't explain it right in the code, I'll add a bit
on the webpage.

BTW what do you think of the actual idea of helping newbies collaborate
on a basic project like this in pricipal ? If there are other small projects
like this that people think of I'd be happy to host them as something like 
sourceforge always seems a bit intimidating, then when they are
completed/working we could transfer them over to robs useless python
site. 



From cynic@mail.cz  Sun Jun  3 02:00:47 2001
From: cynic@mail.cz (cynic@mail.cz)
Date: Sat, 2 Jun 2001 21:00:47 -0400
Subject: [Tutor] Prompt 2
Message-ID: <200106022100369.SM00824@m2w060>

I haven't read the previous thread, but this looks like it's not a prompt, but a console window. I suggest you start a co=
nsole _prior to_ starting the program (i. e. run command.com and type e. g. C:\>path\to\your\app>myapp.py), or create a b=
atch for it, and make sure the "close when finished" (I don't know the exact english desc., and the only win9x sytem I ha=
ve at reach is localized) checkbox is unchecked.


Original Message:
-----------------
From: Ricky Parks rickyp1@frontiernet.net
Date: Sat, 2 Jun 2001 18:16:49 -0500
To: Tutor@python.org
Subject: [Tutor] Prompt 2


    OK, I am going to tell you step by step what I do.I write an small program in a text editor, save it, there is a prob=
lem with my computer that make me have to associate these kinds of files every time I load it so I associate it with the =
Python (command line) and run it. That is when the prompt screen opens and then closes so fast that I can not read what i=
s says. Could that have some thing to do with my properties setting? Python is so confusing to run compared to Qbasic, wh=
ich I have been using.
                                        Richard E. Parks 2   

--------------------------------------------------------------------
Mail2Web - Check your email from the web at
http://www.mail2web.com/ .



From cynic@mail.cz  Sun Jun  3 02:03:44 2001
From: cynic@mail.cz (cynic@mail.cz)
Date: Sat, 2 Jun 2001 21:03:44 -0400
Subject: [Tutor] Newbie Project
Message-ID: <200106022103123.SM00776@m2w049>

I think it's a neat idea. After all, everybody's newcomer in some field through the whole life. And Python is probably th=
e best language to learn programming around.

Original Message:
-----------------
From: Martin Stevens budgester@budgester.com
Date: Sun, 3 Jun 2001 02:12:36 +0100
To: cynic@mail.cz, tutor@python.org
Subject: Re: Re: [Tutor] Newbie Project


On Sat, Jun 02, 2001 at 08:36:09PM -0400, cynic@mail.cz wrote:
> ok, that sounds reasonable. as long as you don't need to update anything previously inserted, I guess. but that wasn't =
the goal, right?
> 
You've got it, probably didn't explain it right in the code, I'll add a bit
on the webpage.

BTW what do you think of the actual idea of helping newbies collaborate
on a basic project like this in pricipal ? If there are other small projects
like this that people think of I'd be happy to host them as something like 
sourceforge always seems a bit intimidating, then when they are
completed/working we could transfer them over to robs useless python
site. 

--------------------------------------------------------------------
Mail2Web - Check your email from the web at
http://www.mail2web.com/ .



From cynic@mail.cz  Sun Jun  3 02:11:25 2001
From: cynic@mail.cz (cynic@mail.cz)
Date: Sat, 2 Jun 2001 21:11:25 -0400
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <20010602211163.SM00804@m2w061>

Hi there,

I'm not very familiar with Python, but IIRC pickle is meant for serializing data, which is not the same as general persis=
tance using files, databases and alike. I'd suggest you use a csv file to save your addresses, read the file a line at a =
time, and split it into your variables. the file would look st. like this:

XXXXXXXXX start of file XXXXXXXXXXX
Doe;Joe;123456
Black;Tom;987654
Clinton;Bill;111222
XXXXXXXXX end of file XXXXXXXXXXX


Original Message:
-----------------
From: Daryl G gman_95@hotmail.com
Date: Sat, 02 Jun 2001 23:52:15 -0000
To: tutor@python.org
Subject: [Tutor] Saving and loading data to/from files


Hi,  I am having difficulty in saving and loading data that I created in a 
simple Address book program. I  am using 3 list variables for First and Last 
name and phone number and an interger that counts the total number of 
entries.  I first tried using the 'write' but that wouldn't work with lists. 
I discovered the pickle module and
I am able to save my data, but when I load it back up and then try to view 
it in my program, its not there.

variables
import pickle, string

F_Name=3D[]
L_Name=3D[]
PH_num=3D[]
total=3D0

#savedata method
def savedata():
    filename=3D raw_input("Enter the name you wish to give this address book: 
")
    object=3D(F_Name, L_Name, PH_num, total)
    file=3Dopen(filename, 'w')
    pickle.dump(object, file)

#opendata method
def opendata():
    filename=3Draw_input("Enter the name of the Addressbook you wish to open: 
")
    file =3D open(filename,'r')
    (F_Name,L_Name, PH_num, total)=3Dpickle.load(file)


What am I doing wrong?
Another question that I have is how do I format data that I want to display 
in specific
columns in standerd output, like that can be done in C ?
Thanks
Daryl
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

--------------------------------------------------------------------
Mail2Web - Check your email from the web at
http://www.mail2web.com/ .



From sarnold@earthling.net  Sun Jun  3 02:12:37 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Sat, 2 Jun 2001 18:12:37 -0700
Subject: [Tutor] Prompt 2
In-Reply-To: <002001c0ebba$1a4be600$6601a8c0@Parks>
Message-ID: <20010603011238.2500A1F62A@shiva.arnolds.bogus>

On 2 Jun 01, at 18:16, Ricky Parks wrote:

> Python is so confusing to run compared to Qbasic, which I
> have been using.

Have you guys tried running things from within PythonWin or Komodo 
initially?  At least until it's working to your satisfaction (then 
you can call it with pythonw.exe).  You should be able to run some 
things inter-actively, as well as run script files directly.  Of 
course, I'm using the ActiveState Python 2.0 build 203, but it 
works for me.

Steve

*************************************************************
Steve Arnold                           http://arnolds.dhs.org

Things go better with Linux and King Crimson.


From dyoo@hkn.eecs.berkeley.edu  Sun Jun  3 02:33:35 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 2 Jun 2001 18:33:35 -0700 (PDT)
Subject: [Tutor] Ok
In-Reply-To: <LNBBLJKPBEHFEDALKOLCIECDKGAA.tim.one@home.com>
Message-ID: <Pine.LNX.4.21.0106021832250.4476-100000@hkn.eecs.berkeley.edu>

On Sat, 2 Jun 2001, Tim Peters wrote:

> [Ricky Parks]
> >     Ok, I am going to stick with it, I will say this agian I am a
> > beginer an know nothing about programming, so half the stuff that is
> > sent I will not undersand! Thank you.
> 
> If you only see stuff you already understand, how would you learn?  I've
> been programming for decades, and I don't understand half of what I see
> either:  it's a very big world out there <wink>.
> 
> Questions at all levels are welcome here.  So if the list goes through
> a period where everything seems over your head, feel free to start new
> topics on things *you're* wondering about!  The biggest problem

And stop us when we start sounding really incomprehensible!  That probably
means that we're not doing a good job in explaining things.

Good luck to you.




From gman_95@hotmail.com  Sun Jun  3 02:47:32 2001
From: gman_95@hotmail.com (Daryl G)
Date: Sun, 03 Jun 2001 01:47:32 -0000
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <F91YZTa0RkjTC17OEjl0000b9f0@hotmail.com>

Hi,
Unfortunatly, I don't know what a csv file is -sorry. I have tried the one 
line at a time approach, but from I could tell python wouldn't allow this 
wiht the list type. At least not with the file.write() .
It  would give an error with list variable. It said it was a read only 
character buffer. The write method only works with primitive types; not 
lists, tuples, or dictionarys.
I have, however, discovered that it is infact reading in the data from a 
file when I am using the pickle method. I verified this by adding a print 
statement in my opendata method and it showed that it had read in the data. 
The problem appears to be in my function that displays the information. I 
can't figure out why it doesn't work
Thanks.

#listdata method to display contents of Address book
#will display info if just added, but will not display info if just
#loaded from a file

def listdata():
   i=0
   total=len(L_Name)
   print total
   print "Names and phone numbers in database so far"
   print
   print """Last Name       First Name      PH#"""

   for i in range(total):
       print L_Name[i],
       print "         ",F_Name[i],
       print "\t\t",PH_num[i]

>From: "cynic@mail.cz" <cynic@mail.cz>
>Reply-To: cynic@mail.cz
>To: "gman_95@hotmail.com" <gman_95@hotmail.com>, "tutor@python.org" 
><tutor@python.org>
>Subject: RE: [Tutor] Saving and loading data to/from files
>Date: Sat, 2 Jun 2001 21:11:25 -0400
>
>Hi there,
>
>I'm not very familiar with Python, but IIRC pickle is meant for serializing 
>data, which is not the same as general persistance using files, databases 
>and alike. I'd suggest you use a csv file to save your addresses, read the 
>file a line at a time, and split it into your variables. the file would 
>look st. like this:
>
>XXXXXXXXX start of file XXXXXXXXXXX
>Doe;Joe;123456
>Black;Tom;987654
>Clinton;Bill;111222
>XXXXXXXXX end of file XXXXXXXXXXX
>
>
>Original Message:
>-----------------
>From: Daryl G gman_95@hotmail.com
>Date: Sat, 02 Jun 2001 23:52:15 -0000
>To: tutor@python.org
>Subject: [Tutor] Saving and loading data to/from files
>
>
>Hi,  I am having difficulty in saving and loading data that I created in a
>simple Address book program. I  am using 3 list variables for First and 
>Last
>name and phone number and an interger that counts the total number of
>entries.  I first tried using the 'write' but that wouldn't work with 
>lists.
>I discovered the pickle module and
>I am able to save my data, but when I load it back up and then try to view
>it in my program, its not there.
>
>variables
>import pickle, string
>
>F_Name=[]
>L_Name=[]
>PH_num=[]
>total=0
>
>#savedata method
>def savedata():
>     filename= raw_input("Enter the name you wish to give this address 
>book:
>")
>     object=(F_Name, L_Name, PH_num, total)
>     file=open(filename, 'w')
>     pickle.dump(object, file)
>
>#opendata method
>def opendata():
>     filename=raw_input("Enter the name of the Addressbook you wish to 
>open:
>")
>     file = open(filename,'r')
>     (F_Name,L_Name, PH_num, total)=pickle.load(file)
>
>
>What am I doing wrong?
>Another question that I have is how do I format data that I want to display
>in specific
>columns in standerd output, like that can be done in C ?
>Thanks
>Daryl
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>--------------------------------------------------------------------
>Mail2Web - Check your email from the web at
>http://www.mail2web.com/ .
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From rear@sirius.com  Sun Jun  3 03:05:53 2001
From: rear@sirius.com (Bob Rea)
Date: Sat, 2 Jun 2001 19:05:53 -0700
Subject: [Tutor] Ok
In-Reply-To: <Pine.LNX.4.21.0106021832250.4476-100000@hkn.eecs.berkeley.edu>
References: <Pine.LNX.4.21.0106021832250.4476-100000@hkn.eecs.berkeley.edu>
Message-ID: <01060219055304.00987@gandalf>

On Saturday 02 June 2001 06:33 pm, Danny Yoo wrote:
> And stop us when we start sounding really incomprehensible!  That
> probably means that we're not doing a good job in explaining
> things.

Hmmm, well...
sometimes references on a topic might be useful to a newbie like me
like some references on basic algorithms for beginners?
very basic, please
sorting, for instance

-- 
Bob Rea

	Freedom is only privilege extended
		unless enjoyed by one and all
		--Billy Bragg

rear@sirius.com   http://www.sirius.com/~rear


From rick@niof.net  Sun Jun  3 03:41:20 2001
From: rick@niof.net (Rick Pasotto)
Date: Sat, 2 Jun 2001 22:41:20 -0400
Subject: [Tutor] Ok
In-Reply-To: <01060219055304.00987@gandalf>; from rear@sirius.com on Sat, Jun 02, 2001 at 07:05:53PM -0700
References: <Pine.LNX.4.21.0106021832250.4476-100000@hkn.eecs.berkeley.edu> <01060219055304.00987@gandalf>
Message-ID: <20010602224120.B2841@tc.niof.net>

On Sat, Jun 02, 2001 at 07:05:53PM -0700, Bob Rea wrote:
> On Saturday 02 June 2001 06:33 pm, Danny Yoo wrote:
> > And stop us when we start sounding really incomprehensible!  That
> > probably means that we're not doing a good job in explaining
> > things.
> 
> Hmmm, well...
> sometimes references on a topic might be useful to a newbie like me
> like some references on basic algorithms for beginners?
> very basic, please
> sorting, for instance

But sorting is an advanced topic, more suited to a lower level
programming language. If you are in fact a newbie, python's builtin
sorting is more than adequate for any tasks you are likely to tackle.
This list should be for learning *python* with a little bit of
programming technique thrown in.

YMMV

-- 
Political economy has not been given the mission of finding out
what society would be like if it had pleased God to make man
different from what he is. It may be regrettable that Providence,
at the beginning, neglected to seek the advice of some of our
modern reformers... if He had not disregarded the advice of
Fourier, the social order would have borne no resemblance to the
one in which we are obliged to live, breathe, and move about. But,
since we are in it, since we of live, move, and have our being in
it, our only recourse is to study it and to understand its laws,
especially if the improvement of our condition essentially depends
upon such knowledge.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From python_newbei@hotmail.com  Sun Jun  3 04:47:25 2001
From: python_newbei@hotmail.com (sean schroeder)
Date: Sun, 03 Jun 2001 03:47:25 -0000
Subject: [Tutor] new to python...
Message-ID: <F194Imd1UtYj7XGeFaa00017626@hotmail.com>

Hello,

I am a heavy Perl programmer and very interested in learning how to use 
Python - mainly for the following type of tasks:
		- cgi scripting
		- databases  access (mysql, oracle, postgress)
		- Reading and writing to files.

I have begun using Perl's OOP functionality, but believe that Python is 
better suited for the UML and OOPD methodologies that I have embarked on.

Last Note:  is there a Python compiler avaialable  for either Linux or NT?

So, with the above information in mind. I am looking for a resource that 
will help me easily make the transition.  More specifically I am looking for 
a PDF or book that basically shows/explains how to mvoe from Perl to Python 
as painlessly as possible.

thanks
Sean Schroeder
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From dyoo@hkn.eecs.berkeley.edu  Sun Jun  3 06:37:38 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 2 Jun 2001 22:37:38 -0700 (PDT)
Subject: [Tutor] Please?
In-Reply-To: <003d01c0eb95$6e56a340$6601a8c0@Parks>
Message-ID: <Pine.LNX.4.21.0106022234440.6190-100000@hkn.eecs.berkeley.edu>

On Sat, 2 Jun 2001, Ricky Parks wrote:

> I am a beginner and I am unsubscribing to tuter because I am getting
> to many emails at once and none of them are helping me, could you
> posiblie try to teach personaly? I am realy eger to learn!

Dear Ricky,

If you're getting overwhelmed by tutor email, you can set the mailing list
up so it bundles the messages up into larger "digests".  Visit:

    http://mail.python.org/mailman/listinfo/tutor

and at the bottom of the page, you'll see something about editing your own
options.

That page also allows you to unsubscribe if you want.

Good luck to you.




From dyoo@hkn.eecs.berkeley.edu  Sun Jun  3 07:06:23 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 2 Jun 2001 23:06:23 -0700 (PDT)
Subject: [Tutor] new to python...  [transition from perl->python]
In-Reply-To: <F194Imd1UtYj7XGeFaa00017626@hotmail.com>
Message-ID: <Pine.LNX.4.21.0106022244310.6190-100000@hkn.eecs.berkeley.edu>

On Sun, 3 Jun 2001, sean schroeder wrote:

> I am a heavy Perl programmer and very interested in learning how to
> use Python - mainly for the following type of tasks:
> 		- cgi scripting
> 		- databases  access (mysql, oracle, postgress)
> 		- Reading and writing to files.

You'll definitely want to look at the topic pages on Web (CGI) scripting
and Databases here:

    http://python.org/topics/web/
    http://python.org/topics/database/

There are introductions there that will help get you up to speed on this.



> Last Note:  is there a Python compiler avaialable  for either Linux or NT?

Not yet.  I believe that a compiler for Microsoft's .NET platform is being
developed, so you might want to ask on comp.lang.python for more details
on that.



> So, with the above information in mind. I am looking for a resource
> that will help me easily make the transition.  More specifically I am
> looking for a PDF or book that basically shows/explains how to mvoe
> from Perl to Python as painlessly as possible.

Hmmm... try the official tutorial:

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

It assumes experience with a programming language like Perl or C++.  The
other tutorials on:

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

should also be helpful for you.  After you go through the official
tutorial, you should be ok.




Here are a list of some caveats in the transition from Perl to Python:


String interpolation --- Python doesn't automatically interpolate into
strings: there's a separate string formatting operator '%'.  So, for
example, in Perl, we could do something like this:

###
$name = "sean";
$sentence = "Hello $name";
###

The equivalent in Python would be:

###
name = "sean"
sentence = "Hello %s" % (name)
###

The official tutorial touches on this under the "Fancier Output
Formatting" topic:

http://python.org/doc/current/tut/node9.html#SECTION009100000000000000000





Integer Division --- Python has a distinction between integer division and
floating point division.  It's different in Perl, since Perl uses floating
point throughout.

###
half = 1 / 2
###

won't assign .5 to our 'half' variable in Python --- we'll get 0.




String manipulation --- Python's uses the idea that strings are immutable,
so, if we have something like:

###
myline = "Hello, I am a line with a trailing newline.\n"
###

to get rid of that last character, we don't have Perl's chomp() operator,
but we do have something similar:

###
myline = myline.strip()   ### Take off the trailing newline.
###

An alternative way to take off that last character includes:

###
myline = myline[:-1]      ## Keep all but the last character
###

which you can think of almost like chop().

When you're working with Python, keep the immutability of strings in mind.  
The tutorial will cover how do to string manipulation, so we'll leave the
details there.



Those are the big ones I can think of at the moment.

Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Sun Jun  3 07:26:03 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 2 Jun 2001 23:26:03 -0700 (PDT)
Subject: [Tutor] Ok
In-Reply-To: <01060219055304.00987@gandalf>
Message-ID: <Pine.LNX.4.21.0106022312240.6190-100000@hkn.eecs.berkeley.edu>

On Sat, 2 Jun 2001, Bob Rea wrote:

> On Saturday 02 June 2001 06:33 pm, Danny Yoo wrote:
> > And stop us when we start sounding really incomprehensible!  That
> > probably means that we're not doing a good job in explaining
> > things.
> 
> Hmmm, well...
> sometimes references on a topic might be useful to a newbie like me
> like some references on basic algorithms for beginners?
> very basic, please
> sorting, for instance

Donald Knuth's "Art of Computer Programming" is the book I look at when I
want to look at a reference, but it's REALLY DENSE reading. I do not
recommend his book if you're just starting out on programming.  His books
are very good (and they have beautiful typography), but the can also be a
little intimidating at first.  *grin*


Hmmm... if you want to see some Computer Science ideas, there's a nice
book called "How to Think Like a Computer Scientist", by Allen Downey:

    http://www.ibiblio.org/obp/

which introduces these ideas using Python; I've heard good things about
this book, so feel free to take a look at it.


Usually though, we don't focus on algorithms as much as on using Python
effectively.  When a task looks like it needs an algorithm, we try to
direct people toward things that do most of the hard work for them.  For
example, in sorting a list of names, we can take advantage of the sort()
that the list already knows about:

###
>>> stooges = ['larry', 'moe', 'curly']
>>> stooges.sort()
>>> stooges
['curly', 'larry', 'moe']
###


If you have any questions, feel free to ask us at tutor!



From sburr@mac.com  Sun Jun  3 07:35:12 2001
From: sburr@mac.com (Steven Burr)
Date: Sat, 2 Jun 2001 23:35:12 -0700
Subject: [Tutor] bitwise operations
In-Reply-To: <8551136CB6F6D311811B00508B8B92E0C897C0@mail.rpmtec.com>
Message-ID: <20010603063340.FIRW12680.femail19.sdc1.sfba.home.com@localhost>

On Friday, June 1, 2001, at 06:53 AM, Blake Winton (Screaming) wrote:

>>> Could anyone tell me all there is to know about bit
>>> manipulation;
>> No, I doubt it. I don'ty think anyone has figured
>> that out yet... Some things you might like to do
>> a search on the net for are 'Boolean Algenra'
>> and 'Bitmasks'
>
> Okay, but surely we could give Craig a short overview...

I'm writing mostly to thank Craig for asking this question, which I've 
also wondered about, and Blake for writing his "short" overview, which 
was one of the clearest explanations of a difficult topic I've read on 
this list.  And that's saying something.

But I also wanted to mention that in making my way through the 
wonderful  2nd ed. of "Programming Python," I came across another 
interesting example of using bitwise operations.  Some of the functions 
in the os module, such as os.system, return a 2 byte (16 bit) integer 
that packs the exit status of the function in the "high" (i.e. 
left-hand) byte and the the number of the signal that killed the 
function in the low byte.  So if you need to know the exit status of a 
process (which apparently can be useful in "inter-process 
communications"), you nab this return value and shift it 8 bits to the 
right.

Suppose for example you have the following script in a file named 
graucho.py:

import sys
print "Hello, I must be going."
sys.exit(42)

You can call it, grab its return value and extract the exit status like 
so:

 >>> import os
 >>> ret = os.system('python graucho.py')
Hello, I must be going.
 >>> ret >> 8
42


From rob@jam.rr.com  Sun Jun  3 07:41:55 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sun, 03 Jun 2001 01:41:55 -0500
Subject: [Tutor] new to python...
References: <F194Imd1UtYj7XGeFaa00017626@hotmail.com>
Message-ID: <3B19DC33.AFAA0322@jam.rr.com>

sean schroeder wrote:
> 
> Hello,
> 
> I am a heavy Perl programmer and very interested in learning how to use
> Python - mainly for the following type of tasks:
>                 - cgi scripting
>                 - databases  access (mysql, oracle, postgress)
>                 - Reading and writing to files.
> 
> I have begun using Perl's OOP functionality, but believe that Python is
> better suited for the UML and OOPD methodologies that I have embarked on.
> 
> Last Note:  is there a Python compiler avaialable  for either Linux or NT?
> 
> So, with the above information in mind. I am looking for a resource that
> will help me easily make the transition.  More specifically I am looking for
> a PDF or book that basically shows/explains how to mvoe from Perl to Python
> as painlessly as possible.
> 
> thanks
> Sean Schroeder
> 

You might want to check these out. This is a page of links to tutorials,
accompanied by brief descriptions of each. Some are designed with Perl
programmers and the like in mind:

http://www.lowerstandard.com/python/tutoriallinks.html

Python is great for working with CGI and other forms of web programming.
You may be interested in *Programming Python, 2nd edition* once you
become somewhat familiar with Python. It covers the areas you expressed
interest in with some considerable detail, in a tutorial style.

Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From dyoo@hkn.eecs.berkeley.edu  Sun Jun  3 09:52:34 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 3 Jun 2001 01:52:34 -0700 (PDT)
Subject: [Tutor] Saving and loading data to/from files
In-Reply-To: <F91YZTa0RkjTC17OEjl0000b9f0@hotmail.com>
Message-ID: <Pine.LNX.4.21.0106030126180.6190-100000@hkn.eecs.berkeley.edu>

On Sun, 3 Jun 2001, Daryl G wrote:

> Unfortunatly, I don't know what a csv file is -sorry. I have tried the one 

A "csv" file is a file where all the fields as separated by commas.  It's
nice to save data like this because it's fairly easy to separate a
comma-separated line back into its pieces:

###
>>> line = 'Daryl,gman_95@hotmail.com,tutor@python.org'
>>> user, email, mailing_list = string.split(line, ',')
>>> user, email, mailing_list
('Daryl', 'gman_95@hotmail.com', 'tutor@python.org')
###

I'm not quite sure what each of the letters stand for though.  Comma
Separated... Vormat?  *grin* Many programs know how to write their output
in csv format.  For example, Microsoft Excel knows how to write
spreadsheets in csv.


This message will be long, but don't skip it because I think I found the
bug in your program.



> Unfortunatly, I don't know what a csv file is -sorry. I have tried the
> one line at a time approach, but from I could tell python wouldn't
> allow this wiht the list type. At least not with the file.write() . It
> would give an error with list variable. It said it was a read only
> character buffer. The write method only works with primitive types;
> not lists, tuples, or dictionarys.

Hmmm... can you show us how you're writing to the file?  That'll help us
give advice on how to get things working.



> I have, however, discovered that it is infact reading in the data from
> a file when I am using the pickle method. I verified this by adding a
> print statement in my opendata method and it showed that it had read
> in the data.

Ah, good!



> The problem appears to be in my function that displays the
> information. I can't figure out why it doesn't work Thanks.

Ok, let's take a look.


> #listdata method to display contents of Address book
> #will display info if just added, but will not display info if just
> #loaded from a file
> 
> def listdata():
>    i=0
>    total=len(L_Name)
>    print total
>    print "Names and phone numbers in database so far"
>    print
>    print """Last Name       First Name      PH#"""
> 
>    for i in range(total):
>        print L_Name[i],
>        print "         ",F_Name[i],
>        print "\t\t",PH_num[i]

>From what I can tell, this looks ok.  It's using global variables, which
always make me involuntarily nervous, but that's ok.  *grin*

What I think is going on is exactly global variable stuff.  Let's take a
look at the loading part of your program.

###
import pickle, string

F_Name=[]
L_Name=[]
PH_num=[]
total=0

#            [some code cut]
#opendata method
def opendata():
     filename=raw_input("Enter the name of the Addressbook you wish to 
open:
")
     file = open(filename,'r')
     (F_Name,L_Name, PH_num, total)=pickle.load(file)
###


Yes, the bug that you're running into has to do with local variable stuff.  
What I mean is that, in your opendata() function, you have the line:

     (F_Name,L_Name, PH_num, total)=pickle.load(file)

In functions, Python will expect the variables inside to be "local", and
that means that any changes you make to variables inside opendata() stay
isolated from the rest of the program.  Usually, this is a good thing,
because this sort of sandboxing keeps us from messing with another part of
a program accidently.  And you're seeing this because, as long as we're in
opendata(), we can see that the file loaded successfully.  But those
variables "outside" the sandbox, in Global-land, haven't been touched, so
that's why the listdata() doesn't show any changes.


In this case, what you want is to make the change to F_Name, L_name,
PH_num, and total to be "global", so that the rest of the program knows
that those variables changed.  What you'll need to do is add the line:

    global F_Name, L_Name, PH_num, total

at the very beginning of your opendata() function, which tells Python to
take off the sandbox for those specific variables.  With this change, your
opendata() will look like this:


###
def opendata():
     global F_Name, L_Name, PH_num, total
     filename=raw_input("Enter the name of the Addressbook you wish to 
open:
")
     file = open(filename,'r')
     (F_Name,L_Name, PH_num, total)=pickle.load(file)
###

and that should fix the bug.


Having said that, it's usually a good idea to avoid global variables.  
There are usually good ways of rearranging things so that globals aren't
necessary... but we can talk about that on another message.


Hope this helps!  If you have more questions, feel free to ask us.



From lonetwin@yahoo.com  Sun Jun  3 11:04:16 2001
From: lonetwin@yahoo.com (steve)
Date: Sun, 3 Jun 2001 15:34:16 +0530
Subject: [Tutor] Prompt 2
In-Reply-To: <002001c0ebba$1a4be600$6601a8c0@Parks>
References: <002001c0ebba$1a4be600$6601a8c0@Parks>
Message-ID: <01060315334600.10411@mercury.in.cqsl.com>

Hey there Ricky,

> >     OK, I am going to tell you step by step what I do.I write an smal=
l
> program in a text editor, save it, there is a problem with my computer =
that
> make me have to associate these kinds of files every time I load it so =
I
> associate it with the Python (command line) and run it. That is when th=
e
> prompt screen opens and then closes so fast that I can not read what is
> says. Could that have some thing to do with my properties setting? Pyth=
on
> is so confusing to run compared to Qbasic, which I have been using. Ric=
hard
> E. Parks 2

 I've been looking at u r mails since u joined in....looks like u r one o=
f=20
the as-new-as-can be newbie :)....ok here's the reply to u r question:

B'fore I go to the exact answer, lemme explain a few things...
    Python is a intepreted language, (I know u knew that...just trying to=
 be=20
complete...don't get offended if something sounds insulting to u r=20
knowledge)...but unlike qbasic it has an interactive prompt intepreter to=
o,=20
this helps u to try each python statement interactively b4 u put it all=20
together in a file and make a total working program out of it.
  When u invoke this, what u see is a ">>>" prompt with the version and o=
ther=20
info in a small window, that "looks" like the dos command prompt....on th=
e=20
other hand after writing the whole program, if u want to execute it what=20
"should" do is open a MS-DOS commond prompt (Start>Program Files>MS-DOS=20
Prompt) and type in
c:\[path-to-wherever]> python myproggy.py
    This will execute u r file (assuming that python.exe is in ur path=20
variable, and u r within the same directory where u have stored ur file=20
[myproggy.py].
    This brings us to what "I think" U are doing...u are creating the fil=
e,=20
saving it as myproggy.py, associating it with pytyhon and "double-clickin=
g"=20
it....what this does is calls the intepreter (b'cos of the=20
association)....executes the proggy (b'cos it is a nice, working python=20
program)...and "closes" the intepreter window ('cos it has nothing else t=
o do=20
)...now if u do wanna check if this is what is happening....that's simple=
,=20
insert the statement=20
raw_input() somewhere in u r program...what this will do is wait for u to=
=20
enter some-input followed by an enter...b4 going to the next statement...=
=2E

U'll know whats happening....hope this helps....if it doesn't or if somet=
hing=20
strange happens (like u r hard-disk goes up in flames) feel free to ask t=
he=20
tutor list again :)

Peace
Steve

P.S: the guys on this list are "very" helpful....change u r attitude, be=20
positive 'bout learning ...an' they'll be more than glad to help u out.
--=20
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||=09
|||/\##|||||||||##/\||=09
|/    \#########/    \=09
|\     \#######/     /=09
||\____/#######\____/|=09
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=09
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


From lumbricus@gmx.net  Sun Jun  3 11:10:29 2001
From: lumbricus@gmx.net (lumbricus@gmx.net)
Date: Sun, 3 Jun 2001 12:10:29 +0200
Subject: [Tutor] Mailing List.
In-Reply-To: <20010602174307.A2841@tc.niof.net>; from rick@niof.net on Sat, Jun 02, 2001 at 05:43:07PM -0400
References: <20010602225439.A17781@budgester.com> <20010602174307.A2841@tc.niof.net>
Message-ID: <20010603121029.A1744@Laplace.localdomain>

On Sat, Jun 02, 2001 at 05:43:07PM -0400, Rick Pasotto wrote:
> On Sat, Jun 02, 2001 at 10:54:39PM +0100, Martin Stevens wrote:
> > 
> > BTW I'm using Mutt on Debian, so there maybe a way of replying
> > to the list automatically.
> 
> Put in your .muttrc
> 
> subscribe tutor

there is a line where you can
switch on a _Subject:_ 
in your header, too
good luck!!
> 
> and then when you want to reply press 'L' (that's capital-L)
> for List-reply.
> 

HTH Joe!

-- 
In order to discover who you are, first learn who everybody else is;
you're what's left.


From craig@osa.att.ne.jp  Sun Jun  3 11:43:37 2001
From: craig@osa.att.ne.jp (Craig Hagerman)
Date: Sun, 03 Jun 2001 19:43:37 +0900
Subject: [Tutor] bitwise operations
Message-ID: <E156VIj-0004Nr-00@mail.python.org>

Hi,

I want to say a big thank you to Alan Gauld, Blake Winton (GREAT explanation
Blake) and Daniel Yoo for the excellant responses to my question about using
bitwise operations. I now have a very general, overview kind of
understanding about how and why one deals with bits. But I will have to play
around and give myself some simple learning tasks to work through to really
get a handle on this stuff. You guys have given me enough of an
understanding that I now have a place to start. Ironically, I just got a new
order of books from Amazon and was fliping though "A programmers guide to
Java Certification" and came upon a couple more simple examples of bit usage
(different language but the principle is the same).

Again, thanks for taking the time to impart your knowledge.

Craig Hagerman


From tescoil@irtc.net  Sun Jun  3 11:49:16 2001
From: tescoil@irtc.net (Tesla Coil)
Date: Sun, 03 Jun 2001 05:49:16 -0500
Subject: [Tutor] Saving and loading data to/from files
References: <Pine.LNX.4.21.0106030126180.6190-100000@hkn.eecs.berkeley.edu>
Message-ID: <3B1A162C.E897E397@irtc.net>

On 3 Jun 2001, Daniel Yoo wrote:
> I'm not quite sure what each of the letters stand 
> for though.  Comma Separated... Vormat?  *grin*

Comma Separated Variable, or,
Computer Spreadsheet Vomitus, 
depending on who you ask...



From arcege@speakeasy.net  Sun Jun  3 12:52:12 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Sun, 3 Jun 2001 07:52:12 -0400 (EDT)
Subject: [Tutor] Saving and loading data to/from files
In-Reply-To: <F30BEzJvlZGdOZofu450000d210@hotmail.com> from "Daryl G" at Jun 02, 2001 11:52:15 PM
Message-ID: <200106031152.f53BqDK07773@dsl092-074-184.bos1.dsl.speakeasy.net>

Daryl G wrote
> 
> Hi,  I am having difficulty in saving and loading data that I created in a 
> simple Address book program. I  am using 3 list variables for First and Last 
> name and phone number and an interger that counts the total number of 
> entries.  I first tried using the 'write' but that wouldn't work with lists. 
> I discovered the pickle module and
> I am able to save my data, but when I load it back up and then try to view 
> it in my program, its not there.
> 
> variables
> import pickle, string
> 
> F_Name=[]
> L_Name=[]
> PH_num=[]
> total=0
> 
> #savedata method
> def savedata():
>     filename= raw_input("Enter the name you wish to give this address book: 
> ")
>     object=(F_Name, L_Name, PH_num, total)
>     file=open(filename, 'w')
>     pickle.dump(object, file)
> 
> #opendata method
> def opendata():
>     filename=raw_input("Enter the name of the Addressbook you wish to open: 
> ")
>     file = open(filename,'r')
>     (F_Name,L_Name, PH_num, total)=pickle.load(file)
> 
> 
> What am I doing wrong?

You are assigning to local variables in opendata() when the variables
are global in savedata.  However you might want to think about passing
values, especially removing the raw_input() calls from the functions.

def opendata(filename):
  global F_Name, L_Name, PH_num, total
  file = open(filename, 'r')
  (F_Name, L_Name, PH_num, total) = pickle.load(file)

Or better yet, returning the values:
def opendata(filename):
  file = open(filename, 'r')
  # assigning to all values catches the error of invalid data format
  (F_Name, L_Name, PH_num, total) = pickle.load(file)
  return (F_Name, L_Name, PH_num, total)

Pickle is fine for outputting single values, but for a database of
values (like an address) you will want to look at the shelve module
(which uses pickle and the *dbm modules, see "anydbm") or a relational
database (which could be overkill for an address book application).

> Another question that I have is how do I format data that I want to display 
> in specific
> columns in standerd output, like that can be done in C ?

This is done with the string % operator.  With an order sequence:
  print '''Name: %s %s; Phone: %s''' % (F_Name, L_Name, PH_num)
or with a dictionary:
  print '''Name: %(first)s %(last)s; Phone: %(phone)s''' % {
    'first': F_Name, 'last': L_Name, 'phone': PH_num
  }

The Python Library documention has all this.  Much of it is actually
like C's sprintf.
<URL: http://www.python.org/doc/current/lib/typesseq-strings.html>

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From arcege@speakeasy.net  Sun Jun  3 12:53:23 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Sun, 3 Jun 2001 07:53:23 -0400 (EDT)
Subject: [Tutor] Ok
In-Reply-To: <Pine.LNX.4.21.0106021832250.4476-100000@hkn.eecs.berkeley.edu> from "Daniel Yoo" at Jun 02, 2001 06:33:35 PM
Message-ID: <200106031153.f53BrNP07783@dsl092-074-184.bos1.dsl.speakeasy.net>

Daniel Yoo wrote
> And stop us when we start sounding really incomprehensible!  That probably
> means that we're not doing a good job in explaining things.

Guilty, sometimes. ;)

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From lha2@columbia.edu  Sun Jun  3 15:21:40 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Sun, 03 Jun 2001 10:21:40 -0400
Subject: [Tutor] Something to tack on to "Useless Python" challenges
Message-ID: <3B1A47F4.72959659@mail.verizon.net>

http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html

Python should be up to the task...

Anyone have a module lying around for torking with arbitrarily large
numbers (in Python)?


From gman_95@hotmail.com  Sun Jun  3 15:39:22 2001
From: gman_95@hotmail.com (Daryl G)
Date: Sun, 03 Jun 2001 14:39:22 -0000
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <F158ltFlmmlQ080Gxw80000a708@hotmail.com>

Yup, it was the global/local problem. I thought that since I had those 
varibles declared globally, they would be scene everywere, but local 
varibles take precedence. Forgot about that

The %s doesn't quite work right. If a name is shorter than another, then the 
positions wont be right in my simple table. I guess I have to see if that 
center() method will work for me.

example
LastName        FirstName       Phone#
Stephanopolis   George          900-856-2992
Jo   Mary          800-328-6387

is what I end up getting.
Thanks. I'll check that api doc

Computer Spreadsheet Vomitus. I love that. :)


>From: "Michael P. Reilly" <arcege@dsl092-074-184.bos1.dsl.speakeasy.net>
>Reply-To: arcege@speakeasy.net
>To: gman_95@hotmail.com (Daryl G)
>CC: tutor@python.org
>Subject: Re: [Tutor] Saving and loading data to/from files
>Date: Sun, 3 Jun 2001 07:52:12 -0400 (EDT)
>
>Daryl G wrote
> >
> > Hi,  I am having difficulty in saving and loading data that I created in 
>a
> > simple Address book program. I  am using 3 list variables for First and 
>Last
> > name and phone number and an interger that counts the total number of
> > entries.  I first tried using the 'write' but that wouldn't work with 
>lists.
> > I discovered the pickle module and
> > I am able to save my data, but when I load it back up and then try to 
>view
> > it in my program, its not there.
> >
> > variables
> > import pickle, string
> >
> > F_Name=[]
> > L_Name=[]
> > PH_num=[]
> > total=0
> >
> > #savedata method
> > def savedata():
> >     filename= raw_input("Enter the name you wish to give this address 
>book:
> > ")
> >     object=(F_Name, L_Name, PH_num, total)
> >     file=open(filename, 'w')
> >     pickle.dump(object, file)
> >
> > #opendata method
> > def opendata():
> >     filename=raw_input("Enter the name of the Addressbook you wish to 
>open:
> > ")
> >     file = open(filename,'r')
> >     (F_Name,L_Name, PH_num, total)=pickle.load(file)
> >
> >
> > What am I doing wrong?
>
>You are assigning to local variables in opendata() when the variables
>are global in savedata.  However you might want to think about passing
>values, especially removing the raw_input() calls from the functions.
>
>def opendata(filename):
>   global F_Name, L_Name, PH_num, total
>   file = open(filename, 'r')
>   (F_Name, L_Name, PH_num, total) = pickle.load(file)
>
>Or better yet, returning the values:
>def opendata(filename):
>   file = open(filename, 'r')
>   # assigning to all values catches the error of invalid data format
>   (F_Name, L_Name, PH_num, total) = pickle.load(file)
>   return (F_Name, L_Name, PH_num, total)
>
>Pickle is fine for outputting single values, but for a database of
>values (like an address) you will want to look at the shelve module
>(which uses pickle and the *dbm modules, see "anydbm") or a relational
>database (which could be overkill for an address book application).
>
> > Another question that I have is how do I format data that I want to 
>display
> > in specific
> > columns in standerd output, like that can be done in C ?
>
>This is done with the string % operator.  With an order sequence:
>   print '''Name: %s %s; Phone: %s''' % (F_Name, L_Name, PH_num)
>or with a dictionary:
>   print '''Name: %(first)s %(last)s; Phone: %(phone)s''' % {
>     'first': F_Name, 'last': L_Name, 'phone': PH_num
>   }
>
>The Python Library documention has all this.  Much of it is actually
>like C's sprintf.
><URL: http://www.python.org/doc/current/lib/typesseq-strings.html>
>
>   -Arcege
>
>--
>+----------------------------------+-----------------------------------+
>| Michael P. Reilly                | arcege@speakeasy.net              |

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From sheila@thinkspot.net  Sun Jun  3 16:01:18 2001
From: sheila@thinkspot.net (Sheila King)
Date: Sun, 03 Jun 2001 08:01:18 -0700
Subject: [Tutor] Saving and loading data to/from files
In-Reply-To: <3B1A162C.E897E397@irtc.net>
References: <Pine.LNX.4.21.0106030126180.6190-100000@hkn.eecs.berkeley.edu> <3B1A162C.E897E397@irtc.net>
Message-ID: <1A07617500E0@kserver.org>

I thought it was 

Comma Separated Values

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/


On Sun, 03 Jun 2001 05:49:16 -0500, Tesla Coil <tescoil@irtc.net>  wrote
about Re: [Tutor] Saving and loading data to/from files:

:On 3 Jun 2001, Daniel Yoo wrote:
:> I'm not quite sure what each of the letters stand 
:> for though.  Comma Separated... Vormat?  *grin*
:
:Comma Separated Variable, or,
:Computer Spreadsheet Vomitus, 
:depending on who you ask...
:
:
:_______________________________________________
:Tutor maillist  -  Tutor@python.org
:http://mail.python.org/mailman/listinfo/tutor



From scarblac@pino.selwerd.nl  Sun Jun  3 16:07:55 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Sun, 3 Jun 2001 17:07:55 +0200
Subject: [Tutor] Something to tack on to "Useless Python" challenges
In-Reply-To: <3B1A47F4.72959659@mail.verizon.net>; from vze2f978@mail.verizon.net on Sun, Jun 03, 2001 at 10:21:40AM -0400
References: <3B1A47F4.72959659@mail.verizon.net>
Message-ID: <20010603170755.A23389@pino.selwerd.nl>

On  0, Lloyd Hugh Allen <vze2f978@mail.verizon.net> wrote:
> http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html
> 
> Python should be up to the task...
> 
> Anyone have a module lying around for torking with arbitrarily large
> numbers (in Python)?

No need for a module in Python, it has long integers itself:
>>> 1000000000000000000000000L
1000000000000000000000000L

The problem here of course isn't Python or long integers, but an algorithm
that doesn't take time measured in ages of the universe...

I'll help you on your way: 2 is not a factor in any of the numbers. So now
you have one fewer prime to check! ;-)

-- 
Remco Gerlich


From arcege@speakeasy.net  Sun Jun  3 16:12:04 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Sun, 3 Jun 2001 11:12:04 -0400 (EDT)
Subject: [Tutor] Saving and loading data to/from files
In-Reply-To: <F158ltFlmmlQ080Gxw80000a708@hotmail.com> from "Daryl G" at Jun 03, 2001 02:39:22 PM
Message-ID: <200106031512.f53FC4k04685@dsl092-074-184.bos1.dsl.speakeasy.net>

Daryl G wrote
> The %s doesn't quite work right. If a name is shorter than another, then the 
> positions wont be right in my simple table. I guess I have to see if that 
> center() method will work for me.

You need to put the width/length specifies in (just like with C).

> example
> LastName        FirstName       Phone#
> Stephanopolis   George          900-856-2992
> Jo   Mary          800-328-6387
> is what I end up getting.

For this, the formatting string would be:
fmt = '''%(L_Name)-15.15s %(F_Name)-15.15s %(PH_num)s'''

Last name ("(L_Name)"), left justified ("-"), 15 characters wide (max
and min, "15.15") string ("s"); same for first name; the phone number
is an unrestricted string.

> Computer Spreadsheet Vomitus. I love that. :)

Actually, CSV means "comma-separated values" and it is more complicated
than just splitting on a comma: if the data has a comma, then the value
is quoted with double-quotes, but what if the value has a double-quote?
It is also only a textual format, not a data retrieval system; it is
one means used to transfer data between database systems.  Usually the
first line is the field names.  If you're interested, look for "ASV"
in the Vaults of Parnassus <URL: http://www.vex.net/parnassus/>.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From rick@niof.net  Sun Jun  3 16:14:20 2001
From: rick@niof.net (Rick Pasotto)
Date: Sun, 3 Jun 2001 11:14:20 -0400
Subject: [Tutor] Saving and loading data to/from files
In-Reply-To: <F158ltFlmmlQ080Gxw80000a708@hotmail.com>; from gman_95@hotmail.com on Sun, Jun 03, 2001 at 02:39:22PM -0000
References: <F158ltFlmmlQ080Gxw80000a708@hotmail.com>
Message-ID: <20010603111420.A29372@tc.niof.net>

On Sun, Jun 03, 2001 at 02:39:22PM -0000, Daryl G wrote:
> The %s doesn't quite work right. If a name is shorter than another,
> then the positions wont be right in my simple table. I guess I have to
> see if that center() method will work for me.
> 
> example
> LastName        FirstName       Phone#
> Stephanopolis   George          900-856-2992
> Jo   Mary          800-328-6387

Use a width modifier with your %s spec. "%-20s" means to left justify
using at least 20 columns. Just make sure the width you use is as long
as the longest value. You can also use "%-*s" % (width,string) if you
want the width to be dynamic, ie, if you scan the list first to
determine the maximum lengths.

-- 
Is there any need to prove that this odious perversion of the law
is a perpetual cause of hatred, discord, and even social disorder?
Look at the United States. There is no country in the world where
the law confines itself more rigorously to its proper role, which
is to guarantee everyone's liberty and property. Accordingly,
there is no country in which the social order seems to rest on a
more stable foundation. Nevertheless, even in the United States
there are two questions, and only two, which since it was founded,
have several times put the political order in danger. And what are
these two questions? The question of slavery and that of tariffs,
that is, precisely the only two questions concerning which,
contrary to the general spirit of this republic, the law has
assumed a spoiliative character. Slavery is a violation, sanctioned
by law, of the rights of the person. Protective tariffs are a
violation, perpetrated by the law, of the right to property; and
certainly it is remarkable that in the midst of so many other
disputes this twofold legal scourge, a sad heritage from the Old
World, should be the only one that can and perhaps will lead to
the dissolution of the Union. It is, in fact, impossible to
imagine any graver situation in a society than one in which the
law becomes an instrument of injustice. And if this fact gives
rise to such dreadful consequences in the United States, where it
is only exceptional, what must be its consequences in Europe where
it is a principle and a system?
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From rob@jam.rr.com  Sun Jun  3 16:17:56 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sun, 03 Jun 2001 10:17:56 -0500
Subject: [Tutor] Re: Useless Thanks!
References: <3B198806.41D90105@jam.rr.com> <3B198C26.DB1DC306@irtc.net>
Message-ID: <3B1A5524.E19E170D@jam.rr.com>

Tesla Coil wrote:
> 
> > I've uploaded clippage.py
> 
> Wow, what service!
> 
> > Also, how do you like the new look of the site?
> > It's not quite as good as oreilly.com yet, but I
> > attack it freshly every few weeks or so these days.
> 
> Think it really bad needs to feature a list of the
> "Top Ten Most Useless Python Programmers."
> 
> You know people would really scramble to be able
> to put on *that* on their resume!
> 
> Could announce to Tutor that you're planning this and
> will give honorable mention at the bottom to the one
> who writes the Useless Python Program to grab pages
> www.lowerstandard.com/python/uselesspython[1-6].html
> and generate the statistics.
> 
> Of course, it'll hafta take into account that it'll
> soon have more than six pages to grab from all the
> responses resulting of its implementation...
> 
> I'll disqualify myself for having the unfair lead
> of having thought it up. <wink>.
> 
> Also: Perhaps an icon or something to designate a
> Useless contribution is specific to *nix or MS?
> 
> Then you could include in Useless challenges:
> "Port an existing Useless Python program to an
> OS on which it does not currently operate."

I'm forwarding this messge in its entirety to the Tutor List to see if
anyone has any thoughts on the general subject. Thanks to your
collective generosity and creativity, Useless Python has begun to grow
into what I certainly hope is "far from useless" as one reviewer phrased
it.

What would make it even more handy? I'll certainly add the new
challenges suggested to me over the last few days, which seem to be
amusing some of you. I've been trying to work on my web programming
skills (in Python, of course), and would like to add more interactivity
to the site. Aside from coming up with a way for people to upload their
own source files and descriptions, I've thought it would be interesting
if viewers could vote on the uselessness of any script and/or mark
whether they think it's Newbie, Intermediate, Advanced, Guru, or Yoo
level. Oh, and as soon as I can figure out where we're keeping our log
files, I'll try to make some stats available.

It's your site. How do you want it to grow next?

Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From rob@jam.rr.com  Sun Jun  3 16:22:33 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sun, 03 Jun 2001 10:22:33 -0500
Subject: [Tutor] Saving and loading data to/from files
References: <Pine.LNX.4.21.0106030126180.6190-100000@hkn.eecs.berkeley.edu> <3B1A162C.E897E397@irtc.net> <1A07617500E0@kserver.org>
Message-ID: <3B1A5639.5CFA48CB@jam.rr.com>

Sheila King wrote:
> 
> I thought it was
> 
> Comma Separated Values
> 
> --
> Sheila King

I remember the old days, when we called them comma-delimited files. It
took me forever to figure out that's what a .csv file was.

Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From pdiaz88@terra.es  Sun Jun  3 18:24:36 2001
From: pdiaz88@terra.es (Pedro Diaz Jimenez)
Date: Sun, 3 Jun 2001 17:24:36 +0000
Subject: [Tutor] Something to tack on to "Useless Python" challenges
In-Reply-To: <3B1A47F4.72959659@mail.verizon.net>
References: <3B1A47F4.72959659@mail.verizon.net>
Message-ID: <01060317243600.07891@duero>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 03 June 2001 14:21, Lloyd Hugh Allen wrote:
> http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html
>
> Python should be up to the task...
>
> Anyone have a module lying around for torking with arbitrarily large
> numbers (in Python)?
MPZ module should do the job, but...
This is (in my opinion) the type of job not suited python. A C program would 
do the same job, faster

Cheers

Pedro
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

- -- 

/*
 * Pedro Diaz Jimenez
 * pdiaz88@terra.es 
 * pdiaz@acm.asoc.fi.upm.es
 *
 * Wanna see how 100000! looks like?:
 * http://acm.asoc.fi.upm.es/~pdiaz/fact_100.000
 * 
 * La sabiduria me persigue, pero yo soy mas rapido
 * 
 * "Las artes marciales son parte de una filosofía,
 *  no deben ser consideradas un arma. Y por eso,
 *  recuerda: No hay nada como un buen revolver"
 *    Les Luthiers, Iniciacion a las Artes Marciales
 *
 */

Random quote:
- -------------

You feel a whole lot more like you do now than you did when you used to.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7GnLcnu53feEYxlERAkgwAKCrJzqjfYDjUPmIwWVO0tdjqeBnwwCfY+VV
t1JfWWNdnmqg6BB8UYnnluQ=
=cSmp
-----END PGP SIGNATURE-----


From rob@jam.rr.com  Sun Jun  3 16:40:14 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sun, 03 Jun 2001 10:40:14 -0500
Subject: [Tutor] Something to tack on to "Useless Python" challenges
References: <3B1A47F4.72959659@mail.verizon.net> <01060317243600.07891@duero>
Message-ID: <3B1A5A5E.D4D5E758@jam.rr.com>

Pedro Diaz Jimenez wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Sunday 03 June 2001 14:21, Lloyd Hugh Allen wrote:
> > http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html
> >
> > Python should be up to the task...
> >
> > Anyone have a module lying around for torking with arbitrarily large
> > numbers (in Python)?
> MPZ module should do the job, but...
> This is (in my opinion) the type of job not suited python. A C program would
> do the same job, faster
> 
> Cheers
> 
> Pedro
> >

Almost certainly correct, which would make the Python version pretty
Useless. But aside from the pure joy of Uselessness, it would be
interesting to go as far as possible using Python for some of these
really hairy, advanced tasks. Then we'd have some great examples of
Python's current limits, and it would be easier for someone to take the
part already written in Python and code the remainder in C.

Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From deirdre@deirdre.net  Sun Jun  3 17:02:54 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Sun, 3 Jun 2001 09:02:54 -0700
Subject: [Tutor] Re: Useless Thanks!
In-Reply-To: <3B1A5524.E19E170D@jam.rr.com>
References: <3B198806.41D90105@jam.rr.com> <3B198C26.DB1DC306@irtc.net>
 <3B1A5524.E19E170D@jam.rr.com>
Message-ID: <a05100e01b7400c80fbb4@[10.0.1.8]>

>  > Think it really bad needs to feature a list of the
>>  "Top Ten Most Useless Python Programmers."

I love this idea!

Strangely enough, my own contribution came up on a job interview last 
week when someone asked about whether I'd written network clients or 
servers. I pointed out that my example of both had been up on the 
useless python pages for some time. :)

>What would make it even more handy? I'll certainly add the new
>challenges suggested to me over the last few days, which seem to be
>amusing some of you. I've been trying to work on my web programming
>skills (in Python, of course), and would like to add more interactivity
>to the site. Aside from coming up with a way for people to upload their
>own source files and descriptions, I've thought it would be interesting
>if viewers could vote on the uselessness of any script and/or mark
>whether they think it's Newbie, Intermediate, Advanced, Guru, or Yoo
>level. Oh, and as soon as I can figure out where we're keeping our log
>files, I'll try to make some stats available.

My dislike of that kind of system is that then there tend to be 
cliques (like in Advogato, where cliques of people can vote someone 
up or down). How about someone votes on whether or not the example 
was useful to them?

>It's your site. How do you want it to grow next?

But thanks for letting me know what I *really* should do (other than 
submit it) with my simulation modeling homework examples. After all, 
the bagel baker example DOES explain why the store might be out of 
bagels....
-- 
_Deirdre     Stash-o-Matic: http://weirdre.com      http://deirdre.net
Macintosh Developer (seeking work): Will work for Cocoa
"I love deadlines. I like the whooshing sound they make as they fly by."
                                                          - Douglas Adams


From pdiaz88@terra.es  Sun Jun  3 20:13:51 2001
From: pdiaz88@terra.es (Pedro Diaz Jimenez)
Date: Sun, 3 Jun 2001 19:13:51 +0000
Subject: Any volunteers ? (was: Re: [Tutor] Something to tack on to "Useless Python" challenges)
In-Reply-To: <3B1A5A5E.D4D5E758@jam.rr.com>
References: <3B1A47F4.72959659@mail.verizon.net> <01060317243600.07891@duero> <3B1A5A5E.D4D5E758@jam.rr.com>
Message-ID: <01060319135100.00334@duero>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Well, you could build a computing module using libgmp in C, and then
build the rest of the app in python using that module. (modRSAchallenge ?). 
Very, very interesting

We could do something ala distributed.net, but in python and focusing on the 
factoring challenge. I would love to work on that project. Any volunteers?. 
Unfortunatly I have exams on june. What about doing that in july/august?
I have cryptographic background, and I'm sure more people on this list have 
too.  

Any volunteers?

Cheers
Pedro

On Sunday 03 June 2001 15:40, Rob Andrews wrote:
> Pedro Diaz Jimenez wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On Sunday 03 June 2001 14:21, Lloyd Hugh Allen wrote:
> > > http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html
> > >
> > > Python should be up to the task...
> > >
> > > Anyone have a module lying around for torking with arbitrarily large
> > > numbers (in Python)?
> >
> > MPZ module should do the job, but...
> > This is (in my opinion) the type of job not suited python. A C program
> > would do the same job, faster
> >
> > Cheers
> >
> > Pedro
>
> Almost certainly correct, which would make the Python version pretty
> Useless. But aside from the pure joy of Uselessness, it would be
> interesting to go as far as possible using Python for some of these
> really hairy, advanced tasks. Then we'd have some great examples of
> Python's current limits, and it would be easier for someone to take the
> part already written in Python and code the remainder in C.
>
> Rob

- -- 

/*
 * Pedro Diaz Jimenez
 * pdiaz88@terra.es 
 * pdiaz@acm.asoc.fi.upm.es
 *
 * Wanna see how 100000! looks like?:
 * http://acm.asoc.fi.upm.es/~pdiaz/fact_100.000
 * 
 * La sabiduria me persigue, pero yo soy mas rapido
 * 
 * "Las artes marciales son parte de una filosofía,
 *  no deben ser consideradas un arma. Y por eso,
 *  recuerda: No hay nada como un buen revolver"
 *    Les Luthiers, Iniciacion a las Artes Marciales
 *
 */

Random quote:
- -------------

I bet Einstein turned himself all sorts of colors before he invented the
lightbulb.

		-- Homer Simpson
		   Bart The Genius
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7Gox5nu53feEYxlERAgcdAJ4i/sRDI4S1K9R2mZjFHKGBfkcTjgCgtpZ3
oxsC0QezRkMC7uKy72SyT6w=
=7qJK
-----END PGP SIGNATURE-----


From gozin23@hotmail.com  Sun Jun  3 18:17:34 2001
From: gozin23@hotmail.com (Dennis Willis)
Date: Sun, 03 Jun 2001 17:17:34 -0000
Subject: [Tutor] Async, RAS
Message-ID: <F142FlF8HGmCvoXM7e00000397e@hotmail.com>

Hi,

I've discovered Python (just!) and have been given a task with Win RAS in 
which I have to use it async.  I'd like to try implement with Python.  Does 
anyone know of any Python RAS examples I can use as a starting point (or any 
gotcha's they've already tripped over)?  Target OS is W2k.

Thanks very much.

Dennis Willis

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From lha2@columbia.edu  Sun Jun  3 18:18:41 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Sun, 03 Jun 2001 13:18:41 -0400
Subject: [Tutor] Something to tack on to "Useless Python" challenges
Message-ID: <3B1A7171.ECBECD98@mail.verizon.net>

On 0?, Remco Gerlich wrote:
>On  0, Lloyd Hugh Allen <vze2f978@mail.verizon.net> wrote:
>> http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html
>> 
>> Python should be up to the task...
>> 
>> Anyone have a module lying around for torking with arbitrarily large
>> numbers (in Python)?
>
>No need for a module in Python, it has long integers itself:
>>>> 1000000000000000000000000L
>1000000000000000000000000L
>
>The problem here of course isn't Python or long integers, but an algorithm
>that doesn't take time measured in ages of the universe...
>
>I'll help you on your way: 2 is not a factor in any of the numbers. So now
>you have one fewer prime to check! ;-)

Well, I know that for the first the number, the ones digits of the
factors end in either 3 and 3 or 1 and 9, but there are probably another
85 digits to find.

My question had my Pascal (and just enough c) background showing
through: I had assumed that there was a cap on Long Integers, just a
bigger one than with regular (short?) integers.


From alan.gauld@bt.com  Sun Jun  3 20:44:02 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 3 Jun 2001 20:44:02 +0100
Subject: [Tutor] Off Topic - tutor@pyhon.org FAQ?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7F8@mbtlipnt02.btlabs.bt.co.uk>

> Alan, you can of course use what i did if you want....

Not me, I was just encouraging the original poster.
In fact my time on python tutor duty is likely to 
diminish to supporting my web tutor coz my publisher
just accepted my new book proposal but weith an 
increased scope from my proposal - including twice 
as many pages!...

I'm about to be a busy bee for a while!

Alan G


From alan.gauld@bt.com  Sun Jun  3 20:54:26 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 3 Jun 2001 20:54:26 +0100
Subject: [Tutor] RE:  [book recommendation for Programming Pearls]
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7F9@mbtlipnt02.btlabs.bt.co.uk>

I second the recommendation for Programming Pearls
In act there are 2 books 'PP' and 'More PP'

They don't use C much its nearly all awk(altho I 
haven't seen the latest editions(c1999) I have 
the late '80s editions. They are mines of gold on
anything to do with performant computation and 
also representation of data and documentation.

The chapter on the unix 'spell' program is 
wonderful! In fact they are all pretty good.

Alan G.



From alan.gauld@bt.com  Sun Jun  3 21:00:34 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 3 Jun 2001 21:00:34 +0100
Subject: [Tutor] Lists...
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FA@mbtlipnt02.btlabs.bt.co.uk>

> def intersect_eas(L1, L2):
>     '''The easiest way for Alan G, requires nested_scopes'''
>     return filter(lambda x: (x in L2), L1)

How does it require nested scopes?
lambda and filter are builtin, 
and x,L1 and L2 are all locals.

But I accept its not highly performant - that wasn't part 
of the original question... ;-)

Alan G


From scarblac@pino.selwerd.nl  Sun Jun  3 21:08:08 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Sun, 3 Jun 2001 22:08:08 +0200
Subject: [Tutor] Lists...
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FA@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Sun, Jun 03, 2001 at 09:00:34PM +0100
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FA@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20010603220808.A24174@pino.selwerd.nl>

On  0, alan.gauld@bt.com wrote:
> > def intersect_eas(L1, L2):
> >     '''The easiest way for Alan G, requires nested_scopes'''
> >     return filter(lambda x: (x in L2), L1)
> 
> How does it require nested scopes?
> lambda and filter are builtin, 
> and x,L1 and L2 are all locals.

L1 and L2 are not locals inside the lambda. They're only visible with nested
scopes.

-- 
Remco Gerlich


From alan.gauld@bt.com  Sun Jun  3 21:07:23 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 3 Jun 2001 21:07:23 +0100
Subject: [Tutor] Ok
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FB@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C0EC68.CD502730
Content-type: text/plain; charset="ISO-8859-1"

    Ok, I am going to stick with it, I will say this agian I am a beginer an
know nothing about programming, so half the stuff that is sent I will not
undersand! Thank you.
                                        Richard E Parks 2
                                        RickyP1@frontiernet.net
<mailto:RickyP1@frontiernet.net> 
 

Good. Now it might help if you went into posting mode 
instead of reading(BTW you can cut the volume down by 
getting the digest - that wraps about 12-15 messages 
into a single one. Its an option on the tutor mail 
web page.    
 
How are you trying to learn? Are you using a book or online tutor?
If so which? How far thru' have you gotten. This list will try to answer 
beginner questions of any standard(if thats not a contradiction in terms!)
 
Have fun,
 
Alan G

------_=_NextPart_001_01C0EC68.CD502730
Content-type: text/html; charset="ISO-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">


<META content="MSHTML 5.00.3013.2600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; Ok, I am going to stick with 
  it, I will say this agian I am a beginer an know nothing about programming, so 
  half the stuff that&nbsp;is sent I will not undersand! Thank you.</FONT></DIV>
  <DIV><FONT face=Arial size=2>&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; &nbsp;&nbsp;&nbsp; 
  Richard E Parks 2</FONT></DIV>
  <DIV><FONT face=Arial size=2>&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; &nbsp;&nbsp;&nbsp; <A 
  href="mailto:RickyP1@frontiernet.net">RickyP1@frontiernet.net</A></FONT></DIV>
  <DIV><FONT size=2><FONT face=Arial><SPAN class=050491020-03062001><FONT 
  color=#0000ff 
face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV></BLOCKQUOTE>
<DIV><FONT size=2><FONT face=Arial><SPAN class=050491020-03062001><FONT 
color=#0000ff face="Courier New">Good. Now it might help if you went into 
posting mode </FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=050491020-03062001><FONT 
color=#0000ff face="Courier New">instead of reading(BTW you can cut the volume 
down by </FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=050491020-03062001><FONT 
color=#0000ff face="Courier New">getting the digest - that wraps about 12-15 
messages </FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=050491020-03062001><FONT 
color=#0000ff face="Courier New">into a single one. Its an option on the tutor 
mail </FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=050491020-03062001><FONT 
color=#0000ff face="Courier New">web 
page.</FONT>&nbsp;</SPAN>&nbsp;&nbsp;</FONT><FONT color=#0000ff 
face="Courier New"><SPAN 
class=050491020-03062001>&nbsp;</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=050491020-03062001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=050491020-03062001><FONT color=#000000 face=Arial>How are you trying to 
learn? Are you using a book or online tutor?</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=050491020-03062001><FONT color=#000000 face=Arial>If so 
which?</FONT>&nbsp;<FONT color=#000000 face=Arial>How far thru' have you gotten. 
This list will try to answer </FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=050491020-03062001><FONT color=#000000 face=Arial>beginner questions of 
any standard(if thats not a contradiction in 
terms!)</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=050491020-03062001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=050491020-03062001>Have 
fun,</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN 
class=050491020-03062001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=050491020-03062001>Alan 
G</SPAN></FONT></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01C0EC68.CD502730--


From gman_95@hotmail.com  Sun Jun  3 21:20:03 2001
From: gman_95@hotmail.com (Daryl G)
Date: Sun, 03 Jun 2001 20:20:03 -0000
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <F25cK8r6beUzmRf6Ci60000db18@hotmail.com>

AHA!
That was it, though I did have to do it a little differently.
The way you showed didn't seem to work with lists, so I just converted each 
individual part of a list into a String and then it  worked

   for i in range(total):
      LN=L_Name[i]
      FN=F_Name[i]
      PH=PH_num[i]
      print"%-15.15s %-15.15s %-s" % (LN, FN, PH)


Thanks Again!

>From: "Michael P. Reilly" <arcege@dsl092-074-184.bos1.dsl.speakeasy.net>
>Reply-To: arcege@speakeasy.net
>To: gman_95@hotmail.com (Daryl G)
>CC: tutor@python.org
>Subject: Re: [Tutor] Saving and loading data to/from files
>Date: Sun, 3 Jun 2001 11:12:04 -0400 (EDT)
>
>Daryl G wrote
> > The %s doesn't quite work right. If a name is shorter than another, then 
>the
> > positions wont be right in my simple table. I guess I have to see if 
>that
> > center() method will work for me.
>
>You need to put the width/length specifies in (just like with C).
>
> > example
> > LastName        FirstName       Phone#
> > Stephanopolis   George          900-856-2992
> > Jo   Mary          800-328-6387
> > is what I end up getting.
>
>For this, the formatting string would be:
>fmt = '''%(L_Name)-15.15s %(F_Name)-15.15s %(PH_num)s'''
>
>Last name ("(L_Name)"), left justified ("-"), 15 characters wide (max
>and min, "15.15") string ("s"); same for first name; the phone number
>is an unrestricted string.
>
> > Computer Spreadsheet Vomitus. I love that. :)
>
>Actually, CSV means "comma-separated values" and it is more complicated
>than just splitting on a comma: if the data has a comma, then the value
>is quoted with double-quotes, but what if the value has a double-quote?
>It is also only a textual format, not a data retrieval system; it is
>one means used to transfer data between database systems.  Usually the
>first line is the field names.  If you're interested, look for "ASV"
>in the Vaults of Parnassus <URL: http://www.vex.net/parnassus/>.
>
>   -Arcege
>
>--
>+----------------------------------+-----------------------------------+
>| Michael P. Reilly                | arcege@speakeasy.net              |

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From alan.gauld@bt.com  Sun Jun  3 21:16:29 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 3 Jun 2001 21:16:29 +0100
Subject: [Tutor] Prompt
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FC@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C0EC6A.13018890
Content-type: text/plain; charset="iso-8859-1"

Thank you all for the suport. My bigest problem right now is getiing the
software to run. I downloaded python 2.0 Windows Installer from the
python.org web site. I am still having a problem  with the prompt screen
closing too fast I can even read what is says!   
 

This seems to be common for beginners on windoze.
Try running the Python GUI(IDLE) instead of Python.
Or if you got the ActiveState version run Pythonwin.
 
Alternatively start a DOS box session and type python
at the C:> prompt. That way the DOS box stays put 
after your program runs so you see the output!
 
Somebody should really write up in detail how to start 
a program (and the interpreter) for non command-line 
users.... I've been meaning to add it to my tutor 
for months!
 
HTH,
 
Alan g
 
 

------_=_NextPart_001_01C0EC6A.13018890
Content-type: text/html; charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.00.3013.2600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV><FONT size=2><FONT face=Arial>Thank you all for the suport. My bigest 
  problem right now is getiing the software to run.&nbsp;I downloaded python 2.0 
  Windows&nbsp;Installer from the python.org web site. I am still having a 
  problem&nbsp;&nbsp;with the prompt screen closing too fast I can 
  even&nbsp;read what is says!&nbsp;&nbsp;<FONT color=#0000ff 
  face="Courier New"><SPAN 
  class=500491720-03062001>&nbsp;</SPAN></FONT></FONT></FONT></DIV>
  <DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff 
  face="Courier New"><SPAN 
  class=500491720-03062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV></BLOCKQUOTE>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>This seems to be common for beginners on 
windoze.</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>Try running the Python GUI(IDLE) instead of 
Python.</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>Or if you got the ActiveState version run 
Pythonwin.</SPAN></FONT></FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>Alternatively start a DOS box session and type 
python</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>at the C:&gt; prompt. That way the DOS box stays put 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>after your program runs so you see the 
output!</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>Somebody should really write up in detail how to start 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>a </SPAN></FONT></FONT></FONT><FONT size=2><FONT 
face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>program (and the interpreter) for non command-line 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>users.... I've been meaning to add it to my tutor 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>for months!</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>HTH,</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001>Alan g</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=500491720-03062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C0EC6A.13018890--


From alan.gauld@bt.com  Sun Jun  3 21:30:47 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 3 Jun 2001 21:30:47 +0100
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FD@mbtlipnt02.btlabs.bt.co.uk>

> A "csv" file is a file where all the fields as separated by 
> commas.  It's...
> I'm not quite sure what each of the letters stand for 
> though.  Comma Separated... Vormat?  

Values...

Alan G



From arcege@speakeasy.net  Sun Jun  3 22:09:07 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Sun, 3 Jun 2001 17:09:07 -0400 (EDT)
Subject: [Tutor] Saving and loading data to/from files
In-Reply-To: <F25cK8r6beUzmRf6Ci60000db18@hotmail.com> from "Daryl G" at Jun 03, 2001 08:20:03 PM
Message-ID: <200106032109.f53L97a01253@dsl092-074-184.bos1.dsl.speakeasy.net>

Daryl G wrote
> That was it, though I did have to do it a little differently.
> The way you showed didn't seem to work with lists, so I just converted each 
> individual part of a list into a String and then it  worked
> 
>    for i in range(total):
>       LN=L_Name[i]
>       FN=F_Name[i]
>       PH=PH_num[i]
>       print"%-15.15s %-15.15s %-s" % (LN, FN, PH)

Sorry, I hadn't quite gotten that they were lists (I haven't really been
feeling "with it" lately).

You might find it easier to keep things together.  Create tuples with
the information, then arrays of those tuples.
NameInfo = [
  ('Guido', 'van Rossum', '703-555-1234'),
  ('Eric', 'Idle', '212-555-5346'),
]
for i in range(len(NameInfo)):
  (FN, LN, PH) = NameInfo[i]
  print "%-15.15s %-15.15s %s" % (LN, FN, PH)

This will allow for keeping things together later, and for better
looping structures: `for (FN, LN, PH) in NameInfo:'


Alternatively, you could use a dictionary for records of "named" fields:
NameInfo = [
  {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'},
  {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'},
]
for record in NameInfo:
  print "%-15.15(last)s %-15.15(first)s %(phone)s" % record


Or maybe make a class:
class Record:
  def __init__(self, first, last, phone):
    self.first, self.last, self.phone = first, last, phone
  def __str__(self):
    return '%-15.15s %-15.15s %s' % (self.last, self.first, self.phone)
NameInfo = [
  Record('Guido', 'van Rossum', '703-555-1234'),
  Record('Eric', 'Idle', '212-555-5346'),
]
for record in NameInfo:
  print record

There are a lot of choices for you, but separate lists for each field
probably isn't a good one. :) (Incidently, the pickle and shelve modules
handle all these structures)

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From tescoil@irtc.net  Sun Jun  3 23:13:47 2001
From: tescoil@irtc.net (Tesla Coil)
Date: Sun, 03 Jun 2001 17:13:47 -0500
Subject: [Tutor] Random Words.
Message-ID: <3B1AB69B.DB3C37E1@irtc.net>

Way to read the file more efficiently if it were
larger? (/usr/share/dict/words has 45,424 entries;
I also have /usr/dict/words with 79,339 entries,
and /usr/dict/words.ott with 172,822).  

Where would be preferable to filter out undesired 
words?  Remove them from the list before choosing,
or, reject them if chosen and replace them?  I'm 
inclined toward the latter, but wonder if that's
best when there's fair chance of rejection, say,
refusing len(words) <=3 and >=9.

And just interested in any different approach...

#!/usr/bin/env python
# randword.py -- Quick and Dirty  
# return a list of random words.
import random

def readfile(lexfile):
    file = open(lexfile)
    lexlist = file.readlines()
    file.close()
    return lexlist

def choosewords(lexlist):
    randwords = []
    entries = len(lexlist)
    for iteration in range(20):
    	word = random.randint(0, entries)
	randwords.append(wordlist[word])
    return randwords	

wordsource = '/usr/share/dict/words'
wordlist = readfile(wordsource)
randlist = choosewords(wordlist)
for word in randlist: print word,




From tescoil@irtc.net  Sun Jun  3 23:15:29 2001
From: tescoil@irtc.net (Tesla Coil)
Date: Sun, 03 Jun 2001 17:15:29 -0500
Subject: [Tutor] Saving and loading data to/from files
References: <Pine.LNX.4.21.0106030126180.6190-100000@hkn.eecs.berkeley.edu> <3B1A162C.E897E397@irtc.net> <1A07617500E0@kserver.org>
Message-ID: <3B1AB701.38A6FCE1@irtc.net>

On 3 Jun 2001, Sheila King replied:
>> Comma Separated Variable, or,
>> Computer Spreadsheet Vomitus, 
>> depending on who you ask...
>
> I thought it was 
>
> Comma Separated Values

That's the real "depending on who you ask."
I'd say "Comma Separated Values" is more
popular and makes more sense, but "Comma
Separated Variable" was the answer received
first time I asked, and you'll get plenty
of hits searching the net for either phrase.



From rick@niof.net  Sun Jun  3 23:48:50 2001
From: rick@niof.net (Rick Pasotto)
Date: Sun, 3 Jun 2001 18:48:50 -0400
Subject: [Tutor] Random Words.
In-Reply-To: <3B1AB69B.DB3C37E1@irtc.net>; from tescoil@irtc.net on Sun, Jun 03, 2001 at 05:13:47PM -0500
References: <3B1AB69B.DB3C37E1@irtc.net>
Message-ID: <20010603184850.B29372@tc.niof.net>

How about:

import random,string,os
stat = os.stat('/usr/share/dict/words')
# the filesize if the 7th element of the array
flen = stat[6]
f = open('/usr/share/dict/words')
words = []
while len(words) < 5:
# seek to a random offset in the file
	f.seek(int(random.random() * flen))
# do a single read with sufficient characters
	chars = f.read(50)
# split it on white space
	wrds = string.split(chars)
# the first element may be only a partial word so use the second
# you can also make other tests on the word here
	if len(wrds[1]) > 3 and len(wrds[1]) < 9:
	   words.append(wrds[1])
print words

This uses minimal memory and I suspect is about as fast as you're
going to get.
	
On Sun, Jun 03, 2001 at 05:13:47PM -0500, Tesla Coil wrote:
> Way to read the file more efficiently if it were
> larger? (/usr/share/dict/words has 45,424 entries;
> I also have /usr/dict/words with 79,339 entries,
> and /usr/dict/words.ott with 172,822).  
> 
> Where would be preferable to filter out undesired 
> words?  Remove them from the list before choosing,
> or, reject them if chosen and replace them?  I'm 
> inclined toward the latter, but wonder if that's
> best when there's fair chance of rejection, say,
> refusing len(words) <=3 and >=9.
> 
> And just interested in any different approach...
> 
> #!/usr/bin/env python
> # randword.py -- Quick and Dirty  
> # return a list of random words.
> import random
> 
> def readfile(lexfile):
>     file = open(lexfile)
>     lexlist = file.readlines()
>     file.close()
>     return lexlist
> 
> def choosewords(lexlist):
>     randwords = []
>     entries = len(lexlist)
>     for iteration in range(20):
>     	word = random.randint(0, entries)
> 	randwords.append(wordlist[word])
>     return randwords	
> 
> wordsource = '/usr/share/dict/words'
> wordlist = readfile(wordsource)
> randlist = choosewords(wordlist)
> for word in randlist: print word,
>

-- 
When under the pretext of fraternity, the legal code imposes
mutual sacrifices on the citizens, human nature is not thereby
abrogated. Everyone will then direct his efforts toward
contributing little to, and taking much from, the common fund of
sacrifices. Now, is it the most unfortunate who gains from this
struggle? Certainly not, but rather the most influential and
calculating.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From gman_95@hotmail.com  Mon Jun  4 00:05:11 2001
From: gman_95@hotmail.com (Daryl G)
Date: Sun, 03 Jun 2001 23:05:11 -0000
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <F83GQvnbEG10Gai4omR00002e64@hotmail.com>

Whoever is "with it" on a Sunday? ;)
I originally had it set up as a dictionary, but when I was displaying them, 
it wasn't coming out right and I see why now.
I will eventually use classes, I'm just getting the basic functionality down 
first.

I was trying the dictionary example in a seperate script, but I get a 
traceback error

File "C:\Python20\dict.py", line 7, in ?
    print "%-15.15(last)s %-15.15(first)s %(phone)s" % record
ValueError: unsupported format character '(' (0x28)

Python ver 2.0

The tuple example works.
I like this one, but tuples aren't mutable, thats why I -reluctantly- chose 
lists when I couldn't get the dictionary to display how I wanted to. That 
way if say a phone number changes, I just need to edit the phone number and 
not have to delete that record and reenter it all in
But I'll implement that later


Cool!
Daryl


>From: "Michael P. Reilly" <arcege@dsl092-074-184.bos1.dsl.speakeasy.net>
>Reply-To: arcege@speakeasy.net
>To: gman_95@hotmail.com (Daryl G)
>CC: tutor@python.org
>Subject: Re: [Tutor] Saving and loading data to/from files
>Date: Sun, 3 Jun 2001 17:09:07 -0400 (EDT)
>
>Daryl G wrote
> > That was it, though I did have to do it a little differently.
> > The way you showed didn't seem to work with lists, so I just converted 
>each
> > individual part of a list into a String and then it  worked
> >
> >    for i in range(total):
> >       LN=L_Name[i]
> >       FN=F_Name[i]
> >       PH=PH_num[i]
> >       print"%-15.15s %-15.15s %-s" % (LN, FN, PH)
>
>Sorry, I hadn't quite gotten that they were lists (I haven't really been
>feeling "with it" lately).
>
>You might find it easier to keep things together.  Create tuples with
>the information, then arrays of those tuples.
>NameInfo = [
>   ('Guido', 'van Rossum', '703-555-1234'),
>   ('Eric', 'Idle', '212-555-5346'),
>]
>for i in range(len(NameInfo)):
>   (FN, LN, PH) = NameInfo[i]
>   print "%-15.15s %-15.15s %s" % (LN, FN, PH)
>
>This will allow for keeping things together later, and for better
>looping structures: `for (FN, LN, PH) in NameInfo:'
>
>
>Alternatively, you could use a dictionary for records of "named" fields:
>NameInfo = [
>   {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'},
>   {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'},
>]
>for record in NameInfo:
>   print "%-15.15(last)s %-15.15(first)s %(phone)s" % record
>
>
>Or maybe make a class:
>class Record:
>   def __init__(self, first, last, phone):
>     self.first, self.last, self.phone = first, last, phone
>   def __str__(self):
>     return '%-15.15s %-15.15s %s' % (self.last, self.first, self.phone)
>NameInfo = [
>   Record('Guido', 'van Rossum', '703-555-1234'),
>   Record('Eric', 'Idle', '212-555-5346'),
>]
>for record in NameInfo:
>   print record
>
>There are a lot of choices for you, but separate lists for each field
>probably isn't a good one. :) (Incidently, the pickle and shelve modules
>handle all these structures)
>
>   -Arcege
>
>--
>+----------------------------------+-----------------------------------+
>| Michael P. Reilly                | arcege@speakeasy.net              |

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From rick@niof.net  Mon Jun  4 00:20:53 2001
From: rick@niof.net (Rick Pasotto)
Date: Sun, 3 Jun 2001 19:20:53 -0400
Subject: [Tutor] Saving and loading data to/from files
In-Reply-To: <F83GQvnbEG10Gai4omR00002e64@hotmail.com>; from gman_95@hotmail.com on Sun, Jun 03, 2001 at 11:05:11PM -0000
References: <F83GQvnbEG10Gai4omR00002e64@hotmail.com>
Message-ID: <20010603192053.C29372@tc.niof.net>

On Sun, Jun 03, 2001 at 11:05:11PM -0000, Daryl G wrote:
> 
> I was trying the dictionary example in a seperate script, but I get a 
> traceback error
> 
> File "C:\Python20\dict.py", line 7, in ?
>     print "%-15.15(last)s %-15.15(first)s %(phone)s" % record
> ValueError: unsupported format character '(' (0x28)

Try:

print "%(last)-15.15s %(first)-15.15s %(phone)s" % record

-- 
When under the pretext of fraternity, the legal code imposes
mutual sacrifices on the citizens, human nature is not thereby
abrogated. Everyone will then direct his efforts toward
contributing little to, and taking much from, the common fund of
sacrifices. Now, is it the most unfortunate who gains from this
struggle? Certainly not, but rather the most influential and
calculating.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From tescoil@irtc.net  Mon Jun  4 01:35:52 2001
From: tescoil@irtc.net (Tesla Coil)
Date: Sun, 03 Jun 2001 19:35:52 -0500
Subject: [Tutor] Random Words.
References: <3B1AB69B.DB3C37E1@irtc.net> <20010603184850.B29372@tc.niof.net>
Message-ID: <3B1AD7E8.5CF59DFF@irtc.net>

On 3 Jun 2001, Rick Pasotto replied:
> This uses minimal memory and I suspect is
> about as fast as you're going to get.

That completely smokes!  I narrowed the criteria
to only words of 8 characters, tried it on a list
of around 235,000 entries--it still doesn't blink.



From gman_95@hotmail.com  Mon Jun  4 02:06:07 2001
From: gman_95@hotmail.com (Daryl G)
Date: Mon, 04 Jun 2001 01:06:07 -0000
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <F65vb5YI9IJsaJbqJGN0000c763@hotmail.com>

Ok, I figured out the dictionary problem
Change the print statement
for record in NameInfo:

    print "%-15.15s %-15.15s %s" % (record['first'], record['last'], 
record['phone'])

now I don't get that error, however I am having difficulty in figuring out 
how to add data to the dictionary.
This seems to be a sequence directory because of the brackets, correct? Plus 
in some of my attempts I get a TypeError loop non-sequence
Accessing the values inside is different then a non-sequence directionary.
Any insight?

Daryl





>From: "Michael P. Reilly" <arcege@dsl092-074-184.bos1.dsl.speakeasy.net>
>Reply-To: arcege@speakeasy.net
>To: gman_95@hotmail.com (Daryl G)
>CC: tutor@python.org
>Subject: Re: [Tutor] Saving and loading data to/from files
>Date: Sun, 3 Jun 2001 17:09:07 -0400 (EDT)
>
>Daryl G wrote
> > That was it, though I did have to do it a little differently.
> > The way you showed didn't seem to work with lists, so I just converted 
>each
> > individual part of a list into a String and then it  worked
> >
> >    for i in range(total):
> >       LN=L_Name[i]
> >       FN=F_Name[i]
> >       PH=PH_num[i]
> >       print"%-15.15s %-15.15s %-s" % (LN, FN, PH)
>
>Sorry, I hadn't quite gotten that they were lists (I haven't really been
>feeling "with it" lately).
>
>You might find it easier to keep things together.  Create tuples with
>the information, then arrays of those tuples.
>NameInfo = [
>   ('Guido', 'van Rossum', '703-555-1234'),
>   ('Eric', 'Idle', '212-555-5346'),
>]
>for i in range(len(NameInfo)):
>   (FN, LN, PH) = NameInfo[i]
>   print "%-15.15s %-15.15s %s" % (LN, FN, PH)
>
>This will allow for keeping things together later, and for better
>looping structures: `for (FN, LN, PH) in NameInfo:'
>
>
>Alternatively, you could use a dictionary for records of "named" fields:
>NameInfo = [
>   {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'},
>   {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'},
>]
>for record in NameInfo:
>   print "%-15.15(last)s %-15.15(first)s %(phone)s" % record
>
>
>Or maybe make a class:
>class Record:
>   def __init__(self, first, last, phone):
>     self.first, self.last, self.phone = first, last, phone
>   def __str__(self):
>     return '%-15.15s %-15.15s %s' % (self.last, self.first, self.phone)
>NameInfo = [
>   Record('Guido', 'van Rossum', '703-555-1234'),
>   Record('Eric', 'Idle', '212-555-5346'),
>]
>for record in NameInfo:
>   print record
>
>There are a lot of choices for you, but separate lists for each field
>probably isn't a good one. :) (Incidently, the pickle and shelve modules
>handle all these structures)
>
>   -Arcege
>
>--
>+----------------------------------+-----------------------------------+
>| Michael P. Reilly                | arcege@speakeasy.net              |

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From sarnold@earthling.net  Mon Jun  4 02:44:03 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Sun, 3 Jun 2001 18:44:03 -0700
Subject: [Tutor] command prompt HOWTO
Message-ID: <20010604014404.36F841F62A@shiva.arnolds.bogus>

Howdy:

I have (semi-coherent rambling) mini-HOWTO for running Python 
programs at the DOS and Linux command prompts.  It's got some 
environment stuff, examples, etc.

If I get some questions/feedback/flames I'll try and make the 
appropriate changes.  It's kinda long; should I post it to the list 
anyway?

Steve



From GADGILP@INFOTECH.ICICI.com  Mon Jun  4 04:47:55 2001
From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH)
Date: Mon, 4 Jun 2001 09:17:55 +0530
Subject: [Tutor] Re: [Python-Help] a number and control char stored in
 a single char. !
Message-ID: <718A0962DFC2D4119FF80008C7289E4701032D44@ICICIBACK3>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C0ECA9.238B6520
Content-Type: text/plain;
	charset="iso-8859-1"

hello,

daniel, u r a life saver! Thanks.

well what i meant when i said, i cant post to tutor list, is that, I was
posting 
from cybercafe, couldn't change sender's addr to my subscribed
id. I thought non subscribers can't post.

/regards
prasad


> -----Original Message-----
> From: Daniel Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
> Sent: Saturday, June 02, 2001 11:25 AM
> Cc: help@python.org; tutor@python.org
> Subject: [Tutor] Re: [Python-Help] a number and control char 
> stored in a
> single char. !
> 
> 
> On Fri, 1 Jun 2001, kaha aham wrote:
> 
> 
> > I am running & capturing screen output of a command using 
> os.popen as
> > helped by tuto@python.org ppl. However the value i capture which
> > should be a number like something like 22345 is displayed as
> > '22345\012'
> 
> Yes, this means that what you're getting back is the string "21345"
> followed by the newline, '\012'.  What you'll need to do is convert it
> with the int() function.
> 
> 
> 
> > I need to numerically compare this value later in program. I tried
> > slicing it to remove the last control char using var[:-1], 
> on which it
> > prints []. I then trid using len(), it tells size as 1 char. I tried
> > printing just 1st char using var[0], and it shows '22345\012'
> 
> Ah!  You had the right idea: what you'll want to do is:
> 
>     var[0][:-1]
> 
> instead.  You want to get all but the last character from var[0], your
> first line of the output.  This is probably what was 
> preventing you from
> converting to integer.  Try int()'ing with var[0][:-1], and 
> you should be
> ok.  But if you're converting with int(), you don't need to 
> strip out the
> newline character; int() knows how to deal with it already.
> 
> 
> Let's look at what happened before... I'm guessing that when you used
> os.popen(), you used the readlines() method to get at all the lines of
> output.  What this means is that "var" stands for all the 
> lines of input,
> and "var[0]" stands for the first line.  However, "var[:-1]" 
> stands for
> all but the last line --- but if your output only consists of 
> one line,
> that means you'll get the empty list, [].  That should 
> explain the weird
> error messages.
> 
> 
> > That's baffling me. How can it put all that number and 
> control char in
> > 1 char. I currently can't post to tutor maillist as I did earlier.
> 
> Hmmm... that's strange!  Try posting your question again; 
> perhaps the mail
> host was down.  In the meantime, I'll forward your message to
> tutor@python.org.
> 
> I just checked, and from what I can tell, you're not subscribed to the
> tutor list yet.  You'll probably need to subscribe to post to 
> tutor.  You
> can subscribe here:
> 
>     http://mail.python.org/mailman/listinfo/tutor
> 
> 
> If you run into difficulties again, feel free to email again. 
>  I'll talk
> to you later!
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


. 


------_=_NextPart_001_01C0ECA9.238B6520
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [Tutor] Re: [Python-Help] a number and control char stored in a single char. !</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>hello,</FONT>
</P>

<P><FONT SIZE=2>daniel, u r a life saver! Thanks.</FONT>
</P>

<P><FONT SIZE=2>well what i meant when i said, i cant post to tutor list, is that, I was posting </FONT>
<BR><FONT SIZE=2>from cybercafe, couldn't change sender's addr to my subscribed</FONT>
<BR><FONT SIZE=2>id. I thought non subscribers can't post.</FONT>
</P>

<P><FONT SIZE=2>/regards</FONT>
<BR><FONT SIZE=2>prasad</FONT>
</P>
<BR>

<P><FONT SIZE=2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt; From: Daniel Yoo [<A HREF="mailto:dyoo@hkn.eecs.berkeley.edu">mailto:dyoo@hkn.eecs.berkeley.edu</A>]</FONT>
<BR><FONT SIZE=2>&gt; Sent: Saturday, June 02, 2001 11:25 AM</FONT>
<BR><FONT SIZE=2>&gt; Cc: help@python.org; tutor@python.org</FONT>
<BR><FONT SIZE=2>&gt; Subject: [Tutor] Re: [Python-Help] a number and control char </FONT>
<BR><FONT SIZE=2>&gt; stored in a</FONT>
<BR><FONT SIZE=2>&gt; single char. !</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; On Fri, 1 Jun 2001, kaha aham wrote:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; I am running &amp; capturing screen output of a command using </FONT>
<BR><FONT SIZE=2>&gt; os.popen as</FONT>
<BR><FONT SIZE=2>&gt; &gt; helped by tuto@python.org ppl. However the value i capture which</FONT>
<BR><FONT SIZE=2>&gt; &gt; should be a number like something like 22345 is displayed as</FONT>
<BR><FONT SIZE=2>&gt; &gt; '22345\012'</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Yes, this means that what you're getting back is the string &quot;21345&quot;</FONT>
<BR><FONT SIZE=2>&gt; followed by the newline, '\012'.&nbsp; What you'll need to do is convert it</FONT>
<BR><FONT SIZE=2>&gt; with the int() function.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; I need to numerically compare this value later in program. I tried</FONT>
<BR><FONT SIZE=2>&gt; &gt; slicing it to remove the last control char using var[:-1], </FONT>
<BR><FONT SIZE=2>&gt; on which it</FONT>
<BR><FONT SIZE=2>&gt; &gt; prints []. I then trid using len(), it tells size as 1 char. I tried</FONT>
<BR><FONT SIZE=2>&gt; &gt; printing just 1st char using var[0], and it shows '22345\012'</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Ah!&nbsp; You had the right idea: what you'll want to do is:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; var[0][:-1]</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; instead.&nbsp; You want to get all but the last character from var[0], your</FONT>
<BR><FONT SIZE=2>&gt; first line of the output.&nbsp; This is probably what was </FONT>
<BR><FONT SIZE=2>&gt; preventing you from</FONT>
<BR><FONT SIZE=2>&gt; converting to integer.&nbsp; Try int()'ing with var[0][:-1], and </FONT>
<BR><FONT SIZE=2>&gt; you should be</FONT>
<BR><FONT SIZE=2>&gt; ok.&nbsp; But if you're converting with int(), you don't need to </FONT>
<BR><FONT SIZE=2>&gt; strip out the</FONT>
<BR><FONT SIZE=2>&gt; newline character; int() knows how to deal with it already.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Let's look at what happened before... I'm guessing that when you used</FONT>
<BR><FONT SIZE=2>&gt; os.popen(), you used the readlines() method to get at all the lines of</FONT>
<BR><FONT SIZE=2>&gt; output.&nbsp; What this means is that &quot;var&quot; stands for all the </FONT>
<BR><FONT SIZE=2>&gt; lines of input,</FONT>
<BR><FONT SIZE=2>&gt; and &quot;var[0]&quot; stands for the first line.&nbsp; However, &quot;var[:-1]&quot; </FONT>
<BR><FONT SIZE=2>&gt; stands for</FONT>
<BR><FONT SIZE=2>&gt; all but the last line --- but if your output only consists of </FONT>
<BR><FONT SIZE=2>&gt; one line,</FONT>
<BR><FONT SIZE=2>&gt; that means you'll get the empty list, [].&nbsp; That should </FONT>
<BR><FONT SIZE=2>&gt; explain the weird</FONT>
<BR><FONT SIZE=2>&gt; error messages.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; That's baffling me. How can it put all that number and </FONT>
<BR><FONT SIZE=2>&gt; control char in</FONT>
<BR><FONT SIZE=2>&gt; &gt; 1 char. I currently can't post to tutor maillist as I did earlier.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Hmmm... that's strange!&nbsp; Try posting your question again; </FONT>
<BR><FONT SIZE=2>&gt; perhaps the mail</FONT>
<BR><FONT SIZE=2>&gt; host was down.&nbsp; In the meantime, I'll forward your message to</FONT>
<BR><FONT SIZE=2>&gt; tutor@python.org.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; I just checked, and from what I can tell, you're not subscribed to the</FONT>
<BR><FONT SIZE=2>&gt; tutor list yet.&nbsp; You'll probably need to subscribe to post to </FONT>
<BR><FONT SIZE=2>&gt; tutor.&nbsp; You</FONT>
<BR><FONT SIZE=2>&gt; can subscribe here:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://mail.python.org/mailman/listinfo/tutor" TARGET="_blank">http://mail.python.org/mailman/listinfo/tutor</A></FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; If you run into difficulties again, feel free to email again. </FONT>
<BR><FONT SIZE=2>&gt;&nbsp; I'll talk</FONT>
<BR><FONT SIZE=2>&gt; to you later!</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; _______________________________________________</FONT>
<BR><FONT SIZE=2>&gt; Tutor maillist&nbsp; -&nbsp; Tutor@python.org</FONT>
<BR><FONT SIZE=2>&gt; <A HREF="http://mail.python.org/mailman/listinfo/tutor" TARGET="_blank">http://mail.python.org/mailman/listinfo/tutor</A></FONT>
<BR><FONT SIZE=2>&gt; </FONT>
</P>
<BR>

<P><B><FONT SIZE=2>.. </FONT></B>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C0ECA9.238B6520--


From r.b.rigilink@chello.nl  Mon Jun  4 07:40:39 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Mon, 04 Jun 2001 08:40:39 +0200
Subject: [Tutor] Saving and loading data to/from files
References: <F65vb5YI9IJsaJbqJGN0000c763@hotmail.com>
Message-ID: <3B1B2D67.7EF35199@chello.nl>

Hi Daryl,

Daryl G wrote:
> 
> Ok, I figured out the dictionary problem
> Change the print statement
> for record in NameInfo:
> 
>     print "%-15.15s %-15.15s %s" % (record['first'], record['last'],
> record['phone'])
> 
> now I don't get that error, however I am having difficulty in figuring out
> how to add data to the dictionary.
> This seems to be a sequence directory because of the brackets, correct? Plus
> in some of my attempts I get a TypeError loop non-sequence
> Accessing the values inside is different then a non-sequence directionary.
> Any insight?
> 

NameInfo is a list (sequence). Each element in this list is a
dictionary.

The trick is to know when you are dealing with the list, and when you're
dealing with an item (a dictionary in this case) in the list. Just some
examples to help you on your way:

Here a two-element list of dictionaries is build

NameInfo = [
    {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'},
    {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'}]

You can access a list-element by indexing with an integer, i.e the first
element with:

print "%(first)-15.15s %(last)-15.15s %s" % NameInfo[0]
Guido      van Rossum    703-555-1234

(Maybe you're surprised that the first item in a list has index 0. Think
of it as an offset)

You can add a new element using something like:

NameInfo.append({'first':'Basil', 'last':'Fawlty',
'phone':'111-222-33333'}

You can change an element by replacing it with a new dictionary  

NameInfo[0] = {'first':'Tim', 'last':'Peters', 'phone':'333-111-22222'}

You can also address items inside each dictionary, for example

print NameInfo[1]['first']
Eric

(i.e. get the second item in the list and from that item het the value
of 'first') 

Use that to add some info to a dict

NameInfo[2]['birth'] = '01 Apr 1933'   # Date of birth for Basil Fawlty


The summary:

Lists are indexed with integers.
Dictionaries are indexed with a key, which can be pretty much anything

List items are added using the_list.append(item)
Dict items are changed/added using the_dict[key] = value

if you have a list of dicts, you can access an item in a dict with

value = alist[index][key]

which is pretty much equivalent to

record = alist[index]
value = record[key]


Hope this helps,

Roeland Rengelink
-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From alan.gauld@bt.com  Mon Jun  4 11:17:17 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 4 Jun 2001 11:17:17 +0100
Subject: [Tutor] Lists...
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FE@mbtlipnt02.btlabs.bt.co.uk>

> > > def intersect_eas(L1, L2):
> > >     '''The easiest way for Alan G, requires nested_scopes'''
> > >     return filter(lambda x: (x in L2), L1)
> > 
> > How does it require nested scopes?
> L1 and L2 are not locals inside the lambda. They're only 
> visible with nested scopes.

Ah, of course. Although the lambda definition is inside 
the function the call to it isn't. Rats!

Alan G


From alan.gauld@bt.com  Mon Jun  4 11:38:02 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 4 Jun 2001 11:38:02 +0100
Subject: [Tutor] Lists...
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D7FF@mbtlipnt02.btlabs.bt.co.uk>

> > def intersect_eas(L1, L2):
> >     '''The easiest way for Alan G, requires nested_scopes'''
> >     return filter(lambda x: (x in L2), L1)

OK a version not requiring nested scopes...

def intersect(L1,L2):  
    return filter(lambda x,y=L2:(x in y), L1)

Still not fast tho'... :-)

Alan g.

PS I needed something similar for a web page that 
has to run on py 1.5.1 so nested scopes were no use to me...


From gman_95@hotmail.com  Mon Jun  4 14:07:03 2001
From: gman_95@hotmail.com (Daryl G)
Date: Mon, 04 Jun 2001 13:07:03 -0000
Subject: [Tutor] Saving and loading data to/from files
Message-ID: <F171vAauNjVuMhvqgSt0000b4b6@hotmail.com>

Thanks Roeland!
Thats what I needed.
I should have thought of that; NameInfo[0]['first']. Ah well, I was
working on this part late last night anyway

Thanks for everyones help!

Daryl



>From: Roeland Rengelink <r.b.rigilink@chello.nl>
>To: Daryl G <gman_95@hotmail.com>
>CC: tutor@python.org
>Subject: Re: [Tutor] Saving and loading data to/from files
>Date: Mon, 04 Jun 2001 08:40:39 +0200
>
>Hi Daryl,
>
>Daryl G wrote:
> >
> > Ok, I figured out the dictionary problem
> > Change the print statement
> > for record in NameInfo:
> >
> >     print "%-15.15s %-15.15s %s" % (record['first'], record['last'],
> > record['phone'])
> >
> > now I don't get that error, however I am having difficulty in figuring 
>out
> > how to add data to the dictionary.
> > This seems to be a sequence directory because of the brackets, correct? 
>Plus
> > in some of my attempts I get a TypeError loop non-sequence
> > Accessing the values inside is different then a non-sequence 
>directionary.
> > Any insight?
> >
>
>NameInfo is a list (sequence). Each element in this list is a
>dictionary.
>
>The trick is to know when you are dealing with the list, and when you're
>dealing with an item (a dictionary in this case) in the list. Just some
>examples to help you on your way:
>
>Here a two-element list of dictionaries is build
>
>NameInfo = [
>     {'first': 'Guido', 'last': 'van Rossum', 'phone': '703-555-1234'},
>     {'first': 'Eric', 'last': 'Idle', 'phone': '212-555-5346'}]
>
>You can access a list-element by indexing with an integer, i.e the first
>element with:
>
>print "%(first)-15.15s %(last)-15.15s %s" % NameInfo[0]
>Guido      van Rossum    703-555-1234
>
>(Maybe you're surprised that the first item in a list has index 0. Think
>of it as an offset)
>
>You can add a new element using something like:
>
>NameInfo.append({'first':'Basil', 'last':'Fawlty',
>'phone':'111-222-33333'}
>
>You can change an element by replacing it with a new dictionary
>
>NameInfo[0] = {'first':'Tim', 'last':'Peters', 'phone':'333-111-22222'}
>
>You can also address items inside each dictionary, for example
>
>print NameInfo[1]['first']
>Eric
>
>(i.e. get the second item in the list and from that item het the value
>of 'first')
>
>Use that to add some info to a dict
>
>NameInfo[2]['birth'] = '01 Apr 1933'   # Date of birth for Basil Fawlty
>
>
>The summary:
>
>Lists are indexed with integers.
>Dictionaries are indexed with a key, which can be pretty much anything
>
>List items are added using the_list.append(item)
>Dict items are changed/added using the_dict[key] = value
>
>if you have a list of dicts, you can access an item in a dict with
>
>value = alist[index][key]
>
>which is pretty much equivalent to
>
>record = alist[index]
>value = record[key]
>
>
>Hope this helps,
>
>Roeland Rengelink
>--
>r.b.rigilink@chello.nl
>
>"Half of what I say is nonsense. Unfortunately I don't know which half"

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From GBunting864@Worldsavings.com  Mon Jun  4 20:23:43 2001
From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x))
Date: Mon, 4 Jun 2001 14:23:43 -0500
Subject: [Tutor] ActivePython
Message-ID: <97E9FA3149D0D311BE5800008349BB27016463DF@ok1ems1.worldsavings.com>

What is the difference between ActivePython and the regular python from
www.python.org <http://www.python.org>  for windows?

Thanks 

Glen


*****************************************************************************
If you are not the intended recipient of this e-mail, please notify 
the sender immediately. The contents of this e-mail do not amend 
any existing disclosures or agreements unless expressly stated.
*****************************************************************************


From hall@phyast.nhn.ou.edu  Mon Jun  4 20:25:38 2001
From: hall@phyast.nhn.ou.edu (Isaac Hall)
Date: Mon, 04 Jun 2001 14:25:38 -0500
Subject: [Tutor] small (I hope) questions
Message-ID: <3B1BE0B2.5D744AF8@mail.nhn.ou.edu>

first, let me introduce myself a little as I am new to this list (but
I may well be widely known as the guy with all the dumb questions
soon...I hope not)  Ive just begun working with Python and Tkinter in
physics applications, and Im getting stuck in some fairly minor aspects
of this.  I have previously only programmed in C/C++.  anyway my
question(s) are:
    a) I am trying to produce a pie chart of just random numbers in a
list to get started with this, however Im confused as to how to call up
a canvas, and draw the chart.
    b) in addition to the pie chart, I also need to put these numbers in
a table (which I have figured out, however I would like to be able to
create this so that the pie chart comes up first, and then clicking on
the pie chart will display the table.

If anyone can help it would be greatly appreciated...my main problem is
in which commands do this, and their syntax, which I am not yet used
to...the logic part of this, I am so far ok with.



From dsh8290@rit.edu  Mon Jun  4 20:37:53 2001
From: dsh8290@rit.edu (D-Man)
Date: Mon, 4 Jun 2001 15:37:53 -0400
Subject: [Tutor] ActivePython
In-Reply-To: <97E9FA3149D0D311BE5800008349BB27016463DF@ok1ems1.worldsavings.com>; from GBunting864@worldsavings.com on Mon, Jun 04, 2001 at 02:23:43PM -0500
References: <97E9FA3149D0D311BE5800008349BB27016463DF@ok1ems1.worldsavings.com>
Message-ID: <20010604153753.C11144@harmony.cs.rit.edu>

On Mon, Jun 04, 2001 at 02:23:43PM -0500, Bunting, Glen, IG (x) wrote:
| What is the difference between ActivePython and the regular python from
| www.python.org <http://www.python.org>  for windows?

ActivePython comes with the win32all extensions and an IDE.  "Regular"
python is just the interpreter, and IDLE bundled up with it (a
simplistic IDE).

Personally, I use the interpreter shipped with cygwin in conjunction
with (g)vim.

-D



From mikebacks@yahoo.com  Mon Jun  4 20:48:21 2001
From: mikebacks@yahoo.com (Michael Bacayo)
Date: Mon, 4 Jun 2001 12:48:21 -0700 (PDT)
Subject: [Tutor] Help with Process Commands
Message-ID: <20010604194821.55492.qmail@web10402.mail.yahoo.com>

I want to learn how to use system(), spawnv(), and
spawnve() the right way. When I use this in a program
of mine, these commands seem to be inconsistent in the
manner that the arguments are sent to the called
program. Sometimes, you need to include the arguments
in the list or tuple with spaces before and after the
"'s and sometimes it's not need. The arguments are not
passed correctly to the called program if not written
a certain way.

Thanks!

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/


From rob@jam.rr.com  Mon Jun  4 20:56:21 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Mon, 4 Jun 2001 14:56:21 -0500
Subject: [Tutor] ActivePython
References: <97E9FA3149D0D311BE5800008349BB27016463DF@ok1ems1.worldsavings.com>
Message-ID: <002901c0ed30$6da1b060$de00a8c0@planhouse5>

> What is the difference between ActivePython and the regular python from
> www.python.org <http://www.python.org>  for windows?
>
> Thanks
>
> Glen
>

I'm sure someone can answer this better, but ActivePython comes with a
slightly different bundle including PythonWin, which is similar to IDLE. For
most purposes, there appears to be little difference, and I like both.

Rob

Useless Python
It's not just for breakfast anymore!
http://www.lowerstandard.com/python/index.html



From ak@silmarill.org  Mon Jun  4 21:04:56 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Mon, 04 Jun 2001 16:04:56 -0400
Subject: [Tutor] Help with Process Commands
In-Reply-To: <"from mikebacks"@yahoo.com>
References: <20010604194821.55492.qmail@web10402.mail.yahoo.com>
Message-ID: <20010604160456.A19445@sill.silmarill.org>

On Mon, Jun 04, 2001 at 12:48:21PM -0700, Michael Bacayo wrote:
> I want to learn how to use system(), spawnv(), and
> spawnve() the right way. When I use this in a program
> of mine, these commands seem to be inconsistent in the
> manner that the arguments are sent to the called
> program. Sometimes, you need to include the arguments
> in the list or tuple with spaces before and after the
> "'s and sometimes it's not need. The arguments are not
> passed correctly to the called program if not written
> a certain way.
> 
> Thanks!

Here's the os.system() syntax:

os.system('ls -al')

or
os.system('ls -a -l')

IOW, everything inside quotes is passed on to the shell for processing,
so you just use the command the way you'd type it in the shell.

Sometimes you will need to do this:

args = ' -al'
cmd = 'ls'
os.system(cmd + args)

or

args = [' -a',' -l']
cmd = 'ls'
os.system(cmd + args[0] + args[1])



-- 
Shine on you crazy diamond
        - Roger


From curtis.larsen@Covance.Com  Mon Jun  4 22:10:36 2001
From: curtis.larsen@Covance.Com (Curtis Larsen)
Date: Mon, 04 Jun 2001 16:10:36 -0500
Subject: [Tutor] De-CSV-ing?
Message-ID: <sb1bb310.017@madis2.truax.covance.com>

What would be the easiest (or simplest) way to convert a line from a CSV
file into a list or tuple?  Sure, you can use ".split(',')" to break the
line into a list -- that's the easy part.  For example, if each read
line in a CSV file were represented by string "s":

s = "1,2,3,5.5,3.95,dog,cat,ferret"
s1 = s.split(",")
s1 now equals ['1', '2', '3', '5.5', '3.95', 'dog', 'cat', 'ferret']

That's great as far as it goes -- you have each value as a
uniquely-addressable item again.  But is there an easy way to convert
the numbers-as-strings field values back to being numbers?  Also, how
would you handle a CSV file where the strings were actually delimited by
(double or single) quotes?  (e.g. the record would look like:
1,2,3,"dog","cat","ferret",7.95 )  Do you have to loop through each
value in each line, or is there an easier/faster conversion approach?

Thanks!
Curtis



-----------------------------------------------------
Confidentiality Notice: This e-mail transmission 
may contain confidential or legally privileged 
information that is intended only for the individual 
or entity named in the e-mail address. If you are not 
the intended recipient, you are hereby notified that 
any disclosure, copying, distribution, or reliance 
upon the contents of this e-mail is strictly prohibited. 

If you have received this e-mail transmission in error, 
please reply to the sender, so that we can arrange 
for proper delivery, and then please delete the message 
from your inbox. Thank you.


From ak@silmarill.org  Mon Jun  4 22:35:34 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Mon, 04 Jun 2001 17:35:34 -0400
Subject: [Tutor] De-CSV-ing?
In-Reply-To: <"from curtis.larsen"@Covance.Com>
References: <sb1bb310.017@madis2.truax.covance.com>
Message-ID: <20010604173534.A19943@sill.silmarill.org>

On Mon, Jun 04, 2001 at 04:10:36PM -0500, Curtis Larsen wrote:
> What would be the easiest (or simplest) way to convert a line from a CSV
> file into a list or tuple?  Sure, you can use ".split(',')" to break the
> line into a list -- that's the easy part.  For example, if each read
> line in a CSV file were represented by string "s":
> 
> s = "1,2,3,5.5,3.95,dog,cat,ferret"
> s1 = s.split(",")
> s1 now equals ['1', '2', '3', '5.5', '3.95', 'dog', 'cat', 'ferret']
> 
> That's great as far as it goes -- you have each value as a
> uniquely-addressable item again.  But is there an easy way to convert
> the numbers-as-strings field values back to being numbers?  Also, how

Yeah, int() and float(). If value isn't convertable, they raise exceptions.

> would you handle a CSV file where the strings were actually delimited by
> (double or single) quotes?  (e.g. the record would look like:
> 1,2,3,"dog","cat","ferret",7.95 )  Do you have to loop through each
> value in each line, or is there an easier/faster conversion approach?

Well, I guess one way is to see if the first and last characters are quotes
and then strip them.

for item in list:
    if item[0] == '"' and item[-1] == '"':
        item = item[1:-1]

> 
> Thanks!
> Curtis
> 
> 
> 
> -----------------------------------------------------
> Confidentiality Notice: This e-mail transmission 
> may contain confidential or legally privileged 
> information that is intended only for the individual 
> or entity named in the e-mail address. If you are not 
> the intended recipient, you are hereby notified that 
> any disclosure, copying, distribution, or reliance 
> upon the contents of this e-mail is strictly prohibited. 
> 
> If you have received this e-mail transmission in error, 
> please reply to the sender, so that we can arrange 
> for proper delivery, and then please delete the message 
> from your inbox. Thank you.
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
The point of philosophy is to start with something so simple as not
to seem worth stating, and to end with something so paradoxical
that no one will believe it.


From sarnold@earthling.net  Tue Jun  5 03:54:47 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Mon, 4 Jun 2001 19:54:47 -0700
Subject: [Tutor] small (I hope) questions
In-Reply-To: <3B1BE0B2.5D744AF8@mail.nhn.ou.edu>
Message-ID: <20010605025448.C4D9C1F62A@shiva.arnolds.bogus>

On 4 Jun 01, at 14:25, Isaac Hall wrote:

[snip]
> a) I am trying to produce a pie chart of just random numbers in
> a list to get started with this, however Im confused as to how to
> call up a canvas, and draw the chart. 
[snip]

Are you sure you want to code this yourself, as opposed to calling 
a graphics lib or using an external app?  I think the WXPython 
package comes with a basic plotting lib.  I know gnuplot works well 
with Python, and a windows version even comes with the ActiveState 
Python (gnuplot is standard on pretty much every Linux 
distribution).  I've only used gnuplot on Linux, and it works fine; 
I fired up the above windows version and it worked with the demos.  
The gnuplot syntax is pretty straightforward; there's an example on 
one of my cheesy screenshots below (the last one on the page):

http://arnolds.dhs.org/screenshots.html

If you have your data in an ASCII file (in column vectors) then 
from within gnuplot you could plot the second and third columns:

plot "this_file" using 2:3 with linespoints

I never tried a pie chart, but it shouldn't be too hard.

I also saw some cool visualization stuff at the last Python 
conference using VTK, but it's a commercial package (there may be 
something available for download).

Steve



From sarnold@earthling.net  Tue Jun  5 04:18:11 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Mon, 4 Jun 2001 20:18:11 -0700
Subject: [Tutor] command prompt HOWTO (long)
Message-ID: <20010605031811.707C11F62A@shiva.arnolds.bogus>

Howdy:

Judging from the lone response I got, I guess I've been expunged 
from the list, consigned to the bit-bucket, redirected to /dev/null 
8-o

Here it is, but it needs some work (some of the longer lines may 
get wrapped in transit).  I'm open to suggestions...

Python Command Prompt mini-HOWTO

Steve Arnold  06-03-2001
sarnold@earthling.net

Introduction

This is an introduction to running Python programs from the command
prompt in both DOS/Windows and X-Windows environments. You should be
familiar with using a basic text editor, creating and saving files,
knowing where they go when you save them, etc. Detailed info on
these topics can be found elsewhere on the web (and is beyond the
scope of this document). However, we will discuss some editing tips,
setting up your environment, and various ways to run Python
programs and capture the output.

The DOS Command Prompt

Most of my win32 experience is with Windows 9x and a little bit of NT4.
The main difference is that NT has a more useful NT command prompt,
as well as the DOS box, where you can actually set the size of the
scroll buffer (among other things), but they are very similar as
well. NT allows setting user-specific environment stuff, but 9x
requires a login profile on a server for this. We'll assume the
Windows box is not connected to a network in this case (except for a
dial-up Internet connection).

Setting up Your Environment

All programs run inside an environment of some kind, and in this
case there are both global settings and some that are specific to
the DOS-shortcut you start from. The easiest place to put your
global environment settings is in your autoexec.bat file. A DOS
batch file is just a text file (with a .bat extension) that contains
a sequence of DOS commands to run, and autoexec.bat is a special
batch file that runs when DOS starts up (and before Windows starts).
You should find autoexec.bat in the root of your C:\ drive (this
file was more widely used back in the Windows 3x days, so you may
not even have one). If you don't have one, just create one with a
text editor.

Tip: The basic Windows text editor is called Notepad.exe and is
really not good for much at all (it can't even load or work with
files bigger than 64k). Although you can use something like Word or
Wordpad to edit text files, I wouldn't recommend it. If you don't
already have some kind of programmer's editor, then here's the best
free one (and it's way better than Notepad):

http://www.winsite.com/info/pc/win95/misc/pfe101i.zip

It's called Programmer's File Editor, and although it's no longer
under development, the file above can be found on numerous ftp
archives. The website for PFE used to be here:

http://www.lancs.ac.uk/people/cpaap/pfe/

If you already have an autoexec.bat file, then just add some of the
settings below. Here is an example file, with each line explained
below (most non-Python stuff has already been removed):

************************  begin C:\autoexec.bat  ***********************

@C:\UTILS\NAV\NAVDX.EXE /Startup
SET PATH=%PATH%;C:\DOS_STUF;C:\USR\GNAT\BIN;C:\PYTHON20
SET ADA_INCLUDE_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components
SET ADA_OBJECTS_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components
SET HOME=C:\HOME\STEVE
c:\windows\command\doskey.com dird=dir /ad $*

************************  end C:\autoexec.bat  ***********************

Line 1: @C:\UTILS\NAV\NAVDX.EXE /Startup

This line is for Norton Antivirus for Win95. If you don't have it,
don't worry (but you should probably have some form of virus
protection).

Line 2: SET PATH=%PATH%;C:\DOS_STUF;C:\USR\GNAT\BIN;C:\PYTHON20

This line sets the path, which is where Windows looks for programs
to run when you type the program name at a command prompt. The
%PATH% is a variable that means "whatever the path was already set
to". The default path for Windows 9x is usually
"C:\windows;C:\windows\command" (notice that semicolons are used to
separate entries in the path) so my complete path would be:

PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\DOS_STUF;C:\USR\GNAT\BIN;C:\PYTHON20

To see what your path is, open a DOS prompt and type "set", which
will show all your DOS environment variables. The first two entries
above are where Windows and DOS programs reside, the DOS_STUF
directory is where I put some additional DOS programs, next is where
the GNU Ada compiler programs reside, and finally the DOS Python
tools. You need this if you want to call the Python interpreter from
anywhere on your hard drive.

Lines 3 & 4:

SET ADA_INCLUDE_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components
SET ADA_OBJECTS_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components

Extra junk telling the Ada compiler where to find things (this
should be phased out soon and stored in the registry instead).

Line 5: SET HOME=C:\HOME\STEVE

This is a handy way to set a home directory (where you can keep your
personal Python files, etc). It also helps with some programs that
look for this variable.

Line 6: c:\windows\command\doskey.com dird=dir /ad $*

If you want to have a command history in your DOS box, i.e., where
you can use the Up-arrow key to recall previous commands, then you
need to load this program (it comes with Windows).

So, unless you have other settings already in your autoexec.bat
file, the basic settings for running Python programs would be:

SET PATH=%PATH%;C:\PYTHON20
SET HOME=C:\HOME\STEVE
c:\windows\command\doskey.com dird=dir /ad $*

And don't forget to download the PFE editor above. If you installed
Python to a different directory than the default shown above, then
change it accordingly.

The default DOS prompt shortcut is on your Start Menu under Start ->
Programs -> MS-DOS Prompt. This is a special type of Windows
shortcut that points to command.com, and allows you to set several
other custom parameters for a given DOS session. I'd recommend
making your own shortcut for Python; you might want to put it with
the other Python menus (right-click on the Start menu and click
Explore). Once you've started your Python-DOS box, select the
Properties button on the toolbar at the top of the window. You
should see several tabs of configuration options, some of which can
make things more convenient. You may have noticed that your DOS box
opened in the C:\Windows directory (if it takes over your whole
screen, then press Alt-Tab to make a window). You can change this to
point to wherever you keep your working Python files. For example, I
would make a directory under my home directory above, such as:

C:\HOME\STEVE\SRC\PYTHON

Then on the Program tab in the MS-DOS Prompt Properties, I would
enter the above path for the "Working" directory. That way, this
particular DOS shortcut will always open in my Python source
directory. Feel free to use the Change Icon button to give your DOS
box a more appealing Python-esque icon (there are several .ico files
in the main Python directory). You don't really need to change
anything else, however, you may want to increase the Initial
Environment size on the Memory tab to at least 1024. You can also
play with the options on the Font tab to change the size of the
window/fonts. However, you can't increase the size of your scroll
buffer, so if the text output of your program scrolls off the top of
your screen, about the only options you have are to pipe the output
to the More command, or redirect it to a file (which we'll cover in
just a minute).

Running Python Programs

Start your customized DPS prompt and type "set" to check your
environment. You should see something like the following:

TMP=C:\WINDOWS\TEMP
TEMP=C:\WINDOWS\TEMP
PROMPT=$p$g
winbootdir=C:\WINDOWS
COMSPEC=C:\COMMAND.COM
ADA_INCLUDE_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components
ADA_OBJECTS_PATH=c:\usr\gnat\asis;c:\usr\gnat\POSIX\src;c:\usr\gnat\Booch\components
HOME=C:\HOME\STEVE
PGPPATH=C:\INTERNET\PGP
TZ=PST8PDT
DIRCMD=/O
BLASTER=A220 I5 D0 P300
windir=C:\WINDOWS
PATH=C:\USR\GNAT\BIN;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\DOS_STUF;C:\PYTHON20

Including the C:\PYTHON20 directory in your path allows Windows to
find both the DOS and win Python interpreters. For text-mode
programs, you would call the PYTHON.EXE interpreter like this:

C:\home\steve\src>python which.py pythonw.exe
\PYTHON20\pythonw.exe

The which.py program implements a version of the 'which' command
that looks for a program in your PATH (in this case PYTHONW.EXE). If
your program has more output than will fit on one screen, then you
can pipe it (the pipe symbol is above your backslash key) to the
More command, which will let you page down through the output one
screen at a time:

python which.py pythonw.exe|more

The other option is to redirect the output to a file (which will end
up in the current directory unless you specify a path):

python which.py pythonw.exe > output.txt

Starting PYTHON.EXE with no arguments will launch the Python
interpreter. If you double click on PYTHONW.EXE, you will see that
nothing (apparently) happens. PYTHON.EXE is the console version of
Python, and is useful when you want to see what Python writes to the
standard output. PYTHONW.EXE is the non-console version of Python,
and does not show a console window. You would normally use it to run
Python programs which create their own windows, programs running as
server processes, etc.

If you want to run a GUI program, then you would use PYTHONW.EXE
(you would probably want to write a short DOS batch file to start
your program). Most Python GUI programs you'll find floating around
require the TCL/Tk package (Tkinter under Windows) for creating the
windows, buttons, etc, however, more people are starting to use the
GTK-based WXPython package. Both TCL/Tk and WXPython programs should
run under both Linux/X-Windows and MS-Windows, provided you have all
required packages installed. More info on this as available on the
Python and ActiveState web sites:

http://www.python.org/

http://www.ActiveState.com/index.html

The Linux Command Prompt

One of the major differences between DOS/NT and Linux command
prompts (or shells) is that Linux/UNIX shells provide full-featured
scripting languages to use within the shell environment. There are
also several different shells to choose from such as the Bash shell,
C shell, and Korn shell. Most Linux distributions seem to default to
Bash, but you can always choose another. The syntax varies from one
shell to the next (although they seem to fall into two main camps)
so we will use the Bash shell syntax in the following examples.

Setting up Your Environment

Your Linux or UNIX environment should already be setup for you (for
the most part). You can see your environment variables as before, by
typing the 'set' command. You should see something like this:

[sarnold@ptolemy sarnold]$ set
BASH=/bin/bash
BASH_ENV=/home/sarnold/.bashrc
BASH_VERSINFO=([0]="2" [1]="04" [2]="11" [3]="1" [4]="release" [5]="i386-redhat-linux-gnu")
BASH_VERSION='2.04.11(1)-release'
COLORS=/etc/DIR_COLORS
COLUMNS=103
DIRSTACK=()
DISPLAY=:2.0
EUID=501
GROUPS=()
HISTFILE=/home/sarnold/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/home/sarnold
HOSTNAME=ptolemy
HOSTTYPE=i386
IFS=' 
'
INPUTRC=/etc/inputrc
KDEDIR=/usr
LANG=en_US
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=62
LOGNAME=sarnold
LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37...
MACHTYPE=i386-redhat-linux-gnu
MAIL=/var/spool/mail/sarnold
MAILCHECK=60
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/home/sarnold/bin
PIPESTATUS=([0]="0")
PPID=13536
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
PS1='[\u@\h \W]\$ '
PS2='> '
PS4='+ '
PWD=/home/sarnold
QTDIR=/usr/lib/qt-2.2.0
REMOTE_HOSTNAME=rama.arnolds.bogus
REMOTE_IPADDRESS=192.168.0.7
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:histexpand:monitor:history:interactive-comments:emacs
SHLVL=4
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
TERM=xterm
TZ=PST8PDT
UID=501
USER=sarnold
USERNAME=sarnold
VNCDESKTOP=X
WINDOWID=8388622
_=PATH
i=/etc/profile.d/which-2.sh
langfile=/home/sarnold/.i18n
sourced=1
mc=() 
{ 
    mkdir -p ~/.mc/tmp 2>/dev/null;
    chmod 700 ~/.mc/tmp;
    MC=~/.mc/tmp/mc-$$;
    /usr/bin/mc -P "$@" >"$MC";
    cd "`cat $MC`";
    /bin/rm "$MC";
    unset MC
}

As you can see, there's much more information here than in the 
previous example. Don't worry if you don't know what it all means 
(I certainly don't) but you can check your path to make sure it has 
the right directories in it. One slight difference though: DOS will 
look in the current directory for programs first, then the path, 
whereas Linux will not look in the current directory unless you 
explicitly add it to your path using the '.' notation (which is not 
a very good idea). If you want a place to put your working Python 
scripts (as well as shell scripts) then you should make a bin 
directory under your home directory (as above) and then add it to 
your path. To modify your personal path setting, as well as other 
shell settings, then you should edit your .bash_profile in your 
home directory (it starts with a '.' so it's hidden, like the DOS 
Hidden file attribute). Here is my modified .bash_profile:  

[sarnold@ptolemy sarnold]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="sarnold"

export USERNAME BASH_ENV PATH

Notice that in Bash syntax, you must first SET the variables, then
EXPORT them. Your Linux distribution should have come with Python
already installed, so you would probably find the Python interpreter
in /usr/bin. Use the 'which' command to locate it (you could also
try the 'locate' command, but you might have to create the locatedb
first if your machine doesn't run all night) like so:

[sarnold@ptolemy sarnold]$ which python
/usr/bin/python

You can run your python programs exactly the same way as under
Windows, except there's no distinction between running a text-mode
program or a GUI program. Of course, you need to be running X to run
most GUI programs, but that's beyond the scope of this HOWTO.




From cynic@mail.cz  Tue Jun  5 05:15:03 2001
From: cynic@mail.cz (Cynic)
Date: Tue, 05 Jun 2001 06:15:03 +0200
Subject: [Tutor] command prompt HOWTO (long)
In-Reply-To: <20010605031811.707C11F62A@shiva.arnolds.bogus>
Message-ID: <5.1.0.14.2.20010605053249.026df008@mail.cz>

At 20:18 4.6. 2001 -0700, Stephen L Arnold wrote:
>Howdy:
>
>Judging from the lone response I got, I guess I've been expunged
>from the list, consigned to the bit-bucket, redirected to /dev/null
>8-o
>
>Here it is, but it needs some work (some of the longer lines may
>get wrapped in transit).  I'm open to suggestions...
>
>Python Command Prompt mini-HOWTO

I think you should be more to the point -- strip anything not related
to python, namely stuff like this:

>Line 1: @C:\UTILS\NAV\NAVDX.EXE /Startup
>
>This line is for Norton Antivirus for Win95. If you don't have it,
>don't worry (but you should probably have some form of virus
>protection).

If I were looking for a quick guide to setting up my machine for Python,
and found a 14kB of stuff largely OT, I wouldn't be very happy.

<rant>

Well, hmm, I'd call this anything but _mini_-HOWTO. I think it's
actually pretty much of a _maxi_-HOWTO considering you're tutoring
people not how to _program_ (be it in Python or any other lingo), but
basic usage of their oh-so-friendly windows (linux) computers. As it is,
it should be called windows-and-linux-for-dummies-HOWTO

I don't want to sound sarcastic or something, but you could have
save yourself some time if you made it a true mini-HOWTO saying
"Read your Windows User's Manual" or "type 'man bash' (without
quotes)". :)

Or, if you prefer this longer version (windoze only):

"""If you had associated .py files with python.exe, and, upon double-
clicking foo.py file, a dos window (well, it's not a dos window, it's
a 32-bit console window) flashes on your screen, and disappears, your
options are:

win9x: create a batch invoking the foo.py program, and uncheck the "close
when finished" checkbox on the "program" card in its properties.

both win9x and NT: create a batch invoking another cmd instance with /k
switch, that will invoke your foo.py

both win9x and NT: start an instance of shell, and invoke foo.py from
there.
"""

using batches is the approach Perl has taken with it's standard programs,
and has the advantage that you can type just the name of the program
(sans extension), and have it executed. I seem to recall reading somewhere
in Perl's doc-set that it also has a disadvantage -- something about
command.com/cmd.exe being dumb enough about passing arguments, but dunno
what exactly it was.

I've only skimmed the Linux part, but it looked similar to the windows half.

Oh, BTW, I found a terrific set of win32 ports of common unix commands,
which, among others, contains which. :)) http://unxutils.sourceforge.net/

</rant>

an idea, maybe stupid:
what about a wrapper which would take care of the cmd x command /k
invokation? something you could import into your script, something that
would require one or two lines of code per use?
would this be possible with python?



cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
     - Book of Installation chapt 3 sec 7 



From ak@silmarill.org  Tue Jun  5 06:09:04 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Tue, 05 Jun 2001 01:09:04 -0400
Subject: [Tutor] command prompt HOWTO (long)
In-Reply-To: <"from cynic"@mail.cz>
References: <20010605031811.707C11F62A@shiva.arnolds.bogus>
 <5.1.0.14.2.20010605053249.026df008@mail.cz>
Message-ID: <20010605010904.A20631@sill.silmarill.org>

On Tue, Jun 05, 2001 at 06:15:03AM +0200, Cynic wrote:
> At 20:18 4.6. 2001 -0700, Stephen L Arnold wrote:
> >Howdy:
> >
> >Judging from the lone response I got, I guess I've been expunged
> >from the list, consigned to the bit-bucket, redirected to /dev/null
> >8-o
> >
> >Here it is, but it needs some work (some of the longer lines may
> >get wrapped in transit).  I'm open to suggestions...
> >
> >Python Command Prompt mini-HOWTO
> 
> I think you should be more to the point -- strip anything not related
> to python, namely stuff like this:
> 
> >Line 1: @C:\UTILS\NAV\NAVDX.EXE /Startup
> >
> >This line is for Norton Antivirus for Win95. If you don't have it,
> >don't worry (but you should probably have some form of virus
> >protection).
> 
> If I were looking for a quick guide to setting up my machine for Python,
> and found a 14kB of stuff largely OT, I wouldn't be very happy.

I'd like to second that - when I was learning linux ~3 years ago, this was
the major stumbling block for me - most of written help is overwhelming.
I think the problem is that when a large company like adobe or ms write
help, they take real-life dumb newbies and try various approaches to
see what works best. When it comes to linux online docs, those who write
them don't really understand what newbies need, so they either write terse
man pages, or get tired of getting frequently asked questions and just
write everything (we don't know what happened before big bang, but [...]).

It's sad how every newbie is disgusted by lack of good optimized for the common
case docs, and naively promises to himself to correct that as soon as he gets
the hang of things (i know i did), and then when he does, he no longer
remembers what would be helpful to him when he was a newbie.

-- 
True sailing is dead
        - Jim


From sarnold@earthling.net  Tue Jun  5 06:27:27 2001
From: sarnold@earthling.net (Stephen L Arnold)
Date: Mon, 4 Jun 2001 22:27:27 -0700
Subject: [Tutor] command prompt HOWTO (shorter)
In-Reply-To: <20010605010904.A20631@sill.silmarill.org>
References: <"from cynic"@mail.cz>
Message-ID: <20010605052727.E05EC1F62A@shiva.arnolds.bogus>

On 5 Jun 01, at 1:09, sill@optonline.net wrote:

> On Tue, Jun 05, 2001 at 06:15:03AM +0200, Cynic wrote:
[snip]
> > If I were looking for a quick guide to setting up my machine for Python,
> > and found a 14kB of stuff largely OT, I wouldn't be very happy.
> 
> I'd like to second that
[snip]

Okay, it lost 5k of non-Python specific stuff, but I'm having 
trouble figuring out what to cut next.  Anybody want to see the new 
version, or would it be too much clogging up your mailbox?

Steve



From r.b.rigilink@chello.nl  Tue Jun  5 07:09:33 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Tue, 05 Jun 2001 08:09:33 +0200
Subject: [Tutor] De-CSV-ing?
References: <sb1bb310.017@madis2.truax.covance.com>
Message-ID: <3B1C779D.78BB6D2B@chello.nl>

Curtis Larsen wrote:
> 
> What would be the easiest (or simplest) way to convert a line from a CSV
> file into a list or tuple?  Sure, you can use ".split(',')" to break the
> line into a list -- that's the easy part.  For example, if each read
> line in a CSV file were represented by string "s":
> 
> s = "1,2,3,5.5,3.95,dog,cat,ferret"
> s1 = s.split(",")
> s1 now equals ['1', '2', '3', '5.5', '3.95', 'dog', 'cat', 'ferret']
> 
> That's great as far as it goes -- you have each value as a
> uniquely-addressable item again.  But is there an easy way to convert
> the numbers-as-strings field values back to being numbers?  Also, how
> would you handle a CSV file where the strings were actually delimited by
> (double or single) quotes?  (e.g. the record would look like:
> 1,2,3,"dog","cat","ferret",7.95 )  Do you have to loop through each
> value in each line, or is there an easier/faster conversion approach?
> 

Hi Curtis,

How about this:

def float_it(item):
    '''try to change item to float, if that's not possible return item
itself'''
    try:
        return float(item)
    except ValueError:
        return item

line = "1,2,3,5.5,3.95,dog,cat,ferret"
items = line.split(',')
items = map(float_it, items)      # call float_it for each item
print items

gives

[1.0, 2.0, 3.0, 5.5, 3.9500000000000002, 'dog', 'cat', 'ferret']

Hope this helps,

Roeland

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From SBrunning@trisystems.co.uk  Tue Jun  5 09:21:14 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Tue, 5 Jun 2001 09:21:14 +0100
Subject: [Tutor] De-CSV-ing?
Message-ID: <31575A892FF6D1118F5800600846864D78BCCD@intrepid>

> From:	Curtis Larsen [SMTP:curtis.larsen@Covance.Com]
> What would be the easiest (or simplest) way to convert a line from a CSV
> file into a list or tuple?
 
Well, the usual way of decoding csv files is to use a finite state machine -
see
<http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?query=finite+state+machine>.
Don't worry, that aren't as complicated as this page makes them sound!

But before writing anything yourself, it's often worth seeing if anyone else
has written something useful. After all, csv file processing is pretty
common, so someone else is *bound* to have done this before.

The first place to look is the Vaults of Parnassus -
<http://www.vex.net/parnassus/>. Searching there for 'csv' takes me to a
link to the 'ASV' module.

Hmmm. The ASV page seems to be down. But the module can still be downloaded
- <http://tratt.net/~laurie/python/asv/releases/asv-0.4.tar.gz>. See here -
<http://www.google.com/search?q=cache:2bPuHjkjtk4:tratt.net/~laurie/python/a
sv/+Python+asv&hl=en&lr=lang_en> for google's cache of the ASV page.

Hope this helps...

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 karimy@nipltd.com  Tue Jun  5 09:35:58 2001
From: karimy@nipltd.com (Karim Yaici)
Date: Tue, 5 Jun 2001 09:35:58 +0100
Subject: [Tutor] small (I hope) questions
References: <3B1BE0B2.5D744AF8@mail.nhn.ou.edu>
Message-ID: <009c01c0ed9a$8b74ad80$a5020a0a@private.nipltd.com>

>     a) I am trying to produce a pie chart of just random numbers in a
> list to get started with this, however Im confused as to how to call up
> a canvas, and draw the chart.

Just to answer to this question. I have used sometime ago a library called
GDChart which allows the creation of charts (lines, pie...) as PNG,
GIF...which you can then used with GUI. I though you might find it useful.
Here is the link http://athani.pair.com/msteed/software/gdchart/

Cheers

Karim



From unsubscribe@virtualgamblinghouse.com  Tue Jun  5 10:19:40 2001
From: unsubscribe@virtualgamblinghouse.com (Orbital casino)
Date: Tue, 5 Jun 2001 11:19:40 +0200
Subject: [Tutor] Orbital casino
Message-ID: <200106050919.LAA03240@smtp.fol.nl>

This is a multi-part message in MIME format.

--orbitalcasino991732780
Content-Type: multipart/alternative;
	boundary="orbitalcasino991732780xx"

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

--------------------------------------
 $ 10 FREE - NO PURCHASE NECESSARY!!!
--------------------------------------

Orbital Online Casino offers new Players

-- $10 FREE - NO PURCHASE NECESSARY!--

All you have to do is download the FREE
software and open a Real Account. On top
of this great DEAL, they are offering
you a 100% First Purchase Bonus!!!!!
That`s right, whatever your first Deposit
into your Real account is, Orbital Online
Casino will match your purchase up to
$100!! See for yourself why Orbital Online
Casino is the SAFEST BET on the NET

           ::CLICK HERE::
http://www.virtualgamblinghouse.com

--------------------------------------
      To claim your FREE cash!!
--------------------------------------

If you no longer wish to receive further
e-mails from Virtualgamblinghouse, please
              reply to:
--unsubscribe@virtualgamblinghouse.com--
with the single word "unsubscribe" as the
subject of the message. Your name will
then be removed from our mailing list.

--orbitalcasino991732780xx
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: Base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9u
YWwvL0VOIj4KCjxodG1sPgo8aGVhZD4KCTx0aXRsZT5vIHIgYiBpIHQgYSBsICZuYnNwO28g
biBsIGkgbiBlICZuYnNwO2MgYSBzIGkgbiBvPC90aXRsZT4KPC9oZWFkPgoKPGJvZHkgYmdj
b2xvcj0iV2hpdGUiIGFsaW5rPSJCbGFjayIgdmxpbms9IkJsYWNrIiBsaW5rPSJCbGFjayI+
Cgo8dGFibGUgYm9yZGVyPSIwIiBjZWxscGFkZGluZz0iMCIgY2VsbHNwYWNpbmc9IjAiIHdp
ZHRoPSI2MDciPgo8dHI+Cgk8dGQgYWxpZ249ImNlbnRlciIgdmFsaWduPSJ0b3AiIHdpZHRo
PSIyMDAiIGhlaWdodD0iMzA2IiBiYWNrZ3JvdW5kPSJiZ18wMS5qcGciPjxicj48YSBocmVm
PSJodHRwOi8vd3d3LnZpcnR1YWxnYW1ibGluZ2hvdXNlLmNvbS9nby5odG1sIj48aW1nIHNy
Yz0ibG9nby5naWYiIHdpZHRoPSIxMzMiIGhlaWdodD0iNzIiIGJvcmRlcj0iMCI+PC9hPjwv
dGQ+Cgk8dGQgYmFja2dyb3VuZD0iYmdfMDIuanBnIiB2YWxpZ249InRvcCIgd2lkdGg9IjQw
NyI+IAoJPGltZyBzcmM9ImludmlzaWJsZS5naWYiIHdpZHRoPSI0MDAiIGhlaWdodD0iMTAi
IGJvcmRlcj0iMCIgPgogICAgICA8Zm9udCBmYWNlPSJUcmVidWNoZXQgTVMiIGNvbG9yPSIj
RkZENzFDIiBmb250IHNpemU9IjQiPjxiPiQgMTAgRlJFRSAKICAgICAgICAtIE5PIFBVUkNI
QVNFIE5FQ0VTU0FSWSEhITwvYj48L2ZvbnQ+PGJyPjxicj4KICAgICAgPHNwYW4gc3R5bGU9
ImZvbnQtc2l6ZTogMTJweDsgZm9udC1mYW1pbHk6IEFyaWFsLCBIZWx2ZXRpY2EsIHNhbnMt
c2VyaWYiPjxiPjxmb250ICBjb2xvcj0iV2hpdGUiPk9yYml0YWwgCiAgICAgICAgT25saW5l
IENhc2lubyBvZmZlcnMgbmV3IFBsYXllcnMgPGJyPgogICAgICAgICQxMCBGUkVFIC0gTk8g
UFVSQ0hBU0UgTkVDRVNTQVJZITxicj4KICAgICAgICA8L2ZvbnQ+PGJyPgogICAgICAgIDxm
b250IGZhY2U9IkFyaWFsLCBIZWx2ZXRpY2EsIHNhbnMtc2VyaWYiIGNvbG9yPSJXaGl0ZSI+
CgkJQWxsIHlvdSBoYXZlIHRvIGRvIGlzIGRvd25sb2FkIHRoZSBGUkVFIHNvZnR3YXJlIGFu
ZCBvcGVuIGEgPGJyPgoJCVJlYWwgQWNjb3VudC4gT24gdG9wIG9mIHRoaXMgZ3JlYXQgREVB
TCwgdGhleSBhcmUgb2ZmZXJpbmcgeW91IDxicj4gCiAgICAgICAgYSAxMDAlIEZpcnN0IFB1
cmNoYXNlIEJvbnVzISEhISEgVGhhdGBzIHJpZ2h0LCB3aGF0ZXZlciB5b3VyPGJyPiAKCQlm
aXJzdCBEZXBvc2l0IGludG8geW91ciBSZWFsIGFjY291bnQgaXMsIE9yYml0YWwgT25saW5l
IENhc2lubyA8YnI+CiAgICAgICAgd2lsbCBtYXRjaCB5b3VyIHB1cmNoYXNlIHVwIHRvICQx
MDAhISBTZWUgZm9yIHlvdXJzZWxmIHdoeSA8YnI+CiAgICAgICAgT3JiaXRhbCBPbmxpbmUg
Q2FzaW5vIGlzIHRoZSBTQUZFU1QgQkVUIG9uIHRoZSBORVQhPC9mb250Pjwvc3Bhbj48YnI+
CgkJPGZvbnQgZmFjZT0iQXJpYWwsIEhlbHZldGljYSwgc2Fucy1zZXJpZiIgIHNpemU9IjMi
IGNvbG9yPSJXaGl0ZSI+CiAgICAgICAgICAgPHNwYW4gc3R5bGU9ImZvbnQtc2l6ZTogMTZw
eDsiPlRvIGNsYWltIHlvdXIgRlJFRSBjYXNoLi4uPC9zcGFuPjwvYj48L2ZvbnQ+CgkJPHBy
ZT4gICAgICAgICAgICAgICAgICAgPGEgaHJlZj0iaHR0cDovL3d3dy52aXJ0dWFsZ2FtYmxp
bmdob3VzZS5jb20vZ28uaHRtbCI+PGltZyBzcmM9ImNsaWNraGVyZS5naWYiIHdpZHRoPSIx
ODUiIGhlaWdodD0iMzMiIGJvcmRlcj0iMCI+PC9hPjwvcHJlPgogICAgCgk8L3RkPgo8L3Ry
Pgo8L3RhYmxlPgo8dGFibGUgYm9yZGVyPSIwIiBjZWxscGFkZGluZz0iMCIgY2VsbHNwYWNp
bmc9IjAiIHdpZHRoPSI2MDciPgo8dHI+Cgk8dGQgd2lkdGg9IjE1Ij4mbmJzcDs8L3RkPgoJ
PHRkIHdpZHRoPSI1OTIiPgoJPGZvbnQgc2l6ZT0iMSIgZmFjZT0iQXJpYWwsIEhlbHZldGlj
YSwgc2Fucy1zZXJpZiIgY29sb3I9ImJsYWNrIj4KCUlmIHlvdSBubyBsb25nZXIgd2lzaCB0
byByZWNlaXZlIGZ1cnRoZXIgZS1tYWlscyBmcm9tIFZpcnR1YWxnYW1ibGluZ2hvdXNlLCBw
bGVhc2UgcmVwbHkgdG8gPGEgaHJlZj0ibWFpbHRvOnVuc3Vic2NyaWJlQHZpcnR1YWxnYW1i
bGluZ2hvdXNlLmNvbSI+dW5zdWJzY3JpYmVAdmlydHVhbGdhbWJsaW5naG91c2UuY29tPC9h
Pgp3aXRoIHRoZSBzaW5nbGUgd29yZCAidW5zdWJzY3JpYmUiIGFzIHRoZSBzdWJqZWN0IDxi
cj5vZiB0aGUgbWVzc2FnZS4gWW91ciBuYW1lIHdpbGwgdGhlbiBiZSByZW1vdmVkIGZyb20g
b3VyIG1haWxpbmcgbGlzdC48YnI+PC9mb250Pgo8L3RkPgo8L3RyPgo8L3RhYmxlPgo8aW1n
IHNyYz0iaHR0cDovL3d3dy52aXJ0dWFsZ2FtYmxpbmdob3VzZS5jb20vc3AuZ2lmIj4KCjwv
Ym9keT4KPC9odG1sPgoK
--orbitalcasino991732780xx--

--orbitalcasino991732780
Content-Type: image/gif;
	name="bg_01.jpg
"
Content-Transfer-Encoding: base64
Content-Location: bg_01.jpg


/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAGwAA/+4ADkFkb2JlAGTAAAAA
Af/bAIQAEQwMDA0MEQ0NERkQDhAZHRYRERYdIhcXFxcXIiEaHRwcHRohISYoKygmITQ0ODg0
NEFBQUFBQUFBQUFBQUFBQQESEBATFRMXFBQXFhIVEhYcFhgYFhwpHBweHBwpNSYhISEhJjUv
MisrKzIvOTk1NTk5QUFBQUFBQUFBQUFBQUFB/8AAEQgBMgDIAwEiAAIRAQMRAf/EAJsAAAID
AQEAAAAAAAAAAAAAAAIDAAEEBQYBAQEBAQEAAAAAAAAAAAAAAAEAAgMEEAACAQIEAgUIBAsH
BAMAAAAAAQIRAyExEgRBBVFhcRMGItKTs9NUlBaBoTJzkbHBQlJicqMUtDbRgiMzRBUl4VOE
NTR0JhEBAQACAQQBBAMAAwAAAAAAAAERAiExURIDQWGRMhNxIlKBoWL/2gAMAwEAAhEDEQA/
APVc753tOS7T+I3Hl3J1ViwnSd2a4LoS4vh20T8Ju/G/Pr95zsXY7O1lG1bhC5hV01Suxk26
dFF1E8b7y9f59d283/hbSMLdqKrT/EhG7KVK0q3KnYkeeJ200mM3l2/nDxL78/RWfZk+cPEv
vz9FZ9mcVEBvw17O184eJffn6Kz7Mnzf4l9+forPszjIuhH9evZ2fm7xL78/RWfZl/NviT35
+is+yOOiya/Vp2dj5s8R+/v0Vn2Ra8V+JPfn6Kz7I5CQcURnq0/y63zV4j9/l6Kz7Iv5o8R+
/wAvRWfZHLSQSQxfq07R0/mjxF7/AC9FY9kT5o8R+/y9FY9kc3STSOB+rTtHR+afEfv8vRWf
ZFfNPiP3+XorPsjnNAtDgfr07R0/mrxH7/L0Vn2RXzV4j9/l6Kz7I5lCUDC/Xp2jqLxT4jf+
vl6Kz7INeJvET/18vRWPZHKjEbGI4P69P8x0l4k8Q+/y9FY9kX8yeIff5eiseyOekRocQX16
f5jf8y+Iff5eiseyJ8y+Iff5eiseyOc0VQsQeGvaOj8zeIff5eiseyIc2hCxF4adof4x/qXf
dtr1Ns4p2vGP9S77tteptnFObOn4xCyiybi0ECgiai0EikEkTUWkNigYobFDI1laiFpLSDoa
kFoNJTQyhTQ4ZtLaBaGtAOJAuhKB0LUSwMqjEbGJUYjYxHByrSU0MoU0ILYDQxgNEg0IWyAT
fGH9S77tteptnGO34vVfEm+7bXqbRxlE5uek/rAlhaS9LLDQUgkglENRHCCkMjEKMGNjA1g5
DGI2MQlAbGA4WQRigtIxQC0EclaQXEe4guJIhxBaHOILiIK0lqIekJRIKjEYokjEYkSBQGQ1
oXJESmAw5AMlkLZCmQhlr8Vxr4j3/wC1a9TaOSrZ3fEsNXiHfv8AWteotHMVsxINPxjP3YSt
mhWwu7NYNZ42xitjVANQHALjbGRgMjAZGBIEYDYwQUYoYoki9JekYok0kSXEFoe0A0ByQ0C0
OkhbQwZBQtIuhaQpaQaRSQVAQWLmNYuaBESFyGyFyFilshGiEMux4gjXn/MP27fqLJg0HT56
q895h95b9RZMVC16RrT8YUolqAyhdBy0BRCUQlENRJYCohqJaiHGILCKISiWohqJEFCUG6UU
4IMopoW0OcaANEiZIW0PaAaEFULSCoRIgkUHQiQVAqA0LkhzQqSIM8hUkPkhUkLNKZAmiEHc
50q885h95b9RZMek383X/N8x+8t/y9kyaQnR00/GF0LUQ9JKDloKQSQSRaRJEgki0gkgS0g0
iJUyLJKoSgVCUBFtC2hzQDQwEtC2hzQDRAqhKBNF0FKSDSIohUCgDQqSHtYCpoomeSFyQ+SE
yQgpogTRCGHc5sq865j97b/l7Jmoa+aKvOuY/e2/5eyZ9JmdHT1/hP4BQtIPSSgtYDQJItRC
USysBSDUS1ENIFhEi1EJIugZAdJVA6EaBFtC2OaAkhBEkA0OkhbRpF6S0gqF0JKSLoWkFQAB
rAVND2hU0SZ5IVJD5IVJCzYS0QNogrDt8yX/ADPMfvbf8vYEUNPMF/zHMfvrf8vYE0MTo6ev
8J/AaFpIuhaQtqoWkFQJRDIUkEkWkEkGQiRdC0i0iQdJTQyhTRApoCSGtAtCiZJC2h0kA0SL
oRIJolCCJF0LSCoSLaFyQ9oXJCmaURUomiaFNEsEyRA2iCsOxv8A/wBxzL763/L2BVB2+/8A
ccy++t/y9gWYyfX+E/hVC6UKcmuAOqoWt4MTQSxyEttEjcpiGU0JBpAQnGS6xioOYzhaRdC1
QuhALRVAmgWSA0AxjAdBRbBcWVO7FN9Ap34dAZawNqmZEnnUBXYdhWumFcGWVg5IIUpINTq8
CyMLeQEkG2ukBjlYJkhUojpC5Dk4KlEgTIWVh09+6c45j99b/l7AvWksQebXlb5xzGubu28P
/HsmCW4cuJhj13+k/hsldVaoHv6MxO8+krvWTfk3vcJ5oXO7F4xVDH3pO96wWWyN6gXfPNt0
MPek70Bl1LW5aaxOgmmq9J5+3dbdDrbW7qtKvApcXDV5mWlsFsF3EC5o2wtsybq/GPkJ1fEL
c33bsylHPh9JyJXK1bZm34M45aJXXIHX1mZ3CtZZGWnvC1cZmWp5INQmyzDy0q7gMjeoZlbl
QBylHMsw3MbVdqTU3k/oMSvUCe4qIljU51AlIQ7tZV4cQXdGG2HORDO7hBGY1eIrmnn/ADBf
r23+4snP72iWBq8TSa8R79L9K16i0cyUjNctL/WNKvFO6uky6yKQNZaO8RfeYGZNtjoW5PsC
0zNMUm8hkbV2WSHbaxHBs6EIRSpQz5dnWaY6ubGxuM1HE620aVimTyfai40WRLkdSlpaTa4l
LzyLxLJKrvkV3tcFwxOdduXLU3CeDX4C9cpWJt+TFpNSbpqpXBdJ024mXPW5uDN9uoK1ojJS
k3jToOW7lRU7lZYOpo222dzypZcEc8/NaxdriKgpTeCNdvb8WOt2FFZDUjPll0mkn1oFbSJp
SDYDHJqN4C5RTCYDqOWaRdtPOOZmdxp0ZtkzHuYYa458TUrntFxu1TX0r6AXdM8J4vsf4gO9
OkcttmrvCGXvCDhnyrr+KpU8Rb7p1WvUWjj62zq+LHTxHvv2rXqbRxqnK9WtfxhlXSpIurBq
/oJiWWmy1GNOs0RrJxXCuZit3MKM3bfypR6Ezns7+vFb7MKU6B6BhSSGKJl0q0ySLS+oVc3N
mLo5qvQniORgrdW4yh3ji5yteVFLjxaeDqjj3tzO825fS8zua01Wpwt53Ubrdp+TLFx6GMue
Gd9cTM4z1KjTVidbbOkVTI40XijsbZeQn0luvT8tUasJ0WboZbm5uPyLa+kU4Xpr7dGZy6Yb
HOK4optM5zs3Yy/zGx1qVzJ4lkY+mGmQMkW9WbM9y8lmORdRSSFNJ4P6Su/tt5hOj8pGpWLG
HunC/LGkYeV/d6jC5qrplwOrfwuQmnRxTq6VwRxJzUpyklRNtpdCOmteX28YN1kE6iG3LL0P
i7+pN/22vU2jjnY8W/1Jvu216m0clHO9XbWcRVQo4sotIGj7dquNUdHbW5YKph20NTVXgdvb
24xgqPE57X4en1TjJkItJIY5qEdUvoByAm4Qep4tZGXTGVXFK7jOTUXlBPh1mG5trcZ6or66
jL73N1+S1CHXmxULVxySdyvUkX/Kx9GpRk7L08DnX7dmNqX6bxrxO1aWlZdpm3fLbd5OVl6J
/o/mtlBvzLxlw7KUrirlXE7duigkk8sGciFm5av93ci4yTxTOrZ4Duz6ZxQyU4/Yjnm2A++W
UYy622b1ai1V5gS2sGZdLju5s+/b8uMafq4MfYhOqbyNK2ttYtV62GopOiHIkxzlJRwOTOkr
kk06J0O01RUZzdxtmpuSVU8aCzZlle3hJVxTAjO5ZdG6rpDlbbdYTcJdDKcZOsZ0rwaNSudn
aYFckndg1ipcO05G+hbt7hwtR0RSVVjm8eOJ1VGu5jHhFJ/VU5vMIw/iZ0dHVprPJnTR5/f8
fyyEJQht53pfFv8AUe+7bXqbRyUq5HY8Vr/9Hv8A9q16m0ZdntLc4d7ebUMoxjnJnPa4y9Xq
0tkx2YtL6Aoo6q2u2fkq3KLeVXUGXL035OBjzjt+nZl28VqVFU7liuhJmK1t+6waxNsMlwMW
5rtrrjXk10Iku2mbB7SqtOiI4MVK0pX6id3FYpJPi8ilhn+EkrqSbII5NS0pVf4i1qT8pUMa
ncrri8Xw6gLt2/JUb0rqDJsaN2rE4Vk1rhipdHUZbEk8TDevSdYN4D9tJ6ajZwzrtPLEdFXU
hVzctvTDGXQJuSlpSjnLAu1SGWbzYN/PBsZTitUlUCe9awhB06UhjrJYGe5anwr9BRbTst71
pVlgy1uVcg5V+z9ZknZlXHLrDhbSjhxNYjEu2ejSoWrirTECdmMKcUxdubhLS/oHOacWmS68
sTlXey0rU8Fn0Iz8x21qcpXtLjOnlqLTo/0mh9t2o35TuTUdUpRgsat8TPvnch3luF9Sh+db
f2sc+H4jrrHj9tmMVymiFtEOjz4em8Vf1Fv/ANq16m0TZOMrFr9VtNdbK8Vf1Hv/ANq16m0Y
9luVYnSf2JZ9XWcd5nL2+jaSa5+Y7F+ShCkFWcsE+jrLs1l5M8WkqkTjJxk8cPJlwaDVuktS
eebZyeoXdxxaJSiwCrVYFMQGgSXEpfiI3gCVKTy6TPeuUelZsbKTzMm4tzuNODoyPMnByvWo
qjdX0LEqd+LX+W6dgqzDu1Fyi8XSeBrV63GCTtybVUnTNMlmuNu5xleSSp08DVZj5KaE8weu
9CatuEaKNXxoNsvyUjV6Ry1/PbJ7hVR6mJn38bsYR+zLBPrNEHWPYM0RklVdaa6TMrrZmdcK
jtL0o1dzFU+sY9luVFtSTo6Ix3NrenJuV6VHlnw7BVzabuK1Qv6upSaf1jx3Zt2nSU+7HcW3
SUK9axQjvYSrTB9BVrdb6D0XYyuLLHPHrAe3k7krsvJVcI8RxGfK3pn65EvKmgnKlX0ItQVu
GvOUsEFG25eQ+huRLFZu4uu1G5F6Xq8l9qz+o5tzb3E288T1Kt23bSivJXBmS7t4cF9J21vD
x+zTNy83K3NZoh17u2SyIay5+FbfFNuUvEG/kuErS/cWjjNNZqh6Xnsa895h95b9RZOdOzBx
bklRflOW239rHr9fqz69bL8M+y3t2w9H2oPg/wAh17e5jcg3CqklVwo5N9ijWoG32O2UU4wh
cgsJ3G3VvPyVT66jr22hbtucI9zKKajL9bL7Lrg+0xe7prmcW5AtypX5QTwjh9KG1Veo5VqT
hcerOWLp0m6FxUCumvMOkxbkU7guUwakG5fgBjj9HDqF6goVTr+ECfF1xRcm2qfUSMo58Q/J
EOXvoy7tvPS6gWJ1idG7oSxxT4HIco2r8oL7NcDU5mHLfjabd+G+DzHwdVRmKF1VRphKuTyM
2OmtlMnKcV0rpE99LJ5mjyKYsFwi8ViRK1VzWILoHJUzEXJ0KC3CNqUq/mxwXaJubqViVYKs
5LB9ATeUFmb9rZs37Hl24ypgsFjRvibkct7wxWt/ecNDSk+Lq012jqtwWNXRVqFHZWIXZPTF
0phV4Z/9C7uf4qLA6Rw37Mtx1VSEuKmJDTk63OaLnnMW/wDuW/UWTkXJO7OkVg3RI3eJrjhz
jmCWGq7aT7O4smTl61y1vBLLtOW05t+r1eq5001/8tNmxuLNpxgoxm3XXWskqZC3a3UqxnOq
nnTP8LN6xI4vgjDrJHIntZ2ZNxxTzTYUZypXgdCdmrquPBmae3cXqiu2JZ7rxx+JXfPiA764
4BuKZkvujohklZ22snVo/iYJ4sYt1DpOU1UBypkzXhHP920+HYluoxxTEy5gcxyk+JVSmkF9
+16cNt3fymszMpuVzU82LLWaNSSOd3tvNbIvANX52+sVGWBHIzh18sdKet4m8Q1vcMznza7G
Lqy8IP3bR03vYvrEy3Gp1/AYq9ZeofGC+3a9WyN3SnL85/Z/tOnyq7F2XbqlKNaPjR4/2nA1
dKCU1wquxjgeb0ytwinperpYi5HPqONbvXYNaLjw/NeWJrtb6VFG6ss5L+wYzeR3E+OJA5Ul
GsXVPFNENMY5N8UY87366Llt/uLInYySspLOtGafEdqc+e8wlFVSnaX7i0c2052bibTSqm0z
G8zl29O2JrbPjDuW4tqrGpIVCaphiMqzm9FU4oCUa4Ux4DHLpFSvQq03gsgUyVcsQuZ4Pp4n
O3GxuwepeXHp4nSe82zlpc1VDFplHB1/KXRWTbq85dwRmZ6DcbGxuG19i50r8px91sb22a1q
sXlJZM6a7R5/ZpZz1jMTgXRdP4C1GPSacsKVWx8bKzeYuCSlWtUMd+SwUQv0a1xOotLihcp1
wKldlLN4AZ8SkV27JRslCUZWIsrx6CVImy8H1EULVOihKULSJCUesZCMioo0W41NSM1dpXIZ
ZPgQ12raIawPJ2OcWpW+d7uM1T+I7u/af6UFbhZdOtSt49q6Tm33ajg8+hHsuc8pjzOxHRPu
t1Zq7F3gtVNUJrjGVFX6GsUeP3fKua7aei/s7snjpnYjLcW5JcU7cXJf3oxMXTNy6er3yaTX
t3Zo73usEtVMuwq5ze7VaYpJcAZbDfPLZbr4a97MW+Xcx9y3Xw97zA8J2a/f/wCoC7zPdXHg
1HsRmneu3HWcmzS+Wcx9x3Xw97zCnyzmfDY7r4e75heP0Zvsz12/7Y3Jo07bf3LK0yrKHQR8
q5p7huvh7vmAvlPNfcN18Pd8wrrn4E9mLmbT7tUeaQnOri1RYGTc7q5uMJvyVlHoLXKea1x2
G6+Hu+YX/tXNfcN18Pd8wJpj4avutmLtGKSowo4o1y5VzRr/AOBuvh7vmFR5VzVZ7DdfD3fM
HFYzrnrPuyPAtS6cTXLlXNHlsN18Pd8wr/aebe4br4e75hYq8p3n3ZWo0TjnxQNDauVc19w3
Xw93zC3yrmmf8Buq/wD17vmDijy17xixL7TX/tPNPcN18Pd8wv8A2rmnuG6+Hu+YWF5TvPuy
aegmk2LlfNPcN18Pd8wJcs5nx2O6+Hu+YWKfLXvPuyJF6KdhrXLeZe47r4e75gS5dzHjsd18
Pe8wcLy17z7s0Ymuzb6yLl/MV/od18Pe8wZDacyi8Nluvh73mGozbO8a7VvBEDsw3cUtez3S
/wDGv+zIaYzM9XvyEIZc0IQhJCEISQhCEkIQhJCEISQhCEkIQhJCEISQhCEkIQhJCEISQhCE
n//Z
--orbitalcasino991732780
Content-Type: image/gif;
	name="bg_02.jpg
"
Content-Transfer-Encoding: base64
Content-Location: bg_02.jpg


/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAGwAA/+4ADkFkb2JlAGTAAAAA
Af/bAIQAEQwMDA0MEQ0NERkQDhAZHRYRERYdIhcXFxcXIiEaHRwcHRohISYoKygmITQ0ODg0
NEFBQUFBQUFBQUFBQUFBQQESEBATFRMXFBQXFhIVEhYcFhgYFhwpHBweHBwpNSYhISEhJjUv
MisrKzIvOTk1NTk5QUFBQUFBQUFBQUFBQUFB/8AAEQgBMgGXAwEiAAIRAQMRAf/EALAAAAID
AQEBAAAAAAAAAAAAAAACAQMEBQYHAQADAQEBAAAAAAAAAAAAAAAAAQIDBAUQAAICAQEEBQcG
CQkIAwAAAAABAgMRBCExEgVBURPTBmEik1SUtBZxgZEy0hShY6NEdIQVJTZCYnIjM3OkRSax
wdFSQyQ1VeGiNBEAAgIBAgQDBAkEAwEAAAAAAAERAgMhEjFBUQSBUhNhkSJCcaHBMiNDY4MU
YpLCJHKCM0T/2gAMAwEAAhEDEQA/AMXxN4h9fl6Kjug+JvEPr8vRUd0c0NpcI6/Tp0R0/iXx
D6/L0VHdB8S+IfX5eio7o5mGGAhD9OnlR0/iXxB6/P0VHdB8S+IPX5+io7o5mCRQh+nTyo6f
xJ4g9fn6KjuiPiXxB6/P0VHdHODAQP06eVHR+JfEPr8vRUd0Q/E3iH1+XoqO6OfghollLFj8
qOh8T+IvX5eio7oj4n8Revy9FR3RzmiMEuS1hx+VHS+KPEXr8vRUd0R8U+IvX5eio7o5jRDQ
pY/QxeVHU+KfEXr8vRU90L8VeI/X5eip7o5mCGhSxehj8qOm/FfiP1+Xoqe6I+LfEfrz9FT3
Ry2hGOWRbDj8qOt8W+JPXn6Knug+LvEnrz9FT3Rx2iAlkelTyo7Pxd4k9efoqe6D4t8SevP0
VPdHGJCWNYqeVHZ+LfEfr79FT3QfFviT15+ip7o46AJY3ip5UdZ+L/Enrz9FT3Yr8Y+JV+fP
0VPdnKaK2ikZWx1XI678Z+JvXvyVPdi/Gnib178lT3ZxpIRjMGkdv418T5//AHfkqe7D418T
+vfkqe7OHgjAEHd+NfE/r35Knuw+NfE/r35KnuzhAAHe+NfE3r35KnuyV408TevP0VPdnAJQ
0B6BeMvEvrz9FT3Y68X+I3+fP0VPdHn0yyLGoGegj4r8RP8AP5eip7ouj4m8QP8AP5+io7o8
/CW41VSKSXQeh2V4i5+/8wn6OjuhviDxB/7Cfo6O6ObBrBYsF7a9A06Gx+IfEHr8/RUd0JLx
J4hX5/L0VHdGZorlDKDaugaGp+KPES/P5eio7oj4p8Revy9FR3Rz5wKmiHVAkjsR8T+IHv18
vRUd0XQ8Q8+l/mE/R0dycGLL654wS0a0rXmjvQ51zuW/mFno6O5Lo805y/8AMbfR6fuDkVTN
lciGdFcWNr7qN65hzl/5jb6PT9wbNH4h1emahzLhu02cPVxXBOtddsEuFrrlHGP+XG05sGsF
mAkHho1ER9B7LjhwdpxLgxxcefN4d+cgcDlL7fkGu0N3n1aVW6aO15dLqjZGPX5sbOH5sgM4
tvxbfbB4YjBIM0OwEgwBIhgAEgNACAMiGAAGQGiMCscjBLRaZW0QO0K0Qy0xcEMkgkbFaEaL
HgVoZFkVNEYLGhWgM2hQDAYARKJRCJEUiGhGtpYK0UmTapTJCNFskIypOW9dStkDNEYHJm0L
gMDYIwAoIDJJGAFAyY6ZWMmMC+MjRXMyRZdCRSY4N9cthfFmKuTNEZPcXuLVGXkMXLB5HuRf
psWayZ5xwzQ8iSWd4mxemzPjA0ZEuIu4hhEGuqzcjdVM5cJYNdNmTNo6Mdjq1S2F8TFTM1we
4k1OpyT/AMfzf++n7tQAck/8fzb++n7tQBXLwOD879z7Tw5DIyDZqbSTkMi5DIQNWHyGRMkp
igasNknInETkUFbhshkXJGQgNw+QyLkMhAKxIrRJBLRauK0Kx2K0Q0WrCsgGQJoJIwQ4jAIR
XgjBY0Q4jBoTBJOASEEEEMnBDAVkJJFbRYxGWmYXQhGBnvIGYwRgMEkjCBMEYLMCtAJoQlE4
IAlodMtgyhFkWOQUGytmqsxVSNtTCTqxJMvjHYPwEwWUWqDA6VRFLgI6jVwMHANRuiMUqimd
TOi4bCqytoJItiT4HPWz5i+ubixba2tokXgDnh1Z1KbMpG2qeTkUWcLwdGqe4zaN6s7/ACN/
u3m7/HT92pAXkb/dXN3+Nn7tSBXLwOH879z7Tw7BskjBsVJBBIAEhkABiKkMsnJAAOWTkMkA
ASySRSRBLJySQiQZaZDFaLBWiWi0ypkYLHERohoqRQJwBDKTDAYAkCkK4i8JbhEOIpHBXgVo
swK0EisipiNFkkVyLRzZBBSWQUc7YEihkZO4bIC5JyBW4GKySAJbBMeLEGW8BSaK5G6iWTmw
e010T2jg3xXSZ1qGnjJujWmc6l7DbVZJLG8ScHatVxL+xQdiitTn0PAK2xD3IpVfJjOn6RZa
fMWuklXy6ifvD6Y7OsNyYnWxzrqsNpmKcXGXCdjUKM/ORz76nJZW8mehGWkrhqUQlg6Gmt4k
kcxPDL6ZuMk/pCy0MKWh6nsOQv8Ac/N3+Ns92pAr5BJPkPN5fjLX/hqQD5fA5/zv3PtPHkMZ
oMGwxAwTgAGKBIMQyMAG0MCAADBOBjAAwAgJJQoyApEhgCcCZaFa2CNFuCGhNFJlLQuC1oRo
hoqRCUwaIIKTHTROwRMZMRcg0JJFgshBZ6FMkUyL5FMjSpy5GVsUZ7xSzmZAEhgDMgCScAAp
DQ2CGgAXaSmQ0AAWxZorlhpmRMurkMacHb0r4kjo1Vs5XLp5fD1HeoSwDRtXuWtBVSyHSzpQ
pUkmN93QbTRd4uZyXSxeyZ1npkI9MLazWveUZyZVMonU8HZlpWUW6bqFtZf8mj5nnNRVwTzj
CYsG8nV1Wkbi9m05XC4vD3opcDlvZK0o9Z4c/hrnH9O73aoCPDn8Mc4/p3+7VAIwn45/qk8x
5SGM0Q0amguCMDYARQuCBsBgAFwBOCBAQBIYAZAInAYAIAkMABSJJQEiKROCGSAikK0I4luB
WhNFIoaFaL3ERxIaGionJLQpJQ2SGxWyHIIFaxEmUyY8mVyLRzZGIxRmKyjBgAEgPaRklBgA
FtGIwRkOICXUHER7GPkWWGAiEWQeGVDxYAdLQ2cNsfKeo0rzFJHj6ZYw+o9Vy+ziri/IWRZH
d0mJRNSqRg0smpYW46KlsASQvYiukuyichI4Mrp8hXOhNbjcK4poAg4mooW1YPP6/T9lZxpe
bLYz2GqqWMrejh8x0/HVJY2718o4ErOdTV4c/hjnH9O/3aoCfDi/0zzhdPHev8PUBHM0PNtC
tFmBWjQ6IEaIwPgMCCCvAYHwHCKRwJwkYLMMjhCRwJgMD4DApKVSvBOB+EOEJHtFwGB+Fhwi
kraLgnA2ASFI0iMMlInAIJHAYIwMAhwVuIriXCSQhoolErki+RTPeTA2yplcmPIqbGkY3sRJ
iNkyYjKg57WDJGSGwyOCJGJSEyMpIRaY2AwSmhkhGsJleBWmXcJDiCYnjKGRllsoCOI5MrVa
FGiKTF7SjM01nouTW5qS6mebgzq8sucMoG9C8dNzVep62meGpHQhcmjz9WsWzLwb6r1KKaYq
3NL9ravI63aE8S6TnK7G5jrUS6ytyMXit0N2UTt6zGtR1liviOUTsfQe1OUWcrUV7JLqOm7o
43mLUYbb6wlEOrknkEFHk/N4dHbW/wD209LAt5Gv3dzdfjp+7UgTzL5HkmhWi1ohouTrgqwR
gscQwKRwVuO0MFmCOEUlbSvBPCPwhgUj2iYDA/CGBSUqiYDhGwGwJKgXhBIYBSEC4DAxASBA
AwCQAAyRxABORWDkJKQC3Cyewpkx5SKpSCDK1yubKpDyZWxwYWsJIRjsVgZsVi5JZAEkZJyQ
QA0x1NosjYinIZCC1kaNcZJjpJmNTa3Fkbush1N6Z68GXyhkqnAsjYmTLDQtTSyrZaGN7GC3
jWLEhUtpomcdkXVvadHQPE2jmwOhoP7RitwZt2v/AKI60Tr6CtzpTOPHoPQcnx93Weszx6s9
LuHFZgrlVZHdlFfHbHejpTsqlJxfQJKiMkbbVqcqyaLcuJhWpxvRZHUx6x56XO4zy07W4lp8
ituK3FGhXLeLKZk4JxfULbOcI5zuJli/i0fA7HJH+7+bv8dP3agCrkM2+T83n09rY/o01IFT
pPsOHZ+Ls/U2/XB51xI4SxkFydaRW4kYHZApKSFwRgkBDgXAEkANQBBOcEZEOSADJDYBIZDJ
GSMgKSSMkNiuSAUobJHELxIVzCBOyHchXIrcxHMIIdyxzElMRyEchwZ2uNKRXJkNitlGTsRL
eKwbFbESLIVjMXApCBWQNgVoBbQwGAySgFAuGQO0RwgIUMk4IABuJ9A8bWt5UAQilZrgPKWX
kEhCyLCAnqWRWDfoF57MUWbdDJKT8or8DbtnGRHViei5VBdhA81CS2nU0GvlVFRltj17zOmj
PTz130hHcs06eWZ51WQl5rwiIcwqmvrfMym7mShZwtZj1o2dqnHTHk4RMGiN7jsmvnLE6prf
kor1FFy2PeTOnpg8An0YOsP4ltGnp4sy6rTf1bwiztb69n1kXznx05a3oHzKq71snO5Mq8Pr
9yc3X4233aoBuQf+J5v/AH1vu9IE8vA5Z/2Z/W/yPOuRHGUuwhzKN9yLeJEcRT2hHaBAb0Xc
ZHEU8ZHGKA3ou4kRxFXGiOMIDei7JHEU9oR2gQG8uchXIqc2K5hAPIXOYrmUuZHEEEvIWuYr
mVOTF4hwQ8hY5kOZW5C8Q4JeQdyYrkK5C8QQQ7sdyFchWxXICZGchHIWUxHIUikfiIzkr4mC
kxDRalsJ4BYTyXRwyGzoxpNQVOArgaeBEOsSsaPDK0MriK0aXWVuBSZjbE0VpjbCHEXaUZOo
+ELwEqQyaYEtFTiQXOOSuUQFAo0RSyK3DAthu2mijKWxlCRqri1FIeg1PIuhdJbDr6VOUIvB
y9NU7LoQSzlnr9Py9RqWwapVmyz5K/MchrDIab3nTu0D6EY56Wcc4FbD0N6d6+DXiUJyi8xZ
tp5hOHm2ecusxuMo70QZ7LV4HQs+LIviOzXqKbekvnKHZYXUcFZW1fSWdvao4zsGrPWRPEm0
620OvyDH7K5v1dtZ7vSAnh9/uXm8vxtvu9QBy8Dhj/Yifzf8jxzsIdhn7QO0LgjcX9oR2hnd
gdoMNxfxhxmfjDtADczRxsjjKO0DjFAbmX8RHEU8QcQQg3MtcheIqciOINBbmW8RHEVcQcQB
LLOIjiK+MjiAUssbF4hHIVyCRajuRHGVuRGRSBY5CNi8RGRADZDJwHCAMXJBOCAESmWQsaKg
yEIdbOvA312Jl6SaOXGbjtRqp1CztMrU6Hdg7lcGaXUVSqNMJqSGcEzOWjs2VspRzpVsrcGd
GVPUUTqLVznydtzRiaIy0aJVlUomu44742gUyHtFewFLaMxYKLbLoRwCwPjcMUch6ocUl1dJ
sUEhtPQ1BZW1lzhjoFuOquBxMF/Kq395U0sqH+89fRepVracbk1FfZLpl0nUsoXD5u/rNa+w
xvWHwNDknvQjprnuMXFfW854kWQ1cc+esMepEE2aJPcjJbofIdGNyltTyh8xlvQ56i1OFLSz
iVWwnCOfIeglRCRi12mUam0JpNF1yWq9GT4elnw/ziX4y78GnqAXw5/DvOP7y/3eoDKNY9ot
z3bue7ceB4w4yniZOQEW8RHGVZYcQSMs4yeMq4iMsJEXcYcZVkOIUgXcZHEVcQcQxFnERxlb
kRlgA/GHEV5YZEElnGHEVZJTYDLOIUFljxhkGy61b0QhGDTGpYJ7EnejVYGzLgMGh1iOAKyE
8TRUngZbSHENwzJ1G4RXAdPI2BktGdogvlBFbjgBCBkMAAF9WocPkN9OpjNbzkjRnKLzFk2q
mdGHubY2uh3Nkls2iyrTMVGrexS2G6u2MjB0aPUxZ6ZF7SidJmsrwdNpNGa6CCrchmxJps5t
iwVpZZbb9YK49J0V4Hj5UlaBq4vBt0dDsnxP6sd5RVXKyXCt7OzRVGuCSW4V7xodHaYN73WX
woeMEkMquJpJEr8J1NDoJSh2s1jO75DOqbZ6WR1qviM9Mp6bzoj2c2vbXCsJb0y3V1qL4Fv6
TJ2GXg03NaHN6NLfEbKeZwl/aLhNKnTaspppnLlQ0tpQ+OEsxbWOotXfM579unwO06cbYNry
omNt0N+1HLq199bxLz0baeY0z2S81vrLV0Y2xNcDdVqIzko7VIo5rqo16ebb2tYRfT2UvOW0
43PrFmNcenzn8hWkGW1m7w4/9Nc4f8+9/wCHqAPDn8M84/p3+71AZc/EXM+dZZOWQNFCY0pB
ZDDHUCyNZMmlaNlGGGGaOzDsmLcV6LM2GG0vdYjgNWJeJlQDuJGByQ6i7Qwx8EYwMmBcMMMG
wyMRAEpZ3BjASBK2GippmcmMsMlqTSl9rOjCKZZwLBnouT2G2GGY2UHqYLVskZ5VFM62dDhR
VOvJEmtsSfA50oPJW0bJ1MonB5Na2OLLhako3DxmglHAhpJyWrBfvFlEWMyxNMZDRRKG0Ro1
NIrlDIySgB5QwJhiAMl9WonBlAA0nxKrZ1co61WrjJC33LGw51cmn5C/a9rJWNJnQ+8u6wJw
8Ty+kthByaillsFFtpLpOnpNOoJSf1mVZwtCMWN5LxyfEbSaZVLLXn9ZrRCNOi033ixJ7Ire
Ya2Z69VXHSFyNHLdE77VOa/q1+E9IoRrr2Lo2FOm09dcVw7Etxc3NeVG9KwednyvJbT5TmX6
eUpOTW3pJr0DUctbWdFOtvbjI8pwSKhTqL17aJHHv02FuMM6Nu47k3XbuZTLS5eUJ1RrTLHE
4kqCp1NM7VmlZmnp3kUM03VsZaNTOiHBjpMGstlfY5v5jfqK1FPyGCcMid2hegnLR3fDi/01
zhfz7vdqgG8Or/TvOF/Pu92qAc8zz4/Fj+uPrPnKHihcDxEKvEthE0QgU14NdSTM7HdhqnBC
qQOpF6iTw5M5OvYjK6clU6cHQ4RZQQ5JtiTRzJQwVSRutrwZZRNKs48uPaVEPaWKqUniKbfU
dLR+HeZatrggoRfTIs5LHI4SNx7PTeBcpPUah56VCOPws0vwJoWtllqfXlf8AlEHhEyHtPW6
vwLdBZ01/E/+WxY/DE87ruV63l8uHVVOCexT3xfzjkDJgFtDyEIBjwk4vKN+mvzg5uSyuTg8
rcTasm2HLallD0O3F5JcTLpr1JGtPJzusM9jHkrZJlU600ZrKjc4iShkJgq9EzmSgUyidCyo
zzrNK3OHLgiYMjRMZtbGPKIjiapnHejXEti0xsFEZNF0XkpGTRDiUygacFc8LeEEmfAKOSzg
cnt3FkYJbggBIV9Zcotkxg3uXzl8YJDgcC1w4du9muu/GxlGGa9Hy7Uaprgi1Dpk/wDcN1TL
pltj1RfVLtNxu08p0vij85dVyvsYrAs62nuI9GNUdlO8VvhsdKjmMJJJvD6maJ66FcHKT2I4
TQknJrDeUKbLkaLFjs06v6TvVaym5ZTLJ8Ti1F7GecjKUJZi8M6mj1ykuCzZLrGrzxQsmDbr
V6DOuyuXmNrJ0KZPhXE+J9LKpqNi2FP9bW9j2FcNTNvco5nRxCRVZp4qLaE09sprMo4x0i63
XQqreXt/kof0mapZW2o4vMZJT4FvOfJ//Bbda7Jym/5Rl1FqhByfzGFtWeinsqvoPR+HXnw9
zh/jLvd6gKfDMpfCnOJv63FqH/h6wL5Hkbvxt36k/WeDw0msLaETZZp8PJRKvbuAmICtm2lm
KMcGygiyOzt7ao0oYEhuCT3IyPQQmRJSL+wm+glaKb3ikVjn2ZluJ0+gtvmopfOdavly6UdT
SaeurDS2l1Zw5mHKuR0VJSnHMutnoqKq4JRikjDVYksGmFvSXJxvidCHCOkjHC0ujaImC6Vc
WYtZy+nUVSrtgpwlvi1lM2KaZLaaHIoPlniPw/LllvbUpy0s3jywfUzhZwfXeb6GvWaW2iaz
GyLXz9B8lug6rZ1S3wk4v5i05EJ0jKXWJ0kt5GNOC2FjreU9h0tNqFJI5Gegeq11y2bibVk6
MOd0tx+FnfTTBpMy6fUKSNaeTFqD1qXVlo/aVygmZ7KjbgSUSS2kzmTrZTOJ0LYoxWyjnC2m
lZOHuK0rxM7WBoSww4ZS8g0YJfKbVXU8+1lyG4m/kI4UWQqlY8RTeDXXy9vbY/mQO1UVTBku
9K+JijByeEssvhp3vkb46eEVhLGCJV4J3nQuya48TMoJbiY1uT4Yrib3JGiNTlJLdnZk9Jyz
Q6aqKaiuJrbI0q5McldpyuW8llOanqY4jvUf+J6vT6aqqtKMUktyIjCvGI/SHFKHlRcGDY86
4TWDHdpEalbFvfhjcS6dvlGScK7SyTbRmlCUXtR6OVMZrZ0mWzQ9LQQmXTJaj+E4nCLJ8Js1
VPZp9fUYeGe+RnbF0OzF3nKxr0+usrwpbYnSp1NNq37+g4eMjqThtTwSpRu1jya1PRTvqqqf
Qkjzmr1Lvtcnu/koW3VWWLgbykUOWzJNrtmmHCqOZCTwn5Dmaq7tJ8P8lF+rv4Vwr6z6DAFa
mHdZ/lTPZeGf4S5x/S1Hu9YEeGf4R5x8uo93rArmedzPM2GWZqtRlsEWxFvNdCMae016eRNk
b4XFjpVQya660ZKZG2uRi0ejW2hdCtdQ6ghYyHT2Cgi7kMDqeBMiSnhFI5cqNUbsdJfC/wAp
y+1wx43eUrU5HxOzC9dZohacWGoNMNSMDrRu8pbG5HLhqC6N4Cg132JxZ8l5q4y5lqpR+q7J
Y+k+hc35lDR6Ky1vzsNQXXJ7j5tNOU3KW1ttt+Vl1RLKyCxwI4GXAhCSeB9CJVcmKA8Sym2U
HsOhVrEt5z414LFEexM1pmvTgzovXVY3/QU2a6T+ovnZlUG9yLoaayXkF6deZt/Jz30RVOdl
m2Us+RCqJ0K+XrfJmmvTVQ2qK+V7WTuqtEVXtsuTWzObVpbZ7Uml1myrQQjtm+J9XQbEkh4w
lPZFN/MS72Z1Y+0x01stSqFUYrEVhdSH4fIbNPoLLZed5qO1puU6etJ4y+t7QVGzS+emM89D
S22bVHC6y1aDCy1k9O9JWtyM1unXQi1jS4mH8rceenRw+XqHo1l1Gx7Ym+6jGdhgtr34HMA6
Kx0K+ZVSWc4Yn7cqdnBt4f8An6DkTrZRKHQVvZz2wRMHqoWQtXFB7X0liulX9dZXWeb0OsnR
NQk/MZ367YXQWHnJasmc9sbRrhqa1tT29Ql/MdPGSrcvOfQc++l7eHYjNRGqu3isWZdGRwRB
1ZURteX07ii3RroRqompJODL5yhGO3eEvmScG/TqpZ3HI1Gr4ZOKN/OOYR4nVU8y6+o4Mm85
+kVoZpS9q8DZG9PpyJbqVGL2mOdij8vUVuTk8sz2qToXd2iBpTc5cUtrFQB5egNEc7cvXiey
8M/wlzj+lqPd6wF8MNfCHOH0Z1Hu9YCnmTz8Tzdq2vYZpxZutgZp1hBbMjWGW0zwyZVicLW4
cBWzTk6dFqxvNtdhwYSnF7zVVqZozdGdePuFGp3IT8pcpHHhrGWLXE7WaerXqdRyK5Mw/fhX
rMi2si16vmaJtpiqxoyy1LbEeoLSZz3qp0n3HSjb5S2F2Dj/AHvh3Ih8xsX1Y/SG0yh9Dvx1
HlE1HNqtPHzped0RW9nnrNbrLNilwrybDP8Ad7bHmUgVVzKWO74JlnMuY266zim8Qj9SC3Iw
4Na0Te1sn7ml0v8A2Fyh/wAfJ0MfCGEbPu8V0fhI7KK6ByJ4rLiZEvIOoS6jRwpEqI0Q6lKg
TwpGiOnvn9SEn8ieC2PLdXJf2bS8pSQtDJFtM1U2odcttX1tgfc3D5QtVs0x5fTcl8ZZGWSq
DUdjL1LZsMLUaZ6mLPW6XU2aCiu2XnrOGd6rSVKKwkvkPNU6idUsx2o2w5vdFrKXD1b2VVpE
5qZLOas68qo1vK6B4aqP1XsM1Otrvituc9A061Lai9Gcrryt7zW9TGCzJ4XWQr67V5rTOVdX
N79qKqrJ0zzviDcFrBVqU5Z0bqcowW0YydSmxWQzvyV30phEhS7q4Zw7K8GadZ1Lq8GOcCGj
prFlqYZQL9LrLNPLDeYhKBW6m9yBNmeTEmju06mq+K25LFpIWSzJ4j1Hn4OdT4ovDXQaFzec
IYazL8BqrHFfC09Ds330aOnOVGMd3Wee1nOdTdKSg+CHQlvMuq1VuolxWSb6l0GaTwG4h0a4
hKTbb3vpZVOxL5SJ2Y2La/8AYVikhhtbywAkUhABFOx4W7pCMXN8Md3SzXVUorC6DO9oR0Yc
Ls5Z6nw1DHhTnEP516+nTVgWeHF/prnC/n3e7VAE/BP9Jlt/G2/qR9ZwlTK1easCT0N29ROj
SoxOjVGuyKZqkJs8tZpLlvgzPKia/ktHsbNNW+gxW6avaVBEnl3CS6GWVpM612ngjHOMYsm1
TTHaLFcYjqK6xXNLcR2iMXVnfjvjfIs4E+kOzXWLCabw2dHTdnsyJVb5lWvjr8ph7FdbD7vF
9Z3eCprchHCCZWx9SFmxP5Tkw0Ln9WDZauVXP/pM7mmnVhG+E68LCGsftFbuKp6VR5b9l3r/
AKWA+4Wr+Tg9dw1yW4z21R6g9NDr3S8p5h6SxdGCuemkd+2vyGK2sNiNvUdkciVBTKrDOlZA
zWRGoOfJRsxOGDu8qo00oxbim+to48olmn1NmnnxJ7OlF1Zy3oz2MK6IpLGx/QNOitrYkc7R
a6F0Ft/4m+ubTS3ouTBqDHqNOuhHMvpxk9JOrjW4w36TeMR5uytorU5ReGda7SpbMGK2jHRj
Ami6XddUJGWRih+Yx42p7DG1D0MHdK2li+uydbTi8YOppeYqXm2bGcfOQUsEJup02rW6hnpv
MsWzbkz20Z+Q5mm186sKTyjrU6iu6OU95orSc1qWo9Puiae11SUZbug6GVOJknSpLYNQrY7M
eb1soi8PVC3U5yY56aUpYisnZxW15zKb9XpqI7Wl5OkIXMVMluCW45b0Tisz/AZrnXDZu8hZ
q+ZOxtVrEetnOlJt5b2mbslwOulbP7wWS4t24zyiWN+Uz3Xxj5X1EpuQyKiWos2llmWdnE8L
YusLJub27hDRHnZLy4RCRIE7t4MySIJjCVksLd1j10zs2v6prrqUcGV7xwOnFgdnrwFqpjFY
SL4xGUUMkYOzZ6FMaqei8Or/AE7zhfz7vdqgG8Pfw/zf+8t92qA6Py/+n2Hl/wD1fvf5HP4G
txp0smnhlf8AW+q6r2W/uyIu+Ms/dNV7Lf3ZtKMWzovajJfDeWw1EsedptUn+i6juhbLHJbN
Nqn+q6juhyupJydRF7Tl3tpncvrun9XSap/qt/dnOu0Guk/N0Wqf6td9gJXUDl8byCkapcr5
nnZodV7Pb9ghcr5r6hqvZ7fsENGtL9SjONw8brE8qTLf2XzT1DVez2/YD9mc09Q1Xs9v2CIO
hXrzsvebNNq5OKTZqlJtZyc2vQc0hLP3DVY/R7fsG+unXJYlotUv1a7uykZ2dU5TXvFjdOue
cnS0+r4ltZzp6bVvdo9V7Nd3YU06+uW3RarH6Nd3ZUidk1xR3qtRg0pqSORVO9LEtJql+q39
2badU4rEtPqvZNR3Q5JlLmiy2sxW1m6Wqqa/sdVn9E1PdGayxS3Uar2TUd0Jm+PNVcWjm21m
WyB0pxm92m1T/VdR3RnnTe92k1Xst/dkQb+rja+9X3nMnHaUyR0Z6XVvdo9V7Nd3ZTLRa57t
FqvZrvsDTMbunK1feZar7aZcVbx19R6LluvVsE5NZ6Thy0HMejQ6r2e77A1Om5tTNShodV5f
+3t+wWrHNZLqj2cdRDGWRLhmso4+m1OqUUrdHq4vp/7a9/7KzVDVTj+barH6LqO6KldTJoNR
U2cvUVPLOvLUxkv/AM+qz+iajujJdmX1dNqn+q6juhyuojiW1tZM0lw7Ude3T3yezSap/qt/
dmWei1j+rotV7Nd3YSuqGm5kyws6y1STIfL+Yb1otV7Nd9gI6PmS36HVez3fYMrVXJnZh7mN
LcBs9Ro01koTWJcKKlpeYeo6r2a77BP3XX+o6r2a77BEQzsWfHZQ71Xieho1Vah50vpEv5tp
4bIvil1I4fYcyxh6PV46vu932Bfuuu9S1Xs13dlO7gx2YJl3p/cjVfzS+zKi+CPkMcpuTzJ5
b6XtG+66/wBS1Xs132BJaXmWNmg1T/V7fsEPczZZMNVpeq8RXIqsvhFbX9BFmj5zLYuX6pL9
Ht+wUvlfN3v0Gq9nt+wNV6mV+8qlFWVWamct2xFDedpr/ZPNv/X6r2e37Afsnm3/AK/Vez2/
YKWhx2y2txZjwyUjX+yea7/2fqs/o9v2CY8p5q352g1SX6Pb9gGyUl5l7zHtexLLL6tPlpy3
myvlevh+Y6r2e77BdHQ67p0Wq9mu+wZWtZ8mdWKmJa2vSf8AkiiEMIsUS5aPXepar2a7ux1p
dZ6nqvZru7Mmrv5X7jrrkwpRvp/cilRY2C37trfU9V7Nd3Zv5d4d5jr5RlqIS0Wjb8+U/N1E
47dkIb4Z65YfkJVLNxDHbuMVVO+r+hybuQwlX4Z5lqJ+bVqHfbXJtba41Rq4vkzW8eTaB6T7
ppvun3Ls1917Psey6Oy4eDh+jYB1bfh2+yDyPU/F9SPn3/XJcAAUZgAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAH//2Q==
--orbitalcasino991732780
Content-Type: image/gif;
	name="clickhere.gif
"
Content-Transfer-Encoding: base64
Content-Location: clickhere.gif


R0lGODlhuQAhAMQQAHFvmJiWtEtIfMzL2vLy9rKxx4uJq+Xl7FhVhtjY42Vij6Wkvn58or++
0P///z47c////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ACH5BAEAABAALAAAAAC5ACEAAAX/ICSOZGmeaKqubOu+cCzPdG3feK7vfO//wKDIQSwaj8ik
cslsOp/QqHQKhREf2Kx2y+16v+CweEwum89kYsuBbrvf8Lhc7lix5/i8fs/v1lF3fYKDhIVe
fyaBhlsARABbAVdojQ6PaEQBi4uIJIqaWZSWWZGeZKFtmJ+GnEOqjI5bCACiZqeXDpmug6wQ
pXkCAQMDCwhctqABubELwgECxrDAyWm4CgXDxVzAwsRdyQAGA8pZBg0DBbR7vL5zCAdGBNmg
sFqkXAwERgnQlQ8DDgQUUEsA75kWAQSLBORC5J+DfVoKHDEgaJ2gBgAN4HNQ4FW/epK05EvA
gBRFLaEk/zo4OaZIAAAqWWKRSEAjwQMMiRxIsECLAUwAMDqQp8ciHwGpHgRoMO7BMSz2tDAg
IvBBgQIynRIRmjVMQyxIcW1JqoBeFp3PDGL5NyBLvqZ4jO55yi9d1FEhvVAqks6rWCxJsVAq
kIxUUyIdc4pL9q4tH7l66Hq0m1dpZX4AHTimpiyw1iSH/45Nsrlooj5lV2JB8FLtZ8qeSGUD
8NIjOiJdvwT2nJqBX7gP8vVcdbpP45lEXNO9uzrpO4jz+kk84BrMbtFY3jWAqrm65yzTnzVK
0HcOZD0/HewkMjw6bC4qE7xz4BtltLecz2K3rD7h9tHApUaAQ9T1cZ4eAeTDXn5dkFwmwAIK
dWVLJPG0JNp3SinIUXUPYCjYfJpV9Vhxg8zC4RsCzKKLMQCcSIYCABA1YgnsrGjjjZucUCOO
PPZoHiA+Binkj0AOaeSRLdmB5JJMnrXGjk1GqYoaL1Bh5ZVYZqnlllcK4eWXYIYp5phklmnm
mWimqeaabLb5ZQgAOw==
--orbitalcasino991732780
Content-Type: image/gif;
	name="invisible.gif
"
Content-Transfer-Encoding: base64
Content-Location: invisible.gif


R0lGODlhCgAKAIAAAP///wAAACH5BAEAAAAALAAAAAAKAAoAAAIIhI+py+0PYysAOw==
--orbitalcasino991732780
Content-Type: image/gif;
	name="logo.gif
"
Content-Transfer-Encoding: base64
Content-Location: logo.gif


R0lGODlhhQBIAOZ/APXHV7CxtJhuB9GqT+eqFu7Kd3WIr3Fwa7rE2al6CbWDCfPTiNWZC29R
B4aVseSlDseucCI1WvX08v735ujr83F6itXb5ixBbLW8yee0O9zh7OetIykrLJqt08/Iuq2S
TcyTC/bis//+/ExRWui4RfW5KkdTaHFlSeixK62ccBs1aoJ2U8TGyY5xKsWYKqm41vz58+7w
9a+li/PaoMTK1cSNCZmcn0Q3FfH0+V1rhbykZ8vU5+e8VPC9ROvr6tLW3P79+ZekvaaGOMq7
muTj4fX4/Nzc3M3S2++5OpiPdaayyIKEhdHS0lxiadyfDtirPkZBM/j4+PvEPvf394aKlnOQ
ydjUx/KyF8uUFODl8GJRJeXo7+/r4lNtpOSvMoReBdSbINXY3zBLgEddiaGsw/v9/8OeSK++
2/Hw7/f6/5SRhr/L4ZWAStDBnF1ECvz7+t3f4+bm5mRcR4ucv3hlNWp9pIU6a8/P0NjX1dbf
8L6JCeKhBjQ6Rdy6Zf///////yH5BAEAAH8ALAAAAACFAEgAAAf/gH+Cg4SFhoeIiYqLjI2O
j5CRkpOUlZaXmJmam5ydnp+goaKjpKWmp6ipqqusra6vsLGys7SjMhA8BTMACwsFAH0QtcOI
YwdCLhslUlIAADMhITPQMwsAFcTZfystXw1u4F8KKD0FIVzR1QBSA9q1TU0mF2KEdnYNDz3n
IUgbKBsPsLgzlaPCEjVJkhzIUUjMBUURhEQLUaAAgT1OQCiwM1DULWfMSojM8ETHkkcBds3Y
4OwBCD0JOHb0lOJXDyQlAO5h8LKGTwUHGqkBgGLlAwAksCgQIHPmJpsZUBBgUEOPgAY3OGjl
4EYLw0UppKBY0GMPAR4DFGhxuikF0gwb/6bC/OKGw0ND9Bb1QYKiAI+dWMwIMcE2E4S3cUEk
EPCFQ4RKSYiy5JExQYIVhTFBkELin0vLDThc4pHBC8seDGA2uJuZklseXggQcKKazyUdAEwT
yDAApgDbrSv16lWxwBCTlzwQ98XjyeIbKmB1gBNDwpTr2KdI8IGgCqEj1rNnj4IjzgtCHWAA
WQ9EhIgyaSQUmeLD0BwJFgihiSI+CnsRQPjhwQBX3YXAFFG8EYYifniixBt+wOBDHEZUWCER
PgSYRReDwOFHHHhYaCERcaDhhwgdDKKEHzj8EMaLL17ogx9vFOKAHwsOwgQRFobxAx4wvghH
AEI08NgfcwQIh/8Efpx3CAZ+YNAJBVEe0MQIWGaJ5RImnjHIESJUwIeWWZrQRAAiZDEIGUDQ
cMKbJ8hxQploxkCIAyL8QIiWZq6wApxvysFGC6IJsoMfTIxABYuIQCnlJgZIEMdXibDgBwuD
/CBCHYrkEMcUBggSQBkeKGDqYl9AQYgPEnAqCJ56HtKEDjNYYQZMCXzhDXB/GIAGqCqIgYcf
CDzpRwCcJHlHXomQ4ccdmYoQaiJj3CGCA3/kMEQaHoAhW2WEDULEFK7+ASsiffSBRhl9OFGD
ZY0RksWx4S4ahbHIbuIsDYyQIQITmQIxbSIWRBHqAW1wC8YDD/DUQiFvbMHhqyLkSIj/DAAg
oUMcRUCAa2iF+EHEGH/EoKalaxjiKCfOPqpIEM9GW+4hCADhAzYrbNstww4PgoAfz5JMcayD
HEbCBmZwUUQKi4FMCA4i2PCQpGPkgMYbQRQCZb6arOhyIh3ELMgPAidC5bGCsKHzwg0z8LAg
VNzxRo2DnDtIH1JE9YAZHOsgQF2G+GHEV/CI6gcFWovwNSb+YrqIs9COLW0iAcSA9h9CJLzz
A04woMAgF5gwrMt2R9YDCbEx8AEXaSRxwyH72XBIDh46KcjWnDgAROSKrOj4H2QPbEgES4iw
hSCZK8xww3o0QQgGZZAuwhF/HNaDF1LRJgQXZRzQ1CCHYsAa/yFi2HD4wLhv4gAMGjBCw6UB
C29IEmio+QcbmrPdMAhBDUKDCEqoWxmMoAMpXC8utEkAG+JAN0MAYQrYQEQOjOAHL90uSpyo
w4yKlYggMClrggjD5BAhhCXgAHHbSJgVSEACHriwBykYhAf9IDtBmI8IOojKbGqggMXQgQJp
OMQR/EADZh2CCu/B1h+gZLIsOPGJGojBDiYRAKCxCAc4iIEWtVgEoI1sEPNSoiGe0IA/lAEN
g2gDjSbAxjbCoAg46KLIhCaDNpSBCGa4Audw9YUbmMBEhzhRBBNhApTdTgRWTKQV0TgJG7AA
D2iQAJOsuB08BIBSf6CCDWY2iA/owf+GNfyDDLaAhi2acjs+uMMlx5AEHgAgCTZIggv2oBjQ
AMcGoRxEDnDZiAoEIIIVwKUwh4lLKlAiAlg6gJUqoExmXolXgohABMYniBSUQFV/kOYg6LAC
ZXrzm1YyAR8O0AcA9OAJQmiBAE6VqxscKZvvJMQ0G3GBCETnD/WUpj73qU1XqKEHD0CEHCwj
gIIa9CqCOMAAzKm3jODqb4X6g/OCYwkeSKEGiLgAFq7ghM69qwFQgMIKykmC0sSFJzx8zjuF
IAeKVgICPUBBQBGhhT1YxQ03GNMHeHATk84mNTXQiNME8QQBuLQSAIDLFT6QiJCOaQVmyIBI
/oFAnoCAKqn/0iUbNqAHah7VEX3oQVwIcAUdHKICK/jAAJAghRKgQDeco8pVQdCYCBCmAikg
wRX08LqvRqICSIALAeJSAhIMQAeIhUAfeIoTFDhWNjwDQQ06J4AbXIANT8hsCa5AAL76VRIf
iKlsZOOPHpj2tFFx7Fj3B4KrMqCyfFiBF0TCWZ4IAJufhcQAckIAhpF2A8ANLnC/5S49mMq4
feQDZjkbV9VENLePgOvyHtDb0X6LATwxLkEheoEWOIFnVUEVdL4H3Ua4QI/TXR52sSvZHm4X
p45pgQucgIWqLMUbWSFveRvRgqlYtbVUqYpx3csY+HLEDiZogIIVDI787rcSX7Cv/6kmTOCr
wDcC+rWDClRgT/0+OBJ2uEEDvnBQxtAlK1rx8IdBYQcO8IEDKOYDhldM4xrb+MY4NsQbXkAD
OxHCD2UQRIMGkYchgw8HhCiDH7zTpEFUwQ87sN0hFMfBQZTBB3kIGQICaOWUDQJoQi7E2aYw
CiBYMA/3GkQRqPSHBv5hB0UoxBqO92UqPTlFgniyBaqsYy8X4ngSKEQR+EWIGPC5CJb7Q5wH
QQEUhk0UOHCSBdxM5jOkwchvDiIhEIBCQZShAyvyA5575Yc5TOwQRZhiIfKAgzNUsBBkCPIg
DP20P6zhDWkWhAbs1wFNh2ILP7BAHArh44IRYgdTELXP2kg3CAmkaA3KznMUfsBnQ1AgDHAg
hATOs4ZO/8ECcPA2Bfjs4y2QmRBwgMMR6Jzjdrv73fCOt7znTe962/ve+M63vvfN7367IhAA
Ow==

--orbitalcasino991732780--


From unsubscribe@virtualgamblinghouse.com  Tue Jun  5 10:19:44 2001
From: unsubscribe@virtualgamblinghouse.com (Orbital casino)
Date: Tue, 5 Jun 2001 11:19:44 +0200
Subject: [Tutor] Orbital casino
Message-ID: <200106050919.LAA03253@smtp.fol.nl>

This is a multi-part message in MIME format.

--orbitalcasino991732784
Content-Type: multipart/alternative;
	boundary="orbitalcasino991732784xx"

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

--------------------------------------
 $ 10 FREE - NO PURCHASE NECESSARY!!!
--------------------------------------

Orbital Online Casino offers new Players

-- $10 FREE - NO PURCHASE NECESSARY!--

All you have to do is download the FREE
software and open a Real Account. On top
of this great DEAL, they are offering
you a 100% First Purchase Bonus!!!!!
That`s right, whatever your first Deposit
into your Real account is, Orbital Online
Casino will match your purchase up to
$100!! See for yourself why Orbital Online
Casino is the SAFEST BET on the NET

           ::CLICK HERE::
http://www.virtualgamblinghouse.com

--------------------------------------
      To claim your FREE cash!!
--------------------------------------

If you no longer wish to receive further
e-mails from Virtualgamblinghouse, please
              reply to:
--unsubscribe@virtualgamblinghouse.com--
with the single word "unsubscribe" as the
subject of the message. Your name will
then be removed from our mailing list.

--orbitalcasino991732784xx
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: Base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9u
YWwvL0VOIj4KCjxodG1sPgo8aGVhZD4KCTx0aXRsZT5vIHIgYiBpIHQgYSBsICZuYnNwO28g
biBsIGkgbiBlICZuYnNwO2MgYSBzIGkgbiBvPC90aXRsZT4KPC9oZWFkPgoKPGJvZHkgYmdj
b2xvcj0iV2hpdGUiIGFsaW5rPSJCbGFjayIgdmxpbms9IkJsYWNrIiBsaW5rPSJCbGFjayI+
Cgo8dGFibGUgYm9yZGVyPSIwIiBjZWxscGFkZGluZz0iMCIgY2VsbHNwYWNpbmc9IjAiIHdp
ZHRoPSI2MDciPgo8dHI+Cgk8dGQgYWxpZ249ImNlbnRlciIgdmFsaWduPSJ0b3AiIHdpZHRo
PSIyMDAiIGhlaWdodD0iMzA2IiBiYWNrZ3JvdW5kPSJiZ18wMS5qcGciPjxicj48YSBocmVm
PSJodHRwOi8vd3d3LnZpcnR1YWxnYW1ibGluZ2hvdXNlLmNvbS9nby5odG1sIj48aW1nIHNy
Yz0ibG9nby5naWYiIHdpZHRoPSIxMzMiIGhlaWdodD0iNzIiIGJvcmRlcj0iMCI+PC9hPjwv
dGQ+Cgk8dGQgYmFja2dyb3VuZD0iYmdfMDIuanBnIiB2YWxpZ249InRvcCIgd2lkdGg9IjQw
NyI+IAoJPGltZyBzcmM9ImludmlzaWJsZS5naWYiIHdpZHRoPSI0MDAiIGhlaWdodD0iMTAi
IGJvcmRlcj0iMCIgPgogICAgICA8Zm9udCBmYWNlPSJUcmVidWNoZXQgTVMiIGNvbG9yPSIj
RkZENzFDIiBmb250IHNpemU9IjQiPjxiPiQgMTAgRlJFRSAKICAgICAgICAtIE5PIFBVUkNI
QVNFIE5FQ0VTU0FSWSEhITwvYj48L2ZvbnQ+PGJyPjxicj4KICAgICAgPHNwYW4gc3R5bGU9
ImZvbnQtc2l6ZTogMTJweDsgZm9udC1mYW1pbHk6IEFyaWFsLCBIZWx2ZXRpY2EsIHNhbnMt
c2VyaWYiPjxiPjxmb250ICBjb2xvcj0iV2hpdGUiPk9yYml0YWwgCiAgICAgICAgT25saW5l
IENhc2lubyBvZmZlcnMgbmV3IFBsYXllcnMgPGJyPgogICAgICAgICQxMCBGUkVFIC0gTk8g
UFVSQ0hBU0UgTkVDRVNTQVJZITxicj4KICAgICAgICA8L2ZvbnQ+PGJyPgogICAgICAgIDxm
b250IGZhY2U9IkFyaWFsLCBIZWx2ZXRpY2EsIHNhbnMtc2VyaWYiIGNvbG9yPSJXaGl0ZSI+
CgkJQWxsIHlvdSBoYXZlIHRvIGRvIGlzIGRvd25sb2FkIHRoZSBGUkVFIHNvZnR3YXJlIGFu
ZCBvcGVuIGEgPGJyPgoJCVJlYWwgQWNjb3VudC4gT24gdG9wIG9mIHRoaXMgZ3JlYXQgREVB
TCwgdGhleSBhcmUgb2ZmZXJpbmcgeW91IDxicj4gCiAgICAgICAgYSAxMDAlIEZpcnN0IFB1
cmNoYXNlIEJvbnVzISEhISEgVGhhdGBzIHJpZ2h0LCB3aGF0ZXZlciB5b3VyPGJyPiAKCQlm
aXJzdCBEZXBvc2l0IGludG8geW91ciBSZWFsIGFjY291bnQgaXMsIE9yYml0YWwgT25saW5l
IENhc2lubyA8YnI+CiAgICAgICAgd2lsbCBtYXRjaCB5b3VyIHB1cmNoYXNlIHVwIHRvICQx
MDAhISBTZWUgZm9yIHlvdXJzZWxmIHdoeSA8YnI+CiAgICAgICAgT3JiaXRhbCBPbmxpbmUg
Q2FzaW5vIGlzIHRoZSBTQUZFU1QgQkVUIG9uIHRoZSBORVQhPC9mb250Pjwvc3Bhbj48YnI+
CgkJPGZvbnQgZmFjZT0iQXJpYWwsIEhlbHZldGljYSwgc2Fucy1zZXJpZiIgIHNpemU9IjMi
IGNvbG9yPSJXaGl0ZSI+CiAgICAgICAgICAgPHNwYW4gc3R5bGU9ImZvbnQtc2l6ZTogMTZw
eDsiPlRvIGNsYWltIHlvdXIgRlJFRSBjYXNoLi4uPC9zcGFuPjwvYj48L2ZvbnQ+CgkJPHBy
ZT4gICAgICAgICAgICAgICAgICAgPGEgaHJlZj0iaHR0cDovL3d3dy52aXJ0dWFsZ2FtYmxp
bmdob3VzZS5jb20vZ28uaHRtbCI+PGltZyBzcmM9ImNsaWNraGVyZS5naWYiIHdpZHRoPSIx
ODUiIGhlaWdodD0iMzMiIGJvcmRlcj0iMCI+PC9hPjwvcHJlPgogICAgCgk8L3RkPgo8L3Ry
Pgo8L3RhYmxlPgo8dGFibGUgYm9yZGVyPSIwIiBjZWxscGFkZGluZz0iMCIgY2VsbHNwYWNp
bmc9IjAiIHdpZHRoPSI2MDciPgo8dHI+Cgk8dGQgd2lkdGg9IjE1Ij4mbmJzcDs8L3RkPgoJ
PHRkIHdpZHRoPSI1OTIiPgoJPGZvbnQgc2l6ZT0iMSIgZmFjZT0iQXJpYWwsIEhlbHZldGlj
YSwgc2Fucy1zZXJpZiIgY29sb3I9ImJsYWNrIj4KCUlmIHlvdSBubyBsb25nZXIgd2lzaCB0
byByZWNlaXZlIGZ1cnRoZXIgZS1tYWlscyBmcm9tIFZpcnR1YWxnYW1ibGluZ2hvdXNlLCBw
bGVhc2UgcmVwbHkgdG8gPGEgaHJlZj0ibWFpbHRvOnVuc3Vic2NyaWJlQHZpcnR1YWxnYW1i
bGluZ2hvdXNlLmNvbSI+dW5zdWJzY3JpYmVAdmlydHVhbGdhbWJsaW5naG91c2UuY29tPC9h
Pgp3aXRoIHRoZSBzaW5nbGUgd29yZCAidW5zdWJzY3JpYmUiIGFzIHRoZSBzdWJqZWN0IDxi
cj5vZiB0aGUgbWVzc2FnZS4gWW91ciBuYW1lIHdpbGwgdGhlbiBiZSByZW1vdmVkIGZyb20g
b3VyIG1haWxpbmcgbGlzdC48YnI+PC9mb250Pgo8L3RkPgo8L3RyPgo8L3RhYmxlPgo8aW1n
IHNyYz0iaHR0cDovL3d3dy52aXJ0dWFsZ2FtYmxpbmdob3VzZS5jb20vc3AuZ2lmIj4KCjwv
Ym9keT4KPC9odG1sPgoK
--orbitalcasino991732784xx--

--orbitalcasino991732784
Content-Type: image/gif;
	name="bg_01.jpg
"
Content-Transfer-Encoding: base64
Content-Location: bg_01.jpg


/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAGwAA/+4ADkFkb2JlAGTAAAAA
Af/bAIQAEQwMDA0MEQ0NERkQDhAZHRYRERYdIhcXFxcXIiEaHRwcHRohISYoKygmITQ0ODg0
NEFBQUFBQUFBQUFBQUFBQQESEBATFRMXFBQXFhIVEhYcFhgYFhwpHBweHBwpNSYhISEhJjUv
MisrKzIvOTk1NTk5QUFBQUFBQUFBQUFBQUFB/8AAEQgBMgDIAwEiAAIRAQMRAf/EAJsAAAID
AQEAAAAAAAAAAAAAAAIDAAEEBQYBAQEBAQEAAAAAAAAAAAAAAAEAAgMEEAACAQIEAgUIBAsH
BAMAAAAAAQIRAyExEgRBBVFhcRMGItKTs9NUlBaBoTJzkbHBQlJicqMUtDbRgiMzRBUl4VOE
NTR0JhEBAQACAQQBBAMAAwAAAAAAAAERAiExURIDQWGRMhNxIlKBoWL/2gAMAwEAAhEDEQA/
APVc753tOS7T+I3Hl3J1ViwnSd2a4LoS4vh20T8Ju/G/Pr95zsXY7O1lG1bhC5hV01Suxk26
dFF1E8b7y9f59d283/hbSMLdqKrT/EhG7KVK0q3KnYkeeJ200mM3l2/nDxL78/RWfZk+cPEv
vz9FZ9mcVEBvw17O184eJffn6Kz7Mnzf4l9+forPszjIuhH9evZ2fm7xL78/RWfZl/NviT35
+is+yOOiya/Vp2dj5s8R+/v0Vn2Ra8V+JPfn6Kz7I5CQcURnq0/y63zV4j9/l6Kz7Iv5o8R+
/wAvRWfZHLSQSQxfq07R0/mjxF7/AC9FY9kT5o8R+/y9FY9kc3STSOB+rTtHR+afEfv8vRWf
ZFfNPiP3+XorPsjnNAtDgfr07R0/mrxH7/L0Vn2RXzV4j9/l6Kz7I5lCUDC/Xp2jqLxT4jf+
vl6Kz7INeJvET/18vRWPZHKjEbGI4P69P8x0l4k8Q+/y9FY9kX8yeIff5eiseyOekRocQX16
f5jf8y+Iff5eiseyJ8y+Iff5eiseyOc0VQsQeGvaOj8zeIff5eiseyIc2hCxF4adof4x/qXf
dtr1Ns4p2vGP9S77tteptnFObOn4xCyiybi0ECgiai0EikEkTUWkNigYobFDI1laiFpLSDoa
kFoNJTQyhTQ4ZtLaBaGtAOJAuhKB0LUSwMqjEbGJUYjYxHByrSU0MoU0ILYDQxgNEg0IWyAT
fGH9S77tteptnGO34vVfEm+7bXqbRxlE5uek/rAlhaS9LLDQUgkglENRHCCkMjEKMGNjA1g5
DGI2MQlAbGA4WQRigtIxQC0EclaQXEe4guJIhxBaHOILiIK0lqIekJRIKjEYokjEYkSBQGQ1
oXJESmAw5AMlkLZCmQhlr8Vxr4j3/wC1a9TaOSrZ3fEsNXiHfv8AWteotHMVsxINPxjP3YSt
mhWwu7NYNZ42xitjVANQHALjbGRgMjAZGBIEYDYwQUYoYoki9JekYok0kSXEFoe0A0ByQ0C0
OkhbQwZBQtIuhaQpaQaRSQVAQWLmNYuaBESFyGyFyFilshGiEMux4gjXn/MP27fqLJg0HT56
q895h95b9RZMVC16RrT8YUolqAyhdBy0BRCUQlENRJYCohqJaiHGILCKISiWohqJEFCUG6UU
4IMopoW0OcaANEiZIW0PaAaEFULSCoRIgkUHQiQVAqA0LkhzQqSIM8hUkPkhUkLNKZAmiEHc
50q885h95b9RZMek383X/N8x+8t/y9kyaQnR00/GF0LUQ9JKDloKQSQSRaRJEgki0gkgS0g0
iJUyLJKoSgVCUBFtC2hzQDQwEtC2hzQDRAqhKBNF0FKSDSIohUCgDQqSHtYCpoomeSFyQ+SE
yQgpogTRCGHc5sq865j97b/l7Jmoa+aKvOuY/e2/5eyZ9JmdHT1/hP4BQtIPSSgtYDQJItRC
USysBSDUS1ENIFhEi1EJIugZAdJVA6EaBFtC2OaAkhBEkA0OkhbRpF6S0gqF0JKSLoWkFQAB
rAVND2hU0SZ5IVJD5IVJCzYS0QNogrDt8yX/ADPMfvbf8vYEUNPMF/zHMfvrf8vYE0MTo6ev
8J/AaFpIuhaQtqoWkFQJRDIUkEkWkEkGQiRdC0i0iQdJTQyhTRApoCSGtAtCiZJC2h0kA0SL
oRIJolCCJF0LSCoSLaFyQ9oXJCmaURUomiaFNEsEyRA2iCsOxv8A/wBxzL763/L2BVB2+/8A
ccy++t/y9gWYyfX+E/hVC6UKcmuAOqoWt4MTQSxyEttEjcpiGU0JBpAQnGS6xioOYzhaRdC1
QuhALRVAmgWSA0AxjAdBRbBcWVO7FN9Ap34dAZawNqmZEnnUBXYdhWumFcGWVg5IIUpINTq8
CyMLeQEkG2ukBjlYJkhUojpC5Dk4KlEgTIWVh09+6c45j99b/l7AvWksQebXlb5xzGubu28P
/HsmCW4cuJhj13+k/hsldVaoHv6MxO8+krvWTfk3vcJ5oXO7F4xVDH3pO96wWWyN6gXfPNt0
MPek70Bl1LW5aaxOgmmq9J5+3dbdDrbW7qtKvApcXDV5mWlsFsF3EC5o2wtsybq/GPkJ1fEL
c33bsylHPh9JyJXK1bZm34M45aJXXIHX1mZ3CtZZGWnvC1cZmWp5INQmyzDy0q7gMjeoZlbl
QBylHMsw3MbVdqTU3k/oMSvUCe4qIljU51AlIQ7tZV4cQXdGG2HORDO7hBGY1eIrmnn/ADBf
r23+4snP72iWBq8TSa8R79L9K16i0cyUjNctL/WNKvFO6uky6yKQNZaO8RfeYGZNtjoW5PsC
0zNMUm8hkbV2WSHbaxHBs6EIRSpQz5dnWaY6ubGxuM1HE620aVimTyfai40WRLkdSlpaTa4l
LzyLxLJKrvkV3tcFwxOdduXLU3CeDX4C9cpWJt+TFpNSbpqpXBdJ024mXPW5uDN9uoK1ojJS
k3jToOW7lRU7lZYOpo222dzypZcEc8/NaxdriKgpTeCNdvb8WOt2FFZDUjPll0mkn1oFbSJp
SDYDHJqN4C5RTCYDqOWaRdtPOOZmdxp0ZtkzHuYYa458TUrntFxu1TX0r6AXdM8J4vsf4gO9
OkcttmrvCGXvCDhnyrr+KpU8Rb7p1WvUWjj62zq+LHTxHvv2rXqbRxqnK9WtfxhlXSpIurBq
/oJiWWmy1GNOs0RrJxXCuZit3MKM3bfypR6Ezns7+vFb7MKU6B6BhSSGKJl0q0ySLS+oVc3N
mLo5qvQniORgrdW4yh3ji5yteVFLjxaeDqjj3tzO825fS8zua01Wpwt53Ubrdp+TLFx6GMue
Gd9cTM4z1KjTVidbbOkVTI40XijsbZeQn0luvT8tUasJ0WboZbm5uPyLa+kU4Xpr7dGZy6Yb
HOK4optM5zs3Yy/zGx1qVzJ4lkY+mGmQMkW9WbM9y8lmORdRSSFNJ4P6Su/tt5hOj8pGpWLG
HunC/LGkYeV/d6jC5qrplwOrfwuQmnRxTq6VwRxJzUpyklRNtpdCOmteX28YN1kE6iG3LL0P
i7+pN/22vU2jjnY8W/1Jvu216m0clHO9XbWcRVQo4sotIGj7dquNUdHbW5YKph20NTVXgdvb
24xgqPE57X4en1TjJkItJIY5qEdUvoByAm4Qep4tZGXTGVXFK7jOTUXlBPh1mG5trcZ6or66
jL73N1+S1CHXmxULVxySdyvUkX/Kx9GpRk7L08DnX7dmNqX6bxrxO1aWlZdpm3fLbd5OVl6J
/o/mtlBvzLxlw7KUrirlXE7duigkk8sGciFm5av93ci4yTxTOrZ4Duz6ZxQyU4/Yjnm2A++W
UYy622b1ai1V5gS2sGZdLju5s+/b8uMafq4MfYhOqbyNK2ttYtV62GopOiHIkxzlJRwOTOkr
kk06J0O01RUZzdxtmpuSVU8aCzZlle3hJVxTAjO5ZdG6rpDlbbdYTcJdDKcZOsZ0rwaNSudn
aYFckndg1ipcO05G+hbt7hwtR0RSVVjm8eOJ1VGu5jHhFJ/VU5vMIw/iZ0dHVprPJnTR5/f8
fyyEJQht53pfFv8AUe+7bXqbRyUq5HY8Vr/9Hv8A9q16m0ZdntLc4d7ebUMoxjnJnPa4y9Xq
0tkx2YtL6Aoo6q2u2fkq3KLeVXUGXL035OBjzjt+nZl28VqVFU7liuhJmK1t+6waxNsMlwMW
5rtrrjXk10Iku2mbB7SqtOiI4MVK0pX6id3FYpJPi8ilhn+EkrqSbII5NS0pVf4i1qT8pUMa
ncrri8Xw6gLt2/JUb0rqDJsaN2rE4Vk1rhipdHUZbEk8TDevSdYN4D9tJ6ajZwzrtPLEdFXU
hVzctvTDGXQJuSlpSjnLAu1SGWbzYN/PBsZTitUlUCe9awhB06UhjrJYGe5anwr9BRbTst71
pVlgy1uVcg5V+z9ZknZlXHLrDhbSjhxNYjEu2ejSoWrirTECdmMKcUxdubhLS/oHOacWmS68
sTlXey0rU8Fn0Iz8x21qcpXtLjOnlqLTo/0mh9t2o35TuTUdUpRgsat8TPvnch3luF9Sh+db
f2sc+H4jrrHj9tmMVymiFtEOjz4em8Vf1Fv/ANq16m0TZOMrFr9VtNdbK8Vf1Hv/ANq16m0Y
9luVYnSf2JZ9XWcd5nL2+jaSa5+Y7F+ShCkFWcsE+jrLs1l5M8WkqkTjJxk8cPJlwaDVuktS
eebZyeoXdxxaJSiwCrVYFMQGgSXEpfiI3gCVKTy6TPeuUelZsbKTzMm4tzuNODoyPMnByvWo
qjdX0LEqd+LX+W6dgqzDu1Fyi8XSeBrV63GCTtybVUnTNMlmuNu5xleSSp08DVZj5KaE8weu
9CatuEaKNXxoNsvyUjV6Ry1/PbJ7hVR6mJn38bsYR+zLBPrNEHWPYM0RklVdaa6TMrrZmdcK
jtL0o1dzFU+sY9luVFtSTo6Ix3NrenJuV6VHlnw7BVzabuK1Qv6upSaf1jx3Zt2nSU+7HcW3
SUK9axQjvYSrTB9BVrdb6D0XYyuLLHPHrAe3k7krsvJVcI8RxGfK3pn65EvKmgnKlX0ItQVu
GvOUsEFG25eQ+huRLFZu4uu1G5F6Xq8l9qz+o5tzb3E288T1Kt23bSivJXBmS7t4cF9J21vD
x+zTNy83K3NZoh17u2SyIay5+FbfFNuUvEG/kuErS/cWjjNNZqh6Xnsa895h95b9RZOdOzBx
bklRflOW239rHr9fqz69bL8M+y3t2w9H2oPg/wAh17e5jcg3CqklVwo5N9ijWoG32O2UU4wh
cgsJ3G3VvPyVT66jr22hbtucI9zKKajL9bL7Lrg+0xe7prmcW5AtypX5QTwjh9KG1Veo5VqT
hcerOWLp0m6FxUCumvMOkxbkU7guUwakG5fgBjj9HDqF6goVTr+ECfF1xRcm2qfUSMo58Q/J
EOXvoy7tvPS6gWJ1idG7oSxxT4HIco2r8oL7NcDU5mHLfjabd+G+DzHwdVRmKF1VRphKuTyM
2OmtlMnKcV0rpE99LJ5mjyKYsFwi8ViRK1VzWILoHJUzEXJ0KC3CNqUq/mxwXaJubqViVYKs
5LB9ATeUFmb9rZs37Hl24ypgsFjRvibkct7wxWt/ecNDSk+Lq012jqtwWNXRVqFHZWIXZPTF
0phV4Z/9C7uf4qLA6Rw37Mtx1VSEuKmJDTk63OaLnnMW/wDuW/UWTkXJO7OkVg3RI3eJrjhz
jmCWGq7aT7O4smTl61y1vBLLtOW05t+r1eq5001/8tNmxuLNpxgoxm3XXWskqZC3a3UqxnOq
nnTP8LN6xI4vgjDrJHIntZ2ZNxxTzTYUZypXgdCdmrquPBmae3cXqiu2JZ7rxx+JXfPiA764
4BuKZkvujohklZ22snVo/iYJ4sYt1DpOU1UBypkzXhHP920+HYluoxxTEy5gcxyk+JVSmkF9
+16cNt3fymszMpuVzU82LLWaNSSOd3tvNbIvANX52+sVGWBHIzh18sdKet4m8Q1vcMznza7G
Lqy8IP3bR03vYvrEy3Gp1/AYq9ZeofGC+3a9WyN3SnL85/Z/tOnyq7F2XbqlKNaPjR4/2nA1
dKCU1wquxjgeb0ytwinperpYi5HPqONbvXYNaLjw/NeWJrtb6VFG6ss5L+wYzeR3E+OJA5Ul
GsXVPFNENMY5N8UY87366Llt/uLInYySspLOtGafEdqc+e8wlFVSnaX7i0c2052bibTSqm0z
G8zl29O2JrbPjDuW4tqrGpIVCaphiMqzm9FU4oCUa4Ux4DHLpFSvQq03gsgUyVcsQuZ4Pp4n
O3GxuwepeXHp4nSe82zlpc1VDFplHB1/KXRWTbq85dwRmZ6DcbGxuG19i50r8px91sb22a1q
sXlJZM6a7R5/ZpZz1jMTgXRdP4C1GPSacsKVWx8bKzeYuCSlWtUMd+SwUQv0a1xOotLihcp1
wKldlLN4AZ8SkV27JRslCUZWIsrx6CVImy8H1EULVOihKULSJCUesZCMioo0W41NSM1dpXIZ
ZPgQ12raIawPJ2OcWpW+d7uM1T+I7u/af6UFbhZdOtSt49q6Tm33ajg8+hHsuc8pjzOxHRPu
t1Zq7F3gtVNUJrjGVFX6GsUeP3fKua7aei/s7snjpnYjLcW5JcU7cXJf3oxMXTNy6er3yaTX
t3Zo73usEtVMuwq5ze7VaYpJcAZbDfPLZbr4a97MW+Xcx9y3Xw97zA8J2a/f/wCoC7zPdXHg
1HsRmneu3HWcmzS+Wcx9x3Xw97zCnyzmfDY7r4e75heP0Zvsz12/7Y3Jo07bf3LK0yrKHQR8
q5p7huvh7vmAvlPNfcN18Pd8wrrn4E9mLmbT7tUeaQnOri1RYGTc7q5uMJvyVlHoLXKea1x2
G6+Hu+YX/tXNfcN18Pd8wJpj4avutmLtGKSowo4o1y5VzRr/AOBuvh7vmFR5VzVZ7DdfD3fM
HFYzrnrPuyPAtS6cTXLlXNHlsN18Pd8wr/aebe4br4e75hYq8p3n3ZWo0TjnxQNDauVc19w3
Xw93zC3yrmmf8Buq/wD17vmDijy17xixL7TX/tPNPcN18Pd8wv8A2rmnuG6+Hu+YWF5TvPuy
aegmk2LlfNPcN18Pd8wJcs5nx2O6+Hu+YWKfLXvPuyJF6KdhrXLeZe47r4e75gS5dzHjsd18
Pe8wcLy17z7s0Ymuzb6yLl/MV/od18Pe8wZDacyi8Nluvh73mGozbO8a7VvBEDsw3cUtez3S
/wDGv+zIaYzM9XvyEIZc0IQhJCEISQhCEkIQhJCEISQhCEkIQhJCEISQhCEkIQhJCEISQhCE
n//Z
--orbitalcasino991732784
Content-Type: image/gif;
	name="bg_02.jpg
"
Content-Transfer-Encoding: base64
Content-Location: bg_02.jpg


/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAGwAA/+4ADkFkb2JlAGTAAAAA
Af/bAIQAEQwMDA0MEQ0NERkQDhAZHRYRERYdIhcXFxcXIiEaHRwcHRohISYoKygmITQ0ODg0
NEFBQUFBQUFBQUFBQUFBQQESEBATFRMXFBQXFhIVEhYcFhgYFhwpHBweHBwpNSYhISEhJjUv
MisrKzIvOTk1NTk5QUFBQUFBQUFBQUFBQUFB/8AAEQgBMgGXAwEiAAIRAQMRAf/EALAAAAID
AQEBAAAAAAAAAAAAAAACAQMEBQYHAQADAQEBAAAAAAAAAAAAAAAAAQIDBAUQAAICAQEEBQcG
CQkIAwAAAAABAgMRBCExEgVBURPTBmEik1SUtBZxgZEy0hShY6NEdIQVJTZCYnIjM3OkRSax
wdFSQyQ1VeGiNBEAAgIBAgQDBAkEAwEAAAAAAAERAgMhEjFBUQSBUhNhkSJCcaHBMiNDY4MU
YpLCJHKCM0T/2gAMAwEAAhEDEQA/AMXxN4h9fl6Kjug+JvEPr8vRUd0c0NpcI6/Tp0R0/iXx
D6/L0VHdB8S+IfX5eio7o5mGGAhD9OnlR0/iXxB6/P0VHdB8S+IPX5+io7o5mCRQh+nTyo6f
xJ4g9fn6KjuiPiXxB6/P0VHdHODAQP06eVHR+JfEPr8vRUd0Q/E3iH1+XoqO6OfghollLFj8
qOh8T+IvX5eio7oj4n8Revy9FR3RzmiMEuS1hx+VHS+KPEXr8vRUd0R8U+IvX5eio7o5jRDQ
pY/QxeVHU+KfEXr8vRU90L8VeI/X5eip7o5mCGhSxehj8qOm/FfiP1+Xoqe6I+LfEfrz9FT3
Ry2hGOWRbDj8qOt8W+JPXn6Knug+LvEnrz9FT3Rx2iAlkelTyo7Pxd4k9efoqe6D4t8SevP0
VPdHGJCWNYqeVHZ+LfEfr79FT3QfFviT15+ip7o46AJY3ip5UdZ+L/Enrz9FT3Yr8Y+JV+fP
0VPdnKaK2ikZWx1XI678Z+JvXvyVPdi/Gnib178lT3ZxpIRjMGkdv418T5//AHfkqe7D418T
+vfkqe7OHgjAEHd+NfE/r35Knuw+NfE/r35KnuzhAAHe+NfE3r35KnuyV408TevP0VPdnAJQ
0B6BeMvEvrz9FT3Y68X+I3+fP0VPdHn0yyLGoGegj4r8RP8AP5eip7ouj4m8QP8AP5+io7o8
/CW41VSKSXQeh2V4i5+/8wn6OjuhviDxB/7Cfo6O6ObBrBYsF7a9A06Gx+IfEHr8/RUd0JLx
J4hX5/L0VHdGZorlDKDaugaGp+KPES/P5eio7oj4p8Revy9FR3Rz5wKmiHVAkjsR8T+IHv18
vRUd0XQ8Q8+l/mE/R0dycGLL654wS0a0rXmjvQ51zuW/mFno6O5Lo805y/8AMbfR6fuDkVTN
lciGdFcWNr7qN65hzl/5jb6PT9wbNH4h1emahzLhu02cPVxXBOtddsEuFrrlHGP+XG05sGsF
mAkHho1ER9B7LjhwdpxLgxxcefN4d+cgcDlL7fkGu0N3n1aVW6aO15dLqjZGPX5sbOH5sgM4
tvxbfbB4YjBIM0OwEgwBIhgAEgNACAMiGAAGQGiMCscjBLRaZW0QO0K0Qy0xcEMkgkbFaEaL
HgVoZFkVNEYLGhWgM2hQDAYARKJRCJEUiGhGtpYK0UmTapTJCNFskIypOW9dStkDNEYHJm0L
gMDYIwAoIDJJGAFAyY6ZWMmMC+MjRXMyRZdCRSY4N9cthfFmKuTNEZPcXuLVGXkMXLB5HuRf
psWayZ5xwzQ8iSWd4mxemzPjA0ZEuIu4hhEGuqzcjdVM5cJYNdNmTNo6Mdjq1S2F8TFTM1we
4k1OpyT/AMfzf++n7tQAck/8fzb++n7tQBXLwOD879z7Tw5DIyDZqbSTkMi5DIQNWHyGRMkp
igasNknInETkUFbhshkXJGQgNw+QyLkMhAKxIrRJBLRauK0Kx2K0Q0WrCsgGQJoJIwQ4jAIR
XgjBY0Q4jBoTBJOASEEEEMnBDAVkJJFbRYxGWmYXQhGBnvIGYwRgMEkjCBMEYLMCtAJoQlE4
IAlodMtgyhFkWOQUGytmqsxVSNtTCTqxJMvjHYPwEwWUWqDA6VRFLgI6jVwMHANRuiMUqimd
TOi4bCqytoJItiT4HPWz5i+ubixba2tokXgDnh1Z1KbMpG2qeTkUWcLwdGqe4zaN6s7/ACN/
u3m7/HT92pAXkb/dXN3+Nn7tSBXLwOH879z7Tw7BskjBsVJBBIAEhkABiKkMsnJAAOWTkMkA
ASySRSRBLJySQiQZaZDFaLBWiWi0ypkYLHERohoqRQJwBDKTDAYAkCkK4i8JbhEOIpHBXgVo
swK0EisipiNFkkVyLRzZBBSWQUc7YEihkZO4bIC5JyBW4GKySAJbBMeLEGW8BSaK5G6iWTmw
e010T2jg3xXSZ1qGnjJujWmc6l7DbVZJLG8ScHatVxL+xQdiitTn0PAK2xD3IpVfJjOn6RZa
fMWuklXy6ifvD6Y7OsNyYnWxzrqsNpmKcXGXCdjUKM/ORz76nJZW8mehGWkrhqUQlg6Gmt4k
kcxPDL6ZuMk/pCy0MKWh6nsOQv8Ac/N3+Ns92pAr5BJPkPN5fjLX/hqQD5fA5/zv3PtPHkMZ
oMGwxAwTgAGKBIMQyMAG0MCAADBOBjAAwAgJJQoyApEhgCcCZaFa2CNFuCGhNFJlLQuC1oRo
hoqRCUwaIIKTHTROwRMZMRcg0JJFgshBZ6FMkUyL5FMjSpy5GVsUZ7xSzmZAEhgDMgCScAAp
DQ2CGgAXaSmQ0AAWxZorlhpmRMurkMacHb0r4kjo1Vs5XLp5fD1HeoSwDRtXuWtBVSyHSzpQ
pUkmN93QbTRd4uZyXSxeyZ1npkI9MLazWveUZyZVMonU8HZlpWUW6bqFtZf8mj5nnNRVwTzj
CYsG8nV1Wkbi9m05XC4vD3opcDlvZK0o9Z4c/hrnH9O73aoCPDn8Mc4/p3+7VAIwn45/qk8x
5SGM0Q0amguCMDYARQuCBsBgAFwBOCBAQBIYAZAInAYAIAkMABSJJQEiKROCGSAikK0I4luB
WhNFIoaFaL3ERxIaGionJLQpJQ2SGxWyHIIFaxEmUyY8mVyLRzZGIxRmKyjBgAEgPaRklBgA
FtGIwRkOICXUHER7GPkWWGAiEWQeGVDxYAdLQ2cNsfKeo0rzFJHj6ZYw+o9Vy+ziri/IWRZH
d0mJRNSqRg0smpYW46KlsASQvYiukuyichI4Mrp8hXOhNbjcK4poAg4mooW1YPP6/T9lZxpe
bLYz2GqqWMrejh8x0/HVJY2718o4ErOdTV4c/hjnH9O/3aoCfDi/0zzhdPHev8PUBHM0PNtC
tFmBWjQ6IEaIwPgMCCCvAYHwHCKRwJwkYLMMjhCRwJgMD4DApKVSvBOB+EOEJHtFwGB+Fhwi
kraLgnA2ASFI0iMMlInAIJHAYIwMAhwVuIriXCSQhoolErki+RTPeTA2yplcmPIqbGkY3sRJ
iNkyYjKg57WDJGSGwyOCJGJSEyMpIRaY2AwSmhkhGsJleBWmXcJDiCYnjKGRllsoCOI5MrVa
FGiKTF7SjM01nouTW5qS6mebgzq8sucMoG9C8dNzVep62meGpHQhcmjz9WsWzLwb6r1KKaYq
3NL9ravI63aE8S6TnK7G5jrUS6ytyMXit0N2UTt6zGtR1liviOUTsfQe1OUWcrUV7JLqOm7o
43mLUYbb6wlEOrknkEFHk/N4dHbW/wD209LAt5Gv3dzdfjp+7UgTzL5HkmhWi1ohouTrgqwR
gscQwKRwVuO0MFmCOEUlbSvBPCPwhgUj2iYDA/CGBSUqiYDhGwGwJKgXhBIYBSEC4DAxASBA
AwCQAAyRxABORWDkJKQC3Cyewpkx5SKpSCDK1yubKpDyZWxwYWsJIRjsVgZsVi5JZAEkZJyQ
QA0x1NosjYinIZCC1kaNcZJjpJmNTa3Fkbush1N6Z68GXyhkqnAsjYmTLDQtTSyrZaGN7GC3
jWLEhUtpomcdkXVvadHQPE2jmwOhoP7RitwZt2v/AKI60Tr6CtzpTOPHoPQcnx93Weszx6s9
LuHFZgrlVZHdlFfHbHejpTsqlJxfQJKiMkbbVqcqyaLcuJhWpxvRZHUx6x56XO4zy07W4lp8
ituK3FGhXLeLKZk4JxfULbOcI5zuJli/i0fA7HJH+7+bv8dP3agCrkM2+T83n09rY/o01IFT
pPsOHZ+Ls/U2/XB51xI4SxkFydaRW4kYHZApKSFwRgkBDgXAEkANQBBOcEZEOSADJDYBIZDJ
GSMgKSSMkNiuSAUobJHELxIVzCBOyHchXIrcxHMIIdyxzElMRyEchwZ2uNKRXJkNitlGTsRL
eKwbFbESLIVjMXApCBWQNgVoBbQwGAySgFAuGQO0RwgIUMk4IABuJ9A8bWt5UAQilZrgPKWX
kEhCyLCAnqWRWDfoF57MUWbdDJKT8or8DbtnGRHViei5VBdhA81CS2nU0GvlVFRltj17zOmj
PTz130hHcs06eWZ51WQl5rwiIcwqmvrfMym7mShZwtZj1o2dqnHTHk4RMGiN7jsmvnLE6prf
kor1FFy2PeTOnpg8An0YOsP4ltGnp4sy6rTf1bwiztb69n1kXznx05a3oHzKq71snO5Mq8Pr
9yc3X4233aoBuQf+J5v/AH1vu9IE8vA5Z/2Z/W/yPOuRHGUuwhzKN9yLeJEcRT2hHaBAb0Xc
ZHEU8ZHGKA3ou4kRxFXGiOMIDei7JHEU9oR2gQG8uchXIqc2K5hAPIXOYrmUuZHEEEvIWuYr
mVOTF4hwQ8hY5kOZW5C8Q4JeQdyYrkK5C8QQQ7sdyFchWxXICZGchHIWUxHIUikfiIzkr4mC
kxDRalsJ4BYTyXRwyGzoxpNQVOArgaeBEOsSsaPDK0MriK0aXWVuBSZjbE0VpjbCHEXaUZOo
+ELwEqQyaYEtFTiQXOOSuUQFAo0RSyK3DAthu2mijKWxlCRqri1FIeg1PIuhdJbDr6VOUIvB
y9NU7LoQSzlnr9Py9RqWwapVmyz5K/MchrDIab3nTu0D6EY56Wcc4FbD0N6d6+DXiUJyi8xZ
tp5hOHm2ecusxuMo70QZ7LV4HQs+LIviOzXqKbekvnKHZYXUcFZW1fSWdvao4zsGrPWRPEm0
620OvyDH7K5v1dtZ7vSAnh9/uXm8vxtvu9QBy8Dhj/Yifzf8jxzsIdhn7QO0LgjcX9oR2hnd
gdoMNxfxhxmfjDtADczRxsjjKO0DjFAbmX8RHEU8QcQQg3MtcheIqciOINBbmW8RHEVcQcQB
LLOIjiK+MjiAUssbF4hHIVyCRajuRHGVuRGRSBY5CNi8RGRADZDJwHCAMXJBOCAESmWQsaKg
yEIdbOvA312Jl6SaOXGbjtRqp1CztMrU6Hdg7lcGaXUVSqNMJqSGcEzOWjs2VspRzpVsrcGd
GVPUUTqLVznydtzRiaIy0aJVlUomu44742gUyHtFewFLaMxYKLbLoRwCwPjcMUch6ocUl1dJ
sUEhtPQ1BZW1lzhjoFuOquBxMF/Kq395U0sqH+89fRepVracbk1FfZLpl0nUsoXD5u/rNa+w
xvWHwNDknvQjprnuMXFfW854kWQ1cc+esMepEE2aJPcjJbofIdGNyltTyh8xlvQ56i1OFLSz
iVWwnCOfIeglRCRi12mUam0JpNF1yWq9GT4elnw/ziX4y78GnqAXw5/DvOP7y/3eoDKNY9ot
z3bue7ceB4w4yniZOQEW8RHGVZYcQSMs4yeMq4iMsJEXcYcZVkOIUgXcZHEVcQcQxFnERxlb
kRlgA/GHEV5YZEElnGHEVZJTYDLOIUFljxhkGy61b0QhGDTGpYJ7EnejVYGzLgMGh1iOAKyE
8TRUngZbSHENwzJ1G4RXAdPI2BktGdogvlBFbjgBCBkMAAF9WocPkN9OpjNbzkjRnKLzFk2q
mdGHubY2uh3Nkls2iyrTMVGrexS2G6u2MjB0aPUxZ6ZF7SidJmsrwdNpNGa6CCrchmxJps5t
iwVpZZbb9YK49J0V4Hj5UlaBq4vBt0dDsnxP6sd5RVXKyXCt7OzRVGuCSW4V7xodHaYN73WX
woeMEkMquJpJEr8J1NDoJSh2s1jO75DOqbZ6WR1qviM9Mp6bzoj2c2vbXCsJb0y3V1qL4Fv6
TJ2GXg03NaHN6NLfEbKeZwl/aLhNKnTaspppnLlQ0tpQ+OEsxbWOotXfM579unwO06cbYNry
omNt0N+1HLq199bxLz0baeY0z2S81vrLV0Y2xNcDdVqIzko7VIo5rqo16ebb2tYRfT2UvOW0
43PrFmNcenzn8hWkGW1m7w4/9Nc4f8+9/wCHqAPDn8M84/p3+71AZc/EXM+dZZOWQNFCY0pB
ZDDHUCyNZMmlaNlGGGGaOzDsmLcV6LM2GG0vdYjgNWJeJlQDuJGByQ6i7Qwx8EYwMmBcMMMG
wyMRAEpZ3BjASBK2GippmcmMsMlqTSl9rOjCKZZwLBnouT2G2GGY2UHqYLVskZ5VFM62dDhR
VOvJEmtsSfA50oPJW0bJ1MonB5Na2OLLhako3DxmglHAhpJyWrBfvFlEWMyxNMZDRRKG0Ro1
NIrlDIySgB5QwJhiAMl9WonBlAA0nxKrZ1co61WrjJC33LGw51cmn5C/a9rJWNJnQ+8u6wJw
8Ty+kthByaillsFFtpLpOnpNOoJSf1mVZwtCMWN5LxyfEbSaZVLLXn9ZrRCNOi033ixJ7Ire
Ya2Z69VXHSFyNHLdE77VOa/q1+E9IoRrr2Lo2FOm09dcVw7Etxc3NeVG9KwednyvJbT5TmX6
eUpOTW3pJr0DUctbWdFOtvbjI8pwSKhTqL17aJHHv02FuMM6Nu47k3XbuZTLS5eUJ1RrTLHE
4kqCp1NM7VmlZmnp3kUM03VsZaNTOiHBjpMGstlfY5v5jfqK1FPyGCcMid2hegnLR3fDi/01
zhfz7vdqgG8Or/TvOF/Pu92qAc8zz4/Fj+uPrPnKHihcDxEKvEthE0QgU14NdSTM7HdhqnBC
qQOpF6iTw5M5OvYjK6clU6cHQ4RZQQ5JtiTRzJQwVSRutrwZZRNKs48uPaVEPaWKqUniKbfU
dLR+HeZatrggoRfTIs5LHI4SNx7PTeBcpPUah56VCOPws0vwJoWtllqfXlf8AlEHhEyHtPW6
vwLdBZ01/E/+WxY/DE87ruV63l8uHVVOCexT3xfzjkDJgFtDyEIBjwk4vKN+mvzg5uSyuTg8
rcTasm2HLallD0O3F5JcTLpr1JGtPJzusM9jHkrZJlU600ZrKjc4iShkJgq9EzmSgUyidCyo
zzrNK3OHLgiYMjRMZtbGPKIjiapnHejXEti0xsFEZNF0XkpGTRDiUygacFc8LeEEmfAKOSzg
cnt3FkYJbggBIV9Zcotkxg3uXzl8YJDgcC1w4du9muu/GxlGGa9Hy7Uaprgi1Dpk/wDcN1TL
pltj1RfVLtNxu08p0vij85dVyvsYrAs62nuI9GNUdlO8VvhsdKjmMJJJvD6maJ66FcHKT2I4
TQknJrDeUKbLkaLFjs06v6TvVaym5ZTLJ8Ti1F7GecjKUJZi8M6mj1ykuCzZLrGrzxQsmDbr
V6DOuyuXmNrJ0KZPhXE+J9LKpqNi2FP9bW9j2FcNTNvco5nRxCRVZp4qLaE09sprMo4x0i63
XQqreXt/kof0mapZW2o4vMZJT4FvOfJ//Bbda7Jym/5Rl1FqhByfzGFtWeinsqvoPR+HXnw9
zh/jLvd6gKfDMpfCnOJv63FqH/h6wL5Hkbvxt36k/WeDw0msLaETZZp8PJRKvbuAmICtm2lm
KMcGygiyOzt7ao0oYEhuCT3IyPQQmRJSL+wm+glaKb3ikVjn2ZluJ0+gtvmopfOdavly6UdT
SaeurDS2l1Zw5mHKuR0VJSnHMutnoqKq4JRikjDVYksGmFvSXJxvidCHCOkjHC0ujaImC6Vc
WYtZy+nUVSrtgpwlvi1lM2KaZLaaHIoPlniPw/LllvbUpy0s3jywfUzhZwfXeb6GvWaW2iaz
GyLXz9B8lug6rZ1S3wk4v5i05EJ0jKXWJ0kt5GNOC2FjreU9h0tNqFJI5Gegeq11y2bibVk6
MOd0tx+FnfTTBpMy6fUKSNaeTFqD1qXVlo/aVygmZ7KjbgSUSS2kzmTrZTOJ0LYoxWyjnC2m
lZOHuK0rxM7WBoSww4ZS8g0YJfKbVXU8+1lyG4m/kI4UWQqlY8RTeDXXy9vbY/mQO1UVTBku
9K+JijByeEssvhp3vkb46eEVhLGCJV4J3nQuya48TMoJbiY1uT4Yrib3JGiNTlJLdnZk9Jyz
Q6aqKaiuJrbI0q5McldpyuW8llOanqY4jvUf+J6vT6aqqtKMUktyIjCvGI/SHFKHlRcGDY86
4TWDHdpEalbFvfhjcS6dvlGScK7SyTbRmlCUXtR6OVMZrZ0mWzQ9LQQmXTJaj+E4nCLJ8Js1
VPZp9fUYeGe+RnbF0OzF3nKxr0+usrwpbYnSp1NNq37+g4eMjqThtTwSpRu1jya1PRTvqqqf
Qkjzmr1Lvtcnu/koW3VWWLgbykUOWzJNrtmmHCqOZCTwn5Dmaq7tJ8P8lF+rv4Vwr6z6DAFa
mHdZ/lTPZeGf4S5x/S1Hu9YEeGf4R5x8uo93rArmedzPM2GWZqtRlsEWxFvNdCMae016eRNk
b4XFjpVQya660ZKZG2uRi0ejW2hdCtdQ6ghYyHT2Cgi7kMDqeBMiSnhFI5cqNUbsdJfC/wAp
y+1wx43eUrU5HxOzC9dZohacWGoNMNSMDrRu8pbG5HLhqC6N4Cg132JxZ8l5q4y5lqpR+q7J
Y+k+hc35lDR6Ky1vzsNQXXJ7j5tNOU3KW1ttt+Vl1RLKyCxwI4GXAhCSeB9CJVcmKA8Sym2U
HsOhVrEt5z414LFEexM1pmvTgzovXVY3/QU2a6T+ovnZlUG9yLoaayXkF6deZt/Jz30RVOdl
m2Us+RCqJ0K+XrfJmmvTVQ2qK+V7WTuqtEVXtsuTWzObVpbZ7Uml1myrQQjtm+J9XQbEkh4w
lPZFN/MS72Z1Y+0x01stSqFUYrEVhdSH4fIbNPoLLZed5qO1puU6etJ4y+t7QVGzS+emM89D
S22bVHC6y1aDCy1k9O9JWtyM1unXQi1jS4mH8rceenRw+XqHo1l1Gx7Ym+6jGdhgtr34HMA6
Kx0K+ZVSWc4Yn7cqdnBt4f8An6DkTrZRKHQVvZz2wRMHqoWQtXFB7X0liulX9dZXWeb0OsnR
NQk/MZ367YXQWHnJasmc9sbRrhqa1tT29Ql/MdPGSrcvOfQc++l7eHYjNRGqu3isWZdGRwRB
1ZURteX07ii3RroRqompJODL5yhGO3eEvmScG/TqpZ3HI1Gr4ZOKN/OOYR4nVU8y6+o4Mm85
+kVoZpS9q8DZG9PpyJbqVGL2mOdij8vUVuTk8sz2qToXd2iBpTc5cUtrFQB5egNEc7cvXiey
8M/wlzj+lqPd6wF8MNfCHOH0Z1Hu9YCnmTz8Tzdq2vYZpxZutgZp1hBbMjWGW0zwyZVicLW4
cBWzTk6dFqxvNtdhwYSnF7zVVqZozdGdePuFGp3IT8pcpHHhrGWLXE7WaerXqdRyK5Mw/fhX
rMi2si16vmaJtpiqxoyy1LbEeoLSZz3qp0n3HSjb5S2F2Dj/AHvh3Ih8xsX1Y/SG0yh9Dvx1
HlE1HNqtPHzped0RW9nnrNbrLNilwrybDP8Ad7bHmUgVVzKWO74JlnMuY266zim8Qj9SC3Iw
4Na0Te1sn7ml0v8A2Fyh/wAfJ0MfCGEbPu8V0fhI7KK6ByJ4rLiZEvIOoS6jRwpEqI0Q6lKg
TwpGiOnvn9SEn8ieC2PLdXJf2bS8pSQtDJFtM1U2odcttX1tgfc3D5QtVs0x5fTcl8ZZGWSq
DUdjL1LZsMLUaZ6mLPW6XU2aCiu2XnrOGd6rSVKKwkvkPNU6idUsx2o2w5vdFrKXD1b2VVpE
5qZLOas68qo1vK6B4aqP1XsM1Otrvituc9A061Lai9Gcrryt7zW9TGCzJ4XWQr67V5rTOVdX
N79qKqrJ0zzviDcFrBVqU5Z0bqcowW0YydSmxWQzvyV30phEhS7q4Zw7K8GadZ1Lq8GOcCGj
prFlqYZQL9LrLNPLDeYhKBW6m9yBNmeTEmju06mq+K25LFpIWSzJ4j1Hn4OdT4ovDXQaFzec
IYazL8BqrHFfC09Ds330aOnOVGMd3Wee1nOdTdKSg+CHQlvMuq1VuolxWSb6l0GaTwG4h0a4
hKTbb3vpZVOxL5SJ2Y2La/8AYVikhhtbywAkUhABFOx4W7pCMXN8Md3SzXVUorC6DO9oR0Yc
Ls5Z6nw1DHhTnEP516+nTVgWeHF/prnC/n3e7VAE/BP9Jlt/G2/qR9ZwlTK1easCT0N29ROj
SoxOjVGuyKZqkJs8tZpLlvgzPKia/ktHsbNNW+gxW6avaVBEnl3CS6GWVpM612ngjHOMYsm1
TTHaLFcYjqK6xXNLcR2iMXVnfjvjfIs4E+kOzXWLCabw2dHTdnsyJVb5lWvjr8ph7FdbD7vF
9Z3eCprchHCCZWx9SFmxP5Tkw0Ln9WDZauVXP/pM7mmnVhG+E68LCGsftFbuKp6VR5b9l3r/
AKWA+4Wr+Tg9dw1yW4z21R6g9NDr3S8p5h6SxdGCuemkd+2vyGK2sNiNvUdkciVBTKrDOlZA
zWRGoOfJRsxOGDu8qo00oxbim+to48olmn1NmnnxJ7OlF1Zy3oz2MK6IpLGx/QNOitrYkc7R
a6F0Ft/4m+ubTS3ouTBqDHqNOuhHMvpxk9JOrjW4w36TeMR5uytorU5ReGda7SpbMGK2jHRj
Ami6XddUJGWRih+Yx42p7DG1D0MHdK2li+uydbTi8YOppeYqXm2bGcfOQUsEJup02rW6hnpv
MsWzbkz20Z+Q5mm186sKTyjrU6iu6OU95orSc1qWo9Puiae11SUZbug6GVOJknSpLYNQrY7M
eb1soi8PVC3U5yY56aUpYisnZxW15zKb9XpqI7Wl5OkIXMVMluCW45b0Tisz/AZrnXDZu8hZ
q+ZOxtVrEetnOlJt5b2mbslwOulbP7wWS4t24zyiWN+Uz3Xxj5X1EpuQyKiWos2llmWdnE8L
YusLJub27hDRHnZLy4RCRIE7t4MySIJjCVksLd1j10zs2v6prrqUcGV7xwOnFgdnrwFqpjFY
SL4xGUUMkYOzZ6FMaqei8Or/AE7zhfz7vdqgG8Pfw/zf+8t92qA6Py/+n2Hl/wD1fvf5HP4G
txp0smnhlf8AW+q6r2W/uyIu+Ms/dNV7Lf3ZtKMWzovajJfDeWw1EsedptUn+i6juhbLHJbN
Nqn+q6juhyupJydRF7Tl3tpncvrun9XSap/qt/dnOu0Guk/N0Wqf6td9gJXUDl8byCkapcr5
nnZodV7Pb9ghcr5r6hqvZ7fsENGtL9SjONw8brE8qTLf2XzT1DVez2/YD9mc09Q1Xs9v2CIO
hXrzsvebNNq5OKTZqlJtZyc2vQc0hLP3DVY/R7fsG+unXJYlotUv1a7uykZ2dU5TXvFjdOue
cnS0+r4ltZzp6bVvdo9V7Nd3YU06+uW3RarH6Nd3ZUidk1xR3qtRg0pqSORVO9LEtJql+q39
2badU4rEtPqvZNR3Q5JlLmiy2sxW1m6Wqqa/sdVn9E1PdGayxS3Uar2TUd0Jm+PNVcWjm21m
WyB0pxm92m1T/VdR3RnnTe92k1Xst/dkQb+rja+9X3nMnHaUyR0Z6XVvdo9V7Nd3ZTLRa57t
FqvZrvsDTMbunK1feZar7aZcVbx19R6LluvVsE5NZ6Thy0HMejQ6r2e77A1Om5tTNShodV5f
+3t+wWrHNZLqj2cdRDGWRLhmso4+m1OqUUrdHq4vp/7a9/7KzVDVTj+barH6LqO6KldTJoNR
U2cvUVPLOvLUxkv/AM+qz+iajujJdmX1dNqn+q6juhyuojiW1tZM0lw7Ude3T3yezSap/qt/
dmWei1j+rotV7Nd3YSuqGm5kyws6y1STIfL+Yb1otV7Nd9gI6PmS36HVez3fYMrVXJnZh7mN
LcBs9Ro01koTWJcKKlpeYeo6r2a77BP3XX+o6r2a77BEQzsWfHZQ71Xieho1Vah50vpEv5tp
4bIvil1I4fYcyxh6PV46vu932Bfuuu9S1Xs13dlO7gx2YJl3p/cjVfzS+zKi+CPkMcpuTzJ5
b6XtG+66/wBS1Xs132BJaXmWNmg1T/V7fsEPczZZMNVpeq8RXIqsvhFbX9BFmj5zLYuX6pL9
Ht+wUvlfN3v0Gq9nt+wNV6mV+8qlFWVWamct2xFDedpr/ZPNv/X6r2e37Afsnm3/AK/Vez2/
YKWhx2y2txZjwyUjX+yea7/2fqs/o9v2CY8p5q352g1SX6Pb9gGyUl5l7zHtexLLL6tPlpy3
myvlevh+Y6r2e77BdHQ67p0Wq9mu+wZWtZ8mdWKmJa2vSf8AkiiEMIsUS5aPXepar2a7ux1p
dZ6nqvZru7Mmrv5X7jrrkwpRvp/cilRY2C37trfU9V7Nd3Zv5d4d5jr5RlqIS0Wjb8+U/N1E
47dkIb4Z65YfkJVLNxDHbuMVVO+r+hybuQwlX4Z5lqJ+bVqHfbXJtba41Rq4vkzW8eTaB6T7
ppvun3Ls1917Psey6Oy4eDh+jYB1bfh2+yDyPU/F9SPn3/XJcAAUZgAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAH//2Q==
--orbitalcasino991732784
Content-Type: image/gif;
	name="clickhere.gif
"
Content-Transfer-Encoding: base64
Content-Location: clickhere.gif


R0lGODlhuQAhAMQQAHFvmJiWtEtIfMzL2vLy9rKxx4uJq+Xl7FhVhtjY42Vij6Wkvn58or++
0P///z47c////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ACH5BAEAABAALAAAAAC5ACEAAAX/ICSOZGmeaKqubOu+cCzPdG3feK7vfO//wKDIQSwaj8ik
cslsOp/QqHQKhREf2Kx2y+16v+CweEwum89kYsuBbrvf8Lhc7lix5/i8fs/v1lF3fYKDhIVe
fyaBhlsARABbAVdojQ6PaEQBi4uIJIqaWZSWWZGeZKFtmJ+GnEOqjI5bCACiZqeXDpmug6wQ
pXkCAQMDCwhctqABubELwgECxrDAyWm4CgXDxVzAwsRdyQAGA8pZBg0DBbR7vL5zCAdGBNmg
sFqkXAwERgnQlQ8DDgQUUEsA75kWAQSLBORC5J+DfVoKHDEgaJ2gBgAN4HNQ4FW/epK05EvA
gBRFLaEk/zo4OaZIAAAqWWKRSEAjwQMMiRxIsECLAUwAMDqQp8ciHwGpHgRoMO7BMSz2tDAg
IvBBgQIynRIRmjVMQyxIcW1JqoBeFp3PDGL5NyBLvqZ4jO55yi9d1FEhvVAqks6rWCxJsVAq
kIxUUyIdc4pL9q4tH7l66Hq0m1dpZX4AHTimpiyw1iSH/45Nsrlooj5lV2JB8FLtZ8qeSGUD
8NIjOiJdvwT2nJqBX7gP8vVcdbpP45lEXNO9uzrpO4jz+kk84BrMbtFY3jWAqrm65yzTnzVK
0HcOZD0/HewkMjw6bC4qE7xz4BtltLecz2K3rD7h9tHApUaAQ9T1cZ4eAeTDXn5dkFwmwAIK
dWVLJPG0JNp3SinIUXUPYCjYfJpV9Vhxg8zC4RsCzKKLMQCcSIYCABA1YgnsrGjjjZucUCOO
PPZoHiA+Binkj0AOaeSRLdmB5JJMnrXGjk1GqYoaL1Bh5ZVYZqnlllcK4eWXYIYp5phklmnm
mWimqeaabLb5ZQgAOw==
--orbitalcasino991732784
Content-Type: image/gif;
	name="invisible.gif
"
Content-Transfer-Encoding: base64
Content-Location: invisible.gif


R0lGODlhCgAKAIAAAP///wAAACH5BAEAAAAALAAAAAAKAAoAAAIIhI+py+0PYysAOw==
--orbitalcasino991732784
Content-Type: image/gif;
	name="logo.gif
"
Content-Transfer-Encoding: base64
Content-Location: logo.gif


R0lGODlhhQBIAOZ/APXHV7CxtJhuB9GqT+eqFu7Kd3WIr3Fwa7rE2al6CbWDCfPTiNWZC29R
B4aVseSlDseucCI1WvX08v735ujr83F6itXb5ixBbLW8yee0O9zh7OetIykrLJqt08/Iuq2S
TcyTC/bis//+/ExRWui4RfW5KkdTaHFlSeixK62ccBs1aoJ2U8TGyY5xKsWYKqm41vz58+7w
9a+li/PaoMTK1cSNCZmcn0Q3FfH0+V1rhbykZ8vU5+e8VPC9ROvr6tLW3P79+ZekvaaGOMq7
muTj4fX4/Nzc3M3S2++5OpiPdaayyIKEhdHS0lxiadyfDtirPkZBM/j4+PvEPvf394aKlnOQ
ydjUx/KyF8uUFODl8GJRJeXo7+/r4lNtpOSvMoReBdSbINXY3zBLgEddiaGsw/v9/8OeSK++
2/Hw7/f6/5SRhr/L4ZWAStDBnF1ECvz7+t3f4+bm5mRcR4ucv3hlNWp9pIU6a8/P0NjX1dbf
8L6JCeKhBjQ6Rdy6Zf///////yH5BAEAAH8ALAAAAACFAEgAAAf/gH+Cg4SFhoeIiYqLjI2O
j5CRkpOUlZaXmJmam5ydnp+goaKjpKWmp6ipqqusra6vsLGys7SjMhA8BTMACwsFAH0QtcOI
YwdCLhslUlIAADMhITPQMwsAFcTZfystXw1u4F8KKD0FIVzR1QBSA9q1TU0mF2KEdnYNDz3n
IUgbKBsPsLgzlaPCEjVJkhzIUUjMBUURhEQLUaAAgT1OQCiwM1DULWfMSojM8ETHkkcBds3Y
4OwBCD0JOHb0lOJXDyQlAO5h8LKGTwUHGqkBgGLlAwAksCgQIHPmJpsZUBBgUEOPgAY3OGjl
4EYLw0UppKBY0GMPAR4DFGhxuikF0gwb/6bC/OKGw0ND9Bb1QYKiAI+dWMwIMcE2E4S3cUEk
EPCFQ4RKSYiy5JExQYIVhTFBkELin0vLDThc4pHBC8seDGA2uJuZklseXggQcKKazyUdAEwT
yDAApgDbrSv16lWxwBCTlzwQ98XjyeIbKmB1gBNDwpTr2KdI8IGgCqEj1rNnj4IjzgtCHWAA
WQ9EhIgyaSQUmeLD0BwJFgihiSI+CnsRQPjhwQBX3YXAFFG8EYYifniixBt+wOBDHEZUWCER
PgSYRReDwOFHHHhYaCERcaDhhwgdDKKEHzj8EMaLL17ogx9vFOKAHwsOwgQRFobxAx4wvghH
AEI08NgfcwQIh/8Efpx3CAZ+YNAJBVEe0MQIWGaJ5RImnjHIESJUwIeWWZrQRAAiZDEIGUDQ
cMKbJ8hxQploxkCIAyL8QIiWZq6wApxvysFGC6IJsoMfTIxABYuIQCnlJgZIEMdXibDgBwuD
/CBCHYrkEMcUBggSQBkeKGDqYl9AQYgPEnAqCJ56HtKEDjNYYQZMCXzhDXB/GIAGqCqIgYcf
CDzpRwCcJHlHXomQ4ccdmYoQaiJj3CGCA3/kMEQaHoAhW2WEDULEFK7+ASsiffSBRhl9OFGD
ZY0RksWx4S4ahbHIbuIsDYyQIQITmQIxbSIWRBHqAW1wC8YDD/DUQiFvbMHhqyLkSIj/DAAg
oUMcRUCAa2iF+EHEGH/EoKalaxjiKCfOPqpIEM9GW+4hCADhAzYrbNstww4PgoAfz5JMcayD
HEbCBmZwUUQKi4FMCA4i2PCQpGPkgMYbQRQCZb6arOhyIh3ELMgPAidC5bGCsKHzwg0z8LAg
VNzxRo2DnDtIH1JE9YAZHOsgQF2G+GHEV/CI6gcFWovwNSb+YrqIs9COLW0iAcSA9h9CJLzz
A04woMAgF5gwrMt2R9YDCbEx8AEXaSRxwyH72XBIDh46KcjWnDgAROSKrOj4H2QPbEgES4iw
hSCZK8xww3o0QQgGZZAuwhF/HNaDF1LRJgQXZRzQ1CCHYsAa/yFi2HD4wLhv4gAMGjBCw6UB
C29IEmio+QcbmrPdMAhBDUKDCEqoWxmMoAMpXC8utEkAG+JAN0MAYQrYQEQOjOAHL90uSpyo
w4yKlYggMClrggjD5BAhhCXgAHHbSJgVSEACHriwBykYhAf9IDtBmI8IOojKbGqggMXQgQJp
OMQR/EADZh2CCu/B1h+gZLIsOPGJGojBDiYRAKCxCAc4iIEWtVgEoI1sEPNSoiGe0IA/lAEN
g2gDjSbAxjbCoAg46KLIhCaDNpSBCGa4Audw9YUbmMBEhzhRBBNhApTdTgRWTKQV0TgJG7AA
D2iQAJOsuB08BIBSf6CCDWY2iA/owf+GNfyDDLaAhi2acjs+uMMlx5AEHgAgCTZIggv2oBjQ
AMcGoRxEDnDZiAoEIIIVwKUwh4lLKlAiAlg6gJUqoExmXolXgohABMYniBSUQFV/kOYg6LAC
ZXrzm1YyAR8O0AcA9OAJQmiBAE6VqxscKZvvJMQ0G3GBCETnD/WUpj73qU1XqKEHD0CEHCwj
gIIa9CqCOMAAzKm3jODqb4X6g/OCYwkeSKEGiLgAFq7ghM69qwFQgMIKykmC0sSFJzx8zjuF
IAeKVgICPUBBQBGhhT1YxQ03GNMHeHATk84mNTXQiNME8QQBuLQSAIDLFT6QiJCOaQVmyIBI
/oFAnoCAKqn/0iUbNqAHah7VEX3oQVwIcAUdHKICK/jAAJAghRKgQDeco8pVQdCYCBCmAikg
wRX08LqvRqICSIALAeJSAhIMQAeIhUAfeIoTFDhWNjwDQQ06J4AbXIANT8hsCa5AAL76VRIf
iKlsZOOPHpj2tFFx7Fj3B4KrMqCyfFiBF0TCWZ4IAJufhcQAckIAhpF2A8ANLnC/5S49mMq4
feQDZjkbV9VENLePgOvyHtDb0X6LATwxLkEheoEWOIFnVUEVdL4H3Ua4QI/TXR52sSvZHm4X
p45pgQucgIWqLMUbWSFveRvRgqlYtbVUqYpx3csY+HLEDiZogIIVDI787rcSX7Cv/6kmTOCr
wDcC+rWDClRgT/0+OBJ2uEEDvnBQxtAlK1rx8IdBYQcO8IEDKOYDhldM4xrb+MY4NsQbXkAD
OxHCD2UQRIMGkYchgw8HhCiDH7zTpEFUwQ87sN0hFMfBQZTBB3kIGQICaOWUDQJoQi7E2aYw
CiBYMA/3GkQRqPSHBv5hB0UoxBqO92UqPTlFgniyBaqsYy8X4ngSKEQR+EWIGPC5CJb7Q5wH
QQEUhk0UOHCSBdxM5jOkwchvDiIhEIBCQZShAyvyA5575Yc5TOwQRZhiIfKAgzNUsBBkCPIg
DP20P6zhDWkWhAbs1wFNh2ILP7BAHArh44IRYgdTELXP2kg3CAmkaA3KznMUfsBnQ1AgDHAg
hATOs4ZO/8ECcPA2Bfjs4y2QmRBwgMMR6Jzjdrv73fCOt7znTe962/ve+M63vvfN7367IhAA
Ow==

--orbitalcasino991732784--


From arcege@speakeasy.net  Tue Jun  5 12:50:53 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Tue, 5 Jun 2001 07:50:53 -0400 (EDT)
Subject: [Tutor] small (I hope) questions
In-Reply-To: <3B1BE0B2.5D744AF8@mail.nhn.ou.edu> from "Isaac Hall" at Jun 04, 2001 02:25:38 PM
Message-ID: <200106051150.f55BorL03332@dsl092-074-184.bos1.dsl.speakeasy.net>

Isaac Hall wrote
> first, let me introduce myself a little as I am new to this list (but

Welcome.

> I may well be widely known as the guy with all the dumb questions
> soon...I hope not)  Ive just begun working with Python and Tkinter in
> physics applications, and Im getting stuck in some fairly minor aspects
> of this.  I have previously only programmed in C/C++.  anyway my
> question(s) are:
>     a) I am trying to produce a pie chart of just random numbers in a
> list to get started with this, however Im confused as to how to call up
> a canvas, and draw the chart.

All you need is a little math to get the values properly set up (but then
this will be the same with just about any package.

Here is a segment to help you start:
size = (200, 200)
graph = Canvas(graphicframe, height=size[0], width=size[1])
# get the total representing the circumference
sum = reduce(operator.add, values)
# starting angle
lastangle = 0.0
for i in range(len(values)):
  item = values[i]
  # how much of the pie do we eat up
  percentage = (item / sum)
  # calculate ending angle based on that percentage
  newangle = lastangle + (percentage * 360.0)
  # create a new pie arc in the circle
  # the "get_indexed_color()" function is something you'll need to
  # write, you should get a unique color for each value, probably
  # not repeat the colors, and likely start with the primary colors
  # (red, yellow, blue) first
  graph.create_arc(0, 0, size[0], size[1],
    start=lastangle, extent=newangle,
    fill=get_indexed_color(i),
    style='pieslice'
  )
  lastangle=newangle

You probably have to tweek things to get the details to work (I'm not
feeling well, so not going to fully debug this, sorry), but all you need
is a little geometry.

>     b) in addition to the pie chart, I also need to put these numbers in
> a table (which I have figured out, however I would like to be able to
> create this so that the pie chart comes up first, and then clicking on
> the pie chart will display the table.

Do you want a new window with the table (look at Toplevel)?  Do you
want a new area of the window (with the pie chart) to display the table
(you can just use pack for this)?  The methods for these are different.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From curtis.larsen@Covance.Com  Tue Jun  5 15:23:05 2001
From: curtis.larsen@Covance.Com (Curtis Larsen)
Date: Tue, 05 Jun 2001 09:23:05 -0500
Subject: [Tutor] De-CSV-ing Resolved
Message-ID: <sb1ca50e.040@madis2.truax.covance.com>

Thanks to everyone who replied I now have:

o A further understanding of exception usage
o A nice little function to test with, and
o A site that "high-level" explains such algorithms


Thanks again!
Curtis
 


-----------------------------------------------------
Confidentiality Notice: This e-mail transmission 
may contain confidential or legally privileged 
information that is intended only for the individual 
or entity named in the e-mail address. If you are not 
the intended recipient, you are hereby notified that 
any disclosure, copying, distribution, or reliance 
upon the contents of this e-mail is strictly prohibited. 

If you have received this e-mail transmission in error, 
please reply to the sender, so that we can arrange 
for proper delivery, and then please delete the message 
from your inbox. Thank you.


From MuraleeKrishnanR.  Tue Jun  5 18:00:33 2001
From: MuraleeKrishnanR. (MuraleeKrishnanR.)
Date: 5 Jun 2001 11:00:33 MDT
Subject: [Tutor] Hello
Message-ID: <20010605170033.21022.qmail@nwcst313.netaddress.usa.net>

Hello all,
   =

 This is the first time i am mailing in this list..
 i am a beginner in Python programming. I am stuck up
 somewhere so I thought someone would be able to help
 me out.
 The following is the error message when i wrote a
 program for implementing Tkinter
 ---------------------------------------------
 C:\Python21>python gui.py
 Traceback (most recent call last):
   File "gui.py", line 3, in ?
     top =3D Tkinter.Tk()
   File "c:\python21\lib\lib-tk\Tkinter.py", line 1480,
 in __init__
     self.tk =3D _tkinter.create(screenName, baseName,
 className)
 TclError: Can't find a usable init.tcl in the
 following directories:
     {} C:/PYTHON21/lib/tcl8.3 C:/lib/tcl8.3 lib/tcl8.3
 lib/tcl8.3/library librar
 y ../tcl8.3/library



 This probably means that Tcl wasn't installed
 properly.
 ------------------------------------------------------
>
 Hope someone would help me..

regards,
Murali

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=3D=
1


From cynic@mail.cz  Tue Jun  5 20:07:39 2001
From: cynic@mail.cz (Cynic)
Date: Tue, 05 Jun 2001 21:07:39 +0200
Subject: [Tutor] Hello
In-Reply-To: <20010605170033.21022.qmail@nwcst313.netaddress.usa.net>
Message-ID: <5.1.0.14.2.20010605210203.02081e78@mail.cz>

No guarantees...

Append the directory where init.tcl lives either to $PYTHONPATH 
or (in the script) to sys.path.

At 19:00 5.6. 2001, Muralee Krishnan R. wrote the following:
-------------------------------------------------------------- 
>Hello all,
>   
> This is the first time i am mailing in this list..
> i am a beginner in Python programming. I am stuck up
> somewhere so I thought someone would be able to help
> me out.
> The following is the error message when i wrote a
> program for implementing Tkinter
> ---------------------------------------------
> C:\Python21>python gui.py
> Traceback (most recent call last):
>   File "gui.py", line 3, in ?
>     top = Tkinter.Tk()
>   File "c:\python21\lib\lib-tk\Tkinter.py", line 1480,
> in __init__
>     self.tk = _tkinter.create(screenName, baseName,
> className)
> TclError: Can't find a usable init.tcl in the
> following directories:
>     {} C:/PYTHON21/lib/tcl8.3 C:/lib/tcl8.3 lib/tcl8.3
> lib/tcl8.3/library librar
> y ../tcl8.3/library
>
>
>
> This probably means that Tcl wasn't installed
> properly.
> ------------------------------------------------------
>>
> Hope someone would help me..
>
>regards,
>Murali
>
>____________________________________________________________________
>Get free email and a permanent address at http://www.netaddress.com/?N=1
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor 
------end of quote------ 


cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
    - Book of Installation chapt 3 sec 7 



From _cardiac_@yahoo.com  Tue Jun  5 22:02:11 2001
From: _cardiac_@yahoo.com (CARDIAC ARREST)
Date: Tue, 5 Jun 2001 14:02:11 -0700 (PDT)
Subject: [Tutor] (no subject)
Message-ID: <20010605210211.926.qmail@web13901.mail.yahoo.com>

I need some more simple instructions on learning to
program with python ... the only programming i know is
VERY basic html .. some of the things that are writen
a just cant understand .. i dont want to know how to
do 2+2 etc i wanna know how to make something i know
this is part of the 1st steps but 

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/


From brett@earthlight.co.nz  Tue Jun  5 22:10:05 2001
From: brett@earthlight.co.nz (Brett Shand)
Date: Wed, 6 Jun 2001 09:10:05 +1200
Subject: [Tutor] (no subject)
In-Reply-To: <20010605210211.926.qmail@web13901.mail.yahoo.com>
Message-ID: <3B1DF36D.22407.381D006@localhost>

I am in a somewhat similar situation.  I am using "Learning Python" 
by Lutz and Ascher.  I recommend it very highly.

You can get more information here:

http://www.oreilly.com/catalog/lpython/

brett
---------------------------------------------

On 5 Jun 2001, at 14:02, CARDIAC ARREST wrote:

> I need some more simple instructions on learning to
> program with python ... the only programming i know is
> VERY basic html .. some of the things that are writen
> a just cant understand .. i dont want to know how to
> do 2+2 etc i wanna know how to make something i know
> this is part of the 1st steps but 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35 
> a year!  http://personal.mail.yahoo.com/
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 




From _cardiac_@yahoo.com  Tue Jun  5 22:14:48 2001
From: _cardiac_@yahoo.com (CARDIAC ARREST)
Date: Tue, 5 Jun 2001 14:14:48 -0700 (PDT)
Subject: [Tutor] (no subject)
Message-ID: <20010605211448.6518.qmail@web13905.mail.yahoo.com>

ok i dont think i was detialed enough in the last
message i was frustrated :P  anyway what im trying to
find is like a program example icq    something that
is made with mostly or all  python that i can see the
code and build on it i learn best by watching/ looking
then doing if someone gave me the code to example icq
or something complex  i code write it line by line
then see how it comes together if someone has a
program like this that i could use i will sign a
agreement or whatever that i wont try to sell it or
all that junk i just want to LEARN!!! HELP PLEASE!!!

Thank you all 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/


From kauphlyn@speakeasy.org  Tue Jun  5 22:56:28 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Tue, 5 Jun 2001 14:56:28 -0700 (PDT)
Subject: [Tutor] (no subject)
In-Reply-To: <20010605211448.6518.qmail@web13905.mail.yahoo.com>
Message-ID: <Pine.LNX.4.33L2.0106051453270.15130-100000@grace.speakeasy.net>

You might find some interesting stuff on
http://www.lowerstandard.com/python/pythonsource.html


On Tue, 5 Jun 2001, CARDIAC ARREST wrote:

> ok i dont think i was detialed enough in the last
> message i was frustrated :P  anyway what im trying to
> find is like a program example icq    something that
> is made with mostly or all  python that i can see the
> code and build on it i learn best by watching/ looking
> then doing if someone gave me the code to example icq
> or something complex  i code write it line by line
> then see how it comes together if someone has a
> program like this that i could use i will sign a
> agreement or whatever that i wont try to sell it or
> all that junk i just want to LEARN!!! HELP PLEASE!!!
>
> Thank you all
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35
> a year!  http://personal.mail.yahoo.com/
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From rob@jam.rr.com  Tue Jun  5 22:09:02 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Tue, 5 Jun 2001 16:09:02 -0500
Subject: [Tutor] (no subject)
References: <20010605210211.926.qmail@web13901.mail.yahoo.com>
Message-ID: <002501c0ee03$d78c90c0$de00a8c0@planhouse5>

----- Original Message -----
From: "CARDIAC ARREST" <_cardiac_@yahoo.com>
To: <tutor@python.org>
Sent: Tuesday, June 05, 2001 4:02 PM
Subject: [Tutor] (no subject)


> I need some more simple instructions on learning to
> program with python ... the only programming i know is
> VERY basic html .. some of the things that are writen
> a just cant understand .. i dont want to know how to
> do 2+2 etc i wanna know how to make something i know
> this is part of the 1st steps but
>

No problem! There are a number of good tutorials on the web, and here's a
page with links to a good number of them:

http://www.lowerstandard.com/python/tutoriallinks.html

Rob

Useless Python
It's not just for breakfast anymore!
http://www.lowerstandard.com/python/index.html



From phil@xfr.co.uk  Tue Jun  5 23:11:07 2001
From: phil@xfr.co.uk (Philip Kilner)
Date: Tue, 05 Jun 2001 23:11:07 +0100
Subject: [Tutor] (no subject)
In-Reply-To: <20010605211448.6518.qmail@web13905.mail.yahoo.com>
References: <20010605211448.6518.qmail@web13905.mail.yahoo.com>
Message-ID: <VA.00000085.05e44e23@xfr.co.uk>

Hello,

In article <20010605211448.6518.qmail@web13905.mail.yahoo.com>, Cardiac 
Arrest wrote:
> like a program example icq    something that
> is made with mostly or all  python that i can see the
> code and build on it

I'm nowhere near that level of complexity, but I can help you find 
Python resources. For ICQ-type applications, I took a look at:-

   http://www.jabber.org
   
   - and there is indeed a Python tool (Python/Gnome actually). 
It's at:-

   http://pybber.sourceforge.net/
   
There's also an AIM (AOL IM) client at:-

   http://www.z3p.f2s.com/download/code/toc.py
   
   (Pulls up source in browser!)
   
I found this for you in the Vaults of Parnassus;-

   http://www.vex.net/parnassus/
   
This is the first place I would look for downloadable python apps with 
source - but I'd be looking for something simpler...<g>

I don't know if any of the IM resources are any good - I'm just trying 
to help you find stuff - but Parnassus is a fabulous resource.

HTH,

PhilK





From python.tutorial@jarava.org  Wed Jun  6 00:57:04 2001
From: python.tutorial@jarava.org (Javier JJ)
Date: Wed, 6 Jun 2001 01:57:04 +0200
Subject: [Tutor] Access to Windows Timers / Idle "states"??
Message-ID: <006901c0ee1b$39375870$0124a8c0@uno>

Hi all!!

After some "lurking" on the list (and not too much time to program, either
:-) I've decided to jump with both feet in :-)

I'm trying to make a program that can handle "timers" (ie, set a timer for
"x" seconds later) and / or "register" itself to recieve windows events.

The idea is, when I launch this program, I want to be able to set a certain
amount of time after whihc I want my program to do something (namely, kill
another program :-)

At the moment, the "killing another program" would be handled with the
pslist and pskill utils from sysinternals, so I "only" want to be able to
set a timer...

Alternatively, I'd like to be able to "know" when the "idle" process kicks
in, like to know when the countdown for the screensaver starts....

The thing is, I have a program that every now and then locks itself solid
and the only way out is a hard reboot (even in W2k, ctrl-alt-del won't work,
even though the OS "seems" to be getting the keys, and the mouse cursor
moves). So, I'd like to be able to "sense" when the OS hasn't been getting
any imput (keys / mouse) for a set period of time and, if that happens,
it'll just kill the offending process....

Am I making any sense at all?

Any and all help would be greatly appreciated.

    TIA

    Javier

----

Hm..what's this red button fo:=/07<NO CARRIER





From _cardiac_@yahoo.com  Wed Jun  6 01:12:53 2001
From: _cardiac_@yahoo.com (CARDIAC ARREST)
Date: Tue, 5 Jun 2001 17:12:53 -0700 (PDT)
Subject: [Tutor] (no subject)
Message-ID: <20010606001253.97275.qmail@web13904.mail.yahoo.com>

 A big THANK YOU for the replies i have got from my
post i wasnt sure about doing it but im glad i did
thank you all again!!!

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/


From ak@silmarill.org  Wed Jun  6 01:30:50 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Tue, 05 Jun 2001 20:30:50 -0400
Subject: [Tutor] Access to Windows Timers / Idle "states"??
In-Reply-To: <"from python.tutorial"@jarava.org>
References: <006901c0ee1b$39375870$0124a8c0@uno>
Message-ID: <20010605203050.A24683@sill.silmarill.org>

On Wed, Jun 06, 2001 at 01:57:04AM +0200, Javier JJ wrote:
> Hi all!!
> 
> After some "lurking" on the list (and not too much time to program, either
> :-) I've decided to jump with both feet in :-)
> 
> I'm trying to make a program that can handle "timers" (ie, set a timer for
> "x" seconds later) and / or "register" itself to recieve windows events.
> 
> The idea is, when I launch this program, I want to be able to set a certain
> amount of time after whihc I want my program to do something (namely, kill
> another program :-)
> 
> At the moment, the "killing another program" would be handled with the
> pslist and pskill utils from sysinternals, so I "only" want to be able to
> set a timer...
> 
> Alternatively, I'd like to be able to "know" when the "idle" process kicks
> in, like to know when the countdown for the screensaver starts....
> 
> The thing is, I have a program that every now and then locks itself solid
> and the only way out is a hard reboot (even in W2k, ctrl-alt-del won't work,
> even though the OS "seems" to be getting the keys, and the mouse cursor
> moves). So, I'd like to be able to "sense" when the OS hasn't been getting
> any imput (keys / mouse) for a set period of time and, if that happens,
> it'll just kill the offending process....
> 
> Am I making any sense at all?

Sort of :-). I don't use windows anymore, so I can only help with the timer
thing.. the command for it is time.sleep(5) to sleep for 5 seconds. If you want
to set hours or minutes, the way to do so is this: time.sleep(60*60*3.5) for 3.5
hours, for instance. Also, you have time.time() which gives you current time in
seconds from the start of epoch (~1970). 

Anyway, in order for timer to work, here's what you can do:

sense_keypress()
time.sleep(60)
if not keypresses_happened():
    os.kill(someprog)

Look at docs for os.kill.

time.time() you can use to tell how long something took, like this:

t = time.time()
do_something()
print 'do_something() took %d seconds' % (time.time() - t)


> 
> Any and all help would be greatly appreciated.
> 
>     TIA
> 
>     Javier
> 
> ----
> 
> Hm..what's this red button fo:=/07<NO CARRIER
> 
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lucifer Sam Siam cat
Always sitting by your side
Always by your side
That cat's something I can't explain
        - Syd


From dsh8290@rit.edu  Wed Jun  6 03:24:53 2001
From: dsh8290@rit.edu (D-Man)
Date: Tue, 5 Jun 2001 22:24:53 -0400
Subject: [Tutor] Access to Windows Timers / Idle "states"??
In-Reply-To: <006901c0ee1b$39375870$0124a8c0@uno>; from python.tutorial@jarava.org on Wed, Jun 06, 2001 at 01:57:04AM +0200
References: <006901c0ee1b$39375870$0124a8c0@uno>
Message-ID: <20010605222453.B14318@harmony.cs.rit.edu>

On Wed, Jun 06, 2001 at 01:57:04AM +0200, Javier JJ wrote:
...
| The thing is, I have a program that every now and then locks itself solid
| and the only way out is a hard reboot (even in W2k, ctrl-alt-del won't work,
| even though the OS "seems" to be getting the keys, and the mouse cursor
| moves). 

I've seen this with win2k also.  Sometimes it is the OS's own fault as
it tries to shutdown (though sometimes I wonder if it is really trying
...)

| So, I'd like to be able to "sense" when the OS hasn't been getting
| any imput (keys / mouse) for a set period of time and, if that
| happens, it'll just kill the offending process....
| 
| Am I making any sense at all?

Yes -- you want to prevent your OS from locking up (IOW failing to
meet its requirements).  The solution is much simpler : use Debian! <grin>

Sorry, not much help with the code, but I don't try and fix windows by
writing my own watchdog timer <wink> and am not sure how you would do
that reliably.

-D



From dyoo@hkn.eecs.berkeley.edu  Wed Jun  6 07:53:38 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 5 Jun 2001 23:53:38 -0700 (PDT)
Subject: [Tutor] Converting problem sets from other languages into Python?
Message-ID: <Pine.LNX.4.21.0106052338200.10350-100000@hkn.eecs.berkeley.edu>

Hiya everyone,

A while back, some people asked for sample problems that they could do to
test out their fluency in Python.  Usually, self-motivated projects are
idea at letting people make their knowledge relevant, but sometimes,
people don't know where to start!

Perhaps we should also provide a small "problem set" repository.  Sorta
like mini-exercises, with some hints at how to approach a problem.  
Useless Python already does a little bit of this with its Python
Challenges at:

    http://www.lowerstandard.com/python/pythonchallenge.html

and perhaps this can be extended with more problems.

In short: why not stea... er... convert problems from some textbooks to
make them Python-relevant?  By providing these practical problems, we'd
let people gain more confidence as they find they can do these things.  
Extending "Useless Python", we can have "Useless Python Problems".  
*grin*


I have a few problems written in Scheme, which I should be able to convert
into Python:

    http://hkn.eecs.berkeley.edu/~dyoo/cs3/doublets.pdf
    http://hkn.eecs.berkeley.edu/~dyoo/cs3/wordprocessing.pdf

(which have too much of a CS flavor, admittedly, but I have to start
somewhere.)

What do people think?



From wheelege@tsn.cc  Wed Jun  6 08:45:39 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Wed, 6 Jun 2001 17:45:39 +1000
Subject: [Tutor] Converting problem sets from other languages into Python?
References: <Pine.LNX.4.21.0106052338200.10350-100000@hkn.eecs.berkeley.edu>
Message-ID: <01e801c0ee5c$afeb28c0$0200a8c0@ACE>

> <...>
>
> What do people think?
>

  Great idea!

  Some good all-round computer problems can be found at
http://www.cse.unsw.edu.au/progcomp - just click on the links to see the
problems for the various years (the grand final ones are particularly fun
:).

  Glen.



From wheelege@tsn.cc  Wed Jun  6 09:41:18 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Wed, 6 Jun 2001 18:41:18 +1000
Subject: [Tutor] Recursion
Message-ID: <021401c0ee64$75b65dc0$0200a8c0@ACE>

This is a multi-part message in MIME format.

------=_NextPart_000_0211_01C0EEB8.4655DFC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

  Hey all,

  While fiddling around with maths, I thought it would be nice and cool =
to get all the possible permutations of a set, taken n at a time.  I =
have been trying to get this to work nicely, but I'm just not familiar =
enough with recursion to get it to behave.
  For example, if I wanted to get all the permutations of a set =
['a','b'] taken three at a time, I would write this :

>>> c =3D []
>>> s =3D ['a', 'b']
>>> for i1 in range(len(s)):
...  for i2 in range(len(s)):
...   for i3 in range(len(s)):
...    c.append([s[i1], s[i2], s[i3]])
...=20
>>> for item in c: print item
...=20
['a', 'a', 'a']
['a', 'a', 'b']
['a', 'b', 'a']
['a', 'b', 'b']
['b', 'a', 'a']
['b', 'a', 'b']
['b', 'b', 'a']
['b', 'b', 'b']

  Which is all well and good, but when I want to take them n at a time I =
need more for loops.  Thus I thought 'Hmmm, I could get a function which =
calls itself n times...that would work!' - but I'm just too green with =
this sort of programming for it to happen for me.
  Help?

  Thanks,
  Glen.

------=_NextPart_000_0211_01C0EEB8.4655DFC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>&nbsp; Hey all,</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; While fiddling around with maths, I thought it would be nice =
and=20
cool to get all the possible permutations of a set, taken n at a =
time.&nbsp; I=20
have been trying to get this to work nicely, but I'm just not familiar =
enough=20
with recursion to get it to behave.</DIV>
<DIV>&nbsp; For example, if I wanted to get all the&nbsp;permutations of =
a set=20
['a','b'] taken three at a time, I would write this :</DIV>
<DIV>&nbsp;</DIV>
<DIV>&gt;&gt;&gt; c =3D []<BR>&gt;&gt;&gt; s =3D ['a', =
'b']<BR>&gt;&gt;&gt; for i1=20
in range(len(s)):<BR>... &nbsp;for i2 in range(len(s)):<BR>... =
&nbsp;&nbsp;for=20
i3 in range(len(s)):<BR>... &nbsp;&nbsp;&nbsp;c.append([s[i1], s[i2],=20
s[i3]])<BR>... <BR>&gt;&gt;&gt; for item in c: print item<BR>... =
<BR>['a', 'a',=20
'a']<BR>['a', 'a', 'b']<BR>['a', 'b', 'a']<BR>['a', 'b', 'b']<BR>['b', =
'a',=20
'a']<BR>['b', 'a', 'b']<BR>['b', 'b', 'a']<BR>['b', 'b', 'b']<BR></DIV>
<DIV>&nbsp; Which is all well and good, but when I want to take them n =
at a time=20
I need more for loops.&nbsp; Thus I thought 'Hmmm, I could get a =
function which=20
calls itself n times...that would work!'&nbsp;- but I'm just too green =
with this=20
sort of programming for it to happen for me.</DIV>
<DIV>&nbsp; Help?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Thanks,</DIV>
<DIV>&nbsp; Glen.</DIV></BODY></HTML>

------=_NextPart_000_0211_01C0EEB8.4655DFC0--



From scarblac@pino.selwerd.nl  Wed Jun  6 10:28:03 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 6 Jun 2001 11:28:03 +0200
Subject: [Tutor] Recursion
In-Reply-To: <021401c0ee64$75b65dc0$0200a8c0@ACE>; from wheelege@tsn.cc on Wed, Jun 06, 2001 at 06:41:18PM +1000
References: <021401c0ee64$75b65dc0$0200a8c0@ACE>
Message-ID: <20010606112803.A19167@pino.selwerd.nl>

On  0, Glen Wheeler <wheelege@tsn.cc> wrote:
>   Hey all,
> 
>   While fiddling around with maths, I thought it would be nice and cool to get all the possible permutations of a set, taken n at a time.  I have been trying to get this to work nicely, but I'm just not familiar enough with recursion to get it to behave.
>   For example, if I wanted to get all the permutations of a set ['a','b'] taken three at a time, I would write this :
> 
> >>> c = []
> >>> s = ['a', 'b']
> >>> for i1 in range(len(s)):
> ...  for i2 in range(len(s)):
> ...   for i3 in range(len(s)):
> ...    c.append([s[i1], s[i2], s[i3]])
> ... 
> >>> for item in c: print item
> ... 
> ['a', 'a', 'a']
> ['a', 'a', 'b']
> ['a', 'b', 'a']
> ['a', 'b', 'b']
> ['b', 'a', 'a']
> ['b', 'a', 'b']
> ['b', 'b', 'a']
> ['b', 'b', 'b']
> 
> Which is all well and good, but when I want to take them n at a time I
> need more for loops.  Thus I thought 'Hmmm, I could get a function which
> calls itself n times...that would work!' - but I'm just too green with this
> sort of programming for it to happen for me.

The way to think about recursion is solving the problem by solving a smaller
version of the problem first, until you get a smaller problem that's easy to
solve. In this case, the reasoning goes something like this:

You can get all the permutations of a list by taking each element in turn,
and then add to that element all the permutations of the *rest* of the list.
That rest is smaller than the list itself. And the problem is trivial for a
list of length 1 or 0. So we can use recursion.

We get something like this:

def permutations(L):
   result = []
   if len(L) <= 1:
      # The single result is the list itself
      result.append(L[:])
   else:
      for i in range(len(L)):
         # We pick element i, and combine it with the permutations of the rest
	 rest = L[:i] + L[i+1:]
         for permutation in permutations(rest):
            result.append([L[i]]+permutation)
   return result

-- 
Remco Gerlich


From dyoo@hkn.eecs.berkeley.edu  Wed Jun  6 10:35:31 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 6 Jun 2001 02:35:31 -0700 (PDT)
Subject: [Tutor] Recursion
In-Reply-To: <021401c0ee64$75b65dc0$0200a8c0@ACE>
Message-ID: <Pine.LNX.4.21.0106060209460.11718-100000@hkn.eecs.berkeley.edu>

On Wed, 6 Jun 2001, Glen Wheeler wrote:

>   For example, if I wanted to get all the permutations of a set
> ['a','b'] taken three at a time, I would write this :
> 
> >>> c = []
> >>> s = ['a', 'b']
> >>> for i1 in range(len(s)):
> ...  for i2 in range(len(s)):
> ...   for i3 in range(len(s)):
> ...    c.append([s[i1], s[i2], s[i3]])
> ... 
> >>> for item in c: print item
> ... 
> ['a', 'a', 'a']
> ['a', 'a', 'b']
> ['a', 'b', 'a']
> ['a', 'b', 'b']
> ['b', 'a', 'a']
> ['b', 'a', 'b']
> ['b', 'b', 'a']
> ['b', 'b', 'b']
> 
>   Which is all well and good, but when I want to take them n at a time
> I need more for loops.  Thus I thought 'Hmmm, I could get a function
> which calls itself n times...that would work!' - but I'm just too
> green with this sort of programming for it to happen for me.

Hello Glen!

To see the recursion, we should look at some small cases of the problem
first.  As background for the others: the idea of recursion is to see a
relationship between the "big" version of a problem and a slightly smaller
version.  By seeing this relationship, we may be able to solve the big
problem by taking advantage of the solution for the small one.


In this problem, we're measuring bigness by 'n at a time'.  The bigger 'n'
gets, the larger the problem.  Let's take a really close look at what the
program should do when n is equal to 1, 2, and 3.  Once we do this, things
might look clearer (or more blurry, depending on how long we strain our
eyes... *grin*)


We know that taking the one_at_a_time() on this list ['a', 'b'] should
look like:

    [ ['a'],
      ['b'] ]

Let's pretend we have that function to play with.  We can imagine what the
result of two_at_a_time() looks like:

    [ ['a', 'a'],
      ['a', 'b'],

      ['b', 'a'],
      ['b', 'b'] ]


I'm intensionally printing two_at_a_time()'s result in 2 visually distinct
blocks because, if we look at this for a little bit, we might see a small
pattern.  In order to get two_at_a_time(), all we need to do is take every
element in one_at_a_time, and plunk either 'a' or 'b' in front.  This can
be written as:


###
def two_at_a_time(L):
    source = one_at_a_time(L)
    c = []
    for x in L:
        for s in source:
            c.append([x] + s)
###


Ok, let's look at three_at_a_time() and see if there's a relationship
between it and two_at_a_time:


    [ ['a', 'a', 'a'],
      ['a', 'a', 'b'],
      ['a', 'b', 'a'],
      ['a', 'b', 'b'],

      ['b', 'a', 'a'],
      ['b', 'a', 'b'],
      ['b', 'b', 'a'],
      ['b', 'b', 'b'], ]


Same idea: let's use two_at_a_time() to solve three_at_a_time()!  The
definition for three_at_a_time() will eerily familiar...

###
def three_at_a_time(L):
    source = two_at_a_time(L)
    c = []
    for x in L:
        for s in source:
            c.append([x] + s)
###


This should give you enough to write n_at_a_time().  If you have any
questions, please feel free to ask.  Good luck!



From scarblac@pino.selwerd.nl  Wed Jun  6 10:38:36 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 6 Jun 2001 11:38:36 +0200
Subject: [Tutor] Recursion
In-Reply-To: <021401c0ee64$75b65dc0$0200a8c0@ACE>; from wheelege@tsn.cc on Wed, Jun 06, 2001 at 06:41:18PM +1000
References: <021401c0ee64$75b65dc0$0200a8c0@ACE>
Message-ID: <20010606113836.A19201@pino.selwerd.nl>

On  0, Glen Wheeler <wheelege@tsn.cc> wrote:
>   Hey all,
> 
>   While fiddling around with maths, I thought it would be nice and cool to get all the possible permutations of a set, taken n at a time.  I have been trying to get this to work nicely, but I'm just not familiar enough with recursion to get it to behave.
>   For example, if I wanted to get all the permutations of a set ['a','b'] taken three at a time, I would write this :
> 
> >>> c = []
> >>> s = ['a', 'b']
> >>> for i1 in range(len(s)):
> ...  for i2 in range(len(s)):
> ...   for i3 in range(len(s)):
> ...    c.append([s[i1], s[i2], s[i3]])
> ... 
> >>> for item in c: print item
> ... 
> ['a', 'a', 'a']
> ['a', 'a', 'b']
> ['a', 'b', 'a']
> ['a', 'b', 'b']
> ['b', 'a', 'a']
> ['b', 'a', 'b']
> ['b', 'b', 'a']
> ['b', 'b', 'b']

Wait. In my other mail, I solved the wrong problem :-)
I read 'permutations' and stopped reading.

You want to make lists of length n with elements taking from a list L;
again, solve it by making all the lists of length n-1, where length 0 is
trivial, and combine them with all the possible elements:

def permutations2(L, n):   # What's the proper name for this, anyway?
   if n == 0:
      return [[]]
   result = []
   
   # Compute this outside the loop
   smaller_lists = permutations2(L, n-1)
   
   for element in L:
      for l in smaller_lists:
         result.append([element]+l)
   return result

(untested)
-- 
Remco Gerlich


From dyoo@hkn.eecs.berkeley.edu  Wed Jun  6 10:41:30 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 6 Jun 2001 02:41:30 -0700 (PDT)
Subject: [Tutor] Recursion
In-Reply-To: <Pine.LNX.4.21.0106060209460.11718-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.21.0106060238440.11718-100000@hkn.eecs.berkeley.edu>

On Wed, 6 Jun 2001, Daniel Yoo wrote:

> ###
> def two_at_a_time(L):
>     source = one_at_a_time(L)
>     c = []
>     for x in L:
>         for s in source:
>             c.append([x] + s)
> ###

Oops.  Ok, I need to make a correction of a very silly bug:


###
def two_at_a_time(L):
    source = one_at_a_time(L)
    c = []
    for x in L:
        for s in source:
            c.append([x] + s)
    return c
###

The program I wrote did all this neat work, but it never gave the answer
back to us!  Ugh.  Same bug with three_at_a_time().  Sorry about that.



From wheelege@tsn.cc  Wed Jun  6 10:58:47 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Wed, 6 Jun 2001 19:58:47 +1000
Subject: [Tutor] Recursion
References: <021401c0ee64$75b65dc0$0200a8c0@ACE> <20010606113836.A19201@pino.selwerd.nl>
Message-ID: <023b01c0ee6f$4870b3a0$0200a8c0@ACE>

  Thanks Daniel for the great explanation+thought process, and Remco for
inadverdently answering two questions.
  You two surely are a very effective one-two in this list :)

  Thanks again,
  Glen.



From Eugene.Leitl@lrz.uni-muenchen.de  Wed Jun  6 11:29:05 2001
From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl)
Date: Wed, 6 Jun 2001 12:29:05 +0200 (MET DST)
Subject: [Tutor] parsing a blank-separated string into a list
Message-ID: <Pine.SOL.4.33.0106061225180.8647-100000@sun1.lrz-muenchen.de>

Assuming, I have a string like this (produced by the JME applet,
encoding a molecule I entered):

10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C
8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3
1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1

And want to turn it into a list like this:

[10, 11, C, 9.13 ... ]

How do I do it?

jmelist = map(None, jmevalue) produces

[1, 0, 1, 1, C, ...], whereas I want the blank-separted atoms.

Is there an idiom for that? (I mean, it's of course possible to do it by
hand, but it's not Python Zen).



From SBrunning@trisystems.co.uk  Wed Jun  6 11:51:22 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Wed, 6 Jun 2001 11:51:22 +0100
Subject: [Tutor] parsing a blank-separated string into a list
Message-ID: <31575A892FF6D1118F5800600846864D78BCEA@intrepid>

> From:	Eugene Leitl [SMTP:Eugene.Leitl@lrz.uni-muenchen.de]
> Assuming, I have a string like this (produced by the JME applet,
> encoding a molecule I entered):
> 
> 10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C
> 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3
> 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1
> 
> And want to turn it into a list like this:
> 
> [10, 11, C, 9.13 ... ]
> 
> How do I do it?
> 
> jmelist = map(None, jmevalue) produces
> 
> [1, 0, 1, 1, C, ...], whereas I want the blank-separted atoms.
 
Try this

mystring = '''10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C
7.92 -6.75 C 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13
-6.05 1 2 2 1 3 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10
1'''
mylist = mystring.split()

At this point, mylist consists of a list of strings. It looks like you want
the numeric strings converted into numbers. Floats by the look of it. Now,
if your strings were *all* numeric, you could do:

mylist = [float(value) for value in mylist]

and you would be fine. List comprehensions are nice. ;-)

But in your case, this would blow up with a ValueError when trying to
convert the alphabetic characters, so we'll have to do this the old
fashioned way:

for index in range(len(mylist)):
    try:
        mylist[index] = float(mylist[index])
    except ValueError:
        pass

BTW, if you are not familiar with floats, you have a lot of surprises coming
up. If you are, then you *still* have a lot of surprises coming up. ;-)

HTH,
Simon B.




-----------------------------------------------------------------------
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 rob@jam.rr.com  Wed Jun  6 12:11:51 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 06 Jun 2001 06:11:51 -0500
Subject: [Tutor] Converting problem sets from other languages into Python?
References: <Pine.LNX.4.21.0106052338200.10350-100000@hkn.eecs.berkeley.edu>
Message-ID: <3B1E0FF7.DD2600D6@jam.rr.com>

Daniel Yoo wrote:
> 
> Hiya everyone,
> 
> A while back, some people asked for sample problems that they could do to
> test out their fluency in Python.  Usually, self-motivated projects are
> idea at letting people make their knowledge relevant, but sometimes,
> people don't know where to start!
> 
> Perhaps we should also provide a small "problem set" repository.  Sorta
> like mini-exercises, with some hints at how to approach a problem.
> Useless Python already does a little bit of this with its Python
> Challenges at:
> 
>     http://www.lowerstandard.com/python/pythonchallenge.html
> 
> and perhaps this can be extended with more problems.
> 
> In short: why not stea... er... convert problems from some textbooks to
> make them Python-relevant?  By providing these practical problems, we'd
> let people gain more confidence as they find they can do these things.
> Extending "Useless Python", we can have "Useless Python Problems".
> *grin*
> 
> I have a few problems written in Scheme, which I should be able to convert
> into Python:
> 
>     http://hkn.eecs.berkeley.edu/~dyoo/cs3/doublets.pdf
>     http://hkn.eecs.berkeley.edu/~dyoo/cs3/wordprocessing.pdf
> 
> (which have too much of a CS flavor, admittedly, but I have to start
> somewhere.)
> 
> What do people think?
> 

This is just the sort of thing I had in mind. I'd thought of
swip^^^^converting some of the problems from my books on other
languages, partly so I could figure out how to actually get them
accomplished in Python (which is easier) so I'd have a frame of
reference on how do do them in the other languages.

But I think the bottom line is that newbies, teachers, and other people
interested in the Python learning process NEED good CS-type problems and
some proposed solutions. I believe that every ACM problem we can solve
in Python, and every good classical or practical problem we can do it
with, will help us learn the language and add significantly to the
Python legacy.

Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From rob@jam.rr.com  Wed Jun  6 12:15:15 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 06 Jun 2001 06:15:15 -0500
Subject: [Tutor] Recursion
References: <021401c0ee64$75b65dc0$0200a8c0@ACE> <20010606113836.A19201@pino.selwerd.nl> <023b01c0ee6f$4870b3a0$0200a8c0@ACE>
Message-ID: <3B1E10C3.342CF072@jam.rr.com>

Glen Wheeler wrote:
> 
>   Thanks Daniel for the great explanation+thought process, and Remco for
> inadverdently answering two questions.
>   You two surely are a very effective one-two in this list :)
> 
>   Thanks again,
>   Glen.
> 

A few of us in Mississippi still suspect that Danny and Remco are
actually sophisticated bot scripts that Guido brought back from the
future in his time machine.

Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From steve@mercury.in.cqsl.com  Wed Jun  6 11:56:41 2001
From: steve@mercury.in.cqsl.com (lonetwin@yahoo.com)
Date: Wed, 6 Jun 2001 16:26:41 +0530 (IST)
Subject: [Tutor] parsing a blank-separated string into a list
In-Reply-To: <Pine.SOL.4.33.0106061225180.8647-100000@sun1.lrz-muenchen.de>
Message-ID: <Pine.LNX.4.21.0106061622070.1923-100000@mercury.in.cqsl.com>

On Wed, 6 Jun 2001, Eugene Leitl wrote:


>10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C
>8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3
>1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1
>
>And want to turn it into a list like this:
>
>[10, 11, C, 9.13 ... ]
>
>How do I do it?

>>>import string
>>> p = '10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C ...'
>>> string.split(p)
['10', '11', 'C', '9.13', '-8.85', 'C', '10.34', '-8.15', 'C', '7.92', '-8.15',
'C', '10.34', '-6.75', 'C', '...']

:)
if u have python 2.0, don't import string, just do a 
p.split()

Peace
Steve
-- 
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||	
|||/\##|||||||||##/\||	
|/    \#########/    \	
|\     \#######/     /	
||\____/#######\____/|	
=====================================	
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
====================================



From rob@jam.rr.com  Wed Jun  6 12:44:46 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 06 Jun 2001 06:44:46 -0500
Subject: [Tutor] Converting problem sets from other languages into Python?
References: <Pine.LNX.4.21.0106052338200.10350-100000@hkn.eecs.berkeley.edu> <01e801c0ee5c$afeb28c0$0200a8c0@ACE>
Message-ID: <3B1E17AE.523862B4@jam.rr.com>

Glen Wheeler wrote:
> 
> > <...>
> >
> > What do people think?
> >
> 
>   Great idea!
> 
>   Some good all-round computer problems can be found at
> http://www.cse.unsw.edu.au/progcomp - just click on the links to see the
> problems for the various years (the grand final ones are particularly fun
> :).
> 
>   Glen.
> 

Superlative, Glen! I've added this material to the list of programming
contest problem links on the appropriate Useless page:

http://www.lowerstandard.com/python/acmcontest.html

While we're kinda on the subject, I'll go ahead and leak an up-coming
feature for Useless. (First I need to finish the program that will
automatically generate the HTML pages, but I'm mostly there.)

Once it's begun, for each script someone contributes to Useless, the
contributor will be able to add an icon to a script by someone else,
indicating one of several things ("I actually used this", "I learned
something from this", "This is indeed Useless", etc.). But for each
programming contest or Python Challenge solution, the contributor will
receive two of these. Aside from adding some humor and interesting
commentary to the scripts, I'm hoping this will encourage budding coders
to share their gifts more.

Okay, I'm done now,
Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From wheelege@tsn.cc  Wed Jun  6 12:59:20 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Wed, 6 Jun 2001 21:59:20 +1000
Subject: [Tutor] Converting problem sets from other languages into Python?
References: <Pine.LNX.4.21.0106052338200.10350-100000@hkn.eecs.berkeley.edu> <01e801c0ee5c$afeb28c0$0200a8c0@ACE> <3B1E17AE.523862B4@jam.rr.com>
Message-ID: <029701c0ee80$1fba46e0$0200a8c0@ACE>

> Superlative, Glen! I've added this material to the list of programming
> contest problem links on the appropriate Useless page:
>
> http://www.lowerstandard.com/python/acmcontest.html
>

  Thanks.  I just went to investigate what you added, and noticed that only
the sample problems are there - if you link to the parent page
(http://www.cse.unsw.edu.au/~progcomp/) then there are actually links to a
very many more problems.  Also from this page are the links to the much more
entertaining grand final problems.  These links are under the heading
'ProgComp in past years', it's on the right of the page near the bottom.
  The ones your linked to now actually have worked solutions written out for
them, wheras the others don't (yet).

> While we're kinda on the subject, I'll go ahead and leak an up-coming
> feature for Useless. (First I need to finish the program that will
> automatically generate the HTML pages, but I'm mostly there.)
>

  If you need help... :)

> Once it's begun, for each script someone contributes to Useless, the
> contributor will be able to add an icon to a script by someone else,
> indicating one of several things ("I actually used this", "I learned
> something from this", "This is indeed Useless", etc.). But for each
> programming contest or Python Challenge solution, the contributor will
> receive two of these. Aside from adding some humor and interesting
> commentary to the scripts, I'm hoping this will encourage budding coders
> to share their gifts more.
>

  Sounds like an excellent idea!  I won't be able to hold back my flood of
scripts then :)

  Glen.

> Okay, I'm done now,
> Rob



From rob@jam.rr.com  Wed Jun  6 13:15:16 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 06 Jun 2001 07:15:16 -0500
Subject: [Tutor] Converting problem sets from other languages into Python?
References: <Pine.LNX.4.21.0106052338200.10350-100000@hkn.eecs.berkeley.edu> <01e801c0ee5c$afeb28c0$0200a8c0@ACE> <3B1E17AE.523862B4@jam.rr.com> <029701c0ee80$1fba46e0$0200a8c0@ACE>
Message-ID: <3B1E1ED4.F2B89880@jam.rr.com>

Glen Wheeler wrote:
> 
> > Superlative, Glen! I've added this material to the list of programming
> > contest problem links on the appropriate Useless page:
> >
> > http://www.lowerstandard.com/python/acmcontest.html
> >
> 
>   Thanks.  I just went to investigate what you added, and noticed that only
> the sample problems are there - if you link to the parent page
> (http://www.cse.unsw.edu.au/~progcomp/) then there are actually links to a
> very many more problems.  Also from this page are the links to the much more
> entertaining grand final problems.  These links are under the heading
> 'ProgComp in past years', it's on the right of the page near the bottom.
>   The ones your linked to now actually have worked solutions written out for
> them, wheras the others don't (yet).
> 

Thanks for catching that, Glen. My error has been remedied now.

That's what I get for pre-coffee web maintenance,
Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From python.tutorial@jarava.org  Wed Jun  6 14:10:05 2001
From: python.tutorial@jarava.org (Javier JJ)
Date: Wed, 6 Jun 2001 15:10:05 +0200
Subject: [Tutor] Access to Windows Timers / Idle "states"??
References: <006901c0ee1b$39375870$0124a8c0@uno> <20010605222453.B14318@harmony.cs.rit.edu>
Message-ID: <007d01c0ee8a$018b5560$0124a8c0@uno>

> | The thing is, I have a program that every now and then locks itself
solid
> | and the only way out is a hard reboot (even in W2k, ctrl-alt-del won't
work,
> | even though the OS "seems" to be getting the keys, and the mouse cursor
> | moves).
>
> I've seen this with win2k also.  Sometimes it is the OS's own fault as
> it tries to shutdown (though sometimes I wonder if it is really trying
> ...)

MM... Personally, I've only experienced this on programs that run fullscreen
and "take over" the display, like the program on my WinTV card, Games....
it's probably something to do with DirectX or similar... and that's a beast
I won't touch with a 10 meter pole :) So, as the OS seems to be "receiving"
input still (sometimes - not always- I've been able to ctrl-alt-del, open
the the task manager and kill the beast), I was wondering about how to
"build my own watchdog timer" :-))

> | So, I'd like to be able to "sense" when the OS hasn't been getting
> | any imput (keys / mouse) for a set period of time and, if that
> | happens, it'll just kill the offending process....
> |
> | Am I making any sense at all?
>
> Yes -- you want to prevent your OS from locking up (IOW failing to

Welll. it's not really (at least it doesn't seem) like it's really frozen
solid.. only that the screen is and not all inputs are handled.. but the
network and services go on (eprompter keeps checking the mail, etc). I had
wondered about another solution: building a xmlrpc or similar server that
would let me "kill" the offending process when triggered from another
machine. Buy having the two computers on is something I'd rather avoid :-))

> meet its requirements).  The solution is much simpler : use Debian! <grin>

Well, I do :-)) (Ok, not Debian, but Mandrake). Problem is, I haven't found
HlafLife - Front Line Force for Linux .... and besides, I don't think I
could switch to linux and be 100% productive as of yet ....

> Sorry, not much help with the code, but I don't try and fix windows by
> writing my own watchdog timer <wink> and am not sure how you would do
> that reliably.

Well, _if_ there is a way of "hooking" onto the event(s) that Windows uses
to signal "no activity" (ie, the same ones that the OS uses to know when to
fire the screensaver), that'd be fairly simple to do. ..

Thanks for the idea, though. I'll look into watchdogs :-))

    Javier

----

Famous last words - Don't worry, I can handle it.






From python.tutorial@jarava.org  Wed Jun  6 14:25:09 2001
From: python.tutorial@jarava.org (Javier JJ)
Date: Wed, 6 Jun 2001 15:25:09 +0200
Subject: [Tutor] Access to Windows Timers / Idle "states"??
References: <006901c0ee1b$39375870$0124a8c0@uno> <20010605203050.A24683@sill.silmarill.org>
Message-ID: <009f01c0ee8c$1bf55930$0124a8c0@uno>

> >
> > Am I making any sense at all?
>
> Sort of :-). I don't use windows anymore, so I can only help with the
timer
> thing.. the command for it is time.sleep(5) to sleep for 5 seconds. If you
want
> to set hours or minutes, the way to do so is this: time.sleep(60*60*3.5)
for 3.5
> hours, for instance. Also, you have time.time() which gives you current
time in
> seconds from the start of epoch (~1970).

That's really the way :-)) I only need to delay an action a set amount of
time, nothing really fancy (I know if I had to sichronize serveral things,
then I'd have to "really" build a timer to use a "general" event", But for
what I need, time.sleep probably will fit nicely :-)

> Anyway, in order for timer to work, here's what you can do:
>
> sense_keypress()

I guess the trick is here :-) I'll have to build this function.... the trick
is how, I guess :-))

> time.sleep(60)
> if not keypresses_happened():
>     os.kill(someprog)
>
> Look at docs for os.kill.

Will do :-) Pity is, "avaliability: UNIX".That's what I "Love" about
"pskill" form sysinternals... it's like kill, only for windows :-)

> time.time() you can use to tell how long something took, like this:
>
> t = time.time()
> do_something()
> print 'do_something() took %d seconds' % (time.time() - t)
>

Thanks a lot for the help :-)

    Javier
----

Famous last words - Don't worry, I can handle it.






From Eugene.Leitl@lrz.uni-muenchen.de  Wed Jun  6 14:45:12 2001
From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl)
Date: Wed, 6 Jun 2001 15:45:12 +0200 (MET DST)
Subject: [Tutor] parsing a blank-separated string into a list
In-Reply-To: <31575A892FF6D1118F5800600846864D78BCEA@intrepid>
Message-ID: <Pine.SOL.4.33.0106061539030.8647-100000@sun1.lrz-muenchen.de>

On Wed, 6 Jun 2001, Simon Brunning wrote:

> Try this
>
> mystring = '''10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C
> 7.92 -6.75 C 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13
> -6.05 1 2 2 1 3 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10
> 1'''
> mylist = mystring.split()

Thanks, but I'm stuck with 1.5.2, as 2.1 wouldn't build correctly (can't
do freezing, and too dumb to get the configuration right, as the build
procedure has changed with 2.1) on the AIX box I'm developing for.

Hence I'll stick to the suggestion of the other poster:

import string
jmelist = string.split(jmevalue)

Which works for 1.5.2. Yay!

> At this point, mylist consists of a list of strings. It looks like you want
> the numeric strings converted into numbers. Floats by the look of it. Now,

Usually a good guess, but not in this case. See below.

> if your strings were *all* numeric, you could do:
>
> mylist = [float(value) for value in mylist]
>
> and you would be fine. List comprehensions are nice. ;-)
>
> But in your case, this would blow up with a ValueError when trying to
> convert the alphabetic characters, so we'll have to do this the old
> fashioned way:
>
> for index in range(len(mylist)):
>     try:
>         mylist[index] = float(mylist[index])
>     except ValueError:
>         pass
>
> BTW, if you are not familiar with floats, you have a lot of surprises coming
> up. If you are, then you *still* have a lot of surprises coming up. ;-)

Oh, I'm familiar with them, I used to do numerics on big boxes, at least
as a user. Any "surprises" will be contained by me not processing the
float information. All I need to do is to rearrange the jme string into a
mol type:

5 6 C 8.76 -3.88 C 8.06 -5.09 C 5.96 -3.88 C 6.66 -2.66 C 7.36 -3.88 1 2 1
1 5 1 2 5 1 3 4 1 3 5 1 4 5 1

to:




  5  6  0  0  0  0  0  0  0  0  1 V2000
    8.7600   -3.8800    0.0000 C   0  0  0  0  0  0
    8.0600   -5.0900    0.0000 C   0  0  0  0  0  0
    5.9600   -3.8800    0.0000 C   0  0  0  0  0  0
    6.6600   -2.6600    0.0000 C   0  0  0  0  0  0
    7.3600   -3.8800    0.0000 C   0  0  0  0  0  0
  1  2  1  0  0  0
  1  5  1  0  0  0
  2  5  1  0  0  0
  3  4  1  0  0  0
  3  5  1  0  0  0
  4  5  1  0  0  0
M  END

It is a stupid format, but I don't have a choice. I'll post the subroutine
when I'm done, could be useful for some folks.

-- Eugene Leitl
______________________________________________________________
ICBMTO  : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204
57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3



From toodles@yifan.net  Wed Jun  6 15:18:14 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Wed, 6 Jun 2001 22:18:14 +0800
Subject: [Tutor] List mimicing
Message-ID: <FPEHJJPEEOIPMAHOADBKEEPFCDAA.toodles@yifan.net>

Hi folks,

I'm creating a class somewhat like shelve that stores a list as a file, and
provides a very list-like interface to it. I'm having troubles with __iadd__
and __imul__ however. When I call them, it deletes everything in my
file...if someone has enough time to go through my code, I would be _very_
appreciative. I'll delete the irrelevant parts to make it quicker/easier

Here's what i did to test __iadd__, __imul__ reacts the same way:

>>> import file
>>> x=file.ListShelf('a')
>>> x.get()
>>> x+=[1,2,3]
>>> x.get()
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in ?
    x.get()
AttributeError: 'None' object has no attribute 'get'
>>> print x
None

Thanks, Andrew

-------- code ----------

import cPickle,types,os

class ListShelf:
	def __init__(self,filename):
		"""
		Open file for updating if it exists, otherwise create it.
		"""
		if not os.access(filename,os.F_OK):
			os.open(filename,os.O_CREAT)
		self.file=open(filename,'r+')
	def get(self):
		return self._load()
	def _dump(self,_list):
		"""
		Seek to the beginning of file and cPickle the list to it.
		"""
		self.file.seek(0)
		cPickle.dump(_list,self.file)
	def _load(self):
		"""
		Seek to the beginning of file and un-cPickle the list from it.
		If the file is empty, return an empty list.
		"""
		self.file.seek(0)
		try:
			return cPickle.load(self.file)
		except EOFError: return []
	def __iadd__(self,other):
		"ie. list+=other"
		_list=self._load()
		_list+=other
		self._dump(_list)
	def __imul__(self,other):
		"ie. list*=other"
		_list=self._load()
		_list*=other
		self._dump(_list)




From kalle@gnupung.net  Wed Jun  6 16:14:14 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Wed, 6 Jun 2001 17:14:14 +0200
Subject: [Tutor] List mimicing
In-Reply-To: <FPEHJJPEEOIPMAHOADBKEEPFCDAA.toodles@yifan.net>; from toodles@yifan.net on Wed, Jun 06, 2001 at 10:18:14PM +0800
References: <FPEHJJPEEOIPMAHOADBKEEPFCDAA.toodles@yifan.net>
Message-ID: <20010606171414.A11739@father>

Sez Andrew Wilkins:
> Hi folks,
> 
> I'm creating a class somewhat like shelve that stores a list as a file, and
> provides a very list-like interface to it. I'm having troubles with __iadd__
> and __imul__ however.
[snip]

You want to take a look at the class UserList in the module UserList in the
standard library.

> -------- code ----------
> 
> import cPickle,types,os
> 
> class ListShelf:
[snip]
> 	def __iadd__(self,other):
> 		"ie. list+=other"
> 		_list=self._load()
> 		_list+=other
> 		self._dump(_list)

                return self

> 	def __imul__(self,other):
> 		"ie. list*=other"
> 		_list=self._load()
> 		_list*=other
> 		self._dump(_list)

                return self

Peace,
  Kalle
-- 
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
 [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]


From tescoil@irtc.net  Wed Jun  6 17:04:45 2001
From: tescoil@irtc.net (Tesla Coil)
Date: Wed, 06 Jun 2001 11:04:45 -0500
Subject: [Tutor] Converting problem sets from other languages into Python?
References: <Pine.LNX.4.21.0106052338200.10350-100000@hkn.eecs.berkeley.edu> <01e801c0ee5c$afeb28c0$0200a8c0@ACE> <3B1E17AE.523862B4@jam.rr.com>
Message-ID: <3B1E549D.95898EA4@irtc.net>

On 6 June 2001, Rob Andrews wrote:
> While we're kinda on the subject, I'll go ahead
> and leak an up-coming feature for Useless. (First
> I need to finish the program that will automatically
> generate the HTML pages, but I'm mostly there.)
>
> Once it's begun, for each script someone contributes
> to Useless, the contributor will be able to add an
> icon to a script by someone else, indicating one of
> several things ("I actually used this", "I learned
> something from this", "This is indeed Useless", etc.).

Should have voting review skill and style rather 
than utility, e.g, Elegant, Genius from Mars,
Runs with Square Wheels, Just When You Thought
Obfuscated Python Didn't Exist, etc.  This sort
of commentary can be made regardless of what a
program proposes to do.  And, however one rates
the utility of working code to solve the Knight's
Tour puzzle (I, for one, am not too sure), the
question is probably of less consequence to the
programmer's next effort than what could be said
of how well it was implemented.



From GBunting864@Worldsavings.com  Wed Jun  6 17:09:55 2001
From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x))
Date: Wed, 6 Jun 2001 11:09:55 -0500
Subject: [Tutor] python and Microsoft proxy server
Message-ID: <97E9FA3149D0D311BE5800008349BB27016692F8@ok1ems1.worldsavings.com>

Hi,

I am trying to learn Python and I would like to try out the urllib module.
The problem is everything here goes out through Microsoft's Proxy server
which authenticates with NTLM.  Is there any way to allow Python to
authenticate with the proxy server so I can get to the Internet with Python?

Thanks,

Glen


*****************************************************************************
If you are not the intended recipient of this e-mail, please notify 
the sender immediately. The contents of this e-mail do not amend 
any existing disclosures or agreements unless expressly stated.
*****************************************************************************


From britt_green@hotmail.com  Wed Jun  6 17:29:05 2001
From: britt_green@hotmail.com (Britt Green)
Date: Wed, 06 Jun 2001 09:29:05 -0700
Subject: [Tutor] Paths under WinNT?
Message-ID: <F46y0EyNgUo2hYsQUoL00005174@hotmail.com>

Hey,

I was wondering if someone could help me set up my path under Windows NT. Is 
there a way to point it to the Python2.1 folder, so it'll see everything 
that lives underneath that? Currently, if I have a class in a folder within 
Python 2.1 and try to import it, Python can't find it. I'm in the position 
of not knowing enough about WinNT to change my path so any advice is 
welcome.

Britt

--
It is pitch black. You are likely to be eaten by a grue.

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From GBunting864@Worldsavings.com  Wed Jun  6 17:41:30 2001
From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x))
Date: Wed, 6 Jun 2001 11:41:30 -0500
Subject: [Tutor] Paths under WinNT?
Message-ID: <97E9FA3149D0D311BE5800008349BB27016693B5@ok1ems1.worldsavings.com>

Britt,

To set the path, all you need to do is right click on My Computer and choose
properties. Then click on the environment tab, highlight path under the
system variables, then add the path you want entered in the value section.

Glen

 -----Original Message-----
From: 	Britt Green [mailto:britt_green@hotmail.com] 
Sent:	Wednesday, June 06, 2001 9:29 AM
To:	tutor@python.org
Subject:	[Tutor] Paths under WinNT?

Hey,

I was wondering if someone could help me set up my path under Windows NT. Is

there a way to point it to the Python2.1 folder, so it'll see everything 
that lives underneath that? Currently, if I have a class in a folder within 
Python 2.1 and try to import it, Python can't find it. I'm in the position 
of not knowing enough about WinNT to change my path so any advice is 
welcome.

Britt

--
It is pitch black. You are likely to be eaten by a grue.

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


*****************************************************************************
If you are not the intended recipient of this e-mail, please notify 
the sender immediately. The contents of this e-mail do not amend 
any existing disclosures or agreements unless expressly stated.
*****************************************************************************


From dsh8290@rit.edu  Wed Jun  6 18:03:45 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 6 Jun 2001 13:03:45 -0400
Subject: [Tutor] Access to Windows Timers / Idle "states"??
In-Reply-To: <007d01c0ee8a$018b5560$0124a8c0@uno>; from python.tutorial@jarava.org on Wed, Jun 06, 2001 at 03:10:05PM +0200
References: <006901c0ee1b$39375870$0124a8c0@uno> <20010605222453.B14318@harmony.cs.rit.edu> <007d01c0ee8a$018b5560$0124a8c0@uno>
Message-ID: <20010606130345.E12381@connecticut.cs.rit.edu>

On Wed, Jun 06, 2001 at 03:10:05PM +0200, Javier JJ wrote:
| > | So, I'd like to be able to "sense" when the OS hasn't been getting
| > | any imput (keys / mouse) for a set period of time and, if that
| > | happens, it'll just kill the offending process....
| > |
| > | Am I making any sense at all?
| >
| > Yes -- you want to prevent your OS from locking up (IOW failing to
| 
| Welll. it's not really (at least it doesn't seem) like it's really frozen
| solid.. only that the screen is and not all inputs are handled.. but the
| network and services go on (eprompter keeps checking the mail, etc). I had
| wondered about another solution: building a xmlrpc or similar server that
| would let me "kill" the offending process when triggered from another
| machine. Buy having the two computers on is something I'd rather avoid :-))

I think telnetd or sshd might be distributed with cygwin.  Any real
networked/multiuser OS allows for remote access anyways...

(where'd the 'su' equivalent disappear to... I shouldn't be logged in as
administrator for day-to-day work, yet I shouldn't have to log out
just to install a new toy... oh, yeah, this is windows <wink>)

| > meet its requirements).  The solution is much simpler : use Debian! <grin>
| 
| Well, I do :-)) (Ok, not Debian, but Mandrake). Problem is, I haven't found

<grin>

| HlafLife - Front Line Force for Linux .... and besides, I don't think I
| could switch to linux and be 100% productive as of yet ....
| 
| > Sorry, not much help with the code, but I don't try and fix windows by
| > writing my own watchdog timer <wink> and am not sure how you would do
| > that reliably.
| 
| Well, _if_ there is a way of "hooking" onto the event(s) that Windows uses
| to signal "no activity" (ie, the same ones that the OS uses to know when to
| fire the screensaver), that'd be fairly simple to do. ..

Does the screensaver kick in if you leave it idle long enough?  If so
then you should write a screensaver :-).  The screensaver won't be an
ordinary, flash-some-colors-on-the-screen sort of thing but it would
kill the offending process if it exists then exec the "real"
screensaver for those situations where you really want a screen saver.

I think this sort of thing would be relatively easy if MS allowed for
custom window managers because the window manager gets all input
(keyboard, mouse, etc) events and figures out whether to keep them
(and deal with it) or pass it on to the app.  I suppose, if this were
X, you could create a layer that would see all events from the X
server and determine whether to kill the bad app or not and pass them
on to the real WM.

Anyways, the telnetd or screensaver idea are the most realistic/doable
ideas.

-D



From rob@jam.rr.com  Wed Jun  6 18:28:00 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 6 Jun 2001 12:28:00 -0500
Subject: [Tutor] Converting problem sets from other languages into Python?
References: <Pine.LNX.4.21.0106052338200.10350-100000@hkn.eecs.berkeley.edu> <01e801c0ee5c$afeb28c0$0200a8c0@ACE> <3B1E17AE.523862B4@jam.rr.com> <3B1E549D.95898EA4@irtc.net>
Message-ID: <004701c0eeae$092df1a0$de00a8c0@planhouse5>

----- Original Message -----
From: "Tesla Coil" <tescoil@irtc.net>
To: "Rob Andrews" <rob@jam.rr.com>
Cc: <tutor@python.org>
Sent: Wednesday, June 06, 2001 11:04 AM
Subject: Re: [Tutor] Converting problem sets from other languages into
Python?


<snip />

>
> Should have voting review skill and style rather
> than utility, e.g, Elegant, Genius from Mars,
> Runs with Square Wheels, Just When You Thought
> Obfuscated Python Didn't Exist, etc.  This sort
> of commentary can be made regardless of what a
> program proposes to do.  And, however one rates
> the utility of working code to solve the Knight's
> Tour puzzle (I, for one, am not too sure), the
> question is probably of less consequence to the
> programmer's next effort than what could be said
> of how well it was implemented.
>
Actually, these are also options. I have quite a few in mind, and each will
have its own distinct graphic. I don't understand the *Runs with Square
Wheels* one, though. hehe

Rob

Useless Python
It's not just for breakfast anymore!
http://www.lowerstandard.com/python/index.html



From kstoner@netins.net  Wed Jun  6 18:40:43 2001
From: kstoner@netins.net (Katharine Stoner)
Date: Wed, 6 Jun 2001 12:40:43 -0500
Subject: [Tutor] beginners out there
Message-ID: <001801c0eeaf$cff1ed40$8352b1cf@oemcomputer>

This is a multi-part message in MIME format.

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

This is a shout out to all the beginners who need some help finding =
explainations on they're own.

Everything you need get to that is online documentation is at python's =
homepage.  Some of it just takes a while to get to. You have to dig a =
bit to find the good stuff.  There are some lesson plans that help on =
explaining things http://www.livewires.org.uk/python/.  This explains =
some of the lingo that goes with programing and how some of the =
fundamentals work.  Its all in html format or Adobe Acrobat reader =
format ready to be downloaded.
Alan Guald's book is probably the best easy, down to earth beginners =
book I've found.  The best way to approach this that I've found is to =
watch the tutor emails, get a book, find some tutorials, get a project, =
and start playing around with code.  Any beginner question would be fine =
here.  We have the tutor emails to help one another learn better.  I'm =
about 8 months into my Python education and it takes time to learn how =
to program with the basics.

This is just one beginner to another.

-Cameron

------=_NextPart_000_0015_01C0EE85.E67BADA0
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>This is a shout out to all the =
beginners who need=20
some help finding explainations on they're own.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Everything you need get to that is =
online=20
documentation is at python's homepage.&nbsp; Some of it just takes a =
while to=20
get to.&nbsp;You have to dig a bit to find the good stuff.&nbsp; There =
are some=20
lesson plans that help on explaining things <A=20
href=3D"http://www.livewires.org.uk/python/">http://www.livewires.org.uk/=
python/</A>.&nbsp;=20
This explains some of the lingo that goes with programing and how some =
of the=20
fundamentals work.&nbsp; Its all in html format or Adobe Acrobat reader =
format=20
ready to be downloaded.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Alan Guald's book is probably the best =
easy, down=20
to earth beginners book I've found.&nbsp; The best way to approach this =
that=20
I've found is to watch the tutor emails, get a book, find some =
tutorials, get a=20
project, and start playing around with code.&nbsp; Any beginner question =
would=20
be fine here.&nbsp; We have the tutor emails to help one another learn=20
better.&nbsp; I'm about 8 months into my Python education and it takes =
time to=20
learn how to program with the basics.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This is just one beginner to =
another.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-Cameron</FONT></DIV></BODY></HTML>

------=_NextPart_000_0015_01C0EE85.E67BADA0--



From pobrien@orbtech.com  Wed Jun  6 18:00:05 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 6 Jun 2001 12:00:05 -0500
Subject: [Tutor] Best way to strip string string padded with nulls
Message-ID: <NBBBIOJPGKJEKIECEMCBMENGJPAA.pobrien@orbtech.com>

I'm working with DDE to get data out of Goldmine. The data returned from
Goldmine is padded with nulls (and other random data, see example below). I
need to strip the resulting string down to just the relevant data. I have
some example code here that works, but I'm looking for suggestions for a
simpler or more elegant approach. Thanks.

Here is a snippet from an interactive session so you can see what I have
described above:

>>> c = conversation.Request("Contact1->Company")
>>> c
'GoldMine Software
Corporation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Ok\xf8\xff'
>>> i = c.index('\x00')
>>> i
29
>>> a = c[:i]
>>> a
'GoldMine Software Corporation'

Of course, this could also be collapsed to the following:

c = c[:c.index('\00')]

But considering the fact that I'll have to do this to every string that gets
returned via DDE requests, I'm hoping there is a better way. Thanks for the
help.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."




From ak@silmarill.org  Wed Jun  6 18:48:11 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Wed, 06 Jun 2001 13:48:11 -0400
Subject: [Tutor] Access to Windows Timers / Idle "states"??
In-Reply-To: <"from dsh8290"@rit.edu>
References: <006901c0ee1b$39375870$0124a8c0@uno>
 <20010605222453.B14318@harmony.cs.rit.edu>
 <007d01c0ee8a$018b5560$0124a8c0@uno>
 <20010606130345.E12381@connecticut.cs.rit.edu>
Message-ID: <20010606134811.A27269@sill.silmarill.org>

On Wed, Jun 06, 2001 at 01:03:45PM -0400, D-Man wrote:
> On Wed, Jun 06, 2001 at 03:10:05PM +0200, Javier JJ wrote:
> | > | So, I'd like to be able to "sense" when the OS hasn't been getting
> | > | any imput (keys / mouse) for a set period of time and, if that
> | > | happens, it'll just kill the offending process....
> | > |
> | > | Am I making any sense at all?
> | >
> | > Yes -- you want to prevent your OS from locking up (IOW failing to
> | 
> | Welll. it's not really (at least it doesn't seem) like it's really frozen
> | solid.. only that the screen is and not all inputs are handled.. but the
> | network and services go on (eprompter keeps checking the mail, etc). I had
> | wondered about another solution: building a xmlrpc or similar server that
> | would let me "kill" the offending process when triggered from another
> | machine. Buy having the two computers on is something I'd rather avoid :-))
> 
> I think telnetd or sshd might be distributed with cygwin.  Any real
> networked/multiuser OS allows for remote access anyways...
> 
> (where'd the 'su' equivalent disappear to... I shouldn't be logged in as
> administrator for day-to-day work, yet I shouldn't have to log out
> just to install a new toy... oh, yeah, this is windows <wink>)
> 
> | > meet its requirements).  The solution is much simpler : use Debian! <grin>
> | 
> | Well, I do :-)) (Ok, not Debian, but Mandrake). Problem is, I haven't found
> 
> <grin>
> 
> | HlafLife - Front Line Force for Linux .... and besides, I don't think I
> | could switch to linux and be 100% productive as of yet ....
> | 
> | > Sorry, not much help with the code, but I don't try and fix windows by
> | > writing my own watchdog timer <wink> and am not sure how you would do
> | > that reliably.
> | 
> | Well, _if_ there is a way of "hooking" onto the event(s) that Windows uses
> | to signal "no activity" (ie, the same ones that the OS uses to know when to
> | fire the screensaver), that'd be fairly simple to do. ..
> 
> Does the screensaver kick in if you leave it idle long enough?  If so
> then you should write a screensaver :-).  The screensaver won't be an
> ordinary, flash-some-colors-on-the-screen sort of thing but it would
> kill the offending process if it exists then exec the "real"
> screensaver for those situations where you really want a screen saver.
> 
> I think this sort of thing would be relatively easy if MS allowed for
> custom window managers because the window manager gets all input
> (keyboard, mouse, etc) events and figures out whether to keep them
> (and deal with it) or pass it on to the app.  I suppose, if this were
> X, you could create a layer that would see all events from the X
> server and determine whether to kill the bad app or not and pass them
> on to the real WM.

Well if this was X, you could just ctrl-alt-F2 to second console and
kill the offending process.. :-)

> 
> Anyways, the telnetd or screensaver idea are the most realistic/doable
> ideas.
> 
> -D
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Jupiter and Saturn Oberon Miranda
And Titania Neptune Titan
Stars can frighten
        - Syd


From scarblac@pino.selwerd.nl  Wed Jun  6 18:56:37 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 6 Jun 2001 19:56:37 +0200
Subject: [Tutor] Best way to strip string string padded with nulls
In-Reply-To: <NBBBIOJPGKJEKIECEMCBMENGJPAA.pobrien@orbtech.com>; from pobrien@orbtech.com on Wed, Jun 06, 2001 at 12:00:05PM -0500
References: <NBBBIOJPGKJEKIECEMCBMENGJPAA.pobrien@orbtech.com>
Message-ID: <20010606195636.A19968@pino.selwerd.nl>

On  0, "Patrick K. O'Brien" <pobrien@orbtech.com> wrote:
> I'm working with DDE to get data out of Goldmine. The data returned from
> Goldmine is padded with nulls (and other random data, see example below). I
> need to strip the resulting string down to just the relevant data. I have
> some example code here that works, but I'm looking for suggestions for a
> simpler or more elegant approach. Thanks.
> 
> Here is a snippet from an interactive session so you can see what I have
> described above:
> 
> >>> c = conversation.Request("Contact1->Company")
> >>> c
> 'GoldMine Software
> Corporation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
> x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Ok\xf8\xff'
> >>> i = c.index('\x00')
> >>> i
> 29
> >>> a = c[:i]
> >>> a
> 'GoldMine Software Corporation'
> 
> Of course, this could also be collapsed to the following:
> 
> c = c[:c.index('\00')]
> 
> But considering the fact that I'll have to do this to every string that gets
> returned via DDE requests, I'm hoping there is a better way. Thanks for the
> help.


c = c.replace('\00', '')

-- 
Remco Gerlich


From scarblac@pino.selwerd.nl  Wed Jun  6 19:01:12 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 6 Jun 2001 20:01:12 +0200
Subject: [Tutor] Best way to strip string string padded with nulls
In-Reply-To: <NBBBIOJPGKJEKIECEMCBMENGJPAA.pobrien@orbtech.com>; from pobrien@orbtech.com on Wed, Jun 06, 2001 at 12:00:05PM -0500
References: <NBBBIOJPGKJEKIECEMCBMENGJPAA.pobrien@orbtech.com>
Message-ID: <20010606200112.A19981@pino.selwerd.nl>

On  0, "Patrick K. O'Brien" <pobrien@orbtech.com> wrote:
> I'm working with DDE to get data out of Goldmine. The data returned from
> Goldmine is padded with nulls (and other random data, see example below). I
> need to strip the resulting string down to just the relevant data. I have
> some example code here that works, but I'm looking for suggestions for a
> simpler or more elegant approach. Thanks.
> 
> Here is a snippet from an interactive session so you can see what I have
> described above:
> 
> >>> c = conversation.Request("Contact1->Company")
> >>> c
> 'GoldMine Software
> Corporation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
> x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Ok\xf8\xff'
> >>> i = c.index('\x00')
> >>> i
> 29
> >>> a = c[:i]
> >>> a
> 'GoldMine Software Corporation'
> 
> Of course, this could also be collapsed to the following:
> 
> c = c[:c.index('\00')]
> 
> But considering the fact that I'll have to do this to every string that gets
> returned via DDE requests, I'm hoping there is a better way. Thanks for the
> help.

Hmm, seems I solved the wrong problem *again*. You want to delete the stuff
after the nulls as well. I think that last line of code you have there is
the best option.

-- 
Remco Gerlich


From pobrien@orbtech.com  Wed Jun  6 19:17:15 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 6 Jun 2001 13:17:15 -0500
Subject: [Tutor] Best way to strip string string padded with nulls
In-Reply-To: <20010606200112.A19981@pino.selwerd.nl>
Message-ID: <NBBBIOJPGKJEKIECEMCBCENJJPAA.pobrien@orbtech.com>

Yeah. <grin> Your suggestion would work if the padding were all nulls, but
Goldmine manages to send back some random junk as well. So I do need to just
cut it short at the very first null. Thanks anyway.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Remco Gerlich
Sent: Wednesday, June 06, 2001 1:01 PM
To: tutor@python.org
Subject: Re: [Tutor] Best way to strip string string padded with nulls

Hmm, seems I solved the wrong problem *again*. You want to delete the stuff
after the nulls as well. I think that last line of code you have there is
the best option.

--
Remco Gerlich

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From kojo@hal-pc.org  Wed Jun  6 19:45:06 2001
From: kojo@hal-pc.org (Kojo Idrissa)
Date: Wed, 06 Jun 2001 13:45:06 -0500
Subject: [Tutor] beginners out there
In-Reply-To: <001801c0eeaf$cff1ed40$8352b1cf@oemcomputer>
Message-ID: <5.0.2.1.0.20010606131223.00ae5dd0@Pop3.norton.antivirus>

--=====================_94567841==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

As is often my way, I will now jump on the bandwagon started by someone 
else.  In this case, Cameron.

As a little motivation for the beginners out there ( and I've been 
beginning for a long time now...), here's a snippet from a "Python 101" 
article on Devshed.:
In the consciously-elitist world of software engineering, a developer with 
a few years of Python under his belt gets the best cubicle, the prettiest 
girl and the respect of his neighbours; people move out of the way when he 
strides down the hall, and colleagues turn to him for creative and elegant 
solutions to the problems they encounter. Walk into a job interview and 
mention Python when reciting your qualifications; you'll immediately see a 
glint of recognition in the interviewer's eyes, an awareness that, in the 
hierarchy of software developers, you're one of the top guns



Of course, that's a joke, but it's the lead off of a series of "Python 101" 
articles that they're doing.  Here's the URL:
<http://www.devshed.com/Server_Side/Python/Python101_1/page1.html>

Also, some  of you new to programming may want to become "serious" about 
it.  I'm sure that means something different to everyon...in my case I'm 
starting on a Comp. Sci. degree and plan to do this sort of thing for the 
rest of my life.  Anyway, I'm currently reading:

"How to Think Like a Computer Scientist."
<http://www.ibiblio.org/obp/thinkCSpy/>
It uses Python as it's language of instruction, and can be downloaded all 
at once as a .tgz file (Winzip can open these).  I found that helpfull, so 
I can read while not online.


"How to Design Programs: An Introduction to Computing and Programming"
<http://www.htdp.org/2001-01-18/Book/ >
This one uses Scheme as it's language, but the snippet below explains why 
I'd recommend it to beginners:
This book is the first book on programming as the core subject of a liberal 
arts education. Its main focus is the design process that leads from 
problem statements to well-organized solutions; it de-emphasizes the study 
of programming language details, algorithmic minutiae, and specific 
application domains.

I also recall a number of posts to this list asking how to go about 
designing a larger program.  This would seem to address that concern.  In 
addition, I think we all, no matter what we do in life, have problems we 
have to deal with that could use well-organized solutions.  This link 
"book" would probably be better after you've spent a little time with 
Python, but you can learn so much Python so quickly, you'll be 
suprised.  Also, if you already have a program idea in mind, working on the 
design can help you focus what parts of Python you should study. ("Ok, so 
how do I generate a random number for my RPG dice rolls module?")

Just my US$.02 (Ok, it's more like a nickel...I'm verbose).  I'd also 
second most of what Cameron said.  He tends to post very interesting 
questions that make it obvious that he's learning more about the language 
as time goes on.

This list is also an excellent resource.  People respond quickly and with 
good information [I think, at times, I may be one of the exceptions, so I 
try to stay quiet...:-)], and if they don't know what you're asking, they 
don't YELL at you, they ask for more details.  I Love You Guys!!

Ok, that's enough.  Now I must eat, read and write.


At 12:40 PM 6/6/2001 -0500, Katharine Stoner wrote:
>This is a shout out to all the beginners who need some help finding 
>explainations on they're own.
>
>Everything you need get to that is online documentation is at python's 
>homepage.  Some of it just takes a while to get to. You have to dig a bit 
>to find the good stuff.  There are some lesson plans that help on 
>explaining things 
><http://www.livewires.org.uk/python/>http://www.livewires.org.uk/python/. 
>This explains some of the lingo that goes with programing and how some of 
>the fundamentals work.  Its all in html format or Adobe Acrobat reader 
>format ready to be downloaded.
>Alan Guald's book is probably the best easy, down to earth beginners book 
>I've found.  The best way to approach this that I've found is to watch the 
>tutor emails, get a book, find some tutorials, get a project, and start 
>playing around with code.  Any beginner question would be fine here.  We 
>have the tutor emails to help one another learn better.  I'm about 8 
>months into my Python education and it takes time to learn how to program 
>with the basics.
>
>This is just one beginner to another.
>
>-Cameron

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************
--=====================_94567841==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
As is often my way, I will now jump on the bandwagon started by someone
else.&nbsp; In this case, Cameron.<br>
<br>
As a little motivation for the beginners out there ( and I've been
beginning for a long time now...), here's a snippet from a &quot;Python
101&quot; article on Devshed.:<br>

<dl><i>
<dd>In the consciously-elitist world of software engineering, a developer
with a few years of Python under his belt gets the best cubicle, the
prettiest girl and the respect of his neighbours; people move out of the
way when he strides down the hall, and colleagues turn to him for
creative and elegant solutions to the problems they encounter. Walk into
a job interview and mention Python when reciting your qualifications;
you'll immediately see a glint of recognition in the interviewer's eyes,
an awareness that, in the hierarchy of software developers, you're one of
the top guns<br>
<br>
<br>
<br>
</i>
</dl>Of course, that's a joke, but it's the lead off of a series of
&quot;Python 101&quot; articles that they're doing.&nbsp; Here's the
URL:<br>
&lt;<a href="http://www.devshed.com/Server_Side/Python/Python101_1/page1.html" eudora="autourl">http://www.devshed.com/Server_Side/Python/Python101_1/page1.html</a>&gt;<br>
<br>
Also, some&nbsp; of you new to programming may want to become
&quot;serious&quot; about it.&nbsp; I'm sure that means something
different to everyon...in my case I'm starting on a Comp. Sci. degree and
plan to do this sort of thing for the rest of my life.&nbsp; Anyway, I'm
currently reading:<br>
<br>
&quot;How to Think Like a Computer Scientist.&quot; <br>
&lt;<a href="http://www.ibiblio.org/obp/thinkCSpy/" eudora="autourl">http://www.ibiblio.org/obp/thinkCSpy/</a>&gt;<br>
It uses Python as it's language of instruction, and can be downloaded all
at once as a .tgz file (Winzip can open these).&nbsp; I found that
helpfull, so I can read while not online.<br>
<br>
<br>
&quot;How to Design Programs: An Introduction to Computing and
Programming&quot;<br>
&lt;<a href="http://www.htdp.org/2001-01-18/Book/" eudora="autourl">http://www.htdp.org/2001-01-18/Book/
</a>&gt;<br>
This one uses Scheme as it's language, but the snippet below explains why
I'd recommend it to beginners:<br>

<dl><i>
<dd>This book is the first book on programming as the core subject of a
liberal arts education. Its main focus is the design process that leads
from problem statements to well-organized solutions; it de-emphasizes the
study of programming language details, algorithmic minutiae, and specific
application domains.<br>
<br>
</i>
</dl>I also recall a number of posts to this list asking how to go about
designing a larger program.&nbsp; This would seem to address that
concern.&nbsp; In addition, I think we all, no matter what we do in life,
have problems we have to deal with that could use well-organized
solutions.&nbsp; This link &quot;book&quot; would probably be better
after you've spent a little time with Python, but you can learn so much
Python so quickly, you'll be suprised.&nbsp; Also, if you already have a
program idea in mind, working on the design can help you focus what parts
of Python you should study. (&quot;Ok, so how do I generate a random
number for my RPG dice rolls module?&quot;)<br>
<br>
Just my US$.02 (Ok, it's more like a nickel...I'm verbose).&nbsp; I'd
also second most of what Cameron said.&nbsp; He tends to post very
interesting questions that make it obvious that he's learning more about
the language as time goes on.&nbsp; <br>
<br>
This list is also an excellent resource.&nbsp; People respond quickly and
with good information [I think, at times, I may be one of the exceptions,
so I try to stay quiet...:-)], and if they don't know what you're asking,
they don't YELL at you, they ask for more details.&nbsp; I Love You
Guys!!<br>
<br>
Ok, that's enough.&nbsp; Now I must eat, read and write.<br>
<br>
<br>
At 12:40 PM 6/6/2001 -0500, Katharine Stoner wrote:<br>
<blockquote type=cite class=cite cite><font face="arial" size=2>This is a
shout out to all the beginners who need some help finding explainations
on they're own.</font><br>
&nbsp;<br>
<font face="arial" size=2>Everything you need get to that is online
documentation is at python's homepage.&nbsp; Some of it just takes a
while to get to. You have to dig a bit to find the good stuff.&nbsp;
There are some lesson plans that help on explaining things
<a href="http://www.livewires.org.uk/python/">http://www.livewires.org.uk/python/</a>.&nbsp;
This explains some of the lingo that goes with programing and how some of
the fundamentals work.&nbsp; Its all in html format or Adobe Acrobat
reader format ready to be downloaded.</font><br>
<font face="arial" size=2>Alan Guald's book is probably the best easy,
down to earth beginners book I've found.&nbsp; The best way to approach
this that I've found is to watch the tutor emails, get a book, find some
tutorials, get a project, and start playing around with code.&nbsp; Any
beginner question would be fine here.&nbsp; We have the tutor emails to
help one another learn better.&nbsp; I'm about 8 months into my Python
education and it takes time to learn how to program with the
basics.</font><br>
&nbsp;<br>
<font face="arial" size=2>This is just one beginner to
another.</font><br>
&nbsp;<br>
<font face="arial" size=2>-Cameron</font></blockquote>
<x-sigsep><p></x-sigsep>
**************************** <br>
Kojo Idrissa <br>
&nbsp; <br>
kojo@hal-pc.org<br>
<a href="http://www.hal-pc.org/~kojo/" eudora="autourl">http</a>://www.hal-pc.org<a href="http://www.hal-pc.org/~kojo/" eudora="autourl">/~kojo/</a><br>
****************************</html>

--=====================_94567841==_.ALT--



From pobrien@orbtech.com  Wed Jun  6 19:45:19 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 6 Jun 2001 13:45:19 -0500
Subject: [Tutor] Best way to strip string string padded with nulls
In-Reply-To: <NBBBIOJPGKJEKIECEMCBMENGJPAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBGENKJPAA.pobrien@orbtech.com>

Here's one problem with my solution.

null = '\x00'
c = conversation.Request("Contact1->Company")
c = c[:c.index(null)]

If there is no null in c, index returns a ValueError that would have to be
dealt with. Worse is if I used c.find(null) since find would return -1 which
would eat the last character of c. Looks like I still need to work on this.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Wednesday, June 06, 2001 12:00 PM
To: Python Tutor
Subject: [Tutor] Best way to strip string string padded with nulls

I'm working with DDE to get data out of Goldmine. The data returned from
Goldmine is padded with nulls (and other random data, see example below). I
need to strip the resulting string down to just the relevant data. I have
some example code here that works, but I'm looking for suggestions for a
simpler or more elegant approach. Thanks.

Here is a snippet from an interactive session so you can see what I have
described above:

>>> c = conversation.Request("Contact1->Company")
>>> c
'GoldMine Software
Corporation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Ok\xf8\xff'
>>> i = c.index('\x00')
>>> i
29
>>> a = c[:i]
>>> a
'GoldMine Software Corporation'

Of course, this could also be collapsed to the following:

c = c[:c.index('\00')]

But considering the fact that I'll have to do this to every string that gets
returned via DDE requests, I'm hoping there is a better way. Thanks for the
help.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From kauphlyn@speakeasy.org  Wed Jun  6 20:14:45 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Wed, 6 Jun 2001 12:14:45 -0700 (PDT)
Subject: [Tutor] parsing a blank-separated string into a list
In-Reply-To: <Pine.SOL.4.33.0106061225180.8647-100000@sun1.lrz-muenchen.de>
Message-ID: <Pine.LNX.4.33L2.0106061211010.7420-100000@grace.speakeasy.net>

Hey Eugene,

Long time since Planeria, eh?

try
>>jmevalue = ' 10 11 C 9.13 ect '
>>jmelist = jmevalue.split(' ')
>>jmelist
['10', '11', 'C', '9.13', etc]



On Wed, 6 Jun 2001, Eugene Leitl wrote:

>
> Assuming, I have a string like this (produced by the JME applet,
> encoding a molecule I entered):
>
> 10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C
> 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3
> 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1
>
> And want to turn it into a list like this:
>
> [10, 11, C, 9.13 ... ]
>
> How do I do it?
>
> jmelist = map(None, jmevalue) produces
>
> [1, 0, 1, 1, C, ...], whereas I want the blank-separted atoms.
>
> Is there an idiom for that? (I mean, it's of course possible to do it by
> hand, but it's not Python Zen).
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From kauphlyn@speakeasy.org  Wed Jun  6 20:30:41 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Wed, 6 Jun 2001 12:30:41 -0700 (PDT)
Subject: [Tutor] parsing a blank-separated string into a list
In-Reply-To: <Pine.LNX.4.33L2.0106061211010.7420-100000@grace.speakeasy.net>
Message-ID: <Pine.LNX.4.33L2.0106061224570.7420-100000@grace.speakeasy.net>

What I wrote below works for Python 2.0 , and I dont know when it was
implemented, but it
definitely doesnt work on my Linux box, which is running python 1.5.2. For that,
I did the following:

import re
jmelist = re.split(' ', jmevalue)

Hope that helps, and sorry for any confusions for people with older versions ;-)



On Wed, 6 Jun 2001, Daniel Coughlin wrote:

> Hey Eugene,
>
> Long time since Planeria, eh?
>
> try
> >>jmevalue = ' 10 11 C 9.13 ect '
> >>jmelist = jmevalue.split(' ')
> >>jmelist
> ['10', '11', 'C', '9.13', etc]
>
>
>
> On Wed, 6 Jun 2001, Eugene Leitl wrote:
>
> >
> > Assuming, I have a string like this (produced by the JME applet,
> > encoding a molecule I entered):
> >
> > 10 11 C 9.13 -8.85 C 10.34 -8.15 C 7.92 -8.15 C 10.34 -6.75 C 7.92 -6.75 C
> > 8.43 -3.89 C 9.83 -3.89 C 8.00 -5.23 C 10.26 -5.23 C+ 9.13 -6.05 1 2 2 1 3
> > 1 2 4 1 3 5 2 4 10 2 5 10 1 6 7 1 6 8 1 7 9 1 8 10 1 9 10 1
> >
> > And want to turn it into a list like this:
> >
> > [10, 11, C, 9.13 ... ]
> >
> > How do I do it?
> >
> > jmelist = map(None, jmevalue) produces
> >
> > [1, 0, 1, 1, C, ...], whereas I want the blank-separted atoms.
> >
> > Is there an idiom for that? (I mean, it's of course possible to do it by
> > hand, but it's not Python Zen).
> >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>



From pobrien@orbtech.com  Wed Jun  6 20:32:16 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 6 Jun 2001 14:32:16 -0500
Subject: [Tutor] Best way to strip string string padded with nulls
In-Reply-To: <NBBBIOJPGKJEKIECEMCBGENKJPAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBIENMJPAA.pobrien@orbtech.com>

This is what I've come up with so far. I'm still open to suggestions.

def nullstrip(s):
    """Return a string truncated at the first null character."""
    try:
        s = s[:s.index('\x00')]
    except ValueError:  # No nulls were found, which is okay.
        pass
    return s

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: Patrick K. O'Brien [mailto:pobrien@orbtech.com]
Sent: Wednesday, June 06, 2001 1:45 PM
To: Python Tutor
Subject: RE: [Tutor] Best way to strip string string padded with nulls

Here's one problem with my solution.

null = '\x00'
c = conversation.Request("Contact1->Company")
c = c[:c.index(null)]

If there is no null in c, index returns a ValueError that would have to be
dealt with. Worse is if I used c.find(null) since find would return -1 which
would eat the last character of c. Looks like I still need to work on this.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."




From pobrien@orbtech.com  Wed Jun  6 22:38:53 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 6 Jun 2001 16:38:53 -0500
Subject: [Tutor] Utility functions - was: Best way to strip string string padded with nulls
In-Reply-To: <NBBBIOJPGKJEKIECEMCBIENMJPAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBOENOJPAA.pobrien@orbtech.com>

The function I came up with is obviously useful in a variety of contexts. So
it probably ought to go into some kind of general utility file. What kind of
standards do the rest of you follow when you find yourself with generic bits
of code like this? Do you have a particular file or set of files in which to
put these general functions?

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Wednesday, June 06, 2001 2:32 PM
To: Python Tutor
Subject: RE: [Tutor] Best way to strip string string padded with nulls

This is what I've come up with so far. I'm still open to suggestions.

def nullstrip(s):
    """Return a string truncated at the first null character."""
    try:
        s = s[:s.index('\x00')]
    except ValueError:  # No nulls were found, which is okay.
        pass
    return s

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."



From ak@silmarill.org  Wed Jun  6 23:02:18 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Wed, 06 Jun 2001 18:02:18 -0400
Subject: [Tutor] Utility functions - was: Best way to strip string string
 padded with nulls
In-Reply-To: <"from pobrien"@orbtech.com>
References: <NBBBIOJPGKJEKIECEMCBIENMJPAA.pobrien@orbtech.com>
 <NBBBIOJPGKJEKIECEMCBOENOJPAA.pobrien@orbtech.com>
Message-ID: <20010606180218.A28726@sill.silmarill.org>

On Wed, Jun 06, 2001 at 04:38:53PM -0500, Patrick K. O'Brien wrote:
> The function I came up with is obviously useful in a variety of contexts. So
> it probably ought to go into some kind of general utility file. What kind of
> standards do the rest of you follow when you find yourself with generic bits
> of code like this? Do you have a particular file or set of files in which to
> put these general functions?
> 
> ---
> Patrick K. O'Brien
> Orbtech
> "I am, therefore I think."
> 
> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Patrick K. O'Brien
> Sent: Wednesday, June 06, 2001 2:32 PM
> To: Python Tutor
> Subject: RE: [Tutor] Best way to strip string string padded with nulls
> 
> This is what I've come up with so far. I'm still open to suggestions.
> 
> def nullstrip(s):
>     """Return a string truncated at the first null character."""
>     try:
>         s = s[:s.index('\x00')]
>     except ValueError:  # No nulls were found, which is okay.
>         pass
>     return s

ActiveState python cookbook, I don't have url on hand so google for it.

> 
> ---
> Patrick K. O'Brien
> Orbtech
> "I am, therefore I think."
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Shine on you crazy diamond
        - Roger


From pobrien@orbtech.com  Wed Jun  6 23:24:10 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 6 Jun 2001 17:24:10 -0500
Subject: [Tutor] Utility functions - was: Best way to strip string string padded with nulls
In-Reply-To: <20010606180218.A28726@sill.silmarill.org>
Message-ID: <NBBBIOJPGKJEKIECEMCBEEOAJPAA.pobrien@orbtech.com>

I think my question might not have been clear enough. I was wondering where
to put these functions on my local machine. For example, should I create a
file like utility.py and import that file into my other programs so I can
make use of these little utility functions, like my stripnull()? Does that
make sense? What do the rest of you do?

BTW, the reference you gave is an excellent resource that I've been checking
out whenever I need to do something new. The url is
http://aspn.activestate.com/ASPN/Python/Cookbook/ and there are lots of
interesting code examples. I may just take your suggestion and post my
little function there. Thanks.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
sill@optonline.net
Sent: Wednesday, June 06, 2001 5:02 PM
To: Python Tutor
Subject: Re: [Tutor] Utility functions - was: Best way to strip string
string padded with nulls

ActiveState python cookbook, I don't have url on hand so google for it.

--
Shine on you crazy diamond
        - Roger

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From rik_klaver@hotmail.com  Wed Jun  6 23:47:08 2001
From: rik_klaver@hotmail.com (Rik Klaver)
Date: Wed, 06 Jun 2001 22:47:08
Subject: [Tutor] importing modules
Message-ID: <F590QUUBPcZi71mrvoG000049ea@hotmail.com>

I have downloaded some modules (or packages), which I've already put under 
the 'Python21' folder in Win98. My problem is: Python lets me import some, 
such as dynwin, pmw and pingo, but not the Mmtk20, Numeric and Htmlgen. For 
some modules Python raises a SystemError.
Is the fact that Python does not recognize these modules due to their 
DOS-names or to Python immediately recognizing, whenever a module is 
imported, a (say) __init__-file?
I have no idea and I would very much like to use these modules (especially 
the Mtmk)..

thanks in advance for any comments

Rik Klaver
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



From toodles@yifan.net  Thu Jun  7 02:14:44 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Thu, 7 Jun 2001 09:14:44 +0800
Subject: [Tutor] List mimicing
In-Reply-To: <20010606171414.A11739@father>
Message-ID: <FPEHJJPEEOIPMAHOADBKEEPJCDAA.toodles@yifan.net>

> Sez Andrew Wilkins:
> > Hi folks,
> >
> > I'm creating a class somewhat like shelve that stores a list as
> a file, and
> > provides a very list-like interface to it. I'm having troubles
> with __iadd__
> > and __imul__ however.
> [snip]
>
> You want to take a look at the class UserList in the module
> UserList in the
> standard library.

Okay, I can do that, but I'll still be overriding everything anyway won't I?
In which case __imul__ and __iadd__ will still act the same? I'll play
around with it anyway, and see if I'm wrong =)



>
> > -------- code ----------
> >
> > import cPickle,types,os
> >
> > class ListShelf:
> [snip]
> > 	def __iadd__(self,other):
> > 		"ie. list+=other"
> > 		_list=self._load()
> > 		_list+=other
> > 		self._dump(_list)
>
>                 return self
>
> > 	def __imul__(self,other):
> > 		"ie. list*=other"
> > 		_list=self._load()
> > 		_list*=other
> > 		self._dump(_list)
>
>                 return self
>
> Peace,
>   Kalle
> --
> Email: kalle@gnupung.net     | You can tune a filesystem, but you
> Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
> PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
>  [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>




From toodles@yifan.net  Thu Jun  7 04:12:30 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Thu, 7 Jun 2001 11:12:30 +0800
Subject: [Tutor] List mimicing
In-Reply-To: <20010606171414.A11739@father>
Message-ID: <FPEHJJPEEOIPMAHOADBKMEPJCDAA.toodles@yifan.net>

Okay I've fixed it now. Thanks Kalle, I looked through the source of
UserList and found the prob :)
Also I've subclassed it now, and changed the way it works so it cuts a lot
of method definitions out...I'll post this to Rob for Useless later if
anyone is even remotely interested. heh

Andrew Wilkins

> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Kalle Svensson
> Sent: Wednesday, 6 June 2001 11:14 PM
> To: tutor@python.org
> Subject: Re: [Tutor] List mimicing
>
>
> Sez Andrew Wilkins:
> > Hi folks,
> >
> > I'm creating a class somewhat like shelve that stores a list as
> a file, and
> > provides a very list-like interface to it. I'm having troubles
> with __iadd__
> > and __imul__ however.
> [snip]
>
> You want to take a look at the class UserList in the module
> UserList in the
> standard library.
>
> > -------- code ----------
> >
> > import cPickle,types,os
> >
> > class ListShelf:
> [snip]
> > 	def __iadd__(self,other):
> > 		"ie. list+=other"
> > 		_list=self._load()
> > 		_list+=other
> > 		self._dump(_list)
>
>                 return self
>
> > 	def __imul__(self,other):
> > 		"ie. list*=other"
> > 		_list=self._load()
> > 		_list*=other
> > 		self._dump(_list)
>
>                 return self
>
> Peace,
>   Kalle
> --
> Email: kalle@gnupung.net     | You can tune a filesystem, but you
> Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
> PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
>  [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>




From kromag@nsacom.net  Thu Jun  7 17:37:29 2001
From: kromag@nsacom.net (kromag@nsacom.net)
Date: Thu, 7 Jun 2001 09:37:29 -0700 (PDT)
Subject: [Tutor] ExpectPy HOWTO/Tutorial/Handholding
Message-ID: <200106071637.f57GbTg11731@pop.nsacom.net>

Several weeks ago I posted a question about parsing data from a serial port. 
The data from the serial port uses a binary 3 to signal that it is through 
transmitting. Someone mentioned that the ExpectPy module might be a good 
candidate for parsing this data.

Does anyone have a HOWTO for ExpectPy?

Thanks!


From rickyp1@frontiernet.net  Thu Jun  7 17:05:08 2001
From: rickyp1@frontiernet.net (Ricky Parks)
Date: Thu, 7 Jun 2001 11:05:08 -0500
Subject: [Tutor] Finaly
Message-ID: <006a01c0ef6c$000e0880$6601a8c0@Parks>

This is a multi-part message in MIME format.

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

I can not find where to unsubscibe. Could some one help me! I have given =
up python!

------=_NextPart_000_000B_01C0EF41.B6B4F880
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>I can not find where to unsubscibe. =
Could some one=20
help me! I have given up python!</FONT></DIV></BODY></HTML>

------=_NextPart_000_000B_01C0EF41.B6B4F880--



From scarblac@pino.selwerd.nl  Thu Jun  7 17:21:43 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 7 Jun 2001 18:21:43 +0200
Subject: [Tutor] Finaly
In-Reply-To: <006a01c0ef6c$000e0880$6601a8c0@Parks>; from rickyp1@frontiernet.net on Thu, Jun 07, 2001 at 11:05:08AM -0500
References: <006a01c0ef6c$000e0880$6601a8c0@Parks>
Message-ID: <20010607182143.A21324@pino.selwerd.nl>

On  0, Ricky Parks <rickyp1@frontiernet.net> wrote:
> I can not find where to unsubscibe. Could some one help me! I have given up python!

Sorry to hear you've given up Python...

Anyway, you can unsubscribe at the mailman page for this list,
http://mail.python.org/mailman/listinfo/tutor

Enter your email address in the 'Edit Options' box at the bottom and you'll
go to a page where you can unsubscribe.

-- 
Remco Gerlich


From abbn@v-share.com  Thu Jun  7 17:48:33 2001
From: abbn@v-share.com (Vassilis Vassiliou)
Date: Thu, 7 Jun 2001 19:48:33 +0300
Subject: [Tutor] Shareware Software Registration Services
Message-ID: <200106071648.f57GmXS13803@v-share.com>

Dear Software Vendor,

Our company Visage Services Inc. offers valuable shareware software registration services to many developers for the past 4 years. Being ourselves shareware software developers we created in 1998 a state of the art service administration system which proved very reliable and prosperous, due to its highly adaptable flexibility. Taking into consideration our very attractive fee schedule this could be a major opportunity to enhance your profits at a minimum cost. Please visit our site at http://www.v-share.com for a detailed description of these services and our fee schedule. Should you need assistance, feel free to contact me anytime.

Thank you for your time reading my mail.

Sincerely,

  Vassilis Vassiliou 
  Sales Manager
  VISAGE SERVICES INC. 
  abbn@v-share.com


From curtis.larsen@Covance.Com  Thu Jun  7 19:27:26 2001
From: curtis.larsen@Covance.Com (Curtis Larsen)
Date: Thu, 07 Jun 2001 13:27:26 -0500
Subject: [Tutor] ExpectPy HOWTO/Tutorial/Handholding
Message-ID: <sb1f8157.079@madis2.truax.covance.com>

According to this recent blurb in "Dr. Dobbs' Python-URL" (a weekly
"what's-new-in-Python" e-mail newsletter), there may be another
possibility:

"""
How do you do serial IO in Python? Usual answer: It depends on
your operating system. New answer: not anymore! XIO is a new
cross-platform serial port driver for win32 and Unix.
http://groups.google.com/groups?ic=1&th=dae9fa4438b9bc9a,3 
"""

Following the link, we learn more:

"Currently, the module implements port creation, opening, closing,
configuration, reading, writing & status peeking. It has been tested
under Linux-x86 and Win-9X. It contains a naive implementation of flow
control (and pretty untested -- so beware!)."



Hope that helps!
Curtis

PS: To receive a new issue of "Dr. Dobbs" in e-mail each Monday
morning, ask <claird@neosoft.com> to subscribe.  Mention "Python-URL!".


>>> <kromag@nsacom.net> 06/07/2001 11:37:29 AM >>>
Several weeks ago I posted a question about parsing data from a serial
port. 
The data from the serial port uses a binary 3 to signal that it is
through 
transmitting. Someone mentioned that the ExpectPy module might be a
good 
candidate for parsing this data.

Does anyone have a HOWTO for ExpectPy?

Thanks!

_______________________________________________
Tutor maillist  -  Tutor@python.org 
http://mail.python.org/mailman/listinfo/tutor


-----------------------------------------------------
Confidentiality Notice: This e-mail transmission 
may contain confidential or legally privileged 
information that is intended only for the individual 
or entity named in the e-mail address. If you are not 
the intended recipient, you are hereby notified that 
any disclosure, copying, distribution, or reliance 
upon the contents of this e-mail is strictly prohibited. 

If you have received this e-mail transmission in error, 
please reply to the sender, so that we can arrange 
for proper delivery, and then please delete the message 
from your inbox. Thank you.


From inkedmcse@yahoo.com  Thu Jun  7 23:01:00 2001
From: inkedmcse@yahoo.com (Kelly Brett)
Date: Thu, 7 Jun 2001 15:01:00 -0700 (PDT)
Subject: [Tutor] python question...
Message-ID: <20010607220100.74350.qmail@web11703.mail.yahoo.com>

--0-195772596-991951260=:74165
Content-Type: text/plain; charset=us-ascii


hello-

i'm brand new to programming, and i'm very excited about learning python.  I've used the "instant hacking" tutorial on the website, and it's making total sense.  i'm just wondering how it is that somebody can get good at this stuff.  i understand that practice makes perfect, but it just seems like there are so many directions that can be taken.  

so, beside the aforementioned tutorial, what is a good resource that won't confuse the crap out of me?

thanks guys!!

brett



---------------------------------
Do You Yahoo!?
Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail.
--0-195772596-991951260=:74165
Content-Type: text/html; charset=us-ascii

<P>hello-</P>
<P>i'm brand new to programming, and i'm very excited about learning python.&nbsp; I've used the "instant hacking" tutorial on the website, and it's making total sense.&nbsp; i'm just wondering how it is that somebody can get <EM>good</EM> at this stuff.&nbsp; i understand that practice makes perfect, but it just seems like there are so many directions that can be taken.&nbsp; </P>
<P>so, beside the aforementioned tutorial, what is a good resource that won't confuse the crap out of me?</P>
<P>thanks guys!!</P>
<P>brett</P><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://personal.mail.yahoo.com/?.refer=mailiyfoot">Yahoo! Mail Personal Address</a> - 
Get email at your own domain with Yahoo! Mail.
--0-195772596-991951260=:74165--


From glingl@aon.at  Thu Jun  7 23:30:11 2001
From: glingl@aon.at (Gregor Lingl)
Date: Fri, 08 Jun 2001 00:30:11 +0200
Subject: [Tutor] python question...
References: <20010607220100.74350.qmail@web11703.mail.yahoo.com>
Message-ID: <3B200073.E90320ED@aon.at>

--------------6FC4330FBD56AB1883C7BF2A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


If you want to lern to program - using Python - try  How to think like a
computer scientist
(http://www.ibiblio.org/obp/thinkCSpy/)

Then to find more cooncrete material- exercises and so on ... - , go to
Alan Gaulds's book on programming
(http://members.nbci.com/alan_gauld/tutor/tutindex.htm)

A very useful list of tutorials of each kind you find at Rob Andrews
Tutorial Page (http://www.lowerstandard.com/python/tutoriallinks.html)
on his  Useless Python Site

Good luck (and be patient!)
Gregor L.

Kelly Brett schrieb:

  hello-

  i'm brand new to programming, and i'm very excited about learning
python.  I've used the "instant hacking" tutorial on the website, and
it's making total sense.  i'm just wondering how it is that
  somebody can get good at this stuff.  i understand that practice makes
perfect, but it just seems like there are so many directions that can be
taken.

  so, beside the aforementioned tutorial, what is a good resource that
won't confuse the crap out of me?

  thanks guys!!

  brett




Kelly Brett schrieb:

> hello-
>
> i'm brand new to programming, and i'm very excited about learning
> python.  I've used the "instant hacking" tutorial on the website, and
> it's making total sense.  i'm just wondering how it is that somebody
> can get good at this stuff.  i understand that practice makes perfect,
> but it just seems like there are so many directions that can be taken.
>
> so, beside the aforementioned tutorial, what is a good resource that
> won't confuse the crap out of me?
>
> thanks guys!!
>
> brett
>
>
> -----------------------------------------------------------------------
> Do You Yahoo!?
> Yahoo! Mail Personal Address - Get email at your own domain with
> Yahoo! Mail.

--------------6FC4330FBD56AB1883C7BF2A
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
&nbsp;
<br>If you want to lern to program - using Python - try&nbsp; <a href="http://www.ibiblio.org/obp/thinkCSpy/">How
to think like a computer scientist</a>
<br>(<A HREF="http://www.ibiblio.org/obp/thinkCSpy/">http://www.ibiblio.org/obp/thinkCSpy/</A>)
<p>Then to find more cooncrete material- exercises and so on ... - , go
to&nbsp; <a href="http://members.nbci.com/alan_gauld/tutor/tutindex.htm">Alan
Gaulds's book on programming</a>
<br>(<A HREF="http://members.nbci.com/alan_gauld/tutor/tutindex.htm">http://members.nbci.com/alan_gauld/tutor/tutindex.htm</A>)
<p>A very useful list of tutorials of each kind you find at <a href="http://www.lowerstandard.com/python/tutoriallinks.html">Rob
Andrews&nbsp; Tutorial Page </a>(<A HREF="http://www.lowerstandard.com/python/tutoriallinks.html">http://www.lowerstandard.com/python/tutoriallinks.html</A>)
on his&nbsp; <a href="http://www.lowerstandard.com/python/pythonsource.html">Useless
Python Site</a>
<p>Good luck (and be patient!)
<br>Gregor L.
<p>Kelly Brett schrieb:
<p>&nbsp; hello-
<p>&nbsp; i'm brand new to programming, and i'm very excited about learning
python.&nbsp; I've used the "instant hacking" tutorial on the website,
and it's making total sense.&nbsp; i'm just wondering how it is that
<br>&nbsp; somebody can get good at this stuff.&nbsp; i understand that
practice makes perfect, but it just seems like there are so many directions
that can be taken.
<p>&nbsp; so, beside the aforementioned tutorial, what is a good resource
that won't confuse the crap out of me?
<p>&nbsp; thanks guys!!
<p>&nbsp; brett
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<p>Kelly Brett schrieb:
<blockquote TYPE=CITE>hello-
<p>i'm brand new to programming, and i'm very excited about learning python.&nbsp;
I've used the "instant hacking" tutorial on the website, and it's making
total sense.&nbsp; i'm just wondering how it is that somebody can get <i>good</i>
at this stuff.&nbsp; i understand that practice makes perfect, but it just
seems like there are so many directions that can be taken.
<p>so, beside the aforementioned tutorial, what is a good resource that
won't confuse the crap out of me?
<p>thanks guys!!
<p>brett
<br>&nbsp;
<p>
<hr size=1><b>Do You Yahoo!?</b>
<br><a href="http://personal.mail.yahoo.com/?.refer=mailiyfoot">Yahoo!
Mail Personal Address</a> - Get email at your own domain with Yahoo! Mail.</blockquote>
</html>

--------------6FC4330FBD56AB1883C7BF2A--



From j_f9@yahoo.com  Fri Jun  8 01:23:00 2001
From: j_f9@yahoo.com (F. Tourigny)
Date: Thu, 7 Jun 2001 17:23:00 -0700 (PDT)
Subject: [Tutor] sys._doc_ documentation
Message-ID: <20010608002300.67711.qmail@web14506.mail.yahoo.com>

I'm just starting with Programming Python, p. 16.
Typing:
   sys._doc_
at the python prompt returns this message:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'sys' module has no attribute '_doc_'

However, "dir(sys)" is listing "_doc_" among the
module's attributes.

What gives?
(Using ActivePython 2.1, Build 210)

Greetings,
Frederic



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/


From m.hadfield@niwa.cri.nz  Fri Jun  8 01:28:39 2001
From: m.hadfield@niwa.cri.nz (Mark Hadfield)
Date: Fri, 8 Jun 2001 12:28:39 +1200
Subject: [Tutor] sys._doc_ documentation
References: <20010608002300.67711.qmail@web14506.mail.yahoo.com>
Message-ID: <000401c0efb1$f7260dd0$d938a8c0@Hadfield>

From: "F. Tourigny" <j_f9@yahoo.com>


> I'm just starting with Programming Python, p. 16.
> Typing:
>    sys._doc_
> at the python prompt returns this message:
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'sys' module has no attribute '_doc_'
>
> However, "dir(sys)" is listing "_doc_" among the
> module's attributes.
> What gives?
> (Using ActivePython 2.1, Build 210)

Works for me (below). You probably left off one of the underscores.

ActivePython 2.1, build 210 ActiveState)
based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.>>>
import sys
>>> import sys
>>> sys.__doc__
"This module provides access to some objects used or maintained by
the\ninterpre
ter and to functions that interact strongly with the interpreter.\n\nDynamic
obj
ects:\n\nargv -- command line arguments; argv[0] is the script pathname if
known
\npath -- module search path; path[0] is the script directory, else
''\nmodules
-- dictionary of loaded modules\n\ndisplayhook -- called to show results in
an i
nteractive session\nexcepthook -- called to handle any uncaught exception
other
than SystemExit\n  To customize printing in an interactive session or to
install
 a custom\n  top-level exception handler, assign other functions to replace
thes
e.\n\nexitfunc -- if sys.exitfunc exists, this routine is called when Python
exi
ts\n  Assigning to sys.exitfunc is deprecated; use the atexit module
instead.\n\
....

---
Mark Hadfield
m.hadfield@niwa.cri.nz  http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research




From ak@silmarill.org  Fri Jun  8 01:48:29 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Thu, 07 Jun 2001 20:48:29 -0400
Subject: [Tutor] sys._doc_ documentation
In-Reply-To: <"from j_f9"@yahoo.com>
References: <20010608002300.67711.qmail@web14506.mail.yahoo.com>
Message-ID: <20010607204829.A421@sill.silmarill.org>

On Thu, Jun 07, 2001 at 05:23:00PM -0700, F. Tourigny wrote:
> I'm just starting with Programming Python, p. 16.
> Typing:
>    sys._doc_
> at the python prompt returns this message:
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'sys' module has no attribute '_doc_'
> 
> However, "dir(sys)" is listing "_doc_" among the
> module's attributes.
> 
> What gives?
> (Using ActivePython 2.1, Build 210)
> 
> Greetings,
> Frederic

That's a typo, it should be sys.__doc__ .

> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35 
> a year!  http://personal.mail.yahoo.com/
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lime and limpid green
a second scene
A fight between the blue
you once knew
        - Syd


From amc1@dcs.qmw.ac.uk  Fri Jun  8 15:41:03 2001
From: amc1@dcs.qmw.ac.uk (Allan Crooks)
Date: Fri, 08 Jun 2001 15:41:03 +0100
Subject: [Tutor] Viewing __doc__ strings
Message-ID: <E158NTS-00019K-00@mk-smarthost-2.mail.uk.worldonline.com>

Hi,

Is there anyway to make Python display __doc__ strings without all the "\n" characters? I know I could manually split it and then rejoin it, but surely there's an easier way?

I'm using Python 2.1 on WinNT 4, if that's of any use.

Thanks,
Allan.



From SBrunning@trisystems.co.uk  Fri Jun  8 15:46:07 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Fri, 8 Jun 2001 15:46:07 +0100
Subject: [Tutor] Viewing __doc__ strings
Message-ID: <31575A892FF6D1118F5800600846864D78BD0D@intrepid>

> From:	Allan Crooks [SMTP:amc1@dcs.qmw.ac.uk]
> Is there anyway to make Python display __doc__ strings without all the
> "\n" characters? I know I could manually split it and then rejoin it, but
> surely there's an easier way?
 
Just use print.

print whatever.__doc__

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 scarblac@pino.selwerd.nl  Fri Jun  8 15:55:14 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 8 Jun 2001 16:55:14 +0200
Subject: [Tutor] Viewing __doc__ strings
In-Reply-To: <E158NTS-00019K-00@mk-smarthost-2.mail.uk.worldonline.com>; from amc1@dcs.qmw.ac.uk on Fri, Jun 08, 2001 at 03:41:03PM +0100
References: <E158NTS-00019K-00@mk-smarthost-2.mail.uk.worldonline.com>
Message-ID: <20010608165514.A23343@pino.selwerd.nl>

On  0, Allan Crooks <amc1@dcs.qmw.ac.uk> wrote:
> Is there anyway to make Python display __doc__ strings without all the
> "\n" characters? I know I could manually split it and then rejoin it, but
> surely there's an easier way?

print it:

>>> len.__doc__
'len(object) -> integer\n\nReturn the number of items of a sequence or mapping.'
>>> print len.__doc__
len(object) -> integer

Return the number of items of a sequence or mapping.

Just like any other strings with \n's in them, really :)

Personally I use a little doc() function that goes like this:

def doc(x):
   print "Object:", `x`
   print
   if hasattr(x, '__doc__'):
      print "Docstring:"
      print x.__doc__
   else:
      print "No docstring."

So I can just type

>>> doc(object)

> I'm using Python 2.1 on WinNT 4, if that's of any use.

On Linux I put that function in ~/.pythonrc, but I don't know where it goes
on WinNT. There should be a file that's executed before you enter the
interpreter.

-- 
Remco Gerlich


From iumarumo@eidosnet.co.uk  Fri Jun  8 17:46:21 2001
From: iumarumo@eidosnet.co.uk (ibraheem umaru-mohammed)
Date: Fri, 8 Jun 2001 17:46:21 +0100
Subject: [Tutor] Viewing __doc__ strings
In-Reply-To: <20010608165514.A23343@pino.selwerd.nl>; from scarblac@pino.selwerd.nl on Fri, Jun 08, 2001 at 04:55:14PM +0200
References: <E158NTS-00019K-00@mk-smarthost-2.mail.uk.worldonline.com> <20010608165514.A23343@pino.selwerd.nl>
Message-ID: <20010608174621.B5878@micromuse.com>

[Remco Gerlich wrote...]
-| On  0, Allan Crooks <amc1@dcs.qmw.ac.uk> wrote:
-| > Is there anyway to make Python display __doc__ strings without all the
-| > "\n" characters? I know I could manually split it and then rejoin it, but
-| > surely there's an easier way?
-| 
-| print it:
-| 
-| >>> len.__doc__
-| 'len(object) -> integer\n\nReturn the number of items of a sequence or mapping.'
-| >>> print len.__doc__
-| len(object) -> integer
-| 
-| Return the number of items of a sequence or mapping.
-| 
-| Just like any other strings with \n's in them, really :)
-| 
-| Personally I use a little doc() function that goes like this:
-| 
-| def doc(x):
-|    print "Object:", `x`
-|    print
-|    if hasattr(x, '__doc__'):
-|       print "Docstring:"
-|       print x.__doc__
-|    else:
-|       print "No docstring."
-| 
-| So I can just type
-| 
-| >>> doc(object)
-| 
-| > I'm using Python 2.1 on WinNT 4, if that's of any use.
-| 
-| On Linux I put that function in ~/.pythonrc, but I don't know where it goes
-| on WinNT. There should be a file that's executed before you enter the
-| interpreter.
-| 

Or under Python 2.x

	>>>import pydoc
	>>>pydoc.doc(len)

kindest regards,

	--ibs.

-- 
			Ibraheem Umaru-Mohammed
			   ium@micromuse.com
			   www.micromuse.com
			         --0--


From pobrien@orbtech.com  Fri Jun  8 16:54:11 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Fri, 8 Jun 2001 10:54:11 -0500
Subject: [Tutor] Viewing __doc__ strings
In-Reply-To: <20010608165514.A23343@pino.selwerd.nl>
Message-ID: <NBBBIOJPGKJEKIECEMCBGEAGKAAA.pobrien@orbtech.com>

I like that a lot. Very helpful when you are messing with something new in
interactive mode. You inspired me to create my own variation. Hope everyone
likes it.

def doc(x):
    """Print type, representation and documentation string for object x."""
    print "Object:", str(x)
    print "Object Type:", type(x)
    print "Representation:", repr(x)
    print "Documentation String:"
    print "---------------------"
    try:
        print x.__doc__
    except AttributeError:
        print "This object does not have a documentation string."

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Remco Gerlich
Sent: Friday, June 08, 2001 9:55 AM
To: tutor@python.org
Subject: Re: [Tutor] Viewing __doc__ strings

<snip>

Personally I use a little doc() function that goes like this:

def doc(x):
   print "Object:", `x`
   print
   if hasattr(x, '__doc__'):
      print "Docstring:"
      print x.__doc__
   else:
      print "No docstring."

So I can just type

>>> doc(object)

> I'm using Python 2.1 on WinNT 4, if that's of any use.

On Linux I put that function in ~/.pythonrc, but I don't know where it goes
on WinNT. There should be a file that's executed before you enter the
interpreter.

--
Remco Gerlich

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From wall@adinet.com.uy  Fri Jun  8 16:53:21 2001
From: wall@adinet.com.uy (Walter Moreira)
Date: Fri, 8 Jun 2001 12:53:21 -0300
Subject: [Tutor] Viewing __doc__ strings
In-Reply-To: <E158NTS-00019K-00@mk-smarthost-2.mail.uk.worldonline.com>; from amc1@dcs.qmw.ac.uk on Fri, Jun 08, 2001 at 03:41:03PM +0100
References: <E158NTS-00019K-00@mk-smarthost-2.mail.uk.worldonline.com>
Message-ID: <20010608125321.A29049@casa.parque>

On Fri, Jun 08, 2001 at 03:41:03PM +0100, Allan Crooks wrote:
> Hi,
> 
> Is there anyway to make Python display __doc__ strings without all the "\n" characters? I know I could manually split it and then rejoin it, but surely there's an easier way?
> 
> I'm using Python 2.1 on WinNT 4, if that's of any use.

Use the pydoc module which is included in 2.1. For example:

    >>> def f(x):
    ...	    """A dummy function.
    ...	    It returns x.
    ...	    """
    ...	    return x
    ...
    >>> f.__doc__
    'A dummy function.\n\tIt returns x.\n\t'
    >>>
    >>> from pydoc import help
    >>> help(f)
    Help on function f in module __main__:

    f(x)
	A dummy function.
	It returns x.

pydoc is really cool!!

Regards:
Walter

-- 
--------------
Walter Moreira  <> Centro de Matematica  <> Universidad de la Republica
email: walterm@cmat.edu.uy <> HomePage: http://www.cmat.edu.uy/~walterm
                 +-----------------------------------------------------
        /OD\_    |   LEARNING, n. The kind of ignorance distinguishing
 O o . |_o_o_)   |   the studious.
                 |               -- Ambrose Bierce. Devil's Dictionary
               --+--


From rpm@wag.caltech.edu  Fri Jun  8 17:10:12 2001
From: rpm@wag.caltech.edu (Richard P. Muller)
Date: Fri, 08 Jun 2001 09:10:12 -0700
Subject: [Tutor] Re: python question
References: <E158ObF-0006op-00@mail.python.org>
Message-ID: <3B20F8E4.7B3F758E@wag.caltech.edu>


> tutor-request@python.org wrote:

> 
> Subject: [Tutor] python question...
> Date: Thu, 7 Jun 2001 15:01:00 -0700 (PDT)
> From: Kelly Brett <inkedmcse@yahoo.com>
> To: tutor@python.org
> 
> hello-
> 
> i'm brand new to programming, and i'm very excited about learning
> python.  I've used the "instant hacking" tutorial on the website, and
> it's making total sense.  i'm just wondering how it is that somebody
> can get good at this stuff.  i understand that practice makes perfect,
> but it just seems like there are so many directions that can be
> taken.
> 
> so, beside the aforementioned tutorial, what is a good resource that
> won't confuse the crap out of me?


You already answered your question, in part. The way to get better at
Python is simply to use it. Everywhere. Next time you have a simple
repetitive task to do on the computer, think about how you could do it
with Python. Hackers are generally lazy people, and would rather figure
out an elegant programming solution to a problem rather than have to
repeat some boring task over and over again.

I like Lutz/Ascher's "Learning Python" as a good into. After a while
you'll find all books rather limiting, though. Now I mostly just flip
through the Library Reference from the Python docs.

Some of the best advice anyone ever gave me was to "collect toys". Bill
McCurdy (now at LBL) told me this, in regard to how to be a better
computational chemist, but it applies to computer programming as well.
Next time you hear about some interesting idea (such as XML), algorithm
(such as quick sort), or program, rather than just read about it, code
up a simple "toy" version of it. It's amazing how much more you learn
when you actually try to program something -- it forces you to
understand every facet of the idea rather than simply the jist.

Rick


From pobrien@orbtech.com  Fri Jun  8 17:13:57 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Fri, 8 Jun 2001 11:13:57 -0500
Subject: [Tutor] Idea to help newbies - let's define 'help'
Message-ID: <NBBBIOJPGKJEKIECEMCBKEAHKAAA.pobrien@orbtech.com>

Here is an idea. When you run the python interpreter in interactive mode for
the very first time, it is probably pretty common to type the word 'help'
just to see what happens. And guess what you get:

>>> help
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
NameError: name 'help' is not defined
>>>

This is not exactly the friendliest response you and I could think of giving
someone. (Especially if we want them to love Python the way we do.) So how
about joining me in a little project here where we define 'help' for use in
interactive mode? That means we need to create a script that will be pointed
to by PYTHONSTARTUP or some other mechanism. The script (I'll suggest the
name interactive.py) needs to contain useful functions like Remco Gerlich's
doc() function as well as others. In addition, there needs to be a function
named help() that will work with no parameters passed to it (at least none
required).

That's as far as I've gone with the idea. Anyone else interested?

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."




From pobrien@orbtech.com  Fri Jun  8 17:54:58 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Fri, 8 Jun 2001 11:54:58 -0500
Subject: [Tutor] Idea to help newbies - let's define 'help'
In-Reply-To: <NBBBIOJPGKJEKIECEMCBKEAHKAAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBMEAJKAAA.pobrien@orbtech.com>

I see now that pydoc has 'help' defined and is probably the way to go. So
one approach would be to just add 'from pydoc import help' to a startup
script. Or we could try to reinvent the wheel and learn something along the
way. I may do both.

The pydoc technique is pretty cool in that help is actually an object,
rather than simply a function:

help = Helper(sys.stdin, sys.stdout)

Helper is a custom class that does all kinds of things. Take a look at
pydoc.py for more inspiration.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Friday, June 08, 2001 11:14 AM
To: Python Tutor
Subject: [Tutor] Idea to help newbies - let's define 'help'

Here is an idea. When you run the python interpreter in interactive mode for
the very first time, it is probably pretty common to type the word 'help'
just to see what happens. And guess what you get:

>>> help
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
NameError: name 'help' is not defined
>>>

This is not exactly the friendliest response you and I could think of giving
someone. (Especially if we want them to love Python the way we do.) So how
about joining me in a little project here where we define 'help' for use in
interactive mode? That means we need to create a script that will be pointed
to by PYTHONSTARTUP or some other mechanism. The script (I'll suggest the
name interactive.py) needs to contain useful functions like Remco Gerlich's
doc() function as well as others. In addition, there needs to be a function
named help() that will work with no parameters passed to it (at least none
required).

That's as far as I've gone with the idea. Anyone else interested?

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From pobrien@orbtech.com  Fri Jun  8 18:41:24 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Fri, 8 Jun 2001 12:41:24 -0500
Subject: [Tutor] PYTHONSTARTUP under Win98
Message-ID: <NBBBIOJPGKJEKIECEMCBCEALKAAA.pobrien@orbtech.com>

I have a python script (.pythonrc.py) created and pointed to by
PYTHONSTARTUP in my autoexec.bat file under Win98SE. If I go to a dos prompt
and start python, the startup script is executed properly because the
functions I defined in .pythonrc.py are available according to dir() and
simply by using them. So everything is setup properly.

However, nothing happens when I launch one of the IDEs, such as IDLE,
PythonWin or Boa. I would have expected the interactive windows of these
tools to have executed my startup script. I know they can "see" it because
the following works:

>>> dir()
['__builtins__', '__doc__', '__name__', 'pywin']
>>> import os
>>> os.environ.get('PYTHONSTARTUP')
'C:\\My Documents\\pobrien\\.pythonrc.py'
>>> execfile(os.environ.get('PYTHONSTARTUP'))
>>> dir()
['__builtins__', '__doc__', '__name__', 'doc', 'help', 'os', 'pywin']
>>>

So what gives? Is this the expected behavior? I just found an IDLE command
line flag (-s will run $IDLESTARTUP or $PYTHONSTARTUP first) in the help
file. So maybe that is the case.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."




From dyoo@hkn.eecs.berkeley.edu  Sat Jun  9 08:06:10 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 9 Jun 2001 00:06:10 -0700 (PDT)
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a
 builtin]
In-Reply-To: <Pine.GSO.4.21.0106090144370.23189-100000@isis.visi.com>
Message-ID: <Pine.LNX.4.21.0106090002040.956-100000@hkn.eecs.berkeley.edu>

>> Is it practical and possible to have pydoc's help() function 
>> autoloaded by bundling a modified interpreter?

> Yes, I've followed that discussion on the tutor list too. I think some
> sort of interactive help would be great. I'm afraid modifying the
> interpreter is a bit beyond me at this point, however. Making the CD
> more interactive would be very cool, no doubt.


Yahoo!  We don't need to recompile at all: we just need to append the
following to site.py within the library :

###
## (within site.py)
## Added by dyoo
from pydoc import help
__builtin__.help = help
del help
###

That will do it!  Afterwards, help() will appear to be a builtin.  I'll
crosspost this to the tutor list; people were wondering about this one.  
This should definitely make things nicer for people.




From dyoo@hkn.eecs.berkeley.edu  Sat Jun  9 08:26:36 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 9 Jun 2001 00:26:36 -0700 (PDT)
Subject: [Tutor] PYTHONSTARTUP under Win98
In-Reply-To: <NBBBIOJPGKJEKIECEMCBCEALKAAA.pobrien@orbtech.com>
Message-ID: <Pine.LNX.4.21.0106090015110.956-100000@hkn.eecs.berkeley.edu>

On Fri, 8 Jun 2001, Patrick K. O'Brien wrote:

> I have a python script (.pythonrc.py) created and pointed to by
> PYTHONSTARTUP in my autoexec.bat file under Win98SE. If I go to a dos prompt

Python only looks at PYTHONSTARTUP if you run it as an interactive
interpreter.  That is, only when you run it through the dos prompt.  It's
one of those details that the official tutorial sorta whispers vaguely
about... *grin*


""" 
This file is only read in interactive sessions, not when Python reads
commands from a script, and not when /dev/tty is given as the explicit
source of commands (which otherwise behaves like an interactive session).  
"""

http://www.python.org/doc/current/tut/node4.html#SECTION004230000000000000000



> So what gives? Is this the expected behavior? I just found an IDLE command
> line flag (-s will run $IDLESTARTUP or $PYTHONSTARTUP first) in the help
> file. So maybe that is the case.

Yes, you'll want to add the -s option to get IDLE to look at the
$PYTHONSTARTUP variable.


Another approach that we can use to get things to load automatically is to
add some lines to the "site.py", which makes changes for everyone,
regardless if we're running Python interactively or not.

Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Sat Jun  9 08:47:57 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 9 Jun 2001 00:47:57 -0700 (PDT)
Subject: [Tutor] Utility functions - was: Best way to strip string string
 padded with nulls
In-Reply-To: <NBBBIOJPGKJEKIECEMCBEEOAJPAA.pobrien@orbtech.com>
Message-ID: <Pine.LNX.4.21.0106090039520.956-100000@hkn.eecs.berkeley.edu>

On Wed, 6 Jun 2001, Patrick K. O'Brien wrote:

> I think my question might not have been clear enough. I was wondering where
> to put these functions on my local machine. For example, should I create a
> file like utility.py and import that file into my other programs so I can
> make use of these little utility functions, like my stripnull()? Does that
> make sense? What do the rest of you do?

I often keep a small personal directory filled with useful scripts that
I've written.  If a function seems a bit obscure, it goes into its own
little file.  Who knows --- a unoverlapping-genome-sequence-displayer.py
might come in handy someday.  *grin*

If it seems general enough, it'll go into a file that's more generically
named.  For example, I put some of my string manipulating functions in a
file called "MyStringUtils.py".  You can probably make it more personal by
putting your initials in the name somewhere... although I haven't done
this myself, since "MyDy.py" looks a little silly.


Finally, to make things nicer, I set my PYTHONPATH up so that those
scripts are available at my fingertips.

Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Sat Jun  9 08:57:53 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sat, 9 Jun 2001 00:57:53 -0700 (PDT)
Subject: [Tutor] importing modules
In-Reply-To: <F590QUUBPcZi71mrvoG000049ea@hotmail.com>
Message-ID: <Pine.LNX.4.21.0106090048110.956-100000@hkn.eecs.berkeley.edu>

On Wed, 6 Jun 2001, Rik Klaver wrote:

> I have downloaded some modules (or packages), which I've already put under 
> the 'Python21' folder in Win98. My problem is: Python lets me import some, 
> such as dynwin, pmw and pingo, but not the Mmtk20, Numeric and Htmlgen. For 
> some modules Python raises a SystemError.

Hmmm... This is a little strange!  Mmtk (The Molecular Modeling
Toolkit) at:

    http://starship.python.net/crew/hinsen/MMTK/

says that it needs both ScientificPython and Numeric Python to get things
running.  At the same time, it looks like you might need the netCDF
library too!  Whew.  This might be a little ugly.


It might be good to get Numeric Python working first, and then get MmTk20
working.  To get Scientific Python, try downloading here:

    http://basic.netmeg.net/godzilla/

You can download the netcdf and scientific_netcdf dll libraries, which
you'll probably want to copy somewhere... can anyone give details on where
it's supposed to go on Win98?  I believe it should go within the
site-packages/ directory, but I could be very wrong about this.


About Htmlgen, hmmm... I'm not quite sure.  Are you using WinZip to unzip
the files?  If so, you should have been ok; WinZip does the right thing
with long file names.  Can you tell us where exactly you're copying them
to --- just in the Python21 folder, or in one of the smaller subfolders
there?

Installing new software is always a pain; I hope that this can be fixed
quickly.  Good luck to you!



From arcege@speakeasy.net  Sat Jun  9 13:01:34 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Sat, 9 Jun 2001 08:01:34 -0400 (EDT)
Subject: [Tutor] ExpectPy HOWTO/Tutorial/Handholding
In-Reply-To: <200106071637.f57GbTg11731@pop.nsacom.net> from "kromag@nsacom.net" at Jun 07, 2001 09:37:29 AM
Message-ID: <200106091201.f59C1Yg01761@dsl092-074-184.bos1.dsl.speakeasy.net>

kromag@nsacom.net wrote
> Several weeks ago I posted a question about parsing data from a serial port. 
> The data from the serial port uses a binary 3 to signal that it is through 
> transmitting. Someone mentioned that the ExpectPy module might be a good 
> candidate for parsing this data.
> 
> Does anyone have a HOWTO for ExpectPy?

There is no HOWTO for ExpectPy (unless someone wrote one without telling
the author).  The original idea back when it was written four years
ago was that it was a supplement to Expect, and that the user would
probably be reading _Exploring Expect_.  But then, that was a while ago.
There are links to the Expect site with more info.

What is it that you are looking for?

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From pobrien@orbtech.com  Sat Jun  9 15:30:19 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sat, 9 Jun 2001 09:30:19 -0500
Subject: [Tutor] Utility functions - was: Best way to strip string string padded with nulls
In-Reply-To: <Pine.LNX.4.21.0106090039520.956-100000@hkn.eecs.berkeley.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBCEBKKAAA.pobrien@orbtech.com>

That does help. I'm just so in love with Python's approach of having
OneRightWay for everything that I'm trying to apply that to my own code. At
every step I'm wondering, what is the OneRightWay for this? (Yes, I have
been accused of being a bit anal.) If anyone else has a better OneRightWay
to organize code I'm all ears. <grin>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Daniel Yoo
Sent: Saturday, June 09, 2001 2:48 AM
To: Patrick K. O'Brien
Cc: Python Tutor
Subject: RE: [Tutor] Utility functions - was: Best way to strip string
string padded with nulls

On Wed, 6 Jun 2001, Patrick K. O'Brien wrote:

> I think my question might not have been clear enough. I was wondering
where
> to put these functions on my local machine. For example, should I create a
> file like utility.py and import that file into my other programs so I can
> make use of these little utility functions, like my stripnull()? Does that
> make sense? What do the rest of you do?

I often keep a small personal directory filled with useful scripts that
I've written.  If a function seems a bit obscure, it goes into its own
little file.  Who knows --- a unoverlapping-genome-sequence-displayer.py
might come in handy someday.  *grin*

If it seems general enough, it'll go into a file that's more generically
named.  For example, I put some of my string manipulating functions in a
file called "MyStringUtils.py".  You can probably make it more personal by
putting your initials in the name somewhere... although I haven't done
this myself, since "MyDy.py" looks a little silly.


Finally, to make things nicer, I set my PYTHONPATH up so that those
scripts are available at my fingertips.

Hope this helps!


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From pobrien@orbtech.com  Sat Jun  9 15:52:01 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sat, 9 Jun 2001 09:52:01 -0500
Subject: [Tutor] PYTHONSTARTUP under Win98
In-Reply-To: <Pine.LNX.4.21.0106090015110.956-100000@hkn.eecs.berkeley.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBEEBLKAAA.pobrien@orbtech.com>

Thanks. I'm slowly catching on. The more I learn Python, the more impressed
I am with the language ... and the more disappointed I am with the
information about the environment. I think the setup and configuration of
Python is still too big of a barrier for newbies. Python 2.1 and distutils
has helped a lot, but there are still too many gotchas that get in the way.
And if you want to be seriously productive you're going to want to control
the python environment. For me, that means getting everything working the
way I want it to in IDLE, PythonWin, Boa and VisualPython.

And now you're telling me about site.py! Where the hell did that come from.
I don't remember seeing anything about that!!! <wink>

Okay, okay, I found it in the Python Essential Reference (excellent,
excellent book). I'll have to read about it in order to reply.

Thanks again for all your help.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Daniel Yoo
Sent: Saturday, June 09, 2001 2:27 AM
To: Patrick K. O'Brien
Cc: Python Tutor
Subject: Re: [Tutor] PYTHONSTARTUP under Win98

On Fri, 8 Jun 2001, Patrick K. O'Brien wrote:

> I have a python script (.pythonrc.py) created and pointed to by
> PYTHONSTARTUP in my autoexec.bat file under Win98SE. If I go to a dos
prompt

Python only looks at PYTHONSTARTUP if you run it as an interactive
interpreter.  That is, only when you run it through the dos prompt.  It's
one of those details that the official tutorial sorta whispers vaguely
about... *grin*


"""
This file is only read in interactive sessions, not when Python reads
commands from a script, and not when /dev/tty is given as the explicit
source of commands (which otherwise behaves like an interactive session).
"""

http://www.python.org/doc/current/tut/node4.html#SECTION00423000000000000000
0



> So what gives? Is this the expected behavior? I just found an IDLE command
> line flag (-s will run $IDLESTARTUP or $PYTHONSTARTUP first) in the help
> file. So maybe that is the case.

Yes, you'll want to add the -s option to get IDLE to look at the
$PYTHONSTARTUP variable.


Another approach that we can use to get things to load automatically is to
add some lines to the "site.py", which makes changes for everyone,
regardless if we're running Python interactively or not.

Hope this helps!


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From pobrien@orbtech.com  Sat Jun  9 15:52:03 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sat, 9 Jun 2001 09:52:03 -0500
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin]
In-Reply-To: <Pine.LNX.4.21.0106090002040.956-100000@hkn.eecs.berkeley.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBGEBLKAAA.pobrien@orbtech.com>

Cool idea. Could I suggest a small change, though? The documentation for
site says this:

"After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored."

So would it make more sense to create a sitecustomize.py file with your
code? I'm going to give it a try, as soon as I have another cup of coffee.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Daniel Yoo
Sent: Saturday, June 09, 2001 2:06 AM
To: Timothy Wilson
Cc: Python-Edu SIG; tutor@python.org
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help()
as a builtin]


>> Is it practical and possible to have pydoc's help() function
>> autoloaded by bundling a modified interpreter?

> Yes, I've followed that discussion on the tutor list too. I think some
> sort of interactive help would be great. I'm afraid modifying the
> interpreter is a bit beyond me at this point, however. Making the CD
> more interactive would be very cool, no doubt.


Yahoo!  We don't need to recompile at all: we just need to append the
following to site.py within the library :

###
## (within site.py)
## Added by dyoo
from pydoc import help
__builtin__.help = help
del help
###

That will do it!  Afterwards, help() will appear to be a builtin.  I'll
crosspost this to the tutor list; people were wondering about this one.
This should definitely make things nicer for people.



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From pobrien@orbtech.com  Sat Jun  9 16:18:41 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sat, 9 Jun 2001 10:18:41 -0500
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin]
In-Reply-To: <NBBBIOJPGKJEKIECEMCBGEBLKAAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBGEBMKAAA.pobrien@orbtech.com>

Here is the code in site.py that attempts to load sitecustomize.py. As you
can gather, sitecustomize.py will have to be on the PYTHONPATH in order to
be found, which limits where the file can be located.

#
# Run custom site specific code, if available.
#
try:
    import sitecustomize
except ImportError:
    pass

Site.py lives in the Lib directory, so that might be one place to put
sitecustomize.py. I don't like that because I like to keep customizations
separate from standard Python stuff. So I will probably put this into one of
my own personal directories. But that doesn't work as a standard approach.

Now that I've played with this I actually like Daniel Yoo's original
suggestion the best. Maybe someone should suggest to Guido and company that
Daniel's change to site.py be added to the standard distribution. There is
something of a precedent in that site.py includes some code to define
responses to some other terms (see code below). Anyone know how to submit a
PEP?

--- snipped from site.py as support for PEP XXXXX ---

# Define new built-ins 'quit' and 'exit'.
# These are simply strings that display a hint on how to exit.
if os.sep == ':':
    exit = 'Use Cmd-Q to quit.'
elif os.sep == '\\':
    exit = 'Use Ctrl-Z plus Return to exit.'
else:
    exit = 'Use Ctrl-D (i.e. EOF) to exit.'
import __builtin__
__builtin__.quit = __builtin__.exit = exit
del exit

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Saturday, June 09, 2001 9:52 AM
To: Python-Edu SIG; tutor@python.org
Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting
help() as a builtin]

Cool idea. Could I suggest a small change, though? The documentation for
site says this:

"After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored."

So would it make more sense to create a sitecustomize.py file with your
code? I'm going to give it a try, as soon as I have another cup of coffee.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."




From pobrien@orbtech.com  Sat Jun  9 17:16:21 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sat, 9 Jun 2001 11:16:21 -0500
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin]
In-Reply-To: <NBBBIOJPGKJEKIECEMCBGEBLKAAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBMEBOKAAA.pobrien@orbtech.com>

I gave this a try (Adding Daniel's code to sitecustomize.py) and it didn't
quite work. Some stuff did and some didn't. As you can see from the sample
session below, help on a specific function works, but help with no
parameters does not. Weird. Daniel's code works when entered interactively
but not when loaded from sitecustomize.py. So then I tried the original
suggestion to add it to site.py and I get the same behavior. Can anyone else
confirm this? Daniel? I ran this on Win98SE with Python 2.1.

---
>>> help
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "c:\python21\lib\pydoc.py", line 1276, in __repr__
    self()
  File "c:\python21\lib\pydoc.py", line 1285, in __call__
    self.interact()
  File "c:\python21\lib\pydoc.py", line 1297, in interact
    self.output.flush()
IOError: [Errno 9] Bad file descriptor

>>> help(len)
Help on built-in function len:

len(...)
    len(object) -> integer

    Return the number of items of a sequence or mapping.
>>>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Saturday, June 09, 2001 9:52 AM
To: Python-Edu SIG; tutor@python.org
Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting
help() as a builtin]

Cool idea. Could I suggest a small change, though? The documentation for
site says this:

"After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored."

So would it make more sense to create a sitecustomize.py file with your
code? I'm going to give it a try, as soon as I have another cup of coffee.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Daniel Yoo
Sent: Saturday, June 09, 2001 2:06 AM
To: Timothy Wilson
Cc: Python-Edu SIG; tutor@python.org
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help()
as a builtin]


>> Is it practical and possible to have pydoc's help() function
>> autoloaded by bundling a modified interpreter?

> Yes, I've followed that discussion on the tutor list too. I think some
> sort of interactive help would be great. I'm afraid modifying the
> interpreter is a bit beyond me at this point, however. Making the CD
> more interactive would be very cool, no doubt.


Yahoo!  We don't need to recompile at all: we just need to append the
following to site.py within the library :

###
## (within site.py)
## Added by dyoo
from pydoc import help
__builtin__.help = help
del help
###

That will do it!  Afterwards, help() will appear to be a builtin.  I'll
crosspost this to the tutor list; people were wondering about this one.
This should definitely make things nicer for people.



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig



From pobrien@orbtech.com  Sat Jun  9 17:34:53 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sat, 9 Jun 2001 11:34:53 -0500
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin]
In-Reply-To: <NBBBIOJPGKJEKIECEMCBMEBOKAAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBMEBPKAAA.pobrien@orbtech.com>

Just to be thoroughly anal about this whole thing, I added the following
code to my .pythonrc.py PYTHONSTARTUP file:

import __builtin__
from pydoc import help
__builtin__.help = help
del help
del __builtin__

When I go into an IDE that honors PYTHONSTARTUP, such as IDLE with the -s
command line switch, help is added to builtin and works completely fine (see
below for sample output).

I must admit, I'm not sure I understand the advantage of having help be a
builtin versus having it be just 'from pydoc import help' except that the
latter did nothing when I tried it as part of site.py. So I imagine there
are namespace things going on that I don't fully understand.

---
Here is what 'help' at the python prompt should look like:
---
>>> help

Welcome to Python 2.1!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://www.python.org/doc/tut/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Saturday, June 09, 2001 11:16 AM
To: Python-Edu SIG; tutor@python.org
Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting
help() as a builtin]

I gave this a try (Adding Daniel's code to sitecustomize.py) and it didn't
quite work. Some stuff did and some didn't. As you can see from the sample
session below, help on a specific function works, but help with no
parameters does not. Weird. Daniel's code works when entered interactively
but not when loaded from sitecustomize.py. So then I tried the original
suggestion to add it to site.py and I get the same behavior. Can anyone else
confirm this? Daniel? I ran this on Win98SE with Python 2.1.

---
>>> help
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "c:\python21\lib\pydoc.py", line 1276, in __repr__
    self()
  File "c:\python21\lib\pydoc.py", line 1285, in __call__
    self.interact()
  File "c:\python21\lib\pydoc.py", line 1297, in interact
    self.output.flush()
IOError: [Errno 9] Bad file descriptor

>>> help(len)
Help on built-in function len:

len(...)
    len(object) -> integer

    Return the number of items of a sequence or mapping.
>>>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."




From kromag@nsacom.net  Sun Jun 10 07:35:11 2001
From: kromag@nsacom.net (kromag@nsacom.net)
Date: Sat, 9 Jun 2001 23:35:11 -0700 (PDT)
Subject: [Tutor] PosixSerial.py seems to be missing....
Message-ID: <200106100635.f5A6ZBg21652@pop.nsacom.net>

Does anyone know of a mirror for the PosixSerial.py module? The link at 
Vaults of Parnassus is dead. (http://members.tripod.com/~gcavazos/)

Thanks!

d


From allan.crooks@btinternet.com  Sun Jun 10 15:28:38 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Sun, 10 Jun 2001 15:28:38 +0100
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
Message-ID: <E1596EY-000JgG-00@mk-smarthost-2.mail.uk.worldonline.com>

Hi,

First off, thanks to everyone who responded to my message. Needless to say, I feel somewhat stupid for not trying print. :)

Thanks for the scripts people sent as well. I'm growing somewhat fond of Patrick's however, so I'll probably use that over Pydoc's. Thanks very much Patrick. :)

BTW, does anyone know how Pydoc retrieves the arg list for functions when you use help?

e.g.

>>> def t(x,y,s,ll,m,f=None,n=2):
..   print x,y,s,ll,m,f,n

>>> pydoc.help(t)

Help on function t in module __main__:

t(x, y, s, ll, m, f=None, n=2)


Which now brings me to my next question: Is there a central repository of functions that exist somewhere? Something like a utility module? It just seems a shame for all these methods to just float around without having a home of some sort...

Thanks again,
Allan.



From pobrien@orbtech.com  Sun Jun 10 16:16:21 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sun, 10 Jun 2001 10:16:21 -0500
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
In-Reply-To: <E1596EY-000JgG-00@mk-smarthost-2.mail.uk.worldonline.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBOECEKAAA.pobrien@orbtech.com>

You are most welcome. If you are interested, here is the latest version of
my startup file (.pythonrc.py):

from pydoc import help
from pprint import pprint

def doc(x):
    """Print type, representation and documentation string for object x."""
    print "Object:", str(x)
    print "Object Type:", type(x)
    print "Representation:", repr(x)
    print "Documentation String:"
    print "---------------------"
    try:
        print x.__doc__
    except AttributeError:
        print "This object does not have a documentation string."

# Let the user know that this file has been loaded by their IDE.
# If it doesn't get loaded they won't see the following message.
import os
print "---"
print "Python Startup file (%s) was loaded." %
os.environ.get('PYTHONSTARTUP')
print "---"
del os

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Allan Crooks
Sent: Sunday, June 10, 2001 9:29 AM
To: tutor@python.org
Subject: [Tutor] Central Python Library / Viewing __doc__ strings

Hi,

First off, thanks to everyone who responded to my message. Needless to say,
I feel somewhat stupid for not trying print. :)

Thanks for the scripts people sent as well. I'm growing somewhat fond of
Patrick's however, so I'll probably use that over Pydoc's. Thanks very much
Patrick. :)




From pobrien@orbtech.com  Sun Jun 10 17:12:09 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sun, 10 Jun 2001 11:12:09 -0500
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
In-Reply-To: <E1596EY-000JgG-00@mk-smarthost-2.mail.uk.worldonline.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBCECGKAAA.pobrien@orbtech.com>

Not entirely sure what you are looking for, but here are some suggestions
anyway:

1. Type dir() to see a list of stuff in the current namespace. Type
dir([object]) to get a list of attributes/methods/functions for an object.
For example:

>>> import pydoc
>>> dir(pydoc)
['Doc', 'ErrorDuringImport', 'HTMLDoc', 'HTMLRepr', 'Helper',
'ModuleScanner', 'Repr', 'Scanner', 'TextDoc', 'TextRepr', '__author__',
'__builtins__', '__credits__', '__date__', '__doc__', '__file__',
'__name__', '__version__', 'allmethods', 'apropos', 'classname', 'cli',
'cram', 'describe', 'doc', 'expandtabs', 'find', 'getdoc', 'getpager',
'gui', 'help', 'html', 'imp', 'importfile', 'inspect', 'isdata',
'ispackage', 'ispath', 'join', 'locate', 'lower', 'os', 'pager', 'pathdirs',
'pipepager', 'plain', 'plainpager', 're', 'replace', 'rfind', 'rstrip',
'safeimport', 'serve', 'split', 'splitdoc', 'stat', 'strip', 'stripid',
'synopsis', 'sys', 'tempfilepager', 'text', 'ttypager', 'types', 'writedoc',
'writedocs']
>>>

2. Look in the documentation at the module index to see all the modules and
the functions defined in each
(http://www.python.org/doc/current/modindex.html). Or try the index
(http://www.python.org/doc/current/lib/genindex.html).


Let me know if I am way off base because I'm sure I probably misunderstood
the question.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Allan Crooks
Sent: Sunday, June 10, 2001 9:29 AM
To: tutor@python.org
Subject: [Tutor] Central Python Library / Viewing __doc__ strings

Hi,

<snip>

Which now brings me to my next question: Is there a central repository of
functions that exist somewhere? Something like a utility module? It just
seems a shame for all these methods to just float around without having a
home of some sort...

Thanks again,
Allan.


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From allan.crooks@btinternet.com  Sun Jun 10 18:09:43 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Sun, 10 Jun 2001 18:09:43 +0100
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
Message-ID: <E1598kn-000L4Q-00@mk-smarthost-1.mail.uk.worldonline.com>

Thanks for the information, but yes, there was a bit of a misunderstanding. :)

What I meant was is there any kind of place where code that we've written can become easily public domain?

For example, I've written a piece of code that denests lists, tuples, and any other sequence type (it's better than I've described it, honest). It's currently sitting at home, not publicly available. I could put it online, but I doubt anyone would really be interested in it on it's own (they could probably write something in the time it takes to actually find it).

But if there was some place where little pieces of code was collected together and put in the public domain, so that people could find it more easily, and people could use this utility module to use several little functions (to save time coding their own).

I think Useless Python is the closest that I've come to it, but I think I'm looking for a place to submit generic functions. I may just end up putting my own repository of code online anyway...... Just wondered if there was a way I could donate my code for the "greater good" really. :)

Thanks anyway,
Allan.

> Not entirely sure what you are looking for, but here are some suggestions
> anyway:
> 
> 1. Type dir() to see a list of stuff in the current namespace. Type
> dir([object]) to get a list of attributes/methods/functions for an object.
> For example:
> 
> >>> import pydoc
> >>> dir(pydoc)
> ['Doc', 'ErrorDuringImport', 'HTMLDoc', 'HTMLRepr', 'Helper',
> 'ModuleScanner', 'Repr', 'Scanner', 'TextDoc', 'TextRepr', '__author__',
> '__builtins__', '__credits__', '__date__', '__doc__', '__file__',
> '__name__', '__version__', 'allmethods', 'apropos', 'classname', 'cli',
> 'cram', 'describe', 'doc', 'expandtabs', 'find', 'getdoc', 'getpager',
> 'gui', 'help', 'html', 'imp', 'importfile', 'inspect', 'isdata',
> 'ispackage', 'ispath', 'join', 'locate', 'lower', 'os', 'pager', 'pathdirs',
> 'pipepager', 'plain', 'plainpager', 're', 'replace', 'rfind', 'rstrip',
> 'safeimport', 'serve', 'split', 'splitdoc', 'stat', 'strip', 'stripid',
> 'synopsis', 'sys', 'tempfilepager', 'text', 'ttypager', 'types', 'writedoc',
> 'writedocs']
> >>>
> 
> 2. Look in the documentation at the module index to see all the modules and
> the functions defined in each
> (http://www.python.org/doc/current/modindex.html). Or try the index
> (http://www.python.org/doc/current/lib/genindex.html).
> 
> 
> Let me know if I am way off base because I'm sure I probably misunderstood
> the question.
> 
> ---
> Patrick K. O'Brien
> Orbtech
> "I am, therefore I think."
> 
> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Allan Crooks
> Sent: Sunday, June 10, 2001 9:29 AM
> To: tutor@python.org
> Subject: [Tutor] Central Python Library / Viewing __doc__ strings
> 
> Hi,
> 
> <snip>
> 
> Which now brings me to my next question: Is there a central repository of
> functions that exist somewhere? Something like a utility module? It just
> seems a shame for all these methods to just float around without having a
> home of some sort...
> 
> Thanks again,
> Allan.
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 



From pobrien@orbtech.com  Sun Jun 10 18:28:07 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sun, 10 Jun 2001 12:28:07 -0500
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
In-Reply-To: <E1598kn-000L4Q-00@mk-smarthost-1.mail.uk.worldonline.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBGECHKAAA.pobrien@orbtech.com>

Ah, yes. That code sounds interesting. I wouldn't mind seeing it myself. I
think I might have a need for something like that, actually. Useless Python
is a great spot for something like this and the Python Cookbook is as well
(http://aspn.activestate.com/ASPN/Python/Cookbook/). I think the Python
Cookbook is exactly what you were looking for. See what you think. In the
mean time, I'd love a copy of the code. Thanks.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Allan Crooks
Sent: Sunday, June 10, 2001 12:10 PM
To: tutor@python.org
Subject: RE: [Tutor] Central Python Library / Viewing __doc__ strings

Thanks for the information, but yes, there was a bit of a misunderstanding.
:)

What I meant was is there any kind of place where code that we've written
can become easily public domain?

For example, I've written a piece of code that denests lists, tuples, and
any other sequence type (it's better than I've described it, honest). It's
currently sitting at home, not publicly available. I could put it online,
but I doubt anyone would really be interested in it on it's own (they could
probably write something in the time it takes to actually find it).

But if there was some place where little pieces of code was collected
together and put in the public domain, so that people could find it more
easily, and people could use this utility module to use several little
functions (to save time coding their own).

I think Useless Python is the closest that I've come to it, but I think I'm
looking for a place to submit generic functions. I may just end up putting
my own repository of code online anyway...... Just wondered if there was a
way I could donate my code for the "greater good" really. :)

Thanks anyway,
Allan.

> Not entirely sure what you are looking for, but here are some suggestions
> anyway:
>
> 1. Type dir() to see a list of stuff in the current namespace. Type
> dir([object]) to get a list of attributes/methods/functions for an object.
> For example:
>
> >>> import pydoc
> >>> dir(pydoc)
> ['Doc', 'ErrorDuringImport', 'HTMLDoc', 'HTMLRepr', 'Helper',
> 'ModuleScanner', 'Repr', 'Scanner', 'TextDoc', 'TextRepr', '__author__',
> '__builtins__', '__credits__', '__date__', '__doc__', '__file__',
> '__name__', '__version__', 'allmethods', 'apropos', 'classname', 'cli',
> 'cram', 'describe', 'doc', 'expandtabs', 'find', 'getdoc', 'getpager',
> 'gui', 'help', 'html', 'imp', 'importfile', 'inspect', 'isdata',
> 'ispackage', 'ispath', 'join', 'locate', 'lower', 'os', 'pager',
'pathdirs',
> 'pipepager', 'plain', 'plainpager', 're', 'replace', 'rfind', 'rstrip',
> 'safeimport', 'serve', 'split', 'splitdoc', 'stat', 'strip', 'stripid',
> 'synopsis', 'sys', 'tempfilepager', 'text', 'ttypager', 'types',
'writedoc',
> 'writedocs']
> >>>
>
> 2. Look in the documentation at the module index to see all the modules
and
> the functions defined in each
> (http://www.python.org/doc/current/modindex.html). Or try the index
> (http://www.python.org/doc/current/lib/genindex.html).
>
>
> Let me know if I am way off base because I'm sure I probably misunderstood
> the question.
>
> ---
> Patrick K. O'Brien
> Orbtech
> "I am, therefore I think."
>
> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Allan Crooks
> Sent: Sunday, June 10, 2001 9:29 AM
> To: tutor@python.org
> Subject: [Tutor] Central Python Library / Viewing __doc__ strings
>
> Hi,
>
> <snip>
>
> Which now brings me to my next question: Is there a central repository of
> functions that exist somewhere? Something like a utility module? It just
> seems a shame for all these methods to just float around without having a
> home of some sort...
>
> Thanks again,
> Allan.
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Sun Jun 10 18:26:05 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 10 Jun 2001 10:26:05 -0700 (PDT)
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
In-Reply-To: <E1598kn-000L4Q-00@mk-smarthost-1.mail.uk.worldonline.com>
Message-ID: <Pine.LNX.4.21.0106101021260.27610-100000@hkn.eecs.berkeley.edu>

On Sun, 10 Jun 2001, Allan Crooks wrote:

> I think Useless Python is the closest that I've come to it, but I
> think I'm looking for a place to submit generic functions. I may just
> end up putting my own repository of code online anyway...... Just
> wondered if there was a way I could donate my code for the "greater
> good" really. :)

The Vaults of Parnassus is one of the "official" repositories for Python
code:

    http://www.vex.net/parnassus


Another place that might be relevant is the Python Cookbook, maintained
here:

    http://aspn.activestate.com/ASPN/Cookbook/Python

Hope this helps!



From rob@jam.rr.com  Sun Jun 10 18:32:07 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sun, 10 Jun 2001 12:32:07 -0500
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
References: <E1598kn-000L4Q-00@mk-smarthost-1.mail.uk.worldonline.com>
Message-ID: <3B23AF17.A580EBF@jam.rr.com>

Allan Crooks wrote:
> 
> Thanks for the information, but yes, there was a bit of a misunderstanding. :)
> 
> What I meant was is there any kind of place where code that we've written can become easily public domain?
> 
> For example, I've written a piece of code that denests lists, tuples, and any other sequence type (it's better than I've described it, honest). It's currently sitting at home, not publicly available. I could put it online, but I doubt anyone would really be interested in it on it's own (they could probably write something in the time it takes to actually find it).
> 
> But if there was some place where little pieces of code was collected together and put in the public domain, so that people could find it more easily, and people could use this utility module to use several little functions (to save time coding their own).
> 
> I think Useless Python is the closest that I've come to it, but I think I'm looking for a place to submit generic functions. I may just end up putting my own repository of code online anyway...... Just wondered if there was a way I could donate my code for the "greater good" really. :)
> 
> Thanks anyway,
> Allan.
> 

Of course your code is always welcome at Useless Python (which I just
gave Yet Another face-lift, including quotes from some of you). I
encourage people to send material to Useless, the Vaults, the Cookbook,
and anywhere else you care to. Although many of us look at CPAN with
just a hint of envy, I like the fact that Useless, the Vaults, and the
Cookbook are actually quite different from each other.

After all, There's More Than One Way To Do It! (Oh, wait.... That's Perl
again.)

Rob
-- 

Useless Python!
Kinda like the AOL of the Open Source Community 3;->
http://www.lowerstandard.com/python/index.html


From dyoo@hkn.eecs.berkeley.edu  Sun Jun 10 18:37:50 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 10 Jun 2001 10:37:50 -0700 (PDT)
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting
 help() as a builtin]
In-Reply-To: <NBBBIOJPGKJEKIECEMCBMEBPKAAA.pobrien@orbtech.com>
Message-ID: <Pine.LNX.4.21.0106101026150.27610-100000@hkn.eecs.berkeley.edu>

On Sat, 9 Jun 2001, Patrick K. O'Brien wrote:

> import __builtin__
> from pydoc import help
> __builtin__.help = help
> del help
> del __builtin__
> 
> When I go into an IDE that honors PYTHONSTARTUP, such as IDLE with the
> -s command line switch, help is added to builtin and works completely
> fine (see below for sample output).

Ah, good!  I'm glad it's working now.


> I must admit, I'm not sure I understand the advantage of having help
> be a builtin versus having it be just 'from pydoc import help' except
> that the latter did nothing when I tried it as part of site.py. So I
> imagine there are namespace things going on that I don't fully
> understand.

It's a namespacing issue: if we do the "from pydoc import help", then
help()'s visible from the 'site' module, since that's where it's being
imported into.  However, it's not visible anywhere outside, and that's the
big problem.  We can do a small example to explore this if you want.  
It's an extension of the "local variables" idea, but instead of functions,
it uses whole files (modules) as the containers.


The way the code gets around this isolating behavior is it grabs the
__builtin__ module, which is actually just a big container for all the
built-in functions that Python makes available to us globally.

###
>>> import __builtin__
>>> dir(__builtin__)
['ArithmeticError', 'AssertionError', 'AttributeError',
'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
'Exception', 'FloatingPointError', 'IOError', 'ImportError',
'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
'NotImplementedError', 'OSError', 'OverflowError', 'RuntimeError',
'RuntimeWarning', 'StandardError', 'SyntaxError', 'SyntaxWarning',
'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
'UnicodeError', 'UserWarning', 'ValueError', 'Warning',
'ZeroDivisionError', '__debug__', '__doc__', '__import__', '__name__',
'abs', 'apply', 'buffer', 'callable', 'chr', 'cmp', 'coerce', 'compile',
'complex', 'copyright', 'credits', 'delattr', 'dir', 'divmod', 'eval',
'execfile', 'exit', 'filter', 'float', 'getattr', 'globals', 'hasattr',
'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass',
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'oct',
'open', 'ord', 'pow', 'quit', 'range', 'raw_input', 'reduce', 'reload',
'repr', 'round', 'setattr', 'slice', 'str', 'tuple', 'type', 'unichr',
'unicode', 'vars', 'xrange', 'zip']
###


The code snippet that we have:

> import __builtin__
> from pydoc import help
> __builtin__.help = help

is meant to stuff our help function() alongside those other functions.



[about the unsuccessful approach in sitecustomize.py]

> but not when loaded from sitecustomize.py. So then I tried the original
> suggestion to add it to site.py and I get the same behavior. Can anyone else
> confirm this? Daniel? I ran this on Win98SE with Python 2.1.

Hmmm!  I haven't been able to confirm this; I don't have Windows on this
laptop.  I'll see if I can check this on Win2k when I get home though.



From pobrien@orbtech.com  Sun Jun 10 18:41:01 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sun, 10 Jun 2001 12:41:01 -0500
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
In-Reply-To: <E1596EY-000JgG-00@mk-smarthost-2.mail.uk.worldonline.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBCECIKAAA.pobrien@orbtech.com>

First, the short answer. It's all in the inspect module:

>>> import inspect
>>> inspect.getargspec(t)
(['x', 'y', 's', 'll', 'm', 'f', 'n'], None, None, (None, 2))

That gets you part of the way. Then you need to do some formatting:

>>> inspect.formatargspec(inspect.getargspec(t))
'((x, y, s, ll, m, f, n), None, None, (None, 2))'

Then you'll need to spend a few hours dissecting the inspect module to
figure out everything that goes on to get the arguments and produce the
final formatting that help(t) shows. (Because I'm too tired to do it myself
and I'm already in trouble with the wife for spending all morning on this.
<grin>)

Now for the long(er) answer. Here is the relevant method from pydoc.py. It
is part of the Helper class defined in pydoc:

    def help(self, request):
        if type(request) is type(''):
            if request == 'help': self.intro()
            elif request == 'keywords': self.listkeywords()
            elif request == 'topics': self.listtopics()
            elif request == 'modules': self.listmodules()
            elif request[:8] == 'modules ':
                self.listmodules(split(request)[1])
            elif self.keywords.has_key(request): self.showtopic(request)
            elif self.topics.has_key(request): self.showtopic(request)
            elif request: doc(request, 'Help on %s:')
        elif isinstance(request, Helper): self()
        else: doc(request, 'Help on %s:')
        self.output.write('\n')


So calling help on an object results in a call to doc(object, 'Help on
%s:'). Doc() is a function that looks like:

def doc(thing, title='Python Library Documentation: %s', forceload=0):
    """Display text documentation, given an object or a path to an
object."""
    suffix, name = '', None
    if type(thing) is type(''):
        try:
            object = locate(thing, forceload)
        except ErrorDuringImport, value:
            print value
            return
        if not object:
            print 'no Python documentation found for %s' % repr(thing)
            return
        parts = split(thing, '.')
        if len(parts) > 1: suffix = ' in ' + join(parts[:-1], '.')
        name = parts[-1]
        thing = object

    desc = describe(thing)
    module = inspect.getmodule(thing)
    if not suffix and module and module is not thing:
        suffix = ' in module ' + module.__name__
    pager(title % (desc + suffix) + '\n\n' + text.document(thing, name))


The last bit of code - text.document(thing, name) - is what we need to
explore. Doc() gets documentation on the thing with the document() method of
the TextDoc class (which is a child of the Doc class and the document method
is actually defined in the Doc class, not in TextDoc):

class Doc:
    def document(self, object, name=None, *args):
        """Generate documentation for an object."""
        args = (object, name) + args
        if inspect.ismodule(object): return apply(self.docmodule, args)
        if inspect.isclass(object): return apply(self.docclass, args)
        if inspect.isroutine(object): return apply(self.docroutine, args)
        return apply(self.docother, args)


Since in your example t is a function (inspect.isroutine(t) will return 1,
or true), we need to look at self.docroutine:

class TextDoc(Doc):
... <snipped>
    def docroutine(self, object, name=None, mod=None, cl=None):
        """Produce text documentation for a function or method object."""
        realname = object.__name__
        name = name or realname
        note = ''
        skipdocs = 0
        if inspect.ismethod(object):
            imclass = object.im_class
            if cl:
                if imclass is not cl:
                    note = ' from ' + classname(imclass, mod)
                    skipdocs = 1
            else:
                if object.im_self:
                    note = ' method of %s instance' % classname(
                        object.im_self.__class__, mod)
                else:
                    note = ' unbound %s method' % classname(imclass,mod)
            object = object.im_func

        if name == realname:
            title = self.bold(realname)
        else:
            if (cl and cl.__dict__.has_key(realname) and
                cl.__dict__[realname] is object):
                skipdocs = 1
            title = self.bold(name) + ' = ' + realname
        if inspect.isbuiltin(object):
            argspec = '(...)'
        else:
            args, varargs, varkw, defaults = inspect.getargspec(object)
            argspec = inspect.formatargspec(
                args, varargs, varkw, defaults,
formatvalue=self.formatvalue)
            if realname == '<lambda>':
                title = 'lambda'
                argspec = argspec[1:-1] # remove parentheses
        decl = title + argspec + note

        if skipdocs:
            return decl + '\n'
        else:
            doc = getdoc(object) or ''
            return decl + '\n' + (doc and rstrip(self.indent(doc)) + '\n')

Now, this is a lot of code to look at, but the answer to your question lies
with inspect.getargspec(object). If we run that bit of code on t we get the
following:

>>> inspect.getargspec(t)
(['x', 'y', 's', 'll', 'm', 'f', 'n'], None, None, (None, 2))
>>>

The rest of the code makes things a prettier.  Again, that analysis will be
left as an exercise for the reader. <wink>

Hope that answered your question.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Allan Crooks
Sent: Sunday, June 10, 2001 9:29 AM
To: tutor@python.org
Subject: [Tutor] Central Python Library / Viewing __doc__ strings

<snip>

BTW, does anyone know how Pydoc retrieves the arg list for functions when
you use help?

e.g.

>>> def t(x,y,s,ll,m,f=None,n=2):
..   print x,y,s,ll,m,f,n

>>> pydoc.help(t)

Help on function t in module __main__:

t(x, y, s, ll, m, f=None, n=2)

<snip>

Thanks again,
Allan.


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From pobrien@orbtech.com  Sun Jun 10 19:22:07 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sun, 10 Jun 2001 13:22:07 -0500
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin]
In-Reply-To: <Pine.LNX.4.21.0106101026150.27610-100000@hkn.eecs.berkeley.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBCECJKAAA.pobrien@orbtech.com>

Just to clarify a tiny bit. (I hope) Adding help to the builtins works from
my PYTHONSTARTUP file, but not from site.py or sitecustomize.py. So it
doesn't really have any advantage over 'from pydoc import help' when loaded
this way, does it? If it will only work properly from the startup file, I
feel that "from pydoc import help" is just as good an approach. In fact, it
has the advantage of being listed in dir() and not buried in __builtins__.
Or am I missing something?

I think I understand the namespace concept pretty well. (I hope. <g>) What I
don't understand is why the module pointed to by PYTHONSTARTUP is part of
the global namespace (which is why we can just do 'from pydoc import help'
in it, and the help function stays around) while site.py is not (so while
'from pydoc import help' works it also "disappears" once control goes to the
interactive prompt, unless we do the __builtin__ trick). Well, I do
understand why it works that way for the startup file. It just seemed like
it would work the same for site.py, based on the (skimpy) documentation. So
my confusion has more to do with a lack of documented behavior, rather than
the behavior itself, if that makes any sense. And maybe the answer is just
"because".

Other than that, I understand and agree with everything you say below. I
just wish I knew why your suggested code doesn't entirely work in site.py.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Daniel Yoo
Sent: Sunday, June 10, 2001 12:38 PM
To: Patrick K. O'Brien
Cc: tutor@python.org
Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting
help() as a builtin]

On Sat, 9 Jun 2001, Patrick K. O'Brien wrote:

> import __builtin__
> from pydoc import help
> __builtin__.help = help
> del help
> del __builtin__
>
> When I go into an IDE that honors PYTHONSTARTUP, such as IDLE with the
> -s command line switch, help is added to builtin and works completely
> fine (see below for sample output).

Ah, good!  I'm glad it's working now.


> I must admit, I'm not sure I understand the advantage of having help
> be a builtin versus having it be just 'from pydoc import help' except
> that the latter did nothing when I tried it as part of site.py. So I
> imagine there are namespace things going on that I don't fully
> understand.

It's a namespacing issue: if we do the "from pydoc import help", then
help()'s visible from the 'site' module, since that's where it's being
imported into.  However, it's not visible anywhere outside, and that's the
big problem.  We can do a small example to explore this if you want.
It's an extension of the "local variables" idea, but instead of functions,
it uses whole files (modules) as the containers.


The way the code gets around this isolating behavior is it grabs the
__builtin__ module, which is actually just a big container for all the
built-in functions that Python makes available to us globally.

###
>>> import __builtin__
>>> dir(__builtin__)
['ArithmeticError', 'AssertionError', 'AttributeError',
'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
'Exception', 'FloatingPointError', 'IOError', 'ImportError',
'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
'NotImplementedError', 'OSError', 'OverflowError', 'RuntimeError',
'RuntimeWarning', 'StandardError', 'SyntaxError', 'SyntaxWarning',
'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
'UnicodeError', 'UserWarning', 'ValueError', 'Warning',
'ZeroDivisionError', '__debug__', '__doc__', '__import__', '__name__',
'abs', 'apply', 'buffer', 'callable', 'chr', 'cmp', 'coerce', 'compile',
'complex', 'copyright', 'credits', 'delattr', 'dir', 'divmod', 'eval',
'execfile', 'exit', 'filter', 'float', 'getattr', 'globals', 'hasattr',
'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass',
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'oct',
'open', 'ord', 'pow', 'quit', 'range', 'raw_input', 'reduce', 'reload',
'repr', 'round', 'setattr', 'slice', 'str', 'tuple', 'type', 'unichr',
'unicode', 'vars', 'xrange', 'zip']
###


The code snippet that we have:

> import __builtin__
> from pydoc import help
> __builtin__.help = help

is meant to stuff our help function() alongside those other functions.



[about the unsuccessful approach in sitecustomize.py]

> but not when loaded from sitecustomize.py. So then I tried the original
> suggestion to add it to site.py and I get the same behavior. Can anyone
else
> confirm this? Daniel? I ran this on Win98SE with Python 2.1.

Hmmm!  I haven't been able to confirm this; I don't have Windows on this
laptop.  I'll see if I can check this on Win2k when I get home though.


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Sun Jun 10 20:46:47 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 10 Jun 2001 12:46:47 -0700 (PDT)
Subject: [Tutor] PosixSerial.py seems to be missing....
In-Reply-To: <200106100635.f5A6ZBg21652@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106101245290.28691-100000@hkn.eecs.berkeley.edu>

On Sat, 9 Jun 2001 kromag@nsacom.net wrote:
> Does anyone know of a mirror for the PosixSerial.py module? The link at 
> Vaults of Parnassus is dead. (http://members.tripod.com/~gcavazos/)

Ouch!  I haven't been able to find this either; you may want to ask the
comp.lang.python folks and bring this to their attention.



From israel@lith.com  Sun Jun 10 21:35:19 2001
From: israel@lith.com (Israel Evans)
Date: Sun, 10 Jun 2001 13:35:19 -0700
Subject: [Tutor] request: info on AI and related subjects for Python
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A14494@mailcluster.lith.com>

Has anyone found any good information on applying Python to AI/Neural
network yada yada programming and whether or not it's a good idea?


~Israel~


From lumbricus@gmx.net  Sun Jun 10 22:49:06 2001
From: lumbricus@gmx.net (lumbricus@gmx.net)
Date: Sun, 10 Jun 2001 23:49:06 +0200
Subject: [Tutor] request: info on AI and related subjects for Python
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A14494@mailcluster.lith.com>; from israel@lith.com on Sun, Jun 10, 2001 at 01:35:19PM -0700
References: <AF020C5FC551DD43A4958A679EA16A15A14494@mailcluster.lith.com>
Message-ID: <20010610234906.A14085@Laplace.localdomain>

On Sun, Jun 10, 2001 at 01:35:19PM -0700, Israel Evans wrote:
> Has anyone found any good information on applying Python to AI/Neural
> network yada yada programming and whether or not it's a good idea?
> 

"http://www.ai.uga.edu/~jae/ai.html"
"http://www-acs.ucsd.edu/~jstrout/python/ai/"

> 
> ~Israel~
> 

HTH J!

> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

-- 
Colorless green ideas sleep furiously.


From InternetShops@mail.ru  Mon Jun 11 00:22:30 2001
From: InternetShops@mail.ru (InternetShops@mail.ru)
Date: Mon, 11 Jun 2001 01:22:30 +0200
Subject: [Tutor] úáëáú îáäåöîïçï ïâïòõäï÷áîéñ þåòåú éîôåòîåô
Message-ID: <200106102322.f5ANMUM14499@friedrich.unkelhaeuser.de>

This is a MIME encoded message.

--b21fe52ec73da2129e8a6323ced0b8f49
Content-Type: text/html ;	charset="windows-1251"
Content-Transfer-Encoding: base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
L0VOIj4NCg0KPGh0bWw+DQo8aGVhZD4NCgk8dGl0bGU+x8DKwMcgzcDExcbNzsPOIM7BztDTxM7C
wM3I3yDXxdDFxyDIzdLF0M3F0jwvdGl0bGU+DQo8L2hlYWQ+DQoNCjxib2R5Pg0KPGRpdiBhbGln
bj0iQ0VOVEVSIj4NCjxoMj7V7vDu+OXlIO7h7vDz5O7i4O3o5SDs7ubt7iDq8+/o8vwsIOfg6uDn
4OIg9+Xw5ecgyO3y5fDt5fI6PC9oMj4NCjx0YWJsZT4NCjx0cj4NCgk8dGQ+PGI+yu7s7/z+8uXw
+zo8L2I+PC90ZD4NCjwvdHI+DQo8dHI+DQoJPHRkPjxhIGhyZWY9Imh0dHA6Ly93d3cudmlzdC5y
dUB3d3cuamFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD10dXRvckBweXRob24ub3JnJnM9dmlzdC5y
dSI+dmlzdC5ydTwvYT48YnI+DQoJPGEgaHJlZj0iaHR0cDovL3d3dy5rbG9uZGFpay5ydUB3d3cu
amFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD10dXRvckBweXRob24ub3JnJnM9a2xvbmRhaWsucnUi
Pmtsb25kYWlrLnJ1PC9hPjxicj4NCgk8YSBocmVmPSJodHRwOi8vd3d3Lm12aWRlby5ydUB3d3cu
amFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD10dXRvckBweXRob24ub3JnJnM9bXZpZGVvLnJ1Ij5t
dmlkZW8ucnU8L2E+DQoJPC90ZD4NCjwvdHI+DQo8dHI+DQoJPHRkPjxiPs3u8/Lh8+roOjwvYj48
L3RkPg0KPC90cj4NCjx0cj4NCgk8dGQ+PGEgaHJlZj0iaHR0cDovL3d3dy5ub3RlYm9va3BvcnRh
bC5ydUB3d3cuamFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD10dXRvckBweXRob24ub3JnJnM9bm90
ZWJvb2twb3J0YWwucnUiPm5vdGVib29rcG9ydGFsLnJ1PC9hPjwvdGQ+DQo8L3RyPg0KPHRyPg0K
CTx0ZD48YSBocmVmPSJodHRwOi8vd3d3Lm5ib29rLnJ1QHd3dy5qYW4taGVuZHJpay5jb20vcmVz
LnBocD90PXR1dG9yQHB5dGhvbi5vcmcmcz1uYm9vay5ydSI+bmJvb2sucnUgPC9hPjwvdGQ+DQo8
L3RyPg0KPHRyPg0KCTx0ZD48YSBocmVmPSJodHRwOi8vd3d3Lm1pY3JvbWF0aXgucnVAd3d3Lmph
bi1oZW5kcmlrLmNvbS9yZXMucGhwP3Q9dHV0b3JAcHl0aG9uLm9yZyZzPW1pY3JvbWF0aXgucnUi
Pm1pY3JvbWF0aXgucnU8L2E+PC90ZD4NCjwvdHI+DQo8dHI+DQoJPHRkPjxiPs/w6O3y5fD7Ojwv
Yj48L3RkPg0KPC90cj4NCjx0cj4NCgk8dGQ+PGEgaHJlZj0iaHR0cDovL3d3dy5kb3N0YXZrYS5y
dUB3d3cuamFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD10dXRvckBweXRob24ub3JnJnM9ZG9zdGF2
a2EucnUiPmRvc3RhdmthLnJ1PC9hPjwvdGQ+DQo8L3RyPg0KPHRyPg0KCTx0ZD48YSBocmVmPSJo
dHRwOi8vd3d3LmFydXMucnVAd3d3Lmphbi1oZW5kcmlrLmNvbS9yZXMucGhwP3Q9dHV0b3JAcHl0
aG9uLm9yZyZzPWFydXMucnUiPmFydXMucnU8L2E+PC90ZD4NCjwvdHI+DQo8dHI+DQoJPHRkPjxi
Pszz6/zy6Ozl5OjgLe/w7uXq8u7w+yAo4ujk5e7v8O7l6vLu8PspOjwvYj48L3RkPg0KPC90cj4N
Cjx0cj4NCgk8dGQ+PGEgaHJlZj0iaHR0cDovL3d3dy5hbGxwcm9qZWN0b3JzLnJ1QHd3dy5qYW4t
aGVuZHJpay5jb20vcmVzLnBocD90PXR1dG9yQHB5dGhvbi5vcmcmcz1hbGxwcm9qZWN0b3JzLnJ1
Ij5hbGxwcm9qZWN0b3JzLnJ1PC9hPjwvdGQ+DQo8L3RyPg0KPHRyPg0KCTx0ZD48YSBocmVmPSJo
dHRwOi8vd3d3Lm11bHRpbWVkaWEtcHJvamVjdG9yLnJ1QHd3dy5qYW4taGVuZHJpay5jb20vcmVz
LnBocD90PXR1dG9yQHB5dGhvbi5vcmcmcz1tdWx0aW1lZGlhLXByb2plY3Rvci5ydSI+bXVsdGlt
ZWRpYS1wcm9qZWN0b3IucnU8L2E+PC90ZD4NCjwvdHI+DQo8dHI+DQoJPHRkPjxhIGhyZWY9Imh0
dHA6Ly93d3cuYWxlZS5jb21Ad3d3Lmphbi1oZW5kcmlrLmNvbS9yZXMucGhwP3Q9dHV0b3JAcHl0
aG9uLm9yZyZzPWFsZWUuY29tIj5hbGVlLmNvbTwvYT48L3RkPg0KPC90cj4NCjx0cj4NCgk8dGQ+
PGI+yu7v6PD7OjwvYj48L3RkPg0KPC90cj4NCjx0cj4NCgk8dGQ+PGEgaHJlZj0iaHR0cDovL3d3
dy5taXRhLnJ1QHd3dy5qYW4taGVuZHJpay5jb20vcmVzLnBocD90PXR1dG9yQHB5dGhvbi5vcmcm
cz1taXRhLnJ1Ij5taXRhLnJ1PC9hPjwvdGQ+DQo8L3RyPg0KPHRyPg0KCTx0ZD48YSBocmVmPSJo
dHRwOi8vd3d3Lm1hcnZlbC5ydUB3d3cuamFuLWhlbmRyaWsuY29tL3Jlcy5waHA/dD10dXRvckBw
eXRob24ub3JnJnM9bWFydmVsLnJ1Ij5tYXJ2ZWwucnU8L2E+PC90ZD4NCjwvdHI+DQo8dHI+DQoJ
PHRkPjxhIGhyZWY9Imh0dHA6Ly93d3cuc2NvcHkucnVAd3d3Lmphbi1oZW5kcmlrLmNvbS9yZXMu
cGhwP3Q9dHV0b3JAcHl0aG9uLm9yZyZzPXNjb3B5LnJ1Ij5zY29weS5ydTwvYT48L3RkPg0KPC90
cj4NCjwvdGFibGU+DQoNCjwvZGl2Pg0KPC9ib2R5Pg0KPC9odG1sPg0K

--b21fe52ec73da2129e8a6323ced0b8f49--





From dyoo@hkn.eecs.berkeley.edu  Mon Jun 11 03:03:09 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Sun, 10 Jun 2001 19:03:09 -0700 (PDT)
Subject: [Tutor] request: info on AI and related subjects for Python
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A14494@mailcluster.lith.com>
Message-ID: <Pine.LNX.4.21.0106101855510.32000-100000@hkn.eecs.berkeley.edu>

On Sun, 10 Jun 2001, Israel Evans wrote:

> Has anyone found any good information on applying Python to AI/Neural
> network yada yada programming and whether or not it's a good idea?

Peter Norvig, one of the authors of the textbook, "Artifical Inteligence:
A Modern Approach", has a small page about Python in his AI programming.  
His page is here:

    http://www.norvig.com/python-lisp.html

This isn't quite what you're looking for though, because it only explains
the differences between Lisp and Python.  It sounds like you're more
interested in actual applications of AI stuff.  Parnassus does have some
links to AI programs.  For example, there are some neural net
implementations here:

    http://www.vex.net/parnassus/apyllo.py?find=neural+net

If you want something more input about this, you might want to talk with
people on comp.lang.python as well; I believe that Mark Lutz or one of the
other Python authors has written expert system shells in Python, so Python
seems to be a reasonable language for certain AI applications.


Anyway, hope this helps!



From bcarey@ix.netcom.com  Mon Jun 11 03:47:40 2001
From: bcarey@ix.netcom.com (William N Carey)
Date: Sun, 10 Jun 2001 19:47:40 -0700
Subject: [Tutor] a db question
Message-ID: <200106110244.WAA11500@barry.mail.mindspring.net>

Hi all,

I'm new to Python.  I love Python, and recently tried 
using it to do a very simple database project,  but perhaps my 
expectations were unrealistic. Using Python 2.0 on a Win2000
machine with 256M Ram and many gigs of disk space, I couldn't 
successfully load a text file which consists of a 12 character key 
and a 38 character text string as the record.  The problem is that 
the file consist of  about 800,000 records.  I used  "anydb" which 
on my machine uses bsddb as the default (I believe).  After about 
120,000 records the load would halt with
an "error: (0, 'error')"  .  The key and text string are normal.  I can 
start the reload a couple of records short of where it blew up, and it 
continues for another 100,000 or so records, and blows up again, 
until it finally halts at about 400,000 records with a hard halt 
(invoking my Visual C++ debugger).

I built in a file.sync instruction which happens every 10,000 
records, and this didn't help.

I suspect that I am asking the "db" routines to do too much, but 
that is disappointing to me, because Python has always done 
whatever I wanted in my limited past with it.  Below is the very 
simple program that doesn't finish.

Thanks for any advice!!!

import os, anydbm
ofile = anydbm.open("e:\\python20\\lib\\wnctrans","c")
ifile = open("e:\\python20\\lib\\wncdet","rb")
fin = ifile.fileno()
for x in range(0,783284):
   if x % 10000 == 0:
      ofile.sync
   print x
   ptr = os.lseek(fin,x * 50, 0)
   wstr = os.read(fin,50)
   if len(wstr) == 50:
      key12 = str(wstr[:12])
      item = str(wstr[12:])
      ofile[key12] = item
os.close(fin)
print "Done..."
dum = raw_input("any key")
ofile.clo


From wheelege@tsn.cc  Mon Jun 11 05:39:53 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 11 Jun 2001 14:39:53 +1000
Subject: [Tutor] a db question
References: <200106110244.WAA11500@barry.mail.mindspring.net>
Message-ID: <00cc01c0f230$907f7cc0$0200a8c0@ACE>

> <...>
> I built in a file.sync instruction which happens every 10,000
> records, and this didn't help.
>

  I'm no db expert, but in your code you aren't calling that function - you
have forgotten the ()'s :).

> <...>
>
> import os, anydbm
> ofile = anydbm.open("e:\\python20\\lib\\wnctrans","c")
> ifile = open("e:\\python20\\lib\\wncdet","rb")
> fin = ifile.fileno()
> for x in range(0,783284):
>    if x % 10000 == 0:
>       ofile.sync

  Just here ------^^

>    print x

  Perhaps you could try your code without this print?

>    ptr = os.lseek(fin,x * 50, 0)
>    wstr = os.read(fin,50)
>    if len(wstr) == 50:
>       key12 = str(wstr[:12])
>       item = str(wstr[12:])
>       ofile[key12] = item
> os.close(fin)
> print "Done..."
> dum = raw_input("any key")
> ofile.clo

  And I assume this is a classic copy and paste error, but this should be
ofile.close() :)

  Anywho, hope that helped,
  Glen.



From wheelege@tsn.cc  Mon Jun 11 07:52:23 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 11 Jun 2001 16:52:23 +1000
Subject: [Tutor] a db question
References: <200106110535.BAA13343@maynard.mail.mindspring.net>
Message-ID: <001201c0f243$1221a7a0$0200a8c0@ACE>

> Glen,
>
> I tried your suggestions, putting the parentheses after "sync" and
> getting rid of the print statement... it didn't help.  It went much
> faster with no print statement, but it blew up at exactly the same
> spot.  I carefully checked both the key value and the record (text
> string), and they were fine.  I think it may be that I only have 256M
> of RAM, and I'm getting some kind of caching problem.

  Indeed, like some sort of virtual memory problem...good old windows.

> Also, if I restart the program a couple of records before the one that
> it  blew up on, it continues fine for another 100,000 records or so,
> so it doesn't seem to be a problem with my data.
>

  That's good news.  In that case, I would suggest using multiple files -
your code looks like this...

import os, anydbm
ofile = anydbm.open("e:\\python20\\lib\\wnctrans","c")
ifile = open("e:\\python20\\lib\\wncdet","rb")
fin = ifile.fileno()
for x in range(0,783284):
   if x % 10000 == 0:
      ofile.sync
   print x
   ptr = os.lseek(fin,x * 50, 0)
   wstr = os.read(fin,50)
   if len(wstr) == 50:
      key12 = str(wstr[:12])
      item = str(wstr[12:])
      ofile[key12] = item
os.close(fin)
print "Done..."
dum = raw_input("any key")
ofile.close()

  Right?  I suppose you could try doing the same thing, but split it up into
smaller loops.  For example...

t = 0
for x in range(1000):
  t += x

  Could become...

t = 0
for y in range((1000/10), (1000+(1000/10)), (1000/10)): ## that last thing
is called the 'step'
  st = 0
  for x in range((y-(1000/10)), y):
    st += x
  t += st
  del st

  I left the range things unsimplified because although the look a little
ugly now, I hope that this way it is easier to see what is happening.  In
both cases t will have the same end value.
  Or, even better, look into the os() module and try to find stuff on memory
allocation.  I'm afraid that the multiple loops thing may just be a dead
end, so it looks like either you get thrown a bone from people more
knowledgeable than me (come on guys :) or have a bit of reading ahead of
you.  Either way, alot of fun.

  Hope that helped,
  Glen.




From ppathiyi@cisco.com  Mon Jun 11 10:50:33 2001
From: ppathiyi@cisco.com (Praveen Pathiyil)
Date: Mon, 11 Jun 2001 15:20:33 +0530
Subject: [Tutor] Getting a function name from within itself
Message-ID: <00a601c0f25b$f513b8b0$37ef87c0@ppathiyipc>

This is a multi-part message in MIME format.

------=_NextPart_000_00A3_01C0F28A.0EA2C1D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,

        I am posting a question which is not specific to python.=20
        Is there a way to get the name of a function from within itself =
at runtime ? Suppose that i have a function f1. At the run time when it =
encounters some condition ( errors or some condition which i want to let =
the user know by printing), I want to say that this warning originated =
from this function f1, without actually hard coding that name in the =
print statement.

def f1(self):
    --- do something --
    Print "Warning ......", function_name

Can i get the function name from execution environment or something ?

Thanks,
Praveen.



------=_NextPart_000_00A3_01C0F28A.0EA2C1D0
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.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; I =
am posting=20
a question which is not specific to python. </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Is there=20
a way to get the name of a function from within itself at runtime ? =
Suppose that=20
i have a function f1. At the run time when it encounters some condition =
( errors=20
or some condition which i want to let the user know by printing), I want =
to say=20
that this warning originated from this function f1, without actually =
hard coding=20
that name in the print statement.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def f1(self):</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; --- do something =
--</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Print "Warning =
......",=20
function_name</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Can i get the function name from =
execution=20
environment or something ?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Praveen.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_00A3_01C0F28A.0EA2C1D0--



From toodles@yifan.net  Mon Jun 11 11:42:36 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Mon, 11 Jun 2001 18:42:36 +0800
Subject: [Tutor] Getting a function name from within itself
In-Reply-To: <00a601c0f25b$f513b8b0$37ef87c0@ppathiyipc>
Message-ID: <FPEHJJPEEOIPMAHOADBKGEAGCEAA.toodles@yifan.net>

This is a multi-part message in MIME format.

------=_NextPart_000_0002_01C0F2A6.48A15740
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: base64

DQogICAgICAgICAgSSBhbSBwb3N0aW5nIGEgcXVlc3Rpb24gd2hpY2ggaXMgbm90IHNwZWNpZmlj
IHRvIHB5dGhvbi4gDQogICAgICAgICAgSXMgdGhlcmUgYSB3YXkgdG8gZ2V0IHRoZSBuYW1lIG9m
IGEgZnVuY3Rpb24gZnJvbSB3aXRoaW4gaXRzZWxmIGF0IHJ1bnRpbWUgPyBTdXBwb3NlIHRoYXQg
aSBoYXZlIGEgZnVuY3Rpb24gZjEuIEF0IHRoZSBydW4gdGltZSB3aGVuIGl0IGVuY291bnRlcnMg
c29tZSBjb25kaXRpb24gKCBlcnJvcnMgb3Igc29tZSBjb25kaXRpb24gd2hpY2ggaSB3YW50IHRv
IGxldCB0aGUgdXNlciBrbm93IGJ5IHByaW50aW5nKSwgSSB3YW50IHRvIHNheSB0aGF0IHRoaXMg
d2FybmluZyBvcmlnaW5hdGVkIGZyb20gdGhpcyBmdW5jdGlvbiBmMSwgd2l0aG91dCBhY3R1YWxs
eSBoYXJkIGNvZGluZyB0aGF0IG5hbWUgaW4gdGhlIHByaW50IHN0YXRlbWVudC4NCg0KICBkZWYg
ZjEoc2VsZik6DQogICAgICAtLS0gZG8gc29tZXRoaW5nIC0tDQogICAgICBQcmludCAiV2Fybmlu
ZyAuLi4uLi4iLCBmdW5jdGlvbl9uYW1lDQoNCiAgQ2FuIGkgZ2V0IHRoZSBmdW5jdGlvbiBuYW1l
IGZyb20gZXhlY3V0aW9uIGVudmlyb25tZW50IG9yIHNvbWV0aGluZyA/ICANCg0KICBUaGFua3Ms
DQogIFByYXZlZW4uDQoNCiAgV2VsbCBJIGh1cnQgbXkgYnJhaW4gdGhpbmtpbmcgYWJvdXQgdGhp
cyBvbmUsIGJ1dCBJJ2xsIHJlcGx5IG5ldmVydGhlbGVzcy4gVGhlIG1vc3QgdmlhYmxlIHNvbHV0
aW9uIEkgY2FtZSB1cCB3aXRoIHdhc24ndCB2ZXJ5IHZpYWJsZToNCg0KICBkZWYgZjEoZnVuYz1m
MSk6DQogICBwcmludCBmdW5jLmZ1bmNfbmFtZQ0KDQogIFVzZXItZGVmaW5lZC1mdW5jdGlvbnMn
IG5hbWVzcGFjZSBpcyB0aGF0IG9mIHRoZSBjYWxsaW5nIGJsb2NrLCBnaXZlbiBieSBnbG9iYWwo
KS4gVGhlIGZ1bmN0aW9uIGlzIGluIHRoZXJlIHNvbWV3aGVyZS4uLmJ1dCB0aGF0IGRvZXNuJ3Qg
c2VlbSB0byBiZSBtdWNoIG9mIGEgaGVscC4NCg0KICBDbGFzc2VzIGFyZSBhbHdheXMgZnVuICpn
cmluKg0KDQogIEFuZHJldw0K

------=_NextPart_000_0002_01C0F2A6.48A15740
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
L0VOIj4NCjxIVE1MPjxIRUFEPg0KPE1FVEEgaHR0cC1lcXVpdj1Db250ZW50LVR5cGUgY29udGVu
dD0idGV4dC9odG1sOyBjaGFyc2V0PWlzby04ODU5LTEiPg0KPE1FVEEgY29udGVudD0iTVNIVE1M
IDUuNTAuNDYxNi4yMDAiIG5hbWU9R0VORVJBVE9SPg0KPFNUWUxFPjwvU1RZTEU+DQo8L0hFQUQ+
DQo8Qk9EWSBiZ0NvbG9yPSNmZmZmZmY+DQo8QkxPQ0tRVU9URSBkaXI9bHRyIA0Kc3R5bGU9IlBB
RERJTkctTEVGVDogNXB4OyBNQVJHSU4tTEVGVDogNXB4OyBCT1JERVItTEVGVDogIzAwMDBmZiAy
cHggc29saWQ7IE1BUkdJTi1SSUdIVDogMHB4Ij4NCiAgPERJVj48Rk9OVCBmYWNlPUFyaWFsIGNv
bG9yPSMwMDAwMDAgc2l6ZT0yPjwvRk9OVD4mbmJzcDs8L0RJVj4NCiAgPERJVj48Rk9OVCBmYWNl
PUFyaWFsIHNpemU9Mj4mbmJzcDsmbmJzcDsmbmJzcDsgJm5ic3A7Jm5ic3A7Jm5ic3A7IEkgYW0g
DQogIHBvc3RpbmcgYSBxdWVzdGlvbiB3aGljaCBpcyBub3Qgc3BlY2lmaWMgdG8gcHl0aG9uLiA8
L0ZPTlQ+PC9ESVY+DQogIDxESVY+PEZPTlQgZmFjZT1BcmlhbCBzaXplPTI+Jm5ic3A7Jm5ic3A7
Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7IElzIA0KICB0aGVyZSBhIHdheSB0byBnZXQg
dGhlIG5hbWUgb2YgYSBmdW5jdGlvbiBmcm9tIHdpdGhpbiBpdHNlbGYgYXQgcnVudGltZSA/IA0K
ICBTdXBwb3NlIHRoYXQgaSBoYXZlIGEgZnVuY3Rpb24gZjEuIEF0IHRoZSBydW4gdGltZSB3aGVu
IGl0IGVuY291bnRlcnMgc29tZSANCiAgY29uZGl0aW9uICggZXJyb3JzIG9yIHNvbWUgY29uZGl0
aW9uIHdoaWNoIGkgd2FudCB0byBsZXQgdGhlIHVzZXIga25vdyBieSANCiAgcHJpbnRpbmcpLCBJ
IHdhbnQgdG8gc2F5IHRoYXQgdGhpcyB3YXJuaW5nIG9yaWdpbmF0ZWQgZnJvbSB0aGlzIGZ1bmN0
aW9uIGYxLCANCiAgd2l0aG91dCBhY3R1YWxseSBoYXJkIGNvZGluZyB0aGF0IG5hbWUgaW4gdGhl
IHByaW50IHN0YXRlbWVudC48L0ZPTlQ+PC9ESVY+DQogIDxESVY+Jm5ic3A7PC9ESVY+DQogIDxE
SVY+PEZPTlQgZmFjZT1BcmlhbCBzaXplPTI+ZGVmIGYxKHNlbGYpOjwvRk9OVD48L0RJVj4NCiAg
PERJVj48Rk9OVCBmYWNlPUFyaWFsIHNpemU9Mj4mbmJzcDsmbmJzcDsmbmJzcDsgLS0tIGRvIHNv
bWV0aGluZyANCiAgLS08L0ZPTlQ+PC9ESVY+DQogIDxESVY+PEZPTlQgZmFjZT1BcmlhbCBzaXpl
PTI+Jm5ic3A7Jm5ic3A7Jm5ic3A7IFByaW50ICJXYXJuaW5nIC4uLi4uLiIsIA0KICBmdW5jdGlv
bl9uYW1lPC9GT05UPjwvRElWPg0KICA8RElWPiZuYnNwOzwvRElWPg0KICA8RElWPjxGT05UIGZh
Y2U9QXJpYWw+PEZPTlQgc2l6ZT0yPkNhbiBpIGdldCB0aGUgZnVuY3Rpb24gbmFtZSBmcm9tIGV4
ZWN1dGlvbiANCiAgZW52aXJvbm1lbnQgb3Igc29tZXRoaW5nID88U1BBTiBjbGFzcz03MTAwNzIy
MTAtMTEwNjIwMDE+PEZPTlQgZmFjZT1UYWhvbWEgDQogIGNvbG9yPSMwMDAwZmY+Jm5ic3A7PC9G
T05UPjwvU1BBTj48L0ZPTlQ+PC9GT05UPjxGT05UIGZhY2U9QXJpYWw+PEZPTlQgDQogIHNpemU9
Mj48U1BBTiBjbGFzcz03MTAwNzIyMTAtMTEwNjIwMDE+Jm5ic3A7PC9TUEFOPjwvRk9OVD48L0ZP
TlQ+PC9ESVY+DQogIDxESVY+Jm5ic3A7PC9ESVY+DQogIDxESVY+PEZPTlQgZmFjZT1BcmlhbCBz
aXplPTI+VGhhbmtzLDwvRk9OVD48L0RJVj4NCiAgPERJVj48Rk9OVCBmYWNlPUFyaWFsIHNpemU9
Mj5QcmF2ZWVuLjwvRk9OVD48L0RJVj4NCiAgPERJVj48Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0j
MDAwMGZmIHNpemU9Mj48L0ZPTlQ+Jm5ic3A7PC9ESVY+DQogIDxESVY+PFNQQU4gY2xhc3M9NzEw
MDcyMjEwLTExMDYyMDAxPjxGT05UIGZhY2U9VGFob21hIGNvbG9yPSMwMDAwZmYgDQogIHNpemU9
Mj5XZWxsIEkmbmJzcDtodXJ0IG15IGJyYWluIHRoaW5raW5nIGFib3V0IHRoaXMgb25lLCBidXQg
SSdsbCByZXBseSANCiAgbmV2ZXJ0aGVsZXNzLiBUaGUgbW9zdCB2aWFibGUgc29sdXRpb24gSSBj
YW1lIHVwIHdpdGggd2Fzbid0IHZlcnkgDQogIHZpYWJsZTo8L0ZPTlQ+PC9TUEFOPjwvRElWPg0K
ICA8RElWPjxTUEFOIGNsYXNzPTcxMDA3MjIxMC0xMTA2MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBj
b2xvcj0jMDAwMGZmIA0KICBzaXplPTI+PC9GT05UPjwvU1BBTj4mbmJzcDs8L0RJVj4NCiAgPERJ
Vj48U1BBTiBjbGFzcz03MTAwNzIyMTAtMTEwNjIwMDE+PEZPTlQgZmFjZT1UYWhvbWEgY29sb3I9
IzAwMDBmZiBzaXplPTI+ZGVmIA0KICBmMShmdW5jPWYxKTo8L0ZPTlQ+PC9TUEFOPjwvRElWPg0K
ICA8RElWPjxTUEFOIGNsYXNzPTcxMDA3MjIxMC0xMTA2MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBj
b2xvcj0jMDAwMGZmIA0KICBzaXplPTI+Jm5ic3A7cHJpbnQgZnVuYy5mdW5jX25hbWU8L0ZPTlQ+
PC9TUEFOPjwvRElWPg0KICA8RElWPjxTUEFOIGNsYXNzPTcxMDA3MjIxMC0xMTA2MjAwMT48Rk9O
VCBmYWNlPVRhaG9tYSBjb2xvcj0jMDAwMGZmIA0KICBzaXplPTI+PC9GT05UPjwvU1BBTj4mbmJz
cDs8L0RJVj4NCiAgPERJVj48U1BBTiBjbGFzcz03MTAwNzIyMTAtMTEwNjIwMDE+PEZPTlQgZmFj
ZT1UYWhvbWEgY29sb3I9IzAwMDBmZiANCiAgc2l6ZT0yPlVzZXItZGVmaW5lZC1mdW5jdGlvbnMn
IG5hbWVzcGFjZSBpcyB0aGF0IG9mIHRoZSBjYWxsaW5nIGJsb2NrLCBnaXZlbiANCiAgYnkgZ2xv
YmFsKCkuIFRoZSBmdW5jdGlvbiBpcyBpbiB0aGVyZSBzb21ld2hlcmUuLi5idXQgdGhhdCBkb2Vz
bid0IHNlZW0gdG8gYmUgDQogIG11Y2ggb2YgYSBoZWxwLjwvRk9OVD48L1NQQU4+PC9ESVY+DQog
IDxESVY+PFNQQU4gY2xhc3M9NzEwMDcyMjEwLTExMDYyMDAxPjxGT05UIGZhY2U9VGFob21hIGNv
bG9yPSMwMDAwZmYgDQogIHNpemU9Mj48L0ZPTlQ+PC9TUEFOPiZuYnNwOzwvRElWPg0KICA8RElW
PjxTUEFOIGNsYXNzPTcxMDA3MjIxMC0xMTA2MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0j
MDAwMGZmIA0KICBzaXplPTI+Q2xhc3NlcyBhcmUgYWx3YXlzIGZ1biAqZ3Jpbio8L0ZPTlQ+PC9T
UEFOPjwvRElWPg0KICA8RElWPjxTUEFOIGNsYXNzPTcxMDA3MjIxMC0xMTA2MjAwMT48Rk9OVCBm
YWNlPVRhaG9tYSBjb2xvcj0jMDAwMGZmIA0KICBzaXplPTI+PC9GT05UPjwvU1BBTj4mbmJzcDs8
L0RJVj4NCiAgPERJVj48U1BBTiBjbGFzcz03MTAwNzIyMTAtMTEwNjIwMDE+PEZPTlQgZmFjZT1U
YWhvbWEgY29sb3I9IzAwMDBmZiANCiAgc2l6ZT0yPkFuZHJldzwvRk9OVD48L1NQQU4+PC9ESVY+
PC9CTE9DS1FVT1RFPjwvQk9EWT48L0hUTUw+DQo=

------=_NextPart_000_0002_01C0F2A6.48A15740--



From arcege@speakeasy.net  Mon Jun 11 13:07:43 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Mon, 11 Jun 2001 08:07:43 -0400 (EDT)
Subject: [Tutor] Getting a function name from within itself
In-Reply-To: <00a601c0f25b$f513b8b0$37ef87c0@ppathiyipc> from "Praveen Pathiyil" at Jun 11, 2001 03:20:33 PM
Message-ID: <200106111207.f5BC7he11666@dsl092-074-184.bos1.dsl.speakeasy.net>

Praveen Pathiyil wrote
>         I am posting a question which is not specific to python.=20
>         Is there a way to get the name of a function from within itself =
> at runtime ? Suppose that i have a function f1. At the run time when it =
> encounters some condition ( errors or some condition which i want to let =
> the user know by printing), I want to say that this warning originated =
> from this function f1, without actually hard coding that name in the =
> print statement.
> 
> def f1(self):
>     --- do something --
>     Print "Warning ......", function_name
> 
> Can i get the function name from execution environment or something ?

You can use the traceback object from exceptions to get this information.

>>> def get_caller():
...   import sys
...   try: raise SystemError
...   except SystemError:
...     exc, val, tb = sys.exc_info()
...     # from the traceback, get the second frame back (first is get_caller)
...     caller = tb.tb_frame.f_back
...     # delete the traceback object to free memory
...     del exc, val, tb
...     return caller
...

At this point, you would get a frame for the calling function, which
contain a reference to the code, and subsequently to the name.
>>> def whatsmyline():
...   print 'function name is', get_caller().f_code.co_name
...
>>> whatsmyline()
function name is whatsmyline
>>>

This is the most common (and least obtrusive) idiom.  In Python 2.1,
there is now a new standard library module called "inspect" which does
a lot of this for you.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From hanna@chagford.com  Mon Jun 11 22:40:49 2001
From: hanna@chagford.com (Hanna Joo)
Date: Mon, 11 Jun 2001 14:40:49 -0700
Subject: [Tutor] Threads.. help /___\  (look of despair)
Message-ID: <012001c0f2bf$303aa940$0100007f@localdomain>

Hi all

I wrote a simple consumer - producer program trying to use threads (solid
emphasis on 'trying'). I have this feeling I don't know how to pass
arguments to threads and keep it synchronized.. any help will be greatly
appreaciated.

import threading
from time import sleep

def producer():

 soup = 'ABCDEFGHIJKLMNOP'
 while len(buff) != 15:
  inx = randint(1,15)
  buff.append(soup[inx])
  print soup[inx], "thrown into soup!!"
  sleep(randint(1,3))

def consumer():

 while len(buff) :
  a = buff.pop()
  print a, "eaten from soup!!"
  sleep(randint(1,3))


def main():

 print 'starting threads...'
 buff = []
 firstthread = threading.Thread(target=producer, args=(buffer))       #---->
problem area!!
 secondthread = threading.Thread(target=consumer, args=(buffer)) #---->
problem area!!

 firstthread.start()
 secondthread.start()

 firstthread.join()
 secondthread.join()

if __name__ == '__main__':
 main()


ERROR>:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "c:\python\lib\threading.py", line 376, in __bootstrap
    self.run()
  File "c:\python\lib\threading.py", line 364, in run
    apply(self.__target, self.__args, self.__kwargs)
TypeError: apply() 2nd argument must be a sequence

Exception in thread Thread-2:
Traceback (most recent call last):
  File "c:\python\lib\threading.py", line 376, in __bootstrap
    self.run()
  File "c:\python\lib\threading.py", line 364, in run
    apply(self.__target, self.__args, self.__kwargs)
TypeError: apply() 2nd argument must be a sequence

TIA

Hanna



From arcege@speakeasy.net  Mon Jun 11 14:46:10 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Mon, 11 Jun 2001 09:46:10 -0400 (EDT)
Subject: [Tutor] Threads.. help /___\  (look of despair)
In-Reply-To: <012001c0f2bf$303aa940$0100007f@localdomain> from "Hanna Joo" at Jun 11, 2001 02:40:49 PM
Message-ID: <200106111346.f5BDkAo11794@dsl092-074-184.bos1.dsl.speakeasy.net>

Hanna Joo wrote
> 
> Hi all
> 
> I wrote a simple consumer - producer program trying to use threads (solid
> emphasis on 'trying'). I have this feeling I don't know how to pass
> arguments to threads and keep it synchronized.. any help will be greatly
> appreaciated.

I see four errors here:

1.  You are not importing the randint function.  This is minor though.
  from random import randint

2.  The arguments to the threads should be a sequence (really should be
  a tuple); to make a singleton tuple, you need to add a comma:
    (1)    ==> the expression of the number 1
    (1,)   ==> a tuple containing the number 1

3.  Both functions do not allow for the argument being given.
  def producer(buff):

4.  The "buffer" in main does not exist, but "buff" does.  You should
    be consistant in the names within a function.

> import threading
> from time import sleep
  from random import randint
> 
> def producer():
  def producer(buff):
> 
>  soup = 'ABCDEFGHIJKLMNOP'
>  while len(buff) != 15:
>   inx = randint(1,15)
>   buff.append(soup[inx])
>   print soup[inx], "thrown into soup!!"
>   sleep(randint(1,3))
> 
> def consumer():
  def consumer(buff):
> 
>  while len(buff) :
>   a = buff.pop()
>   print a, "eaten from soup!!"
>   sleep(randint(1,3))
> 
> 
> def main():
> 
>  print 'starting threads...'
>  buff = []
   buffer = []
>  firstthread = threading.Thread(target=producer, args=(buffer))
   firstthread = threading.Thread(target=producer, args=(buffer,))
>  secondthread = threading.Thread(target=consumer, args=(buffer))
   secondthread = threading.Thread(target=consumer, args=(buffer,))
> 
>  firstthread.start()
>  secondthread.start()
> 
>  firstthread.join()
>  secondthread.join()
> 
> if __name__ == '__main__':
>  main()

Once I made these changes, I got a working program (but probably not
what is expected *smile*).

HTH :)
  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From dyoo@hkn.eecs.berkeley.edu  Mon Jun 11 16:53:49 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Mon, 11 Jun 2001 08:53:49 -0700 (PDT)
Subject: [Tutor] Getting a function name from within itself
In-Reply-To: <FPEHJJPEEOIPMAHOADBKGEAGCEAA.toodles@yifan.net>
Message-ID: <Pine.LNX.4.21.0106110838250.9374-100000@hkn.eecs.berkeley.edu>

On Mon, 11 Jun 2001, Andrew Wilkins wrote:

>           I am posting a question which is not specific to python. 
>           Is there a way to get the name of a function from within
> itself at runtime ? Suppose that i have a function f1. At the run time
> when it encounters some condition ( errors or some condition which i
> want to let the user know by printing), I want to say that this
> warning originated from this function f1, without actually hard coding
> that name in the print statement.


There must be a way to do this in Python, because the following:

###
>>> def f():
...     pass 
... 
>>> x = f
>>> x
<function f at 0x81728c4>
###

shows that 'x' remembers that it actually came out of function f.  So, if
anything, we can always ask for the string repr() of a function during
runtime.  After that, we can pull the name out of the string.


But this seems like a lot of work.  Michael's suggestion to use inspect
sounds like the best way to get the function's name, but I've actually
never used inspect.  Well, it's a good time to learn now!  *grin*

Let's see...

    http://python.org/doc/current/lib/inspect-types.html

sounds about right.  It appears to show that we can use
inspect.getmembers(), and then pull out the particular 'member' that
contains the name:

###
>>> import inspect
>>> inspect.getmembers(x)
[('__dict__', None), ('__doc__', None), ('__name__', 'f'),
('func_closure', None), ('func_code', <code object f at 0x8180f78, file
"<stdin>", line 1>), ('func_defaults', None), ('func_dict', None),
('func_doc', None), ('func_globals', {'__doc__': None, 'inspect': <module
'inspect' from '/usr/local/lib/python2.1/inspect.pyc'>, 'x': <function f
at 0x81728c4>, 'i': 25, 'f': <function f at 0x81728c4>,
'__builtins__': <module '__builtin__' (built-in)>,
'__name__': '__main__'}), ('func_name', 'f')]
###

Hmmm... that's a little ugly; we just want the one associated with the
func_name; that appears to be the last record:

###
>>> inspect.getmembers(x)[-1]
('func_name', 'f')
>>> inspect.getmembers(x)[-1][-1]
'f'
###

Ah!  But it's unreasonable to have to always type that to get the
name.  Let's make this into a function, so we don't have to do so much
indicing:

###
>>> def getFuncName(f): return inspect.getmembers(f)[-1][-1]
...
>>> getFuncName(x)
'f'
###


Ok, this appears to work for this case.  I wonder what happens with
functions with no name at all...

###
>>> getFuncName(lambda x: 1)  
'<lambda>'
###

I haven't fully tested this code yet, but it seems something you can play
with as well.  Hope this helps!



From bill-bell@bill-bell.hamilton.on.ca  Mon Jun 11 17:29:55 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Mon, 11 Jun 2001 12:29:55 -0400
Subject: [Tutor] RE: Getting a function name from within itself
In-Reply-To: <E159U7o-0004LR-00@mail.python.org>
Message-ID: <3B24B9C3.1554.DA3F463@localhost>

> On Mon, 11 Jun 2001, Andrew Wilkins wrote:

> I am posting a question which is not specific to python. Is there a
> way to get the name of a function from within itself at runtime ?
> Suppose that i have a function f1. At the run time when it
> encounters some condition ( errors or some condition which i want
> to let the user know by printing), I want to say that this warning
> originated from this function f1, without actually hard coding that
> name in the print statement. 

Although your question is not specific to Python solutions are, in 
general, specific to each language and sometimes to each 
language's implementation.

A recipe is available for Python on the Activestate site.

http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52315

For Perl, as another example, see Recipe 10.4 in "Perl Cookbook" 
(Christiansen and Torkington), "Determining Current Function 
Name".

Bill

Bill Bell, Software Developer


From deirdre@deirdre.net  Mon Jun 11 18:26:10 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Mon, 11 Jun 2001 10:26:10 -0700
Subject: [Tutor] Threads.. help /___\  (look of despair)
In-Reply-To: <012001c0f2bf$303aa940$0100007f@localdomain>
References: <012001c0f2bf$303aa940$0100007f@localdomain>
Message-ID: <a05100e12b74aac858e85@[10.0.1.8]>

>I wrote a simple consumer - producer program trying to use threads (solid
>emphasis on 'trying'). I have this feeling I don't know how to pass
>arguments to threads and keep it synchronized.. any help will be greatly
>appreaciated.

Synchronization between threads is one of the trickiest problems with 
the most subtle consequnces of any problem in computer science. Even 
very experienced programmers have problems with it.

But your basic synchronization problem is simply not using the 
features of threads: locking and unlocking.

My suggestion would be to learn the concepts of threading with a 
lower-level interface (i.e. import thread) and mutexes and semaphores 
THEN move to the higher level interface.

There's an excellent series of articles (applicable to python on 
Windows as much as anything) in Linux magazine that is a very good 
thread primer. I'm not sure when the article series started, but I 
have the March issue in hand.

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From allan.crooks@btinternet.com  Mon Jun 11 19:29:03 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Mon, 11 Jun 2001 19:29:03 +0100
Subject: [Tutor] Buffer's?
Message-ID: <E159WR3-0003Ut-00@gadolinium.btinternet.com>

Can anyone explain to me what the buffer function actually does? I can't find much mention about it in the Python documentation.....



From DOUGS@oceanic.com  Mon Jun 11 19:42:06 2001
From: DOUGS@oceanic.com (Doug Stanfield)
Date: Mon, 11 Jun 2001 08:42:06 -1000
Subject: [Tutor] a db question
Message-ID: <8457258D741DD411BD3D0050DA62365907A8A5@huina.oceanic.com>

[William N Carey asked:]
> I couldn't successfully load a text file which consists of a 12
> character key and a 38 character text string as the record.  The
> problem is that the file consist of  about 800,000 records.  I
> used  "anydb" which on my machine uses bsddb as the default (I
> believe).  After about 120,000 records the load would halt with
> an "error: (0, 'error')"

I have had similar experiences with the db files on Windows.  I know others
have also because there are alternatives to the standard bsddb.  I gave up
on the platform and moved to Linux where everything worked great, but if you
can't do that there may be other solutions.

> I suspect that I am asking the "db" routines to do too much, but 
> that is disappointing to me, because Python has always done 
> whatever I wanted in my limited past with it.

Don't blame it on Python! The blame lies elsewhere.  One fix might be a
different database type; I've heard good things about Gadfly and Metakit.
Check out the database page at the Vaults of Parnassus:

http://www.vex.net/parnassus/apyllo.py/973100124

HTH

-Doug-


From jarrett@engineer.com  Mon Jun 11 19:56:24 2001
From: jarrett@engineer.com (W. Jarrett Campbell)
Date: Mon, 11 Jun 2001 13:56:24 -0500
Subject: [Tutor] basic gadfly question
Message-ID: <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>

I'm new to the world of Python, Databases, and SQL but it has been a fun
adventure so far!  What a great resource this tutor mailing list is.  Thank
you all for your support of newbies!



I have basic question regarding the Gadfly package.  I'm working with the
sample database generated by the gftest.py module.  I'm trying to execute an
SQL statement such as:

INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers')

When I do this I get an error back saying that I did not define a value for
the column 'PERWEEK'

My questions are these?  Do you have to set all values in the insert
statement or is there some way around this?  Is this bad database
programming form to want to set only some fields?  Is this related to gadfly
not supporting Null values?

When using the ODBC package in the win32all distribution, I can achieve this
functionality with MS Access databases.  I wanted to stick with gadfly to
remain platform independent and not require my users to purchase Access.
Any advice?

Thanks in advance,

W. Jarrett Campbell
jarrett@engineer.com





From rha207@worldnet.att.net  Mon Jun 11 19:55:58 2001
From: rha207@worldnet.att.net (Ron)
Date: Mon, 11 Jun 2001 14:55:58 -0400
Subject: [Tutor] def problem
Message-ID: <000801c0f2a8$275e68a0$0f7c4c0c@computer>

This is a multi-part message in MIME format.

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

I'm having problems with "def". Here's what I put in and save as =
"test122"

def here():
    print "hello"
    print
    print "that was a space"

This is what I get.

>>> import test123
>>> here()
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    here()
NameError: name 'here' is not defined
>>>=20

------=_NextPart_000_0005_01C0F286.9F729540
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>I'm having problems with "def". Here's =
what I put=20
in and save as "test122"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def here():<BR>&nbsp;&nbsp;&nbsp; print =

"hello"<BR>&nbsp;&nbsp;&nbsp; print<BR>&nbsp;&nbsp;&nbsp; print "that =
was a=20
space"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This is what I get.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; import =
test123<BR>&gt;&gt;&gt;=20
here()<BR>Traceback (most recent call last):<BR>&nbsp; File =
"&lt;pyshell#1&gt;",=20
line 1, in ?<BR>&nbsp;&nbsp;&nbsp; here()<BR>NameError: name 'here' is =
not=20
defined<BR>&gt;&gt;&gt; </FONT></DIV></BODY></HTML>

------=_NextPart_000_0005_01C0F286.9F729540--



From deirdre@deirdre.net  Mon Jun 11 20:04:32 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Mon, 11 Jun 2001 12:04:32 -0700
Subject: [Tutor] basic gadfly question
In-Reply-To: <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
References: <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
Message-ID: <a05100e1cb74ac6329235@[10.0.1.8]>

At 1:56 PM -0500 6/11/01, W. Jarrett Campbell wrote:
>I have basic question regarding the Gadfly package.  I'm working with the
>sample database generated by the gftest.py module.  I'm trying to execute an
>SQL statement such as:
>
>INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers')
>
>When I do this I get an error back saying that I did not define a value for
>the column 'PERWEEK'
>
>My questions are these?  Do you have to set all values in the insert
>statement or is there some way around this?

Gadfly requires this. It is not a constraint of SQL generally.

>Is this bad database
>programming form to want to set only some fields?  Is this related to gadfly
>not supporting Null values?

No, but since it doesn't support nulls, that's a design compromise.

>When using the ODBC package in the win32all distribution, I can achieve this
>functionality with MS Access databases.  I wanted to stick with gadfly to
>remain platform independent and not require my users to purchase Access.
>Any advice?

There are also other cross-platform databases that don't require 
licenses (mysql, postgres, berkeleydb). I know nothing about their 
support on Windows but use the first two on Linux.

But none are as simple to set up as gadfly.

Gadfly is quirky, but if it suits your needs, it's great.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From kalle@gnupung.net  Mon Jun 11 20:12:43 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Mon, 11 Jun 2001 21:12:43 +0200
Subject: [Tutor] def problem
In-Reply-To: <000801c0f2a8$275e68a0$0f7c4c0c@computer>; from rha207@worldnet.att.net on Mon, Jun 11, 2001 at 02:55:58PM -0400
References: <000801c0f2a8$275e68a0$0f7c4c0c@computer>
Message-ID: <20010611211243.B5198@father>

Sez Ron:
> I'm having problems with "def". Here's what I put in and save as "test122"
> 
> def here():
>     print "hello"
>     print
>     print "that was a space"
> 
> This is what I get.
> 
> >>> import test123
> >>> here()
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in ?
>     here()
> NameError: name 'here' is not defined
> >>> 

This is not a problem with def, just a misunderstanding of import. <wink>
You have to access the names of the test123 module like:

>>> import test123
>>> test123.here()
hello

that was a space
>>> 

You could also use the "from x import y" statement:

>>> from test123 import here
>>> here()
hello

that was a space
>>> 

Peace,
  Kalle
-- 
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
 [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]


From bdupire@seatech.fau.edu  Mon Jun 11 20:15:07 2001
From: bdupire@seatech.fau.edu (Benoit Dupire)
Date: Mon, 11 Jun 2001 15:15:07 -0400
Subject: [Tutor] def problem
References: <000801c0f2a8$275e68a0$0f7c4c0c@computer>
Message-ID: <3B2518BA.9078857D@seatech.fau.edu>

--------------E3E5CA49B2922E202ECD33F7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit



Ron wrote:

> I'm having problems with "def". Here's what I put in and save as
> "test122" def here():
>     print "hello"
>     print
>     print "that was a space" This is what I get. >>> import test123
> >>> here()
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in ?
>     here()
> NameError: name 'here' is not defined
> >>>

This is because the function called here() does not exist in the current
namespace.
here() lives in the module namespace (test123)
Thus, to call the function, you must prefix it with the name of the
module.
It becomes:

test123.here()


--
Benoit Dupire


--------------E3E5CA49B2922E202ECD33F7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
&nbsp;
<p>Ron wrote:
<blockquote TYPE=CITE><style></style>
<font face="Arial"><font size=-1>I'm
having problems with "def". Here's what I put in and save as "test122"</font></font>&nbsp;<font face="Arial"><font size=-1>def
here():</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; print "hello"</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; print</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; print "that was
a space"</font></font>&nbsp;<font face="Arial"><font size=-1>This is what
I get.</font></font>&nbsp;<font face="Arial"><font size=-1>>>> import test123</font></font>
<br><font face="Arial"><font size=-1>>>> here()</font></font>
<br><font face="Arial"><font size=-1>Traceback (most recent call last):</font></font>
<br><font face="Arial"><font size=-1>&nbsp; File "&lt;pyshell#1>", line
1, in ?</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; here()</font></font>
<br><font face="Arial"><font size=-1>NameError: name 'here' is not defined</font></font>
<br><font face="Arial"><font size=-1>>>></font></font></blockquote>

<p>This is because the function called here() does not exist in the current
namespace.
<br>here() lives in the module namespace (test123)
<br>Thus, to call the function, you must prefix it with the name of the
module.
<br>It becomes:
<p>test123.here()
<br>&nbsp;
<p>--
<br>Benoit Dupire
<br>&nbsp;
</body>
</html>

--------------E3E5CA49B2922E202ECD33F7--



From pobrien@orbtech.com  Mon Jun 11 20:18:50 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Mon, 11 Jun 2001 14:18:50 -0500
Subject: [Tutor] def problem
In-Reply-To: <000801c0f2a8$275e68a0$0f7c4c0c@computer>
Message-ID: <NBBBIOJPGKJEKIECEMCBIEDKKAAA.pobrien@orbtech.com>

This is a multi-part message in MIME format.

------=_NextPart_000_001A_01C0F281.6FE2A040
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

The secret is in namespaces, which is basically a way of controlling what is
visible at any given point in time. One way to know what is visible is the
dir() function. Try running dir() after you do your import and you will see
test123 listed, but not here(). That means python can’t “see” here() without
a little more help from you. If you then try dir(test123) you will see
here() listed. So here() is part of test123. That means test123.here() will
work while here() by itself will not. Does that make sense?

Now, if you really want to be able to just type here() and have python
understand what you mean, you must import thusly:

from test123 import here

Once you get the hang of it you will come to love namespaces.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Ron
Sent: Monday, June 11, 2001 1:56 PM
To: tutor@python.org
Subject: [Tutor] def problem

I'm having problems with "def". Here's what I put in and save as "test122"

def here():
    print "hello"
    print
    print "that was a space"

This is what I get.

>>> import test123
>>> here()
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    here()
NameError: name 'here' is not defined
>>>

------=_NextPart_000_001A_01C0F281.6FE2A040
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 9">
<meta name=3DOriginator content=3D"Microsoft Word 9">
<link rel=3DFile-List href=3D"cid:filelist.xml@01C0F281.6E482A20">
<!--[if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:DoNotRelyOnCSS/>
 </o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:Zoom>0</w:Zoom>
  <w:DocumentKind>DocumentEmail</w:DocumentKind>
  <w:EnvelopeVis/>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:16792199 0 0 0 65791 0;}
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
	{margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
span.EmailStyle15
	{mso-style-type:personal-reply;
	mso-ansi-font-size:10.0pt;
	mso-ascii-font-family:Arial;
	mso-hansi-font-family:Arial;
	mso-bidi-font-family:Arial;
	color:navy;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1027"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext=3D"edit">
  <o:idmap v:ext=3D"edit" data=3D"1"/>
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=3Dwhite lang=3DEN-US style=3D'tab-interval:.5in'>

<div class=3DSection1>

<p class=3DMsoNormal><span class=3DEmailStyle15><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>Th=
e secret
is in namespaces, which is basically a way of controlling what is =
visible at
any given point in time. One way to know what is visible is the dir() =
function.
Try running dir() after you do your import and you will see test123 =
listed, but
not here(). That means python can&#8217;t &#8220;see&#8221; here() =
without a little more help
from you. If you then try dir(test123) you will see here() listed. So =
here() is
part of test123. That means test123.here() will work while here() by =
itself
will not. Does that make sense?<o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle15><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'><!=
[if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle15><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>No=
w, if
you really want to be able to just type here() and have python =
understand what
you mean, you must import thusly:<o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle15><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'><!=
[if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle15><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>fr=
om
test123 import here<o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle15><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'><!=
[if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle15><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>On=
ce you
get the hang of it you will come to love =
namespaces.<o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle15><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'><!=
[if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoAutoSig><!--[if supportFields]><span =
class=3DEmailStyle15><font=20
size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'><span =
style=3D'mso-element:field-begin'></span><span=20
style=3D"mso-spacerun: yes">&nbsp;</span>AUTOTEXTLIST \s &quot;E-mail=20
Signature&quot; <span =
style=3D'mso-element:field-separator'></span></span></font></span><![endi=
f]--><font
size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:navy'>---</span></font><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:navy;mso-color-alt:windowtext'><o:p></o:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:navy'>Patrick =
K.
O'Brien</span></font><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:navy;mso-color-a=
lt:
windowtext'><o:p></o:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:navy'>Orbtech</s=
pan></font><font
size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:navy;mso-color-alt:windowtext'><o:p></o:p>=
</span></font></p>

<p class=3DMsoAutoSig><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:navy'>&quot;I =
am, therefore
I think.&quot;</span></font><font size=3D2 color=3Dnavy =
face=3DArial><span
style=3D'font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;col=
or:navy;
mso-color-alt:windowtext'><o:p></o:p></span></font></p>

<p class=3DMsoNormal><!--[if supportFields]><span =
class=3DEmailStyle15><font=20
size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'><span =
style=3D'mso-element:field-end'></span></span></font></span><![endif]--><=
span
class=3DEmailStyle15><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><font size=3D2 color=3Dblack face=3DTahoma><span =
style=3D'font-size:
10.0pt;font-family:Tahoma;color:black'>-----Original Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> =
tutor-admin@python.org
[mailto:tutor-admin@python.org]<b><span style=3D'font-weight:bold'>On =
Behalf Of </span></b>Ron<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Monday, June 11, =
2001 1:56
PM<br>
<b><span style=3D'font-weight:bold'>To:</span></b> tutor@python.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> [Tutor] def =
problem</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dblack face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:black'>I'm having problems with =
&quot;def&quot;.
Here's what I put in and save as &quot;test122&quot;</span></font><font
color=3Dblack><span =
style=3D'color:black;mso-color-alt:windowtext'><o:p></o:p></span></font><=
/p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:black'>&nbsp;</span></font><font =
color=3Dblack><span
style=3D'color:black;mso-color-alt:windowtext'><o:p></o:p></span></font><=
/p>

<p class=3DMsoNormal><font size=3D2 color=3Dblack face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:black'>def here():<br>
&nbsp;&nbsp;&nbsp; print &quot;hello&quot;<br>
&nbsp;&nbsp;&nbsp; print<br>
&nbsp;&nbsp;&nbsp; print &quot;that was a space&quot;</span></font><font
color=3Dblack><span =
style=3D'color:black;mso-color-alt:windowtext'><o:p></o:p></span></font><=
/p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:black'>&nbsp;</span></font><font =
color=3Dblack><span
style=3D'color:black;mso-color-alt:windowtext'><o:p></o:p></span></font><=
/p>

<p class=3DMsoNormal><font size=3D2 color=3Dblack face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:black'>This is what I =
get.</span></font><font
color=3Dblack><span =
style=3D'color:black;mso-color-alt:windowtext'><o:p></o:p></span></font><=
/p>

<p class=3DMsoNormal><font size=3D3 color=3Dblack face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:black'>&nbsp;</span></font><font =
color=3Dblack><span
style=3D'color:black;mso-color-alt:windowtext'><o:p></o:p></span></font><=
/p>

<p class=3DMsoNormal><font size=3D2 color=3Dblack face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:black'>&gt;&gt;&gt; import test123<br>
&gt;&gt;&gt; here()<br>
Traceback (most recent call last):<br>
&nbsp; File &quot;&lt;pyshell#1&gt;&quot;, line 1, in ?<br>
&nbsp;&nbsp;&nbsp; here()<br>
NameError: name 'here' is not defined<br>
&gt;&gt;&gt; </span></font><font color=3Dblack><span =
style=3D'color:black;
mso-color-alt:windowtext'><o:p></o:p></span></font></p>

</div>

</body>

</html>

------=_NextPart_000_001A_01C0F281.6FE2A040--



From lumbricus@gmx.net  Mon Jun 11 20:21:38 2001
From: lumbricus@gmx.net (lumbricus@gmx.net)
Date: Mon, 11 Jun 2001 21:21:38 +0200
Subject: [Tutor] def problem
In-Reply-To: <000801c0f2a8$275e68a0$0f7c4c0c@computer>; from rha207@worldnet.att.net on Mon, Jun 11, 2001 at 02:55:58PM -0400
References: <000801c0f2a8$275e68a0$0f7c4c0c@computer>
Message-ID: <20010611212138.A15875@Laplace.localdomain>

On Mon, Jun 11, 2001 at 02:55:58PM -0400, Ron wrote:
> I'm having problems with "def". Here's what I put in and save as "test122"
> 
> def here():
>     print "hello"
>     print
>     print "that was a space"
> 
> This is what I get.
> 
> >>> import test123
> >>> here()

>>> test123.here() 

HTH J!

-- 
If you laid all of our laws end to end, there would be no end.
		-- Mark Twain


From glingl@aon.at  Mon Jun 11 20:26:05 2001
From: glingl@aon.at (Gregor Lingl)
Date: Mon, 11 Jun 2001 21:26:05 +0200
Subject: [Tutor] def problem
References: <000801c0f2a8$275e68a0$0f7c4c0c@computer>
Message-ID: <3B251B4D.20716326@aon.at>

--------------8BBF5159477132DCF7019982
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit



Ron schrieb:

> I'm having problems with "def". Here's what I put in and save as
> "test122" def here():
>     print "hello"
>     print
>     print "that was a space" This is what I get. >>> import test123
> >>> here()
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in ?
>     here()
> NameError: name 'here' is not defined
> >>>

you have to call (qualified):

>>> test123.here()
hello

that was a space
>>>

or to import this way:
>>> from test123 import *
>>> here()
hello

that was a space
>>>

Gregor

--------------8BBF5159477132DCF7019982
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
&nbsp;
<p>Ron schrieb:
<blockquote TYPE=CITE><style></style>
<font face="Arial"><font size=-1>I'm
having problems with "def". Here's what I put in and save as "test122"</font></font>&nbsp;<font face="Arial"><font size=-1>def
here():</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; print "hello"</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; print</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; print "that was
a space"</font></font>&nbsp;<font face="Arial"><font size=-1>This is what
I get.</font></font>&nbsp;<font face="Arial"><font size=-1>>>> import test123</font></font>
<br><font face="Arial"><font size=-1>>>> here()</font></font>
<br><font face="Arial"><font size=-1>Traceback (most recent call last):</font></font>
<br><font face="Arial"><font size=-1>&nbsp; File "&lt;pyshell#1>", line
1, in ?</font></font>
<br><font face="Arial"><font size=-1>&nbsp;&nbsp;&nbsp; here()</font></font>
<br><font face="Arial"><font size=-1>NameError: name 'here' is not defined</font></font>
<br><font face="Arial"><font size=-1>>>></font></font></blockquote>

<p><br><tt>you have to call (qualified):</tt><tt></tt>
<p><tt>>>> test123.here()</tt>
<br><tt>hello</tt><tt></tt>
<p><tt>that was a space</tt>
<br><tt>>>></tt><tt></tt>
<p><tt>or to import this way:</tt>
<br><tt>>>> from test123 import *</tt>
<br><tt>>>> here()</tt>
<br><tt>hello</tt><tt></tt>
<p><tt>that was a space</tt>
<br><tt>>>></tt><tt></tt>
<p><tt>Gregor</tt>
</body>
</html>

--------------8BBF5159477132DCF7019982--



From allan.crooks@btinternet.com  Mon Jun 11 20:22:54 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Mon, 11 Jun 2001 20:22:54 +0100
Subject: [Tutor] Central Python Library / Viewing __doc__ strings
Message-ID: <E159XH9-0004wq-00@protactinium>

[Denesting program]
> Ah, yes. That code sounds interesting. I wouldn't mind seeing it myself. I
> think I might have a need for something like that, actually.

You asked for it. :) It's called fringe because I had to create a similar function in Scheme for my course at university, and that's the name we had to call it. Maybe it's suitable, I don't know. :) The code is at the end of the message.

> Useless Python
> is a great spot for something like this and the Python Cookbook is as well
> (http://aspn.activestate.com/ASPN/Python/Cookbook/). I think the Python
> Cookbook is exactly what you were looking for. See what you think. In the
> mean time, I'd love a copy of the code. Thanks.

Thanks for the links, I'm off to waste an entire night looking at it. :)

Allan.

----------

def isList(obj):
   """isList(obj) -> Returns true if obj is a Python list.

      This function does not return true if the object supplied
      is a UserList object.
   """
   return type(obj)==types.ListType

def isTuple(obj):
    "isTuple(obj) -> Returns true if obj is a Python tuple."
    return type(obj)==types.TupleType

def isPySeq(obj):
    """isPySeq(obj) -> Returns true if obj is a Python list or a Python tuple.
    
       This function does not return true if the object supplied is
       a UserList object.
    """
    return isList(obj) or isTuple(obj)

def isLongString(obj):
    """isLongString(obj) -> Returns true if obj is a string of a size larger than 1.
 
       This function does not return true if the object supplied is
       a UserString object.
    """
    return type(obj)==types.StringType and len(obj)>1

# I like how the doc for this dwarfs the size of the code. :)

def fringe (seq, func=isPySeq):
   """fringe(seq [,func]) -> Denests a sequence (seq).

   A list is returned which contains all elements in the
   sequence. If the sequence contains other sequences,
   then the elements inside it are added to the list that
   is returned, as opposed to adding the nested sequence to
   the list.
   
   By default, if the sequence contains any lists or tuples,
   they are denested. Other sequence types (such as strings)
   are not. If you wish to alter the behaviour of this, then
   you must supply a function, which will be called with one
   argument (an element). The function must return a boolean
   object to indicate if the object is a sequence, and thus
   requires de-nesting.
   
   Care needs to be taken if a function is supplied that
   regards a string as a sequence. Each element in a string
   is also a string of size 1, meaning that for any function
   which returns true if the object is a non-empty string will
   recurse infinitely. If you wish to decompose strings, you
   should create a function which uses the isLongString method
   in this module.
   
   It should be noted that this method will crash if the sequence
   contains circular references to itself.
   """
   res = []
   for x in seq:
     __fringe(x, func, res)
   return res

def __fringe (obj, func, res):
   "Helper method for fringe."
   if func(obj):
      for x in obj:
         __fringe (x, func, res)
   else:
      res.append(obj)



From cynic@mail.cz  Mon Jun 11 20:37:12 2001
From: cynic@mail.cz (Cynic)
Date: Mon, 11 Jun 2001 21:37:12 +0200
Subject: [Tutor] basic gadfly question
In-Reply-To: <a05100e1cb74ac6329235@[10.0.1.8]>
References: <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
Message-ID: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>

At 21:04 11.6. 2001, Deirdre Saoirse Moen wrote the following:
-------------------------------------------------------------- 
>At 1:56 PM -0500 6/11/01, W. Jarrett Campbell wrote:
>>I have basic question regarding the Gadfly package.  I'm working with the
>>sample database generated by the gftest.py module.  I'm trying to execute an
>>SQL statement such as:
>>
>>INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers')
>>
>>When I do this I get an error back saying that I did not define a value for
>>the column 'PERWEEK'
>>
>>My questions are these?  Do you have to set all values in the insert
>>statement or is there some way around this?
>
>Gadfly requires this. It is not a constraint of SQL generally.
>
>>Is this bad database
>>programming form to want to set only some fields?  Is this related to gadfly
>>not supporting Null values?

NULL values are BAD. Learn about SQL, and you'll understand why.

>No, but since it doesn't support nulls, that's a design compromise.
>
>>When using the ODBC package in the win32all distribution, I can achieve this
>>functionality with MS Access databases.  I wanted to stick with gadfly to
>>remain platform independent and not require my users to purchase Access.
>>Any advice?
>
>There are also other cross-platform databases that don't require licenses (mysql, postgres, berkeleydb). I know nothing about their support on Windows but use the first two on Linux.

win32 MySQL is great. easy to setup -- just a regular windows installer.
also, the support is good. postgres, on the other hand, was a bitch to get
running (on windows), at least when I tried, which was almost two years ago. :)
and, the mailing lists supposedly provide less help.

>But none are as simple to set up as gadfly.

I have never heard of that, let alone use it, so I do know.

>Gadfly is quirky, but if it suits your needs, it's great.
>-- 
>_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
>"Cannot run out of time.... Is infinite time. You... are finite....
>Zathrus... is finite. This... is wrong tool!" -- Zathrus
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
------end of quote------ 


cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
    - Book of Installation chapt 3 sec 7 



From deirdre@deirdre.net  Mon Jun 11 20:45:52 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Mon, 11 Jun 2001 12:45:52 -0700
Subject: [Tutor] basic gadfly question
In-Reply-To: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>
References: <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>
Message-ID: <a05100e20b74acdb654d5@[10.0.1.8]>

At 9:37 PM +0200 6/11/01, Cynic wrote:
>  >>My questions are these?  Do you have to set all values in the insert
>>>statement or is there some way around this?
>>
>>Gadfly requires this. It is not a constraint of SQL generally.
>>
>>>Is this bad database
>>>programming form to want to set only some fields?  Is this related to gadfly
>>>not supporting Null values?
>
>NULL values are BAD. Learn about SQL, and you'll understand why.

This is *completely* untrue.

In fact, if you actually READ Codd & Date, you'll discover why 
supporting null values is a requirement for a truly relational 
database.

Why? Because sometimes there isn't a relationship between a record in 
one entity and another entity. And sometimes there is.

For example, a student relation may have a link to a faculty relation 
only if the student has an advisor. If that student doesn't have an 
advisor, that attribute SHOULD be null.

In a truly relational database, the null value would signify there 
was no relationship, which is correct.

If you don't support nulls, you'd have to create a false value to a 
false record in the other relation, which implies a relationship that 
doesn't in fact exist.

>  >But none are as simple to set up as gadfly.
>
>I have never heard of that, let alone use it, so I do know.

Gadfly is a SQL implementation written entirely in Python and can be 
found at http://www.chordate.com
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From kalle@gnupung.net  Mon Jun 11 20:53:47 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Mon, 11 Jun 2001 21:53:47 +0200
Subject: [Tutor] def problem
In-Reply-To: <3B251B4D.20716326@aon.at>; from glingl@aon.at on Mon, Jun 11, 2001 at 09:26:05PM +0200
References: <000801c0f2a8$275e68a0$0f7c4c0c@computer> <3B251B4D.20716326@aon.at>
Message-ID: <20010611215347.B5451@father>

Sez Gregor Lingl:
[snip]
> or to import this way:
> >>> from test123 import *

I would recommend against using "from x import *", use "from x import w,y,z"
instead.  "from x import *" might rebind names in the current namespace that
you do not want it to...  Sure, there are specail cases (Tkinter leaps to
mind) where there are no such problems, but better safe than sorry.

Peace,
  Kalle
-- 
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
 [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]


From cynic@mail.cz  Mon Jun 11 21:32:18 2001
From: cynic@mail.cz (Cynic)
Date: Mon, 11 Jun 2001 22:32:18 +0200
Subject: [Tutor] basic gadfly question
In-Reply-To: <a05100e20b74acdb654d5@[10.0.1.8]>
References: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>
 <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>
Message-ID: <5.1.0.14.2.20010611221822.00baf3c8@mail.cz>

>A relation is in third normal form (3NF) if and only if it is 
>in 2NF and every nonkey attribute is nontransitively dependent 
>on the primary key.

So, as you can see, NULLs actually break normalization rules.

At 21:45 11.6. 2001, Deirdre Saoirse Moen wrote the following:
-------------------------------------------------------------- 
>This is *completely* untrue.
>
>In fact, if you actually READ Codd & Date, you'll discover why supporting null values is a requirement for a truly relational database.
>
>Why? Because sometimes there isn't a relationship between a record in one entity and another entity. And sometimes there is.
>
>For example, a student relation may have a link to a faculty relation only if the student has an advisor. If that student doesn't have an advisor, that attribute SHOULD be null.
>
>In a truly relational database, the null value would signify there was no relationship, which is correct.
>
>If you don't support nulls, you'd have to create a false value to a false record in the other relation, which implies a relationship that doesn't in fact exist.
------end of quote------ 


cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
    - Book of Installation chapt 3 sec 7 



From clickron@webtv.net  Mon Jun 11 21:28:07 2001
From: clickron@webtv.net (Ron)
Date: Mon, 11 Jun 2001 16:28:07 -0400 (EDT)
Subject: [Tutor] Re: def problem (Thanks)
In-Reply-To: tutor-request@python.org's message of Mon, 11 Jun 2001
 15:19:02 -0400
Message-ID: <13511-3B2529D7-1702@storefull-166.iap.bryant.webtv.net>

Sometimes you just don't see the forest for the trees.<g>

Appreciate the help everybody. Thanks.

Ron



From deirdre@deirdre.net  Mon Jun 11 21:33:20 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Mon, 11 Jun 2001 13:33:20 -0700
Subject: [Tutor] basic gadfly question
In-Reply-To: <5.1.0.14.2.20010611221822.00baf3c8@mail.cz>
References: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>
 <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>
 <5.1.0.14.2.20010611221822.00baf3c8@mail.cz>
Message-ID: <a05100e22b74adb46824a@[10.0.1.8]>

At 10:32 PM +0200 6/11/01, Cynic wrote:
>  >A relation is in third normal form (3NF) if and only if it is
>>in 2NF and every nonkey attribute is nontransitively dependent
>>on the primary key.
>
>So, as you can see, NULLs actually break normalization rules.

No, because a null value isn't transitively dependent upon the 
primary key. Or do you not understand transitive dependencies?

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From pobrien@orbtech.com  Mon Jun 11 21:59:40 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Mon, 11 Jun 2001 15:59:40 -0500
Subject: [Tutor] Re: def problem (Thanks)
In-Reply-To: <13511-3B2529D7-1702@storefull-166.iap.bryant.webtv.net>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEDOKAAA.pobrien@orbtech.com>

And then a dozen lumberjacks come scrambling out of the woods all offering
to help you chop down your sapling, right? <wink>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Ron
Sent: Monday, June 11, 2001 3:28 PM
To: tutor@python.org
Subject: [Tutor] Re: def problem (Thanks)

Sometimes you just don't see the forest for the trees.<g>

Appreciate the help everybody. Thanks.

Ron


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From DavidCraig@PIA.CA.GOV  Mon Jun 11 22:45:55 2001
From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV)
Date: Mon, 11 Jun 2001 14:45:55 -0700
Subject: [Tutor] What am I missing??
Message-ID: <OF586BB605.A18C704C-ON88256A68.0076D0E8@PIA.CA.GOV>

I am working through the python tutorial on "How to think like a Computer
Scientist in Python".

I know its simple but I can't find why this does not work.  This is the
distance() I have written.  Below is the error message I get.

# distance function

def distance(x1, y1, x2, y2):
    dx = x2 - x1
    dy = y2 - y1
    dsquared = dx**2 + dy**2
    result = sqrt(dsquared)
    return result



Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>> import math
>>> distance(1, 2, 4, 6)
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    distance(1, 2, 4, 6)
NameError: name 'distance' is not defined

TIA for any assistance : ))

Dave




D. H. Craig, CSM




From kromag@nsacom.net  Tue Jun 12 01:04:49 2001
From: kromag@nsacom.net (kromag@nsacom.net)
Date: Mon, 11 Jun 2001 17:04:49 -0700 (PDT)
Subject: [Tutor] Threads.... More Despair....
Message-ID: <200106120004.f5C04ng07464@pop.nsacom.net>

I read of Hannah's plight with interest, as threads are kicking my backside 
as well.

The following pathetic script attempts to summon up a thread, write to a 
database and exit:

import win32com.client
import random
import time
import string
import thread

engine=win32com.client.Dispatch("DAO.DBEngine.35")
db=engine.OpenDatabase("\windows\desktop\terror.mdb")


## Function write() writes a list to the database
def write(inputtage):
	time=inputtage[0]
	data_string=inputtage[1]
	db.Execute("insert into data values(%f, '%s')" %(time, data_string))
	return 'ok'

tik_tok=time.time()
surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
the_madness=(tik_tok, surprize)
thread.start_new_thread(write(the_madness))

gets this error:

Traceback (most recent call last):
  File "dbwrite.py", line 21, in ?
    thread.start_new_thread(write(the_madness))
TypeError: start_new_thread requires at least 2 arguments; 1 given

Fair enough. I looked again at my spanking new copy of "Python Standard 
Library" and noticed that in the example 'start_new_thread(worker, ())'. In 
the example, worker() does not accept an argument. Hrm.

In the spirit of blind flailing I attempted:

thread.start_new_thread(write(the_madness),())

and got:

Traceback (most recent call last):
  File "dbwrite.py", line 21, in ?
    thread.start_new_thread(write(the_madness), ())
TypeError: first arg must be callable

for my troubles. Since I don't have a clue what is going on this was not a 
big surprize! :-)

Spawn seems so much easier! :-)

d


From kauphlyn@speakeasy.org  Mon Jun 11 23:04:52 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Mon, 11 Jun 2001 15:04:52 -0700 (PDT)
Subject: [Tutor] What am I missing??
In-Reply-To: <OF586BB605.A18C704C-ON88256A68.0076D0E8@PIA.CA.GOV>
Message-ID: <Pine.LNX.4.33L2.0106111457140.8000-100000@grace.speakeasy.net>

well from the look of your interpriter session and the name error, it doesnt
look like you defined
the distance function in the the interpriter. try this:
>> import math
>> def distance(x1,y1,x2,y2):
..	dx = x2 - x1
.. 	dy = y2 - y1
..	dsquared = dx**2 + dy**2
..	result = math.sqrt(dsquared)
.. 	return result
..
>>distance(1,2,3,4)
2.8284 etc
>>


On Mon, 11 Jun 2001, DavidCraig@PIA.CA.GOV wrote:

> I am working through the python tutorial on "How to think like a Computer
> Scientist in Python".
>
> I know its simple but I can't find why this does not work.  This is the
> distance() I have written.  Below is the error message I get.
>
> # distance function
>
> def distance(x1, y1, x2, y2):
>     dx = x2 - x1
>     dy = y2 - y1
>     dsquared = dx**2 + dy**2
>     result = sqrt(dsquared)
>     return result
>
>
>
> Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
> >>> import math
> >>> distance(1, 2, 4, 6)
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in ?
>     distance(1, 2, 4, 6)
> NameError: name 'distance' is not defined
>
> TIA for any assistance : ))
>
> Dave
>
>
>
>
> D. H. Craig, CSM
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From ak@silmarill.org  Mon Jun 11 23:08:13 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Mon, 11 Jun 2001 18:08:13 -0400
Subject: [Tutor] What am I missing??
In-Reply-To: <"from DavidCraig"@PIA.CA.GOV>
References: <OF586BB605.A18C704C-ON88256A68.0076D0E8@PIA.CA.GOV>
Message-ID: <20010611180813.A8110@sill.silmarill.org>

On Mon, Jun 11, 2001 at 02:45:55PM -0700, DavidCraig@PIA.CA.GOV wrote:
> I am working through the python tutorial on "How to think like a Computer
> Scientist in Python".
> 
> I know its simple but I can't find why this does not work.  This is the
> distance() I have written.  Below is the error message I get.
> 
> # distance function
> 
> def distance(x1, y1, x2, y2):
>     dx = x2 - x1
>     dy = y2 - y1
>     dsquared = dx**2 + dy**2
>     result = sqrt(dsquared)
>     return result

Where did you type this in? You have two choices that would both work:
first, you can type it in a file, e.g. distfile.py, then start the
interpreter, and do this:

>>> from distfile import distance
>>> import math
>>> distance(1,2,4,6)

OR

you can type the function in the interpreter, like this:

>>> def distance(x1,y1,x2,y2):
>>>  dx = x2 - x1
[...]

and then use it this time without the need to import distance.


> 
> 
> 
> Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
> >>> import math
> >>> distance(1, 2, 4, 6)
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in ?
>     distance(1, 2, 4, 6)
> NameError: name 'distance' is not defined
> 
> TIA for any assistance : ))
> 
> Dave


> 
> 
> 
> 
> D. H. Craig, CSM
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
The point of philosophy is to start with something so simple as not
to seem worth stating, and to end with something so paradoxical
that no one will believe it.


From deirdre@deirdre.net  Mon Jun 11 23:13:44 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Mon, 11 Jun 2001 15:13:44 -0700
Subject: Normal Forms was Re: [Tutor] basic gadfly question
In-Reply-To: <a05100e22b74adb46824a@[10.0.1.8]>
References: <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>
 <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <NDBBLLANIGLGFCJPIECNEEKJCCAA.jarrett@engineer.com>
 <5.1.0.14.2.20010611212548.00baf3c8@mail.cz>
 <5.1.0.14.2.20010611221822.00baf3c8@mail.cz>
 <a05100e22b74adb46824a@[10.0.1.8]>
Message-ID: <a05100e27b74add46fa6e@[10.0.1.8]>

>At 10:32 PM +0200 6/11/01, Cynic wrote:
>>  >A relation is in third normal form (3NF) if and only if it is
>>>in 2NF and every nonkey attribute is nontransitively dependent
>>>on the primary key.
>>
>>So, as you can see, NULLs actually break normalization rules.
>
>No, because a null value isn't transitively dependent upon the 
>primary key. Or do you not understand transitive dependencies?

Because this does come up:

For a schema R, where A->BC, BC->CD D->E
	(the left side is the many side, the right side is the one side)

A transitive dependency would be A->D or A->E or B->E. Because A->BC, 
therefore A->B and A->C. BC->CD, since C is the same on both sides, 
that means B->D, so, by transitivity rules, A -> B and B -> D, 
therefore A -> D.

Note that B->D and D->B, which indicates a one-to-one relationship.

In other words, it means that there's a compound join the schema, like so:

	order uniquely identifies which customer and which sales rep
	customer uniquely identifies zip code

Now let's say that this order is one relation, and that relation is:

order #, order date, customer number, customer name, customer company 
name, customer address, customer city, customer state, customer zip.

This relation would not be in 3NF because customer company name is 
dependent upon customer number and NOT on the primary key for the 
relation (order #).

The fact that the company name may or may not be a null value has 
nothing to do with being in 3NF or not.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From DavidCraig@PIA.CA.GOV  Mon Jun 11 23:16:57 2001
From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV)
Date: Mon, 11 Jun 2001 15:16:57 -0700
Subject: [Tutor] def distance
Message-ID: <OFD7D47C5D.ED261EC6-ON88256A68.007A4875@PIA.CA.GOV>

Thanks all for the help.  Daniel, that works and makes much sense.

Dave

D. H. Craig, CSM




From allan.crooks@btinternet.com  Tue Jun 12 01:04:44 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Tue, 12 Jun 2001 01:04:44 +0100
Subject: [Tutor] Threads.... More Despair....
Message-ID: <E159bhy-000I47-00@mk-smarthost-1.mail.uk.worldonline.com>

This'll be my first piece of help I've ever given anyone on this list! I'm doing my bit! :)

<snip>

> ## Function write() writes a list to the database
> def write(inputtage):
> 	time=inputtage[0]
> 	data_string=inputtage[1]
> 	db.Execute("insert into data values(%f, '%s')" %(time, data_string))
> 	return 'ok'
> 
> tik_tok=time.time()
> surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
> the_madness=(tik_tok, surprize)
> thread.start_new_thread(write(the_madness))
> 
> gets this error:
> 
> Traceback (most recent call last):
>   File "dbwrite.py", line 21, in ?
>     thread.start_new_thread(write(the_madness))
> TypeError: start_new_thread requires at least 2 arguments; 1 given
> 
> Fair enough. I looked again at my spanking new copy of "Python Standard 
> Library" and noticed that in the example 'start_new_thread(worker, ())'. In 
> the example, worker() does not accept an argument. Hrm.
> 
> In the spirit of blind flailing I attempted:
> 
> thread.start_new_thread(write(the_madness),())
> 
> and got:
> 
> Traceback (most recent call last):
>   File "dbwrite.py", line 21, in ?
>     thread.start_new_thread(write(the_madness), ())
> TypeError: first arg must be callable
> 
> for my troubles. Since I don't have a clue what is going on this was not a 
> big surprize! :-)

The problem is the slight misunderstanding of what happens when you put:

thread.start_new_thread(write(the_madness),())

What you mean to say is:

thread.start_new_thread(write, (the_madness,)).

The whole point of creating a new thread is to invoke some function. The function may, or may not need arguments.

To create a new thread, you need to supply the function you want to run, and any supplementary arguments.

The function is obviously "write", and the only argument you are supplying is "the_madness". But when you put write(the_madness), the function is actually being executed, and then returns a value (looking at the code, it's the string 'ok'). So:

thread.start_new_thread(write(the_madness),())

is evaluated to:

thread.start_new_thread('ok', ())

and then the thread module complains because it is unable to run the function 'ok' (which is a string, not a function of any sort).

So, once again, the corrected line is:
thread.start_new_thread(write, (the_madness,))

Don't forget that because it's a tuple of one element, it has to have the comma after the first element.

I would try this code out, but I don't have a database to test it on, and in all honesty, I can't be bothered. Hope it works though. :)

Allan.



From bill-bell@bill-bell.hamilton.on.ca  Tue Jun 12 01:39:39 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Mon, 11 Jun 2001 20:39:39 -0400
Subject: [Tutor] Re: What am I missing??
In-Reply-To: <E159Zto-0008DS-00@mail.python.org>
Message-ID: <3B252C8B.2536.F64624F@localhost>

DavidCraig@PIA.CA.GOV	wrote, in part:
> I am working through the python tutorial on "How to think like a
> Computer Scientist in Python".
> 
> I know its simple but I can't find why this does not work.  This is
> the distance() I have written.  Below is the error message I get.
> 
> # distance function
> 
> def distance(x1, y1, x2, y2):
>     dx = x2 - x1
>     dy = y2 - y1
>     dsquared = dx**2 + dy**2
>     result = sqrt(dsquared)
>     return result
>   <SNIP>
>     distance(1, 2, 4, 6)
> NameError: name 'distance' is not defined

I'd expect the lines showing your definition of the the function to 
appear more like the following.

>>> def distance(x1, y1, x2, y2):
... 	dx=x2-x1 	
... 	dy=y2-y1 	
... 	dsquared=dx**2+dy**2
... 	result=math.sqrt(dsquared) 	
... 	return result
... 

Note the little dots that appear at the beginning of eachof the lines 
other than the first. The fact that it doesn't suggests that you 
haven't entered the lines of code one at a time so that the Python 
interpreter can handle indentation properly. In any case, if you 
enter the 'def' line, press 'Enter' then enter the next line and press 
'Enter' and so on then the interpreter will cope and your definition 
should work--almost (see below).

When you enter your invokation line you should see a result like 
the following.

>>> distance(1,2,4,6)
5.0

The other thing I notice (because I tripped over it myself) is that you 
use an unadorned 'import' statement to gain access to the sqrt 
function. As a consequence you will need to refer to it as math.sqrt 
(as shown in my code), rather than just sqrt.

HTH (as people say).

Bill

Bill Bell, Software Developer


From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 02:25:28 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Mon, 11 Jun 2001 18:25:28 -0700 (PDT)
Subject: [Tutor] Threads.... More Despair....
In-Reply-To: <200106120004.f5C04ng07464@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106111802470.19117-100000@hkn.eecs.berkeley.edu>

On Mon, 11 Jun 2001 kromag@nsacom.net wrote:

> The following pathetic script attempts to summon up a thread, write to
> a database and exit:

Ok, let's take a look.


> import win32com.client
> import random
> import time
> import string
> import thread
> 
> engine=win32com.client.Dispatch("DAO.DBEngine.35")
> db=engine.OpenDatabase("\windows\desktop\terror.mdb")
> 
> 
> ## Function write() writes a list to the database
> def write(inputtage):
> 	time=inputtage[0]
> 	data_string=inputtage[1]
> 	db.Execute("insert into data values(%f, '%s')" %(time, data_string))
> 	return 'ok'
> 
> tik_tok=time.time()
> surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
> the_madness=(tik_tok, surprize)

Looks ok so far.


> thread.start_new_thread(write(the_madness))

There's a small problem here; the problem is that the 'write(the_madness)'
part of this line is getting called too quickly.  What I mean is that, for
every command that is made of compound pieces, Python will execute the
inner stuff first, and then pass the results off to the outer
'thread.start_new_thread( results of "write(the_madness)" )' stuff.  The
result is that thread.start_new_thread is only getting one thing, and that
thing isn't something it can work with.  This explains the error:


> Traceback (most recent call last):
>   File "dbwrite.py", line 21, in ?
>     thread.start_new_thread(write(the_madness))
> TypeError: start_new_thread requires at least 2 arguments; 1 given

The quickest way to fix this is the following line:

    thread.start_new_thread(write, (the_madness,))

which tells Python "Ok, we want to start a new thread.  When it starts up,
it should execute 'write', with 'the_madness' as it's first
argument."  The really tricky part is the last part:

    (the_madness,)

because if we don't have that comma, Python won't be able to figure out
that 'the_madness' should fit into inputtage.


> Fair enough. I looked again at my spanking new copy of "Python
> Standard Library" and noticed that in the example
> 'start_new_thread(worker, ())'. In the example, worker() does not
> accept an argument. Hrm.

Yes, in that particular case, worker doesn't take any arguments, so the
second thing we give start_new_thread turns out to be an empty tuple.  
But in your case, you need to send off your write() function the_madness
as the first (and only) argument.


With this in mind, the documentation on thread.start_new_thread() might
make more sense now:

"""
start_new_thread (function, args[, kwargs])

Start a new thread. The thread executes the function function with the
argument list args (which must be a tuple)...
"""


> for my troubles. Since I don't have a clue what is going on this was
> not a big surprize! :-)

You're getting closer.  *grin*



For reference, here's another example of a threaded program:

###
import thread
import time

def fallingBridge(name, delay):
    print "The", name, "bridge is falling down..."
    time.sleep(delay)
    print "The", name, "bridge fell down!"


if __name__ == '__main__':
    bridges = ['london', 'san mateo', 'golden gate']
    delays = [1, 2, 3]
    for b, d in zip(bridges, delays):
        thread.start_new_thread(fallingBridge, (b, d))
    print "All done!"
###

And here it is in action:

###
All done!
>>> The golden gate bridge is falling down...
The san mateo bridge is falling down...
The london bridge is falling down...
The london bridge fell down!
The san mateo bridge fell down!
The golden gate bridge fell down!
###

Hmmm... I knew I forgot to tell my main thread to wait until all my
threads were done.  It's saying "All done!" a bit too quickly, and that's
what motivates the need for more control over our threads.  The
'threading' module allows us to do this to our Threads with join(), but
that's for another message.  *grin*

Good luck!



From kojo@hal-pc.org  Tue Jun 12 02:51:23 2001
From: kojo@hal-pc.org (Kojo Idrissa)
Date: Mon, 11 Jun 2001 20:51:23 -0500
Subject: [Tutor] time.strptime in Active State Python 2.1
Message-ID: <5.0.2.1.0.20010611204629.02055c78@Pop3.norton.antivirus>

I'm trying to use that attribute of the time module, but I"m being told 
that the attribute DNE.  According to page 172 of David Beazley's 'Python 
Essential Ref', it does exist.

Is this a change from 1.5.2 (which the book is based on) to 2.1?  Below are 
the screens from my interactive prompt.

Thanks,

PythonWin 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see 
'Help/About PythonWin' for further copyright information.
<snip>
 >>> time.strptime('06/11/01 20:27:24',[])
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
AttributeError: 'time' module has no attribute 'strptime'

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************



From allan.crooks@btinternet.com  Tue Jun 12 02:58:10 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Tue, 12 Jun 2001 02:58:10 +0100
Subject: [Tutor] time.strptime in Active State Python 2.1
Message-ID: <E159dWE-0000O9-00@gadolinium.btinternet.com>

> PythonWin 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32.
> Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see 
> 'Help/About PythonWin' for further copyright information.
> <snip>
>  >>> time.strptime('06/11/01 20:27:24',[])
> Traceback (most recent call last):
>    File "<interactive input>", line 1, in ?
> AttributeError: 'time' module has no attribute 'strptime'

You're trying to access the wrong function, I believe.

>>> import time
>>> dir(time)
['__doc__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', 'ctime',
'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'time', 'timez
one', 'tzname']
>>> time.strftime
<built-in function strftime>
>>>

It's STRFTIME, if that's not clear. :)

Allan.



From kojo@hal-pc.org  Tue Jun 12 03:07:08 2001
From: kojo@hal-pc.org (Kojo Idrissa)
Date: Mon, 11 Jun 2001 21:07:08 -0500
Subject: [Tutor] time.strptime in Active State Python 2.1
In-Reply-To: <E159dWE-0000O9-00@gadolinium.btinternet.com>
Message-ID: <5.0.2.1.0.20010611210433.0205fe98@Pop3.norton.antivirus>

I know about the STRFTIME function, but according to Python Ess. Ref, 
there's also a STRPTIME function.  Maybe it was in 1.5.2 and it's gone in 2.1.

If that's the case, how do I go about taking a string representinig a 
certain time and turn it into a tuple  of the same form as returned by 
LOCALTIME?

Thanks,

At 02:58 AM 6/12/2001 +0100, you wrote:
> > PythonWin 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32.
> > Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see
> > 'Help/About PythonWin' for further copyright information.
> > <snip>
> >  >>> time.strptime('06/11/01 20:27:24',[])
> > Traceback (most recent call last):
> >    File "<interactive input>", line 1, in ?
> > AttributeError: 'time' module has no attribute 'strptime'
>
>You're trying to access the wrong function, I believe.
>
> >>> import time
> >>> dir(time)
>['__doc__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', 
>'ctime',
>'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'time', 
>'timez
>one', 'tzname']
> >>> time.strftime
><built-in function strftime>
> >>>
>
>It's STRFTIME, if that's not clear. :)
>
>Allan.

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************



From allan.crooks@btinternet.com  Tue Jun 12 03:21:28 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Tue, 12 Jun 2001 03:21:28 +0100
Subject: [Tutor] time.strptime in Active State Python 2.1
Message-ID: <E159dsl-0003ND-00@tungsten.btinternet.com>

> I know about the STRFTIME function, but according to Python Ess. Ref, 
> there's also a STRPTIME function.  Maybe it was in 1.5.2 and it's gone in 2.1.

Sorry, I actually bothered to look at the time documentation in this time. :)

It's very rare that they would remove a function from a module.

The good news is strptime still exists. The bad news is, it's only available on "most Unix systems".

Take a look for yourself at: http://www.python.org/doc/current/lib/module-time.html

> If that's the case, how do I go about taking a string representinig a 
> certain time and turn it into a tuple  of the same form as returned by 
> LOCALTIME?

Ahh. Well, it's not provided in standard python, so you have to use modules elsewhere.

I've had a look for you, and this one might be of use:

http://www.fukt.hk-r.se/~flognat/hacks/strptime.py

HTH,
Allan.



From allan.crooks@btinternet.com  Tue Jun 12 05:22:43 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Tue, 12 Jun 2001 05:22:43 +0100
Subject: [Tutor] Uncallable class methods?
Message-ID: <E159fm3-0006Oy-00@gadolinium.btinternet.com>

Hi,

Quick question about the following piece of code:

>>> class X:
..   def y():
..     print 'I am y of x.'

Is there anyway that y can be invoked? My understanding is no, in which case, can anyone tell me why the interpreter doesn't complain about a class method being declared which does not have the minimum of one argument?

Of course, considering the wealth of replies I received about my query about buffers, maybe I'm asking in the wrong place. :)

Allan.



From pobrien@orbtech.com  Tue Jun 12 06:01:04 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Tue, 12 Jun 2001 00:01:04 -0500
Subject: [Tutor] Uncallable class methods?
In-Reply-To: <E159fm3-0006Oy-00@gadolinium.btinternet.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBKEEIKAAA.pobrien@orbtech.com>

Hmmm. Very interesting question. You would think that something would
complain sooner. Here is what I got:

>>> class x:
	def y():
		print 'Yo'


>>> dir(x)
['__doc__', '__module__', 'y']
>>> x.y
<unbound method x.y>
>>> x.y()
Traceback (most recent call last):
  File "<pyshell#26>", line 1, in ?
    x.y()
TypeError: unbound method y() must be called with instance as first argument
>>> z = x()
>>> z
<__main__.x instance at 016BDC1C>
>>> z.y()
Traceback (most recent call last):
  File "<pyshell#31>", line 1, in ?
    z.y()
TypeError: y() takes no arguments (1 given)
>>>

Kind of a funny catch-22 going on. For the total newbies, def y() should
have been declared as def y(self), of which Allan is well aware. The point
is why does python let us mess up so badly in the first place? And I do not
know the answer to that question.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Allan Crooks
Sent: Monday, June 11, 2001 11:23 PM
To: tutor@python.org
Subject: [Tutor] Uncallable class methods?

Hi,

Quick question about the following piece of code:

>>> class X:
..   def y():
..     print 'I am y of x.'

Is there anyway that y can be invoked? My understanding is no, in which
case, can anyone tell me why the interpreter doesn't complain about a class
method being declared which does not have the minimum of one argument?

Of course, considering the wealth of replies I received about my query about
buffers, maybe I'm asking in the wrong place. :)

Allan.


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 06:13:04 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Mon, 11 Jun 2001 22:13:04 -0700 (PDT)
Subject: [Tutor] Buffer's?
In-Reply-To: <E159WR3-0003Ut-00@gadolinium.btinternet.com>
Message-ID: <Pine.LNX.4.21.0106111359590.14337-100000@hkn.eecs.berkeley.edu>

On Mon, 11 Jun 2001, Allan Crooks wrote:

> Can anyone explain to me what the buffer function actually does? I
> can't find much mention about it in the Python documentation.....

Hmmm!  I've never encountered the buffer function before!  Let's take a
look...


###
>>> buffer
<built-in function buffer>
>>> print buffer.__doc__
buffer(object [, offset[, size]) -> object

Creates a new buffer object which references the given object.
The buffer will reference a slice of the target object from the
start of the object (or at the specified offset). The slice will
extend to the end of the target object (or with the specified size).
###


Don't worry if this doesn't make sense to you; it's gibberish to me too...
*grin* I wonder why such a function would be useful?  There's a reference
to a thread on the main Python list that talks about buffer() here:

    http://mail.python.org/pipermail/python-list/1999-October/013886.html

>From reading this, it sounds like buffer is meant to make it easy to pass
in huge slices of information back and forth between functions.  Wait,
wait!  I see now!


Buffers allow us to take "slices" of our lists.  Unlike normal slices
though, these buffers don't make a copy of the original list.  To see why
buffers are useful, let's show that regular Python slices are actually
copies of an original list:

###
>>> mylist = range(5)
>>> mylist
[0, 1, 2, 3, 4]
>>> myslice = mylist[-2:]
>>> myslice
[3, 4]
>>> myslice[0] = 'three'
>>> myslice
['three', 4]
>>> mylist
[0, 1, 2, 3, 4]
###

So that's how slices work, by copying the section we're interested in as a
whole new list.

Normally, this copying behavior is a good thing, because it lets us fiddle
around with small pieces of a list without having disturbed the main list.  
However, it's a nightmare if we need to work with huge slices, since
copying can be expensive.  Buffers, then, act like slices: the only
difference is that they shouldn't copy the original list.

It's a little hard for me to show practical examples using buffers,
because, frankly, I've haven't worked with them yet.  *grin* Also, the
documentation on them seems really sparse --- I suspect that it's not
quite popular yet, since Python lists apparently doesn't support the
buffer interface yet.  Still, you might want to ask on comp.lang.python
and see if anyone is using it.


There's another reference to Buffer object in the Python/C API here:

    http://python.org/doc/current/api/bufferObjects.html

which suggests that buffer() is a sort of function that one shouldn't
touch unless you're a real efficiency enthusiast.


Sorry about the incomplete information!



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 06:27:55 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Mon, 11 Jun 2001 22:27:55 -0700 (PDT)
Subject: [Tutor] Uncallable class methods?
In-Reply-To: <NBBBIOJPGKJEKIECEMCBKEEIKAAA.pobrien@orbtech.com>
Message-ID: <Pine.LNX.4.21.0106112213210.22112-100000@hkn.eecs.berkeley.edu>

On Tue, 12 Jun 2001, Patrick K. O'Brien wrote:

> Hmmm. Very interesting question. You would think that something would
> complain sooner. Here is what I got:

I suspect it has to do with the way Python does things dynamically.  For
example, typing out the following:

###
def test1():
   foobar
###

doesn't break, at least as long as we don't actually call test1().  But
when we actually do call test1(), that's when Python looks inside and sees
that 'foobar' hasn't been defined.

Likewise, when we're defining a class's members, like the example:

> >>> class x:
> 	def y():
> 		print 'Yo'


Python doesn't call y() yet, and so it doesn't detect the error about the
missing "self" argument.

As a wild guess, I think Python does it this way to reduce the number of
rules it needs to check as it reads our definitions.  When we're defining
"members" of a class, we're using the framework for defining regular
functions, with the small rule that the first argument will magically get
filled in with an instance... but the procedure that reads def's doesn't
really need to know about the special role of 'self'.

I believe that the PyChecker utility here:

    http://pychecker.sourceforge.net

does check for the kind of bugs like this.


> Kind of a funny catch-22 going on. For the total newbies, def y() should
> have been declared as def y(self), of which Allan is well aware. The point
> is why does python let us mess up so badly in the first place? And I do not
> know the answer to that question.

It's probably to make the Python implementors lives a little easier: they
can reuse the same kind of definition-reading code without having to
special-case it for class definitions.  The consequence, unfortunately, is
that it isn't quite as helpful as we'd like it; the parser isn't context
senstive.

But perhaps this can be fixed!  You might want to raise this question to
them; this definitely sounds like the sort of thing that catches people
off guard.


> Of course, considering the wealth of replies I received about my query about
> buffers, maybe I'm asking in the wrong place. :)

*head in shame*



From kojo@hal-pc.org  Tue Jun 12 06:42:17 2001
From: kojo@hal-pc.org (Kojo Idrissa)
Date: Tue, 12 Jun 2001 00:42:17 -0500
Subject: [Tutor] time.strptime in Active State Python 2.1
In-Reply-To: <E159dsl-0003ND-00@tungsten.btinternet.com>
Message-ID: <5.0.2.1.0.20010612004110.00ae7328@Pop3.norton.antivirus>

Thanks Allan, this looks like just what I was looking for.  I'll bring this 
module over to my Win2K partition and add it to my list of "Reasons to use 
Linux more".

:-)


At 03:21 AM 6/12/2001 +0100, you wrote:
> > I know about the STRFTIME function, but according to Python Ess. Ref,
> > there's also a STRPTIME function.  Maybe it was in 1.5.2 and it's gone 
> in 2.1.
>
>Sorry, I actually bothered to look at the time documentation in this time. :)
>
>It's very rare that they would remove a function from a module.
>
>The good news is strptime still exists. The bad news is, it's only 
>available on "most Unix systems".
>
>Take a look for yourself at: 
>http://www.python.org/doc/current/lib/module-time.html
>
> > If that's the case, how do I go about taking a string representinig a
> > certain time and turn it into a tuple  of the same form as returned by
> > LOCALTIME?
>
>Ahh. Well, it's not provided in standard python, so you have to use 
>modules elsewhere.
>
>I've had a look for you, and this one might be of use:
>
>http://www.fukt.hk-r.se/~flognat/hacks/strptime.py
>
>HTH,
>Allan.
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************



From pobrien@orbtech.com  Tue Jun 12 06:47:05 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Tue, 12 Jun 2001 00:47:05 -0500
Subject: [Tutor] SubDictionaries or am I reinventing a wheel?
Message-ID: <NBBBIOJPGKJEKIECEMCBAEEKKAAA.pobrien@orbtech.com>

Imagine that you have a dictionary with a multipart key and you want to
extract a new dictionary that is a subset of the existing dictionary based
on matching a few of the leading elements that make up the key. For example,
GoldMine stores multiple record types in some of its database files. So I
have a dictionary with the table name and record type code as the key.

gmRecordTypes = {  # Table, Type, Description
    ('CAL', 'A'): 'Appointment',
    ('CAL', 'C'): 'Call back',
    ('CAL', 'D'): 'To-do',
    ('CAL', 'E'): 'Event',
    ('CAL', 'F'): 'Literature fulfillment',
    ('CAL', 'M'): 'Message',
    ('CAL', 'O'): 'Other',
    ('CAL', 'Q'): 'Queued e-mail',
    ('CAL', 'S'): 'Sales potential',
    ('CAL', 'T'): 'Next action',
    ('CONTHIST', 'A'): 'Appointment',
    ('CONTHIST', 'C'): 'Phone call',
    ('CONTHIST', 'D'): 'To-do',
    ('CONTHIST', 'E'): 'Event',
    ('CONTHIST', 'F'): 'Literature fulfillment',
    ('CONTHIST', 'L'): 'Form',
    ('CONTHIST', 'M'): 'Sent message',
    ('CONTHIST', 'O'): 'Other',
    ('CONTHIST', 'S'): 'Sale',
    ('CONTHIST', 'T'): 'Next action',
<snip>
    }

Now let's say I wanted a function that would return a new dictionary of just
the record types and descriptions for the CONTHIST table. Think of this as
sort of a query against a database table - select type, description from
gmRecordTypes where table = 'CONTHIST'. Imagine that you had lots of
dictionaries like this and that you wanted the function to be able to select
based on one matching element or several matching elements of the key. Well,
I did and here is what I came up with.

# partmatch can be a single value or any valid sequence for a dictionary key
or portion thereof.

def subDictionary(dictionary, partmatch=None):
    """Return a subset of a dictionary based on a partial key match."""
    if partmatch == None:
        return dictionary
    else:
        subd = {}
        partsize = len(partmatch)
        if partsize == 1:  # Reduce single element sequences to single
elements.
            partmatch = partmatch[0]
        for key in dictionary.keys():
            if partsize == 1:  # Reduce single element sequences to single
elements.
                keypart = key[0]
            else:
                keypart = key[:partsize]
            if keypart == partmatch:
                if len(key[partsize:]) == 1:  # Simplify the new key by
reducing it to a single object if possible.
                    newkey = key[partsize]
                else:
                    newkey = key[partsize:]
                subd[newkey] = dictionary[key]
        return subd

Now, I either came up with something nifty that will be useful to me and
maybe others, or I just spent a good couple of hours reinventing the wheel.
Does anyone know of any Python module that does this already? Is this a good
approach to the problem I described, or am I off my rocker? Somehow this
sort of manipulation seems like it should be part of the core of python in
the way that keys() and values() are already there.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."




From jacqueline_juselius@yahoo.com  Tue Jun 12 07:16:46 2001
From: jacqueline_juselius@yahoo.com (jacqueline juselius)
Date: Mon, 11 Jun 2001 23:16:46 -0700 (PDT)
Subject: [Tutor] reading sequence codes in from a file
Message-ID: <20010612061646.78540.qmail@web14310.mail.yahoo.com>

Hi folks,

I have a config file which contain list of sequence
code pairs.

eg. ruleFile

rule1,\272,\377
rule2,\280,\375

I read these lines in with :

  lines = open(ruleFile).readlines()
and split the line and store the last two columns into
a list, creating a translation list of before and
after values.

 
I then read another file text file and see if I can
find any of these special characters that's in the
first column and translate them to what ever is in the
second column.

My problem is that when I read the rule File I don't
get an escape sequence but a string.

eg.

in python I can say 

a = "\272"  
print a

and I will get a funny character (a's length = 1)

but when I read the line from a file I get double
slashes  "//272",  its length being 4 instead of one. 
ie. python has taken it as a string.

My thought was that I could parse out "272" and then
someohow translate it to "/272" with a length of 1.

Does anyone know how to do this or how to read an
escape sequence in from a file and have it treated as
an escape sequence and not a string?

I tried the chr() function but that only handles the
256 ascii chars.


Thanks,

Jacqueline



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/


From alan.gauld@freenet.co.uk  Tue Jun 12 08:17:56 2001
From: alan.gauld@freenet.co.uk (Alan Gauld)
Date: Tue, 12 Jun 2001 07:17:56 +0000
Subject: [Tutor] New Web tutor version
Message-ID: <3.0.1.32.20010612071756.013a999c@mail.freenet.co.uk>

Hi gang,

I'm happy to announce a new translation of my 
Web tutor in the Czech language. This is a very 
professional translation and has revamped the 
look of the site too. 

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

OR to see the home site, where they are using Python in anger:
------------------
The Czech version of your book is displayed on our Czech 
web site, on 

http://www.datapartner.cz 

please go to "Poradna" (something like Guidance) and there 
on "Jak se naucit programovat" (the name of your book in 
Czech language.)
------------------

Unfortunately the changes mean it only works in 
Internet Explorer - I've asked them to fix the 
problems...

While I was at it the downloadable version in all 
languages is now in tar/gzip format since that is 
readable in winzip etc as well as Linux.

Enjoy,

Alan G



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 09:02:38 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 12 Jun 2001 01:02:38 -0700 (PDT)
Subject: [Tutor] reading sequence codes in from a file
In-Reply-To: <20010612061646.78540.qmail@web14310.mail.yahoo.com>
Message-ID: <Pine.LNX.4.21.0106120046490.23545-100000@hkn.eecs.berkeley.edu>

On Mon, 11 Jun 2001, jacqueline juselius wrote:

> but when I read the line from a file I get double
> slashes  "//272",  its length being 4 instead of one. 
> ie. python has taken it as a string.
> 
> My thought was that I could parse out "272" and then
> someohow translate it to "/272" with a length of 1.

This is perfectly possible.  (For this message, I'm assuming that you're
using Python 1.52; things will look slightly different in Python 2.1,
although the ideas are the same.)


> Does anyone know how to do this or how to read an
> escape sequence in from a file and have it treated as
> an escape sequence and not a string?
>
> I tried the chr() function but that only handles the
> 256 ascii chars.

The only problem is that when you're writing '\272', you're actually
writing a number in base-8 "octal".  That is, '\272' doesn't stand for the
number 272, but for:

   2 * (8**2)  = 128
 + 7 * (8**1)  =  56
 + 2 * (8**0)  =   2
-------------  --------
                 186

which is why you're getting that error message with chr(): it's way out of
its comfortable domain, and doesn't know what to do with a character code
larger than 256.

If you have eight fingers, base-8 this will make sense.  However, if
you're not octafingered, then we can use Python to do this converting work
for us:

###
>>> int('272', 8)
186
###

which, thankfully, is the same as the manual calculation we did above.  
The int() function can take in an optional 'base' as its second number: we
just need to tell Python to compensate for 8-fingeredness, and it can do
it.

Applying chr() on this number should work much more nicely:

###
>>> chr(186)
'\272'
###

Whew!  Anyway, I think I wandered a bit, so please ask questions, and
we'll try to clarify things.

Good luck!



From lonetwin@yahoo.com  Tue Jun 12 10:22:43 2001
From: lonetwin@yahoo.com (steve)
Date: Tue, 12 Jun 2001 14:52:43 +0530
Subject: [Tutor] Uncallable class methods?
In-Reply-To: <E159fm3-0006Oy-00@gadolinium.btinternet.com>
References: <E159fm3-0006Oy-00@gadolinium.btinternet.com>
Message-ID: <01061214524307.11131@mercury.in.cqsl.com>

Hi all,
 This here is a nice question vvvvvvvvv

> Quick question about the following piece of code:
> >>> class X:
>
> ..   def y():
> ..     print 'I am y of x.'
>
> Is there anyway that y can be invoked? My understanding is no, in which
> case, can anyone tell me why the interpreter doesn't complain about a c=
lass
> method being declared which does not have the minimum of one argument?


 Well, here's how I see it as...I think it's a pretty good thing that pyt=
hon=20
complains when U try to use an "unbound" function, but does not when u de=
fine=20
it .....'cos by doing that I can ensure that these functions are to be us=
ed=20
"only" within the class itself.....kinda like a "private" function....if =
u=20
really do require to use something that u defined for the class but did n=
ot=20
mean an object of the class to use it, well define it outside the class a=
nd=20
make it available to the class by importing it.....else make it a "valid"=
=20
function of the class.

Like I said ealier....just my thoughts....I've never come across the need=
 to=20
use an "unbound" funtion outside a class....but then again, I haven't yet=
=20
solved all the world's problems too.

Peace
Steve
--=20
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||=09
|||/\##|||||||||##/\||=09
|/    \#########/    \=09
|\     \#######/     /=09
||\____/#######\____/|=09
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=09
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


From a.dijkstra03@kpn.com  Tue Jun 12 10:22:36 2001
From: a.dijkstra03@kpn.com (a.dijkstra03@kpn.com)
Date: Tue, 12 Jun 2001 11:22:36 +0200
Subject: [Tutor] newbie help..image in toplevelwindow?
Message-ID: <B1B813073C91D311BC3E0000F8FA5DA5D76CE2@tontw001v3>

Hi there,

This is one of my first attempts building a application with Tkinter.
Could anyone explain to me what i'm doing wrong? I'm trying to insert a
image in the toplevel window. I'm using win NT and python2.1.

Thanks in advance

regards Arjen



from Tkinter import *
from whrandom import choice
from string import upper
from re import sub


kleur=['red', 'yellow', 'brown', 'green', 'purple', 'black', 'orange',
'white',
       'blue']
alist=[]
klos='.....\n moet koffie halen!!!'
best=open('koffielijst', 'r')
x=best.readlines()
for item in x:
    a=sub('\n', '', item)
    alist.append(a)
best.close()

def kiezen():
    kl=choice(kleur)
    klos=upper(choice(alist)) + '\n moet koffie halen!!!'
    label.configure(text=klos, fg=kl)

def nieuw():
    invoer=entry.get()
    if invoer != '':
        alist.append(invoer)
        toev=open('koffielijst', 'a')
        toev.write(invoer + '\n')
        toev.close()
        lijst.insert(END, invoer)
        entry.delete(0, END)
    return alist

def opslaan():
    opsl=open('koffielijst', 'w')
    for item in alist:
        opsl.write(item + '\n')
    opsl.close()
    
        
def deleteButtonClick():
    indicies = lijst.curselection()
    indicies = [int(index) for index in indicies]   # Cast indicies to ints
    indicies.sort()
    indicies.reverse()
    for index in indicies:
        lijst.delete(index)
        alist.pop(index)
    opslaan()
    return alist


def newwin():
    wat=Toplevel()
    fr=Frame(wat)
    t=Label(fr, text='Versie 1.0', fg='red', bg='white')
    t.pack(pady=10)
    filename='PythonPoweredSmall.gif'
    img = PhotoImage(file=filename)
    hm = Label(fr, image=img)
    hm.pack()
    wat.title('info')
    fr.pack()
        

top=Tk()
label=Label(top, text=klos, font='Times 30 bold', fg='black')
label.pack()

menubar = Menu(top)
filemenu=Menu(menubar, tearoff=0)
filemenu.add_command(label="?????", command=newwin)
top.config(menu=menubar)
menubar.add_cascade(label="informatie", menu=filemenu)

frame=Frame(top, bd=20, relief=SUNKEN)
frame.pack(side=LEFT)
entry=Entry(frame, width=23)
entry.pack()
frame1=Frame(frame)
frame1.pack(fill=X)

knop=Button(frame1, text='toevoegen', command=nieuw)
knop.pack(side=LEFT)

deleteButton = Button(frame1, text='verwijderen', command=deleteButtonClick)
deleteButton.pack(fill=X)

scrollbar=Scrollbar(frame)
scrollbar.pack(side=RIGHT, fill=Y)
lijst=Listbox(frame, height=5, width=20, yscrollcommand=scrollbar.set)
for item in alist:
    lijst.insert(END, item)
lijst.pack(side=BOTTOM)

scrollbar.config(command=lijst.yview)


Kies=Button(top, text='kiezen', font='Times 15', command=kiezen)
##Kies.bind('<Key-Return>')
Kies.pack(fill=X)


quit=Button(top, text='afsluiten', font='Times 15', command=top.quit)
quit.pack(fill=X)


#filename='PythonPowered.gif'
#img = PhotoImage(file=filename)
#hm=Label(top, image=img)
#hm.pack(pady=30)

filename1='koffie.gif'
img1 = PhotoImage(file=filename1)
hm1=Label(top, image=img1)
hm1.pack(pady=18)
top.title('   KOFFIEMACHINE')

mainloop()


From scarblac@pino.selwerd.nl  Tue Jun 12 10:23:01 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 12 Jun 2001 11:23:01 +0200
Subject: [Tutor] Uncallable class methods?
In-Reply-To: <01061214524307.11131@mercury.in.cqsl.com>; from lonetwin@yahoo.com on Tue, Jun 12, 2001 at 02:52:43PM +0530
References: <E159fm3-0006Oy-00@gadolinium.btinternet.com> <01061214524307.11131@mercury.in.cqsl.com>
Message-ID: <20010612112301.A30501@pino.selwerd.nl>

On  0, steve <lonetwin@yahoo.com> wrote:
>  Well, here's how I see it as...I think it's a pretty good thing that python 
> complains when U try to use an "unbound" function, but does not when u define 
> it .....'cos by doing that I can ensure that these functions are to be used 
> "only" within the class itself.

You can't use them within the class itself either.

-- 
Remco Gerlich


From alan.gauld@bt.com  Tue Jun 12 10:21:48 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 12 Jun 2001 10:21:48 +0100
Subject: [Tutor] Uncallable class methods?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D810@mbtlipnt02.btlabs.bt.co.uk>

> Quick question about the following piece of code:
> 
> >>> class X:
> ..   def y():
> ..     print 'I am y of x.'
> 
> Is there anyway that y can be invoked? 

Not that I know of. It seems strange since this would be 
a reasonable thing to do - define a class method. But altho' 
Python allows the definition of class attributes it doesn't
work with class methods(altho' it allows the "definition" 
of them it doesn't provide any way to call them - doh!

> doesn't complain about a class method being declared which 
> does not have the minimum of one argument?

Coz class methods shouldn't have an instance...?
Instance methods shpould have but classs methods shouldn't. 
But Python doesn't support class methods - yet...

This is not the most helpful of posts but does confirm that
there is a hole somewhere. Maybe Mr Peters can comment?

Alan G.


From r.b.rigilink@chello.nl  Tue Jun 12 10:58:16 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Tue, 12 Jun 2001 11:58:16 +0200
Subject: [Tutor] Uncallable class methods?
References: <E159fm3-0006Oy-00@gadolinium.btinternet.com>
Message-ID: <3B25E7B8.CC309BCB@chello.nl>

Allan Crooks wrote:
> 
> Hi,
> 
> Quick question about the following piece of code:
> 
> >>> class X:
> ..   def y():
> ..     print 'I am y of x.'
> 
> Is there anyway that y can be invoked? My understanding is no, in which case, can anyone tell me why the interpreter doesn't complain about a class method being declared which does not have the minimum of one argument?
> 

Actually, there is.

>>> X.__dict__['y']()
I am y of x.

It's useless in practice, and I don't think this is the reason the
implementors chose to allow the code. However it does illustrate what
happens under the hood: Your code creates a function object and binds it
to name 'y' in namespace 'X'

Consider:

>>> X.y
<unbound method X.y>
>>> X.__dict__['y']
<function y at 0x81217fc>
>>> x = X()
>>> x.y
<method X.y of X instance at 0x80cfc44>

I.e. only when there's an attribute look-up for 'y' in 'x'/'X' does the
function become a bound/unbound method, depending on whether the
attribute was looked up in an instance is a class object.

Also consider:

class X:
    pass

def y():
    print 'I am y of x.'

X.y = y
del y

which is completely equivalent to your code.

You're proposing to make the simple name-binding operation X.y = y raise
an error in this case.

It's obvious to me that that isn't right. But I can't really tell you
why. Which means it's not really obvious ;)

Hope this sort of answers your question.

Roeland

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From r.b.rigilink@chello.nl  Tue Jun 12 11:34:47 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Tue, 12 Jun 2001 12:34:47 +0200
Subject: [Tutor] newbie help..image in toplevelwindow?
References: <B1B813073C91D311BC3E0000F8FA5DA5D76CE2@tontw001v3>
Message-ID: <3B25F047.122B511E@chello.nl>

a.dijkstra03@kpn.com wrote:
> 
> Hi there,
> 
> This is one of my first attempts building a application with Tkinter.
> Could anyone explain to me what i'm doing wrong? I'm trying to insert a
> image in the toplevel window. I'm using win NT and python2.1.
> 

Hoi Arjen,

I didn't try the code, but I think it may be as simple as:


> top.title('   KOFFIEMACHINE')

top.pack()

> 
> mainloop()

If it isn't, let me know.

Roeland
-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From rob@jam.rr.com  Tue Jun 12 12:04:09 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Tue, 12 Jun 2001 06:04:09 -0500
Subject: [Tutor] New Web tutor version
References: <3.0.1.32.20010612071756.013a999c@mail.freenet.co.uk>
Message-ID: <3B25F729.F0C48E7C@jam.rr.com>

Alan Gauld wrote:
> 
> Hi gang,
> 
> I'm happy to announce a new translation of my
> Web tutor in the Czech language. This is a very
> professional translation and has revamped the
> look of the site too.
> 
> http://www.crosswinds.net/~agauld/czech/
> 
> OR to see the home site, where they are using Python in anger:
> ------------------
> The Czech version of your book is displayed on our Czech
> web site, on
> 
> http://www.datapartner.cz
> 
> please go to "Poradna" (something like Guidance) and there
> on "Jak se naucit programovat" (the name of your book in
> Czech language.)
> ------------------
> 
> Unfortunately the changes mean it only works in
> Internet Explorer - I've asked them to fix the
> problems...
> 
> While I was at it the downloadable version in all
> languages is now in tar/gzip format since that is
> readable in winzip etc as well as Linux.
> 
> Enjoy,
> 
> Alan G
> 

Congrats, Alan! I finally have a good excuse to learn some Czech. I'll
update your Useless link to reflect the news.

Rob
-- 
As foretold by Nostradamus....
Useless Python!
http://www.lowerstandard.com/python


From a.dijkstra03@kpn.com  Tue Jun 12 12:10:55 2001
From: a.dijkstra03@kpn.com (a.dijkstra03@kpn.com)
Date: Tue, 12 Jun 2001 13:10:55 +0200
Subject: [Tutor] newbie help..image in toplevelwindow?
Message-ID: <B1B813073C91D311BC3E0000F8FA5DA5D76CE5@tontw001v3>

Hoi Roeland,

No, that didn't work too. I now get the following message:

Traceback (most recent call last):
  File "C:\Python21\mijnscripts\koffiemach.py", line 118, in ?
    top.pack()
AttributeError: Tk instance has no attribute 'pack'


Does it help you any futher? Please let me know.

Tanks anyway

Arjen

-----Oorspronkelijk bericht-----
Van: Roeland Rengelink [mailto:r.b.rigilink@chello.nl]
Verzonden: dinsdag 12 juni 2001 12:35
Aan: a.dijkstra03@kpn.com
CC: tutor@python.org
Onderwerp: Re: [Tutor] newbie help..image in toplevelwindow?


a.dijkstra03@kpn.com wrote:
> 
> Hi there,
> 
> This is one of my first attempts building a application with Tkinter.
> Could anyone explain to me what i'm doing wrong? I'm trying to insert a
> image in the toplevel window. I'm using win NT and python2.1.
> 

Hoi Arjen,

I didn't try the code, but I think it may be as simple as:


> top.title('   KOFFIEMACHINE')

top.pack()

> 
> mainloop()

If it isn't, let me know.

Roeland
-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


From scarblac@pino.selwerd.nl  Tue Jun 12 12:30:57 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 12 Jun 2001 13:30:57 +0200
Subject: [lonetwin@yahoo.com: Re: [Tutor] Uncallable class methods?]
Message-ID: <20010612133057.B30814@pino.selwerd.nl>

Steve accidentally mailed his reply only to me.

----- Forwarded message from steve <lonetwin@yahoo.com> -----

Delivered-To: scarblac@pino.selwerd.nl
From: steve <lonetwin@yahoo.com>
Date: Tue, 12 Jun 2001 16:54:55 +0530
X-Mailer: KMail [version 1.1.99]
To: Remco Gerlich <scarblac@pino.selwerd.nl>
In-Reply-To: <20010612112301.A30501@pino.selwerd.nl>
Subject: Re: [Tutor] Uncallable class methods?

Hey there,

> On  0, steve <lonetwin@yahoo.com> wrote:
> >  Well, here's how I see it as...I think it's a pretty good thing that
> > python complains when U try to use an "unbound" function, but does not
> > when u define it .....'cos by doing that I can ensure that these
> > functions are to be used "only" within the class itself.

 There ^^^^^^^^, all that was me trying to be a smart-ass, I'm sorry....tho' 
what I actually was trying to say was :

<snip>
...kinda like a "private" function....if u 
really do require to use something that u defined for the class but did not 
mean an object of the class to use it, well define it outside the class
</snip>

like in.....within the same module/file.

I messed up, I'm sorry (guess my fundas are still weak)....thanx Remco for 
correcting me ....(by doing that U made sure I "always" remembered that :) )

Peace
Steve

-- 
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||	
|||/\##|||||||||##/\||	
|/    \#########/    \	
|\     \#######/     /	
||\____/#######\____/|	
=====================================	
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
====================================

----- End forwarded message -----


From arcege@speakeasy.net  Tue Jun 12 12:35:12 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Tue, 12 Jun 2001 07:35:12 -0400 (EDT)
Subject: [Tutor] newbie help..image in toplevelwindow?
In-Reply-To: <B1B813073C91D311BC3E0000F8FA5DA5D76CE2@tontw001v3> from "a.dijkstra03@kpn.com" at Jun 12, 2001 11:22:36 AM
Message-ID: <200106121135.f5CBZDO13254@dsl092-074-184.bos1.dsl.speakeasy.net>

a.dijkstra03@kpn.com wrote
> This is one of my first attempts building a application with Tkinter.
> Could anyone explain to me what i'm doing wrong? I'm trying to insert a
> image in the toplevel window. I'm using win NT and python2.1.

You need to keep the image until the window is destroyed.  To deal with
the simple problem now, change the function to:

# first create a variable set to None, we'll populate it only once
_newwin_img = None
def newwin():
    global _newwin_img            # not a local variable to the function
    wat=Toplevel()
    fr=Frame(wat)
    t=Label(fr, text='Versie 1.0', fg='red', bg='white')
    t.pack(pady=10)
    filename='PythonPoweredSmall.gif'
    if not _newwin_img:                               # if not populated
      _newwin_img = PhotoImage(file=filename)
    hm = Label(fr, image=_newwin_img)
    hm.pack()
    wat.title('info')
    fr.pack()

Because of the interactions between Python and Tcl for Tkinter, the
image will be destroyed when the Python reference is destroy, which is
the end of the function.  [Most people talk about "scope" in programming,
and do not realize that "extent" is often a more important concept.]

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From a.dijkstra03@kpn.com  Tue Jun 12 12:38:53 2001
From: a.dijkstra03@kpn.com (a.dijkstra03@kpn.com)
Date: Tue, 12 Jun 2001 13:38:53 +0200
Subject: [Tutor] newbie help..image in toplevelwindow?
Message-ID: <B1B813073C91D311BC3E0000F8FA5DA5D76CE9@tontw001v3>

YESS. It works! Thank you very much.

-----Oorspronkelijk bericht-----
Van: Michael P. Reilly
[mailto:arcege@dsl092-074-184.bos1.dsl.speakeasy.net]
Verzonden: dinsdag 12 juni 2001 13:35
Aan: a.dijkstra03@kpn.com
CC: tutor@python.org
Onderwerp: Re: [Tutor] newbie help..image in toplevelwindow?


a.dijkstra03@kpn.com wrote
> This is one of my first attempts building a application with Tkinter.
> Could anyone explain to me what i'm doing wrong? I'm trying to insert a
> image in the toplevel window. I'm using win NT and python2.1.

You need to keep the image until the window is destroyed.  To deal with
the simple problem now, change the function to:

# first create a variable set to None, we'll populate it only once
_newwin_img = None
def newwin():
    global _newwin_img            # not a local variable to the function
    wat=Toplevel()
    fr=Frame(wat)
    t=Label(fr, text='Versie 1.0', fg='red', bg='white')
    t.pack(pady=10)
    filename='PythonPoweredSmall.gif'
    if not _newwin_img:                               # if not populated
      _newwin_img = PhotoImage(file=filename)
    hm = Label(fr, image=_newwin_img)
    hm.pack()
    wat.title('info')
    fr.pack()

Because of the interactions between Python and Tcl for Tkinter, the
image will be destroyed when the Python reference is destroy, which is
the end of the function.  [Most people talk about "scope" in programming,
and do not realize that "extent" is often a more important concept.]

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From alan.gauld@bt.com  Tue Jun 12 13:04:09 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 12 Jun 2001 13:04:09 +0100
Subject: [Tutor] Useless challenge?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D812@mbtlipnt02.btlabs.bt.co.uk>

I was thinking the other day that there doesn't seem to be any 
kind of equivalent to the Tk widget tour demo that starts when 
you install Tcl/Tk. I was also thinking that since its all 
written in Tcl/Tk it should be fairly easy(technically speaking) 
to translate it into Python/Tkinter.

I also thought that since it is essentially a lot of little 
applets inside a containing structure that it would be a 
good challenge for the Useless Python site - list the applets 
to be converted and get people to build the Python versions. 

This could then allow some extras to be added such as the 
PMW widgets too.

Then, for a real test, convert it all to wxPython! ;-)

What think yez?

Alan g

------------------------------
British Telecommunications plc
Registered office: 81 Newgate Street London EC1A 7AJ
Registered in England no. 1800000.

This electronic message contains information from British 
Telecommunications plc which may be privileged or confidential. 
The information is intended to be for the use of the individual(s) 
or entity named above.
If you are not the intended recipient be aware that any disclosure, 
copying, distribution or use of the contents of this information is 
prohibited. If you have received this electronic message in error, 
please notify us by telephone or email (to the numbers or address 
above) immediately.
 


From r.b.rigilink@chello.nl  Tue Jun 12 13:23:29 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Tue, 12 Jun 2001 14:23:29 +0200
Subject: [Tutor] SubDictionaries or am I reinventing a wheel?
References: <NBBBIOJPGKJEKIECEMCBAEEKKAAA.pobrien@orbtech.com>
Message-ID: <3B2609C1.34A88AAF@chello.nl>

"Patrick K. O'Brien" wrote:


Hi Patrick,

> 
> Imagine that you have a dictionary with a multipart key and you want to
> extract a new dictionary that is a subset of the existing dictionary based
> on matching a few of the leading elements that make up the key. For example,
> GoldMine stores multiple record types in some of its database files. So I
> have a dictionary with the table name and record type code as the key.
> 
> gmRecordTypes = {  # Table, Type, Description
>     ('CAL', 'A'): 'Appointment',

<snip>

>     }
> 

Have you considered using nested dictionaries for this, i.e.:

gmRecordTypes = {'CAL': {'A': 'Appointment',
                         'C': 'Call back',
                         ...
                         'T': 'Next action},
                 'CONTHIST': {'A':'Appointment',
                              'C': 'Call back',
                              ...
                              'T': 'Next action'}}

You can then get at the subdictionaries through

subd = gmRecordTypes['CAL']

and individual values with

val = gmRecordTypes['CAL']['A']

This is sort of the standard approach for what you seem to describe.

> Now let's say I wanted a function that would return a new dictionary of just
> the record types and descriptions for the CONTHIST table. Think of this as
> sort of a query against a database table - select type, description from
> gmRecordTypes where table = 'CONTHIST'. Imagine that you had lots of
> dictionaries like this and that you wanted the function to be able to select
> based on one matching element or several matching elements of the key. Well,
> I did and here is what I came up with.
> 
> # partmatch can be a single value or any valid sequence for a dictionary key
> or portion thereof.
> 
> def subDictionary(dictionary, partmatch=None):
>     """Return a subset of a dictionary based on a partial key match."""
>     if partmatch == None:
>         return dictionary

Are you sure that subDictionary(dictionary) should return dictionary
itself,
while subDictionary(dictionary, ()) should return a copy?

>     else:
>         subd = {}
>         partsize = len(partmatch)
>         if partsize == 1:  # Reduce single element sequences to single
> elements.
>             partmatch = partmatch[0]
>         for key in dictionary.keys():
>             if partsize == 1:  # Reduce single element sequences to single
> elements.
>                 keypart = key[0]
>             else:
>                 keypart = key[:partsize]
>             if keypart == partmatch:
>                 if len(key[partsize:]) == 1:  # Simplify the new key by
> reducing it to a single object if possible.
>                     newkey = key[partsize]
>                 else:
>                     newkey = key[partsize:]
>                 subd[newkey] = dictionary[key]
>         return subd
> 

Here's my somewhat more concise version.
Note that I also test if key and partmatch are of the same type.

def subDictionary(dictionary, partmatch=()):
    """Return a subset of a dictionary based on a partial key match."""

    subd = {}
    for key, val in dictionary.items():
        if partial_match(partmatch, key):
            newkey = key[len(partmatch):]
            if len(newkey) == 1:
                newkey = newkey[0]
            subd[newkey] = val
    return subd

def partial_match(first, second):
    '''Match two sequences

    returns 0 if type(first) != type(second)
    
    returns 1 if second[:len(first)] == first
    returns 0 otherwise
    '''
    if type(first) != type(second):
        return 0
    return second[:len(first)] == first


> Now, I either came up with something nifty that will be useful to me and
> maybe others, or I just spent a good couple of hours reinventing the wheel.
> Does anyone know of any Python module that does this already? Is this a good
> approach to the problem I described, or am I off my rocker? 

Hey, your code works, which is the only practical definition of 'good
approach'

> Somehow this
> sort of manipulation seems like it should be part of the core of python in
> the way that keys() and values() are already there.
> 

This sounds like a nasty question, but think of it a an exercise.

Exactly what kind of manipulation do you mean? Remember keys() and
values() can be described exactly in one sentence only. Try to find the
one-sentence description for your proposed extensions. You could then
try building your own UserDict class that implements these manipulations
as additional methods.

Hope this helps,

Roeland

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From rob@jam.rr.com  Tue Jun 12 13:29:15 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Tue, 12 Jun 2001 07:29:15 -0500
Subject: [Tutor] Useless challenge?
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D812@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <3B260B1B.918DF86B@jam.rr.com>

alan.gauld@bt.com wrote:
> 
> I was thinking the other day that there doesn't seem to be any
> kind of equivalent to the Tk widget tour demo that starts when
> you install Tcl/Tk. I was also thinking that since its all
> written in Tcl/Tk it should be fairly easy(technically speaking)
> to translate it into Python/Tkinter.
> 
> I also thought that since it is essentially a lot of little
> applets inside a containing structure that it would be a
> good challenge for the Useless Python site - list the applets
> to be converted and get people to build the Python versions.
> 
> This could then allow some extras to be added such as the
> PMW widgets too.
> 
> Then, for a real test, convert it all to wxPython! ;-)
> 
> What think yez?
> 
> Alan g
> 

Sounds nifty to me! In fact, I've already added this to the page. Now,
if only my web hosting service felt inclined to accept connections from
me, I'd just upload it. I guess I'll have to go to work and do it again.

It's really amazing. Ever since it was sold to new owners a few weeks
back, my host will refuse to allow me to ftp approximately 1/3 of the
time, but only from this location. When I move to a new host, there will
be great rejoicing in the land.

Have a Useless Day,
Rob
-- 
As foretold by Nostradamus....
Useless Python!
http://www.lowerstandard.com/python


From pobrien@orbtech.com  Tue Jun 12 13:46:39 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Tue, 12 Jun 2001 07:46:39 -0500
Subject: [Tutor] SubDictionaries or am I reinventing a wheel?
In-Reply-To: <3B2609C1.34A88AAF@chello.nl>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEFCKAAA.pobrien@orbtech.com>

D'oh!!! (Followed by a smack to the forehead.)

Boy you nailed this one, Roeland! I knew I was overlooking something very
obvious (to everyone but me <wink>).

No, I did not consider using nested dictionaries. But you can bet I'll never
make that mistake again. Ouch!

Your example of being able to do val = gmRecordTypes['CAL']['A'] was exactly
the kind of simple, elegant language feature I just knew had to be available
in python. I hope that explains the final question of my original post,
which in no way did I intend to sound "nasty". My apologies to anyone who
got that impression.

Thank you very much for helping me see the error of my ways!
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Roeland Rengelink
Sent: Tuesday, June 12, 2001 7:23 AM
To: pobrien@orbtech.com
Cc: Python Tutor
Subject: Re: [Tutor] SubDictionaries or am I reinventing a wheel?

"Patrick K. O'Brien" wrote:


Hi Patrick,

>
> Imagine that you have a dictionary with a multipart key and you want to
> extract a new dictionary that is a subset of the existing dictionary based
> on matching a few of the leading elements that make up the key. For
example,
> GoldMine stores multiple record types in some of its database files. So I
> have a dictionary with the table name and record type code as the key.
>
> gmRecordTypes = {  # Table, Type, Description
>     ('CAL', 'A'): 'Appointment',

<snip>

>     }
>

Have you considered using nested dictionaries for this, i.e.:

gmRecordTypes = {'CAL': {'A': 'Appointment',
                         'C': 'Call back',
                         ...
                         'T': 'Next action},
                 'CONTHIST': {'A':'Appointment',
                              'C': 'Call back',
                              ...
                              'T': 'Next action'}}

You can then get at the subdictionaries through

subd = gmRecordTypes['CAL']

and individual values with

val = gmRecordTypes['CAL']['A']

This is sort of the standard approach for what you seem to describe.

> Now let's say I wanted a function that would return a new dictionary of
just
> the record types and descriptions for the CONTHIST table. Think of this as
> sort of a query against a database table - select type, description from
> gmRecordTypes where table = 'CONTHIST'. Imagine that you had lots of
> dictionaries like this and that you wanted the function to be able to
select
> based on one matching element or several matching elements of the key.
Well,
> I did and here is what I came up with.
>
> # partmatch can be a single value or any valid sequence for a dictionary
key
> or portion thereof.
>
> def subDictionary(dictionary, partmatch=None):
>     """Return a subset of a dictionary based on a partial key match."""
>     if partmatch == None:
>         return dictionary

Are you sure that subDictionary(dictionary) should return dictionary
itself,
while subDictionary(dictionary, ()) should return a copy?

>     else:
>         subd = {}
>         partsize = len(partmatch)
>         if partsize == 1:  # Reduce single element sequences to single
> elements.
>             partmatch = partmatch[0]
>         for key in dictionary.keys():
>             if partsize == 1:  # Reduce single element sequences to single
> elements.
>                 keypart = key[0]
>             else:
>                 keypart = key[:partsize]
>             if keypart == partmatch:
>                 if len(key[partsize:]) == 1:  # Simplify the new key by
> reducing it to a single object if possible.
>                     newkey = key[partsize]
>                 else:
>                     newkey = key[partsize:]
>                 subd[newkey] = dictionary[key]
>         return subd
>

Here's my somewhat more concise version.
Note that I also test if key and partmatch are of the same type.

def subDictionary(dictionary, partmatch=()):
    """Return a subset of a dictionary based on a partial key match."""

    subd = {}
    for key, val in dictionary.items():
        if partial_match(partmatch, key):
            newkey = key[len(partmatch):]
            if len(newkey) == 1:
                newkey = newkey[0]
            subd[newkey] = val
    return subd

def partial_match(first, second):
    '''Match two sequences

    returns 0 if type(first) != type(second)

    returns 1 if second[:len(first)] == first
    returns 0 otherwise
    '''
    if type(first) != type(second):
        return 0
    return second[:len(first)] == first


> Now, I either came up with something nifty that will be useful to me and
> maybe others, or I just spent a good couple of hours reinventing the
wheel.
> Does anyone know of any Python module that does this already? Is this a
good
> approach to the problem I described, or am I off my rocker?

Hey, your code works, which is the only practical definition of 'good
approach'

> Somehow this
> sort of manipulation seems like it should be part of the core of python in
> the way that keys() and values() are already there.
>

This sounds like a nasty question, but think of it a an exercise.

Exactly what kind of manipulation do you mean? Remember keys() and
values() can be described exactly in one sentence only. Try to find the
one-sentence description for your proposed extensions. You could then
try building your own UserDict class that implements these manipulations
as additional methods.

Hope this helps,

Roeland

--
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From r.b.rigilink@chello.nl  Tue Jun 12 14:21:05 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Tue, 12 Jun 2001 15:21:05 +0200
Subject: [Tutor] SubDictionaries or am I reinventing a wheel?
References: <NBBBIOJPGKJEKIECEMCBAEFCKAAA.pobrien@orbtech.com>
Message-ID: <3B261741.23857E52@chello.nl>

"Patrick K. O'Brien" wrote:
> 
> D'oh!!! (Followed by a smack to the forehead.)
> 
> Boy you nailed this one, Roeland! I knew I was overlooking something very
> obvious (to everyone but me <wink>).
> 
> No, I did not consider using nested dictionaries. But you can bet I'll never
> make that mistake again. Ouch!
> 
> Your example of being able to do val = gmRecordTypes['CAL']['A'] was exactly
> the kind of simple, elegant language feature I just knew had to be available
> in python. I hope that explains the final question of my original post,
> which in no way did I intend to sound "nasty". My apologies to anyone who
> got that impression.
> 

Misunderstanding ;)

I didn't think your question was nasty, I thought you might take my
question ('Exactly what kind of manipulation do you mean ?') as nasty,
because you had actually given a pretty good explanation of what you
meant.

Anyway, glad to be of help,

Roeland

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From pobrien@orbtech.com  Tue Jun 12 14:48:18 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Tue, 12 Jun 2001 08:48:18 -0500
Subject: [Tutor] SubDictionaries or am I reinventing a wheel?
In-Reply-To: <3B261741.23857E52@chello.nl>
Message-ID: <NBBBIOJPGKJEKIECEMCBIEFDKAAA.pobrien@orbtech.com>

Gotcha. My mistake. Going on too little sleep. The brain is a little slow
this morning. Thanks again for the help. I really appreciate it.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: roeland [mailto:roeland]On Behalf Of Roeland Rengelink
Sent: Tuesday, June 12, 2001 8:21 AM
To: pobrien@orbtech.com
Cc: Python Tutor
Subject: Re: [Tutor] SubDictionaries or am I reinventing a wheel?

"Patrick K. O'Brien" wrote:
>
> D'oh!!! (Followed by a smack to the forehead.)
>
> Boy you nailed this one, Roeland! I knew I was overlooking something very
> obvious (to everyone but me <wink>).
>
> No, I did not consider using nested dictionaries. But you can bet I'll
never
> make that mistake again. Ouch!
>
> Your example of being able to do val = gmRecordTypes['CAL']['A'] was
exactly
> the kind of simple, elegant language feature I just knew had to be
available
> in python. I hope that explains the final question of my original post,
> which in no way did I intend to sound "nasty". My apologies to anyone who
> got that impression.
>

Misunderstanding ;)

I didn't think your question was nasty, I thought you might take my
question ('Exactly what kind of manipulation do you mean ?') as nasty,
because you had actually given a pretty good explanation of what you
meant.

Anyway, glad to be of help,

Roeland

--
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 17:09:39 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 12 Jun 2001 09:09:39 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind!
In-Reply-To: <200106121632.f5CGW5g07404@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106120901410.28711-100000@hkn.eecs.berkeley.edu>

On Tue, 12 Jun 2001 kromag@nsacom.net wrote:

> db=engine.OpenDatabase("\windows\desktop\terror.mdb")

Here's the bug!  When you put a backslash in a string, Python treats it as
a special "escape" character.  We can see how Python interpreted this
particular string:

###
>>> print "\windows\desktop\terror.mdb"
\windows\desktop	error.mdb
###

It didn't find equivalent escape codes for '\w' or '\d', but '\t' matches
with the 'tab' escape code.  Assumedly, if engine.OpenDatabase can't find
a file, it returns None, and that explains the error you're getting:

###
AttributeError: 'None' object has no attribute 'Execute'
###


The fix is to tell Python to treat the backslashes as regular
characters.  There are two main ways to do this: the first is to double up
all the backslashes:

    db = engine.OpenDatabase("\\windows\\desktop\\terror.mdb")

because the escape code for '\\' is the single backslash character.  The
other way is to use "raw strings", which are just strings which don't put
any special meaning to the backslash:

    db = engine.OpenDatabase(r"\windows\desktop\terror.mdb")

The leading 'r' in front tells Python to treat this particular string as
a raw string.

Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 18:34:00 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 12 Jun 2001 10:34:00 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind!
In-Reply-To: <200106121925.f5CJP2g20793@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106121021310.29803-100000@hkn.eecs.berkeley.edu>

On Tue, 12 Jun 2001 kromag@nsacom.net wrote:

> Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> said: 
> 
> > On Tue, 12 Jun 2001 kromag@nsacom.net wrote:
> > 
> > > db=engine.OpenDatabase("windowsdesktopterror.mdb")
> > 
> > Here's the bug!  When you put a backslash in a string, Python treats it as
> > a special "escape" character.  We can see how Python interpreted this
> > particular string:
>
> Errr... Uuhhh... I always use double backslashes! Are you sure you
> were using what I pasted in? :-)

Oh my gosh.  I'm sorry about that!  I just woke up.  I was looking at...

...wait a minute.


> > ###
> > >>> print "windowsdesktopterror.mdb"
> > windowsdesktop	error.mdb
> > ##

Hmmm...  *laugh*


> Traceback (most recent call last):
>   File "dbwrite.py", line 8, in ?
>     db=engine.OpenDatabase("\windows\desktop\terrorista.mdb")
>   File "<COMObject DAO.DBEngine.35>", line 2, in OpenDatabase
> pywintypes.com_error: (-2147352567, 'Exception occurred.', 
> (0, 'DAO.Workspace', "Couldn't find 
> file '\windows\desktop\terrorista.mdb'.", 'jeterr35.hlp', 5003024, -
> 2146825264), None)
> >Exit code: 1

Can you show us what your source code looks like now?  With all these
revisions, I'm having a difficult time remembering things.

Talk to you later!




From jarrett@ydyn.com  Tue Jun 12 22:11:45 2001
From: jarrett@ydyn.com (W. Jarrett Campbell)
Date: Tue, 12 Jun 2001 16:11:45 -0500
Subject: [Tutor] doc strings and structured text
Message-ID: <NDBBLLANIGLGFCJPIECNIEJDCIAA.jarrett@ydyn.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0013_01C0F35A.604CDC70
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_0014_01C0F35A.604CDC70"


------=_NextPart_001_0014_01C0F35A.604CDC70
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

In my new python adventure I've seen lots of reference to 'doc strings' and
'structured text'.  I've even figured out how to generate some basic inline
documentation using the ActiveState implementation of pydoc.  However, I
haven't been able to find a really good, tutorial level reference explaining
doc strings and structured text.

Does anyone have suggestions for some background reading on these topics.

Thank you,

Jarrett




      W. Jarrett Campbell, Ph.D.
      Member of the Technical Staff
      Yield Dynamics, Inc.
      5838 Balcones Drive, Ste. 101
      Austin, TX 78731
     512.323.9149  office
      512.257.9503  fax
      512.415.1078  mobile
      jarrett@ydyn.com
      http://www.ydyn.com




------=_NextPart_001_0014_01C0F35A.604CDC70
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.4616.200" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D063081021-12062001><FONT face=3DArial size=3D2>In my =
new python=20
adventure I've seen lots of reference to 'doc strings' and 'structured=20
text'.&nbsp; I've even figured out how to generate some basic inline=20
documentation using the ActiveState implementation of pydoc.&nbsp; =
However, I=20
haven't been able to find a really good, tutorial level reference =
explaining doc=20
strings and structured text.</FONT></SPAN></DIV>
<DIV><SPAN class=3D063081021-12062001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D063081021-12062001><FONT face=3DArial size=3D2>Does =
anyone have=20
suggestions for some background reading on these=20
topics.</FONT></SPAN></DIV><SPAN class=3D063081021-12062001>
<DIV><BR><FONT face=3DArial size=3D2>Thank you,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV></SPAN><SPAN class=3D063081021-12062001><FONT face=3DArial=20
size=3D2>Jarrett</FONT></SPAN></DIV>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<TABLE width=3D312>
  <TBODY>
  <TR>
    <TD align=3Dleft width=3D304 colSpan=3D2>
      <P align=3Dleft><IMG height=3D66 =
src=3D"cid:063081021@12062001-19aa" width=3D250=20
      border=3D0> </P></TD></TR>
  <TR>
    <TD align=3Dleft width=3D179><FONT size=3D1>W. Jarrett Campbell, =
Ph.D.<BR>Member=20
      of the Technical Staff<BR>Yield Dynamics, Inc.<BR>5838 Balcones =
Drive,=20
      Ste. 101<BR>Austin, TX 78731<BR></FONT></TD>
    <TD align=3Dleft width=3D119><FONT size=3D1>512.323.9149&nbsp;=20
      office<BR>512.257.9503&nbsp; fax<BR>512.415.1078&nbsp; =
mobile<BR><A=20
      href=3D"mailto:jarrett@ydyn.com">jarrett@ydyn.com</A><BR><A=20
      =
href=3D"http://www.ydyn.com/">http://www.ydyn.com<BR></A></FONT></TD></TR=
></TBODY></TABLE>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_001_0014_01C0F35A.604CDC70--

------=_NextPart_000_0013_01C0F35A.604CDC70
Content-Type: image/gif;
	name="signature.gif"
Content-Transfer-Encoding: base64
Content-ID: <063081021@12062001-19aa>

R0lGODlh+gBCALMAAAgICCQkJEVFRV5eXnNzc4iIiJycnK2trbW1tcXFxdbW1t7e3ufn5+/v7/f3
9////ywAAAAA+gBCAAAE/vDJSau9OOvNu/9gKI5kWS0GY65s675wLHNIAChzru9871sNwwBAcPyO
yKRyGRQQBIuldEqtihjPRuFg7Xq/U4ZAoEAYGhkHooADu99wjyO7IGcYBpshzu/zHQUBCQ8GAkYX
DAECCQZcfo+QVQgAgwwDbRYKAgMMDQRRkaGiPg5CEgwIhxViA2gFAmgjDAoEtQeqo7kYDrhgWQ8L
ghdzAWgOA44gDgwHAwMGjQMIutQVDgoDRS29Kw1jRkIqQASOCa0h2NkK4g8JBLHVurQCAAbcIgsD
oC0JATiWmCoc0AYoWQc8AT71EhMwXqQgTwLsaaHghotS9tqdAyKggIQa/uw4FCpwBhEUh6EcHBiD
rcC9KwQstgAooYDHCwcCiBPykoIDd880iNmHsg+tAJwChTRhAMCAQS1APrAE1cITIw1ucdCyaamF
oUX9pFMQxEBDEwOcVF2R7cGxAfcaBJj2YCA8DAueLOg5IR/RsGC0SHT76m43AGvoHp5mzqsETSoa
XNKg5pnjCzYBa2igoNEBaDZtQmvUCYY7AakeYDtrAjIBxSYYUCqYQROaWhtqrOVAYKIIBw0SJDDs
hdeCBCvpAVgeIHQg5h3LKOBVQo2iWIBuXiTQShqLOXATCLisGpZc30AQPONrFf2HvM4Gg7lWK9um
Bg14UZ+gv8ECPJvU/pJaCJ48EwstBRDXmj/HwEaCNwmA1xM2WSWIgWT6hGDJX1s1Y8Bw/40AHHu/
1YDUAXs5oUwDzAxkxwfYpMBfVzEcAEB+3nUDRWMaNCOZgxQg8IkIhSlDQHMkpoFFNgqSwEAgBFTl
jUEaElAAeT7lYQgFeWBJQiFu5WiCZFpQaY0zG+I1GYEqyiFkSSQsM8QiY7hQAAAHLJWmT0lOsJKX
gMyFS05msiCXRzStoAkC421QADIZAUFSnxTsycFPSJbgSUcoPjBJkyB4s1GlJ01giWL6pfrVIkLl
4SArlH4gxiDqxYqBjQmxJ1ujF5gDqlsYGECAB5IVwCEIQj6lyqeG/grgngSSibMMPR0VUAt3zjC5
ijAY9GNhBV3OYIkKtbIwyYCbZdora8B1VqpPJHWQVYZx1gDLCbyacAxqCCSAAAIHBOzsSgEUXPAY
zgIccMC9JCCTNf3ca4EZOTCKhgEumQsAiSrBtQvGuPyUbS3EFeLlVCSboN4BxPVzcgd5LSfzM/Q4
h9o7+nWQzT2BfGvBfjJcVcexIqzUgQJITdgcAwlYy52zL0m4gSaRjrBAIIV6euMLwOEXSyCHdFbX
rwL5c0ENGStxVR6/Ap2BwwJsZdOoZytiZQEI5KcBLUT3ZRPZGtSB2kt32hpCwdAiwwaMbVaAdNpJ
zOGRlbllPUGB/gBgWSCZG/gHuJ8EKSjGs0bSbU1zOzSAZ5iomd1BDawhveUScyiQD9mNX+DJO2vq
fqTt+VJkxxwS90UjCZoQgKV4rLmgBWJhPlV1BkG09fMrzZNi5VM+RUhBP5bvi4N4HP6E/QNyWT4C
d8AdGTwhxf82BpbHDKuDsNA/kJaxHAA43fXx28E1bFeBmGzNePtIRAApgDSoOMBZFcjKdSZAjhcE
YzgDKMaQoHUAn5UINRvoR9/4RIEGrAFOpViLGHIClSGoDzhNUV638scDNTzBGTKUwJEclAdVVMR+
ktogtJy2PQBAjQKPusgW8MCGPUkmhyIaiJc8AZt7qGEToDiG/sFuYiNtEKaDHtPf++DVkeFcqDeG
+00zENCJikBFMrOjIIOCQw/WbGo3UxkNNPJkgUB8rn/6mBQwTqISKI6gBuqTwEAOoQVDKjIh3yjF
XPRXhAcSoS+ccIYR3hIXYQ3Agxaow8vMFYBkOOwf7sNFMASQkAxughsEyx4NdMKP3mgFftdwwih3
gcbcCAMhzVEPBXJiD7BVhAuPmwpSQJEXe7CvM3lI2zKaoYgriaQYbrplCDrCSCdIMAXxQl8HySIc
BCwgGJhQw0h2aZIRfiAP75gA9ua3Al91zpt1MCIObBQLydjDRh455QP8SIj8EUMFwQgELJqCGnPQ
4yl/BJu8/u6UuSvQMCffNIKNEqCAO2mHP85QgEhjwgkWWKoEk6ClqQoWzwsd7UVpIClSjGgEuCUO
Ubl6RRQeaI88eMxb4sAQnMyRrbyF4BX9C8QnFTSiDJjBGEIyQ1CG6AwD7OUC+cgW95z3nfNVgKM9
8YQsFbkxa6jCE8t5SiJugQ3EMO18DvMX6tBHhCMhxYTOuIvb3IKfNIrHMctgRME+xD9eMM0MihCG
fpimAPEcIAHMUMTx+NNXyngtjTX8ozVktIGBCIR7S3IKVBiFBYOlpR6xiFjwhEQA2yX2fwIUAmyB
kxdWDsEZCLvWQ22RwfocSWYAeJRylqaZI9ioE8ywbUdt/sCgCSDNiGdISwKuKoGfQPZnhxAOO1tD
j+YYsKGdeMIZsDCGfk3nEA8cw4c4ysRjQFezxaWIIk77lNpCyQKfwQ5mlZAVjJHkQ9Yg4TD2mplX
bDe+2zgnA1TilFlwE8EzSF87vAjhI1xDSALIU/L2W+G33atcHf6BjciABnfAKcQvuIqnwojiHDjg
ahJBg2Tq0eIYqBjENY5BKTqSGmKwLMcp3hKOgfydgXzyco9yJ5FBcGMWL7kE+UjIVc1n1Se7QMXW
4vCTBUeUpjjZyia4ijcoDOYPBAqKHTVQmVsg5t6teaKCMl5F38yCq0CGzh3ox1bR59MD49kChRAM
fMHcc4+WXiODP/7zCkqRk48q+qtqloCex/poDwiJhpWeQD98czWYZnpMrMTjo5EWz5+U99MuEI6W
Q1ysTULJz6iOdUy1cRTvyfrWLBjI+JAialz7Wlb+eNInV/1rWcPtGbAttrJB4DAhLvvZcjAjtKdN
bVxHAAAAOw==

------=_NextPart_000_0013_01C0F35A.604CDC70--



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 22:54:06 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 12 Jun 2001 14:54:06 -0700 (PDT)
Subject: [Tutor] doc strings and structured text
In-Reply-To: <NDBBLLANIGLGFCJPIECNIEJDCIAA.jarrett@ydyn.com>
Message-ID: <Pine.LNX.4.21.0106121439250.1752-100000@hkn.eecs.berkeley.edu>

On Tue, 12 Jun 2001, W. Jarrett Campbell wrote:

> In my new python adventure I've seen lots of reference to 'doc
> strings' and 'structured text'.  I've even figured out how to generate
> some basic inline documentation using the ActiveState implementation
> of pydoc.  However, I haven't been able to find a really good,
> tutorial level reference explaining doc strings and structured text.

Hello!

There's a good explanation on document strings "docstrings" here:

    http://www.onlamp.com/pub/a/python/2001/05/17/docstrings.html

which should provide a high-level tutorial on what docstrings are about.  

Docstrings are small strings that we attach to functions: at the very
beginning of a function definition, Python lets us stick in a string.  
For example:

###
def invertDict(dict):
    """inverts a dictionary so that the keys become the values, and
       vice versa ."""
    newdict = {}
    for key, value in dict.items(): newdict[value] = key
    return newdict
###

That multi-line string above is the docstring.  What's neat is that we can
look at this docstring later on if we want a small reminder of how things
work:

###
>>> print invertDict.__doc__
inverts a dictionary so that the keys become the values, and          
       vice versa .
>>> invertDict({1:'one', 2:'two', 3:'three'})
{'one': 1, 'two': 2, 'three': 3}
###

Almost every function in Python has a docstring, which makes our life much
easier.  Docstrings can also be attached to classes.  There's even a
suggestion to allow docstrings to attach to pretty much everything, but I
don't think that feature is implemented yet.

How does this relate to the other topic of "structured text"?  Structured
text is an approach to let people use indentation in their docstrings as a
way of structuring things.  Think HTML, and you'll have the idea of
StructuredText.  The big difference is that StructuredText doesn't use
tags at all.

The ZopeBook (which is coming out by New Riders soon, yah!), is written in
StructuredText, so you can take a look at an extended example of it here:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/zope-book/Book/README.txt?rev=1.2&content-type=text/plain

(sorry about the long link)

So the basic idea is to make it easy to write really elaborate docstrings
without having to learn an HTML-like language.


Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 23:14:18 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 12 Jun 2001 15:14:18 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind!
In-Reply-To: <200106122043.f5CKhZg08801@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106121501180.1752-100000@hkn.eecs.berkeley.edu>

On Tue, 12 Jun 2001 kromag@nsacom.net wrote:

> def Yoo(Need, Coffee):
>     headrush=open('/yoo/skull/caffeine_funnel.zap', 'r+')
>     write.headrush('%s', '%s')% ('cream', 'sugar')
>     time.sleep(0) 
>     return: "to your keyboard"
           ^^^

Hmmm... there's a bug here --- the colon isn't necessary.  The correction:

###
      return "to your keyboard"
###

should fix things.


Let's look at the rest of the program:

> import string
> import thread
> 
> engine=win32com.client.Dispatch("DAO.DBEngine.35")
> db=engine.OpenDatabase("\windows\desktop\terror.mdb")

Ok, I'm not imagining things after all.  *grin* There are backslashes on
this line: can you double check?


> One of the nice fellers over in db-sig said that the problem was that 'None' 
> is part of engine.OpenDatabase(). Sure enough:
> 
> >>> print db
> Traceback (innermost last):
>   File "<pyshell#4>", line 1, in ?
>     print db
> [exception info cut]
> Right there at the end, like an inflamed toe stands 'None'. Unfortunately I 
> am still too newbie to know whether this means that 'None' must be appeased 
> or if it can be bypassed.

"None" is probably not a problem in this particular case; what this error
means is that it wasn't able to establish the database connection
properly.  Once we get the connection working, you won't even need to
worry about handling None, since it simply won't appear.

If you fix the backslashing bug:

    db=engine.OpenDatabase(r"\windows\desktop\terror.mdb")

then printing 'db' should be ok.


Good luck!



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 12 23:17:57 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 12 Jun 2001 15:17:57 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind! (fwd)
Message-ID: <Pine.LNX.4.21.0106121516430.1752-100000@hkn.eecs.berkeley.edu>

Dear kromag,

You message isn't being sent to tutor; strange!  I see it in the carbon
copy list, so I'm a little baffled.  I'll forward it to the rest of the
list.

---------- Forwarded message ----------
Date: Tue, 12 Jun 2001 13:43:35 -0700 (PDT)
From: kromag@nsacom.net
To: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>,
     Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>, kromag@nsacom.net
Cc: tutor@python.org
Subject: Re: [Tutor] Threads....  Unhandle my Exception you Feind!

Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> said: 


def Yoo(Need, Coffee):
    headrush=open('/yoo/skull/caffeine_funnel.zap', 'r+')
    write.headrush('%s', '%s')% ('cream', 'sugar')
    time.sleep(0) 
    return: "to your keyboard"


It just won't run cleanly through the interpreter... :-)

> 
> Can you show us what your source code looks like now?  With all these
> revisions, I'm having a difficult time remembering things.

Certainly!

-------------begin the bane of all threads----------
import win32com.client
import random
import time
import string
import thread

engine=win32com.client.Dispatch("DAO.DBEngine.35")
db=engine.OpenDatabase("\windows\desktop\terror.mdb")


## Function write() writes a list to the database
def write(inputtage):
## I was just playin' with strings here...
#	time=inputtage[0]
#	data_string=inputtage[1]
	db.Execute("insert into data values(%f, '%s')" % inputtage)
	return 'ok'

if __name__=='__main__':
	tik_tok=time.time()
	surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
	the_madness=(tik_tok, surprize)
	thread.start_new_thread(write,(the_madness,))

-------------end the bane of all threads------------


One of the nice fellers over in db-sig said that the problem was that 'None' 
is part of engine.OpenDatabase(). Sure enough:

>>> print db
Traceback (innermost last):
  File "<pyshell#4>", line 1, in ?
    print db
  File "C:Python20win32comclientdynamic.py", line 165, in __str__
    return str(self.__call__())
  File "C:Python20win32comclientdynamic.py", line 165, in __str__
    return str(self.__call__())
  File "C:Python20win32comclientdynamic.py", line 150, in __call__
    return self._get_good_object_(apply
(self._oleobj_.Invoke,allArgs),self._olerepr_.defaultDispatchName,None)
com_error: (-2147352567, 'Exception occurred.', (0, 'DAO.TableDefs', 'Invalid 
argument.', 'jeterr35.hlp', 5003001, -2146825287), None)
>>> 

Right there at the end, like an inflamed toe stands 'None'. Unfortunately I 
am still too newbie to know whether this means that 'None' must be appeased 
or if it can be bypassed.

Is there a clean, cross-platform way to get rid of it? I haven't seen this 
sort of nonsense with psycopg and postgreSQ(uea)L yet, but I'll bet I will 
run on to similar things.

I definitely want to get this through my head before I start fiddling with 
threading() and/or psycopg with it's cool persistent threads.

It's getting hairy around here! :-)




From israel@lith.com  Wed Jun 13 02:28:22 2001
From: israel@lith.com (Israel Evans)
Date: Tue, 12 Jun 2001 18:28:22 -0700
Subject: [tutor] PATH vs PYTHONPATH on win98 and win2000?
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144BE@mailcluster.lith.com>

I have two problems here.

The first is that I use windows 2000 at work( ok make that three problems )
and when I set a PYTHONPATH, things get screwy and tools like IDLE don't
start up.  I can still run some programs, but not all.  If I delete
PYTHONPATH everything works great, however setting PATH to accept the few
exterior python directories that I've created doesn't seem to do anything
and modules can't be found when I import them.

The, now third problem is that I use windows98 at home ( four....  four
problems!)..  and I must ask you how in the bloody blue blazes does one set
the environment variables in the config.sys or autoexec.bat/tsh thingamabobs
anyway?

Bamboozled and flummoxed through and through...

~Israel~




------------------------------------------><--------------------------------
------------
Finnegan's paper began with the electrifying sentence, "The average Canadian
has one testicle, just like Adolph Hitler -- or, more precisely, the average
Canadian has 0.96 testicles, an even sadder plight than Hitler's, if the
average Anything actually existed." He then went on to demonstrate that the
normal or average human lives in substandard housing in Asia, has 1.04
vaginas, cannot read or write, suffers from malnutrition and never heard of
Silken Thomas Fitzgerald or Brian Boru. "The normal," he concluded "consists
of a null set which nobody and nothing really fits." 
Timothy F.X. Finnegan founder of CSICON
<http://www.rawilson.com/csicon.shtml>
------------------------------------------><--------------------------------
------------





From dsh8290@rit.edu  Wed Jun 13 03:02:30 2001
From: dsh8290@rit.edu (D-Man)
Date: Tue, 12 Jun 2001 22:02:30 -0400
Subject: [tutor] PATH vs PYTHONPATH on win98 and win2000?
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144BE@mailcluster.lith.com>; from israel@lith.com on Tue, Jun 12, 2001 at 06:28:22PM -0700
References: <AF020C5FC551DD43A4958A679EA16A15A144BE@mailcluster.lith.com>
Message-ID: <20010612220230.C26826@harmony.cs.rit.edu>

On Tue, Jun 12, 2001 at 06:28:22PM -0700, Israel Evans wrote:
| 
| I have two problems here.
| 
| The first is that I use windows 2000 at work( ok make that three problems )
| and when I set a PYTHONPATH, things get screwy and tools like IDLE don't
| start up.  I can still run some programs, but not all.  If I delete
| PYTHONPATH everything works great, however setting PATH to accept the few
| exterior python directories that I've created doesn't seem to do anything
| and modules can't be found when I import them.

PYTHONPATH is analogous to CLASSPATH in Java.  It is an environment
variable that contains a path list of root directories for python
modules/packages.  I don't know why IDLE would get weird, unless maybe
you left out something it needs.

PATH is a shell variable that contains a path list to search for
executables in.  If you go to the shell prompt (C:\>) and type
'python', the shell will search through PATH until it finds
python.exe.  Same goes if you type 'foobar', though most likely you
don't have 'foobar.exe' in PATH so it complains that it can't find it.

| The, now third problem is that I use windows98 at home ( four....  four
| problems!)..  and I must ask you how in the bloody blue blazes does one set
| the environment variables in the config.sys or autoexec.bat/tsh thingamabobs
| anyway?

Use a text editor (notepad will suffice though I prefer vim) and add
the lines


set PATH C:\python21;%PATH%
set PYTHONPATH C:\python21\Lib;C:\your_python_modules


to the bottom :-).

-D 



From dsh8290@rit.edu  Wed Jun 13 03:07:57 2001
From: dsh8290@rit.edu (D-Man)
Date: Tue, 12 Jun 2001 22:07:57 -0400
Subject: [Tutor] Funny response
Message-ID: <20010612220757.D26826@harmony.cs.rit.edu>

Hi all.  

I just got an automated response from mailman after posting a reply to
a question.  It starts out with :

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This automated response is sent to those of you new to the Tutor list,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

LOL!  I guess mailman got confused and thought I was new.

:-)

-D



From mattvogel@hotmail.com  Wed Jun 13 03:14:52 2001
From: mattvogel@hotmail.com (Matthew Vogel)
Date: Wed, 13 Jun 2001 02:14:52
Subject: [Tutor] outputting HTML
Message-ID: <F207w7MurDy8ZALg7Gk0000f293@hotmail.com>

<html><DIV>Hi,</DIV>
<DIV>I am a newbie to python programming and i am having some trouble getting started in what i want to do.&nbsp; I have written a C program that calls different functions in a library that i also wrote, in order to determine what records(name type and value) are stored in a given file. Now my problem is that i need to use python to output these values to an html file. </DIV>
<DIV>I&nbsp;know i need to use the os.popen() function to open the file that the user will enter as a command line argument when i run the main.py file ie (main.py filename). </DIV>
<DIV>The question is , once i run my c program from inside python to manipulate this data how do i output to html??</DIV>
<DIV>What functions are there in which i can output in html format, if i have already written an html page with headers and such????</DIV>
<DIV>any help would be appreciated greatly </DIV>
<DIV>thanks Matt</DIV>
<DIV>&nbsp;</DIV><br clear=all><hr>Get Your Private, Free E-mail from MSN Hotmail at <a href="http://www.hotmail.com">http://www.hotmail.com</a>.<br></p></html>


From rob@jam.rr.com  Wed Jun 13 05:06:29 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Tue, 12 Jun 2001 23:06:29 -0500
Subject: [Tutor] outputting HTML
References: <F207w7MurDy8ZALg7Gk0000f293@hotmail.com>
Message-ID: <3B26E6C5.249A479A@jam.rr.com>

Matthew Vogel wrote:
> 
> Hi,
> I am a newbie to python programming and i am having some trouble
> getting started in what i want to do.  I have written a C program that
> calls different functions in a library that i also wrote, in order to
> determine what records(name type and value) are stored in a given
> file. Now my problem is that i need to use python to output these
> values to an html file.
> I know i need to use the os.popen() function to open the file that the
> user will enter as a command line argument when i run the main.py file
> ie (main.py filename).
> The question is , once i run my c program from inside python to
> manipulate this data how do i output to html??
> What functions are there in which i can output in html format, if i
> have already written an html page with headers and such????
> any help would be appreciated greatly
> thanks Matt
> 

Sounds like fun! (heehee) Were you looking for info on generating the
HTML, writing it to a file, or both? An example of a rudimentary web
page maker from the Useless Python collection may be found here:

http://www.lowerstandard.com/python/braindead.py

You may find something of value in it.

Happy Hacking,
Rob

As foretold by Nostradamus....
Useless Python!
http://www.lowerstandard.com/python


From wheelege@tsn.cc  Wed Jun 13 06:35:06 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Wed, 13 Jun 2001 15:35:06 +1000
Subject: [tutor] PATH vs PYTHONPATH on win98 and win2000?
References: <AF020C5FC551DD43A4958A679EA16A15A144BE@mailcluster.lith.com>
Message-ID: <00fc01c0f3ca$9ad0ea60$0200a8c0@ACE>

> <...>
>
> The, now third problem is that I use windows98 at home ( four....  four
> problems!)..  and I must ask you how in the bloody blue blazes does one
set
> the environment variables in the config.sys or autoexec.bat/tsh
thingamabobs
> anyway?
>

  tsh??  You should first check if your autoexec.bat and config.sys are
being executed by going to Start->Run->msconfig, and verifying that the two
boxes named 'Process xxx file' are checked.
  Then you can append what D-Man said...although of course I could be
totally off the mark and in that case it would be wise to ignore me :)

  Glen.



From dyoo@hkn.eecs.berkeley.edu  Wed Jun 13 07:18:37 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Tue, 12 Jun 2001 23:18:37 -0700 (PDT)
Subject: [Tutor] Grabbing the member functions of an instance?
Message-ID: <Pine.LNX.4.21.0106122315540.9988-100000@hkn.eecs.berkeley.edu>

Out of curiosity, is there a better way of pulling out all the member
functions from an instance?  Here's what I have so far:

###
## Python must have something like this already... but I can't recall
## it at the moment.  *sigh*
def getBoundMembers(myinstance):
    """Returns all the member functions in a dictionary.
    
Note: it does not yet look at inherited methods."""
    dict = {}
    myclass = myinstance.__class__
    for member_name in myclass.__dict__.keys():
        dict[member_name] = getattr(myinstance, member_name)
    return dict
###

I'm planning to use this function with a small toy game I'm making; as
soon as I get it working, I'll be a happy person.  *grin*

Thanks for any help!



From toodles@yifan.net  Wed Jun 13 08:19:35 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Wed, 13 Jun 2001 15:19:35 +0800
Subject: FW: [Tutor] Uncallable class methods?
Message-ID: <FPEHJJPEEOIPMAHOADBKCEBDCEAA.toodles@yifan.net>

Sorry Roeland!

> -----Original Message-----
> From: Andrew Wilkins [mailto:toodles@yifan.net]
> Sent: Tuesday, 12 June 2001 10:12 PM
> To: Roeland Rengelink
> Subject: RE: [Tutor] Uncallable class methods?
>
>
> <schnip/>
>
> > > Quick question about the following piece of code:
> > >
> > > >>> class X:
> > > ..   def y():
> > > ..     print 'I am y of x.'
> > >
> > > Is there anyway that y can be invoked? My understanding is no,
> > in which case, can anyone tell me why the interpreter doesn't
> > complain about a class method being declared which does not have
> > the minimum of one argument?
> > >
>
> Okey dokey I just thought I'd give another answer to the
> question, which also has the same useful nature of any of them *grin*
>
> import new
>
> class X:
>  def y():
>   print 'I am y of x'
>
> func=new.function(X.y.func_code,X.y.func_globals)
>
> It doesn't look as pretty as Roeland's IMO, but I felt like
> playing with the 'new' module =)
>
> Andrew Wilkins




From r.b.rigilink@chello.nl  Wed Jun 13 08:27:24 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Wed, 13 Jun 2001 09:27:24 +0200
Subject: [Tutor] Grabbing the member functions of an instance?
References: <Pine.LNX.4.21.0106122315540.9988-100000@hkn.eecs.berkeley.edu>
Message-ID: <3B2715DC.C125BCCC@chello.nl>

Hi Daniel,

I wouldn't call it better. But this looks as base classes too, and only
returns methods, not other objects.

You also might want to have a look at the inspect module.

Here goes:

import types, new
def method_dict(klass, inst):
    '''get a dict of all method_names:method in klass, bound to inst'''
    # We have to invert the look-up order, first look into bases
right-to-left
    d = {}
    bases = list(klass.__bases__)
    bases.reverse()
    for baseklass in bases:
        d.update(method_dict(baseklass, inst))
    # now look in the class itself
    for key, val in klass.__dict__.items():
        if type(val) == types.FunctionType:
            d[key] = new.instancemethod(val, inst, klass)
    return d
    
def methods(inst):
    '''returns dict of bound methods'''
    return method_dict(inst.__class__, inst)

class X:
    def dox(self):
        print 'Hi'

    def doy(self):
        print 'Yo'

class Y(X):
    def doy(self):
        print 'Ok'

y = Y()
print methods(y)
print y.dox, y.doy

Hope this helps,

Roeland

Daniel Yoo wrote:
> 
> Out of curiosity, is there a better way of pulling out all the member
> functions from an instance?  Here's what I have so far:
> 
> ###
> ## Python must have something like this already... but I can't recall
> ## it at the moment.  *sigh*
> def getBoundMembers(myinstance):
>     """Returns all the member functions in a dictionary.
> 
> Note: it does not yet look at inherited methods."""
>     dict = {}
>     myclass = myinstance.__class__
>     for member_name in myclass.__dict__.keys():
>         dict[member_name] = getattr(myinstance, member_name)
>     return dict
> ###
> 
> I'm planning to use this function with a small toy game I'm making; as
> soon as I get it working, I'll be a happy person.  *grin*
> 
> Thanks for any help!
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From toodles@yifan.net  Wed Jun 13 08:45:05 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Wed, 13 Jun 2001 15:45:05 +0800
Subject: [Tutor] Grabbing the member functions of an instance?
In-Reply-To: <Pine.LNX.4.21.0106122315540.9988-100000@hkn.eecs.berkeley.edu>
Message-ID: <FPEHJJPEEOIPMAHOADBKKEBDCEAA.toodles@yifan.net>

Hi Daniel,

> Out of curiosity, is there a better way of pulling out all the member
> functions from an instance?  Here's what I have so far:

How about using inspect? (Are you using Python v 2.1?)
I think someone recently spoke about inspect...in fact I thought it was you
^_^

I don't know a whole lot about inspect, but I'll give it a shot...

import inspect

def getBoundMembers(myinstance):
 dict={}
 members=inspect.getmembers(myinstance.__class__)
 for member in members:
  if inspect.ismethod(member[1]):
   dict[member[0]]=member[1]
 return dict

Actually now that I look at it, it is more work *grin*

Andrew Wilkins

>
> ###
> ## Python must have something like this already... but I can't recall
> ## it at the moment.  *sigh*
> def getBoundMembers(myinstance):
>     """Returns all the member functions in a dictionary.
>
> Note: it does not yet look at inherited methods."""
>     dict = {}
>     myclass = myinstance.__class__
>     for member_name in myclass.__dict__.keys():
>         dict[member_name] = getattr(myinstance, member_name)
>     return dict
> ###
>
> I'm planning to use this function with a small toy game I'm making; as
> soon as I get it working, I'll be a happy person.  *grin*
>
> Thanks for any help!
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>




From hanna@chagford.com  Wed Jun 13 20:26:26 2001
From: hanna@chagford.com (Hanna Joo)
Date: Wed, 13 Jun 2001 12:26:26 -0700
Subject: [Tutor] Threads threads threads gaaahgh (foaming at the mouth)
Message-ID: <003801c0f43e$c1e16de0$0100007f@localdomain>

Big thanks to those who helped me. This is the updated version of the
producer consumer thing.

The problem now is getting 'notify' and 'wait' working. The reference book
says that I those are the methods of condition variables (boohoohoo english
is not even my first language and people do this to me). I went through
chapters on threads again, but I still don't really get it. help please
T_____T  (tears streaming down).

TIA



import threading
from random import randint


class Soup:

 def __init__(self):
  self.next = 0
  self.isFull = 0
  self.isEmpty = 1
  self.buff = ""

 def eat(self):

  while self.isEmpty:
   try : wait()  #########
   except: pass

  self.next = self.next - 1

  if not self.next:
   self.isEmpty = 1

  self.isFull = 0
  notify()     ########=======> how to do this?

  return self.buff[next]


 def add(self,c):
  while self.isFull:
   try: wait()    ########===========> this as well
   except: pass
  self.buff = self.buff[:self.next]+c+self.buff[self.next:]
  self.next += 1

  if self.next == len(self.buff):
    self.isFull= 1
  self.isEmpty = 0
  notify()     #####

class Consumer:


 def __init__(self,soup):
  self.soup = soup

 def run(self):

  for i in range(10) :
   c = self.soup.eat();
   print "Ate a letter "+c

   try:
    sleep(randint(1,3))

   except:
    pass

class Producer:


 def __init__(self,soup):
  self.soup = soup
  self.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

 def run(self):

  for i in range(10):
   c = self.alphabet[randint(1,27)]
   self.soup.add(c);
   print "Added "+c+" to the soup"
   try: sleep(randint(1,3))
   except: pass


def main():

 s = Soup()

 p1 = Producer(s)
 s1 = Consumer(s)

 t1 = threading.Thread(target=p1.run)
 t2 = threading.Thread(target=s1.run)

 t1.start()
 t2.start()

 try :

  t1.join()
  t2.join()

 except:

  print "The producer or consumer thread's join() was interrupted..."



if __name__ == '__main__':
 main()



From kromag@nsacom.net  Wed Jun 13 16:02:39 2001
From: kromag@nsacom.net (kromag@nsacom.net)
Date: Wed, 13 Jun 2001 08:02:39 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind!
Message-ID: <200106131502.f5DF2dg12285@pop.nsacom.net>

> 
> Let's look at the rest of the program:
> 
> > import string
> > import thread
> > 
> > engine=win32com.client.Dispatch("DAO.DBEngine.35")
> > db=engine.OpenDatabase("windowsdesktopterror.mdb")
> 
> Ok, I'm not imagining things after all.  *grin* There are backslashes on
> this line: can you double check?


But, but, but..... Really! I am looking at the code I pasted in! It has 
double backslashes! What manner of madness? Surely your mail agent doesn't 
parse them into links? Anyway, I tried it with the r"pathtofile" method 
and got the same error:

>pythonw -u dbwrong.py
Unhandled exception in thread:
Traceback (most recent call last):
  File "dbwrong.py", line 15, in write
    db.Execute("insert into data values(%f, '%s')" % inputtage)
AttributeError: 'None' object has no attribute 'Execute'
>Exit code: 0

Ah well. I am going to not think about it for a week. That has traditionally 
been the length of time it takes for the answer to coalesce out of the 
aether! :-)

Thanks for your efforts!

d




From pobrien@orbtech.com  Wed Jun 13 15:12:00 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 13 Jun 2001 09:12:00 -0500
Subject: [tutor] PATH vs PYTHONPATH on win98 and win2000?
In-Reply-To: <20010612220230.C26826@harmony.cs.rit.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBEEHEKAAA.pobrien@orbtech.com>

This might seem like nitpicking, but it isn't necessary to add Lib to your
PYTHONPATH. At least not with version 2.1, because python adds lib (and
several other directories) automatically.

Here is a copy of my entire autoexec.bat on my Win98SE machine:

SET PATH=C:\Python21
SET PYTHONPATH=C:\My Documents\pobrien\Code
SET PYTHONSTARTUP=C:\My Documents\pobrien\.pythonrc.py

---
And here is an interactive session showing the resulting python path
(sys.path):

Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>> import sys
>>> sys.path
['C:\\My Documents\\pobrien\\Code', 'C:\\PYTHON21\\Tools\\idle', 'c:\\my
documents\\pobrien\\code', 'c:\\python21\\win32',
'c:\\python21\\win32\\lib', 'c:\\python21', 'c:\\python21\\pythonwin',
'c:\\python21\\dlls', 'c:\\python21\\lib', 'c:\\python21\\lib\\plat-win',
'c:\\python21\\lib\\lib-tk', 'c:\\python21\\numeric']
>>>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
D-Man
Sent: Tuesday, June 12, 2001 9:03 PM
To: 'Tutor@python.org'
Subject: Re: [tutor] PATH vs PYTHONPATH on win98 and win2000?

<snip>

Use a text editor (notepad will suffice though I prefer vim) and add
the lines


set PATH C:\python21;%PATH%
set PYTHONPATH C:\python21\Lib;C:\your_python_modules


to the bottom :-).

-D


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From allan.crooks@btinternet.com  Wed Jun 13 17:13:14 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Wed, 13 Jun 2001 17:13:14 +0100
Subject: [Tutor] Threads threads threads gaaahgh (foaming at the mouth)
Message-ID: <E15ADKi-0003Hi-00@tungsten.btinternet.com>

After having a quick look at the threading library, I started adjusting your code in quite a few ways.

First of all, here's the code you submitted:
> import threading
> from random import randint
> 
> 
> class Soup:
> 
>  def __init__(self):
>   self.next = 0
>   self.isFull = 0
>   self.isEmpty = 1
>   self.buff = ""
> 
>  def eat(self):
> 
>   while self.isEmpty:
>    try : wait()  #########
>    except: pass
> 
>   self.next = self.next - 1
> 
>   if not self.next:
>    self.isEmpty = 1
> 
>   self.isFull = 0
>   notify()     ########=======> how to do this?
> 
>   return self.buff[next]
> 
> 
>  def add(self,c):
>   while self.isFull:
>    try: wait()    ########===========> this as well
>    except: pass
>   self.buff = self.buff[:self.next]+c+self.buff[self.next:]
>   self.next += 1
> 
>   if self.next == len(self.buff):
>     self.isFull= 1
>   self.isEmpty = 0
>   notify()     #####
> 
> class Consumer:
> 
> 
>  def __init__(self,soup):
>   self.soup = soup
> 
>  def run(self):
> 
>   for i in range(10) :
>    c = self.soup.eat();
>    print "Ate a letter "+c
> 
>    try:
>     sleep(randint(1,3))
> 
>    except:
>     pass
> 
> class Producer:
> 
> 
>  def __init__(self,soup):
>   self.soup = soup
>   self.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> 
>  def run(self):
> 
>   for i in range(10):
>    c = self.alphabet[randint(1,27)]
>    self.soup.add(c);
>    print "Added "+c+" to the soup"
>    try: sleep(randint(1,3))
>    except: pass
> 
> 
> def main():
> 
>  s = Soup()
> 
>  p1 = Producer(s)
>  s1 = Consumer(s)
> 
>  t1 = threading.Thread(target=p1.run)
>  t2 = threading.Thread(target=s1.run)
> 
>  t1.start()
>  t2.start()
> 
>  try :
> 
>   t1.join()
>   t2.join()
> 
>  except:
> 
>   print "The producer or consumer thread's join() was interrupted..."
> 
> 
> 
> if __name__ == '__main__':
>  main()
> 


Here's the modified code. The comments (#01, #02 etc.) are used as markers, so I can illustrate how your code has been modified.

import threading
from time import sleep #01
from random import randrange #02

class Soup:

 def __init__(self):
  self.next = 0
  self.isFull = 0
  self.isEmpty = 1
  self.buff = ""
  self.lock = threading.Condition() #03

 def eat(self):
  self.lock.acquire() #04
  while self.isEmpty:
    self.lock.wait()  #05

  self.next = self.next - 1

  if not self.next:
   self.isEmpty = 1

  self.isFull = 0
  self.lock.notify() #06

  self.lock.release() #07
  return self.buff[self.next] #08


 def add(self,c):
  self.lock.acquire() #09
  while self.isFull:
    self.lock.wait() #10
  self.buff = self.buff[:self.next]+c+self.buff[self.next:]
  self.next += 1

  if self.next == len(self.buff):
    self.isFull = 1
  self.isEmpty = 0
  self.lock.notify() #11
  self.lock.release() #12

class Consumer:


 def __init__(self,soup):
  self.soup = soup

 def run(self):

  for i in range(10) :
   c = self.soup.eat();
   print "Ate a letter", c #13
   sleep(randrange(1,5)) #14

class Producer:


 def __init__(self,soup):
  self.soup = soup
  self.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

 def run(self):

  for i in range(10):
   c = self.alphabet[randrange(26)] #15
   self.soup.add(c);
   print "Added", c, "to the soup" #16
   sleep(randrange(1,3)) #17


def main():

 s = Soup()

 p1 = Producer(s)
 s1 = Consumer(s)

 t1 = threading.Thread(target=p1.run)
 t2 = threading.Thread(target=s1.run)

 t1.start()
 t2.start()

 try :

  t1.join()
  t2.join()

 except:

  print "The producer or consumer thread's join() was interrupted..."



if __name__ == '__main__':
 main()



--------------

OK, so here's an explanation of the changes.

#01: You forgot to import sleep from the time module.
#02: We're using randrange instead of randint, because randrange(x,y) will return a number between x (inclusive) and y (exclusive). randint returns a number between x (inclusive) and y (inclusive). It doesn't make much of a difference, it's just what I've chosen to use.
#03: We're using "condition" objects to deal with locking and unlocking. We need to use these so we can do notify() and wait().
#04: Here we've "acquired" the lock. We need to do this before we can do "wait" or "notify"
#05: Now we're using the condition object and waiting on it.
#06: This is the notify that you wanted to put in the code, and we're just invoking the method on the condition object.
#07: We must remember to release the lock once we have finished.
#08: Your code said "return self.buff[next]". What we meant was: "return self.buff[self.next]".
#09: Same as #04.
#10: Same as #05.
#11: Same as #06.
#12: Same as #07.
#13: Doesn't do anything different, but it looks nicer than "Ate a letter "+c. :)
#14: We're just using the randrange method. You may have noticed I adjusted the parameters for randrange, that's because I was just testing with different parameters.
#15: The initial version was more complicated. First of all, the code assumed that the string indexed from 1 (it doesn't). Secondly, changing 1, 27 to 0, 26 still didn't work, because randint may pick a number from 0 to 26, including 26 itself (which is an invalid index). So we can change it either to randint(0,25) or randrange(0,26). I've chosen the randrange option.
#16: Same as #13, it looks nicer. :)
#17: Just using randrange again.

Now having changed that code, I get this:

>>> soup.main()
Ate a letter Y
Added Y to the soup
Ate a letter R
Added R to the soup
Added M to the soup
Added X to the soup
Ate a letter X
Added A to the soup
Added F to the soup
Ate a letter F
Added S to the soup
Added A to the soup
Added G to the soup
Ate a letter G
Added P to the soup
Ate a letter P
Ate a letter A
Ate a letter S
Ate a letter A
Ate a letter M

The code takes several seconds to execute. It seems to work properly.

There are a few more things I feel I should point out about your code for the sake of improvements:
  1) You don't need to use a "next" variable, you can simply use the len function.
  2) I think it'd be easier and nicer to write if you used a list object for a buffer instead of a string.
       That way, the line in the eat function:
          return self.buff[self.next]
       would become:
          return self.buff.pop()

        And the line in the add function:
          self.buff = self.buff[:self.next]+c+self.buff[self.next:]
        would become:
          self.buff.append(c)
   3) Your code had too many "excepts" in it. That in itself is not a bad thing, but you were using "except:" rather than catching any specific errors (e.g. "except: (AttributeError, IndexError), e"). That's definitely something you should aim to change in your programs in the future. For example, your code in the run method of Consumer had these lines in it:

>    try:
>     sleep(randint(1,3))
> 
>    except:
>     pass

Invoking the sleep function doesn't actually raise any exception, but in the code supplied, sleep was undefined (because it wasn't imported). But because you use caught all types of exceptions (including NameErrors), it was harder to track down why no thread seemed to be waiting. If you want to catch a particular exception, you should explicitly state their types, otherwise errors which you would want to get through will not.

HTH,
Allan.



From DavidCraig@PIA.CA.GOV  Wed Jun 13 18:01:02 2001
From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV)
Date: Wed, 13 Jun 2001 10:01:02 -0700
Subject: [Tutor] Python for Web Applications - Off Topic
Message-ID: <OF78EAC443.B2364520-ON88256A6A.005CEA5B@PIA.CA.GOV>

This came out this morning from Open Source  - Interesting

ONE SIZE FITS MOST

Posted at June 8, 2001 01:01 PM PST Pacific


THIS WEEK I finally make good on my promise to take a
closer look at Python for building Web applications.

Python is a Javalike language in some of the most
important respects. It is byte-compiled and therefore
platform-neutral. It sports automatic garbage
collection, which means you won't have to worry about
cleaning up after Python objects when you're done with
them. And it handles exceptions well, enabling you to
make your programs more robust.

Unlike Java, Python does not need type declarations,
which means a variable becomes a string type simply by
setting it to a string value. That is one reason it
seems to take a lot less work to crank out a quick and
dirty application in Python than it does using Java.

Python has a long list of available expansion modules
to give your Python Web application access to LDAP,
IMAP4 (Internet Messaging Access Protocol 4), POP
(Post Office Protocol), SMTP, NNTP (Network News
Transfer Protocol), among other Internet resources.
There is also a number of generic database interfaces
to popular SQL servers. If Web applications aren't
your thing, you can still use Python to create
anything from simple command-line scripts to
full-blown graphical applications using the Troll Tech
Qt GUI toolkit.

You can use several methods to add Python capability to
your Web server, and they are not necessarily mutually
exclusive. I have set up my servers to run Python in a
number of different ways, according to need.

The simplest and most efficient way to add Python to
Apache is to use the mod_python interface, available
at www.modpython.org. When you use this module, you
generally publish information to the browser by using
the "req.write()" command.

This Apache module isn't terribly useful by itself, but
it comes with a mod_python publisher module that makes
it much easier to use Python to write Web
applications. When you configure Apache to use the
mod_python publisher, you can execute Python functions
by pointing to the Python application, followed by the
function you want to run. For example, if you want to
run the "say_hello" function in the "welcome.py"
program, point your browser to
"http://somesite.domain/welcome/say_hello."

The only drawback to the publisher module is that it
writes information to the browser based only on the
information a function returns. This means that you
have to create a Web page by assembling a long string
or an array and then passing it to the browser all at
once at the end of the function.

This approach can work to your advantage, depending on
the type of application you are building. If you must
assemble each page by combining parts into a whole,
you will probably spend more time thinking about which
parts to create. You are likely to think through how
you should break up your Web site content so that you
end up with a site that doesn't break the first time
you need to add a module or change the appearance of a
page.

Of course, that doesn't mean you can't be sloppy if you
want to be. If you're spoiled on the freedom afforded
by a Web language such as PHP (Hypertext PreProcessor,
www.php4.org), you can always use PSP. I used PSP via
a toolkit known as Webware for Python
(webware.sourceforge.net). PSP uses almost the same
syntax as Java Server Pages (JSP), so it's easy to
bounce between the two if you're used to one or the other.

At the other extreme, the WebKit portion of Webware for
Python really carries Python into the big leagues for
Web application development. WebKit includes a
multithreaded application server that runs alongside
Apache. The WebKit server serves up the Python
applications more intelligently than mod_python alone
or the mod_python publisher. In fact, although WebKit
can use mod_python as its default Python extension to
Apache, WebKit comes with its own Apache module in
case you don't want or need mod_python.

If you are serious about using Python to develop for
the Web, I strongly recommend that you look at WebKit
and the sample applications. The samples aren't
pretty, but they demonstrate the power of Python's
object-oriented nature when it comes to building the
framework for a Web application and then extending it
as needed.

Be sure to visit the online version of this column for
examples of Python Server Pages, mod_python, and the
mod_python publisher if you want a closer look. I also
will be publishing detailed examples on VarLinux.org
(www.varlinux.org).

Finally, some readers have pointed me to Ruby, a
Pythonlike language which is yet another alternative.
I haven't yet had the time to check it out, but when I
do I'll let you know what I find.

PSP example

Here is an example of how to Python within a server
page, my least favorite way to use Python, I might
add. This file could be called "welcome.psp," which
has the .psp extension to alert Apache that this is a
Python Server Page.  For a sample Apache configuration
to run PSP, see the last example at the bottom.

<html> <head> <title>Welcome</title> </head> <body> <%
title = "<H1>Welcome to the world of Python</H1>"
greeting = "If you lived here, you'd be home by now"
res.write(title) res.write("<P>")res.write(greeting)
%></body></html>



mod_python example

Here is an example of using Python with the simplest
mod_python approach.  You would create a file called
"welcome.py" with the following content.

from mod_python import apache

def handler(req): title = "<H1>Welcome to the world of
mod_python</H1><P>"greeting = "If you lived here, etc."



req.content_type = "text/html"req.send_http_header()
req.write(title) req.write(greeting)



return apache.OK

Then you must create an entry for this file in your
Apache configuration file "httpd.conf".  That entry
might look something like the following, assuming you
have named the above file "welcome.py" and put it in a
directory called "/python." Note that it is the
"PythonHandler" statement that points to the
welcome.py file (the ".py" extension is not needed
here since it is assumed).

<Directory /python> AddHandler python-program .py
PythonHandler welcome </Directory>



The browser accesses this Python file with a URL such
as "http://somesite.domain/welcome." The mod_python
module automatically executes the handler function for
the file "welcome.py."

In most cases, this isn't a terribly useful means of
using Python for Web applications because there can be
only one Python handler file for each directory.  A
reasonable application would span many directories,
each with its own handler.

mod_python example using Publisher Handler

The mod_python module comes with a Publisher Handler
that allows you to create Web applications using fewer
Python files and directories.  You can create many
functions for your Python programs, and you can
reference these functions directly through URLs. For
example, if you want to execute the "say_hello"
function in the "welcome.py" program, you would use
the URL "http://somesite.domain/welcome/say_hello."
Use the URL
"http://somesite.domain/welcome/say_goodbye" to access
the "say_goodbye" function.

For the simplest configuration, just add lines such as
these to your Apache configuration file to activate
the publisher.

AddHandler python-program .py PythonHandler
mod_python.publisher



Then you can create "welcome.py" to include the
following.



def say_goodbye():s = "<H1>Thanks for visiting!</H1>"
return s



def say_hello(): h1open = "<H1>" h1close = "</H1>" s =
h1open + "Welcome to mod_python publisher." + h1close
return s



The mod_python publisher sends text, HTML, or whatever
you choose to a browser depending on what a function
returns. In the example above, each function returns
string "s," which contains different text depending on
the function.

Combinations

Here is a sample way to configure Apache if you want to
use Python according to your varying needs. This
configuration allows you to use mod_python to run
either mod_python publisher-based applications, Python
Server Pages, or the more sophisticated Webware
applications via WebKit. You should adjust the
configuration to work with the way you have installed
software on your particular server. My test system is
Debian-based, which is why the Web data is placed
under the "/var/www" directory.

<IfModule mod_python.c> AddHandler python-program .psp
PythonPath "sys.path+['/var/www/Webware/WebKit']"
PythonHandler ModPythonAdapter::pspHandler PythonDebug
On



Alias /python/ /var/www/python/ <Location
/python>AddHandler python-program .py SetHandler
python-program PythonPath
"sys.path+['/var/www/python', '/python']"
PythonHandler mod_python.publisher Options +ExecCGI
PythonDebug On </Location>



Alias /webware/ /var/www/Webware/WebKit/ <Location
/webware> AddHandler python-program .py SetHandler
python-program # add the directory that contains
ModPythonAdapter.py PythonPath
"sys.path+['/var/www/Webware/WebKit']" PythonHandler
ModPythonAdapter Options +ExecCGI PythonDebug On
</Location> </IfModule>

Nick Petreley is the founding editor of VarLinux.org
(www.varlinux.org) and LinuxWorld. Reach him at
nicholas@petreley.com.
D. H. Craig, CSM




From pdiaz88@terra.es  Wed Jun 13 22:42:50 2001
From: pdiaz88@terra.es (Pedro Diaz Jimenez)
Date: Wed, 13 Jun 2001 21:42:50 +0000
Subject: [Tutor] Python for Web Applications - Off Topic
In-Reply-To: <OF78EAC443.B2364520-ON88256A6A.005CEA5B@PIA.CA.GOV>
References: <OF78EAC443.B2364520-ON88256A6A.005CEA5B@PIA.CA.GOV>
Message-ID: <01061321425000.06281@duero>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Funny he/she didn't Zope, right?

Cheers
Pedro

On Wednesday 13 June 2001 17:01, DavidCraig@PIA.CA.GOV wrote:
> This came out this morning from Open Source  - Interesting
>
> ONE SIZE FITS MOST
>
> Posted at June 8, 2001 01:01 PM PST Pacific
>
>
> THIS WEEK I finally make good on my promise to take a
> closer look at Python for building Web applications.
>
> Python is a Javalike language in some of the most
> important respects. It is byte-compiled and therefore
> platform-neutral. It sports automatic garbage
> collection, which means you won't have to worry about
> cleaning up after Python objects when you're done with
> them. And it handles exceptions well, enabling you to
> make your programs more robust.
>
> Unlike Java, Python does not need type declarations,
> which means a variable becomes a string type simply by
> setting it to a string value. That is one reason it
> seems to take a lot less work to crank out a quick and
> dirty application in Python than it does using Java.
>
> Python has a long list of available expansion modules
> to give your Python Web application access to LDAP,
> IMAP4 (Internet Messaging Access Protocol 4), POP
> (Post Office Protocol), SMTP, NNTP (Network News
> Transfer Protocol), among other Internet resources.
> There is also a number of generic database interfaces
> to popular SQL servers. If Web applications aren't
> your thing, you can still use Python to create
> anything from simple command-line scripts to
> full-blown graphical applications using the Troll Tech
> Qt GUI toolkit.
>
> You can use several methods to add Python capability to
> your Web server, and they are not necessarily mutually
> exclusive. I have set up my servers to run Python in a
> number of different ways, according to need.
>
> The simplest and most efficient way to add Python to
> Apache is to use the mod_python interface, available
> at www.modpython.org. When you use this module, you
> generally publish information to the browser by using
> the "req.write()" command.
>
> This Apache module isn't terribly useful by itself, but
> it comes with a mod_python publisher module that makes
> it much easier to use Python to write Web
> applications. When you configure Apache to use the
> mod_python publisher, you can execute Python functions
> by pointing to the Python application, followed by the
> function you want to run. For example, if you want to
> run the "say_hello" function in the "welcome.py"
> program, point your browser to
> "http://somesite.domain/welcome/say_hello."
>
> The only drawback to the publisher module is that it
> writes information to the browser based only on the
> information a function returns. This means that you
> have to create a Web page by assembling a long string
> or an array and then passing it to the browser all at
> once at the end of the function.
>
> This approach can work to your advantage, depending on
> the type of application you are building. If you must
> assemble each page by combining parts into a whole,
> you will probably spend more time thinking about which
> parts to create. You are likely to think through how
> you should break up your Web site content so that you
> end up with a site that doesn't break the first time
> you need to add a module or change the appearance of a
> page.
>
> Of course, that doesn't mean you can't be sloppy if you
> want to be. If you're spoiled on the freedom afforded
> by a Web language such as PHP (Hypertext PreProcessor,
> www.php4.org), you can always use PSP. I used PSP via
> a toolkit known as Webware for Python
> (webware.sourceforge.net). PSP uses almost the same
> syntax as Java Server Pages (JSP), so it's easy to
> bounce between the two if you're used to one or the other.
>
> At the other extreme, the WebKit portion of Webware for
> Python really carries Python into the big leagues for
> Web application development. WebKit includes a
> multithreaded application server that runs alongside
> Apache. The WebKit server serves up the Python
> applications more intelligently than mod_python alone
> or the mod_python publisher. In fact, although WebKit
> can use mod_python as its default Python extension to
> Apache, WebKit comes with its own Apache module in
> case you don't want or need mod_python.
>
> If you are serious about using Python to develop for
> the Web, I strongly recommend that you look at WebKit
> and the sample applications. The samples aren't
> pretty, but they demonstrate the power of Python's
> object-oriented nature when it comes to building the
> framework for a Web application and then extending it
> as needed.
>
> Be sure to visit the online version of this column for
> examples of Python Server Pages, mod_python, and the
> mod_python publisher if you want a closer look. I also
> will be publishing detailed examples on VarLinux.org
> (www.varlinux.org).
>
> Finally, some readers have pointed me to Ruby, a
> Pythonlike language which is yet another alternative.
> I haven't yet had the time to check it out, but when I
> do I'll let you know what I find.
>
> PSP example
>
> Here is an example of how to Python within a server
> page, my least favorite way to use Python, I might
> add. This file could be called "welcome.psp," which
> has the .psp extension to alert Apache that this is a
> Python Server Page.  For a sample Apache configuration
> to run PSP, see the last example at the bottom.
>
> <html> <head> <title>Welcome</title> </head> <body> <%
> title = "<H1>Welcome to the world of Python</H1>"
> greeting = "If you lived here, you'd be home by now"
> res.write(title) res.write("<P>")res.write(greeting)
> %></body></html>
>
>
>
> mod_python example
>
> Here is an example of using Python with the simplest
> mod_python approach.  You would create a file called
> "welcome.py" with the following content.
>
> from mod_python import apache
>
> def handler(req): title = "<H1>Welcome to the world of
> mod_python</H1><P>"greeting = "If you lived here, etc."
>
>
>
> req.content_type = "text/html"req.send_http_header()
> req.write(title) req.write(greeting)
>
>
>
> return apache.OK
>
> Then you must create an entry for this file in your
> Apache configuration file "httpd.conf".  That entry
> might look something like the following, assuming you
> have named the above file "welcome.py" and put it in a
> directory called "/python." Note that it is the
> "PythonHandler" statement that points to the
> welcome.py file (the ".py" extension is not needed
> here since it is assumed).
>
> <Directory /python> AddHandler python-program .py
> PythonHandler welcome </Directory>
>
>
>
> The browser accesses this Python file with a URL such
> as "http://somesite.domain/welcome." The mod_python
> module automatically executes the handler function for
> the file "welcome.py."
>
> In most cases, this isn't a terribly useful means of
> using Python for Web applications because there can be
> only one Python handler file for each directory.  A
> reasonable application would span many directories,
> each with its own handler.
>
> mod_python example using Publisher Handler
>
> The mod_python module comes with a Publisher Handler
> that allows you to create Web applications using fewer
> Python files and directories.  You can create many
> functions for your Python programs, and you can
> reference these functions directly through URLs. For
> example, if you want to execute the "say_hello"
> function in the "welcome.py" program, you would use
> the URL "http://somesite.domain/welcome/say_hello."
> Use the URL
> "http://somesite.domain/welcome/say_goodbye" to access
> the "say_goodbye" function.
>
> For the simplest configuration, just add lines such as
> these to your Apache configuration file to activate
> the publisher.
>
> AddHandler python-program .py PythonHandler
> mod_python.publisher
>
>
>
> Then you can create "welcome.py" to include the
> following.
>
>
>
> def say_goodbye():s = "<H1>Thanks for visiting!</H1>"
> return s
>
>
>
> def say_hello(): h1open = "<H1>" h1close = "</H1>" s =
> h1open + "Welcome to mod_python publisher." + h1close
> return s
>
>
>
> The mod_python publisher sends text, HTML, or whatever
> you choose to a browser depending on what a function
> returns. In the example above, each function returns
> string "s," which contains different text depending on
> the function.
>
> Combinations
>
> Here is a sample way to configure Apache if you want to
> use Python according to your varying needs. This
> configuration allows you to use mod_python to run
> either mod_python publisher-based applications, Python
> Server Pages, or the more sophisticated Webware
> applications via WebKit. You should adjust the
> configuration to work with the way you have installed
> software on your particular server. My test system is
> Debian-based, which is why the Web data is placed
> under the "/var/www" directory.
>
> <IfModule mod_python.c> AddHandler python-program .psp
> PythonPath "sys.path+['/var/www/Webware/WebKit']"
> PythonHandler ModPythonAdapter::pspHandler PythonDebug
> On
>
>
>
> Alias /python/ /var/www/python/ <Location
> /python>AddHandler python-program .py SetHandler
> python-program PythonPath
> "sys.path+['/var/www/python', '/python']"
> PythonHandler mod_python.publisher Options +ExecCGI
> PythonDebug On </Location>
>
>
>
> Alias /webware/ /var/www/Webware/WebKit/ <Location
> /webware> AddHandler python-program .py SetHandler
> python-program # add the directory that contains
> ModPythonAdapter.py PythonPath
> "sys.path+['/var/www/Webware/WebKit']" PythonHandler
> ModPythonAdapter Options +ExecCGI PythonDebug On
> </Location> </IfModule>
>
> Nick Petreley is the founding editor of VarLinux.org
> (www.varlinux.org) and LinuxWorld. Reach him at
> nicholas@petreley.com.
> D. H. Craig, CSM
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

- -- 

/*
 * Pedro Diaz Jimenez
 * pdiaz88@terra.es 
 * pdiaz@acm.asoc.fi.upm.es
 *
 * Wanna see how 100000! looks like?:
 * http://acm.asoc.fi.upm.es/~pdiaz/fact_100.000
 * 
 * La sabiduria me persigue, pero yo soy mas rapido
 * 
 * "Las artes marciales son parte de una filosofía,
 *  no deben ser consideradas un arma. Y por eso,
 *  recuerda: No hay nada como un buen revolver"
 *    Les Luthiers, Iniciacion a las Artes Marciales
 *
 */

Random quote:
- -------------

ROMEO:		Courage, man; the hurt cannot be much.
MERCUTIO:	No, 'tis not so deep as a well, nor so wide
			as a church-door; but 'tis enough, 'twill serve.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7J95gnu53feEYxlERAo3EAJ9GFAhrJ79LEN+G8bEBWi8Xd42VCQCdFWk8
kGwLSWa+83hLNo1TPO/brTk=
=iiGY
-----END PGP SIGNATURE-----


From hall@ouhep1.nhn.ou.edu  Wed Jun 13 21:24:10 2001
From: hall@ouhep1.nhn.ou.edu (Isaac Hall)
Date: Wed, 13 Jun 2001 15:24:10 -0500
Subject: [Tutor] (no subject)
Message-ID: <01061315265100.26218@ouhep1>

hello all (again)
I would like to pose a (hopefully) quick and easy question that is confounding
me.  in a program I am trying to write, it has become apparent to me that I
need to create my own widget to place in a Tk window to accomplish what I need.
 How can I do this???  if I am being to vague, let me know and I will clarify.

thanks
Ike


From mascher@crg.ha.nw.schule.de  Wed Jun 13 21:45:11 2001
From: mascher@crg.ha.nw.schule.de (Christian Mascher)
Date: Wed, 13 Jun 2001 22:45:11 +0200
Subject: [Tutor] PYTHONPATH: where to set on Win9x
Message-ID: <3B27D0D7.30DB0E5@gmx.de>

Hello everyone,

I've been following the recent postings on implementing a
startup-configuration of some sorts, perhaps loading some modules
(pydoc) or setting up the path to arbitrary extra module-directories (my
private modules). As far as I understood the matter, the
module-search-path (shown with 'sys.path') where Python looks for and is
able to find modules must (?) be set via the environment variable
PYTHONPATH. 

But that doesn't seem to be the whole story on windows, because I can
run python and import all standard modules with no explicit PYTHONPATH
set in the environment. (During installation the necessary paths must
have been hardwired into the registry.  For the same reason I can start
idle by "executing" idle.pyw from the shell (explorer) right?).

So I guess I only have to use PYTHONPATH for having my personal
directories turn up in sys.path, is that right? Meaning I only need to
put
set PYTHONPATH=d:\mypython 
in autoexec.bat to include that directory. It works, but is it "the
right way" or did I miss a point?

By the way, is the global autoexec.bat really the best place for putting
this? Normally, when I use a console-started compiler (like javac for
instance), I have an extra .bat-script setting the appropriate
environment-variables only when opening the shell (DOS-box) dedicated to
Java or whatever. So it is possible to add environment variables later.
Could/should this be done for the python shell as well? One could of
course append to sys.path in a standard startupscript, but then I have
to set PYTHONSTARUP first, yes?

Hope I'm not asking the same questions Patrick O'Brien and Daniel Yoo
just sorted out, but I'm really still confused about the issue.

Thanks in advance,
Christian


From rob@jam.rr.com  Wed Jun 13 21:52:48 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 13 Jun 2001 15:52:48 -0500
Subject: [Tutor] (no subject)
References: <01061315265100.26218@ouhep1>
Message-ID: <002801c0f44a$da32e660$de00a8c0@planhouse5>

----- Original Message -----
From: "Isaac Hall" <hall@ouhep1.nhn.ou.edu>
To: <tutor@python.org>
Sent: Wednesday, June 13, 2001 3:24 PM
Subject: [Tutor] (no subject)


> hello all (again)
> I would like to pose a (hopefully) quick and easy question that is
confounding
> me.  in a program I am trying to write, it has become apparent to me that
I
> need to create my own widget to place in a Tk window to accomplish what I
need.
>  How can I do this???  if I am being to vague, let me know and I will
clarify.
>
> thanks
> Ike
>
If you can provide a little more detail about your challenge, it would help.
For instance, what is it that you are trying to do. There are some really
interesting widgets available out there already. Can you show any code that
is tripping you in particular?

Rob

Useless Python
It's not just for breakfast anymore!
http://www.lowerstandard.com/python/index.html



From hall@ouhep1.nhn.ou.edu  Wed Jun 13 21:56:35 2001
From: hall@ouhep1.nhn.ou.edu (Isaac Hall)
Date: Wed, 13 Jun 2001 15:56:35 -0500
Subject: [Tutor] (no subject)
In-Reply-To: <002801c0f44a$da32e660$de00a8c0@planhouse5>
References: <01061315265100.26218@ouhep1> <002801c0f44a$da32e660$de00a8c0@planhouse5>
Message-ID: <01061316152200.27433@ouhep1>

--Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD
Content-Type: text/plain
Content-Transfer-Encoding: 8bit

On Wed, 13 Jun 2001, Rob Andrews wrote:
> ----- Original Message -----
> From: "Isaac Hall" <hall@ouhep1.nhn.ou.edu>
> To: <tutor@python.org>
> Sent: Wednesday, June 13, 2001 3:24 PM
> Subject: [Tutor] (no subject)
> 
> 
> > hello all (again)
> > I would like to pose a (hopefully) quick and easy question that is
> confounding
> > me.  in a program I am trying to write, it has become apparent to me that
> I
> > need to create my own widget to place in a Tk window to accomplish what I
> need.
> >  How can I do this???  if I am being to vague, let me know and I will
> clarify.
> >
> > thanks
> > Ike
> >
> If you can provide a little more detail about your challenge, it would help.
> For instance, what is it that you are trying to do. There are some really
> interesting widgets available out there already. Can you show any code that
> is tripping you in particular?
> 
> Rob
> 
> Useless Python
> It's not just for breakfast anymore!
> http://www.lowerstandard.com/python/index.html

yes I can, specifically Im trying to put several pie charts in a window, that
can be sized and moved about as the user wants. (at least by changing a value
or two) as of now, I can do this by defining a function that makes the piechart
on a canvas which is put in a frame, which is then put in a grid by the grid
geometry manager. however,  the powers that be tell me it would be fantastic if
I could do this by skipping the nasty canvas to frame thing altogether, and
create a piechart widget (or class or something like that), which I could
directly throw into the geometry manager, and hopefully create more ease in
allowing the user to specify location, size, etc.   this is where Im stuck.
Ive attached a sample of what it is Im doing, which works just fine, but they
just want no canvases......  

--Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD
Content-Type: text/x-java;
  name="tester.py"
Content-Transfer-Encoding: base64
Content-Description: test pies
Content-Disposition: attachment; filename="tester.py"

IyEvdXNyL2xvY2FsL2Jpbi9weXRob24KIyBGaWxlOiB0ZXN0My5weQoKZnJvbSBUa2ludGVyIGlt
cG9ydCAqCgoKCmRlZiBtYWtlcGllKHZhbHVlcywgZnJhbWUsIGNudnNpemUsIHBpZXhtaW4sIHBp
ZXhtYXgsIHBpZXltaW4sIHBpZXltYXgpOgoJCgkjZGVmaW5lIGFzIG1hbnkgY29sb3JzIGFzIHdl
IG1pZ2h0IG5lZWQKCgljb2xzID0gWwoJInJlZCIsICJEYXJrR3JlZW4iLCAib3JhbmdlIiwgInll
bGxvdyIsICJwdXJwbGUiLAoJImJsdWUiLAoJImdyZWVuIiwKCSJEb2RnZXJCbHVlIiwiZmlyZWJy
aWNrIiwKCSJGb3Jlc3RHcmVlbiIsICJnYWluc2Jvcm8iLCAiR2hvc3RXaGl0ZSIsImdvbGQiLCAi
Z29sZGVucm9kIiwKCSJncmF5IiwiZ3JlZW4iLCJHcmVlblllbGxvdyIsImhvbmV5ZGV3IiwiSW5k
aWFuUmVkIiwiaXZvcnkiLCJraGFraSIsCQoJIkxpZ2h0Qmx1ZTEiLCAiTGlnaHRDb3JhbCIsIkxp
Z2h0Q3lhbiIsCgkiTGlnaHRTYWxtb24iLCJMaWdodFNlYUdyZWVuIiwgIkxpZ2h0U2t5Qmx1ZSIs
IkxpZ2h0U2xhdGVCbHVlIiwKCSJMaWdodFNsYXRlR3JheSIsIkxpZ2h0U3RlZWxCbHVlIiwiTGln
aHRZZWxsb3ciLCJMaW1lR3JlZW4iLCJtYXJvb24iLAoJIk1lZGl1bUFxdWFtYXJpbmUiLCAiTWVk
aXVtQmx1ZSIsICJNZWRpdW1PcmNoaWQiLCJNZWRpdW1QdXJwbGUiLAoJIk1lZGl1bVNlYUdyZWVu
IiwgIk1lZGl1bVNsYXRlQmx1ZSIsICJNZWRpdW1TcHJpbmdHcmVlbiIsIk1lZGl1bVZpb2xldFJl
ZCIsCgkiTWlkbmlnaHRCbHVlIiwibW9jY2FzaW4iLCJOYXZ5Qmx1ZSIsICJPbGl2ZURyYWIiLCJv
cmFuZ2UiLCJPcmFuZ2VSZWQiLAoJIlBhbGVWaW9sZXRSZWQiLCJQYXBheWFXaGlwIiwicGVydSIs
InBsdW0iLCAicHVycGxlIiwicmVkIiwiUm95YWxCbHVlIiwKCSJTYWRkbGVCcm93biIsICJzYWxt
b24iLCJTYW5keUJyb3duIiwgIlNlYUdyZWVuIiwiU2t5Qmx1ZSIsIlNsYXRlQmx1ZSIsCgkiU2xh
dGVHcmF5IiwiU3ByaW5nR3JlZW4iLCJTdGVlbEJsdWUiLCJ0YW4iLCAidGhpc3RsZSIsInRoaXN0
bGUxIiwKCSJ0b21hdG8iLCJ0dXJxdW9pc2UiLCJWaW9sZXRSZWQiLCJ3aGVhdCIsInllbGxvdyIs
IlllbGxvd0dyZWVuIl0KCgkjaW5pdGFsaXplIGFueSBjb3VudGVycwoJaSA9IDAKCWogPSAwCglr
ID0gMAoJCgkjZmluZCBwZXJjZW50YWdlIG9mIHRvdGFsIGZvciBlYWNoIHZhbHVlIHBhc3NlZCB0
byB0aGUgcGllIGNoYXJ0CglwY3QgPSB2YWx1ZXMKCXN1bSA9IDAuMAoJbCA9IGxlbih2YWx1ZXMp
Cgl3aGlsZSBpIDwgbDoKCQlzdW0gPSBzdW0gKyB2YWx1ZXNbaV0KCQlpID0gaSArIDEKCXdoaWxl
IGogPCBsOgoJCXBjdFtqXSA9IHBjdFtqXS9zdW0KCQlqID0gaiArIDEKCQoJI2RlZmluZSBvdXIg
Y2FudmFzIGFzIHBhc3NlZCB0byB1cyBmcm9tIG1haW4gcHJvZ3JhbSwgYW5kIHBhY2sgaW4gdGhl
IGZyYW1lLgoJY2FudmFzID0gQ2FudmFzKGZyYW1lLCB3aWR0aCA9IGNudnNpemVbMF0sIGhlaWdo
dCA9IGNudnNpemVbMV0sIGJnID0gJ3doaXRlJykKCWNhbnZhcy5wYWNrKGV4cGFuZCA9IFlFUywg
ZmlsbCA9IEJPVEgpCglhcmNiZWdpbiA9IDAuMAoKICAgICAgICAjY3JlYXRlIGFyY3MgZm9yIGVh
Y2ggdmFsdWUgdGhhdCBpcyBwYXNzZWQuICBub3RlOiBUa2ludGVyIGRvY3Mgc3RhdGUgdGhhdAoJ
I3RoZSBvcHRpb24gJ2V4dGVudCcgaXMgdXNlZCB0byBzcGVjaWZ5IHRoZSBlbmRpbmcgYW5nbGUs
IGhvd2V2ZXIgdGhpcyBpcyBub3QKCSN0aGUgY2FzZS4gIHRoaXMgb3B0aW9uIGlzIHVzZWQgdG8g
c3BlY2lmeSB0aGUgYXJjIGxlbmd0aCBpbiBkZWdyZWVzLgoJZm9yIGsgaW4gcmFuZ2UobGVuKHZh
bHVlcykpOgoJCWFyY2VuZCA9IGFyY2JlZ2luICsgKHBjdFtrXSAqIDM2MC4wKQoJCWFyY2xlbiA9
IGFyY2VuZCAtIGFyY2JlZ2luCgkJY2FudmFzLmNyZWF0ZV9hcmMocGlleG1pbiwgcGlleW1pbiwg
cGlleG1heCwgcGlleW1heCwKCQkJc3RhcnQgPSBhcmNiZWdpbiwgZXh0ZW50ID0gYXJjbGVuLCBm
aWxsID0gY29sc1trXQoJCSkKCQlhcmNiZWdpbiA9IGFyY2VuZAoKCmNhbnNpemUgPSBbMjAwLCAy
MDBdICAgICAgICAgICAgICAgICAgICAgICAjZGVmaW5lIHNpemUgb2YgY2FudmFzIGZvciBlYWNo
IHBpZSBjaGFydCBbeCx5XQpwaWVzaXplID0gWzE1MCwgMTUwXSAgICAgICAgICAgICAgICAgICAg
ICAgI2RlZmluZSBzaXplIG9mIHBpZWNoYXJ0IGluIGNhbnZhcyBbeCx5XQoKI2RlZmluZSBsb2Nh
dGlvbiBvZiBwaWVjaGFydCBpbiBjYW52YXMKCnBpZXhtaW4gPSAwCnBpZXhtYXggPSBwaWV4bWlu
ICsgcGllc2l6ZVswXQpwaWV5bWluID0gY2Fuc2l6ZVsxXSAtIHBpZXNpemVbMV0KcGlleW1heCA9
IHBpZXltaW4gKyBwaWVzaXplWzFdCgojZGVmaW5lIG51bWJlciBvZiBjb2x1bW5zIGluIHRhYmxl
IGFuZCBudW1iZXIgb2YgaXRlbXMgaW4gZWFjaCBwaWUgY2hhcnQKCm51bWNvbHMgPSA4CnBpZWl0
ZW1zID0gOAoKI2luaXRhbGl6ZSByb290IHdpbmRvdyBhbmQgc3RhcnQgd2l0aCBzYW1wbGUgdmFs
dWVzCgpyb290ID0gVGsoKQkJCnZhbHVlcyA9IFsyLDEsOCw1LDYsNCw5LDgsNSwxMSwxMiw2LDMs
NCwxOSwzLDE1LDIsMTgsNCw3LDYsMiwxOCwyMCwxMSwxOSw1LDI2LDQsMTEsMiwKCQk1LDgsMiw0
LDIsNywzLDIsMTMsNCw5LDIwLDUsNywyMSw2LDksMTMsMiwxLDMsNywxLDQsMiwxLDMsNCw3LDgs
MiwxXQoKI3B1dCBldmVyeXRoaW5nIHdlIHdhbnQgaW50byBhIGdyaWQgaW4gdGhlIHJvb3Qgd2lu
ZG93CgoKbGFiZWwxID0gTGFiZWwocm9vdCwgdGV4dCA9ICJQaWUgMSAocm93IDEpIikKbGFiZWwx
LmdyaWQocm93ID0gMCwgY29sdW1uID0gMCkKCnJvdzEgPSB2YWx1ZXNbMDpwaWVpdGVtc10KZnJh
bWUxID0gRnJhbWUoKQptYWtlcGllKHJvdzEsIGZyYW1lMSwgY2Fuc2l6ZSwgcGlleG1pbiwgcGll
eG1heCwgcGlleW1pbiwgcGlleW1heCkKZnJhbWUxLmdyaWQocm93ID0gMSwgY29sdW1uID0gMCkK
CmxhYmVsMiA9IExhYmVsKHJvb3QsIHRleHQgPSAiUGllIDIgKHJvdyAyKSIpCmxhYmVsMi5ncmlk
KHJvdyA9IDAsIGNvbHVtbiA9IDEpCgpyb3cyID0gdmFsdWVzW3BpZWl0ZW1zOjIqcGllaXRlbXNd
CmZyYW1lMiA9IEZyYW1lKCkKbWFrZXBpZShyb3cyLCBmcmFtZTIsIGNhbnNpemUsIHBpZXhtaW4s
IHBpZXhtYXgsIHBpZXltaW4sIHBpZXltYXgpCmZyYW1lMi5ncmlkKHJvdyA9IDEsIGNvbHVtbiA9
IDEpCgpsYWJlbDMgPSBMYWJlbChyb290LCB0ZXh0ID0gIlBpZSAzIChyb3cgMykiKQpsYWJlbDMu
Z3JpZChyb3cgPSAwLCBjb2x1bW4gPSAyKQoKcm93MyA9IHZhbHVlc1twaWVpdGVtcyoyOjMqcGll
aXRlbXNdCmZyYW1lMyA9IEZyYW1lKCkKbWFrZXBpZShyb3czLCBmcmFtZTMsIGNhbnNpemUsIHBp
ZXhtaW4sIHBpZXhtYXgsIHBpZXltaW4sIHBpZXltYXgpCmZyYW1lMy5ncmlkKHJvdyA9IDEsIGNv
bHVtbiA9IDIpCgpsYWJlbDQgPSBMYWJlbChyb290LCB0ZXh0ID0gIlBpZSA0IChyb3cgNCkiKQps
YWJlbDQuZ3JpZChyb3cgPSAyLCBjb2x1bW4gPSAwKQoKcm93NCA9IHZhbHVlc1twaWVpdGVtcyoz
OnBpZWl0ZW1zKjRdCmZyYW1lNCA9IEZyYW1lKCkKbWFrZXBpZShyb3c0LCBmcmFtZTQsIGNhbnNp
emUsIHBpZXhtaW4sIHBpZXhtYXgsIHBpZXltaW4sIHBpZXltYXgpCmZyYW1lNC5ncmlkKHJvdyA9
IDMsIGNvbHVtbiA9IDApCgpsYWJlbDUgPSBMYWJlbChyb290LCB0ZXh0ID0gIlBpZSA1IChyb3cg
NSkiKQpsYWJlbDUuZ3JpZChyb3cgPSAyLCBjb2x1bW4gPSAxKQoKcm93NSA9IHZhbHVlc1twaWVp
dGVtcyo0OnBpZWl0ZW1zKjVdCmZyYW1lNSA9IEZyYW1lKCkKbWFrZXBpZShyb3c1LCBmcmFtZTUs
IGNhbnNpemUsIHBpZXhtaW4sIHBpZXhtYXgsIHBpZXltaW4sIHBpZXltYXgpCmZyYW1lNS5ncmlk
KHJvdyA9IDMsIGNvbHVtbiA9IDEpCgpsYWJlbDYgPSBMYWJlbChyb290LCB0ZXh0ID0gIlBpZSA2
IChyb3cgNikiKQpsYWJlbDYuZ3JpZChyb3cgPSAyLCBjb2x1bW4gPSAyKQoKcm93NiA9IHZhbHVl
c1twaWVpdGVtcyo1OnBpZWl0ZW1zKjZdCmZyYW1lNiA9IEZyYW1lKCkKbWFrZXBpZShyb3c2LCBm
cmFtZTYsIGNhbnNpemUsIHBpZXhtaW4sIHBpZXhtYXgsIHBpZXltaW4sIHBpZXltYXgpCmZyYW1l
Ni5ncmlkKHJvdyA9IDMsIGNvbHVtbiA9IDIpCgpsYWJlbDcgPSBMYWJlbChyb290LCB0ZXh0ID0g
IlBpZSA3IChyb3cgNykiKQpsYWJlbDcuZ3JpZChyb3cgPSA0LCBjb2x1bW4gPSAwKQoKcm93NyA9
IHZhbHVlc1twaWVpdGVtcyo2OnBpZWl0ZW1zKjddCmZyYW1lNyA9IEZyYW1lKCkKbWFrZXBpZShy
b3c3LCBmcmFtZTcsIGNhbnNpemUsIHBpZXhtaW4sIHBpZXhtYXgsIHBpZXltaW4sIHBpZXltYXgp
CmZyYW1lNy5ncmlkKHJvdyA9IDUsIGNvbHVtbiA9IDApCgpsYWJlbDggPSBMYWJlbChyb290LCB0
ZXh0ID0gIlBpZSA4IChyb3cgOCkiKQpsYWJlbDguZ3JpZChyb3cgPSA0LCBjb2x1bW4gPSAxKQoK
cm93OCA9IHZhbHVlc1twaWVpdGVtcyo3OnBpZWl0ZW1zKjhdCmZyYW1lOCA9IEZyYW1lKCkKbWFr
ZXBpZShyb3c4LCBmcmFtZTgsIGNhbnNpemUsIHBpZXhtaW4sIHBpZXhtYXgsIHBpZXltaW4sIHBp
ZXltYXgpCmZyYW1lOC5ncmlkKHJvdyA9IDUsIGNvbHVtbiA9IDEpCgojdGhpcyBsYXN0IHBpZSBj
aGFydCBqdXN0IHB1dHMgdGhlIHN1bSBvZiBlYWNoIGNvbHVtbiBpbiBhIHBpZSBpdGVtLgoKaSA9
IDAKc3VtID0gW10Kd2hpbGUgaSA8IHBpZWl0ZW1zOgoJc3VtLmFwcGVuZChyb3cxW2ldK3JvdzJb
aV0rcm93M1tpXStyb3c0W2ldK3JvdzVbaV0rcm93NltpXStyb3c3W2ldK3JvdzhbaV0pCglpID0g
aSsxCgpsYWJlbDkgPSBMYWJlbChyb290LCB0ZXh0ID0gIlBpZSA5IChzdW0gb24gZWFjaCBjb2x1
bW4pIikKbGFiZWw5LmdyaWQocm93ID0gNCwgY29sdW1uID0gMikKCmZyYW1lOSA9IEZyYW1lKCkK
bWFrZXBpZShzdW0sIGZyYW1lOSwgY2Fuc2l6ZSwgcGlleG1pbiwgcGlleG1heCwgcGlleW1pbiwg
cGlleW1heCkKZnJhbWU5LmdyaWQocm93ID0gNSwgY29sdW1uID0gMikKCm1haW5sb29wKCk=

--Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD--


From dsh8290@rit.edu  Wed Jun 13 22:19:45 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 13 Jun 2001 17:19:45 -0400
Subject: [Tutor] PYTHONPATH: where to set on Win9x
In-Reply-To: <3B27D0D7.30DB0E5@gmx.de>; from christian.mascher@gmx.de on Wed, Jun 13, 2001 at 10:45:11PM +0200
References: <3B27D0D7.30DB0E5@gmx.de>
Message-ID: <20010613171945.A27830@harmony.cs.rit.edu>

On Wed, Jun 13, 2001 at 10:45:11PM +0200, Christian Mascher wrote:
| So I guess I only have to use PYTHONPATH for having my personal
| directories turn up in sys.path, is that right? Meaning I only need
| to put set PYTHONPATH=d:\mypython in autoexec.bat to include that
| directory. It works, but is it "the right way" or did I miss a
| point?

You got it.  Python knows where to find the standard stuff, you just
have to add your stuff.

| By the way, is the global autoexec.bat really the best place for putting
| this? 

It is a convenient place, especially if you never change it.

| Normally, when I use a console-started compiler (like javac for
| instance), I have an extra .bat-script setting the appropriate
| environment-variables only when opening the shell (DOS-box)
| dedicated to Java or whatever. So it is possible to add environment
| variables later.  Could/should this be done for the python shell as
| well? 

If you prefer you can use a series of scripts just like with java.
The main issue you would run into there is if .py files are associated
with python.exe, not your own .bat file.  Then they would run
python.exe directly and not get your environment changes.

I use Linux or cygwin on Windows so I simply put stuff in ~/.bashrc,
or I make separate scripts if I need to switch stuff around (such as
using a DOS path for $VIM for win32 gvim, and a POSIX path for
cygwin's console-vim).  I always have one or more console (bash)
windows open where I run things from anyways.

HTH,
-D



From israel@lith.com  Wed Jun 13 22:48:02 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 13 Jun 2001 14:48:02 -0700
Subject: [Tutor] PYTHONPATH: where to set on Win9x
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144C7@mailcluster.lith.com>

I find that I get goofy behavior in Win200 when I set PYTHONPATH to have
more than one directory in it.  As soon as I add a second dir, Idle stops
working.  

-----Original Message-----
From: D-Man [mailto:dsh8290@rit.edu]
Sent: Wednesday, June 13, 2001 2:20 PM
To: tutor@python.org
Subject: Re: [Tutor] PYTHONPATH: where to set on Win9x


On Wed, Jun 13, 2001 at 10:45:11PM +0200, Christian Mascher wrote:
| So I guess I only have to use PYTHONPATH for having my personal
| directories turn up in sys.path, is that right? Meaning I only need
| to put set PYTHONPATH=d:\mypython in autoexec.bat to include that
| directory. It works, but is it "the right way" or did I miss a
| point?

You got it.  Python knows where to find the standard stuff, you just
have to add your stuff.

| By the way, is the global autoexec.bat really the best place for putting
| this? 

It is a convenient place, especially if you never change it.

| Normally, when I use a console-started compiler (like javac for
| instance), I have an extra .bat-script setting the appropriate
| environment-variables only when opening the shell (DOS-box)
| dedicated to Java or whatever. So it is possible to add environment
| variables later.  Could/should this be done for the python shell as
| well? 

If you prefer you can use a series of scripts just like with java.
The main issue you would run into there is if .py files are associated
with python.exe, not your own .bat file.  Then they would run
python.exe directly and not get your environment changes.

I use Linux or cygwin on Windows so I simply put stuff in ~/.bashrc,
or I make separate scripts if I need to switch stuff around (such as
using a DOS path for $VIM for win32 gvim, and a POSIX path for
cygwin's console-vim).  I always have one or more console (bash)
windows open where I run things from anyways.

HTH,
-D


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


From alan.gauld@freenet.co.uk  Wed Jun 13 23:42:10 2001
From: alan.gauld@freenet.co.uk (Alan Gauld)
Date: Wed, 13 Jun 2001 22:42:10 +0000
Subject: [Tutor] Embedded Python question
Message-ID: <3.0.1.32.20010613224210.012ad2cc@mail.freenet.co.uk>

This comes from the Czech translators of my tutor.
I only use Python for prototyping so have no experience 
of embedding. However I seem to recall some folks asking 
here so...

>an advice regarding running more than 1 Python embedded interpreter at the
>same time? Or could you please give us any impulse where we can find out it?
>In the concrete: we need run the Py_RunSimpleString() method
>from various C++ threads at the same time.

ie, They want to know can they run multiple interpreters (or 
more accurately call the function) from multiple threads 
within a single process? Is Python threadsafe at that level? 
I have no idea, does anyone else?

I have suggested they should ask on c.l.p too...

Alan g



From pobrien@orbtech.com  Wed Jun 13 23:22:22 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 13 Jun 2001 17:22:22 -0500
Subject: [Tutor] PYTHONPATH: where to set on Win9x
In-Reply-To: <3B27D0D7.30DB0E5@gmx.de>
Message-ID: <NBBBIOJPGKJEKIECEMCBCEIAKAAA.pobrien@orbtech.com>

No problem, Christian. I will do my best to answer your questions. And if I
mispeak, hopefully someone will correct me. Look for comments below that
begin with [POB]. Those would be mine. <g>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Christian Mascher
Sent: Wednesday, June 13, 2001 3:45 PM
To: tutor@python.org
Subject: [Tutor] PYTHONPATH: where to set on Win9x

Hello everyone,

I've been following the recent postings on implementing a
startup-configuration of some sorts, perhaps loading some modules
(pydoc) or setting up the path to arbitrary extra module-directories (my
private modules). As far as I understood the matter, the
module-search-path (shown with 'sys.path') where Python looks for and is
able to find modules must (?) be set via the environment variable
PYTHONPATH.
---
[POB] Yes, with a few exceptions and subtleties. For example, python has
some builtin places that it automatically adds to sys.path. Then the IDE
that you use (IDLE, PythonWin, VPython and Boa, just to name a few) might
make some changes to sys.path. There is also a way for 3rd party packages to
specify a directory that always gets added. And since sys.path is just a
list, you can always add on to it in your code. (In addition, python's
concept of packages can extend its reach into directories that aren't
explicitly listed in sys.path.) But the *easiest* way to have one of your
own directories *always* visible to python *no matter what* IDE you are
using is to add that directory to a SET PYTHONPATH statement in your
autoexec.bat file.
---
But that doesn't seem to be the whole story on windows, because I can
run python and import all standard modules with no explicit PYTHONPATH
set in the environment. (During installation the necessary paths must
have been hardwired into the registry.
---
[POB] Yes, but not necessarily through the registry.
---
For the same reason I can start
idle by "executing" idle.pyw from the shell (explorer) right?).
---
[POB] No. That has to do with the fact that the python installer has
associated the .py and .pyw file extensions with python.exe. So if you
double click on a file with that extension, Windows knows what to do with
that file. This is no different than what happens when you double click on a
.doc file and Word pops up. Gnome and KDE do similar things under Linux. In
Windows Explorer select the Tools | Folder Options | File Types tab to see
the associations: C:\Python21\python.exe "%1" %* (for .py files) and
C:\Python21\pythonw.exe "%1" %* (for .pyw files). Notice that the path to
python.exe is included, so it doesn't matter whether python is on your PATH
for this bit of magic to work.

If you want to be able to open a DOS box and go to any directory and type
"python" or "python myfile.py" then you need to add your python directory to
your PATH either through a batch file or as part of your autoexec.bat, which
again is the *easiest* way to go.
---

So I guess I only have to use PYTHONPATH for having my personal
directories turn up in sys.path, is that right? Meaning I only need to
put
set PYTHONPATH=d:\mypython
in autoexec.bat to include that directory. It works, but is it "the
right way" or did I miss a point?
---
[POB] Yes, that is all you need. No, I don't think you missed the point. I
think this is the right way to go. And if d:\mypython is a python package
(see
http://www.python.org/doc/current/tut/node8.html#SECTION00840000000000000000
0) you can get to subdirectories of mypython using dot notation (from
mypython.mycode.mygame.3d import specialeffects), which is pretty cool,
imho.
---

By the way, is the global autoexec.bat really the best place for putting
this? Normally, when I use a console-started compiler (like javac for
instance), I have an extra .bat-script setting the appropriate
environment-variables only when opening the shell (DOS-box) dedicated to
Java or whatever. So it is possible to add environment variables later.
Could/should this be done for the python shell as well? One could of
course append to sys.path in a standard startupscript, but then I have
to set PYTHONSTARUP first, yes?
---
[POB] Again, putting it in autoexec.bat is just easy and global. If you keep
it simple, you only need to do it once. Otherwise you need to make sure you
set up every desktop shortcut/menu choice/toolbar shortcut, etc. to go
through your batch files for every tool you use (and I actively use IDLE,
Boa, PythonWin and VPython). I would not want to have to hassle with that
myself. I have a *ton* of software loaded on this machine and my
autoexec.bat file consists of only these three lines:
SET PATH=C:\Python21
SET PYTHONPATH=C:\My Documents\pobrien\Code
SET PYTHONSTARTUP=C:\My Documents\pobrien\.pythonrc.py
---

Hope I'm not asking the same questions Patrick O'Brien and Daniel Yoo
just sorted out, but I'm really still confused about the issue.

---
[POB] Don't feel bad. I still think these environmental issues are one of
the weakest areas. I don't know if it's a lack of documentation or what. But
it seems like everyone (myself included) gets completely baffled when they
come to the environment and startup issues. I hope this helped.
---
Thanks in advance,
Christian

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From arcege@speakeasy.net  Wed Jun 13 23:43:09 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Wed, 13 Jun 2001 18:43:09 -0400 (EDT)
Subject: [Tutor] Embedded Python question
In-Reply-To: <3.0.1.32.20010613224210.012ad2cc@mail.freenet.co.uk> from "Alan Gauld" at Jun 13, 2001 10:42:10 PM
Message-ID: <200106132243.f5DMhA501379@dsl092-074-184.bos1.dsl.speakeasy.net>

Alan Gauld wrote
> 
> This comes from the Czech translators of my tutor.
> I only use Python for prototyping so have no experience 
> of embedding. However I seem to recall some folks asking 
> here so...
> 
> >an advice regarding running more than 1 Python embedded interpreter at the
> >same time? Or could you please give us any impulse where we can find out it?
> >In the concrete: we need run the Py_RunSimpleString() method
> >from various C++ threads at the same time.
> 
> ie, They want to know can they run multiple interpreters (or 
> more accurately call the function) from multiple threads 
> within a single process? Is Python threadsafe at that level? 
> I have no idea, does anyone else?

If they don't care about different interpreters (with different namespaces
and not sharing variables and modules), then they can just wrap the code
some of the standard macros around the functions:

  Py_BEGIN_BLOCK_THREADS
  PyRun_SimpleString(...);
  Py_BEGIN_UNBLOCK_THREADS

Otherwise you have to start getting into the lower level thread state
functions.

  PyThreadState *tstate_1, *tstate_2;

  Py_Initialize();
  PyEval_InitThreads();
  tstate_1 = Py_NewInterpreter();
  tstate_2 = Py_NewInterpreter();
  /* create threads */
  ...
  /* in thread 1 */
  PyEval_AcquireThread(tstate_1);
  PyRun_SimpleString(...);
  PyEval_ReleaseThread(tstate_1);
  ...
  /* in thread 2 */
  PyEval_AcquireThread(tstate_2);
  PyRun_SimpleString(...);
  PyEval_ReleaseThread(tstate_2);

This is untested, and I might have some of the functions slightly
incorrect, but the logic should be sound.  It could be that the
interpreters are created inside the peer threads instead of the main
thread (it looks safe enough).  Tim Peters could probably give a more
definitive answer tho.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From pobrien@orbtech.com  Thu Jun 14 00:02:32 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 13 Jun 2001 18:02:32 -0500
Subject: [Tutor] PYTHONPATH: where to set on Win9x
In-Reply-To: <NBBBIOJPGKJEKIECEMCBCEIAKAAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBMEIBKAAA.pobrien@orbtech.com>

Just to clarify/correct one statement I made - d:\mypython doesn't actually
need to be a package itself (though it could be). It could simply contain
other directories that were themselves packages. So in the example I gave
mycode would have to be a package (as would mygame and 3d) but mypython
would not have to be. If it wasn't the import statement would then be:

from mycode.mygame.3d import specialeffects

What I was trying to show is the amount of flexibility that packages can
give you. In this scenario, you only need one directory on your PYTHONPATH
that contains all of your own personal code. But that personal code can
exist in as many subdirectories as you require to stay organized. Just make
each subdirectory a package (by adding a __init__.py file to the
subdirectory) and it becomes visible to python, even though it isn't in
sys.path. That way each is like an independent project, yet visible to
python without requiring you to mess with PYTHONPATH or sys.path every time
you add a new project.

Does that make sense? (If not I give up. Just kidding. <grin>)

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Wednesday, June 13, 2001 5:22 PM
To: tutor@python.org
Subject: RE: [Tutor] PYTHONPATH: where to set on Win9x

<snip>

So I guess I only have to use PYTHONPATH for having my personal
directories turn up in sys.path, is that right? Meaning I only need to
put
set PYTHONPATH=d:\mypython
in autoexec.bat to include that directory. It works, but is it "the
right way" or did I miss a point?
---
[POB] Yes, that is all you need. No, I don't think you missed the point. I
think this is the right way to go. And if d:\mypython is a python package
(see
http://www.python.org/doc/current/tut/node8.html#SECTION00840000000000000000
0) you can get to subdirectories of mypython using dot notation (from
mypython.mycode.mygame.3d import specialeffects), which is pretty cool,
imho.
---
<snip>



From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 00:00:19 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 13 Jun 2001 16:00:19 -0700 (PDT)
Subject: [Tutor] PYTHONPATH: where to set on Win9x
In-Reply-To: <3B27D0D7.30DB0E5@gmx.de>
Message-ID: <Pine.LNX.4.21.0106131551110.24541-100000@hkn.eecs.berkeley.edu>

On Wed, 13 Jun 2001, Christian Mascher wrote:

> So I guess I only have to use PYTHONPATH for having my personal
> directories turn up in sys.path, is that right? Meaning I only need to
> put set PYTHONPATH=d:\mypython in autoexec.bat to include that
> directory. It works, but is it "the right way" or did I miss a point?

Yes.  PYTHONPATH's for personal configuration --- if we have a bunch of
modules that we've written, we can plunk them anywhere in the PYTHONPATH,
and we'll be able to reuse them.  That's what makes Python really neat:
even the simplest programs that we write are already reusable without too
much work.


> By the way, is the global autoexec.bat really the best place for
> putting this? Normally, when I use a console-started compiler (like
> javac for

It actually depends on what Windows edition we're using.  Up to Win98,
putting it in autoexec.bat was the one of the better choices, since
there's only one "user".  On NT and Win2k, each user has a set of
personalized variables, modifiable through the Control Panel.  I forget
the control-panel applet name, but it has the word "Environment Variables"
in it somewhere.


> Hope I'm not asking the same questions Patrick O'Brien and Daniel Yoo
> just sorted out, but I'm really still confused about the issue.

No problem; just as long as we don't contradict ourselves, I think we'll
be fine... *grin*



From dsh8290@rit.edu  Thu Jun 14 00:04:31 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 13 Jun 2001 19:04:31 -0400
Subject: [Tutor] Embedded Python question
In-Reply-To: <3.0.1.32.20010613224210.012ad2cc@mail.freenet.co.uk>; from alan.gauld@freenet.co.uk on Wed, Jun 13, 2001 at 10:42:10PM +0000
References: <3.0.1.32.20010613224210.012ad2cc@mail.freenet.co.uk>
Message-ID: <20010613190431.A9847@idaho.cs.rit.edu>

On Wed, Jun 13, 2001 at 10:42:10PM +0000, Alan Gauld wrote:
| This comes from the Czech translators of my tutor.
| I only use Python for prototyping so have no experience 
| of embedding. However I seem to recall some folks asking 
| here so...
| 
| >an advice regarding running more than 1 Python embedded interpreter at the
| >same time? Or could you please give us any impulse where we can find out it?
| >In the concrete: we need run the Py_RunSimpleString() method
| >from various C++ threads at the same time.
| 
| ie, They want to know can they run multiple interpreters (or 
| more accurately call the function) from multiple threads 
| within a single process? Is Python threadsafe at that level? 
| I have no idea, does anyone else?

I haven't done any embedding, but from what I understand the issue is
mainly that the Python stack is intertwined with the C stack.
Stackless Python would probably be safer for this because it stores
the Python stack separately on the C heap, so as long as it can switch
between different Python stacks, it can have different interpreters
(probably even allowing for shared globals, etc).

-D



From dsh8290@rit.edu  Thu Jun 14 00:06:05 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 13 Jun 2001 19:06:05 -0400
Subject: [Tutor] PYTHONPATH: where to set on Win9x
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144C7@mailcluster.lith.com>; from israel@lith.com on Wed, Jun 13, 2001 at 02:48:02PM -0700
References: <AF020C5FC551DD43A4958A679EA16A15A144C7@mailcluster.lith.com>
Message-ID: <20010613190605.B9847@idaho.cs.rit.edu>

On Wed, Jun 13, 2001 at 02:48:02PM -0700, Israel Evans wrote:
| I find that I get goofy behavior in Win200 when I set PYTHONPATH to have
| more than one directory in it.  As soon as I add a second dir, Idle stops
| working.  

How are you adding a second dir?  Windows uses ';' to separate paths
in a path list (very bad for interracting in "real" (ie bash) shells
because ';' terminates a command).

-D



From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 00:09:49 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 13 Jun 2001 16:09:49 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind!
In-Reply-To: <200106131502.f5DF2dg12285@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106130846440.17268-100000@hkn.eecs.berkeley.edu>

On Wed, 13 Jun 2001 kromag@nsacom.net wrote:

> > Let's look at the rest of the program:
> > 
> > > import string
> > > import thread
> > > 
> > > engine=win32com.client.Dispatch("DAO.DBEngine.35")
> > > db=engine.OpenDatabase("windowsdesktopterror.mdb")
> > 
> > Ok, I'm not imagining things after all.  *grin* There are backslashes on
> > this line: can you double check?
> 
> But, but, but..... Really! I am looking at the code I pasted in! It has 
> double backslashes! What manner of madness? Surely your mail agent doesn't 
> parse them into links? Anyway, I tried it with the r"pathtofile" method 
> and got the same error:


Strange!  Now I'm really confused.  I'm using Pine as my email program,
which I don't think does any email preprocessing.  My apologies for my
earlier message; I didn't realize the messages were being mangled.  Sorry
about the confusion there.  What kind of email program are you using?


> >pythonw -u dbwrong.py
> Unhandled exception in thread:
> Traceback (most recent call last):
>   File "dbwrong.py", line 15, in write
>     db.Execute("insert into data values(%f, '%s')" % inputtage)
> AttributeError: 'None' object has no attribute 'Execute'
> >Exit code: 0

The assumption I'm working on is that 'db' itself is None.  If you could
add the line:

###
if db == none:
    print "We didn't get the database connection yet."
###

right before the Execute, that will help test this guess.  I'm focusing on
the engine.OpenDatabase() call earlier, because that's where 'db' is being
initialized.


> Ah well. I am going to not think about it for a week. That has
> traditionally been the length of time it takes for the answer to
> coalesce out of the aether! :-)

Don't worry about it.  My head is starting to spin too... *grin* Again,
sorry about the bad advice earlier.  I have to learn to be more careful
when I'm reading messages.

You may want to talk with the people on the db-sig a bit more; it sounds
like they have good experience with the Jet database stuff.  Good luck to
you!



From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 00:13:19 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 13 Jun 2001 16:13:19 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind!
In-Reply-To: <Pine.LNX.4.21.0106130846440.17268-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.21.0106131612030.24541-100000@hkn.eecs.berkeley.edu>

> if db == none:
>     print "We didn't get the database connection yet."

Whoops!  I meant:

   if db == None:
       print "We didn't get the database connection yet."




From gncuster@firehead.org  Thu Jun 14 00:28:04 2001
From: gncuster@firehead.org (Nate Custer)
Date: 13 Jun 2001 18:28:04 -0500
Subject: [Tutor] Dict question
Message-ID: <992474884.22310.0.camel@it.web>

--=-AGVnSkuT5LiNtNpkWBA5
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi all,

I am calling a dict (format should be {string: [list]} ). It fails as:

  File "guardian_sum.py", line 45, in scan
    l.append(error_ip)
AttributeError: 'string' object has no attribute 'append'

Why does the error_dict.get() return a string?

Thanks in advance,

Nate Custer

====================================Begin Code
==========================
error_dict = {}

def scan():
    guardian = open("/var/log/guardian/guardian.log", 'r')
    ipchains = open("/home/nsc/ipchains.log", 'w')
    odd = open("/home/nsc/odd.log", 'w')

    nums = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ]
    days = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    blocked_host = []

    while 1:
        # read the line
        line = guardian.readline()
        if not line: break
        
        if line[:3] in days:

            word = string.split (line)
            for w in word:
                if 'IDS' == w[:3]:
                    error = w
                if w[0] in nums:
                    error_ip = w


            if error_dict.has_key(error):
                l = error_dict.get(error)
                l.append(error_ip)
                append = {error: l}
                error_dict.update (append)
            else:
                x = [`error_ip`]
                append = {error: x}
                error_dict.update (append)

--=-AGVnSkuT5LiNtNpkWBA5
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/0.9.99.0">
</HEAD>
<BODY>Hi all,<br>
<br>
I am calling a dict (format should be {string: [list]} ). It fails as:<br>
<br>
 &nbsp;File &quot;guardian_sum.py&quot;, line 45, in scan<br>
 &nbsp;&nbsp;&nbsp;l.append(error_ip)<br>
AttributeError: 'string' object has no attribute 'append'<br>
<br>
Why does the error_dict.get() return a string?<br>
<br>
Thanks in advance,<br>
<br>
Nate Custer<br>
<br>
====================================Begin Code ==========================<br>
error_dict = {}<br>
<br>
def scan():<br>
 &nbsp;&nbsp;&nbsp;guardian = open(&quot;/var/log/guardian/guardian.log&quot;, 'r')<br>
 &nbsp;&nbsp;&nbsp;ipchains = open(&quot;/home/nsc/ipchains.log&quot;, 'w')<br>
 &nbsp;&nbsp;&nbsp;odd = open(&quot;/home/nsc/odd.log&quot;, 'w')<br>
<br>
 &nbsp;&nbsp;&nbsp;nums = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ]<br>
 &nbsp;&nbsp;&nbsp;days = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']<br>
 &nbsp;&nbsp;&nbsp;blocked_host = []<br>
<br>
 &nbsp;&nbsp;&nbsp;while 1:<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# read the line<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line = guardian.readline()<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if not line: break<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if line[:3] in days:<br>
<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;word = string.split (line)<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for w in word:<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if 'IDS' == w[:3]:<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error = w<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if w[0] in nums:<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error_ip = w<br>
<br>
<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if error_dict.has_key(error):<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l = error_dict.get(error)<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l.append(error_ip)<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;append = {error: l}<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error_dict.update (append)<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x = [`error_ip`]<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;append = {error: x}<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error_dict.update (append)</BODY>
</HTML>

--=-AGVnSkuT5LiNtNpkWBA5--


From kauphlyn@speakeasy.org  Thu Jun 14 00:59:58 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Wed, 13 Jun 2001 16:59:58 -0700 (PDT)
Subject: [Tutor] Dict question
In-Reply-To: <992474884.22310.0.camel@it.web>
Message-ID: <Pine.LNX.4.33L2.0106131652320.30614-100000@grace.speakeasy.net>


>             if error_dict.has_key(error):
>                 l = error_dict.get(error)
>                 l.append(error_ip)
>                 append = {error: l}
>                 error_dict.update (append)
>             else:
>                 x = [`error_ip`]
>                 append = {error: x}
>                 error_dict.update (append)
>
if error_dict.has_key(error):
	l = []
	l.append(error_dict.get(error))
	l.append(error_ip)

etc.
I've never used the get() before but it appears to return the value associated
with the key, which in this case is a string. You were then assigning that
string to l. In this case we declare l as a list first then append values to it.
That should work for you. (I didnt test it!)

Hope this helps!

Daniel



From r.b.rigilink@chello.nl  Thu Jun 14 05:05:50 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Thu, 14 Jun 2001 06:05:50 +0200
Subject: [Tutor] Building custom widget (was: (no subject))
References: <01061315265100.26218@ouhep1> <002801c0f44a$da32e660$de00a8c0@planhouse5> <01061316152200.27433@ouhep1>
Message-ID: <3B28381E.1C2E7A31@chello.nl>

Isaac Hall wrote:

Hi Isaac,

I took a look at your program, and I think this will be easy for you to
do, provided you're familiar with Python's OO programming idioms. If
it's not obvious what I'm trying to show, feel free to ask for
additional clarification.

If you find in your code that you do something like:

def draw_widget(aframe, *args):
    <code to draw in aframe>

f = Frame(parent)
draw_widget(f, *args)
f.pack()

Then you can build your own widget, by inheriting from Frame, using your
draw_widget
function almost verbatim (changing aframe to self).

class MyWidget(Frame):
    def __init__(self, parent, *args):
        Frame.__init__(self, parent)
        self.draw_widget(*args)

    def draw_widget(self, *args):
        <code to draw in aframe, now referred to by self>

f = MyWidget(parent, *args)
f.pack()    # or f.grid(...)

Hope this helps,

Roeland

> 
> On Wed, 13 Jun 2001, Rob Andrews wrote:
> > ----- Original Message -----
> > From: "Isaac Hall" <hall@ouhep1.nhn.ou.edu>
> > To: <tutor@python.org>
> > Sent: Wednesday, June 13, 2001 3:24 PM
> > Subject: [Tutor] (no subject)
> >
> >
> > > hello all (again)
> > > I would like to pose a (hopefully) quick and easy question that is
> > confounding
> > > me.  in a program I am trying to write, it has become apparent to me that
> > I
> > > need to create my own widget to place in a Tk window to accomplish what I
> > need.
> > >  How can I do this???  if I am being to vague, let me know and I will
> > clarify.
> > >
> > > thanks
> > > Ike
> > >
> > If you can provide a little more detail about your challenge, it would help.
> > For instance, what is it that you are trying to do. There are some really
> > interesting widgets available out there already. Can you show any code that
> > is tripping you in particular?
> >
> > Rob
> >
> > Useless Python
> > It's not just for breakfast anymore!
> > http://www.lowerstandard.com/python/index.html
> 
> yes I can, specifically Im trying to put several pie charts in a window, that
> can be sized and moved about as the user wants. (at least by changing a value
> or two) as of now, I can do this by defining a function that makes the piechart
> on a canvas which is put in a frame, which is then put in a grid by the grid
> geometry manager. however,  the powers that be tell me it would be fantastic if
> I could do this by skipping the nasty canvas to frame thing altogether, and
> create a piechart widget (or class or something like that), which I could
> directly throw into the geometry manager, and hopefully create more ease in
> allowing the user to specify location, size, etc.   this is where Im stuck.
> Ive attached a sample of what it is Im doing, which works just fine, but they
> just want no canvases......
> 
>   ------------------------------------------------------------------------
>                    Name: tester.py
>    tester.py       Type: text/x-java
>                Encoding: base64
>             Description: test pies

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From r.b.rigilink@chello.nl  Thu Jun 14 05:19:31 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Thu, 14 Jun 2001 06:19:31 +0200
Subject: [Tutor] Dict question
References: <992474884.22310.0.camel@it.web>
Message-ID: <3B283B53.7B2EDA1@chello.nl>

Hi Nate,

As far as I can tell your code is not wrong (Is this everything there
is), so given this I don't understand the error.

However, it is somewhat unconventional, which may hide the error from
me.
The idiom for what you're trying to do with updating your dict is:

l = error_dict.get(error, []) # if error in dict get list, else return
empty list
l.append(error_ip)
error_dict[error] = l         # put list (back) in dict

Hope this helps,

Roeland


> Nate Custer wrote:
> 
> Hi all,
> 
> I am calling a dict (format should be {string: [list]} ). It fails as:
> 
>  File "guardian_sum.py", line 45, in scan
>    l.append(error_ip)
> AttributeError: 'string' object has no attribute 'append'
> 
> Why does the error_dict.get() return a string?
> 
> Thanks in advance,
> 
> Nate Custer
> 
> ====================================Begin Code
> ==========================
> error_dict = {}
> 
> def scan():
>    guardian = open("/var/log/guardian/guardian.log", 'r')
>    ipchains = open("/home/nsc/ipchains.log", 'w')
>    odd = open("/home/nsc/odd.log", 'w')
> 
>    nums = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ]
>    days = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
>    blocked_host = []
> 
>    while 1:
>        # read the line
>        line = guardian.readline()
>        if not line: break
> 
>        if line[:3] in days:
> 
>            word = string.split (line)
>            for w in word:
>                if 'IDS' == w[:3]:
>                    error = w
>                if w[0] in nums:
>                    error_ip = w
> 

This is unconventional:

>            if error_dict.has_key(error):
>                l = error_dict.get(error)
>                l.append(error_ip)
>                append = {error: l}
>                error_dict.update (append)
>            else:
>                x = [`error_ip`]
>                append = {error: x}
>                error_dict.update (append)

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 07:52:35 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Wed, 13 Jun 2001 23:52:35 -0700 (PDT)
Subject: [Tutor] Dict question
In-Reply-To: <992474884.22310.0.camel@it.web>
Message-ID: <Pine.LNX.4.21.0106132307520.27868-100000@hkn.eecs.berkeley.edu>

Dear Nate,

Hello!  I couldn't see problems with your code either.  As a debugging
tip: try printing out your dictionary right before the append(): that
might reveal a problem with the error_dict.

Hypothesis:  Perhaps another function that gets called before scan()
disfigures error_dict in some hideous mangling: that could cause the sort
of error that you're getting.  I'm always wary when I see global
variables, so please indulge my excessive despair... *grin*


Some comments on your code:

>             if error_dict.has_key(error):
>                 l = error_dict.get(error)
>                 l.append(error_ip)

Up to this part, things are ok.  In fact, you can stop right here --- the
next two lines:

>                 append = {error: l}
>                 error_dict.update (append)

aren't necessary: you can remove them.  The reason is because the list
associated with our 'error' key has already been changed by the
'l.append(error_ip)' line above.  When we're using

    l = error_dict.get(error)

we're getting back the literal list that's associated with the key.  That
is, we're not getting some cheap imitation: we're getting the one true
list --- any changes that we make to this list 'l' appears to get
reflected back in the dictionary, because it IS the list from the
dictionary.

Here's an example that shows this in action:

###
>>> book_characters = {}
>>> book_characters['lord of the rings'] = ['frodo']
>>> book_characters['lord of the rings'].append('sam')
>>> book_characters['lord of the rings']
['frodo', 'sam']
>>> characters = book_characters['lord of the rings']
>>> characters.append('gandalf')
>>> book_characters['lord of the rings']
['frodo', 'sam', 'gandalf']
###

Another thing that you might want to look at is: is 'error_ip' itself a
string?  If not, then you'll want to make it into a string with the
backquotes:

    l.append(`error_ip`)

before you insert it into the list, to maintain the desire for all those
list elements to be strings.  Your else clause, later in the code, treats
'error_ip' with backquotes, so you might want to keep the symmetry.


One comment on the else clause:

>             else:
>                 x = [`error_ip`]
>                 append = {error: x}
>                 error_dict.update (append)

We're using this else clause to add a new key-value binding to our
error_dict.  In this case, it's more direct to add it:

    else:
        error_dict[error] = [`error_ip`]

without having to worry about calling update().  dict.update() is meant to
let people merge two large dictionaries together, but it's overkill in
this case.


Hope this helps!





From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 08:00:04 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Thu, 14 Jun 2001 00:00:04 -0700 (PDT)
Subject: [Tutor] Building custom widget (was: (no subject))
In-Reply-To: <3B28381E.1C2E7A31@chello.nl>
Message-ID: <Pine.LNX.4.21.0106132354100.27868-100000@hkn.eecs.berkeley.edu>

> yes I can, specifically Im trying to put several pie charts in a
> window, that can be sized and moved about as the user wants. (at least
> by changing a value or two) as of now, I can do this by defining a
> function that makes the piechart on a canvas which is put in a frame,
> which is then put in a grid by the grid geometry manager. however, the
> powers that be tell me it would be fantastic if I could do this by
> skipping the nasty canvas to frame thing altogether, and create a
> piechart widget (or class or something like that), which I could

By the way, there's a pie chart generator called 'Graphite': perhaps you
can make use of it to generate your pie charts without even fiddling with
Tkinter widgets:

    http://Graphite.sourceforge.net

Another useful graphics module is called PIDDLE:

    http://piddle.sourceforge.net

which Graphite appears to work with.  Both work nicely with Tkinter, so
play with it and see if it fits your needs.



From ppathiyi@cisco.com  Thu Jun 14 12:27:31 2001
From: ppathiyi@cisco.com (Praveen Pathiyil)
Date: Thu, 14 Jun 2001 16:57:31 +0530
Subject: [Tutor] Installing Python2.1.. Problem with _tkinter
Message-ID: <07bb01c0f4c5$01330770$37ef87c0@ppathiyipc>

This is a multi-part message in MIME format.

------=_NextPart_000_07B8_01C0F4F3.19EF3030
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,

        I am facing problems in installing python 2.1 in a solaris =
machine. The errors are coming when i am trying to include the Tkinter =
module

-------------------------------XXXXXXXXXXXXXXX-------------------------

libpython2.1.a(_tkinter.o): In function `Tkinter_Error':
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:233: undefined =
reference to `Tc
l_GetStringResult'
libpython2.1.a(_tkinter.o): In function `Merge':
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:350: undefined =
reference to `Tc
l_Merge'
libpython2.1.a(_tkinter.o): In function `Split':
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:382: undefined =
reference to `Tc
l_SplitList'
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:407: undefined =
reference to `Tc
l_Free'
libpython2.1.a(_tkinter.o): In function `Tkapp_New':
/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:454: undefined =
reference to `Tc
l_CreateInterp'
 =
------------------------------XXXXXXXXXXXXXXXXXX-------------------------=
---------

I have included the paths for Tcl and Tk headers and libraries. I have =
also made the whole comand into a single line as suggested in the=20
Setup file.=20

_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT =
-L/auto/sw/packages/cygnus/progre
ssive-98r1-v0/H-sparc-sun-solaris2.5/lib -I/auto/usrlocal/include =
-I/usr/X11R6/i
nclude -I/usr/openwin/include =
-L/auto/sw/packages/cygnus/progressive-98r1-v0/H-s
parc-sun-solaris2.5/lib -L/usr/X11R6/lib -L/usr/openwin/lib -lX11

Still i am getting the same errors .......

Please help me out ..

Thanks in advance,
Praveen.

------=_NextPart_000_07B8_01C0F4F3.19EF3030
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.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; I =
am facing=20
problems in installing python 2.1 in a solaris machine. The errors are =
coming=20
when i am trying to include the Tkinter module</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>-------------------------------XXXXXXXXXXXXXXX------------------=
-------</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>libpython2.1.a(_tkinter.o): In function =

`Tkinter_Error':<BR>/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:233:=
=20
undefined reference to =
`Tc<BR>l_GetStringResult'<BR>libpython2.1.a(_tkinter.o):=20
In function =
`Merge':<BR>/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:350:=20
undefined reference to `Tc<BR>l_Merge'<BR>libpython2.1.a(_tkinter.o): In =

function =
`Split':<BR>/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:382:=20
undefined reference to=20
`Tc<BR>l_SplitList'<BR>/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:4=
07:=20
undefined reference to `Tc<BR>l_Free'<BR>libpython2.1.a(_tkinter.o): In =
function=20
`Tkapp_New':<BR>/proj/vsc/python/Python-2.1/./Modules/_tkinter.c:454: =
undefined=20
reference to `Tc<BR>l_CreateInterp'<BR>=20
------------------------------XXXXXXXXXXXXXXXXXX-------------------------=
---------</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have included the paths for Tcl and =
Tk headers=20
and libraries. I have also made the whole comand into a single line as =
suggested=20
in the </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Setup file. </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>_tkinter _tkinter.c tkappinit.c =
-DWITH_APPINIT=20
-L/auto/sw/packages/cygnus/progre<BR>ssive-98r1-v0/H-sparc-sun-solaris2.5=
/lib=20
-I/auto/usrlocal/include -I/usr/X11R6/i<BR>nclude -I/usr/openwin/include =

-L/auto/sw/packages/cygnus/progressive-98r1-v0/H-s<BR>parc-sun-solaris2.5=
/lib=20
-L/usr/X11R6/lib -L/usr/openwin/lib -lX11<BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>Still i am getting the same errors=20
.......</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Please help me out ..</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Praveen.</FONT></DIV></BODY></HTML>

------=_NextPart_000_07B8_01C0F4F3.19EF3030--



From scarblac@pino.selwerd.nl  Thu Jun 14 12:37:40 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 14 Jun 2001 13:37:40 +0200
Subject: [Tutor] Installing Python2.1.. Problem with _tkinter
In-Reply-To: <07bb01c0f4c5$01330770$37ef87c0@ppathiyipc>; from ppathiyi@cisco.com on Thu, Jun 14, 2001 at 04:57:31PM +0530
References: <07bb01c0f4c5$01330770$37ef87c0@ppathiyipc>
Message-ID: <20010614133740.A3159@pino.selwerd.nl>

On  0, Praveen Pathiyil <ppathiyi@cisco.com> wrote:
> I have included the paths for Tcl and Tk headers and libraries. I have also made the whole comand into a single line as suggested in the 
> Setup file. 
> 
> _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -L/auto/sw/packages/cygnus/progre
> ssive-98r1-v0/H-sparc-sun-solaris2.5/lib -I/auto/usrlocal/include -I/usr/X11R6/i
> nclude -I/usr/openwin/include -L/auto/sw/packages/cygnus/progressive-98r1-v0/H-s
> parc-sun-solaris2.5/lib -L/usr/X11R6/lib -L/usr/openwin/lib -lX11

I don't see a -L and -I option for the Tcl/Tk directories here.

Try adding them, maybe that helps.

-- 
Remco Gerlich


From aschmidt@nv.cc.va.us  Thu Jun 14 12:52:28 2001
From: aschmidt@nv.cc.va.us (Schmidt, Allen J.)
Date: Thu, 14 Jun 2001 07:52:28 -0400
Subject: [Tutor] Get it, Parse it, Dump it....
Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090688C0B9@novamail.nvcc.vccs.edu>

Hello All...

I've been lurking for a few weeks and now need the services of this list.

I have a URL which connects to someone else's database system and returns
what I have been told is "compact XML." Having never heard of it before I
was curious. Submitting the URL in a browser I get back a ton of data that
is lumped together on the screen. A view source shows something else.

The first 2 lines are tag-like and the data starts on the third line. That
line contains this:
<COLUMN>NAME    ADDRESS    PHONE</COLUMN>

The above data is substituted to make this easier and the line really has
about 80 fields.
Each field is separated by a TAB character.

Then all the following lines look like this: (several hundred lines)
<DATA>Fred    1123 Main Street    555-1212</DATA>

This goes on until the end where there is another ending-tag-like tag on the
very last line.

Here is what I need to be able to do AUTOMATICALLY:

1)Submit the URL (I can get the data back by using urllib.urlopen(url) )

2)Parse the data to remove the first 2 lines and the last line.

3)Parse each line to remove the start and end tags.

4)Make a connection to an ODBC data source on the same PC.

5)Delete all the data in a table.

6)'Pour' all the new data into the appropriate fields in the table

7)Send me an email letting me know the status of the job - number or
records, etc.


That's it!  I have been able to do some of the things at the winPython
prompt but not sure how to proceed with the details of make this into a
stand-alone py file that handles all these things.
My thought would be to CHRON this to have it run at night to update my data.

So...thoughts, comments, directions...

Don't want someone to DO it for me but I think I need some basic help in
putting the pieces together. If its too much to ask of this list, I would
like to know that too.

Thanks!

Allen


From ppathiyi@cisco.com  Thu Jun 14 13:38:13 2001
From: ppathiyi@cisco.com (Praveen Pathiyil)
Date: Thu, 14 Jun 2001 18:08:13 +0530
Subject: [Tutor] Installing Python2.1.. Problem with _tkinter
References: <07bb01c0f4c5$01330770$37ef87c0@ppathiyipc> <20010614133740.A3159@pino.selwerd.nl>
Message-ID: <07ed01c0f4ce$e087a440$37ef87c0@ppathiyipc>

----- Original Message -----
From: "Remco Gerlich" <scarblac@pino.selwerd.nl>
To: <tutor@python.org>
Sent: Thursday, June 14, 2001 5:07 PM
Subject: Re: [Tutor] Installing Python2.1.. Problem with _tkinter


> On  0, Praveen Pathiyil <ppathiyi@cisco.com> wrote:
> > I have included the paths for Tcl and Tk headers and libraries. I have
also made the whole comand into a single line as suggested in the
> > Setup file.
> >
> > _tkinter _tkinter.c
tkappinit.c -DWITH_APPINIT -L/auto/sw/packages/cygnus/progre
> >
ssive-98r1-v0/H-sparc-sun-solaris2.5/lib -I/auto/usrlocal/include -I/usr/X11
R6/i
> >
nclude -I/usr/openwin/include -L/auto/sw/packages/cygnus/progressive-98r1-v0
/H-s
> > parc-sun-solaris2.5/lib -L/usr/X11R6/lib -L/usr/openwin/lib -lX11
>
> I don't see a -L and -I option for the Tcl/Tk directories here.
>
> Try adding them, maybe that helps.

The Tcl and Tk libraries are in the directory
auto/sw/packages/cygnus/progressive-98r1-v0/H-sparc-sun-solaris2.5/lib
and the header files are in the directory
auto/usrlocal/include
both of which are included .....

Any other possible reasons ?

Thx,
Praveen.




From pobrien@orbtech.com  Thu Jun 14 15:01:07 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 14 Jun 2001 09:01:07 -0500
Subject: [Tutor] Get it, Parse it, Dump it....
In-Reply-To: <5CDFEBB60E7FD311B9E30000F6D6090688C0B9@novamail.nvcc.vccs.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBKEILKAAA.pobrien@orbtech.com>

I can't speak for anyone else, but it would help me help you if you could
expand on what you have that *is* working and what *specifically* you still
need on the other things. Otherwise it's a pretty big list. I know some of
the answers, but I don't know if you want advice on where to start or
whether you want to see sample code or whether you have some code and it
isn't doing exactly what you want. So now that we know the scope of your
project (which sounds pretty cool, btw) maybe you could break out some
specific requests so that we can help you with smaller chunks until you have
everything that you need.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Schmidt, Allen J.
Sent: Thursday, June 14, 2001 6:52 AM
To: tutor@python.org
Subject: [Tutor] Get it, Parse it, Dump it....

Hello All...

I've been lurking for a few weeks and now need the services of this list.

I have a URL which connects to someone else's database system and returns
what I have been told is "compact XML." Having never heard of it before I
was curious. Submitting the URL in a browser I get back a ton of data that
is lumped together on the screen. A view source shows something else.

The first 2 lines are tag-like and the data starts on the third line. That
line contains this:
<COLUMN>NAME    ADDRESS    PHONE</COLUMN>

The above data is substituted to make this easier and the line really has
about 80 fields.
Each field is separated by a TAB character.

Then all the following lines look like this: (several hundred lines)
<DATA>Fred    1123 Main Street    555-1212</DATA>

This goes on until the end where there is another ending-tag-like tag on the
very last line.

Here is what I need to be able to do AUTOMATICALLY:

1)Submit the URL (I can get the data back by using urllib.urlopen(url) )

2)Parse the data to remove the first 2 lines and the last line.

3)Parse each line to remove the start and end tags.

4)Make a connection to an ODBC data source on the same PC.

5)Delete all the data in a table.

6)'Pour' all the new data into the appropriate fields in the table

7)Send me an email letting me know the status of the job - number or
records, etc.


That's it!  I have been able to do some of the things at the winPython
prompt but not sure how to proceed with the details of make this into a
stand-alone py file that handles all these things.
My thought would be to CHRON this to have it run at night to update my data.

So...thoughts, comments, directions...

Don't want someone to DO it for me but I think I need some basic help in
putting the pieces together. If its too much to ask of this list, I would
like to know that too.

Thanks!

Allen

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From rob@jam.rr.com  Thu Jun 14 15:57:38 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Thu, 14 Jun 2001 09:57:38 -0500
Subject: [Tutor] a couple of ideas I've been bouncing around
Message-ID: <NFBBKIELCLIEEMGGIGKDOEAJCAAA.rob@jam.rr.com>

In my ongoing quest for novel (twisted?) ways to add even more color to the
Python universe, I've come up with a few more ideas. I picked up Trivial
Pursuit Genus 5 the other day and thought it would be interesting to produce
a Python module for it, essentially a collection of questions and answers
about Python, broken down by general category (e.g., "Python Mythology",
"Data Structures", "Python History", etc.) using a color scheme compatible
with the one Trivial Pursuit uses. This could be printed up on some nice
card stock and actually used with the boxed game set.

The second idea is an actual test. Brainbench (http://www.brainbench.com)
offers a $19.95 certification in Python 1.5. With all the keen, experienced
minds and nearly inexhaustible number of questions archived on this list, we
should be able to come up with a nice test that generates a brief,
meaningful report on how one performed on it. """You were strong enough to
tutor another person in the areas of "strings" and "exception handling". You
seemed competent in "flow control" and "sockets". You should study more on
"OOP" and "embedding". You answered 87% correctly, soundly passing Python
Tutor Certification."""

I think anything we do along these general lines would help provide another
great learning tool and a healthy bit of fun all around.

Rob

"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/



From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 16:01:23 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Thu, 14 Jun 2001 08:01:23 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind! (fwd)
Message-ID: <Pine.LNX.4.21.0106140800070.3418-100000@hkn.eecs.berkeley.edu>

Hiya kormag,

Let me forward this to the other people on tutor.  I've never used TWIG,
so I'm inclined to suspect it.  *grin*


---------- Forwarded message ----------
Date: Thu, 14 Jun 2001 08:27:48 -0700 (PDT)
From: kromag@nsacom.net
To: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>,
     Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>, kromag@nsacom.net
Cc: tutor@python.org
Subject: Re: [Tutor] Threads....  Unhandle my Exception you Feind!

Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> said: 

> > But, but, but..... Really! I am looking at the code I pasted in! It has 
> > double backslashes! What manner of madness? Surely your mail agent 
doesn't 
> > parse them into links? Anyway, I tried it with the r"pathtofile" method 
> > and got the same error:
> 
> 
> Strange!  Now I'm really confused.  I'm using Pine as my email program,
> which I don't think does any email preprocessing.  My apologies for my
> earlier message; I didn't realize the messages were being mangled.  Sorry
> about the confusion there.  What kind of email program are you using?
> 

I post to this list using TWIG (a web interface that in this instance uses 
perl, PHP and apache w/ssl on OpenBSD. Nice interface and fairly secure for 
webmail.)

> 
> > >pythonw -u dbwrong.py
> > Unhandled exception in thread:
> > Traceback (most recent call last):
> >   File "dbwrong.py", line 15, in write
> >     db.Execute("insert into data values(%f, '%s')" % inputtage)
> > AttributeError: 'None' object has no attribute 'Execute'
> > >Exit code: 0
> 
> The assumption I'm working on is that 'db' itself is None.  If you could
> add the line:
> 
> ###
> if db == none:
>     print "We didn't get the database connection yet."

Oho!


> ###
> 
> right before the Execute, that will help test this guess.  I'm focusing on
> the engine.OpenDatabase() call earlier, because that's where 'db' is being
> initialized.
>

Aha! 

I smell a rat! Here again is the script with your mods and the output:


----------begin dbwrong.py--------------

import win32com.client
import random
import time
import string
import thread

engine=win32com.client.Dispatch("DAO.DBEngine.35")
db=engine.OpenDatabase(r"windowsdesktopterror.mdb")


## Function write() writes a list to the database
def write(inputtage):
	if db==None:
		print 'el vomito'
	db.Execute("insert into data values(%f, '%s')" % inputtage)
	return 'ok'

if __name__=='__main__':
	tik_tok=time.time()
	surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
	the_madness=(tik_tok, surprize)
	thread.start_new_thread(write,(the_madness,))

--------------end dbwrong.py----------------

and the errors:

---------begin error------------------------

>pythonw -u dbwrong.py
el vomito   ## There you are you rascal!
Unhandled exception in thread:
Traceback (most recent call last):
  File "dbwrong.py", line 15, in write
    db.Execute("insert into data values(%f, '%s')" % inputtage)
AttributeError: 'None' object has no attribute 'Execute'
>Exit code: 0

---------end error-------------------------

> Don't worry about it.  My head is starting to spin too... *grin* Again,
> sorry about the bad advice earlier.  I have to learn to be more careful
> when I'm reading messages.

My orbital migrane platforms are trained upon you now. Soon you will learn to 
trifle with..... Man, I really need a good mad scientist name.

> 
> You may want to talk with the people on the db-sig a bit more; it sounds
> like they have good experience with the Jet database stuff.  Good luck to
> you!
> 

I shall! It just seems durn weird that adding a single thread causes the 
database name to be spat out. Weird, man. I will post any solution.

d

> 




From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 16:16:38 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Thu, 14 Jun 2001 08:16:38 -0700 (PDT)
Subject: [Tutor] Taking Mark Lutz's training course
In-Reply-To: <200106141532.f5EFWag19056@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106140801300.3418-100000@hkn.eecs.berkeley.edu>

On Thu, 14 Jun 2001 kromag@nsacom.net wrote:

> Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> said: 
> 
> > 
> > Whoops!  I meant:
> > 
> >    if db == None:
> 
> Caught it!
> 
> And now for something completely different:
> 
> Have you taken, or talked to anyone who has taken Mark Lutz' Python
> classes?  It sounds like a good three days, but the money gods have
> frowned upon me this year. I _really_ get a lot of mileage out of
> "Learning Python", so I am inclined toward spending my dough with him.

No, I haven't taken one of his classes.  Has anyone here taken one?  What
are they like?


> I have yet to find a college in the midwest that even teaches Python.
> *sigh*

I actually tried to do a small "Introduction to Python" session in
Berkeley once.  What a disaster!  The problem was that the language was so
obvious, so simple, that I didn't need to say anything... *grin*

Truthfully, I'd need to improve my speaking skills before tackling
something like that.



From aschmidt@nv.cc.va.us  Thu Jun 14 16:17:03 2001
From: aschmidt@nv.cc.va.us (Schmidt, Allen J.)
Date: Thu, 14 Jun 2001 11:17:03 -0400
Subject: [Tutor] Get it, Parse it, Dump it....
Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090688C0C2@novamail.nvcc.vccs.edu>

Great! Thanks for responding.

>From the winPython interpreter, one line at a time, I do this:

>>> import urllib
>>> x=urllib.urlopen("http://site.that.has.the.data/search?etc=stuff")   
         ## This takes 2 minutes to come back

>>> print x.readlines()

And this shows everything on one LONG line coded as I describe below with
the TAB character showing between each field as '\011'

I have been able to use string.split to break the line into a list on the
TAB character.

Not sure how to go about building this into something that can run on its
own instead of the command prompt.

Also need to know how to connect to and talk to my ODBC defined database
(Access2000) and then take the fields, one line at a time, and insert them
into the DB table.

I am using Zope so if there is a way to build this into a script or external
method and call it from Zope that would be great too. Using Zope, I have put
off learning Python long enough. Now I really need it!

Thanks
Allen

-----Original Message-----
From: Patrick K. O'Brien [mailto:pobrien@orbtech.com]
Sent: Thursday, June 14, 2001 10:01 AM
To: Python Tutor
Subject: RE: [Tutor] Get it, Parse it, Dump it....


I can't speak for anyone else, but it would help me help you if you could
expand on what you have that *is* working and what *specifically* you still
need on the other things. Otherwise it's a pretty big list. I know some of
the answers, but I don't know if you want advice on where to start or
whether you want to see sample code or whether you have some code and it
isn't doing exactly what you want. So now that we know the scope of your
project (which sounds pretty cool, btw) maybe you could break out some
specific requests so that we can help you with smaller chunks until you have
everything that you need.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Schmidt, Allen J.
Sent: Thursday, June 14, 2001 6:52 AM
To: tutor@python.org
Subject: [Tutor] Get it, Parse it, Dump it....

Hello All...

I've been lurking for a few weeks and now need the services of this list.

I have a URL which connects to someone else's database system and returns
what I have been told is "compact XML." Having never heard of it before I
was curious. Submitting the URL in a browser I get back a ton of data that
is lumped together on the screen. A view source shows something else.

The first 2 lines are tag-like and the data starts on the third line. That
line contains this:
<COLUMN>NAME    ADDRESS    PHONE</COLUMN>

The above data is substituted to make this easier and the line really has
about 80 fields.
Each field is separated by a TAB character.

Then all the following lines look like this: (several hundred lines)
<DATA>Fred    1123 Main Street    555-1212</DATA>

This goes on until the end where there is another ending-tag-like tag on the
very last line.

Here is what I need to be able to do AUTOMATICALLY:

1)Submit the URL (I can get the data back by using urllib.urlopen(url) )

2)Parse the data to remove the first 2 lines and the last line.

3)Parse each line to remove the start and end tags.

4)Make a connection to an ODBC data source on the same PC.

5)Delete all the data in a table.

6)'Pour' all the new data into the appropriate fields in the table

7)Send me an email letting me know the status of the job - number or
records, etc.


That's it!  I have been able to do some of the things at the winPython
prompt but not sure how to proceed with the details of make this into a
stand-alone py file that handles all these things.
My thought would be to CHRON this to have it run at night to update my data.

So...thoughts, comments, directions...

Don't want someone to DO it for me but I think I need some basic help in
putting the pieces together. If its too much to ask of this list, I would
like to know that too.

Thanks!

Allen

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 16:28:40 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Thu, 14 Jun 2001 08:28:40 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind! (fwd)
In-Reply-To: <Pine.LNX.4.21.0106140800070.3418-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.21.0106140820500.3418-100000@hkn.eecs.berkeley.edu>

On Thu, 14 Jun 2001, Daniel Yoo wrote:
> import win32com.client
> import random
> import time
> import string
> import thread
> 
> engine=win32com.client.Dispatch("DAO.DBEngine.35")
> db=engine.OpenDatabase(r"windowsdesktopterror.mdb")
> 
> 
> ## Function write() writes a list to the database
> def write(inputtage):
> 	if db==None:
> 		print 'el vomito'
> 	db.Execute("insert into data values(%f, '%s')" % inputtage)
> 	return 'ok'
> 
> if __name__=='__main__':
> 	tik_tok=time.time()
> 	surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
> 	the_madness=(tik_tok, surprize)
> 	thread.start_new_thread(write,(the_madness,))


Let's explore the problem further.  Can you try this program?:

###
import win32com.client
import random
import time
import string

engine=win32com.client.Dispatch("DAO.DBEngine.35")
db=engine.OpenDatabase(r"windowsdesktopterror.mdb")
if db==None:
	print 'el vomito 1'


## Function write() writes a list to the database
def write(inputtage):
	if db==None:
		print 'el vomito 2'
	db.Execute("insert into data values(%f, '%s')" % inputtage)
	return 'ok'

if __name__=='__main__':
	tik_tok=time.time()
	surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
	the_madness=(tik_tok, surprize)
	write(the_madness)
###

If this program says "el vomito 1', then it's definitely because of:

    db=engine.OpenDatabase(r"\\windows\\desktop\\terror.mdb")

and that's something you can fix.  Otherwise, if everything works, then it
must have something to do with way threads work.  I think I sorta
understand what's going on, but the results of this experiment will make
me more sure.  Let's try this experiment and see what we get from it.

Hope this helps!



From pobrien@orbtech.com  Thu Jun 14 16:42:06 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 14 Jun 2001 10:42:06 -0500
Subject: [Tutor] a couple of ideas I've been bouncing around
In-Reply-To: <NFBBKIELCLIEEMGGIGKDOEAJCAAA.rob@jam.rr.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBMEJBKAAA.pobrien@orbtech.com>

I like both of these ideas. Maybe there is a way to combine them. Perhaps
the only difference is the Trivial Pursuit version gives the answer and the
Certification version withholds the answer. The pyDoc module shows what you
can do to make the python interpreter even more interactive in terms of
presenting a lot of text and responding to requests for information. Perhaps
we could piggyback that module and create an interactive
trivia/tutor/testing/certification module. I bet the Edu Sig folks might be
interested in this as well.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Rob
Andrews
Sent: Thursday, June 14, 2001 9:58 AM
To: tutor@python.org
Subject: [Tutor] a couple of ideas I've been bouncing around

In my ongoing quest for novel (twisted?) ways to add even more color to the
Python universe, I've come up with a few more ideas. I picked up Trivial
Pursuit Genus 5 the other day and thought it would be interesting to produce
a Python module for it, essentially a collection of questions and answers
about Python, broken down by general category (e.g., "Python Mythology",
"Data Structures", "Python History", etc.) using a color scheme compatible
with the one Trivial Pursuit uses. This could be printed up on some nice
card stock and actually used with the boxed game set.

The second idea is an actual test. Brainbench (http://www.brainbench.com)
offers a $19.95 certification in Python 1.5. With all the keen, experienced
minds and nearly inexhaustible number of questions archived on this list, we
should be able to come up with a nice test that generates a brief,
meaningful report on how one performed on it. """You were strong enough to
tutor another person in the areas of "strings" and "exception handling". You
seemed competent in "flow control" and "sockets". You should study more on
"OOP" and "embedding". You answered 87% correctly, soundly passing Python
Tutor Certification."""

I think anything we do along these general lines would help provide another
great learning tool and a healthy bit of fun all around.

Rob

"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From alan.gauld@bt.com  Thu Jun 14 16:50:22 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 14 Jun 2001 16:50:22 +0100
Subject: [Tutor] Get it, Parse it, Dump it....
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D81F@mbtlipnt02.btlabs.bt.co.uk>

> From the winPython interpreter, one line at a time, I do this:
> >>> import urllib
> >>> x=urllib.urlopen("http://site.that.has.the.data/search?etc=stuff")   
> >>> print x.readlines()
> 
> And this shows everything on one LONG line 
> ...
> I have been able to use string.split to break the line into a 
> list on the TAB character.
> 
> Not sure how to go about building this into something that 
> can run on its own instead of the command prompt.

OK the easy bit first ;-)

Just open a new empty text file and type in the commands 
that you entered at the >>> prompt. ie the ast line would 
look like:

print x.readlines()

insert as the first line:

#! /usr/bin/env python

Save the file as fetchdata.py or whatever and make it executable
and then run it. (I'm assuming since you mentioned chron(cron?) 
that you are on a Linux/Unix platform...)

If you are on windows(coz you mention OCDB below) you don't need 
the special first line above and can just save the file and 
then run it by double clicking in windoze exploder.

> Also need to know how to connect to and talk to my ODBC 
> defined database (Access2000) and then take the fields, 
> one line at a time, and insert them
> into the DB table.

For that you need some SQL - do you know SQL?
If not then I think Access has some tools that generate it 
for you and you could copy it into your program but its 
really better if you learn basic SQL - its easy enough...

> I am using Zope so if there is a way to build this into a 
> script or external method and call it from Zope that 

My limited understanding of Zope says that if you wrap 
the code as a function inside the file then you can call 
it from Zope. I'm sure theres some extra magic but ...

To create a function just do:

def doit():
   # add your lines here all indented by a constant amount

The Zope URL will then be:

http://<www.some.domain/zoperoot/fetchdata/doit

Where fetchdata is your file and doit the function you defined.

As Patrick says it's an interesting problem but you need 
to tackle it bit by bit and ask us specific questions.

You look to be on the rght track.

Alan G


From dyoo@hkn.eecs.berkeley.edu  Thu Jun 14 20:57:19 2001
From: dyoo@hkn.eecs.berkeley.edu (Daniel Yoo)
Date: Thu, 14 Jun 2001 12:57:19 -0700 (PDT)
Subject: [Tutor] Threads....  Unhandle my Exception you Feind! (fwd)
In-Reply-To: <200106142058.f5EKwqg21799@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106141241400.7323-100000@hkn.eecs.berkeley.edu>

On Thu, 14 Jun 2001 kromag@nsacom.net wrote:


> ----------------end dbwrong.py---------------
> <drumroll>
> 
> >pythonw -u dbwrong.py
> el vomito 2
> Unhandled exception in thread:
> Traceback (most recent call last):
>   File "dbwrong.py", line 17, in write
>     db.Execute("insert into data values(%f, '%s')" % inputtage)
> AttributeError: 'None' object has no attribute 'Execute'
> >Exit code: 0
> 
> 
> Thread it is! :-)

Ah ha!  Now I can make a good guess at what's happening.  Here's the
guess: when the main thread (the main program) gets to the end of the
program, it finishes.  However, the program still needs to wait until the
newly-spawned thread finishes.  That's ok so far.

The big problem is: what happens to all the variables created from the
main thread, after the thread dies?  In particular, what happens to our
'db' variable?  What I think is happening is that Python believes we won't
be needing 'db' anymore, so it sets it back to None.  Let's look at the
program again, and this theory might gain plausibility:


> engine=win32com.client.Dispatch("DAO.DBEngine.35")
> db=engine.OpenDatabase(r"windowsdesktopterror.mdb")
> if db==None:                 ## This was added since
> 	print 'el vomito 1'  ## last posting!
> 
> 
> ## Function write() writes a list to the database
> def write(inputtage):
> 	if db==None:
> 		print 'el vomito 2' ## As was this...
> 	db.Execute("insert into data values(%f, '%s')" % inputtage)
> 	return 'ok'
> 
> if __name__=='__main__':
> 	tik_tok=time.time()
> 	surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
> 	the_madness=(tik_tok, surprize)
> 	thread.start_new_thread(write,(the_madness,))

I'll pretend to be the Python system.  "We've just started the new thread.  
Hey, we're done with the main thread!  I'll be nice and clean up the
resources my user doesn't need.  Let's see... we don't need 'engine'
anymore.  Ok, let's toss that.  How about 'db'?  I don't see that anyone
needs it, since write() is in its own little black bock.  Ok, let's toss
that aside too!"  Of course, I could be really wrong about this, but this
is my best guess.

The fix is to convince Python that it really should keep 'db': let's
include it as another argument to the write() function.  Here's an edit of
your program:

###
import win32com.client
import random
import time
import string
import thread

## Function write() writes a list to the database
def write(db, inputtage):
	if db==None:
		print 'el vomito 2' ## As was this...
	db.Execute("insert into data values(%f, '%s')" % inputtage)
	return 'ok'

if __name__=='__main__':
	engine = win32com.client.Dispatch("DAO.DBEngine.35")
	db = engine.OpenDatabase(r"windowsdesktopterror.mdb")
	tik_tok = time.time()
	surprize = random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
	the_madness = (tik_tok, surprize)
	thread.start_new_thread(write,(db, the_madness))
###

The way that this works is that when the main thread is done, and when it
sees if 'db' can be recycled for its bits, the new thread can step in and
say "Gimme!", and maintain db for its own use.  It also avoids global
variables.

I'll cross my fingers about this one... *grin*

Good luck!



From tbrauch@mindless.com  Fri Jun 15 00:03:07 2001
From: tbrauch@mindless.com (Timothy M. Brauch)
Date: Thu, 14 Jun 2001 19:03:07 -0400
Subject: [Tutor] Taking Mark Lutz's training course
References: <Pine.LNX.4.21.0106140801300.3418-100000@hkn.eecs.berkeley.edu>
Message-ID: <3B2942AB.C13CC8E2@mindless.com>

People have written:
> 
> > I have yet to find a college in the midwest that even teaches Python.
> > *sigh*
> 
> I actually tried to do a small "Introduction to Python" session in
> Berkeley once.  What a disaster!  The problem was that the language was so
> obvious, so simple, that I didn't need to say anything... *grin*
> 
> Truthfully, I'd need to improve my speaking skills before tackling
> something like that.

Centre College <http://www.centre.edu/> in Danville Kentucky (where I
currently attend) offers Python in the intro computer science class. 
C/C++ used to be offered, but too many people needed a cs class for
their majors (like biology majors) and they couldn't catch on to C/C++
ideas as easily.  So, we start with Python and a little post script and
SQL (using Gadfly), go to MIPS assembly langauge, then Java and/or C/C++
then C/C++ and/or Java (it depends which sequence they are currently
going, they are offered every other year I think).  Also, we can learn
Maple or Mathematica, if we are so inclined.

 - Tim


From guess-who@kevin-masako.com  Fri Jun 15 01:48:49 2001
From: guess-who@kevin-masako.com (Kevin & Masako Ollivier)
Date: Thu, 14 Jun 2001 20:48:49 -0400
Subject: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around
Message-ID: <011201c0f534$f1a809c0$6401a8c0@cox.rr.com>

Hi Patrick and Rob,

I also like both of your ideas! (BTW, thanks Patrick for sharing this with
the edu-sig list! I had not realized there was also a Tutor list!)

Building on the ideas you presented, what about an software tool (possibly
an "enhanced" version of IDLE?) that gives learners a set of successively
harder programming tasks? At any point, the learner can jump to a virtual
"help center" and view tutorials, the Python references, FAQs/trivia, or
even be given a way to ask a question on the lists. As the learner
successfully complete the tasks given to them, the software will keep a
record and let them know how far they are towards "mastery." (Of course,
true mastery comes only with experience, but it's a start!) I think it has
elements of everything discussed thus far, trivia, tutor, and testing. While
I'm not sure how we could "officially" certify people who complete the
training, we can at least give them a list of all the skills they've
gathered over the course of the training, along with when they were last
assessed.

I think making "real-world tasks" would help increase motivation and give
them examples of what Python is typically used for. The more real it seems,
the more it will be part-game and part-edusoft I think. If we did it well
enough, it could even lead to a finished software product, which is at least
as good as a certificate IMHO!

What do you all think?

Kevin Ollivier

--------------------------------------------
Reply-To: <pobrien@orbtech.com>
From: "Patrick K. O'Brien" <pobrien@orbtech.com>
To: <tutor@python.org>
Cc: "Python Edu SIG" <Edu-sig@python.org>
Date: Thu, 14 Jun 2001 10:42:06 -0500
Subject: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around

I like both of these ideas. Maybe there is a way to combine them. Perhaps
the only difference is the Trivial Pursuit version gives the answer and the
Certification version withholds the answer. The pyDoc module shows what you
can do to make the python interpreter even more interactive in terms of
presenting a lot of text and responding to requests for information. Perhaps
we could piggyback that module and create an interactive
trivia/tutor/testing/certification module. I bet the Edu Sig folks might be
interested in this as well.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of Rob
Andrews
Sent: Thursday, June 14, 2001 9:58 AM
To: tutor@python.org
Subject: [Tutor] a couple of ideas I've been bouncing around

In my ongoing quest for novel (twisted?) ways to add even more color to the
Python universe, I've come up with a few more ideas. I picked up Trivial
Pursuit Genus 5 the other day and thought it would be interesting to produce
a Python module for it, essentially a collection of questions and answers
about Python, broken down by general category (e.g., "Python Mythology",
"Data Structures", "Python History", etc.) using a color scheme compatible
with the one Trivial Pursuit uses. This could be printed up on some nice
card stock and actually used with the boxed game set.

The second idea is an actual test. Brainbench (http://www.brainbench.com)
offers a $19.95 certification in Python 1.5. With all the keen, experienced
minds and nearly inexhaustible number of questions archived on this list, we
should be able to come up with a nice test that generates a brief,
meaningful report on how one performed on it. """You were strong enough to
tutor another person in the areas of "strings" and "exception handling". You
seemed competent in "flow control" and "sockets". You should study more on
"OOP" and "embedding". You answered 87% correctly, soundly passing Python
Tutor Certification."""

I think anything we do along these general lines would help provide another
great learning tool and a healthy bit of fun all around.

Rob

"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor







From rob@jam.rr.com  Fri Jun 15 02:56:51 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Thu, 14 Jun 2001 20:56:51 -0500
Subject: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around
In-Reply-To: <011201c0f534$f1a809c0$6401a8c0@cox.rr.com>
Message-ID: <NFBBKIELCLIEEMGGIGKDCEAPCAAA.rob@jam.rr.com>

#
# Hi Patrick and Rob,
#
# I also like both of your ideas! (BTW, thanks Patrick for sharing this with
# the edu-sig list! I had not realized there was also a Tutor list!)
#

The Tutor list is great! I can't easily think of a more helpful, decent
group of people. And some of the answers to newbie coding questions could
easily be quoted verbatim in documentation.

# Building on the ideas you presented, what about an software tool (possibly
# an "enhanced" version of IDLE?) that gives learners a set of successively
# harder programming tasks? At any point, the learner can jump to a virtual
# "help center" and view tutorials, the Python references, FAQs/trivia, or
# even be given a way to ask a question on the lists. As the learner
# successfully complete the tasks given to them, the software will keep a
# record and let them know how far they are towards "mastery." (Of course,
# true mastery comes only with experience, but it's a start!) I think it has
# elements of everything discussed thus far, trivia, tutor, and
# testing. While
# I'm not sure how we could "officially" certify people who complete the
# training, we can at least give them a list of all the skills they've
# gathered over the course of the training, along with when they were last
# assessed.
#
# I think making "real-world tasks" would help increase motivation and give
# them examples of what Python is typically used for. The more real
# it seems,
# the more it will be part-game and part-edusoft I think. If we did it well
# enough, it could even lead to a finished software product, which
# is at least
# as good as a certificate IMHO!
#
# What do you all think?
#
# Kevin Ollivier
#

Sounds quite interesting, although quite far beyond my skill level. There
are probably lots of odd games we could develop using curses, pygame, etc.
to reinforce learning. If we came up with enough components, I could even
see a Python Learning Lab on sourceforge or similar (or on Useless Python
heehee).

Rob

"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/



From guess-who@kevin-masako.com  Fri Jun 15 04:12:55 2001
From: guess-who@kevin-masako.com (Kevin & Masako Ollivier)
Date: Thu, 14 Jun 2001 23:12:55 -0400
Subject: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing around
References: <NFBBKIELCLIEEMGGIGKDCEAPCAAA.rob@jam.rr.com>
Message-ID: <013a01c0f549$12f77980$6401a8c0@cox.rr.com>

----- Original Message -----
From: "Rob Andrews" <rob@jam.rr.com>
To: "Kevin & Masako Ollivier" <guess-who@kevin-masako.com>;
<tutor@python.org>; <Edu-sig@python.org>
Sent: Thursday, June 14, 2001 9:56 PM
Subject: RE: [Edu-sig] RE: [Tutor] a couple of ideas I've been bouncing
around


> #
> # Hi Patrick and Rob,
> #
> # I also like both of your ideas! (BTW, thanks Patrick for sharing this
with
> # the edu-sig list! I had not realized there was also a Tutor list!)
> #
>
> The Tutor list is great! I can't easily think of a more helpful, decent
> group of people. And some of the answers to newbie coding questions could
> easily be quoted verbatim in documentation.

Actually, I signed up to the Python edu-sig list just yesterday because I
was thinking about the very topic you were discussing. I had always wanted
to be able to teach family and friends who are computer users Python simply
because I often find myself writing little scripts to automate everyday,
repetitive tasks I do on the computer. I was hoping to bounce some ideas
back and forth through the list, and the same day I sign up I'm getting my
wish! =)

The classroom courses I've taken and books I've read almost seem to take all
the fun out of programming, and focus on learning syntax, not problem
solving. I remember in my first C programming class, one of the students
whispered to his friend "So when are we going to start learning how to
program GAMES?" That stuck with me. They didn't see how the lessons they
were learning could be used to create games. And if they don't see that (in
other words, they didn't see how what they were learning could accomplish
their goal), what are they going to take out of the class? If it's anything
like the Trig I learned... Nothing. =)

> # Building on the ideas you presented, what about an software tool
(possibly
> # an "enhanced" version of IDLE?) that gives learners a set of
successively
> # harder programming tasks? At any point, the learner can jump to a
virtual
> # "help center" and view tutorials, the Python references, FAQs/trivia, or
> # even be given a way to ask a question on the lists. As the learner
> # successfully complete the tasks given to them, the software will keep a
> # record and let them know how far they are towards "mastery." (Of course,
> # true mastery comes only with experience, but it's a start!) I think it
has
> # elements of everything discussed thus far, trivia, tutor, and
> # testing. While
> # I'm not sure how we could "officially" certify people who complete the
> # training, we can at least give them a list of all the skills they've
> # gathered over the course of the training, along with when they were last
> # assessed.
> #
> # I think making "real-world tasks" would help increase motivation and
give
> # them examples of what Python is typically used for. The more real
> # it seems,
> # the more it will be part-game and part-edusoft I think. If we did it
well
> # enough, it could even lead to a finished software product, which
> # is at least
> # as good as a certificate IMHO!
> #
> # What do you all think?
> #
> # Kevin Ollivier
> #
>
> Sounds quite interesting, although quite far beyond my skill level. There
> are probably lots of odd games we could develop using curses, pygame, etc.
> to reinforce learning. If we came up with enough components, I could even
> see a Python Learning Lab on sourceforge or similar (or on Useless Python
> heehee).

Some of it is beyond my skill level too. <gg> Of course I believe you don't
learn new skills until you need them, so I like to give myself a challenge
every now and then. =)

At the same time, there's quite a bit of work, programming and
non-programming, to go around! The tutorials would be quite a bit of work,
and then there's Trivial Python (errr... different name maybe?), and if
we're serious about the real-world scenarios then someone would have to drum
those up too. Like good object-oriented programmers, we could develop each
component separately then in the end integrate them into the software.

The Useless Python Learning Lab, huh? =) I have to admit the thing I don't
like about SourceForge is that it sometimes can be dead slow, or down at
times.

Thanks,

Kevin



From fallen@leveltwo.com  Fri Jun 15 17:34:46 2001
From: fallen@leveltwo.com (Fred Allen)
Date: Fri, 15 Jun 2001 09:34:46 -0700
Subject: [Tutor] PYTHONDOCS & Html Documentation
Message-ID: <4BB02C541824D311921600902765DB7B445602@LTISERVER>

Fellows:

I have modified my 'site.py' file with Guido's elegant redefinition of
__builtin__.help, posted on Edu-sig.

When, from Python's interactive screen, I invoke help for, say,
'keywords', behavior accords with expectation...i.e., a list of keywords
is presented.  But, when I invoke it for one of the keywords, say,
'lambda', I receive the following informative, courteous and well
phrased message:

“Sorry, topic and keyword documentation is not available because the
Python HTML documentation files could not be found.  If you have
installed them, please set the environment variable PYTHONDOCS to
indicate their location.”

That message's suggestion made sense, so I followed it.  That is, I
downloaded Python 2.1 HTML Documentation (15 April 2001), a 2008 Kb ZIP
file and extracted its 's contents into C:\Python21\Docs\Html, yielding
10 subdirectories, viz: api, dist, doc, ext, icons, inst, lib, mac, ref,
and tut.  I assume, but am by no means sure, this was the intention of
the error messages “installed.”

I next dutifully created the PYTHONDOCS environment variable (under
Windows 2000), ultimately evaluated thus:

PYTHONDOCS=C:\Python21\Docs\Html;C:\Python21\Docs\Html\api;C:\Python21\D
ocs\Html\dist;C:\Python21\Docs\Html\doc;C:\Python21\Docs\Html\ext;C:\Pyt
hon21\Docs\Html\icons;C:\Python21\Docs\Html\inst;C:\Python21\Docs\Html\l
ib;C:\Python21\Docs\Html\ref;C:\Python21\Docs\Html\tut

I've also tried assigning PYTHONDOCS only the value
“C:\Python21\Docs\Html”, the name of the expanded documentations top
directory, but it functioned as initially.  So does it now, despite the
environment variable's now explicitly citing every subdirectory.  I
attempted expressing PYTHONDOCS directories in Pythonese (e.g., as
arrays of strings).  All to no avail.

If I'm alone in this problem, I'm embarrassed, but consider that
worthwhile in exchange for learning what I'm doing or have done wrong.
With thanks in advance for any's help, I am,

Gratefully,

Fred Allen




From dyoo@hkn.eecs.berkeley.edu  Fri Jun 15 19:27:16 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 15 Jun 2001 11:27:16 -0700 (PDT)
Subject: [Tutor] PYTHONDOCS & Html Documentation
In-Reply-To: <4BB02C541824D311921600902765DB7B445602@LTISERVER>
Message-ID: <Pine.LNX.4.21.0106151117550.25145-100000@hkn.eecs.berkeley.edu>

On Fri, 15 Jun 2001, Fred Allen wrote:

> downloaded Python 2.1 HTML Documentation (15 April 2001), a 2008 Kb ZIP
> file and extracted its 's contents into C:\Python21\Docs\Html, yielding
> 10 subdirectories, viz: api, dist, doc, ext, icons, inst, lib, mac, ref,
> and tut.  I assume, but am by no means sure, this was the intention of

Sounds good!  Your PYTHONDOCS variable should then say:

    C:\Python21\Docs\Html


> I've also tried assigning PYTHONDOCS only the value
> =93C:\Python21\Docs\Html=94, the name of the expanded documentations top

Oh.

> So does it now, despite the environment variable's now explicitly
> citing every subdirectory.  I attempted expressing PYTHONDOCS
> directories in Pythonese (e.g., as arrays of strings).  All to no
> avail.

Ah!  Ok, you won't need to put every directory; the base directory is the
only one you'll need.  I think that pydoc expects PYTHONDOCS to name only
one directory.

Let me check.  Within the pydoc source code, there's one place where pydoc
uses PYTHONDOCS:

###
## within pydoc.Helper.__init__
       for dir in [os.environ.get('PYTHONDOCS'),
                # [dyoo: complicated paths removed to make
                #  explanation more simple]
            if dir and os.path.isdir(os.path.join(dir, 'lib')):
                self.docdir =3D dir
###

Basically, the code here says that it expects PYTHONDOCS to name a single
base directory --- it'll attach the subdirectory name 'lib' to it, and
then pydoc will be happy.

So the problem was adding too much to PYTHONDOCS.  Hope this helps!



From phil.bertram@clear.net.nz  Fri Jun 15 00:53:43 2001
From: phil.bertram@clear.net.nz (Phil Bertram)
Date: Fri, 15 Jun 2001 11:53:43 +1200
Subject: [Tutor] Extending  PythonWin as a quick and dirty GUI
Message-ID: <000301c0f5d0$4c34b820$363661cb@pf05nt.bayernz.co.nz>

Hi all,

I am trying to develop an app that uses a Tkinter GUI.
I am developing the code in 'text' mode and will hook in my GUI later.

I am under the impression that PythonWin can be simply and quickly extended
and used as a GUI for python code. Eg. One is able to add a couple of menu
items to PythonWin, run your code from these menus, print to the PythonWin
interactive window etc etc.

I would like to do this during development and when things are working, then
spend the time writing the proper GUI.

Is this possible with PythonWin ?

PB









From phil.bertram@clear.net.nz  Fri Jun 15 23:53:24 2001
From: phil.bertram@clear.net.nz (Phil Bertram)
Date: Sat, 16 Jun 2001 10:53:24 +1200
Subject: [Tutor] Option of passing sequences are arguments
Message-ID: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz>

Is it possible to unpack a sequence to fill arguments.
I have been playing around with *args type aruments but can't seem to get it
to work.

Eg

I would like to define a class so that it can be called as follows

m = MyObject(arg1,arg2,arg3)

or

args=(arg1,arg2,arg3)
x=MyObject(args)

Phil B




From kalle@gnupung.net  Sat Jun 16 00:31:11 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Sat, 16 Jun 2001 01:31:11 +0200
Subject: [Tutor] Option of passing sequences are arguments
In-Reply-To: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz>; from phil.bertram@clear.net.nz on Sat, Jun 16, 2001 at 10:53:24AM +1200
References: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz>
Message-ID: <20010616013111.A3960@gandalf>

Sez Phil Bertram:
> I would like to define a class so that it can be called as follows
> 
> m = MyObject(arg1,arg2,arg3)
> 
> or
> 
> args=(arg1,arg2,arg3)
> x=MyObject(args)

Python 2.1 (#1, Jun 15 2001, 00:08:24) 
[GCC 2.95.4 20010604 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> def f(*args):
...     print args
... 
>>> args = (1,2,3)
>>> f(1,2,3)
(1, 2, 3)
>>> f(args)
((1, 2, 3),)
>>> f(*args) # This only works in 2.1 (2.0?) and later
(1, 2, 3)
>>> apply(f, args)
(1, 2, 3)
>>> 

Peace,
  Kalle
-- 
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
 [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]


From j_f9@yahoo.com  Sat Jun 16 04:12:54 2001
From: j_f9@yahoo.com (F. Tourigny)
Date: Fri, 15 Jun 2001 20:12:54 -0700 (PDT)
Subject: [Tutor] Looking for an HTMLgen table example
In-Reply-To: <E15Aw21-0004UF-00@mail.python.org>
Message-ID: <20010616031254.72362.qmail@web14506.mail.yahoo.com>

I'm looking for a simple example of how to convert
ASCII strings into an html table with HTMLgen and,
more specifically, how to append rows, and put data
into cells.  I'm just starting with Python and the
HTMLcalendar.py and barchart.py demo modules coming
with the distribution are way over my head at this
point.  (They're proving to be a good read, though.)

Greetings,
Frederic




__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/


From jstanley@start.com.au  Sat Jun 16 06:37:40 2001
From: jstanley@start.com.au (Jordan Stanley)
Date: Sat, 16 Jun 2001 15:37:40 +1000
Subject: [Tutor] win98se path
Message-ID: <B3003135871@i01sv4071.ids1.intelonline.com>



__________________________________________________________________
Get your free Australian email account at http://www.start.com.au



From jstanley@start.com.au  Sat Jun 16 06:37:27 2001
From: jstanley@start.com.au (Jordan Stanley)
Date: Sat, 16 Jun 2001 15:37:27 +1000
Subject: [Tutor] win98se path
Message-ID: <B3003135870@i01sv4071.ids1.intelonline.com>



__________________________________________________________________
Get your free Australian email account at http://www.start.com.au



From jstanley@start.com.au  Sat Jun 16 06:39:20 2001
From: jstanley@start.com.au (Jordan Stanley)
Date: Sat, 16 Jun 2001 15:39:20 +1000
Subject: [Tutor] win98 path
Message-ID: <B3003135891@i01sv4071.ids1.intelonline.com>

with a lot of the examples i have the path is for linux which i dont
have installed at the moment.

when it says on the first line #/usr/src et cetera

in windblows do i change that to #/c:/python21/ ???

thanks in advance 

Jordan

mailto:jstanley@start.com.au


__________________________________________________________________
Get your free Australian email account at http://www.start.com.au



From ak@silmarill.org  Sat Jun 16 07:07:12 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Sat, 16 Jun 2001 02:07:12 -0400
Subject: [Tutor] win98 path
In-Reply-To: <"from jstanley"@start.com.au>
References: <B3003135891@i01sv4071.ids1.intelonline.com>
Message-ID: <20010616020712.A21199@sill.silmarill.org>

On Sat, Jun 16, 2001 at 03:39:20PM +1000, Jordan Stanley wrote:
> with a lot of the examples i have the path is for linux which i dont
> have installed at the moment.
> 
> when it says on the first line #/usr/src et cetera
> 
> in windblows do i change that to #/c:/python21/ ???
> 
> thanks in advance 
> 
> Jordan
> 
> mailto:jstanley@start.com.au

I don't have windows installed but I think you either have #!C:\path_to_python
OR don't have anything there, and windows just knows it's python source because
file is named .py. 


> 
> 
> __________________________________________________________________
> Get your free Australian email account at http://www.start.com.au
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lucifer Sam Siam cat
Always sitting by your side
Always by your side
That cat's something I can't explain
        - Syd


From wheelege@tsn.cc  Sat Jun 16 08:08:59 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Sat, 16 Jun 2001 17:08:59 +1000
Subject: [Tutor] win98 path
References: <B3003135891@i01sv4071.ids1.intelonline.com>
Message-ID: <009101c0f633$3772a880$0200a8c0@ACE>

> with a lot of the examples i have the path is for linux which i dont
> have installed at the moment.
>
> when it says on the first line #/usr/src et cetera
>
> in windblows do i change that to #/c:/python21/ ???
>

  It really depends on what your trying to do.  On Linux, that line will
make it a python scipt.  However, windows uses extensions to determine file
type.  If you installed python correctly then this will be already done for
you, and just double-clicking on a python script will run it in a
dos-window.
  If this already happens, and the box opens and closes too fast, try adding
a raw_input('Press any key to continue...') to the end of your script.
  If in fact you are looking to set up your PYTHONPATH environment variable
then that's different again.
  Is any of that what your looking for?

  Glen.



From toodles@yifan.net  Sat Jun 16 08:22:57 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Sat, 16 Jun 2001 15:22:57 +0800
Subject: [Tutor] randomness
Message-ID: <FPEHJJPEEOIPMAHOADBKGEBOCEAA.toodles@yifan.net>

Hi folks

What's a good way to generate a random unique file name? I can't use
os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with
Python 2.1 I could only think of this:

import os,random

files=os.listdir('threadhtml')
filename=''
while not filename:
 n=random.randint(0,100000)
 if not '%i.html' in files:
  filename='%i.html'

But it seems a bit yucky...can someone shed any light on the matter?

Thanks,

Andrew




From wheelege@tsn.cc  Sat Jun 16 08:22:10 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Sat, 16 Jun 2001 17:22:10 +1000
Subject: [Tutor] randomness
References: <FPEHJJPEEOIPMAHOADBKGEBOCEAA.toodles@yifan.net>
Message-ID: <009d01c0f635$0f567dc0$0200a8c0@ACE>

> Hi folks
>
> What's a good way to generate a random unique file name? I can't use
> os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with
> Python 2.1 I could only think of this:
>
> import os,random
>
> files=os.listdir('threadhtml')
> filename=''
> while not filename:
>  n=random.randint(0,100000)
>  if not '%i.html' in files:
>   filename='%i.html'
>
> But it seems a bit yucky...can someone shed any light on the matter?
>

  Hmmm, well I just used the string modules' predefined string.letters
variable and split it into a list, then did a random number of
random.choice() grabs from it and shoved them in a filename.
  Be sure to check if the file already exists.  I think your code does not
do 'unique file name'-s as you put it :)

  Glen.



From steve@mercury.in.cqsl.com  Sat Jun 16 08:40:02 2001
From: steve@mercury.in.cqsl.com (lonetwin@yahoo.com)
Date: Sat, 16 Jun 2001 13:10:02 +0530 (IST)
Subject: [Tutor] randomness
In-Reply-To: <FPEHJJPEEOIPMAHOADBKGEBOCEAA.toodles@yifan.net>
Message-ID: <Pine.LNX.4.21.0106161305320.7414-100000@mercury.in.cqsl.com>

Hi There, 

On Sat, 16 Jun 2001, Andrew Wilkins wrote:

>Hi folks
>
>What's a good way to generate a random unique file name? I can't use
>os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with
>Python 2.1 I could only think of this:
>
>import os,random
>
>files=os.listdir('threadhtml')
>filename=''
>while not filename:
> n=random.randint(0,100000)
> if not '%i.html' in files:
>  filename='%i.html'
>
>But it seems a bit yucky...can someone shed any light on the matter?

How 'bout 
	filename = "tmpfile%d.html" % os.getpid()
I've seen some *nix proggys do that, U cud also save the pid so that U can delete the file
later.....

Just a suggestion

Peace
Steve
-- 
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||	
|||/\##|||||||||##/\||	
|/    \#########/    \	
|\     \#######/     /	
||\____/#######\____/|	
=====================================	
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
====================================



From toodles@yifan.net  Sat Jun 16 08:38:37 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Sat, 16 Jun 2001 15:38:37 +0800
Subject: [Tutor] randomness
In-Reply-To: <FPEHJJPEEOIPMAHOADBKGEBOCEAA.toodles@yifan.net>
Message-ID: <FPEHJJPEEOIPMAHOADBKCEBPCEAA.toodles@yifan.net>

> import os,random
>
files=os.listdir('threadhtml')
filename=''
while not filename:
 n=random.randint(0,100000)
 if not '%i.html'%n in files:
 filename='%i.html'%n

I oughta check it before sending...

>
> But it seems a bit yucky...can someone shed any light on the matter?
>
> Thanks,
>
> Andrew
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>




From ak@silmarill.org  Sat Jun 16 08:33:26 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Sat, 16 Jun 2001 03:33:26 -0400
Subject: [Tutor] randomness
In-Reply-To: <"from toodles"@yifan.net>
References: <FPEHJJPEEOIPMAHOADBKGEBOCEAA.toodles@yifan.net>
Message-ID: <20010616033326.A22291@sill.silmarill.org>

On Sat, Jun 16, 2001 at 03:22:57PM +0800, Andrew Wilkins wrote:
> Hi folks
> 
> What's a good way to generate a random unique file name? I can't use
> os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with

                6.19 tempfile -- Generate temporary file names
            
               
   This module generates temporary file names. It is not Unix specific,
   but it may require some help on non-Unix systems.

[snip]

-- 
I'll give you anything, everything if you want things
        - Syd


From tutor@python.org  Sat Jun 16 08:44:08 2001
From: tutor@python.org (Tim Peters)
Date: Sat, 16 Jun 2001 03:44:08 -0400
Subject: [Tutor] randomness
In-Reply-To: <FPEHJJPEEOIPMAHOADBKGEBOCEAA.toodles@yifan.net>
Message-ID: <LNBBLJKPBEHFEDALKOLCOEKNKIAA.tim.one@home.com>

[Andrew Wilkins]
> What's a good way to generate a random unique file name? ...

The bad news is that it's surprisingly difficult to do this "correctly"
across platforms.  The good news is that's why Python does it for you:  look
in the Library Reference Manual for the standard tempfile.py module.

tempfile.TemporaryFile() is the best function to use from that, because it
returns an open file object as secure as possible against attacks.

tempfile.mktemp() can be used to get just a path name that didn't exist at
the time you called mktemp(), but it's impossible then to guarantee that
some other process won't create a file with that name before you get around
to doing so.  Python plays several tricks under the covers to make it
exceedingly unlikely that another process will do so, but "guarantee" is a
promise it can't make.

Note that tempfile.py works fine on all platforms (whether Unix, Windows or
Mac).



From r.b.rigilink@chello.nl  Sat Jun 16 08:57:50 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Sat, 16 Jun 2001 09:57:50 +0200
Subject: [Tutor] randomness
References: <FPEHJJPEEOIPMAHOADBKGEBOCEAA.toodles@yifan.net>
Message-ID: <3B2B117E.F95A1DF0@chello.nl>

Hi Andrew,

My quick and dirty solution is usually to use time.time() in the
filename. But if you're creating files in multiple threads (which I
gather you're doing) there is of course an (exceedingly) small
probabilty that files are created at the same moment.

But then again, your code below theoretically suffers from the same
problem (really, it does).

This is really safe:

file_creation_lock = Lock()

class Filecreator:
   file_number = 0:
   def __call__(self):
       Filecreator.file_number += 1
       return open('%6.6i.html' % Filecreator.file_number)

filecreator = Filecreator()

And in the thread:

    def run():
        ...
        file_creation_lock.acquire()
        file = filecreator()
	file_creation_lock.release()
        ...

But, then again, this may be overkill

Hope this helps,

Roeland

Andrew Wilkins wrote:
> 
> Hi folks
> 
> What's a good way to generate a random unique file name? I can't use
> os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with
> Python 2.1 I could only think of this:
> 
> import os,random
> 
> files=os.listdir('threadhtml')
> filename=''
> while not filename:
>  n=random.randint(0,100000)
>  if not '%i.html' in files:
>   filename='%i.html'
> 
> But it seems a bit yucky...can someone shed any light on the matter?
> 
> Thanks,
> 
> Andrew
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From arcege@speakeasy.net  Sat Jun 16 12:14:56 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Sat, 16 Jun 2001 07:14:56 -0400 (EDT)
Subject: [Tutor] Looking for an HTMLgen table example
In-Reply-To: <20010616031254.72362.qmail@web14506.mail.yahoo.com> from "F. Tourigny" at Jun 15, 2001 08:12:54 PM
Message-ID: <200106161114.f5GBEuW01841@dsl092-074-184.bos1.dsl.speakeasy.net>

F. Tourigny wrote
> I'm looking for a simple example of how to convert
> ASCII strings into an html table with HTMLgen and,
> more specifically, how to append rows, and put data
> into cells.  I'm just starting with Python and the
> HTMLcalendar.py and barchart.py demo modules coming
> with the distribution are way over my head at this
> point.  (They're proving to be a good read, though.)

I'd use the TableLite class; it is easier and more like the other
classes in HTMLgen.  Think about it like creating creating nested
lists.

>>> mylist = []
>>> for x in range(5):
...   sublist = []
...   for y in range(5, 10):
...     sublist.append( (x, y) )
...   mylist.append( sublist )
...

At this point you have a list of five sublists, each sublist
will have five tuples of the coordinates.
>>> print mylist
[[(0, 5), (0, 6), (0, 7), (0, 8), (0, 9)], [(1, 5), (1, 6), (1, 7), (1, 8),
(1, 9)], [(2, 5), (2, 6), (2, 7), (2, 8), (2, 9)], [(3, 5), (3, 6), (3, 7),
(3, 8), (3, 9)], [(4, 5), (4, 6), (4, 7), (4, 8), (4, 9)]]

Applying this to the HTMLgen, you can do something similar.
>>> import HTMLgen
>>> table = HTMLgen.TableLite()
>>> for x in range(5):
...   row = HTMLgen.TR()
...   for y in range(5, 10):
...     row.append( HTMLgen.TD( '%d, %d' % (x, y) ) ) # needs to be string
...   table.append( row )
...
>>> print table
<TABLE><TR><TD>0, 5</TD><TD>0, 6</TD><TD>0, 7</TD><TD>0, 8</TD><TD>0, 9</TD></TR>
<TR><TD>1, 5</TD><TD>1, 6</TD><TD>1, 7</TD><TD>1, 8</TD><TD>1, 9</TD></TR>
<TR><TD>2, 5</TD><TD>2, 6</TD><TD>2, 7</TD><TD>2, 8</TD><TD>2, 9</TD></TR>
<TR><TD>3, 5</TD><TD>3, 6</TD><TD>3, 7</TD><TD>3, 8</TD><TD>3, 9</TD></TR>
<TR><TD>4, 5</TD><TD>4, 6</TD><TD>4, 7</TD><TD>4, 8</TD><TD>4, 9</TD></TR>
</TABLE>

>>>

Captions are added as rows are and headers are added as columns.

HTH,
  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From lumbricus@gmx.net  Sat Jun 16 14:58:42 2001
From: lumbricus@gmx.net (lumbricus@gmx.net)
Date: Sat, 16 Jun 2001 15:58:42 +0200
Subject: [Tutor] randomness
In-Reply-To: <Pine.LNX.4.21.0106161305320.7414-100000@mercury.in.cqsl.com>; from steve@mercury.in.cqsl.com on Sat, Jun 16, 2001 at 01:10:02PM +0530
References: <FPEHJJPEEOIPMAHOADBKGEBOCEAA.toodles@yifan.net> <Pine.LNX.4.21.0106161305320.7414-100000@mercury.in.cqsl.com>
Message-ID: <20010616155842.A23710@Laplace.localdomain>

On Sat, Jun 16, 2001 at 01:10:02PM +0530, lonetwin@yahoo.com wrote:
> 
> Hi There, 
> 

Hello!

> >
> >What's a good way to generate a random unique file name? I can't use
> >os.tempnam/os.tmpnam, are they *nix specific? I'm using Windows ME with

> 
> How 'bout 
> 	filename = "tmpfile%d.html" % os.getpid()
> I've seen some *nix proggys do that, U cud also save the pid so that U can delete the file
> later.....
> 

man symlink-attacks :-)

> Just a suggestion
> 
> Peace
> Steve

Grreetz J"o!

-- 
Some people need a good imaginary cure for their painful imaginary ailment.


From dyoo@hkn.eecs.berkeley.edu  Sat Jun 16 19:59:22 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 16 Jun 2001 11:59:22 -0700 (PDT)
Subject: [Tutor] win98 path
In-Reply-To: <B3003135891@i01sv4071.ids1.intelonline.com>
Message-ID: <Pine.LNX.4.21.0106161155100.7006-100000@hkn.eecs.berkeley.edu>

On Sat, 16 Jun 2001, Jordan Stanley wrote:

> with a lot of the examples i have the path is for linux which i dont
> have installed at the moment.
> 
> when it says on the first line #/usr/src et cetera
> 
> in windblows do i change that to #/c:/python21/ ???

Hello Jordan,

If you're on a Windows system, you don't need to worry about the first
line.  The line:

###
#!/usr/local/bin/python
###

is called a "magic line", and Unix systems look at it when we want to make
our scripts executable as programs.  Windows doesn't do executables this
way (it does the .EXE way), so this top line isn't effective on a Windows
system.

By the way, which examples are you looking at?


Talk to you later!



From seedseven@home.nl  Sat Jun 16 20:19:41 2001
From: seedseven@home.nl (Ingo)
Date: Sat, 16 Jun 2001 21:19:41 +0200
Subject: [Tutor] Looking for an HTMLgen table example
Message-ID: <MWMail.rnrgtidr@host.none>

"F. Tourigny" <j_f9@yahoo.com> wrote on 2001-06-16 05:12:54:
>
>I'm looking for a simple example of how to convert
>ASCII strings into an html table with HTMLgen and,
>more specifically, how to append rows, and put data
>into cells.

Don't know what HTMLgen is, but here is the result of my struggle with the same 
problem. Beware, it's only my third Python script and still a work in progress. 
Comments are welcome. 

http://members.home.nl/seedseven/words2table.zip


Ingo

-- 
Photography:  http://members.home.nl/ingoogni/
POV-Ray:  http://members.home.nl/seed7/



From jparlar@home.com  Sat Jun 16 20:29:48 2001
From: jparlar@home.com (Jay Parlar)
Date: Sat, 16 Jun 2001 15:29:48 -0400
Subject: [Tutor] Simple example that won't work!
Message-ID: <20010616193516.YZPM7002.femail4.rdc1.on.home.com@jparlar>

Hello to all my fellow Python lovers. I'm only learning Python right now (after a few years working with the comparatively 
terrible C/C++) and I am absolutely loving it. To learn the language, I am using Wesley Chun's "Core Python Programming". 
It's a very good book with some really good examples, but it's with one of the examples that I'm having difficulty. 

The example is a simple web-based example. All it does is retrieve an HTML document, and print out the first and last non-
blank lines of the page. The error, though, occurs with the urlretrieve( ) call. When I call it, I get the following exception 
message:

Traceback (most recent call last):
  File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ?
    download()
  File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download
    retval= urlretrieve(url)[0]
  File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve
    return _urlopener.retrieve(url, filename, reporthook, data)
  File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve
    fp = self.open(url, data)
  File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open
    return getattr(self, name)(url)
  File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http
    h = httplib.HTTP(host)
  File "c:\program files\python20\lib\httplib.py", line 640, in __init__
    self._conn = self._connection_class(host, port)
  File "c:\program files\python20\lib\httplib.py", line 330, in __init__
    self._set_hostport(host, port)
  File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport
    port = int(host[i+1:])
ValueError: invalid literal for int(): 

My exact call was

retval = urlretrieve(url)[0], where url is any web address.

Now, the interesting thing is the code works fine on another computer it's been tried on, but no luck on mine. I'm running 
Win95b, with Python2.0 in the PythonWin environment.

Any help would be GREATLY appreciated,
Jay P.



From j_f9@yahoo.com  Sun Jun 17 00:01:54 2001
From: j_f9@yahoo.com (F. Tourigny)
Date: Sat, 16 Jun 2001 16:01:54 -0700 (PDT)
Subject: [Tutor] Looking for an HTMLgen table example
In-Reply-To: <E15Aw21-0004UF-00@mail.python.org>
Message-ID: <20010616230154.63839.qmail@web14503.mail.yahoo.com>

And by passing arguments as they do in the
HTMLcalendar.py example:

table = HTMLgen.TableLite(cellpadding=6,
cellspacing=2, border=3)

...I get a great table display.  An amazing tool,
HTMLgen.  Thanks for helping me use it.

> I'd use the TableLite class; it is easier and more
> like the other classes in HTMLgen.  Think about it
> like creating creating nested lists.
> 
> HTH,
>  -Arcege

Greetings,
Frederic







__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/


From ak@silmarill.org  Sun Jun 17 02:56:00 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Sat, 16 Jun 2001 21:56:00 -0400
Subject: [Tutor] Simple example that won't work!
In-Reply-To: <"from jparlar"@home.com>
References: <20010616193516.YZPM7002.femail4.rdc1.on.home.com@jparlar>
Message-ID: <20010616215600.A2779@sill.silmarill.org>

On Sat, Jun 16, 2001 at 03:29:48PM -0400, Jay Parlar wrote:
> 
> Hello to all my fellow Python lovers. I'm only learning Python right now (after a few years working with the comparatively 
> terrible C/C++) and I am absolutely loving it. To learn the language, I am using Wesley Chun's "Core Python Programming". 
> It's a very good book with some really good examples, but it's with one of the examples that I'm having difficulty. 
> 
> The example is a simple web-based example. All it does is retrieve an HTML document, and print out the first and last non-
> blank lines of the page. The error, though, occurs with the urlretrieve( ) call. When I call it, I get the following exception 
> message:
> 
> Traceback (most recent call last):
>   File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript
>     exec codeObject in __main__.__dict__
>   File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ?
>     download()
>   File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download
>     retval= urlretrieve(url)[0]
>   File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve
>     return _urlopener.retrieve(url, filename, reporthook, data)
>   File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve
>     fp = self.open(url, data)
>   File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open
>     return getattr(self, name)(url)
>   File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http
>     h = httplib.HTTP(host)
>   File "c:\program files\python20\lib\httplib.py", line 640, in __init__
>     self._conn = self._connection_class(host, port)
>   File "c:\program files\python20\lib\httplib.py", line 330, in __init__
>     self._set_hostport(host, port)
>   File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport
>     port = int(host[i+1:])
> ValueError: invalid literal for int(): 
> 
> My exact call was
> 
> retval = urlretrieve(url)[0], where url is any web address.
> 
> Now, the interesting thing is the code works fine on another computer it's been tried on, but no luck on mine. I'm running 
> Win95b, with Python2.0 in the PythonWin environment.
> 
> Any help would be GREATLY appreciated,
> Jay P.

The problem is that there was a bug in python where it'd accept (host,port)
as an argument in some situation, and then it was fixed to accept ((host, port))- in other words, a tuple containing 2 elements instead of just two elements.
This pops up all the time when you're using code written for before 2.0 I think.
So, you can either fix that or use 1.5.2.

> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lime and limpid green
a second scene
A fight between the blue
you once knew
        - Syd


From dyoo@hkn.eecs.berkeley.edu  Sun Jun 17 04:55:43 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 16 Jun 2001 20:55:43 -0700 (PDT)
Subject: [Tutor] win98 path (fwd)
Message-ID: <Pine.LNX.4.21.0106162047170.11370-100000@hkn.eecs.berkeley.edu>

Dear Jordan,

Hmmm... I haven't had a chance to look at Teach Yourself Python in 21
Hours, though the title seems a bit... hasty.  *grin* I think you mean 21
days.  In any case, you shouldn't have to worry too much about platform
dependent stuff: the core of Python works the same on Windows, Unix, Mac,
and anything else out there.


Here's the syntax for the "Press enter to continue" thing:

###
raw_input("Please press enter to continue.")
###

If you put that line at the end, then Python will wait until you type
enter.  The real purpose of raw_input() is to allow users to type
information for a program, but in a pinch, raw_input() also works well as
something to stop the program from closing prematurely.

Oh, finally, make sure to do the "Reply to All" thing on tutor email, so
that others can answer your questions too.

Good luck to you!  Hope this helps.


---------- Forwarded message ----------
Date: Sun, 17 Jun 2001 9:58:04 +1000
From: Jordan Stanley <jstanley@start.com.au>
To: "dyoo@hkn.eecs.berkeley.edu" <dyoo@hkn.eecs.berkeley.edu>
Subject: Re: Re: [Tutor] win98 path

i bought a book called sams teach yourself python in 21 hours. its
quite good, except that it doesnt give win or *nix egs it just has
generic code, and doesnt tell you how to stop the code just exiting
straight away. someone else i think glen wheeler wrote me about it
some thing like raw input "press any key to continue" but i dont know
the correct syntax for that.

thanks

jordan

By the way, which examples are you looking at?
>
>


__________________________________________________________________
Get your free Australian email account at http://www.start.com.au




From adam0@tsn.cc  Sun Jun 17 06:51:41 2001
From: adam0@tsn.cc (Adam Gordon)
Date: Sun, 17 Jun 2001 15:51:41 +1000
Subject: [Tutor] A (not so) simple question? Round Robin
Message-ID: <001601c0f6f1$9886dba0$05a616ca@computer1>

This is a multi-part message in MIME format.

------=_NextPart_000_0013_01C0F745.66CBA4C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

  Hey Guys!

  I am just starting to learn python (after hearing my friend praise it =
like a religion :) and thought I'd try out a few classic problems to =
help the learning process.
  So, I went to Useless Python to check out the challenges, and then =
went to the High School comp section.  I went to the 2000 open =
competition and looked for some fun problems.  One which caught my eye =
was a Round Robin problem - didn't look too hard or too easy.
  But, for the life of me I cannot do it!  I've spent quite some time =
mulling it over but still an elegant solution eludes me...here is a copy =
of the problem as found on the website (here =
http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml).


##start task
Task 5 - Round Robin
Description
n teams are to play each other in a competition. In each round each team =
plays exactly one other team. We wish to have as few rounds as possible. =


Write a program which, given an even number n, produces a "draw table" =
showing which team plays which team in each round. It is to take the =
minimum possible number of rounds. If more than one such draw table is =
possible your program may return whichever you wish.=20

For example here is an 4 player draw table=20

  A B C D
A   1 2 3
B 1   3 2
C 2 3   1
D 3 2 1

The letters represent the four teams, the numbers say which round each =
pair of teams is playing.=20

Test Data
      Number of teams =20
      4 =20
      6 =20
      8 =20
      10 =20

Output
Match the format of the output in the example above.=20
Where there is more than one "draw table" you may return whichever you =
wish.=20

Constraints
You may assume the input is even.=20

##end task

  I apologize to anybody with a non-html friendly e-mail client for =
spamming them with gibberish :)

  Thanks in advance,
  Adam.

------=_NextPart_000_0013_01C0F745.66CBA4C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV>&nbsp; Hey Guys!</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; I am just starting to learn python (after hearing my friend =
praise=20
it like&nbsp;a religion :) and thought I'd try out a few classic =
problems to=20
help the learning process.</DIV>
<DIV>&nbsp; So, I went to Useless Python to check out the challenges, =
and then=20
went to the High School comp section.&nbsp; I went to the 2000 open =
competition=20
and looked for some fun problems.&nbsp; One which caught my eye was a =
Round=20
Robin problem - didn't look too hard or too easy.</DIV>
<DIV>&nbsp; But, for the life of me I cannot do it!&nbsp; I've spent =
quite some=20
time mulling it over but still an elegant solution eludes me...here is a =
copy of=20
the problem as found on the website (here <A=20
href=3D"http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.ph=
tml">http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml=
</A>).</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>##start task</DIV>
<DIV>
<H1 align=3Dcenter>Task 5 - Round Robin</H1>
<H2>Description</H2>
<P><I>n</I> teams are to play each other in a competition. In each =
<I>round</I>=20
each team plays exactly one other team. We wish to have as few rounds as =

possible.=20
<P>Write a program which, given an even number <I>n</I>, produces a =
"draw table"=20
showing which team plays which team in each round. It is to take the =
minimum=20
possible number of rounds. If more than one such draw table is possible =
your=20
program may return whichever you wish.=20
<P>For example here is an 4 player draw table <PRE>  A B C D
A   1 2 3
B 1   3 2
C 2 3   1
D 3 2 1
</PRE>
<P>The letters represent the four teams, the numbers say which round =
each pair=20
of teams is playing.=20
<H3>Test Data</H3>
<TABLE border=3D1>
  <TBODY>
  <TR>
    <TH>Number of teams=20
  <TR>
    <TD>4=20
  <TR>
    <TD>6=20
  <TR>
    <TD>8=20
  <TR>
    <TD>10 </TD></TR></TBODY></TABLE>
<H3>Output</H3>Match the format of the output in the example above.=20
<P>Where there is more than one "draw table" you may return whichever =
you wish.=20
<H3>Constraints</H3>You may assume the input is even. </DIV>
<DIV>&nbsp;</DIV>
<DIV>##end task</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; I apologize to anybody with a non-html friendly e-mail =
client for=20
spamming them with gibberish :)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Thanks in advance,</DIV>
<DIV>&nbsp; Adam.</DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_0013_01C0F745.66CBA4C0--



From csmith@blakeschool.org  Sun Jun 17 18:51:05 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Sun, 17 Jun 2001 12:51:05 -0500
Subject: [Tutor] Mac 1011 error after installation
In-Reply-To: <E15Bez4-00019x-00@mail.python.org>
References: <E15Bez4-00019x-00@mail.python.org>
Message-ID: <fc.004c4b6b00755b1c3b9aca0088562d76.755b1d@blakeschool.org>

Hello,

I just tried to install the 2.1 Python on my Mac and have run into a
problem.  After a succcessful installation, when I try to run the IDE it
quits with Mac error 1011 just after the splash screen goes away and the
editor window appears.  Has anyone else encountered this or know what
might be wrong?

Thanks for any help.

/c



From glingl@aon.at  Sun Jun 17 21:03:02 2001
From: glingl@aon.at (Gregor Lingl)
Date: Sun, 17 Jun 2001 22:03:02 +0200
Subject: [Tutor] A (not so) simple question? Round Robin
References: <001601c0f6f1$9886dba0$05a616ca@computer1>
Message-ID: <3B2D0CF6.5566EE8F@aon.at>

--------------C754C59664FDB96DF7AC6849
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit



Adam Gordon schrieb:

>   Hey Guys!   I am just starting to learn python (after hearing my
> friend praise it like a religion :) and thought I'd try out a few
> classic problems to help the learning process.  So, I went to Useless
> Python to check out the challenges, and then went to the High School
> comp section.  I went to the 2000 open competition and looked for some
> fun problems.  One which caught my eye was a Round Robin problem -
> didn't look too hard or too easy.  But, for the life of me I cannot do
> it!  I've spent quite some time mulling it over but still an elegant
> solution eludes me...here is a copy of the problem as found on the
> website (here
> http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml).  ##start
> task
>
>                          Task 5 - Round Robin
>
> Description
>
> n teams are to play each other in a competition. In each round each
> team plays exactly one other team. We wish to have as few rounds as
> possible.
>
> Write a program which, given an even number n, produces a "draw table"
> showing which team plays which team in each round. It is to take the
> minimum possible number of rounds. If more than one such draw table is
> possible your program may return whichever you wish.
>
> For example here is an 4 player draw table
>
>   A B C D
> A   1 2 3
> B 1   3 2
> C 2 3   1
> D 3 2 1
>
> The letters represent the four teams, the numbers say which round each
> pair of teams is playing.
>
> Test Data
>
>

  Number of teams
  4
  6
  8
  10
>
> Output
>
> Match the format of the output in the example above.
>
> Where there is more than one "draw table" you may return whichever you
> wish.
>
> Constraints
>
> You may assume the input is even. ##end task   I apologize to anybody
> with a non-html friendly e-mail client for spamming them with
> gibberish :)   Thanks in advance,  Adam.

Here is a quick and dirty solution. Not very Pythonesque, more a
classical approach.
Take it as a challenge for Pythonistas to find a more *beautiful* one.
( http://www.lowerstandard.com/python/beautycontest.txt )

def roundrobin(n):
    # setup table
    global table
    table = [range(n)]
    for i in range(1,n):
        row = [i]
        while len(row)<n: row.append(0)
        table.append(row)
    # perform recursive brute search
    findround(1,2,n)
    # output in a dirty manner:
    for row in table: print row

def findround(row,col,dim):
    global table
    candidates = range(dim) # candidates for round to play the game
    # remove candidates already in the same row
    for i in range(col): candidates.remove(table[row][i])
    # remove candidates in rows already constructed
    for i in range(row):
        if table[i][col] in candidates: candidates.remove(table[i][col])

    for i in candidates:
        # try round nr. i
        table[row][col]=i
        table[col][row]=i
        if (row == dim-2) and (col == dim-1):
            # everything found
            return 1
        if col < dim - 1:
            if findround(row,col+1,dim):
                return 1
        elif row < dim - 2:
            if findround(row+1,row+2,dim):
                return 1
        # undo the try
        table[row][col]=0
        table[col][row]=0
    # no success
    return 0

# an now call for instance:

roundrobin(10)

--------------C754C59664FDB96DF7AC6849
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
&nbsp;
<p>Adam Gordon schrieb:
<blockquote TYPE=CITE><style></style>
<font face="Arial"><font size=-1>&nbsp;
Hey Guys!</font></font>&nbsp;<font face="Arial"><font size=-1>&nbsp; I
am just starting to learn python (after hearing my friend praise it like
a religion :) and thought I'd try out a few classic problems to help the
learning process.</font></font><font face="Arial"><font size=-1>&nbsp;
So, I went to Useless Python to check out the challenges, and then went
to the High School comp section.&nbsp; I went to the 2000 open competition
and looked for some fun problems.&nbsp; One which caught my eye was a Round
Robin problem - didn't look too hard or too easy.</font></font><font face="Arial"><font size=-1>&nbsp;
But, for the life of me I cannot do it!&nbsp; I've spent quite some time
mulling it over but still an elegant solution eludes me...here is a copy
of the problem as found on the website (here <a href="http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml">http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml</a>).</font></font>&nbsp;&nbsp;<font face="Arial"><font size=-1>##start
task</font></font>
<center>
<h1>
<font face="Arial"><font size=-1>Task 5 - Round Robin</font></font></h1></center>

<h2>
<font face="Arial"><font size=-1>Description</font></font></h2>
<font face="Arial"><font size=-1><i>n</i> teams are to play each other
in a competition. In each <i>round</i> each team plays exactly one other
team. We wish to have as few rounds as possible.</font></font>
<p><font face="Arial"><font size=-1>Write a program which, given an even
number <i>n</i>, produces a "draw table" showing which team plays which
team in each round. It is to take the minimum possible number of rounds.
If more than one such draw table is possible your program may return whichever
you wish.</font></font>
<p><font face="Arial"><font size=-1>For example here is an 4 player draw
table</font></font>
<pre><font face="Arial"><font size=-1>&nbsp; A B C D
A&nbsp;&nbsp; 1 2 3
B 1&nbsp;&nbsp; 3 2
C 2 3&nbsp;&nbsp; 1
D 3 2 1</font></font></pre>
<font face="Arial"><font size=-1>The letters represent the four teams,
the numbers say which round each pair of teams is playing.</font></font>
<h3>
<font face="Arial"><font size=-1>Test Data</font></font></h3>

<table BORDER >
<caption><TBODY>
<br></TBODY></caption>

<tr>
<th>Number of teams&nbsp;</th>
</tr>

<tr>
<td>4&nbsp;</td>
</tr>

<tr>
<td>6&nbsp;</td>
</tr>

<tr>
<td>8&nbsp;</td>
</tr>

<tr>
<td>10&nbsp;</td>
</tr>
</table>

<h3>
Output</h3>
Match the format of the output in the example above.
<p>Where there is more than one "draw table" you may return whichever you
wish.
<h3>
Constraints</h3>
You may assume the input is even.&nbsp;##end task&nbsp;&nbsp; I apologize
to anybody with a non-html friendly e-mail client for spamming them with
gibberish :)&nbsp;&nbsp; Thanks in advance,&nbsp; Adam.</blockquote>

<p><br><tt>Here is a quick and dirty solution. Not very Pythonesque, more
a classical approach.</tt>
<br><tt>Take it as a challenge for Pythonistas to find a more *beautiful*
one.</tt>
<br><tt>( <a href="http://www.lowerstandard.com/python/beautycontest.txt">http://www.lowerstandard.com/python/beautycontest.txt</a>
)</tt><tt></tt>
<p><tt>def roundrobin(n):</tt>
<br><tt>&nbsp;&nbsp;&nbsp; # setup table</tt>
<br><tt>&nbsp;&nbsp;&nbsp; global table</tt>
<br><tt>&nbsp;&nbsp;&nbsp; table = [range(n)]</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for i in range(1,n):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; row = [i]</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while len(row)&lt;n:
row.append(0)</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table.append(row)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; # perform recursive brute search</tt>
<br><tt>&nbsp;&nbsp;&nbsp; findround(1,2,n)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; # output in a dirty manner:</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for row in table: print row</tt>
<br><tt>&nbsp;</tt>
<br><tt>def findround(row,col,dim):</tt>
<br><tt>&nbsp;&nbsp;&nbsp; global table</tt>
<br><tt>&nbsp;&nbsp;&nbsp; candidates = range(dim) # candidates for round
to play the game</tt>
<br><tt>&nbsp;&nbsp;&nbsp; # remove candidates already in the same row</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for i in range(col): candidates.remove(table[row][i])</tt>
<br><tt>&nbsp;&nbsp;&nbsp; # remove candidates in rows already constructed</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for i in range(row):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if table[i][col] in
candidates: candidates.remove(table[i][col])</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for i in candidates:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # try round nr. i</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table[row][col]=i</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table[col][row]=i</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (row == dim-2) and
(col == dim-1):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# everything found</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return 1</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if col &lt; dim - 1:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if findround(row,col+1,dim):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return 1</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elif row &lt; dim -
2:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if findround(row+1,row+2,dim):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return 1</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # undo the try</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table[row][col]=0</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table[col][row]=0</tt>
<br><tt>&nbsp;&nbsp;&nbsp; # no success</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return 0</tt><tt></tt>
<p><tt># an now call for instance:</tt><tt></tt>
<p><tt>roundrobin(10)</tt>
</body>
</html>

--------------C754C59664FDB96DF7AC6849--



From dyoo@hkn.eecs.berkeley.edu  Mon Jun 18 00:57:40 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 17 Jun 2001 16:57:40 -0700 (PDT)
Subject: [Tutor] Mac 1011 error after installation
In-Reply-To: <fc.004c4b6b00755b1c3b9aca0088562d76.755b1d@blakeschool.org>
Message-ID: <Pine.LNX.4.21.0106171647500.26605-100000@hkn.eecs.berkeley.edu>

On Sun, 17 Jun 2001, Christopher Smith wrote:

> I just tried to install the 2.1 Python on my Mac and have run into a
> problem.  After a succcessful installation, when I try to run the IDE it
> quits with Mac error 1011 just after the splash screen goes away and the
> editor window appears.  Has anyone else encountered this or know what
> might be wrong?

Ouch!  This sounds really specific to Macs; I don't have experience with
them at all.  If no one answers this soon, you might want to ask your
question on the main comp.lang.python group.  Another good place to ask is
on the MacPython mailing list:

    http://www.python.org/mailman/listinfo/pythonmac-sig


According to:

    http://www.peter.com.au/programming/mac-os-errors.html

error 1011 matches up with the error: "Mixed mode failure".  Dunno what 
that means, but perhaps it might be familiar to someone else.

I hope someone can help you with this.  Best of luck!



From dyoo@hkn.eecs.berkeley.edu  Mon Jun 18 00:58:10 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 17 Jun 2001 16:58:10 -0700 (PDT)
Subject: [Tutor] Option of passing sequences are arguments
In-Reply-To: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz>
Message-ID: <Pine.LNX.4.21.0106161147170.7006-100000@hkn.eecs.berkeley.edu>

On Sat, 16 Jun 2001, Phil Bertram wrote:

> Is it possible to unpack a sequence to fill arguments. I have been
> playing around with *args type aruments but can't seem to get it to
> work.

Yes, this is possible.


> I would like to define a class so that it can be called as follows
> 
> m = MyObject(arg1,arg2,arg3)
> 
> or
> 
> args=(arg1,arg2,arg3)
> x=MyObject(args)


It sounds like you're looking for the apply() function:

###
>>> def h(a, b):
...     return (a**2 + b**2)**.5
...
>>> args = (3, 4)
>>> apply(h, args)
5.0
###

apply() will take in a function and a tuple.  Once it has those things, it
will call h, and use the tuple as a source for the arguments.

If you want more examples, or if you have questions about it, feel free to
ask us!  Good luck!




From deirdre@deirdre.net  Mon Jun 18 02:07:52 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Sun, 17 Jun 2001 18:07:52 -0700
Subject: [Tutor] Mac 1011 error after installation
In-Reply-To: <Pine.LNX.4.21.0106171647500.26605-100000@hkn.eecs.berkeley.edu>
References: <Pine.LNX.4.21.0106171647500.26605-100000@hkn.eecs.berkeley.edu>
Message-ID: <a05100e19b753046a8afe@[169.254.97.23]>

At 4:57 PM -0700 6/17/01, Danny Yoo wrote:
>According to:
>
>     http://www.peter.com.au/programming/mac-os-errors.html
>
>error 1011 matches up with the error: "Mixed mode failure".  Dunno what
>that means, but perhaps it might be familiar to someone else.
>
>I hope someone can help you with this.  Best of luck!

I know what it means, but it mystifies me.

The Mixed Mode manager is a set of library routines to execute 68k 
code on a PowerPC. Why there would be any 68k code on the Python IDE 
is beyond me!
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From sburr@mac.com  Mon Jun 18 06:44:20 2001
From: sburr@mac.com (Steven Burr)
Date: Sun, 17 Jun 2001 22:44:20 -0700
Subject: [Tutor] Option of passing sequences are arguments
In-Reply-To: <000a01c0f5ee$83f44820$22c6a7cb@pf05nt.bayernz.co.nz>
Message-ID: <20010618054242.YSMA5596.femail17.sdc1.sfba.home.com@localhost>

On Friday, June 15, 2001, at 03:53 PM, Phil Bertram wrote:

> Is it possible to unpack a sequence to fill arguments.
> I have been playing around with *args type aruments but can't seem to 
> get it
> to work.
>
> Eg
>
> I would like to define a class so that it can be called as follows
>
> m = MyObject(arg1,arg2,arg3)
>
> or
>
> args=(arg1,arg2,arg3)
> x=MyObject(args)

I think this may be the kind of thing you're looking for (the __str__ 
method is just
for testing purposes):

import types

class MyObject:

     def __init__(self, *args):
             if len(args) == 1 and type(args[0]) != types.StringType:
                     try:  test = args[0][0]
                     except TypeError:  self.args = args
                     else:  self.args = args[0]
             else:  self.args = args

     def __str__(self):
             return ' '.join([str(x) for x in self.args])

a = MyObject("It's", 'only', 'a', 'flesh', 'wound!')
print a

args = ("I've", 'had', 'worse.')
b = MyObject(args)
print b

c = MyObject("You're a loony!")
print c

d = MyObject(1)
print d


RESULT:

It's only a flesh wound!
I've had worse.
You're a loony!
1


From dyoo@hkn.eecs.berkeley.edu  Mon Jun 18 08:50:12 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 18 Jun 2001 00:50:12 -0700 (PDT)
Subject: [Tutor] An IDLE introduction
Message-ID: <Pine.LNX.4.21.0106180046560.31625-100000@hkn.eecs.berkeley.edu>

Hiya everyone,

I'm starting to write up a small IDLE introduction for people who're just
starting Python.  As it is, it's really, really rough.  I haven't finished
writing in the comments, it still needs more image-captures, and all the
writing needs to be rewritten for clarity.

Still, I wanted to see if this sort of thing would be useful for people.  
Here's the web link (still disconnected from my main site):

    http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/

Any comments would be greatly appreciated.  Thanks!



From glingl@aon.at  Mon Jun 18 09:32:02 2001
From: glingl@aon.at (Gregor Lingl)
Date: Mon, 18 Jun 2001 10:32:02 +0200
Subject: [Tutor] A (not so) simple question? Round Robin
References: <001601c0f6f1$9886dba0$05a616ca@computer1> <3B2D0CF6.5566EE8F@aon.at>
Message-ID: <3B2DBC82.AFC9B4D2@aon.at>


Yesterday I posted a solution to the 'round-robin'-problem asked for
by Adam Gordon.

This solution (shown below) delivers solutions to the "test-data" of the

problem-setting (i. e. for up to 10 teams) immediately.

However, for a solution for 12 teams it needs 4 secs (on my machine),
and for 14 teams 2400 secs. Sort of exponential runtime-behaviour.

Consequently arises the question not only for a more beautiful program,
but also for a more efficient algorithm (for there are certainly
competitions with more than 14 teams).

Seems interesting to me (although it probably is a so called 'well
known'
problem.)

Well known to somebody of you?

With curiosity
Gregor Lingl



> Here is a quick and dirty solution. Not very Pythonesque, more a
> classical approach.
> Take it as a challenge for Pythonistas to find a more *beautiful* one.
>
> ( http://www.lowerstandard.com/python/beautycontest.txt )
>
> def roundrobin(n):
>     # setup table
>     global table
>     table = [range(n)]
>     for i in range(1,n):
>         row = [i]
>         while len(row)<n: row.append(0)
>         table.append(row)
>     # perform recursive brute search
>     findround(1,2,n)
>     # output in a dirty manner:
>     for row in table: print row
>
> def findround(row,col,dim):
>     global table
>     candidates = range(dim) # candidates for round to play the game
>     # remove candidates already in the same row
>     for i in range(col): candidates.remove(table[row][i])
>     # remove candidates in rows already constructed
>     for i in range(row):
>         if table[i][col] in candidates:
> candidates.remove(table[i][col])
>     for i in candidates:
>         # try round nr. i
>         table[row][col]=i
>         table[col][row]=i
>         if (row == dim-2) and (col == dim-1):
>             # everything found
>             return 1
>         if col < dim - 1:
>             if findround(row,col+1,dim):
>                 return 1
>         elif row < dim - 2:
>             if findround(row+1,row+2,dim):
>                 return 1
>         # undo the try
>         table[row][col]=0
>         table[col][row]=0
>     # no success
>     return 0
>
> # an now call for instance:
>
> roundrobin(10)



From wheelege@tsn.cc  Mon Jun 18 11:37:51 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 18 Jun 2001 20:37:51 +1000
Subject: [Tutor] A (not so) simple question? Round Robin
References: <001601c0f6f1$9886dba0$05a616ca@computer1> <3B2D0CF6.5566EE8F@aon.at> <3B2DBC82.AFC9B4D2@aon.at>
Message-ID: <008b01c0f7e2$ba19daa0$0200a8c0@ACE>

>
>
> Yesterday I posted a solution to the 'round-robin'-problem asked for
> by Adam Gordon.
>
> This solution (shown below) delivers solutions to the "test-data" of the
>
> problem-setting (i. e. for up to 10 teams) immediately.
>
> However, for a solution for 12 teams it needs 4 secs (on my machine),
> and for 14 teams 2400 secs. Sort of exponential runtime-behaviour.
>
> Consequently arises the question not only for a more beautiful program,
> but also for a more efficient algorithm (for there are certainly
> competitions with more than 14 teams).
>
> Seems interesting to me (although it probably is a so called 'well
> known'
> problem.)
>
> Well known to somebody of you?
>

  Hmmm well with regards to the performance issue, I did notice quite a few
'in' keywords.  And we all know what linear buggers they are :)  This script
could probably benefit exponentailly (ha ha) from using dictionaries as
opposed to lists, then a simple has_key() call instead of 'in'.
  The beauty I can't really help you with - my python programs struggle to
be elegant, let alone beautiful.  Although I do know of several that I
consider so...just not the ones I code :)
  It sure is an interesting problem.  Perhaps a whole new unexpected
approach would make it all alot easier?  Brute force is usually just the tip
of an iceberg.

  Glen.



From wheelege@tsn.cc  Mon Jun 18 11:55:41 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 18 Jun 2001 20:55:41 +1000
Subject: [Tutor] A (not so) simple question? Round Robin
References: <001601c0f6f1$9886dba0$05a616ca@computer1> <3B2D0CF6.5566EE8F@aon.at> <3B2DBC82.AFC9B4D2@aon.at> <008b01c0f7e2$ba19daa0$0200a8c0@ACE>
Message-ID: <009b01c0f7e5$37b5b2c0$0200a8c0@ACE>

>   Hmmm well with regards to the performance issue, I did notice quite a
few
> 'in' keywords
> <..snip..>

  Argh, that's what sleep deprivation will do to you.  There is only one
'in' keyword being used the way I meant...still, it would increase speed to
use a hash...but prbably not to the extent your looking for.
  Whoops again,

  Glen.



From aschmidt@nv.cc.va.us  Mon Jun 18 12:10:57 2001
From: aschmidt@nv.cc.va.us (Schmidt, Allen J.)
Date: Mon, 18 Jun 2001 07:10:57 -0400
Subject: [Tutor] An IDLE introduction
Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090688C0C9@novamail.nvcc.vccs.edu>

Looks great so far! 

As a side note...I use a tool called ViewletBuilder2 from www.Qarbon.com to
create step-by-step or interactive tutorials on various topics. Start a new
VB2 project and it minimizes itself. Then just do whatever you normally do.
Hit the PAUSE key anytime to capture a screenshot as often as you need. It
tracks mouse movement, too. Then when finished, it jumps to the thumbnail
view of all you captured. You can then go to each slide and add text
balloons and callout bubbles to add your own information to the slide. Even
records for voice annotation.

This would certainly add clarity to for me on many Python topics. And
completed Viewlets can be added for free to the library that anyone can
view. Or serve them up for your own use or limited audience. The builder is
Windows or *nix based but the Viewlets can be seen in any browser and live
on almost any web server.

Just thought I would offer a tip...Don't know enough about Python to be
useful to the list yet.

Allen

-----Original Message-----
From: Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
Sent: Monday, June 18, 2001 3:50 AM
To: tutor@python.org
Subject: [Tutor] An IDLE introduction


Hiya everyone,

I'm starting to write up a small IDLE introduction for people who're just
starting Python.  As it is, it's really, really rough.  I haven't finished
writing in the comments, it still needs more image-captures, and all the
writing needs to be rewritten for clarity.

Still, I wanted to see if this sort of thing would be useful for people.  
Here's the web link (still disconnected from my main site):

    http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/

Any comments would be greatly appreciated.  Thanks!


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


From scarblac@pino.selwerd.nl  Mon Jun 18 12:22:31 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Mon, 18 Jun 2001 13:22:31 +0200
Subject: [Tutor] A (not so) simple question? Round Robin
In-Reply-To: <001601c0f6f1$9886dba0$05a616ca@computer1>; from adam0@tsn.cc on Sun, Jun 17, 2001 at 03:51:41PM +1000
References: <001601c0f6f1$9886dba0$05a616ca@computer1>
Message-ID: <20010618132231.A10765@pino.selwerd.nl>

On  0, Adam Gordon <adam0@tsn.cc> wrote:
>   Hey Guys!
> 
>   I am just starting to learn python (after hearing my friend praise it like a religion :) and thought I'd try out a few classic problems to help the learning process.
>   So, I went to Useless Python to check out the challenges, and then went to the High School comp section.  I went to the 2000 open competition and looked for some fun problems.  One which caught my eye was a Round Robin problem - didn't look too hard or too easy.
>   But, for the life of me I cannot do it!  I've spent quite some time mulling it over but still an elegant solution eludes me...here is a copy of the problem as found on the website (here http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml).
> 
> 
> ##start task
> Task 5 - Round Robin
> Description
> n teams are to play each other in a competition. In each round each team plays exactly one other team. We wish to have as few rounds as possible. 
> 
> Write a program which, given an even number n, produces a "draw table" showing which team plays which team in each round. It is to take the minimum possible number of rounds. If more than one such draw table is possible your program may return whichever you wish. 

In chess tournaments, there are standard tables called "Berger tables".

A program that shows tables like this is at
http://chess.cern.ch/tournaments/robin.en.shtml

Unfortunately, without source, so we'll have to reverse engineer the
algorithm from the tables :-).

Looking at the table for, say, 10 people, we see some patterns:
- Player 1 plays white against player 10 in the first round, then white
  vs player 2, black vs 3, white vs 4, alternating until black vs 9 in round
  9.
- Player 2 starts against 9. Then in the second round he's already paired
  with 1. After that it continues 10, 3, 4, 5, 6, 7, 8.
- Player 3 starts against 8. Then 9, the next in the list. He's already paired
  with 1 and 2 for the next two rounds. Then the list continues, playing
  10, 4, 5, 6, 7.
  
The pattern is slightly different for the upper half of the numbers,
and my time is up. It shouldn't be too hard to find the algorithm and write
a short function.

-- 
Remco Gerlich


From qhe@ydyn.com  Mon Jun 18 14:47:24 2001
From: qhe@ydyn.com (Peter He)
Date: Mon, 18 Jun 2001 08:47:24 -0500
Subject: [Tutor] Folder browser/chooser
Message-ID: <5.1.0.14.0.20010618084711.00ae5370@mail.ydyn.com.criticalpath.net>

Hi all,

Is there a widget which works as a folder broswer/chooser? Just like 
tkFileDialog for file browser/chooser?

Thanks!

Peter 



From rol9999@attglobal.net  Mon Jun 18 16:14:28 2001
From: rol9999@attglobal.net (Roland Schlenker)
Date: Mon, 18 Jun 2001 10:14:28 -0500
Subject: [Tutor] A (not so) simple question? Round Robin
References: <001601c0f6f1$9886dba0$05a616ca@computer1>
Message-ID: <3B2E1AD4.B9D176BE@attglobal.net>

> Adam Gordon wrote:

> Description
> 
> n teams are to play each other in a competition. In each round each
> team plays exactly one other team. We wish to have as few rounds as
> possible.
> 
> Write a program which, given an even number n, produces a "draw table"
> showing which team plays which team in each round. It is to take the
> minimum possible number of rounds. If more than one such draw table is
> possible your program may return whichever you wish.
> 
> For example here is an 4 player draw table
> 
>   A B C D
> A   1 2 3
> B 1   3 2
> C 2 3   1
> D 3 2 1
> 

Using the method suggested at:

http://www.rain.org/~mkummel/stumpers/09feb01a.html

I came up with:

def outerZip(aList):
    assert 0 == len(aList) % 2
    half = len(aList) / 2
    listA, listB = aList[:half], aList[half:]
    listB.reverse()
    return zip(listA, listB)

assert [(1, 6), (2, 5), (3, 4)] == outerZip([1, 2, 3, 4, 5, 6])

class RoundRobin:
    def __init__(self, teams):
        self.teams = teams
        self.rounds = []

    def makeRounds(self):
        numberOfRounds = len(self.teams) - 1
        pivotTeam, teams = self.teams[0], self.teams[1:]
        self.rounds = []
        while 1:
            if numberOfRounds == 0:
                break
            playsPivotTeam, teams = teams[0], teams[1:]
            round = [(pivotTeam, playsPivotTeam)] + outerZip(teams)
            self.rounds.append(round)
            teams = teams + [playsPivotTeam]
            numberOfRounds -= 1

    def playsWhoWhen(self, teamA, teamB):
        if teamA == teamB:
            return ''
        for round in self.rounds:
            for game in round:
                if teamA in game and teamB in game:
                    return self.rounds.index(round) + 1

    def roundsToString(self):
        result = []
        result.append(" ")
        for team in self.teams:
            result.append(" " + team)
        result.append('\n')
        for team in self.teams:
            result.append(team)
            for opposingTeam in self.teams:
                result.append(" %1s" % self.playsWhoWhen(team,
opposingTeam))
            result.append('\n')
        return ''.join(result)

aRound = RoundRobin(['A', 'B', 'C', 'D', 'E', 'F'])
aRound.makeRounds()
assert [[('A', 'B'), ('C', 'F'), ('D', 'E')],
        [('A', 'C'), ('D', 'B'), ('E', 'F')],
        [('A', 'D'), ('E', 'C'), ('F', 'B')],
        [('A', 'E'), ('F', 'D'), ('B', 'C')],
        [('A', 'F'), ('B', 'E'), ('C', 'D')]] == aRound.rounds
assert 1 == aRound.playsWhoWhen('C', 'F')
assert 5 == aRound.playsWhoWhen('A', 'F')
assert "  A B C D E F\n" +\
       "A   1 2 3 4 5\n" +\
       "B 1   4 2 5 3\n" +\
       "C 2 4   5 3 1\n" +\
       "D 3 2 5   1 4\n" +\
       "E 4 5 3 1   2\n" +\
       "F 5 3 1 4 2  \n" == aRound.roundsToString()


Roland Schlenker


From pobrien@orbtech.com  Mon Jun 18 15:24:31 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Mon, 18 Jun 2001 09:24:31 -0500
Subject: [Tutor] An IDLE introduction
In-Reply-To: <Pine.LNX.4.21.0106180046560.31625-100000@hkn.eecs.berkeley.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBCEMMKAAA.pobrien@orbtech.com>

Nice. I find having screenshots is a real comfort when you are starting
out - one picture worth a thousand words and all that. Keep going. I think
this is a very useful thing to have in the tutor arsenal.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Danny Yoo
Sent: Monday, June 18, 2001 2:50 AM
To: tutor@python.org
Subject: [Tutor] An IDLE introduction

Hiya everyone,

I'm starting to write up a small IDLE introduction for people who're just
starting Python.  As it is, it's really, really rough.  I haven't finished
writing in the comments, it still needs more image-captures, and all the
writing needs to be rewritten for clarity.

Still, I wanted to see if this sort of thing would be useful for people.
Here's the web link (still disconnected from my main site):

    http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/

Any comments would be greatly appreciated.  Thanks!


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From chetumal23@excite.com  Mon Jun 18 16:18:54 2001
From: chetumal23@excite.com (john smith smith)
Date: Mon, 18 Jun 2001 08:18:54 -0700 (PDT)
Subject: [Tutor] just saying thanks
Message-ID: <15776461.992877534990.JavaMail.imail@cheeks.excite.com>

i would just like to say you guys are the best, being a newbie to
programming, i wasn't really getting it at first but you guys always offered
great suggestions and encouragement. i'm far from the level you guys are
but, i'm getting there. So once again THANKS!





_______________________________________________________
Send a cool gift with your E-Card
http://www.bluemountain.com/giftcenter/




From vlindberg@verio.net  Mon Jun 18 16:37:35 2001
From: vlindberg@verio.net (VanL)
Date: Mon, 18 Jun 2001 09:37:35 -0600
Subject: [Tutor] Python-to-to native compilation via java?
Message-ID: <3B2E203F.1080600@verio.net>

Hello,

I was reading about the new gcc 3.0 release, and something that 
caught my eye:

"""
The GNU Compiler for the Java Programming Language
What is GCJ?

GCJ is a portable, optimizing, ahead-of-time compiler for the Java 
Programming Language. It can compile:

     * Java source code directly to native machine code,
     * Java source code to Java bytecode (class files),
     * and Java bytecode to native machine code.

Compiled applications are linked with the GCJ runtime, libgcj, which 
provides the core class libraries, a garbage collector, and a 
bytecode interpreter. libgcj can dynamically load and interpret 
class files, resulting in mixed compiled/interpreted applications.
"""

Would code get any significant speedup by going jython -> .class 
files -> native?

Thanks,

Van



From dyoo@hkn.eecs.berkeley.edu  Mon Jun 18 17:50:21 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 18 Jun 2001 09:50:21 -0700 (PDT)
Subject: [Tutor] Python-to-to native compilation via java?
In-Reply-To: <3B2E203F.1080600@verio.net>
Message-ID: <Pine.LNX.4.21.0106180941280.4520-100000@hkn.eecs.berkeley.edu>

On Mon, 18 Jun 2001, VanL wrote:

> I was reading about the new gcc 3.0 release, and something that caught
> my eye:

Did the new gcc come out today?  Very cool!

(For those who might be unfamiliar with "gcc": gcc is a collection of
compilers for many programming languages, including C and Java.  Python is
built on top of C, and it's really neat to see how our favorite language
is built on top of this "simpler" environment.)


> Compiled applications are linked with the GCJ runtime, libgcj, which
> provides the core class libraries, a garbage collector, and a bytecode
> interpreter. libgcj can dynamically load and interpret class files,
> resulting in mixed compiled/interpreted applications. """
> 
> Would code get any significant speedup by going jython -> .class 
> files -> native?

Hmmm...  I don't know!  The Jython people might know; can you ask them
about it?  I'm also interested in hearing if Jython compiles well in gcj.



From jrfrog01@msn.com  Mon Jun 18 17:52:34 2001
From: jrfrog01@msn.com (jay aliason)
Date: Mon, 18 Jun 2001 12:52:34 -0400
Subject: [Tutor] help for a beginner
Message-ID: <OE108MhvqgStMVhEUse0000863b@hotmail.com>

------=_NextPart_001_0004_01C0F7F5.8BA0E700
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am currently trying to learn the language that is Python.  The problem =
is the last language I ever programmed was BASIC.  So I need to know what=
 tools I need to get started I.E.  -Start up platform

-which version to use
-how to get the screen to let me type the language


I am using a compaq 1700T laptop.  It is a pentium III and runs at 800mhz=
.   With windows Me.
Any help would be useful.  Thanks for your time and patience,
                                          The Frog

------=_NextPart_001_0004_01C0F7F5.8BA0E700
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<HTML><BODY STYLE=3D"font:10pt verdana; border:none;"><DIV>I am currently=
 trying to learn the language that is Python.&nbsp; The problem is the la=
st language I ever programmed was BASIC.&nbsp; So I need to know what too=
ls I need to get started I.E.&nbsp; -Start up platform<BR><BR>-which vers=
ion to use</DIV> <DIV>-how to get the screen to let me type the language<=
/DIV> <DIV>&nbsp;</DIV> <DIV>&nbsp;</DIV> <DIV>I am using a compaq 1700T =
laptop.&nbsp; It is a pentium III and runs at 800mhz.&nbsp;&nbsp; With wi=
ndows Me.</DIV> <DIV>Any help would be useful.&nbsp; Thanks for your time=
 and patience,</DIV> <DIV>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The Frog</DIV></BOD=
Y></HTML>

------=_NextPart_001_0004_01C0F7F5.8BA0E700--


From nailed@videotron.ca  Mon Jun 18 18:25:44 2001
From: nailed@videotron.ca (Alain Toussaint)
Date: Mon, 18 Jun 2001 13:25:44 -0400
Subject: [Tutor] Python-to-to native compilation via java?
In-Reply-To: <Pine.LNX.4.21.0106180941280.4520-100000@hkn.eecs.berkeley.edu>
References: <Pine.LNX.4.21.0106180941280.4520-100000@hkn.eecs.berkeley.edu>
Message-ID: <01061813254400.02485@alain>

Hello Everyone,

> Did the new gcc come out today?  Very cool!

yes it did,have a look at http://gcc.gnu.org/

i will probably download it in the next few days but i will be able to 
throughly test it after Samba 2.2.1 is out (at that time,i will rebuild 
my box).

Alain Toussaint


From kalle@gnupung.net  Mon Jun 18 18:56:38 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Mon, 18 Jun 2001 19:56:38 +0200
Subject: [Tutor] help for a beginner
In-Reply-To: <OE108MhvqgStMVhEUse0000863b@hotmail.com>; from jrfrog01@msn.com on Mon, Jun 18, 2001 at 12:52:34PM -0400
References: <OE108MhvqgStMVhEUse0000863b@hotmail.com>
Message-ID: <20010618195638.A12799@gandalf>

Sez jay aliason:
> I am currently trying to learn the language that is Python.  The problem
> is the last language I ever programmed was BASIC.  So I need to know what
> tools I need to get started I.E.  -Start up platform
> 
> -which version to use

Generally, the latest official version is a good bet.  Currently, this is
2.1, and it can be downloaded from
http://www.python.org/2.1/

I've heard people say that ActiveState Python is good for Windows users.
I don't know, but more info can be found on
http://aspn.activestate.com/ASPN/Downloads/ActivePython/

> -how to get the screen to let me type the language

You can use a editor/environment that comes with Python.  This can be IDLE,
which is included in the stadard Python distribution, or Pythonwin, which is
included with ActiveState Python.
In any of these tools, you have interactive interpreter windows for testing.
You can also edit python module files that you can save, distribute and run.
These can be edited in any text editor, but IDLE and Pythonwin have syntax
highlighting and indentation support that make writing Python easier.

A good tutorial is
http://www.crosswinds.net/~agauld/

Peace,
  Kalle
-- 
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
 [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]


From dyoo@hkn.eecs.berkeley.edu  Mon Jun 18 18:59:41 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 18 Jun 2001 10:59:41 -0700 (PDT)
Subject: [Tutor] help for a beginner
In-Reply-To: <OE108MhvqgStMVhEUse0000863b@hotmail.com>
Message-ID: <Pine.LNX.4.21.0106181046290.5718-100000@hkn.eecs.berkeley.edu>

On Mon, 18 Jun 2001, jay aliason wrote:

> I am currently trying to learn the language that is Python.  The
> problem is the last language I ever programmed was BASIC.  So I need

That's not too much of a problem.  In fact, it's great that you have some
experience in BASIC, since the idea of an "interpreter" might seem
familiar to you.  Python has the "print" command too, so there's some
similarities you can take advantage of... *grin*


> to know what tools I need to get started I.E.  -Start up platform
> -which version to use -how to get the screen to let me type the
> language

Python 2.1 is the latest version, and that's probably what you'll want to
get.  Since you're running Win ME, you can just download the .exe file for
Python: in an ideal world, it works uniformly on Windows 95/98/2000/ME/NT.


> I am using a compaq 1700T laptop.  It is a pentium III and runs at
> 800mhz.  With windows Me. Any help would be useful.  Thanks for your
> time and patience,

This sounds good.  You'll want to download the Python interpreter, and it
can be found here:

    http://python.org/2.1/#locations

All you'll probably need to download is the is the Python-2.1.exe
file.  It's a 6 MB download, which isn't too bad.  It comes with all the
tools you'll need to get started:

    o Python itself --- the "interpreter" that forms the heart of the
      system.

    o IDLE --- the Integrated Development Environment that's both a text
      editor and a nice way to play around with Python.

(At the moment, I'm trying to write a small "First Day" guide on IDLE.
Give me another day or so, and I'll be able to post it up.)


You don't need to buy a book to learn Python (although there are a lot of
good ones out there).  You can browse through a few introductions and
tutorials here:

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

Alan Gauld's "Learning to Program":

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

as well as Josh Cogliati's "A Non-Programmer's Tutorial for Python":

    http://www.honors.montana.edu/~jjc/easytut/easytut/

are both good tutorials, and start from the basics.


Finally, you have us:  Ask us any questions you have about Python, and
we'll be happy to talk about them.  Best of wishes!



From nluken@earthlink.net  Mon Jun 18 19:45:52 2001
From: nluken@earthlink.net (Noah Luken)
Date: Mon, 18 Jun 2001 14:45:52 -0400
Subject: [Tutor] a question about making standalone .exes from python
Message-ID: <05ad01c0f826$e785b880$4d6d1a26@noah2lxehj3pbz>

This is a multi-part message in MIME format.

------=_NextPart_000_05AA_01C0F805.5F20E490
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi everyone,=20

(Let me preface this question -- I am a student of architecture =
interested in using python for basic graphic design, algorithms, etc.   =
I have, in the process, been forced to learn some Tkinter, some (quite a =
bit) of OpenGL, as well as the usual complement of useful python =
modules. (PIL, Numeric, pyglut, etc.).  I'm a newbie at ALL of them =
(sigh).)

I'm trying to make a standalone .exe of a python script which invokes =
and draws in an openGL window.  The imports are thus:

from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
import whrandom
import time

I poked around on the internet and tried Installer by Gordon MacMillan, =
since it seemed most up to date.  After installing and running =
SetupTk.py once, I tried his standalone.py on my script =
(interaction02.py) and got this result:


> c:\python21\python.exe c:\python21\installer\Builder.py  interaction
W: exec statment detected at line 281 of imputil
W: No module named dos
W: No module named mac
W: No module named nt.stat
W: No module named os2
W: No module named posix
W: Cannot determine your Windows or System directories
W: Please add them to your PATH if .dlls are not found
W: exec statment detected at line 65 of os
W: exec statment detected at line 138 of os
W: eval hack detected at line 405 of os
W: No module named ce
W: No module named strop.lowercase
W: No module named strop.maketrans
W: No module named strop.uppercase
W: No module named strop.whitespace
W: No module named win32api
W: No module named pwd
W: No module named riscos
W: No module named riscosenviron
W: No module named riscospath
W: No module named MACFS
W: No module named macfs
W: No module named errno.EINVAL
W: eval hack detected at line 634 of pickle
W: __import__ hack detected at line 786 of pickle
W: No module named OpenGL.dynload._opengl
W: No module named OpenGL.dynload._opengl_num
W: No module named OpenGL.dynload.openglutil
W: No module named OpenGL.dynload.openglutil_num
W: No module named OpenGL.dynload.wgl
W: No module named OpenGL.GL.CarefulFunction
W: No module named OpenGL.GL.Error
W: No module named OpenGL.dynload._glu
W: No module named OpenGL.dynload._glu_num
W: No module named OpenGL.dynload._glut

Needless to say, this program didn't work on a machine with opengl card, =
drivers, etc. (problem with .dynload modules)  I'm curious if there's a =
way to get standalone .exe programs to work with python, and I'm also =
wondering if I shouldn't just bite the bullet and program this in C or =
C++ (which would involve learning one of the bad old languages I thought =
I could avoid).  Is there a way to go from python to c to an .exe?  Is =
python the right language for this or am I barking up the wrong tree =
here?

thanks in advance for any help you can offer.

-noah luken
nluken@mit.edu=20

=20



------=_NextPart_000_05AA_01C0F805.5F20E490
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.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi everyone, </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>(Let me preface this question -- I am a =
student of=20
architecture interested in using python for basic graphic design, =
algorithms,=20
etc.&nbsp;&nbsp; I have, in the process, been forced to learn&nbsp;some =
Tkinter,=20
some&nbsp;(quite a bit) of OpenGL, as well as the usual complement of =
useful=20
python modules. (PIL, Numeric, pyglut, etc.).&nbsp; I'm a newbie at ALL =
of them=20
(sigh).)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm trying to make a standalone .exe of =
a=20
python&nbsp;script which&nbsp;invokes and draws&nbsp;in an=20
openGL&nbsp;window.&nbsp; The imports are thus:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>from OpenGL.GL import *<BR>from =
OpenGL.GLUT import=20
*<BR>from OpenGL.GLU import *<BR>import whrandom<BR>import =
time</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I poked around on the internet and =
tried Installer=20
by Gordon MacMillan, since it seemed most up to date.&nbsp; After =
installing and=20
running SetupTk.py once, I tried his standalone.py on my script=20
(interaction02.py) and got this result:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt; c:\python21\python.exe=20
c:\python21\installer\Builder.py&nbsp; interaction<BR>W: exec statment =
detected=20
at line 281 of imputil<BR>W: No module named dos<BR>W: No module named =
mac<BR>W:=20
No module named nt.stat<BR>W: No module named os2<BR>W: No module named=20
posix<BR>W: Cannot determine your Windows or System directories<BR>W: =
Please add=20
them to your PATH if .dlls are not found<BR>W: exec statment detected at =
line 65=20
of os<BR>W: exec statment detected at line 138 of os<BR>W: eval hack =
detected at=20
line 405 of os<BR>W: No module named ce<BR>W: No module named=20
strop.lowercase<BR>W: No module named strop.maketrans<BR>W: No module =
named=20
strop.uppercase<BR>W: No module named strop.whitespace<BR>W: No module =
named=20
win32api<BR>W: No module named pwd<BR>W: No module named riscos<BR>W: No =
module=20
named riscosenviron<BR>W: No module named riscospath<BR>W: No module =
named=20
MACFS<BR>W: No module named macfs<BR>W: No module named =
errno.EINVAL<BR>W: eval=20
hack detected at line 634 of pickle<BR>W: __import__ hack detected at =
line 786=20
of pickle<BR>W: No module named OpenGL.dynload._opengl<BR>W: No module =
named=20
OpenGL.dynload._opengl_num<BR>W: No module named =
OpenGL.dynload.openglutil<BR>W:=20
No module named OpenGL.dynload.openglutil_num<BR>W: No module named=20
OpenGL.dynload.wgl<BR>W: No module named OpenGL.GL.CarefulFunction<BR>W: =
No=20
module named OpenGL.GL.Error<BR>W: No module named =
OpenGL.dynload._glu<BR>W: No=20
module named OpenGL.dynload._glu_num<BR>W: No module named=20
OpenGL.dynload._glut<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Needless to say, this program didn't =
work on a=20
machine with opengl card, drivers, etc. (problem with .dynload modules)  =
I'm=20
curious if there's a way to get&nbsp;standalone&nbsp;.exe programs to =
work with=20
python, and I'm also wondering if I shouldn't just bite the bullet and =
program=20
this in C or C++ (which would involve learning one of the bad old =
languages I=20
thought I could avoid).&nbsp;&nbsp;Is&nbsp;there a way to go from python =
to=20
c&nbsp;to an .exe?&nbsp; Is python the right language for this or am I =
barking=20
up the wrong tree here?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>thanks in advance for any help you can=20
offer.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-noah luken</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A =
href=3D"mailto:nluken@mit.edu">nluken@mit.edu</A>=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</DIV></FONT></BODY></HTML>

------=_NextPart_000_05AA_01C0F805.5F20E490--



From wesc@deirdre.org  Mon Jun 18 20:02:53 2001
From: wesc@deirdre.org (Wesley Chun)
Date: Mon, 18 Jun 2001 12:02:53 -0700 (PDT)
Subject: [Tutor] Taking Mark Lutz's training course
In-Reply-To: <Pine.LNX.4.21.0106140801300.3418-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.31.0106181155270.3546-100000@emperor.deirdre.org>

On Thu, 14 Jun 2001, Daniel Yoo wrote:
> On Thu, 14 Jun 2001 kromag@nsacom.net wrote:
> > Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> said:
> >
> > And now for something completely different:
> >
> > Have you taken, or talked to anyone who has taken Mark Lutz' Python
> > classes?  It sounds like a good three days, but the money gods have
> > frowned upon me this year. I _really_ get a lot of mileage out of
> > "Learning Python", so I am inclined toward spending my dough with him.
>
> No, I haven't taken one of his classes.  Has anyone here taken one?  What
> are they like?

I don't know anyone who has either, but he *is* rather busy
doing it!  In fact, he told me a few days ago that he would
have to start passing business to *me* if July has the same
torrid training pace as June!  :-)


> > I have yet to find a college in the midwest that even teaches Python.
> > *sigh*
>
> I actually tried to do a small "Introduction to Python" session in
> Berkeley once.  What a disaster!  The problem was that the language was so
> obvious, so simple, that I didn't need to say anything... *grin*

I teach the Python course for the University of California,
Santa Cruz extension system -- rather than teaching for students
on-campus, these are once-a-week evening courses for working
professionals.  I believe UC Berkeley is offering a similar
course.

Teaching the actual language, as Daniel pointed out, is rather
straightforward.  The rest of the time, I'm overworking them
with exercises, then doing more advanced topics (i.e., network-
ing, regular expressions, GUIs and Tkinter, web programming, etc.)
towards the end of the 8-week course.  By the time they're done,
not only do they know Python, but are good programmers as well! ;-)

-wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

"Core Python Programming", Prentice Hall PTR, December 2000
    http://starship.python.net/crew/wesc/cpp/

wesley.j.chun :: wesc@baypiggies.org
cyberweb.consulting :: silicon.valley, ca
http://www.roadkill.com/~wesc/cyberweb/




From scastell@sas.upenn.edu  Mon Jun 18 22:41:27 2001
From: scastell@sas.upenn.edu (Steven M. Castellotti)
Date: Mon, 18 Jun 2001 16:41:27 -0500
Subject: [Tutor] Re: [Jython-users] Python to native compilation via java?
References: <3B2E6291.8000907@lindbergs.org>
Message-ID: <3B2E7587.AA221ECC@sas.upenn.edu>

	A very good question! However, don't forget that if the software you're
writing is GPL'd, there might be a restriction on compiling it together
with jython, due to a conflict between the GPL and jython's license.

VanL wrote:
> 
> Hello,
> 
> (Cross-posted by request from the python-tutor mailing list)
> 
> I was reading about the new gcc 3.0 release, and something that caught
> my eye:
> 
> """
> The GNU Compiler for the Java Programming Language
> What is GCJ?
> 
> GCJ is a portable, optimizing, ahead-of-time compiler for the Java
> Programming Language. It can compile:
> 
>     * Java source code directly to native machine code,
>     * Java source code to Java bytecode (class files),
>     * and Java bytecode to native machine code.
> 
> Compiled applications are linked with the GCJ runtime, libgcj, which
> provides the core class libraries, a garbage collector, and a bytecode
> interpreter. libgcj can dynamically load and interpret class files,
> resulting in mixed compiled/interpreted applications.
> """
> 
> Would code get any significant speedup by going jython -> .class files
> -> native? Is it possible?  And does jython compile under gcj?
> 
> Thanks,
> 
> Van

-- 
Steve Castellotti
Systems Programmer
School of Arts and Sciences, University of Pennsylvania


From GBunting864@Worldsavings.com  Mon Jun 18 22:14:06 2001
From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x))
Date: Mon, 18 Jun 2001 16:14:06 -0500
Subject: [Tutor] Taking Mark Lutz's training course
Message-ID: <97E9FA3149D0D311BE5800008349BB270172BEC0@ok1ems1.worldsavings.com>

Where could I find information about the UCSC extension class?  I have
looked on their web site but I could not find anything on python.

Thanks

Glen

 -----Original Message-----
From: 	Wesley Chun [mailto:wesc@deirdre.org] 
Sent:	Monday, June 18, 2001 12:03 PM
To:	Daniel Yoo
Cc:	kromag@nsacom.net; tutor@python.org
Subject:	Re: [Tutor] Taking Mark Lutz's training course

On Thu, 14 Jun 2001, Daniel Yoo wrote:
> On Thu, 14 Jun 2001 kromag@nsacom.net wrote:
> > Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> said:
> >
> > And now for something completely different:
> >
> > Have you taken, or talked to anyone who has taken Mark Lutz' Python
> > classes?  It sounds like a good three days, but the money gods have
> > frowned upon me this year. I _really_ get a lot of mileage out of
> > "Learning Python", so I am inclined toward spending my dough with him.
>
> No, I haven't taken one of his classes.  Has anyone here taken one?  What
> are they like?

I don't know anyone who has either, but he *is* rather busy
doing it!  In fact, he told me a few days ago that he would
have to start passing business to *me* if July has the same
torrid training pace as June!  :-)


> > I have yet to find a college in the midwest that even teaches Python.
> > *sigh*
>
> I actually tried to do a small "Introduction to Python" session in
> Berkeley once.  What a disaster!  The problem was that the language was so
> obvious, so simple, that I didn't need to say anything... *grin*

I teach the Python course for the University of California,
Santa Cruz extension system -- rather than teaching for students
on-campus, these are once-a-week evening courses for working
professionals.  I believe UC Berkeley is offering a similar
course.

Teaching the actual language, as Daniel pointed out, is rather
straightforward.  The rest of the time, I'm overworking them
with exercises, then doing more advanced topics (i.e., network-
ing, regular expressions, GUIs and Tkinter, web programming, etc.)
towards the end of the 8-week course.  By the time they're done,
not only do they know Python, but are good programmers as well! ;-)

-wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

"Core Python Programming", Prentice Hall PTR, December 2000
    http://starship.python.net/crew/wesc/cpp/

wesley.j.chun :: wesc@baypiggies.org
cyberweb.consulting :: silicon.valley, ca
http://www.roadkill.com/~wesc/cyberweb/



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


*****************************************************************************
If you are not the intended recipient of this e-mail, please notify 
the sender immediately. The contents of this e-mail do not amend 
any existing disclosures or agreements unless expressly stated.
*****************************************************************************


From glingl@aon.at  Mon Jun 18 22:21:14 2001
From: glingl@aon.at (Gregor Lingl)
Date: Mon, 18 Jun 2001 23:21:14 +0200
Subject: [Tutor] A (not so) simple question? Round Robin
References: <001601c0f6f1$9886dba0$05a616ca@computer1> <3B2D0CF6.5566EE8F@aon.at> <3B2DBC82.AFC9B4D2@aon.at> <008b01c0f7e2$ba19daa0$0200a8c0@ACE> <009b01c0f7e5$37b5b2c0$0200a8c0@ACE>
Message-ID: <3B2E70CA.64EEE1E7@aon.at>


Glen Wheeler schrieb:

> >   Hmmm well with regards to the performance issue, I did notice quite a
> few
> > 'in' keywords
> > <..snip..>
>
>   Argh, that's what sleep deprivation will do to you.  There is only one
> 'in' keyword being used the way I meant...still, it would increase speed to
> use a hash...but prbably not to the extent your looking for.
>   Whoops again,
>
>   Glen.

So I had to search for a faster method and the internet once more
proved its richness:
google ( round robin tournament program ) led me to

http://www.rain.org/~mkummel/stumpers/09feb01a.html

where a description of an ingenious geometrically motivated algorithm
is given.
Here is the corresponding Python-program:


def roundrobin(n):
    """implements a geometrically motivated algorithm
       to construct a table for a round-robin-tournament.
       The algorithm is called 'polygon method' and described
       at http://www.rain.org/~mkummel/stumpers/09feb01a.html
    """
    # construct table filled with zeros
    row = []
    while len(row)<n: row.append(0)
    table = []
    while len(table)<n: table.append(row[:])
    # represent polygon-with-center as list
    poly = range(n)
    # fill table
    for round in range(1,n):
        for i in range(n/2):
            table[poly[i]][poly[-1-i]]=round
            table[poly[-1-i]][poly[i]]=round
        # rotate polygon
        poly = poly[-2:-1]+poly[:-2]+poly[-1:]
    # output result
    teams = map(chr,range(65, 65+n))
    print "  |" + "%3s"*n % tuple(teams)
    print "--|" + "---"*n
    for i in range(n):
        print "%s |" % teams[i] + "%3d"*n % tuple(table[i])


Again my code contains several rather clumsy portions (for
instance the construction of the table and filling it with zeros)
and a more pythonesque version would be appreciated.

Nevertheless, my conclusion should be: first study, then program.

Hope, you found it a little bit interesting
Gregor Lingl



From deirdre@deirdre.net  Mon Jun 18 23:46:06 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Mon, 18 Jun 2001 15:46:06 -0700
Subject: [Tutor] Taking Mark Lutz's training course
In-Reply-To: <97E9FA3149D0D311BE5800008349BB270172BEC0@ok1ems1.worldsavings.com>
References: <97E9FA3149D0D311BE5800008349BB270172BEC0@ok1ems1.worldsavings.com>
Message-ID: <a05100e05b75434c4e97b@[10.20.0.37]>

At 4:14 PM -0500 6/18/01, Bunting, Glen, IG (x) wrote:
>Where could I find information about the UCSC extension class?  I have
>looked on their web site but I could not find anything on python.

Wes hasn't been teaching at UCSC for the last semester. If you're 
desperate (gah, I can't spell today!) for something in the near 
future, Berkeley is offering one in its extension program for the 
first time in Summer. Otherwise, I'd wait for Wes' next. :)
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From danny.ayers@btinternet.com  Mon Jun 18 23:45:06 2001
From: danny.ayers@btinternet.com (Danny Ayers)
Date: Mon, 18 Jun 2001 23:45:06 +0100
Subject: [Tutor] RE: [Jython-users] Python to native compilation via java?
In-Reply-To: <3B2E6291.8000907@lindbergs.org>
Message-ID: <EBEPLGMHCDOJJJPCFHEFIEJEDKAA.danny.ayers@btinternet.com>

I've just been looking at some of the intermediate Java code generated by
jythonc on its way to a .class. I may be wrong, but it looks to me like the
class is will effectively wrap up the python source, which will be
interpreted by the interpreter embedded in jpython. To compile this up to
native code, unless the compiler is *really* smart it would carry over all
the inefficiencies of the interpretation process, and so I would guess that
the performance improvements overall are likely to be minimal or
non-existent, compared to running the Python source on a native interpreter.
I guess.

BTW, I've just been trying to find a good way of porting Python source over
to Java, and made a small step forward using the Object Domain UML tool
(time limited demo) - it can generate the Java classes and method shells
(from UML generated from Python), which with a bit of search & replace (get
rid of 'self'!) should save a fair bit of hand coding.

---
Danny Ayers
http://www.isacat.net

>-----Original Message-----
>From: jython-users-admin@lists.sourceforge.net
>[mailto:jython-users-admin@lists.sourceforge.net]On Behalf Of VanL
>Sent: 18 June 2001 21:21
>To: jython-users@lists.sourceforge.net
>Subject: [Jython-users] Python to native compilation via java?
>
>
>Hello,
>
>(Cross-posted by request from the python-tutor mailing list)
>
>I was reading about the new gcc 3.0 release, and something that caught
>my eye:
>
>"""
>The GNU Compiler for the Java Programming Language
>What is GCJ?
>
>GCJ is a portable, optimizing, ahead-of-time compiler for the Java
>Programming Language. It can compile:
>
>    * Java source code directly to native machine code,
>    * Java source code to Java bytecode (class files),
>    * and Java bytecode to native machine code.
>
>Compiled applications are linked with the GCJ runtime, libgcj, which
>provides the core class libraries, a garbage collector, and a bytecode
>interpreter. libgcj can dynamically load and interpret class files,
>resulting in mixed compiled/interpreted applications.
>"""
>
>Would code get any significant speedup by going jython -> .class files
>-> native? Is it possible?  And does jython compile under gcj?
>
>Thanks,
>
>Van
>
>
>
>_______________________________________________
>Jython-users mailing list
>Jython-users@lists.sourceforge.net
>http://lists.sourceforge.net/lists/listinfo/jython-users



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 19 00:36:25 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 18 Jun 2001 16:36:25 -0700 (PDT)
Subject: [Tutor] Re: [Python-Help] folder browser/chooser
In-Reply-To: <5.1.0.14.0.20010618141443.00af6eb8@mail.ydyn.com.criticalpath.net>
Message-ID: <Pine.LNX.4.21.0106181626260.11497-100000@hkn.eecs.berkeley.edu>

On Mon, 18 Jun 2001, Peter He wrote:

> Is there a widget which works as a folder browser/chooser? Just like
> tkFileDialog for file browser/chooser.

Hmmm... I'm not quite sure about this one.  Wait, wait, I know I've seen
this question before though.  Let's see...  Ah!  Ok, you'll want to take a
look at Rick Pasotto's answer:

    http://mail.python.org/pipermail/tutor/2001-May/005270.html

There is a FileDialog widget that's just not documented well, but it is
there.  Thanks Rick!



From wesc@deirdre.org  Tue Jun 19 00:36:52 2001
From: wesc@deirdre.org (Wesley Chun)
Date: Mon, 18 Jun 2001 16:36:52 -0700 (PDT)
Subject: [Tutor] Taking Mark Lutz's training course
In-Reply-To: <97E9FA3149D0D311BE5800008349BB270172BEC0@ok1ems1.worldsavings.com>
Message-ID: <Pine.LNX.4.31.0106181633530.11970-100000@emperor.deirdre.org>

glen,

i apologize for neglecting to mention that due to personal reasons,
i have not been able to teach the Python course for UCSC during this
year.  the next class is tentatively set for Winter quarter 2002.

i am available for corporate training however if you company wants
to train a bunch of people, i'll come out there.  Mark Lutz does
mething similar although most of his courses are taught near where
*he* lives.

hope this helps!

-wesley


On Mon, 18 Jun 2001, Bunting, Glen, IG (x) wrote:

> Where could I find information about the UCSC extension class?  I have
> looked on their web site but I could not find anything on python.
>
> Thanks
>
> Glen
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
> "Core Python Programming", Prentice Hall PTR, December 2000
>     http://starship.python.net/crew/wesc/cpp/
>
> wesley.j.chun :: wesc@baypiggies.org
> cyberweb.consulting :: silicon.valley, ca
> http://www.roadkill.com/~wesc/cyberweb/



From michael@exasource.com  Tue Jun 19 03:14:37 2001
From: michael@exasource.com (Michael)
Date: Mon, 18 Jun 2001 20:14:37 -0600
Subject: [Tutor] Python and web scripting
Message-ID: <01061820143700.02862@orion.andromeda>

Hi,

I'm new to Python and new to programming.  I've done html and a few 
javascripts and was wanting to learn a real programming language.  After 
reading up on all the possibilities, I decided to learn Python as my first.

My question is, how is Python used in a web development application.  Can it 
be used in the same manner, but instead of PHP?  Are there any tutorials / 
books that cover this aspect?

Thanks,

Michael

PS I liked the IDLE tutorial, I've already learned some things from that even 
though it is not finished.




From dyoo@hkn.eecs.berkeley.edu  Tue Jun 19 07:19:53 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 18 Jun 2001 23:19:53 -0700 (PDT)
Subject: [Tutor] a question about making standalone .exes from python
In-Reply-To: <05ad01c0f826$e785b880$4d6d1a26@noah2lxehj3pbz>
Message-ID: <Pine.LNX.4.21.0106182317410.16274-100000@hkn.eecs.berkeley.edu>

On Mon, 18 Jun 2001, Noah Luken wrote:

> I poked around on the internet and tried Installer by Gordon
> MacMillan, since it seemed most up to date.  After installing and
> running SetupTk.py once, I tried his standalone.py on my script
> (interaction02.py) and got this result:

Have you tried py2exe?  I believe it too is being actively developed; from
what I've heard, it's very good and easier to work with than McMillian's
Installer.  You can find out about py2exe here:

    http://starship.python.net/crew/theller/py2exe/

Good luck!



From jstanley@start.com.au  Tue Jun 19 10:28:22 2001
From: jstanley@start.com.au (Jordan Stanley)
Date: Tue, 19 Jun 2001 19:28:22 +1000
Subject: [Tutor] Re: An IDLE Introduction
Message-ID: <B3003239850@i01sv4071.ids1.intelonline.com>

i thinks its great so far

just a suggestion, how about introducing varibales eg a=3 s=3*a etc

i'll certainly be coming back to see how the site is going

Jordan


RE: An IDLE introduction (Patrick K. O'Brien)
>
>-----Original Message-----
>From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf
Of
>Danny Yoo
>Sent: Monday, June 18, 2001 2:50 AM
>To: tutor@python.org
>Subject: [Tutor] An IDLE introduction
>
>Hiya everyone,
>
>I'm starting to write up a small IDLE introduction for people who're
just
>starting Python.  As it is, it's really, really rough.  I haven't
finished
>writing in the comments, it still needs more image-captures, and all
the
>writing needs to be rewritten for clarity.
>
>Still, I wanted to see if this sort of thing would be useful for
people.
>Here's the web link (still disconnected from my main site):
>
>    http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/
>
>Any comments would be greatly appreciated.  Thanks!



__________________________________________________________________
Get your free Australian email account at http://www.start.com.au



From fasal.waseem@cis.co.uk  Tue Jun 19 12:10:58 2001
From: fasal.waseem@cis.co.uk (fasal.waseem@cis.co.uk)
Date: Tue, 19 Jun 2001 11:10:58 +0000
Subject: [Tutor] Attribute Error
Message-ID: <OFD4642A37.1233BC28-ON00256A70.003D5145@cis.co.uk>

Hi All

is abspath an attribute of 1.5, if not is there some equivalent of it.

Faz
Distributed system support Analyst
CIS
Miller Street
Manchester
M60 0AL
0161 837 4487 (office)
www.cis.co.uk (our web page)

*************************************************************************

This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return: you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions expressed are those of the individual author.

The CIS marketing group, which is regulated for Investment Business by the Personal Investment Authority, includes:
Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions
CIS Unit Managers Limited Registered in England and Wales number 2369965 (also regulated by IMRO) - for unit trusts and PEPs
CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS name
Registered offices: Miller Street, Manchester M60 0AL   Telephone  0161-832-8686   Internet  http://www.cis.co.uk   E-mail cis@cis.co.uk

CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number 990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the Bank.

CIS & the CIS logo (R) Co-operative Insurance Society Limited

********************************************************************************


From scarblac@pino.selwerd.nl  Tue Jun 19 11:19:14 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 19 Jun 2001 12:19:14 +0200
Subject: [Tutor] Attribute Error
In-Reply-To: <OFD4642A37.1233BC28-ON00256A70.003D5145@cis.co.uk>; from fasal.waseem@cis.co.uk on Tue, Jun 19, 2001 at 11:10:58AM +0000
References: <OFD4642A37.1233BC28-ON00256A70.003D5145@cis.co.uk>
Message-ID: <20010619121914.A12613@pino.selwerd.nl>

On  0, fasal.waseem@cis.co.uk wrote:
> Hi All
> 
> is abspath an attribute of 1.5, if not is there some equivalent of it.

I think you're talking about os.path.abspath().

It's not in 1.5, but was new in 1.5.2; the current documentation says:
(http://www.python.org/doc/current/lib/module-os.path.html)

abspath(path)
   Return a normalized absolutized version of the pathname 'path'. On most
   platforms, this is equivalent to 
   os.path.normpath(os.path.join(os.getcwd(), path))
   New in version 1.5.2.

That line (basically adds the current directory and the path together and
normalizes it) should work.

-- 
Remco Gerlich


From fasal.waseem@cis.co.uk  Tue Jun 19 13:10:04 2001
From: fasal.waseem@cis.co.uk (fasal.waseem@cis.co.uk)
Date: Tue, 19 Jun 2001 12:10:04 +0000
Subject: [Tutor] Attribute Error
Message-ID: <OF37C17A99.8D8323B0-ON00256A70.0042A686@cis.co.uk>

Hi there

Yes I am trying to use os.path.abspath and I am getting error as shown
below;

progspec=os.path.abspath(sys.argv[0])
AttributeError: abspath

how do use sys.argv and normpath together.

regards
Faz
Distributed system support Analyst
CIS
Miller Street
Manchester
M60 0AL
0161 837 4487 (office)
www.cis.co.uk (our web page)


                                                                                                                                    
                    Remco Gerlich                                                                                                   
                    <scarblac@pino.s        To:     tutor@python.org                                                                
                    elwerd.nl>              cc:                                                                                     
                    Sent by:                Subject:     Re: [Tutor] Attribute Error                                                
                    tutor-admin@pyth                                                                                                
                    on.org                                                                                                          
                                                                                                                                    
                                                                                                                                    
                    19/06/01 10:19                                                                                                  
                                                                                                                                    
                                                                                                                                    




On  0, fasal.waseem@cis.co.uk wrote:
> Hi All
>
> is abspath an attribute of 1.5, if not is there some equivalent of it.

I think you're talking about os.path.abspath().

It's not in 1.5, but was new in 1.5.2; the current documentation says:
(http://www.python.org/doc/current/lib/module-os.path.html)

abspath(path)
   Return a normalized absolutized version of the pathname 'path'. On most
   platforms, this is equivalent to
   os.path.normpath(os.path.join(os.getcwd(), path))
   New in version 1.5.2.

That line (basically adds the current directory and the path together and
normalizes it) should work.

--
Remco Gerlich

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



*************************************************************************

This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return: you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions expressed are those of the individual author.

The CIS marketing group, which is regulated for Investment Business by the Personal Investment Authority, includes:
Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions
CIS Unit Managers Limited Registered in England and Wales number 2369965 (also regulated by IMRO) - for unit trusts and PEPs
CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS name
Registered offices: Miller Street, Manchester M60 0AL   Telephone  0161-832-8686   Internet  http://www.cis.co.uk   E-mail cis@cis.co.uk

CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number 990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the Bank.

CIS & the CIS logo (R) Co-operative Insurance Society Limited

********************************************************************************


From arcege@speakeasy.net  Tue Jun 19 12:00:02 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Tue, 19 Jun 2001 07:00:02 -0400 (EDT)
Subject: [Tutor] Attribute Error
In-Reply-To: <20010619121914.A12613@pino.selwerd.nl> from "Remco Gerlich" at Jun 19, 2001 12:19:14 PM
Message-ID: <200106191100.f5JB02i01811@dsl092-074-184.bos1.dsl.speakeasy.net>

Remco Gerlich wrote
> 
> On  0, fasal.waseem@cis.co.uk wrote:
> > is abspath an attribute of 1.5, if not is there some equivalent of it.
> 
> I think you're talking about os.path.abspath().

I took this a completely different way.  I was thinking of 1.5 as
a float, not a release number.

For a floating point number, you are probably looking for the abs()
function.  It is a builtin, so you can just use it directly:

$ python -c 'print abs(-1.5), abs(1.5)'
1.5 1.5

But with this illness, I could have easily gotten mistaken. :)

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From scarblac@pino.selwerd.nl  Tue Jun 19 12:14:13 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 19 Jun 2001 13:14:13 +0200
Subject: [Tutor] Attribute Error
In-Reply-To: <OF37C17A99.8D8323B0-ON00256A70.0042A686@cis.co.uk>; from fasal.waseem@cis.co.uk on Tue, Jun 19, 2001 at 12:10:04PM +0000
References: <OF37C17A99.8D8323B0-ON00256A70.0042A686@cis.co.uk>
Message-ID: <20010619131413.A12716@pino.selwerd.nl>

On  0, fasal.waseem@cis.co.uk wrote:
> Yes I am trying to use os.path.abspath and I am getting error as shown
> below;
> 
> progspec=os.path.abspath(sys.argv[0])
> AttributeError: abspath
> 
> how do use sys.argv and normpath together.

Let's see how I wrote that again, from the library reference documents:
> abspath(path)
>    Return a normalized absolutized version of the pathname 'path'. On most
>    platforms, this is equivalent to
>    os.path.normpath(os.path.join(os.getcwd(), path))
>    New in version 1.5.2.

That means that your line should be written:

progspec = os.path.normpath(os.path.join(os.getcwd(), sys.argv[0]))

to work on 1.5.

(in your case 'path', the argument to abspath(), is 'sys.argv[0]')


-- 
Remco Gerlich


From rhess@bic.ch  Tue Jun 19 15:00:24 2001
From: rhess@bic.ch (Flynt)
Date: Tue, 19 Jun 2001 16:00:24 +0200
Subject: [Tutor] Python and web scripting
References: <01061820143700.02862@orion.andromeda>
Message-ID: <3B2F5AF8.CF125658@bic.ch>

Michael wrote:
> 
> Hi,
> 
> I'm new to Python and new to programming.  I've done html and a few
> javascripts and was wanting to learn a real programming language.  After
> reading up on all the possibilities, I decided to learn Python as my first.
> 
> My question is, how is Python used in a web development application.  Can it
> be used in the same manner, but instead of PHP?  Are there any tutorials /
> books that cover this aspect?
> 
> Thanks,
> 
> Michael
> 
> PS I liked the IDLE tutorial, I've already learned some things from that even
> though it is not finished.
> 

Hi Michael


There is a nice package, HTMLgen
(http://starship.python.net/crew/friedrich/HTMLgen/html/main.html),
which helps you a lot writing HTML.

There is an web application server based entirely on Python, called Zope
(the link is http://www.zope.org/). This is a full featured web
application server framework, for which also a lot of Add-On modules are
already developed to handle special functionalities.
You have to spend some time studying the docs, to see what it is capable
of, but I think it is well worth a try. Because of the use of python, I
think you are moving on much better founded ground than by using PHP,
which might be quicker in the first place to implement but gives not as
much back, when you are going to more involved problems. And, in IMO,
PHP is *web only*, whereas with Python you can work in just all areas.
A comprehensive introduction to Zope will come out right now at New
Riders Publishing, the Zope Book by Amos Latteier and Michel Pelletier
(search for "Zope" on amazon). You can have a look at the last draft of
the book at
http://www.zope.org/Members/michel/ZB/

HTH

--- Flynt


From bill-bell@bill-bell.hamilton.on.ca  Tue Jun 19 16:42:04 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Tue, 19 Jun 2001 11:42:04 -0400
Subject: [Tutor] Elementary questions
In-Reply-To: <E15Bez3-00019v-00@mail.python.org>
Message-ID: <3B2F3A8C.16726.34CAA9D@localhost>

Would it be possible for someone to point me toward advice about 
the following points?

1. When I launch PythonWin its window occupies only part of my 
screen. How may I configure it to use the entire screen? Similarly, 
is it possible to configure PythonWin so that child windows (for 
code, for instance) occupy the entire client window?

2. When I launch a .py script from Windows Explorer the resulting 
DOS box closes before I'm able to read about exceptions. How 
may I change this behaviour of the system?

Thanks in advance.

Bill


From pobrien@orbtech.com  Tue Jun 19 16:55:44 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Tue, 19 Jun 2001 10:55:44 -0500
Subject: [Tutor] Elementary questions
In-Reply-To: <3B2F3A8C.16726.34CAA9D@localhost>
Message-ID: <NBBBIOJPGKJEKIECEMCBEEOJKAAA.pobrien@orbtech.com>

1. Right click on the link or menu choice for PythonWin. You will see an
option labeled "Run." Set it to Maximized and PythonWin will launch in full
screen mode. If you maximize a child window in PythonWin, all existing and
subsequent children will open maximized. Restore one and you restore all,
etc. Like a toggle.

2. Don't run the file by double-clicking on it. You could start a dos window
and then do "python thefile.py". Or run the .py file from IDLE or PythonWin.

Sorry about the brevity, but hope that helps.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Bill Bell
Sent: Tuesday, June 19, 2001 10:42 AM
To: tutor@python.org
Subject: [Tutor] Elementary questions


Would it be possible for someone to point me toward advice about
the following points?

1. When I launch PythonWin its window occupies only part of my
screen. How may I configure it to use the entire screen? Similarly,
is it possible to configure PythonWin so that child windows (for
code, for instance) occupy the entire client window?

2. When I launch a .py script from Windows Explorer the resulting
DOS box closes before I'm able to read about exceptions. How
may I change this behaviour of the system?

Thanks in advance.

Bill

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From mbc2@netdoor.com  Tue Jun 19 17:24:45 2001
From: mbc2@netdoor.com (Brad Chandler)
Date: Tue, 19 Jun 2001 11:24:45 -0500
Subject: [Tutor] Python and web scripting
References: <01061820143700.02862@orion.andromeda> <3B2F5AF8.CF125658@bic.ch>
Message-ID: <000601c0f8dc$5acdbc60$111c0d0a@spb.state.ms.us>

Does one actually write programs in Python when using Zope?  I've looked at
Zope briefly, but it looked overly complicated for simple web scripting and
I could never wrap my mind around how it was supposed to work.

There's something called PSP http://www.ciobriefings.com/psp/ , which stands
for Python Server Pages.  I think it's supposed to work similar to PHP.  It
looks promising, but I haven't figured out whether you can use it with
Python or whether you have to use the Java implementation of Python called
JPython.  (Can someone explain the reason for the exisitence of JPython? Why
would anyone use it? All I know about Java is the client side web stuff
which I hate with a passion).

I like programming in python better, but for web scripting it's hard to beat
PHP, especially if your using MySQL or PostgreSQL since PHP has some great
builtin functions for those databases, better than the ones available for
Python in my opinion.  I use PHP for all of my web scripting and Python for
utility programs that aren't used for the web.

You can of course use Python for cgi programs.  I've included an example of
an extremely simple one below.  The first two print statements are mandatory
I believe, after that you can program away.  I didn't actually need the
'import cgi' line in this example, but keep that module in mind.  You place
the script in your cgi-bin directory and access it by pointing your browser
to http://www.yourdomain.com/cgi-bin/test.py

At least that's how I access mine, assuming you named the file test.py and
made it executable.

#!/usr/bin/python

import cgi

print "Content-type: text/html"
print
print """
<html>
<head>
<title>Hello World!</title>
</head>
<body>
Hello World!<br>
</body></html>
"""

----- Original Message -----
From: "Flynt" <rhess@bic.ch>
To: "Michael" <michael@exasource.com>
Cc: <tutor@python.org>
Sent: Tuesday, June 19, 2001 9:00 AM
Subject: Re: [Tutor] Python and web scripting


> Michael wrote:
> >
> > Hi,
> >
> > I'm new to Python and new to programming.  I've done html and a few
> > javascripts and was wanting to learn a real programming language.  After
> > reading up on all the possibilities, I decided to learn Python as my
first.
> >
> > My question is, how is Python used in a web development application.
Can it
> > be used in the same manner, but instead of PHP?  Are there any tutorials
/
> > books that cover this aspect?
> >
> > Thanks,
> >
> > Michael
> >
> > PS I liked the IDLE tutorial, I've already learned some things from that
even
> > though it is not finished.
> >
>
> Hi Michael
>
>
> There is a nice package, HTMLgen
> (http://starship.python.net/crew/friedrich/HTMLgen/html/main.html),
> which helps you a lot writing HTML.
>
> There is an web application server based entirely on Python, called Zope
> (the link is http://www.zope.org/). This is a full featured web
> application server framework, for which also a lot of Add-On modules are
> already developed to handle special functionalities.
> You have to spend some time studying the docs, to see what it is capable
> of, but I think it is well worth a try. Because of the use of python, I
> think you are moving on much better founded ground than by using PHP,
> which might be quicker in the first place to implement but gives not as
> much back, when you are going to more involved problems. And, in IMO,
> PHP is *web only*, whereas with Python you can work in just all areas.
> A comprehensive introduction to Zope will come out right now at New
> Riders Publishing, the Zope Book by Amos Latteier and Michel Pelletier
> (search for "Zope" on amazon). You can have a look at the last draft of
> the book at
> http://www.zope.org/Members/michel/ZB/
>
> HTH
>
> --- Flynt
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



From wilson@visi.com  Tue Jun 19 18:09:31 2001
From: wilson@visi.com (Timothy Wilson)
Date: Tue, 19 Jun 2001 12:09:31 -0500 (CDT)
Subject: [Tutor] Python and web scripting
In-Reply-To: <000601c0f8dc$5acdbc60$111c0d0a@spb.state.ms.us>
Message-ID: <Pine.GSO.4.21.0106191207240.18891-100000@isis.visi.com>

On Tue, 19 Jun 2001, Brad Chandler wrote:

> Does one actually write programs in Python when using Zope?  I've looked at
> Zope briefly, but it looked overly complicated for simple web scripting and
> I could never wrap my mind around how it was supposed to work.

Yes, you can write Zope apps directly in Python, but it's not a trivial
process. I suspect that some of the PHP-like packages are simpler
initially. Of course, using Zope gives you much more power than simply
scripting in Python. Like anything else, you have to weigh your needs
vs. the complexity of the solution.

That said, it's pretty simple to set up some pretty cool Web apps with
Python. Check out the Zope book at http://www.zope.org/Members/michel/ZB/.

-Tim

--
Tim Wilson      |   Visit Sibley online:   | Check out:
Henry Sibley HS |  http://www.isd197.org   | http://www.zope.org
W. St. Paul, MN |                          | http://slashdot.org
wilson@visi.com |  <dtml-var pithy_quote>  | http://linux.com



From bill-bell@bill-bell.hamilton.on.ca  Tue Jun 19 18:20:46 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Tue, 19 Jun 2001 13:20:46 -0400
Subject: [Tutor] RE: Elementary questions
In-Reply-To: <E15CNwF-00011I-00@mail.python.org>
Message-ID: <3B2F51AE.14806.3A70BF6@localhost>

"Patrick K. O'Brien" <pobrien@orbtech.com> wrote:
> 1. Right click on the link or menu choice for PythonWin. You will see
> an option labeled "Run." Set it to Maximized and PythonWin will launch
> in full screen mode. <SNIP>
> Sorry about the brevity, but hope that helps.

Not at all. Thanks very much for the help. I've been using MSW for 
a l-o-n-g time. Can't believe that it would never have occurred to me 
to do that! LOL. Thanks, Patrick! - Bill

Bill Bell, Software Developer


From michael@exasource.com  Tue Jun 19 19:13:06 2001
From: michael@exasource.com (Michael)
Date: Tue, 19 Jun 2001 12:13:06 -0600
Subject: [Tutor] Python and web scripting
In-Reply-To: <3B2F5AF8.CF125658@bic.ch>
References: <01061820143700.02862@orion.andromeda> <3B2F5AF8.CF125658@bic.ch>
Message-ID: <01061912130600.01219@orion.andromeda>

Hi Flynt,

Thanks for the information.  I felt like a dummy writing this message last 
night because after sending it, I found some information on the Python site.  
I bet I've been on this site at least 15-20 times, but never found the 
information, because I was always looking under the tutorials section.  

I also saw the information on Zope and after reading your post regarding the 
book, decided that I would get it and check it out.  Maybe I'll download Zope 
now and at least try to get it figured out so when it comes time to use it, 
after I actually know something about programming in Python, There will be 
less of a learning curve.

The reason I picked Python is just like you said, It can be used in a variety 
of applications. I'm also interested in trying out Glade. It sounds totally 
awesome.  After I go through several of the web tutorials, what book(s) would 
you, or anyone else reading this recommend?

Thanks,

Michael

> Hi Michael
>
>
> There is a nice package, HTMLgen
> (http://starship.python.net/crew/friedrich/HTMLgen/html/main.html),
> which helps you a lot writing HTML.
>
> There is an web application server based entirely on Python, called Zope
> (the link is http://www.zope.org/). This is a full featured web
> application server framework, for which also a lot of Add-On modules are
> already developed to handle special functionalities.
> You have to spend some time studying the docs, to see what it is capable
> of, but I think it is well worth a try. Because of the use of python, I
> think you are moving on much better founded ground than by using PHP,
> which might be quicker in the first place to implement but gives not as
> much back, when you are going to more involved problems. And, in IMO,
> PHP is *web only*, whereas with Python you can work in just all areas.
> A comprehensive introduction to Zope will come out right now at New
> Riders Publishing, the Zope Book by Amos Latteier and Michel Pelletier
> (search for "Zope" on amazon). You can have a look at the last draft of
> the book at
> http://www.zope.org/Members/michel/ZB/
>
> HTH
>
> --- Flynt

-- 
Michael Lewis
Exasource Inc.
970.206.4556

       "Linux - The final solution"



From csmith@blakeschool.org  Tue Jun 19 19:17:21 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Tue, 19 Jun 2001 13:17:21 -0500
Subject: [Tutor] A (not so) simple question? Round Robin
In-Reply-To: <E15C6PK-0008DT-00@mail.python.org>
References: <E15C6PK-0008DT-00@mail.python.org>
Message-ID: <fc.004c4b6b007579d63b9aca006ee8bae2.757a21@blakeschool.org>

Dear Greg,

I'm learning Python and this was a good learning exercise.

I, too, found the web site that you did and implemented 
a solution using two lists and a dictionary.  Basically
the dictionary acts as a matrix which is accessed through 
a tuple pair. The lists are the two lines of participants;
for a given round, the competitors across from each other
have their entry in the dictionary filled with the round
number.  I modified your print-out routine to fit with
my data.  You can probably tell that I am use to printing
out matrices and don't yet know a more Python like way to 
print out an entire row of my dictionary inone statement.
Basically I need to do something like "print all dictionary
entries that have i as the first member of the tuple key."
Can anyone provide any tips on this?

/c

Code follows:

def roundrobin(n):
 # Uses the "rotating lines" scheme presented 
 # at http://www.rain.org/~mkummel/stumpers/09feb01a.html
 # to print a table for a round robin tournament
 # between n teams which are represented by capital letters.
 # If n is odd, the "bye" is indicated with a "_".

 # make lines
  l=[];m=[];t={};odd=0
  if n/2*2 !=n:
    n=n+1
    odd=1
  n2=n/2
  for i in range(n2):
    l.append(i)
    m.append(i+n2)
 
 # do the rounds
  for r in range(n-1):
    for i in range(n2):
      t[(l[i],m[i])],t[(m[i],l[i])]=r,r
    
    # rotate the lines (this was fun!)
    l.append(m.pop())
    m.insert(0,l.pop(1))
  
 # define team names and print results
  teams = map(chr,range(65,65+n))
  if odd:
    teams[-1]="_"
  print "  |" + "%4s"*n % tuple(teams)
  print "--|" + "----"*n
  for i in range(n):
    print "%s |" % teams[i],
    for j in range(n):
      if i==j:
        t[(i,i)]=-1 # initialize diagonal
      # Without the () in the next line, a string+int error is obtained
      # Also, the trailing comma leaves a space between elements so the
      # total space is actually 4, not 3, for each round number
      print "%3d" % (t[(i,j)]+1), 
    print

roundrobin(7)

#  This is the output
#
#    |   A   B   C   D   E   F   G   _
#  --|--------------------------------
#  A |   0   2   3   4   1   7   6   5
#  B |   2   0   6   3   5   1   4   7
#  C |   3   6   0   7   2   5   1   4
#  D |   4   3   7   0   6   2   5   1
#  E |   1   5   2   6   0   4   7   3
#  F |   7   1   5   2   4   0   3   6
#  G |   6   4   1   5   7   3   0   2
#  _ |   5   7   4   1   3   6   2   0



From wesc@deirdre.org  Tue Jun 19 20:19:33 2001
From: wesc@deirdre.org (Wesley Chun)
Date: Tue, 19 Jun 2001 12:19:33 -0700 (PDT)
Subject: [Tutor] Python and web scripting
In-Reply-To: <01061820143700.02862@orion.andromeda>
Message-ID: <Pine.LNX.4.31.0106191207460.11599-100000@emperor.deirdre.org>

On Mon, 18 Jun 2001, Michael wrote:
>
> I'm new to Python and new to programming.  I've done html and a few
> javascripts and was wanting to learn a real programming language.  After
> reading up on all the possibilities, I decided to learn Python as my first.
>
> My question is, how is Python used in a web development application.  Can it
> be used in the same manner, but instead of PHP?  Are there any tutorials /
> books that cover this aspect?


Michael,

good question.  now by saying "web development" and mentioning PHP,
you are focusing specifically on applications run by web servers
(and not including subjects like lower-level network programming
[sockets] or Internet client programming [FTP, POP3, NNTP, etc.]).
Those are a whole 'nother topic on their!  Anyhoo, congratulations
are still in order for choosing Python after your investigation.

The "old"-style way of web development used CGI, however, the need
to embedding logic in static HTML data spawned a great-enough demand
for tools like ASP, JSP, Cold Fusion, PHP, and even PSP (Python
Server Pages).  The other way to do it is to use Zope, as some have
already mentioned.  Currently, there are some books on Zope coming
out, and as far as PSP goes, I've only seen a few magazine articles.

For basic matters, it may be easiest and most lightweight to use
CGI (plus HTMLgen if your HTML is complex).  Performance for sites
with a good number of hits can be improved by using a Python Apache
module such as PyApache or mod_python.  Once this solution becomes
less productive, then you can migrate to a more "serious" tool such
as the ones we just discussed.

Good luck, and hope this helps!

-wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

"Core Python Programming", Prentice Hall PTR, December 2000
    http://starship.python.net/crew/wesc/cpp/

wesley.j.chun :: wesc@baypiggies.org
cyberweb.consulting :: silicon.valley, ca
http://www.roadkill.com/~wesc/cyberweb/



From michael@exasource.com  Tue Jun 19 21:18:33 2001
From: michael@exasource.com (Michael)
Date: Tue, 19 Jun 2001 14:18:33 -0600
Subject: [Tutor] Python and web scripting
In-Reply-To: <Pine.LNX.4.31.0106191207460.11599-100000@emperor.deirdre.org>
References: <Pine.LNX.4.31.0106191207460.11599-100000@emperor.deirdre.org>
Message-ID: <01061914183301.01219@orion.andromeda>

> Michael,
>
> good question.  now by saying "web development" and mentioning PHP,
> you are focusing specifically on applications run by web servers
> (and not including subjects like lower-level network programming
> [sockets] or Internet client programming [FTP, POP3, NNTP, etc.]).


Yes, my primary focus is on applications run by webservers.  


> Those are a whole 'nother topic on their!  Anyhoo, congratulations
> are still in order for choosing Python after your investigation.


It seemed to be the most versatile language.  I was mainly interested in 
being able to use it in web applications, but as I progress, I like the idea 
of being able to do a complete application, GUI and all.  Glade sounds 
awesome.


>
> The "old"-style way of web development used CGI, however, the need
> to embedding logic in static HTML data spawned a great-enough demand
> for tools like ASP, JSP, Cold Fusion, PHP, and even PSP (Python
> Server Pages).  The other way to do it is to use Zope, as some have
> already mentioned.  Currently, there are some books on Zope coming
> out, 


I have been reading the CVS on The ZOPE Book at sourceforge.  It sounds 
great!  I'm looking forward to downloading it and playing with it until I can 
get proficient enough to use it.


>and as far as PSP goes, I've only seen a few magazine articles.


I've read a couple of things on this too.  Maybe by the time I'm actually 
able to use ZOPE in a real world application, there will be more information 
available on this subject as well.


>
> For basic matters, it may be easiest and most lightweight to use
> CGI (plus HTMLgen if your HTML is complex).  Performance for sites
> with a good number of hits can be improved by using a Python Apache
> module such as PyApache or mod_python.  Once this solution becomes
> less productive, then you can migrate to a more "serious" tool such
> as the ones we just discussed.


I tried using the ApacheToolBox to install all of this, but it failed.  I am 
attempting to do a manual install and see if this works.  Currently we are 
using a PostgreSQL database, PHP and Apache.  The guy working on the backend 
picked PHP becuase he has a strong background in C, but he's already having 
problems working with arrays and is not sure what to do about it.  I'm just 
looking for alternatives and since I don't have any prior programming 
predjudices, decided to look at Python.

Thanks for the information and at what point in my journey would your book be 
beneficial?  Is it right for a total newbie, or would it be better to do a 
few tutorials first?

Thanks,

Michael


From cynic@mail.cz  Tue Jun 19 21:36:03 2001
From: cynic@mail.cz (Cynic)
Date: Tue, 19 Jun 2001 22:36:03 +0200
Subject: [Tutor] Python and web scripting
In-Reply-To: <Pine.LNX.4.31.0106191207460.11599-100000@emperor.deirdre.o
 rg>
References: <01061820143700.02862@orion.andromeda>
Message-ID: <5.1.0.14.2.20010619221645.01fa3230@mail.cz>

Hi there,

At 21:19 19.6. 2001, Wesley Chun wrote the following:
-------------------------------------------------------------- 
>good question.  now by saying "web development" and mentioning PHP,
>you are focusing specifically on applications run by web servers
>(and not including subjects like lower-level network programming
>[sockets] or Internet client programming [FTP, POP3, NNTP, etc.]).
>Those are a whole 'nother topic on their!  Anyhoo, congratulations
>are still in order for choosing Python after your investigation.
------end of quote------ 

this is not true. PHP has a FTP extension, sockets functions, 
a c-client extension (access to IMAP, POP3 and NNTP servers)...
You can do pretty much anything you might want to do with PHP.




cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
    - Book of Installation chapt 3 sec 7 



From wesc@deirdre.org  Tue Jun 19 22:25:33 2001
From: wesc@deirdre.org (Wesley Chun)
Date: Tue, 19 Jun 2001 14:25:33 -0700 (PDT)
Subject: [Tutor] Python and web scripting
In-Reply-To: <01061914183301.01219@orion.andromeda>
Message-ID: <Pine.LNX.4.31.0106191401590.14960-100000@emperor.deirdre.org>

On Tue, 19 Jun 2001, Michael wrote:
>
> It seemed to be the most versatile language.  I was mainly interested in
> being able to use it in web applications, but as I progress, I like the idea
> of being able to do a complete application, GUI and all.  Glade sounds
> awesome.

yes, i have seen a demonstration of GLADE and it looks quite potent.
i don't think GUI development had it any easier!


> > Currently, there are some books on Zope coming out,
>
> I have been reading the CVS on The ZOPE Book at sourceforge.  It sounds
> great!  I'm looking forward to downloading it and playing with it until I can
> get proficient enough to use it.

there is more documentation on Zope now than before,
but some still feel it's lacking.  i'm interesting in
messing around with it more myself.


> >and as far as PSP goes, I've only seen a few magazine articles.
>
> I've read a couple of things on this too.  Maybe by the time I'm actually
> able to use ZOPE in a real world application, there will be more information
> available on this subject as well.
>
> I tried using the ApacheToolBox to install all of this, but it failed.  I am
> using a PostgreSQL database, PHP and Apache.  The guy working on the backend
> picked PHP becuase he has a strong background in C, but he's already having
> problems working with arrays and is not sure what to do about it.  I'm just
> looking for alternatives and since I don't have any prior programming
> predjudices, decided to look at Python.

Ah, yes.  PHP itself is a good concept.  unfortunately, it requires
learning "yet another language."  So this is where PSP and Zope look
like better alternatives.  In my days at Four11.com and Yahoo!, we
used a proprietary PSP-like system to crank our products out.  it is
definitely the way to go as far as coming up with entire web systems
on the fly.

Python makes a pretty good first language.  The syntax is friendly
enough to not scare you away, and you can "add-on" anytime you want.
Sort of like having Batman's costume, then adding different gadgets
as you see fit.


> Thanks for the information and at what point in my journey would your book be
> beneficial?  Is it right for a total newbie, or would it be better to do a
> few tutorials first?

Thanks for asking.  I will make no attempt to hide the fact that
the target audience of Core Python Programming is a technical
person who has prior experience in another language (any).  I'd
suggest doing some of the more well-known programming newbie tutorials:

There are several well-known excellent documents pertaining to
learning how to program with Python.  Most are available from
the Python edu-sig website: http://www.python.org/sigs/edu-sig/

Instant Hacking: Learning to Program with Python
http://www.hetland.org/python/instant-hacking.php

Learning to Program (A. Gauld)
http://members.nbci.com/alan_gauld/tutor/tutindex.htm

Non-Programmers Tutorial (J. Cogliati)
http://www.honors.montana.edu/~jjc/easytut/easytut/

How to Think Like a Computer Scientist (Java and C++ versions
by original author A. Downey; and Python version by J. Elkner)
http://www.ibiblio.org/obp/thinkCS.html

As far as books are concerned, Learn to Program Using Python
is an extension of Alan Gauld's tutorial, and Ivan's Teach
Yourself Python in 24 Hours are both targeted towards pro-
gramming newbies.  These books will teach you how to program
*using* Python.  (anyone have feedback on these BTW?)

Once you know how to program, then Core Python can perhaps
give you much more insight on *Python* programming.  You will
probably get a lot out of the Web Programming chapter
in particular.

Hope this helps!

-wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

"Core Python Programming", Prentice Hall PTR, December 2000
    http://starship.python.net/crew/wesc/cpp/

wesley.j.chun :: wesc@baypiggies.org
cyberweb.consulting :: silicon.valley, ca
http://www.roadkill.com/~wesc/cyberweb/




From malex@purdue.edu  Tue Jun 19 23:01:25 2001
From: malex@purdue.edu (Oleksandr Moskalenko)
Date: Tue, 19 Jun 2001 17:01:25 -0500
Subject: (forw) [wesc@deirdre.org: Re: [Tutor] Python and web scripting]
Message-ID: <20010619170125.A18474@purdue.edu>

--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline

  I read Ivan's Python in 24 hours. It was my first book on Python and
it left me confused in a few places as I am still a newbie here. I heard
your talk at Purdue Linux Users' group which got me really intersted in
Python BTW. Anyway, Since I bought Mark's Learning Python and
Programming Python 2nd ed. I hit my head quite a few times saying "Oh,
that's what Ivan was trying to show!". For example the lambda function
was way over my head until I read about it in Learning Python. 
 I guess they are kind of complimentary. Oh, I also read those tutors on
the web adn think they are excellent.

 Alex.



--2fHTh5uZTiUOsy+g
Content-Type: message/rfc822
Content-Disposition: inline

Return-path: <tutor-admin@python.org>
Envelope-to: malex@localhost
Delivery-date: Tue, 19 Jun 2001 16:41:01 -0500
Received: from oleksa ([127.0.0.1] helo=localhost)
	by oleksa with esmtp (Exim 3.22 #1 (Debian))
	id 15CTF6-0004mq-00
	for <malex@localhost>; Tue, 19 Jun 2001 16:41:00 -0500
Received: from herald.cc.purdue.edu [128.210.11.29]
	by localhost with IMAP (fetchmail-5.8.6)
	for malex@localhost (single-drop); Tue, 19 Jun 2001 16:41:00 -0500 (EST)
Received: via tmail-2000(13) for malex; Tue, 19 Jun 2001 16:42:23 -0500 (EST)
Received: from mail.python.org (mail.python.org [63.102.49.29])
	by herald.cc.purdue.edu (8.11.3/8.11.3/herald) with ESMTP id f5JLgMX00287
	for <malex@purdue.edu>; Tue, 19 Jun 2001 16:42:22 -0500 (EST)
Received: from localhost.localdomain ([127.0.0.1] helo=mail.python.org)
	by mail.python.org with esmtp (Exim 3.21 #1)
	id 15CTGD-0000cZ-00; Tue, 19 Jun 2001 17:42:09 -0400
Received: from [198.144.195.190] (helo=emperor.deirdre.ORG ident=root)
	by mail.python.org with esmtp (Exim 3.21 #1)
	id 15CTFg-0000bu-00
	for tutor@python.org; Tue, 19 Jun 2001 17:41:36 -0400
Received: from emperor.deirdre.org (wesc@localhost [127.0.0.1])
        by localhost (8.12.0.Beta7/8.12.0.Beta7/Debian 8.12.0.Beta7-1) with ESMTP id f5JLPYep015664;
	Tue, 19 Jun 2001 14:25:35 -0700
Received: from localhost (wesc@localhost)
        by emperor.deirdre.org (8.12.0.Beta7/8.12.0.Beta7/Debian 8.12.0.Beta7-1) with ESMTP id f5JLPX5O015660;
	Tue, 19 Jun 2001 14:25:34 -0700
From: Wesley Chun <wesc@deirdre.org>
To: Michael <michael@exasource.com>
cc: Tutor <tutor@python.org>
Subject: Re: [Tutor] Python and web scripting
In-Reply-To: <01061914183301.01219@orion.andromeda>
Message-ID: <Pine.LNX.4.31.0106191401590.14960-100000@emperor.deirdre.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sender: tutor-admin@python.org
Errors-To: tutor-admin@python.org
X-BeenThere: tutor@python.org
X-Mailman-Version: 2.0.5 (101270)
Precedence: bulk
List-Help: <mailto:tutor-request@python.org?subject=help>
List-Post: <mailto:tutor@python.org>
List-Subscribe: <http://mail.python.org/mailman/listinfo/tutor>,
	<mailto:tutor-request@python.org?subject=subscribe>
List-Id: Discussion for learning programming with Python <tutor.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/listinfo/tutor>,
	<mailto:tutor-request@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/tutor/>
Date: Tue, 19 Jun 2001 14:25:33 -0700 (PDT)

On Tue, 19 Jun 2001, Michael wrote:
>
> It seemed to be the most versatile language.  I was mainly interested in
> being able to use it in web applications, but as I progress, I like the idea
> of being able to do a complete application, GUI and all.  Glade sounds
> awesome.

yes, i have seen a demonstration of GLADE and it looks quite potent.
i don't think GUI development had it any easier!


> > Currently, there are some books on Zope coming out,
>
> I have been reading the CVS on The ZOPE Book at sourceforge.  It sounds
> great!  I'm looking forward to downloading it and playing with it until I can
> get proficient enough to use it.

there is more documentation on Zope now than before,
but some still feel it's lacking.  i'm interesting in
messing around with it more myself.


> >and as far as PSP goes, I've only seen a few magazine articles.
>
> I've read a couple of things on this too.  Maybe by the time I'm actually
> able to use ZOPE in a real world application, there will be more information
> available on this subject as well.
>
> I tried using the ApacheToolBox to install all of this, but it failed.  I am
> using a PostgreSQL database, PHP and Apache.  The guy working on the backend
> picked PHP becuase he has a strong background in C, but he's already having
> problems working with arrays and is not sure what to do about it.  I'm just
> looking for alternatives and since I don't have any prior programming
> predjudices, decided to look at Python.

Ah, yes.  PHP itself is a good concept.  unfortunately, it requires
learning "yet another language."  So this is where PSP and Zope look
like better alternatives.  In my days at Four11.com and Yahoo!, we
used a proprietary PSP-like system to crank our products out.  it is
definitely the way to go as far as coming up with entire web systems
on the fly.

Python makes a pretty good first language.  The syntax is friendly
enough to not scare you away, and you can "add-on" anytime you want.
Sort of like having Batman's costume, then adding different gadgets
as you see fit.


> Thanks for the information and at what point in my journey would your book be
> beneficial?  Is it right for a total newbie, or would it be better to do a
> few tutorials first?

Thanks for asking.  I will make no attempt to hide the fact that
the target audience of Core Python Programming is a technical
person who has prior experience in another language (any).  I'd
suggest doing some of the more well-known programming newbie tutorials:

There are several well-known excellent documents pertaining to
learning how to program with Python.  Most are available from
the Python edu-sig website: http://www.python.org/sigs/edu-sig/

Instant Hacking: Learning to Program with Python
http://www.hetland.org/python/instant-hacking.php

Learning to Program (A. Gauld)
http://members.nbci.com/alan_gauld/tutor/tutindex.htm

Non-Programmers Tutorial (J. Cogliati)
http://www.honors.montana.edu/~jjc/easytut/easytut/

How to Think Like a Computer Scientist (Java and C++ versions
by original author A. Downey; and Python version by J. Elkner)
http://www.ibiblio.org/obp/thinkCS.html

As far as books are concerned, Learn to Program Using Python
is an extension of Alan Gauld's tutorial, and Ivan's Teach
Yourself Python in 24 Hours are both targeted towards pro-
gramming newbies.  These books will teach you how to program
*using* Python.  (anyone have feedback on these BTW?)

Once you know how to program, then Core Python can perhaps
give you much more insight on *Python* programming.  You will
probably get a lot out of the Web Programming chapter
in particular.

Hope this helps!

-wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

"Core Python Programming", Prentice Hall PTR, December 2000
    http://starship.python.net/crew/wesc/cpp/

wesley.j.chun :: wesc@baypiggies.org
cyberweb.consulting :: silicon.valley, ca
http://www.roadkill.com/~wesc/cyberweb/



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

--2fHTh5uZTiUOsy+g--


From dyoo@hkn.eecs.berkeley.edu  Tue Jun 19 23:44:30 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 19 Jun 2001 15:44:30 -0700 (PDT)
Subject: [Tutor] Re: An IDLE Introduction
In-Reply-To: <B3003239850@i01sv4071.ids1.intelonline.com>
Message-ID: <Pine.LNX.4.21.0106191540490.28357-100000@hkn.eecs.berkeley.edu>

On Tue, 19 Jun 2001, Jordan Stanley wrote:

> i thinks its great so far
> 
> just a suggestion, how about introducing varibales eg a=3 s=3*a etc
> 
> i'll certainly be coming back to see how the site is going

Thanks!  Hmmm... This should be in "Day 2 of IDLE", which I'm planning to
do sometime soon.  The reason I want to keep the "Day 1" page short is to
encourage people to look at the Python Introductions on
http://python.org/doc/Intros.html, since there's such good documentation
there already.

Talk to you later!



From rol9999@attglobal.net  Wed Jun 20 01:39:07 2001
From: rol9999@attglobal.net (Roland Schlenker)
Date: Tue, 19 Jun 2001 19:39:07 -0500
Subject: [Tutor] A (not so) simple question? Round Robin
References: <E15C6PK-0008DT-00@mail.python.org> <fc.004c4b6b007579d63b9aca006ee8bae2.757a21@blakeschool.org>
Message-ID: <3B2FF0AB.492BF1DA@attglobal.net>

Christopher Smith wrote:
> 
> Dear Greg,
> 
> I'm learning Python and this was a good learning exercise.
> 
> I, too, found the web site that you did and implemented
> a solution using two lists and a dictionary.  Basically
> the dictionary acts as a matrix which is accessed through
> a tuple pair. The lists are the two lines of participants;
> for a given round, the competitors across from each other
> have their entry in the dictionary filled with the round
> number.  I modified your print-out routine to fit with
> my data.  You can probably tell that I am use to printing
> out matrices and don't yet know a more Python like way to
> print out an entire row of my dictionary inone statement.
> Basically I need to do something like "print all dictionary
> entries that have i as the first member of the tuple key."
> Can anyone provide any tips on this?

I think the way you did is just fine.

If you are asking how to find all entries that have i as the
first member of the tuple key:

for k in dict.keys():
    if k[0] == i:
       do something with k


> 
> /c
> 
> Code follows:
> 
> def roundrobin(n):
>  # Uses the "rotating lines" scheme presented
>  # at http://www.rain.org/~mkummel/stumpers/09feb01a.html
>  # to print a table for a round robin tournament
>  # between n teams which are represented by capital letters.
>  # If n is odd, the "bye" is indicated with a "_".
> 
>  # make lines
>   l=[];m=[];t={};odd=0
>   if n/2*2 !=n:
>     n=n+1
>     odd=1
>   n2=n/2
>   for i in range(n2):
>     l.append(i)
>     m.append(i+n2)
> 
>  # do the rounds
>   for r in range(n-1):
>     for i in range(n2):
>       t[(l[i],m[i])],t[(m[i],l[i])]=r,r
> 
>     # rotate the lines (this was fun!)
>     l.append(m.pop())
>     m.insert(0,l.pop(1))
> 
>  # define team names and print results
>   teams = map(chr,range(65,65+n))
>   if odd:
>     teams[-1]="_"
>   print "  |" + "%4s"*n % tuple(teams)
>   print "--|" + "----"*n
>   for i in range(n):
>     print "%s |" % teams[i],
>     for j in range(n):
>       if i==j:
>         t[(i,i)]=-1 # initialize diagonal
>       # Without the () in the next line, a string+int error is obtained
>       # Also, the trailing comma leaves a space between elements so the
>       # total space is actually 4, not 3, for each round number
>       print "%3d" % (t[(i,j)]+1),
>     print
> 
> roundrobin(7)
> 
> #  This is the output
> #
> #    |   A   B   C   D   E   F   G   _
> #  --|--------------------------------
> #  A |   0   2   3   4   1   7   6   5
> #  B |   2   0   6   3   5   1   4   7
> #  C |   3   6   0   7   2   5   1   4
> #  D |   4   3   7   0   6   2   5   1
> #  E |   1   5   2   6   0   4   7   3
> #  F |   7   1   5   2   4   0   3   6
> #  G |   6   4   1   5   7   3   0   2
> #  _ |   5   7   4   1   3   6   2   0
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

Roland Schlenker


From emailrassilca@yahoo.com.au  Wed Jun 20 00:21:02 2001
From: emailrassilca@yahoo.com.au (emailrassilca@yahoo.com.au)
Date: Ñð, 20 èþí 2001 04:36:38
Subject: [Tutor] E-ìàéë áàçû íà îäíîì CD çà 1000 ðóáëåé. Ïðîèçâîäèì ðàññûëêó.
Message-ID: <E15CZTn-0005ne-00@mail.python.org>

Ïðîäàþòñÿ å-ìàéë áàçû íà îäíîì CD çà 1000 ðóáëåé.

Áàçà "Ìîñêâà" - 40000 å-ìàéëîâ ôèðì Ìîñêâû.
Áàçà "Ðîññèÿ" - 300000 å-ìàéëîâ.
+ Ïðîãðàììà äëÿ ðàññûëêè.

Òàêæå ïî Âàøåìó çàêàçó ïðîèçâåäåì ðàññûëêó. 

Ïèøèòå: emailrassilka@yahoo.com.au èëè emailrasilka@yahoo.com.au
 
 
 
 
 


From fasal.waseem@cis.co.uk  Wed Jun 20 10:36:47 2001
From: fasal.waseem@cis.co.uk (fasal.waseem@cis.co.uk)
Date: Wed, 20 Jun 2001 09:36:47 +0000
Subject: [Tutor] Type Error
Message-ID: <OFD4642A37.1233BC28-ON00256A70.003D5145@cis.co.uk>

Hi All

Does anybody know where I can get hold of the document for python version
1.5, as I have to use that version and I keep having errors, and I would be
very grateful if some one check why am I getting this error.

 line=string.split(string.strip(line),maxsplit=1)
TypeError: this function takes no keyword arguments

regards

Faz
Distributed system support Analyst
CIS
Miller Street
Manchester
M60 0AL
0161 837 4487 (office)
www.cis.co.uk (our web page)

*************************************************************************

This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return: you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions expressed are those of the individual author.

The CIS marketing group, which is regulated for Investment Business by the Personal Investment Authority, includes:
Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions
CIS Unit Managers Limited Registered in England and Wales number 2369965 (also regulated by IMRO) - for unit trusts and PEPs
CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS name
Registered offices: Miller Street, Manchester M60 0AL   Telephone  0161-832-8686   Internet  http://www.cis.co.uk   E-mail cis@cis.co.uk

CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number 990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the Bank.

CIS & the CIS logo (R) Co-operative Insurance Society Limited

********************************************************************************


From scarblac@pino.selwerd.nl  Wed Jun 20 09:51:38 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 20 Jun 2001 10:51:38 +0200
Subject: [Tutor] Type Error
In-Reply-To: <OFD4642A37.1233BC28-ON00256A70.003D5145@cis.co.uk>; from fasal.waseem@cis.co.uk on Wed, Jun 20, 2001 at 09:36:47AM +0000
References: <OFD4642A37.1233BC28-ON00256A70.003D5145@cis.co.uk>
Message-ID: <20010620105138.A13953@pino.selwerd.nl>

On  0, fasal.waseem@cis.co.uk wrote:
> Hi All
> 
> Does anybody know where I can get hold of the document for python version
> 1.5, as I have to use that version and I keep having errors, and I would be
> very grateful if some one check why am I getting this error.
> 
>  line=string.split(string.strip(line),maxsplit=1)
> TypeError: this function takes no keyword arguments
> 
> regards

http://www.python.org/doc/1.5/


In this case the closest translation would be
line = string.split(string.strip(line), " ", 1)

but that behaves slightly different; the original you have there splits on
blocks of whitespace, the translation on single spaces so e.g.

>>> string.split("whee   whee")
['whee','whee']
>>> string.split("whee   whee", " ")
['whee','','','whee']

That may or may not be a problem, depending on what your strings look like
(are there multiple spaces between the first word and the rest?)

-- 
Remco Gerlich


From fasal.waseem@cis.co.uk  Wed Jun 20 11:53:52 2001
From: fasal.waseem@cis.co.uk (fasal.waseem@cis.co.uk)
Date: Wed, 20 Jun 2001 10:53:52 +0000
Subject: [Tutor] Thank you
Message-ID: <OF37C17A99.8D8323B0-ON00256A70.0042A686@cis.co.uk>

Hi

Just would like to express my appreciations and thanks to all who sent me
the info recently, especially Remco.

Regards

Faz

*************************************************************************

This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return: you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions expressed are those of the individual author.

The CIS marketing group, which is regulated for Investment Business by the Personal Investment Authority, includes:
Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions
CIS Unit Managers Limited Registered in England and Wales number 2369965 (also regulated by IMRO) - for unit trusts and PEPs
CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS name
Registered offices: Miller Street, Manchester M60 0AL   Telephone  0161-832-8686   Internet  http://www.cis.co.uk   E-mail cis@cis.co.uk

CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number 990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the Bank.

CIS & the CIS logo (R) Co-operative Insurance Society Limited

********************************************************************************


From alan.gauld@bt.com  Wed Jun 20 11:00:48 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 20 Jun 2001 11:00:48 +0100
Subject: [Tutor] help for a beginner
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D830@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C0F96F.E15D7B60
Content-type: text/plain; charset="ISO-8859-1"

I am currently trying to learn the language that is Python.  The problem is
the last language I ever programmed was BASIC.  So I need to know what tools
I need to get started I.E.  -Start up platform
 

Just the standard Python install will suffice. It comes 
with everything you need to get started including a
rudimentary developmet environment(editor/debugger etc)
 
Can I suggest you pay a visit to my online tutor too 
which teaches Python alongside BASIC(and Tcl) so you 
should be able to map your BASIC experience into Python 
terms quite easily.
 
http://www.crosswinds.net/~agauld <http://www.crosswinds.net/~agauld> 

-which version to use 
 

2.1 is the latest but I must confess I'm still happily using 2.0. 

-how to get the screen to let me type the language
 
 
I am using a compaq 1700T laptop.  It is a pentium III and runs at 800mhz.
With windows Me.
Any help would be useful.  Thanks for your time and patience,
                                          The Frog


------_=_NextPart_001_01C0F96F.E15D7B60
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=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DISO-8859-1">


<META content=3D"MSHTML 5.00.3013.2600" name=3DGENERATOR></HEAD>
<BODY=20
style=3D"BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; =
BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT: 10pt =
verdana">
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; =
MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV>I am currently trying to learn the language that is =
Python.&nbsp; The=20
  problem is the last language I ever programmed was BASIC.&nbsp; So I =
need to=20
  know what tools I need to get started I.E.&nbsp; -Start up =
platform<BR><SPAN=20
  class=3D920150610-20062001><FONT color=3D#0000ff=20
  face=3D"Courier New">&nbsp;</FONT></SPAN></DIV></BLOCKQUOTE>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN =
class=3D920150610-20062001>Just=20
the standard Python install will suffice. It comes </SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN =
class=3D920150610-20062001>with=20
everything you need to get started including a</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN=20
class=3D920150610-20062001>rudimentary developmet =
environment(editor/debugger=20
etc)</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN=20
class=3D920150610-20062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN =
class=3D920150610-20062001>Can I=20
suggest you pay a visit to my online tutor too </SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN =
class=3D920150610-20062001>which=20
teaches Python alongside BASIC(and Tcl) so you </SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN=20
class=3D920150610-20062001>should be able to map your BASIC experience =
into Python=20
</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN =
class=3D920150610-20062001>terms=20
quite easily.</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN=20
class=3D920150610-20062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN =
class=3D920150610-20062001><A=20
href=3D"http://www.crosswinds.net/~agauld">http://www.crosswinds.net/~ag=
auld</A></SPAN></FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; =
MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV>-which version to use<FONT color=3D#0000ff face=3D"Courier =
New"><SPAN=20
  class=3D920150610-20062001>&nbsp;</SPAN></FONT></DIV>
  <DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN=20
  class=3D920150610-20062001></SPAN></FONT>&nbsp;</DIV></BLOCKQUOTE>
<DIV><FONT color=3D#0000ff face=3D"Courier New"><SPAN =
class=3D920150610-20062001>2.1=20
is the latest but I must confess I'm still happily using=20
2.0.&nbsp;</SPAN></FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; =
MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV>-how to get the screen to let me type the language</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>I am using a compaq 1700T laptop.&nbsp; It is a pentium III and =
runs at=20
  800mhz.&nbsp;&nbsp; With windows Me.</DIV>
  <DIV>Any help would be useful.&nbsp; Thanks for your time and =
patience,</DIV>
  =
<DIV>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  The Frog</DIV></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C0F96F.E15D7B60--


From alan.gauld@bt.com  Wed Jun 20 11:26:38 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 20 Jun 2001 11:26:38 +0100
Subject: [Tutor] Python and web scripting
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D831@mbtlipnt02.btlabs.bt.co.uk>

> Does one actually write programs in Python when using Zope?  

Yes. The URLs used to reach a Zope page are actually method calls of python
objects. Thus:

http://www.azope.server/zoperoot/anobject/amethod

is a (fictitious!) URL that calls the amethod() method 
of an object called "anobject" which is stored in a folder 
under zoperoot.

> Zope briefly, but it looked overly complicated for simple web 
> scripting 

It is. There is a simpler version called Poor Man's Zope 
which might be more appropriate but I've only read the web 
pages not used it...

> There's something called PSP http://www.ciobriefings.com/psp/ 
> , which stands for Python Server Pages.  I think it's 
> supposed to work similar to PHP.  

Yes and ASP etc etc... It is server sice scripting embedded 
within the HTML.

> looks promising, but I haven't figured out whether you 
> can use it with Python or whether you have to use the 
> Java implementation of Python 

No it works with regular C Python.

> (Can someone explain the reason for the exisitence 
> of JPython? Why would anyone use it? All I know about Java 
> is the client side web stuff which I hate with a passion).

Leaving passion aside client side Java is the only way to 
implement stateful cliuent server applications that run 
in a browser so its very usful. It also performs a lot 
better than http and provides a much richer computing 
environment - drag n drop becomes possible for example.
Unfortunately Javas programming model is a biit longwinded 
jython allows you to build a "Java" web client using Python.

However the real strength of Jaba nowadays is in server side programming and
the huige range of class libraries available 
for enterprise strength computing. Jython provides access to 
all of that industry standard code from Python. Its also about the only way
to get Java and Python to communicate and with many corporates
stanbdardising their computing environment on Java its likely to become even
more ubiquitous.

Finally a compiled Jython program will run on any platform 
with a JVM installed - from a mainframe to an embedded 
system - thats farv more likely than finding a box with 
python installed(at least for now!)

Hopefully some(but not all) of the reasons?

> You can of course use Python for cgi programs.

Yes and there is an addin to allow embedded cgi which 
should speed it up considerably since it obviates the 
need for a new interpreter session each time.

There are several books which talk about web programming 
in Python including the new Programming Python monster
volume.

Alan G


From alan.gauld@bt.com  Wed Jun 20 11:32:54 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 20 Jun 2001 11:32:54 +0100
Subject: [Tutor] Python and web scripting
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D832@mbtlipnt02.btlabs.bt.co.uk>

> > for tools like ASP, JSP, Cold Fusion, PHP, and even PSP 
> ...
> >and as far as PSP goes, I've only seen a few magazine articles.

FWIW it is of course possible to write ASP in Python if 
you are using an NT/IIS web server with Active Scripting 
enabled.

The winall package contains a script that registers python 
as an alternative language alongside VBSCript and JSCript.

You just spoecify LANGUAGE-Python and then write code 
inside the usual

<SCRIPT>
<% ....%>

delimits

In case you already use ASP.

Alan G


From SBrunning@trisystems.co.uk  Wed Jun 20 12:11:57 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Wed, 20 Jun 2001 12:11:57 +0100
Subject: [Tutor] cgi FieldStorage __str__ problem - I think...
Message-ID: <31575A892FF6D1118F5800600846864D78BD69@intrepid>

I'm having a bit of a problem with my first CGI script. The idea is to end
an email based on a form.

I set up a template for the email as follows:

mailtemplate = '''From: %(email)s
Subject: %(subject)s
Email from %(name)s
%(comments)s'''

Then I substitute the data from the form into the template as follows:

form = cgi.FieldStorage()
mailtext = mailtemplate % form

Trouble is, the mailtext field ends up looking like this:

From: MiniFieldStorage('email', 'a@b.c')
Subject: MiniFieldStorage('subject', 'Spam')
Email from MiniFieldStorage('name', 'Fred')
MiniFieldStorage('comments', 'Egg and chips...')

Looks to me like the FieldStorage object's values are instances of some
MiniFieldStorage class, and the __str__ method of that class is just
returning the __repr__. Is this correct?

If so, what do I do about it?

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 scarblac@pino.selwerd.nl  Wed Jun 20 12:33:23 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 20 Jun 2001 13:33:23 +0200
Subject: [Tutor] cgi FieldStorage __str__ problem - I think...
In-Reply-To: <31575A892FF6D1118F5800600846864D78BD69@intrepid>; from SBrunning@trisystems.co.uk on Wed, Jun 20, 2001 at 12:11:57PM +0100
References: <31575A892FF6D1118F5800600846864D78BD69@intrepid>
Message-ID: <20010620133323.A14157@pino.selwerd.nl>

On  0, Simon Brunning <SBrunning@trisystems.co.uk> wrote:
> I'm having a bit of a problem with my first CGI script. The idea is to end
> an email based on a form.
> 
> I set up a template for the email as follows:
> 
> mailtemplate = '''From: %(email)s
> Subject: %(subject)s
> Email from %(name)s
> %(comments)s'''
> 
> Then I substitute the data from the form into the template as follows:
> 
> form = cgi.FieldStorage()
> mailtext = mailtemplate % form
> 
> Trouble is, the mailtext field ends up looking like this:
> 
> From: MiniFieldStorage('email', 'a@b.c')
> Subject: MiniFieldStorage('subject', 'Spam')
> Email from MiniFieldStorage('name', 'Fred')
> MiniFieldStorage('comments', 'Egg and chips...')
> 
> Looks to me like the FieldStorage object's values are instances of some
> MiniFieldStorage class, and the __str__ method of that class is just
> returning the __repr__. Is this correct?

Yes. The actual value is in form["email"].value, and so on.

> If so, what do I do about it?

Maybe the easiest way is to make a tiny wrapper class that calls .value:

class FieldStorageWrapper:
   def __init__(self, fieldstorage):
      self.fieldstorage = fieldstorage
   def __getitem__(self, name):
      return self.fieldstorage[name].value

mailtext = mailtemplate % FieldStorageWrapper(form)

Or maybe trying to do this with a single % call is a bit too cute. If your
forms can get more complicated, the FieldStorage elements themselves may be
other FieldStorage instances, or lists of things if a name occurs multiple
times.

-- 
Remco Gerlich


From bill-bell@bill-bell.hamilton.on.ca  Wed Jun 20 13:08:28 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Wed, 20 Jun 2001 08:08:28 -0400
Subject: [Tutor] Re: Python and web scripting
In-Reply-To: <E15CTcM-0000vH-00@mail.python.org>
Message-ID: <3B3059FC.14663.7AFA33A@localhost>

"Brad Chandler" <mbc2@netdoor.com> wrote, in part:
> Can someone explain the reason for the exisitence of JPython? Why
> would anyone use it? 

Brad, This is what the Jython web site says:
"What is Jython?
Jython is an implementation of the high-level, dynamic, object-oriented 
language {HYPERLINK "http://www.python.org"}Python seamlessly integrated with the {HYPERLINK "http://www.javasoft.com"}Java platform. The 
predecessor to Jython, JPython, is certified as {HYPERLINK "http://www.javasoft.com/100percent/"}100% Pure Java. Jython 
is freely available for both commercial and non-commercial use and is 
distributed with source code. Jython is complementary to Java and is 
especially suited for the following tasks:
Embeddedscripting - Java programmers can add the Jython 
    libraries to their system to allow end users to write simple or 
    complicated scripts that add functionality to the application. 
Interactiveexperimentation - Jython provides an interactive 
    interpreter that can be used to interact with Java packages or with 
    running Java applications. This allows programmers to experiment 
    and debug any Java system using Jython.
Rapid application development - Python programs are typically 2-
10X shorter than the equivalent Java program. This translates directly to 
increased programmer productivity. The seamless interaction between 
Python and Java allows developers to freely mix the two languages both 
during development and in shipping products."

Bill Bell, Software Developer


From SBrunning@trisystems.co.uk  Wed Jun 20 13:59:22 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Wed, 20 Jun 2001 13:59:22 +0100
Subject: [Tutor] cgi FieldStorage __str__ problem - I think...
Message-ID: <31575A892FF6D1118F5800600846864D78BD6B@intrepid>

> From:	Remco Gerlich [SMTP:scarblac@pino.selwerd.nl]
> > I set up a template for the email as follows:
> > 
> > mailtemplate = '''From: %(email)s
> > Subject: %(subject)s
> > Email from %(name)s
> > %(comments)s'''
> > 
> > Then I substitute the data from the form into the template as follows:
> > 
> > form = cgi.FieldStorage()
> > mailtext = mailtemplate % form
> > 
> > Trouble is, the mailtext field ends up looking like this:
> > 
> > From: MiniFieldStorage('email', 'a@b.c')
> > Subject: MiniFieldStorage('subject', 'Spam')
> > Email from MiniFieldStorage('name', 'Fred')
> > MiniFieldStorage('comments', 'Egg and chips...')
> > 
> > Looks to me like the FieldStorage object's values are instances of some
> > MiniFieldStorage class, and the __str__ method of that class is just
> > returning the __repr__. Is this correct?
> 
> Yes. The actual value is in form["email"].value, and so on.
> 
> > If so, what do I do about it?
> 
> Maybe the easiest way is to make a tiny wrapper class that calls .value:
> 
> class FieldStorageWrapper:
>    def __init__(self, fieldstorage):
>       self.fieldstorage = fieldstorage
>    def __getitem__(self, name):
>       return self.fieldstorage[name].value
> 
> mailtext = mailtemplate % FieldStorageWrapper(form)
 
I ended up with the brutally simple:

form = cgi.FieldStorage()
formstrings = {}
for formfield in form.keys():
    formstrings[formfield] = form[formfield].value
mailtext = mailtemplate % formstrings

(I tried form.values() first, but the FieldStorage object doesn't seem to
support it.)

Not pretty, but it works. Much like myself, really.
 
> Or maybe trying to do this with a single % call is a bit too cute.
 
Yeah, but it would have been cool, no?

Thanks, Remco and Roman.

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 adrianhome@webspinners.co.uk  Wed Jun 20 16:07:47 2001
From: adrianhome@webspinners.co.uk (Adrian at home)
Date: Wed, 20 Jun 2001 16:07:47 +0100
Subject: [Tutor] Capturing user input
Message-ID: <028f01c0f99a$c6427da0$e0506bd5@default>

Hi All

I am a total newbie to programming, but for the life of me I cannot
understand why this will not work.  I am using IDLE and a tutorial, the
following code is to capture the user input:

name = raw_input ("What is your name? ")
print name

I cannot get the variable "name" to print to the screen, after the prompt
displays and the user types in their name.  It seems straight forward
enough, am I missing something obvious here?

thanks in advance for any response.

Adrian


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.259 / Virus Database: 130 - Release Date: 05/06/2001



From pobrien@orbtech.com  Wed Jun 20 16:34:47 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 10:34:47 -0500
Subject: [Tutor] Capturing user input
In-Reply-To: <028f01c0f99a$c6427da0$e0506bd5@default>
Message-ID: <NBBBIOJPGKJEKIECEMCBCEPPKAAA.pobrien@orbtech.com>

Works for me:

>>> name = raw_input ("What is your name? ")
What is your name? pat
>>> print name
pat
>>>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Adrian at home
Sent: Wednesday, June 20, 2001 10:08 AM
To: tutor@python.org
Subject: [Tutor] Capturing user input

Hi All

I am a total newbie to programming, but for the life of me I cannot
understand why this will not work.  I am using IDLE and a tutorial, the
following code is to capture the user input:

name = raw_input ("What is your name? ")
print name

I cannot get the variable "name" to print to the screen, after the prompt
displays and the user types in their name.  It seems straight forward
enough, am I missing something obvious here?

thanks in advance for any response.

Adrian


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.259 / Virus Database: 130 - Release Date: 05/06/2001


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From rob@jam.rr.com  Wed Jun 20 16:48:28 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 20 Jun 2001 10:48:28 -0500
Subject: [Tutor] Capturing user input
References: <028f01c0f99a$c6427da0$e0506bd5@default>
Message-ID: <000901c0f9a0$73cd6ca0$de00a8c0@planhouse5>

----- Original Message -----
I am using IDLE and a tutorial, the
> following code is to capture the user input:
>
> name = raw_input ("What is your name? ")
> print name
>
> I cannot get the variable "name" to print to the screen, after the prompt
> displays and the user types in their name.  It seems straight forward
> enough, am I missing something obvious here?
>
> thanks in advance for any response.
>
> Adrian
>
It worked just fine here. Can you paste the text of what you are entering
into IDLE, including any errors, into an email to show us?

Hopefully helpful,
Rob
Useless Python
It's not just for breakfast anymore!
http://www.lowerstandard.com/python/index.html



From adrianhome@webspinners.co.uk  Wed Jun 20 16:55:49 2001
From: adrianhome@webspinners.co.uk (Adrian at home)
Date: Wed, 20 Jun 2001 16:55:49 +0100
Subject: [Tutor] Capturing user input
Message-ID: <02c001c0f9a1$7b043ca0$e0506bd5@default>

whoops I mailed to Patrick privately by mistake, sorry it was meant for the
group.

Thanks for responding

It works from me when I use the Python shell in IDLE, but if I type it into
a file "test.py" save and run it F5, I get no output of the variable "name."
BTW, I am running on WIN ME.  I get no error messages after I press return,
It seems that it is still capturing user input and not getting to the print
command.

To reiterate, this is what is in the test file:

name = raw_input ("What is your name? ")
print name


Adrian



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.259 / Virus Database: 130 - Release Date: 05/06/2001



From pobrien@orbtech.com  Wed Jun 20 16:57:51 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 10:57:51 -0500
Subject: [Tutor] RE: [Idle-dev] IDLE "deemphasised"? Please not so...
In-Reply-To: <003a01c0f8a4$a3137420$f05aa8c0@lslp7o.int.lsl.co.uk>
Message-ID: <NBBBIOJPGKJEKIECEMCBEEABKBAA.pobrien@orbtech.com>

I agree with these sentiments and am copying this message to the Edu and
Tutor lists because I think the folks there are a good part of the demand
that you mention below.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: idle-dev-admin@python.org [mailto:idle-dev-admin@python.org]On Behalf
Of Tony J Ibbs (Tibs)
Sent: Tuesday, June 19, 2001 4:46 AM
To: idle-dev@python.org
Subject: [Idle-dev] IDLE "deemphasised"? Please not so...

In Wesley Chun's thread on amending IDLE, Guido said:
> The problem is that IDLE development has virtually come to a halt
> -- I just can't find the time to work on it, and there are other
> good development environments available.

Mats Wichmann then said:
> As Guido knows, I'm certainly interested in IDLE evolving,
> because I find it a very handy learning tool - not just
> for me; like Wesley, I try to teach some Python classes
> from time to time.  There may be "better" IDEs but I'm
> not convinced I've seen one yet (for Python).  And in my
> particular situation, it HAS to be cross-platform, I'm
> not going to fuss with two different IDEs in a classroom
> situation (students get to choose Win2k or Linux).
>
> But I suspect most "serious programmers" don't really see
> IDLE as being a "serious IDE" - at least I gather this
> impression from comments on c.l.p, esp. from folks who come
> from other (inferior?) languages where an IDE is essential to
> maintaining any sanity, so they've evolved into quite sophisticated
> tools. So I don't know if there'd be a whole lot of overall
> enthusiam for doing a lot to IDLE.

Whilst I understand all about not having time for things because there
are other things to do (!), I do think it would be a pity if IDLE died
away. It seems to me there is a serious place for a moderately decent
editor that comes free with the Python disttribution, knows *about*
Python, and uses Tkinter (i.e., is maximally portable).

Whilst there might be *better* IDEs (in various senses of the word -
heck, I use XEmacs for "normal" work, does that count?), there is
*great* utility in having a reasonable editor that undestands Python up
and running as soon as one has Python up and running (e.g., on Windows).
After all, the alternative may well be Wordpad/Notepad.

Other IDEs involve other work (to set up), or even money. And for some
of us, each program coming in has to be paper-justified, so it may well
not be worth the effort anyway, even for free code.

If it helps, I'm satisfied with having an editor that understands Python
layout, and provides some debugging and class browsing support - if that
isn't a "proper" IDE I don't care (and I think I'm a moderately serious
programmer - it's been what I get paid for for a while now).

What do I actually want? Well, given Guido and co aren't going to do
much with IDLE in the future, I'd vote to at least keep it around, and
mention it as existing, and I'd hope that it might grow slowly via
sourceforge. Just don't underestimate the demand for it.

Tibs

--
Tony J Ibbs (Tibs)      http://www.tibsnjoan.co.uk/
"How fleeting are all human passions compared with the massive
continuity of ducks." - Dorothy L. Sayers, "Gaudy Night"
My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.)


_______________________________________________
IDLE-dev mailing list
IDLE-dev@python.org
http://mail.python.org/mailman/listinfo/idle-dev



From pobrien@orbtech.com  Wed Jun 20 16:55:12 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 10:55:12 -0500
Subject: [Tutor] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: <Pine.LNX.4.31.0106181704000.12659-100000@emperor.deirdre.org>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEABKBAA.pobrien@orbtech.com>

I can't give a whole lot of feedback except to say that I'd hate to see IDLE
abandoned. Maybe there needs to be an effort to get more people involved in
its upkeep. I'm copying this reply to the Edu and Tutor lists, because IDLE
comes up in conversations over there quite a bit. I think there might be
enough interest to motivate some folks. We certainly had things going when
we figured out how to get Python to respond to "help" in interactive
sessions. Maybe we could come up with a way to keep development of IDLE
moving along without the entire burden falling on Guido.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: idle-dev-admin@python.org [mailto:idle-dev-admin@python.org]On Behalf
Of Wesley Chun
Sent: Monday, June 18, 2001 7:11 PM
To: idle-dev@python.org
Subject: [Idle-dev] IDLE's save-before-run requirement

the subject of this message is basically to get some feedback on
having to save a script within IDLE before running it.  when i'm
making a good number of small changes to my file, doing separate
sets of keystrokes started to get old, so i hacked together a
small patch that allows you to "save-n-run."

i thought i'd get Guido's opinion b4submitting a PEP.  he suggested
i also get some more comments from here.  below is basically what i
proposed and his response.

please direct any comments to me (and/or the group).  thanks!

-wesley

> >    b4 i waste people's time by filing a PEP on IDLE,
> >    have you had any comments regarding having to save
> >    a file before being able to run it?  i find myself
> >    having to do multiple sets of keystrokes every time
> >    i make a small edit, so i just hacked up a new key
> >    binding that does a save-n-run (Shift-F5).  i fi-
> >    gure, if it's not a good idea, at least it would be
> >    a good exercise in the Tkinter chapter!  :-)
> >
> >    any thoughts?  anyway, here's a quick 1-line diff:
> >
> > ScriptBinding.py:
> >
> > 16a17,19
> > > - Save and Run module (Shift-F5) does the same but saves *and*
> > > executes the module's code in the __main__ namespace.
> > >
> > 41a45
> > >         '<<save-and-run-script>>': ['<Shift-F5>'],
> > 48a53
> > >                   ('Save & Run script', '<<save-and-run-script>>'),
> > 150a156,166
> > >     def save_and_run_script_event(self, event):
> > >         if not self.editwin.get_saved():
> > >             name = (self.editwin.short_title() or
> > >                     self.editwin.long_title() or
> > >                     "Untitled")
> > >           if name == 'Untitled':
> > >               self.editwin.io.save_as(event)
> > >           else:
> > >               self.editwin.io.save(event)
> > >       self.run_script_event(event)
>
> Nice patch.
>
> The problem is that IDLE development has virtually come to a halt -- I
> just can't find the time to work on it, and there are other good
> development environments available.  I have some ideas for reworking
> the whole save/run machinery, but no code; and I have working code
> that runs the program in a subprocess, but there's a security issue
> that makes me hesitant to check it in...
>
> I wouldn't create a PEP for IDLE -- just discuss your ideas on
> idle-sig.  Maybe enough people are interested to get me coding
> again, or to get someone else to volunteer...
>
> --Guido van Rossum (home page: http://www.python.org/~guido/)


_______________________________________________
IDLE-dev mailing list
IDLE-dev@python.org
http://mail.python.org/mailman/listinfo/idle-dev



From w.richert@gmx.net  Wed Jun 20 17:18:58 2001
From: w.richert@gmx.net (Willi Richert)
Date: Wed, 20 Jun 2001 18:18:58 +0200
Subject: [Tutor] **kw and self
Message-ID: <01062018185800.09462@charybdis>

Hi,

as a bloody newbie (who as reverted already some others to Python) I walked 
34 times through the whole web and did not get the real meaning of **kw and 
self.

Any help is very appreciated.
willi


From delza@alliances.org  Wed Jun 20 17:23:21 2001
From: delza@alliances.org (Dethe Elza)
Date: Wed, 20 Jun 2001 09:23:21 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE "deemphasised"? Please not so...
In-Reply-To: <NBBBIOJPGKJEKIECEMCBEEABKBAA.pobrien@orbtech.com>
Message-ID: <B7561C09.CD9%delza@alliances.org>

It seems to me that the VPython folk are the perfect ones to pick up the
IDLE development reins.  They're actively working on IDLE already, have
already implemented the autosave mentioned, as well as some others, and
generally seem willing and interested.  I'm not sure what the reasoning is
for keeping the VPython IDLE off in its own fork and not bringing it in as
the official IDLE, since it is being actively developed.

--Dethe

on 01/6/20 08:57 AM, Patrick K. O'Brien at pobrien@orbtech.com wrote:

> I agree with these sentiments and am copying this message to the Edu and
> Tutor lists because I think the folks there are a good part of the demand
> that you mention below.
> 
> In Wesley Chun's thread on amending IDLE, Guido said:
>> The problem is that IDLE development has virtually come to a halt
>> -- I just can't find the time to work on it, and there are other
>> good development environments available.
> 
> Mats Wichmann then said:
>> As Guido knows, I'm certainly interested in IDLE evolving,
>> because I find it a very handy learning tool - not just
>> for me; like Wesley, I try to teach some Python classes
>> from time to time.  There may be "better" IDEs but I'm
>> not convinced I've seen one yet (for Python).  And in my
>> particular situation, it HAS to be cross-platform, I'm
>> not going to fuss with two different IDEs in a classroom
>> situation (students get to choose Win2k or Linux).
>> 
>> But I suspect most "serious programmers" don't really see
>> IDLE as being a "serious IDE" - at least I gather this
>> impression from comments on c.l.p, esp. from folks who come
>> from other (inferior?) languages where an IDE is essential to
>> maintaining any sanity, so they've evolved into quite sophisticated
>> tools. So I don't know if there'd be a whole lot of overall
>> enthusiam for doing a lot to IDLE.
> 
> Whilst I understand all about not having time for things because there
> are other things to do (!), I do think it would be a pity if IDLE died
> away. It seems to me there is a serious place for a moderately decent
> editor that comes free with the Python disttribution, knows *about*
> Python, and uses Tkinter (i.e., is maximally portable).
> 
> Whilst there might be *better* IDEs (in various senses of the word -
> heck, I use XEmacs for "normal" work, does that count?), there is
> *great* utility in having a reasonable editor that undestands Python up
> and running as soon as one has Python up and running (e.g., on Windows).
> After all, the alternative may well be Wordpad/Notepad.
> 
> Other IDEs involve other work (to set up), or even money. And for some
> of us, each program coming in has to be paper-justified, so it may well
> not be worth the effort anyway, even for free code.
> 
> If it helps, I'm satisfied with having an editor that understands Python
> layout, and provides some debugging and class browsing support - if that
> isn't a "proper" IDE I don't care (and I think I'm a moderately serious
> programmer - it's been what I get paid for for a while now).
> 
> What do I actually want? Well, given Guido and co aren't going to do
> much with IDLE in the future, I'd vote to at least keep it around, and
> mention it as existing, and I'd hope that it might grow slowly via
> sourceforge. Just don't underestimate the demand for it.
> 
> Tibs

-- 

Dethe Elza 
Chief Mad Scientist
Burning Tiger Technologies




From pdx4d@teleport.com  Wed Jun 20 17:23:44 2001
From: pdx4d@teleport.com (Kirby Urner)
Date: Wed, 20 Jun 2001 09:23:44 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: <NBBBIOJPGKJEKIECEMCBAEABKBAA.pobrien@orbtech.com>
References: <Pine.LNX.4.31.0106181704000.12659-100000@emperor.deirdre.org>
Message-ID: <4.2.0.58.20010620092102.00a39f00@pop3.norton.antivirus>

Lots of schools have iMacs and teaching Python would probably
involve using IDLE on a Mac.  I tried this once.  My recollection
is I didn't get the color-coding of key words.  Can anyone
confirm/disconfirm this is a missing feature in Mac version?
Perhaps I missed a toggle or something.

Kirby
Python IDLE user



From alan.gauld@bt.com  Wed Jun 20 17:15:18 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 20 Jun 2001 17:15:18 +0100
Subject: [Tutor] Capturing user input
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D83F@mbtlipnt02.btlabs.bt.co.uk>

> understand why this will not work.  I am using IDLE and a 
> tutorial, the following code is to capture the user input:
> 
> name = raw_input ("What is your name? ")
> print name

There was a bug in early versions of IDLE (pre 0.5) which means 
raw_input() did not always work. Try running the script at a 
DOS Python prompt and see if it works there. If so its IDLE that's 
broken, you should ideally upgrade your Python version or at 
least upgrade IDLE to v0.5

Assuming you are on an earlier version of course!

Alan G


From scarblac@pino.selwerd.nl  Wed Jun 20 17:55:30 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 20 Jun 2001 18:55:30 +0200
Subject: [Tutor] **kw and self
In-Reply-To: <01062018185800.09462@charybdis>; from w.richert@gmx.net on Wed, Jun 20, 2001 at 06:18:58PM +0200
References: <01062018185800.09462@charybdis>
Message-ID: <20010620185530.A14931@pino.selwerd.nl>

On  0, Willi Richert <w.richert@gmx.net> wrote:
> as a bloody newbie (who as reverted already some others to Python) I walked 
> 34 times through the whole web and did not get the real meaning of **kw and 
> self.

*breathe in deeply*

Ok.

PART I: THE HEDGEHOG
--------------------

No wait, that's wrong.

PART I, edited: KEYWORD ARGUMENTS
----------------------------------

(this has become quite long. probably the best way to understand it
completely is to enter all the examples into an interpreter and play around
with them).

Do you know what a default argument to a function is? Say we have a function
like

def and_now_for(s = "something completely different"):
   print "And now for...", s

It takes one argument, in principle:
>>> and_now_for("more shrubberies")
And now for... more shrubberies

But you can also take the argument off, so that the default is used:
>>> and_now_for()
And now for... something completely different

This is obviously useful. Now say we have a function that takes several
arguments:

def recipe(ingr1="spam", ingr2="spam", ingr3="eggs", ingr4="spam"):
   print ingr1, ingr1, ing3, "and", ingr4

It works fine when called with no arguments, or with some:
>>> recipe()
spam spam eggs and spam
>>> recipe("beans")
beans spam eggs and spam

But what if we want to leave all the default arguments in, except for the
*last*? You can't give an argument except when you also enter all the ones
before it, or Python doesn't know what you want. Enter keyword arguments:

>>> recipe(ingr4="shrubberies")
spam spam eggs and shrubberies

Again, useful. You can fill in any argument like this. For instance in
Tkinter GUIs, functions have lots and lots of default arguments and you
usually only want to enter one or two, so you use keyword arguments.

Now this can be made even more general, with the **arguments construct.
You don't bother to list the arguments and their defaults anymore, but let
the user give any keyword arguments it wants, and they're passed in as a 
*dictionary*. Consider:

def kwarg_demo(**kwargs):
   print kwargs

>>> kwarg_demo(first="bla", second="whee")
{'first': 'bla', 'second': 'whee'}

The function gets a dictionary, it can see which values were filled in
(using kwargs.has_key or kwargs.keys(), for instance). It's flexible.

That's using **kwargs when you *define* a function. Since 2.0 it can also be
used to pass in values. Say you have a function like

def two_arguments(first, second):
   print "first =", first
   print "second =", second

Now we know that the arguments are called first and second, and we've got
some values for them in a dictionary:

dict = {
   'first': 'silly party',
   'second': 'very silly party'
   }

Now, we can call the function using the dictionary, with
>>> two_arguments(**dict)
first = silly party
second = very silly party

What that actually does is fill in the values from the dictionary, like
two_arguments(first='silly party', second='very silly party')

So both when defining and calling a function, you can use the **arguments
syntax to fake keyword arguments with a dictionary.


(pause. you may reread that a few times. i think i laid out the reasoning
sufficiently)


There's a related syntax, with a single *. This is used for giving a
function a variable number of arguments, that don't need their own names.

Say, we have some functions for adding numbers:

def add2(x,y): return x+y

def add3(x,y,z): return x+y+z

def add4(w,x,y,z): return w+x+y+z

Doesn't really look Pythonic, does it? We need a seperate function for every
amount of numbers. In comes the * argument:

def add(*args):
   sum = 0
   for number in args:
      sum += number
   return sum

Now we can call it with as many numbers as we like!

>>> add(3,4,5,6)
18

The number are passed into the function as a tuple, and we can use a for
loop to go through them. The other way around works as well, since Python 2.0;
you can have any sequence, put a * in front and it passes them as individual
arguments to the function:

>>> l = [1,2,3,4,5]
>>> add(*l)
15
>>> add(5, *l)
20
>>> add(5, *l, 6)
               ^
SyntaxError: invalid syntax

Unfortunately, that one doesn't work. Any normal arguments must always come
before the *args, and those must come before the **kwargs.

So if you want to make a function that takes a function as argument, plus
any number of arguments and also keyword arguments, if any, and calls the
function with it, you do it like this, in Python 2.0+:

def apply(f, *args, **kwargs):
   return f(*args, **kwargs)

In older versions, you can't write this - but this apply() function is a
builtin! And that's how you'd do it in older version, use apply().

>>> apply(add, (3,4,5))  # is equivalent to...
12
>>> add(*(3,4,5))        # in newer versions.

Well, that was quite some text. Have to leave again now, hopefully someone
else writes a tome on 'self' or otherwise I'll do that myself later tonight.

-- 
Remco Gerlich


From GBunting864@Worldsavings.com  Wed Jun 20 17:59:16 2001
From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x))
Date: Wed, 20 Jun 2001 11:59:16 -0500
Subject: [Tutor] problems with time.sleep()
Message-ID: <97E9FA3149D0D311BE5800008349BB270174919E@ok1ems1.worldsavings.com>

Hi,

Below is a script that I am trying to write.  Basically it grabs a url and
downloads a file, calculates the speed of the download and place the speed
and time in a dictionary.  The next step to figure out a way to use Tkinter
to graph the results.  The problem I'm getting is it is not printing out the
list that is in the dictionary, and gives no error for that, and the
time.sleep() function fails.  I am on windows NT using ActivePython.  The
script, output, and errors are below.  Any improvements would be
appreciated.

Thanks
Glen


#!/usr/bin/env python

import os, urllib
from time import *

def updateSpeedvar():
        while 1:
                import time
                first = time.time()
                print first
 
urllib.urlretrieve('http://theworks.tucows.com/files3/cooolftp.exe',
                           'test')
                second = time.time()
                print second
                final = second - first
                print final
                speed1 = 1622/final
                speed = round(speed1, 1)
                print speed
                time = strftime("%X", localtime())
                print time
                dict = {time:speed}
                dict.items()
                time.sleep(180)
        


if __name__=='__main__':
    updateSpeedvar()


>>> 993055818.748
993055819.018
0.269999980927
6007.4
09:50:19
Traceback (most recent call last):
  File "c:\python21\pythonwin\pywin\framework\scriptutils.py", line 301, in
RunScript
    exec codeObject in __main__.__dict__
  File "C:\python\bandwidth3.py", line 30, in ?
    updateSpeedvar()
  File "C:\python\bandwidth3.py", line 25, in updateSpeedvar
    time.sleep(180)
AttributeError: sleep


*****************************************************************************
If you are not the intended recipient of this e-mail, please notify 
the sender immediately. The contents of this e-mail do not amend 
any existing disclosures or agreements unless expressly stated.
*****************************************************************************


From deirdre@deirdre.net  Wed Jun 20 18:03:45 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Wed, 20 Jun 2001 10:03:45 -0700
Subject: [Tutor] Normal distribution random numbers?
Message-ID: <a05100e08b75685a3500f@[169.254.218.155]>

I can't find anything out there useful, but perhaps it's just that 
I'm so overtired and fried from grad school finals week (now week and 
a half).

Given a mean, a standard deviation and a random number 0..1, I need a 
function that gives me the generated random number corrected for the 
mean and standard deviation.

This is one of those stats-with-calculus problems that I simply am 
not proficient enough in either subject to derive myself (especially 
not in my current brain mush state).

I've seen stuff out there that'll give the cdf, but that's not what I 
need. I need the raw #. 


From dyoo@hkn.eecs.berkeley.edu  Wed Jun 20 18:26:05 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 20 Jun 2001 10:26:05 -0700 (PDT)
Subject: [Tutor] Python and web scripting
In-Reply-To: <Pine.LNX.4.31.0106191401590.14960-100000@emperor.deirdre.org>
Message-ID: <Pine.LNX.4.21.0106191500110.27678-100000@hkn.eecs.berkeley.edu>

On Tue, 19 Jun 2001, Wesley Chun wrote:

> On Tue, 19 Jun 2001, Michael wrote:
> >
> > It seemed to be the most versatile language.  I was mainly interested in
> > being able to use it in web applications, but as I progress, I like the idea
> > of being able to do a complete application, GUI and all.  Glade sounds
> > awesome.
> 
> yes, i have seen a demonstration of GLADE and it looks quite potent.
> i don't think GUI development had it any easier!

For those who haven't heard about Glade, it's a "gui-builder" in the style
of Visual Basic: you have an empty window, and can interactively add
buttons, menus, and other neat things to this window.  Glade is wonderful
because it make gui-building really easy and experimental, and when we mix
it with Python, everything is good.  *grin*

>From my knowledge, it only works on Unix systems, but please correct me if
this is outdated.  It would be wonderful if someone had a prepackaged
version of Glade/Gtk+/LibGlade on Windows.

Deirdre's written a quicky tutorial about Glade here:

"The Ten Minute Total Idiot's Guide to using Gnome/Gtk+ & Glade with
Python":

    http://www.baypiggies.org/10mintig.html

No comment about the title.



From dsh8290@rit.edu  Wed Jun 20 18:27:35 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 20 Jun 2001 13:27:35 -0400
Subject: [Tutor] Capturing user input
In-Reply-To: <02c001c0f9a1$7b043ca0$e0506bd5@default>; from adrianhome@webspinners.co.uk on Wed, Jun 20, 2001 at 04:55:49PM +0100
References: <02c001c0f9a1$7b043ca0$e0506bd5@default>
Message-ID: <20010620132734.A7721@harmony.cs.rit.edu>

On Wed, Jun 20, 2001 at 04:55:49PM +0100, Adrian at home wrote:
| 
| It works from me when I use the Python shell in IDLE, but if I type it into
| a file "test.py" save and run it F5, I get no output of the variable "name."
| BTW, I am running on WIN ME.  I get no error messages after I press return,
| It seems that it is still capturing user input and not getting to the print
| command.

What happens after you press return?  Does the "DOS" window disappear?
If so, then it printed just fine, Windows just didn't think you wanted
to read it =p.  It is a well known problem with Windows shell support.
There are a couple of solutions :

1)  add an extra  'raw_input()' call to the end of the script, then
    the shell window won't disappear until you press enter (again)

2)  figure out how to tell windows not to close the window when the
    program completes, I don't remember any more (and have yet to find
    it on win2k)

3)  open a shell window manually, then run the script from the command
    line.  The window won't close because the shell is still running
    (you'll get another prompt).  This is what I do.


I just reread your message and saw that you used "F5" in IDLE to run
the script.  I have never used IDLE so I can't help there.  The stuff
I wrote above pertains to double-clicking on the .py file in explorer
to run it so they are irrelevant; the first might actually still be
relevant.  Useful to know anyways.

-D



From csmith@blakeschool.org  Wed Jun 20 18:35:11 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Wed, 20 Jun 2001 12:35:11 -0500
Subject: [Tutor] A (not so) simple question? Round Robin
In-Reply-To: <E15Cgq2-0007Il-00@mail.python.org>
References: <E15Cgq2-0007Il-00@mail.python.org>
Message-ID: <fc.004c4b6b00758b7a3b9aca003506ae07.758cbb@blakeschool.org>

Thanks to Roland and Greg for comments regarding the Round Robin Code.  
Since then I have been reading the Language Reference and learned about 
the "list comprehension" approach to handling lists.  Here is the way 
I now can extract certain keys and then extract the corresponding 
entries.  I already have a dictionary named "t" with tuple keys which 
are pairs of integers (i,j).  I want to print out all entries having a 
key with a given value of i:

  k=t.keys()
  k.sort() # so they are in column order when the row is extracted
  for i in range(n):
    # get the keys for this row and corresponding entries
    row=[x for x in k if x[0]==i]
    p=[t[x] for x in row]
    # print them
    print "%s |" % teams[i] + "%3d"*n % tuple(p)

I noted also in reading (and in Greg's code) that lists of lists are
the preferred way to do matrices.  Introducing this eliminates the 
need for the above "dictionary row extraction."

Here's an alternate way to initialize an array (i.e. list of lists)
 # function to initialize array
  def make_array(r,c):
    a=[]
    for i in range(r):
      a.append([])
      for ii in range(c):
        a[i].append(0)
    return a

/c
-------------------------------------------------------------
Have you ever sung in Latin? The sounds are so nice to sing.  
Did you ever code in Python?  It's very much the same thing.



From dsh8290@rit.edu  Wed Jun 20 18:36:11 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 20 Jun 2001 13:36:11 -0400
Subject: [Tutor] problems with time.sleep()
In-Reply-To: <97E9FA3149D0D311BE5800008349BB270174919E@ok1ems1.worldsavings.com>; from GBunting864@worldsavings.com on Wed, Jun 20, 2001 at 11:59:16AM -0500
References: <97E9FA3149D0D311BE5800008349BB270174919E@ok1ems1.worldsavings.com>
Message-ID: <20010620133611.B7721@harmony.cs.rit.edu>

On Wed, Jun 20, 2001 at 11:59:16AM -0500, Bunting, Glen, IG (x) wrote:
| Hi,
| 
| Below is a script that I am trying to write.  Basically it grabs a url and
| downloads a file, calculates the speed of the download and place the speed
| and time in a dictionary.  The next step to figure out a way to use Tkinter
| to graph the results.  The problem I'm getting is it is not printing out the
| list that is in the dictionary, and gives no error for that, and the
| time.sleep() function fails.  I am on windows NT using ActivePython.  The
| script, output, and errors are below.  Any improvements would be
| appreciated.
| 
| Thanks
| Glen
| 
| 
| #!/usr/bin/env python
| 
| import os, urllib
| from time import *

Bad, bad.  It is not recommended to use "from-import-*".  Note that
this does NOT create a name at the module level called 'time'.

| def updateSpeedvar():
|         while 1:
|                 import time

Here you import time again.  Any reason?  (Other than to create the
binding 'time' to the module object, which wasn't done at the top)?

|                 first = time.time()
|                 print first
|  
| urllib.urlretrieve('http://theworks.tucows.com/files3/cooolftp.exe',
|                            'test')
|                 second = time.time()
|                 print second
|                 final = second - first
|                 print final
|                 speed1 = 1622/final
|                 speed = round(speed1, 1)
|                 print speed
|                 time = strftime("%X", localtime())
                  ^^^^^^
Here you rebind the local name 'time' to a string object.  It no
longer refers to the module object it used to.

|                 print time
|                 dict = {time:speed}
|                 dict.items()
|                 time.sleep(180)

Here time is a string and has no 'sleep' attribute.



I would highly recommend changing the 'from time import *' line at the
beginning to 'import time', then removing the import from inside the
loop (it is redundant now).  Then always qualify the functions.  Ex
use 'time.strftime' not 'strftime'.  As a final fix, change the name
of the local reference to a string to something other than 'time'.
Use 'time_str' or some other name.

The not recommended fix would be to remove the 'time.' from the sleep
call because 'sleep' (and other stuff) was already brought into the
module's namespace, and hasn't been rebound since then.

HTH,
-D



From deirdre@deirdre.net  Wed Jun 20 18:33:00 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Wed, 20 Jun 2001 10:33:00 -0700
Subject: [Tutor] **kw and self
In-Reply-To: <20010620185530.A14931@pino.selwerd.nl>
References: <01062018185800.09462@charybdis>
 <20010620185530.A14931@pino.selwerd.nl>
Message-ID: <a05100e09b7568ab27f77@[169.254.218.155]>

At 6:55 PM +0200 6/20/01, Remco Gerlich wrote:
>On  0, Willi Richert <w.richert@gmx.net> wrote:
>>  as a bloody newbie (who as reverted already some others to Python) I walked
>>  34 times through the whole web and did not get the real meaning of **kw and
>>  self.
>
>*breathe in deeply*
>
>Ok.
>
>PART I: THE HEDGEHOG
>--------------------
>
>No wait, that's wrong.

::snort:;

Thanks for making my morning. I'm tired and grumpy, but this made me laugh.

Therefore I'll answer the self question. :)

self, when used with variables, means: "for this instance of this 
class, this variable is set to that."

Most classes have multiple instances, meaning there's 52 cards or 7 
robots or whatever.

When self is used with methods, it means "use the function that 
belongs to this class."

Note that the first argument, implied when you pass something to a 
class's method, is self.

consider the following example:

class robot:
  def __init__(self, name, robotlist):
   self.name = name
   robotlist.append(self)

robotlist = []

robbie = robot('In',  robotlist)
robbie = robot('A',   robotlist)
robbie = robot('B',   robotlist)
robbie = robot('C',   robotlist)
robbie = robot('D',   robotlist)
robbie = robot('E',   robotlist)
robbie = robot('Out', robotlist)

for i in robotlist:
  print i.name

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From adrianhome@webspinners.co.uk  Wed Jun 20 18:49:15 2001
From: adrianhome@webspinners.co.uk (Adrian at home)
Date: Wed, 20 Jun 2001 18:49:15 +0100
Subject: [Tutor] Capturing user input
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D83F@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <03bb01c0f9b1$536799c0$e0506bd5@default>

Alan

Yep, you are correct.  I upgraded and viola! it works great, thanks -:)
Thanks for the responses and D-man thanks for the info.

Adrian

----- Original Message -----
From: <alan.gauld@bt.com>
To: <adrianhome@webspinners.co.uk>; <tutor@python.org>
Sent: Wednesday, June 20, 2001 5:15 PM
Subject: RE: [Tutor] Capturing user input


> > understand why this will not work.  I am using IDLE and a
> > tutorial, the following code is to capture the user input:
> >
> > name = raw_input ("What is your name? ")
> > print name
>
> There was a bug in early versions of IDLE (pre 0.5) which means
> raw_input() did not always work. Try running the script at a
> DOS Python prompt and see if it works there. If so its IDLE that's
> broken, you should ideally upgrade your Python version or at
> least upgrade IDLE to v0.5
>
> Assuming you are on an earlier version of course!
>
> Alan G
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.259 / Virus Database: 130 - Release Date: 05/06/2001



From scarblac@pino.selwerd.nl  Wed Jun 20 18:48:28 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 20 Jun 2001 19:48:28 +0200
Subject: [Tutor] Normal distribution random numbers?
In-Reply-To: <a05100e08b75685a3500f@[169.254.218.155]>; from deirdre@deirdre.net on Wed, Jun 20, 2001 at 10:03:45AM -0700
References: <a05100e08b75685a3500f@[169.254.218.155]>
Message-ID: <20010620194828.A15007@pino.selwerd.nl>

On  0, Deirdre Saoirse Moen <deirdre@deirdre.net> wrote:
> I can't find anything out there useful, but perhaps it's just that 
> I'm so overtired and fried from grad school finals week (now week and 
> a half).
> 
> Given a mean, a standard deviation and a random number 0..1, I need a 
> function that gives me the generated random number corrected for the 
> mean and standard deviation.
> 
> This is one of those stats-with-calculus problems that I simply am 
> not proficient enough in either subject to derive myself (especially 
> not in my current brain mush state).
> 
> I've seen stuff out there that'll give the cdf, but that's not what I 
> need. I need the raw #. 

*scratch head*. As far as I can see, you'd need the distribution function
for this, not the density function. And although the density function is
well known, the distribution (which is the density function, integrated - my
english vocabulary isn't perfect in this area) isn't directly know, afaik.

That is, if you have a bell curve thingy, the uniform number 0.9 would
correspond to the point where the area under the bell curve to the left of
the point would be 90% of the total. So you need to integrate the function,
and that is hard.

*search search*

All the explanations I can find seem to support this, they all ignore the
problem and point to a table. (I'm looking mainly at
http://davidmlane.com/hyperstat/normal_distribution.html ). I'm very rusty
with this subject, but I think the only way is to build a table.
You need the sums of tiny approximations to the area under the bell curve.
   
Before I try to write some Python, what do you need this for? What kind of
accuracy? Do I sound like I'm making sense?

*BLINK*

Hmm, there are functions in the random module :)
*read source* (you can also generate normally distributed numbers directly)

Apparently, if x and y are random independent variables in [0,1), uniformly
distributed, then both

cos(2*pi*x)*sqrt(-2*log(1-y))
and
sin(2*pi*x)*sqrt(-2*log(1-y))

Are independent variables with distribution mu = 0, sigma = 1.

That should help. See the bit around line 500 in Lib/random.py (in 2.1).

Hmm, tutor posts by random experiment...

-- 
Remco gerlich


From csmith@blakeschool.org  Wed Jun 20 19:03:42 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Wed, 20 Jun 2001 13:03:42 -0500
Subject: [Tutor] Initializing array (was Round Robin)
In-Reply-To: <E15Cgq2-0007Il-00@mail.python.org>
References: <E15Cgq2-0007Il-00@mail.python.org>
Message-ID: <fc.004c4b6b00758ccd3b9aca003506ae07.758d6a@blakeschool.org>

Chris wrote:

> Here's an alternate way to initialize an array (i.e. list of lists)
>  # function to initialize array
>   def make_array(r,c):
>     a=[]
>     for i in range(r):
>       a.append([])
>       for ii in range(c):
>         a[i].append(0)
>     return a

Or how about simply:

	for i in range(r):a.append([0]*c)

But not

	a=[[0]*c]*r

Since the latter creates aliases--look at the following interpreted
session:  

>>> r=2;c=3
>>> a=[[0]*c]*r
>>> a[1][1]=2;a
[[0, 2, 0], [0, 2, 0]]
>>>

You only set a[1][1] to 2 but all a[i][1] values are the same (apparently).

If you use the former code then type the following in the interpreter:

>>> a=[]
>>> for i in range(r):a.append([0]*c)
... 
>>> a[1][1]=2;a
[[0, 0, 0], [0, 2, 0]]
>>>

you obtain a different (perhaps more desired) result.

/c



From guido@digicool.com  Wed Jun 20 19:06:40 2001
From: guido@digicool.com (Guido van Rossum)
Date: Wed, 20 Jun 2001 14:06:40 -0400
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE "deemphasised"? Please not so...
In-Reply-To: Your message of "Wed, 20 Jun 2001 09:23:21 PDT."
 <B7561C09.CD9%delza@alliances.org>
References: <B7561C09.CD9%delza@alliances.org>
Message-ID: <200106201806.f5KI6eN01330@odiug.digicool.com>

> It seems to me that the VPython folk are the perfect ones to pick up the
> IDLE development reins.  They're actively working on IDLE already, have
> already implemented the autosave mentioned, as well as some others, and
> generally seem willing and interested.  I'm not sure what the reasoning is
> for keeping the VPython IDLE off in its own fork and not bringing it in as
> the official IDLE, since it is being actively developed.

I think it was that I wanted to keep control over the direction in
which IDLE was going.  The idle-fork SourceForge project was created
so they could do their development.  But I don't think much happened
there, and I haven't really done much except stifle IDLE development,
so I'm ready to relax my control.  I do have that subprocess-running
code which I would like to get worked into IDLE first though...

--Guido van Rossum (home page: http://www.python.org/~guido/)



From guido@digicool.com  Wed Jun 20 19:07:39 2001
From: guido@digicool.com (Guido van Rossum)
Date: Wed, 20 Jun 2001 14:07:39 -0400
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: Your message of "Wed, 20 Jun 2001 09:23:44 PDT."
 <4.2.0.58.20010620092102.00a39f00@pop3.norton.antivirus>
References: <Pine.LNX.4.31.0106181704000.12659-100000@emperor.deirdre.org>
 <4.2.0.58.20010620092102.00a39f00@pop3.norton.antivirus>
Message-ID: <200106201807.f5KI7dL01340@odiug.digicool.com>

> Lots of schools have iMacs and teaching Python would probably
> involve using IDLE on a Mac.  I tried this once.  My recollection
> is I didn't get the color-coding of key words.  Can anyone
> confirm/disconfirm this is a missing feature in Mac version?
> Perhaps I missed a toggle or something.
> 
> Kirby
> Python IDLE user

Actually, IDLE on a Mac doesn't really work, because Tcl on a Mac
doesn't really work.

But MacPython comes with its own IDE, built by Just van Rossum (my
brother) using the native Mac toolbox.

--Guido van Rossum (home page: http://www.python.org/~guido/)


From israel@lith.com  Wed Jun 20 19:16:23 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 20 Jun 2001 11:16:23 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r
 equirement
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144D9@mailcluster.lith.com>

I'd just like to say that I love IDLE.  It's the only thing I do Python in.
It's also the First tool that has made me comfortable with an interactive
interpreter.  Emacs just frightens me! Vim is Spooky! IDLE is just right!

~Israel~

-----Original Message-----
From: Guido van Rossum [mailto:guido@digicool.com]
Sent: Wednesday, June 20, 2001 11:08 AM
To: Kirby Urner
Cc: pobrien@orbtech.com; idle-dev@python.org; Python Edu SIG; Python
Tutor
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
requirement


> Lots of schools have iMacs and teaching Python would probably
> involve using IDLE on a Mac.  I tried this once.  My recollection
> is I didn't get the color-coding of key words.  Can anyone
> confirm/disconfirm this is a missing feature in Mac version?
> Perhaps I missed a toggle or something.
> 
> Kirby
> Python IDLE user

Actually, IDLE on a Mac doesn't really work, because Tcl on a Mac
doesn't really work.

But MacPython comes with its own IDE, built by Just van Rossum (my
brother) using the native Mac toolbox.

--Guido van Rossum (home page: http://www.python.org/~guido/)

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


From deirdre@deirdre.net  Wed Jun 20 19:16:02 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Wed, 20 Jun 2001 11:16:02 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
 requirement
In-Reply-To: <200106201807.f5KI7dL01340@odiug.digicool.com>
References: <Pine.LNX.4.31.0106181704000.12659-100000@emperor.deirdre.org>
 <4.2.0.58.20010620092102.00a39f00@pop3.norton.antivirus>
 <200106201807.f5KI7dL01340@odiug.digicool.com>
Message-ID: <a05100e10b75697ec98ed@[169.254.218.155]>

At 2:07 PM -0400 6/20/01, Guido van Rossum wrote:
>  > Lots of schools have iMacs and teaching Python would probably
>>  involve using IDLE on a Mac.  I tried this once.  My recollection
>>  is I didn't get the color-coding of key words.  Can anyone
>>  confirm/disconfirm this is a missing feature in Mac version?
>>  Perhaps I missed a toggle or something.
>>
>>  Kirby
>>  Python IDLE user
>
>Actually, IDLE on a Mac doesn't really work, because Tcl on a Mac
>doesn't really work.
>
>But MacPython comes with its own IDE, built by Just van Rossum (my
>brother) using the native Mac toolbox.

And he's a great help to the Mac Python community.

As Russell E Owen also pointed out today on PythonMac:

"Christopher Stern wrote a nice BBEdit Python language plugin, available from
<http://homepage.mac.com/christopherstern/>. That is the only one I know of.

Also, just for the record, the Pepper editor has Python syntax 
coloring built in. I believe Alpha may, as well."

I don't know if the BBEdit plugin works on MacOS X; I haven't tried 
either yet. (I've been using TextEdit for python mostly because I've 
been to crushed with grad school work to bother downloading and 
installing stuff)
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From brendhanhorne@yahoo.com  Wed Jun 20 19:20:15 2001
From: brendhanhorne@yahoo.com (Brendhan Horne)
Date: Wed, 20 Jun 2001 14:20:15 -0400
Subject: [Tutor] raw_input
Message-ID: <006601c0f9b5$a7d7abe0$010044c0@hal9000>

This is a multi-part message in MIME format.

------=_NextPart_000_0063_01C0F994.202EFC00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

>>> raw_input ("Enter your name:")
Enter your name:Brendhan
'Brendhan'
>>> print name
Traceback (innermost last):
  File "<pyshell#7>", line 1, in ?
    print name
NameError: There is no variable named 'name'

Okay What did I do wrong it should have printed my name after the print =
name
command.

--
Thanks,
Brendhan
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
D G(++) e+(++) h-- r++ y++*
------END GEEK CODE BLOCK------



------=_NextPart_000_0063_01C0F994.202EFC00
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 size=3D2>&gt;&gt;&gt; raw_input ("Enter your name:")<BR>Enter =
your=20
name:Brendhan<BR>'Brendhan'<BR>&gt;&gt;&gt; print name<BR>Traceback =
(innermost=20
last):<BR>&nbsp; File "&lt;pyshell#7&gt;", line 1, in =
?<BR>&nbsp;&nbsp;&nbsp;=20
print name<BR>NameError: There is no variable named 'name'<BR><BR>Okay =
What did=20
I do wrong it should have printed my name after the print=20
name<BR>command.<BR><BR>--<BR>Thanks,<BR>Brendhan<BR>-----BEGIN GEEK =
CODE=20
BLOCK-----<BR>Version: 3.1<BR>GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ =
o+ K-=20
w+<BR>O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++<BR>D G(++) =
e+(++) h--=20
r++ y++*<BR>------END GEEK CODE =
BLOCK------<BR><BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_0063_01C0F994.202EFC00--


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



From deirdre@deirdre.net  Wed Jun 20 19:09:44 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Wed, 20 Jun 2001 11:09:44 -0700
Subject: [Tutor] Normal distribution random numbers?
In-Reply-To: <20010620194828.A15007@pino.selwerd.nl>
References: <a05100e08b75685a3500f@[169.254.218.155]>
 <20010620194828.A15007@pino.selwerd.nl>
Message-ID: <a05100e0fb75696252e38@[169.254.218.155]>

At 7:48 PM +0200 6/20/01, Remco Gerlich wrote:
>*scratch head*. As far as I can see, you'd need the distribution function
>for this, not the density function. And although the density function is
>well known, the distribution (which is the density function, integrated - my
>english vocabulary isn't perfect in this area) isn't directly know, afaik.

That's what I thought. Worse, my calculus is really limited to simple 
derivatives and integrals and not up to that par.

>That is, if you have a bell curve thingy, the uniform number 0.9 would
>correspond to the point where the area under the bell curve to the left of
>the point would be 90% of the total. So you need to integrate the function,
>and that is hard.

Right, that's what they call the cdf (cumulative distribution function).

>All the explanations I can find seem to support this, they all ignore the
>problem and point to a table. (I'm looking mainly at
>http://davidmlane.com/hyperstat/normal_distribution.html ). I'm very rusty
>with this subject, but I think the only way is to build a table.
>You need the sums of tiny approximations to the area under the bell curve.
>
>Before I try to write some Python, what do you need this for? What kind of
>accuracy? Do I sound like I'm making sense?

Well, I'm working on the last bit of a final exam that has questions like:

"Consider the assembly of two steel plates, each plate having a hole 
drilled in its center. The plates are to be joined by a pin. The 
plates are aligned for assembly relative to the bottom left corner 
(0, 0).

The hole placement is centered at (3, 2) on each plate. The standard 
deviation in each direction is 0.0045.

The hole diameter is normally distributed with a mean of 0.3 and a 
standard deviation of 0.005.

The pin diameter is also distributed normally with a mean of 0.29 and 
a standard deviation of 0.004.

What fraction of pins will go through the assempled plates? Base your 
answer on a simulation of 50 observations."

(don't worry, I'll solve it myself, I was just stumped by needing 
random numbers normally distributed)

>Hmm, there are functions in the random module :)
>*read source* (you can also generate normally distributed numbers directly)

Doh!

Thanks -- that just solved my problem.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From GBunting864@Worldsavings.com  Wed Jun 20 19:24:29 2001
From: GBunting864@Worldsavings.com (Bunting, Glen, IG (x))
Date: Wed, 20 Jun 2001 13:24:29 -0500
Subject: [Tutor] problems with time.sleep()
Message-ID: <97E9FA3149D0D311BE5800008349BB270174933B@ok1ems1.worldsavings.com>

I made the changes you suggested and everything works now.

Thanks,
Glen

 -----Original Message-----
From: 	D-Man [mailto:dsh8290@rit.edu] 
Sent:	Wednesday, June 20, 2001 10:36 AM
To:	tutor@python.org
Subject:	Re: [Tutor] problems with time.sleep()

On Wed, Jun 20, 2001 at 11:59:16AM -0500, Bunting, Glen, IG (x) wrote:
| Hi,
| 
| Below is a script that I am trying to write.  Basically it grabs a url and
| downloads a file, calculates the speed of the download and place the speed
| and time in a dictionary.  The next step to figure out a way to use
Tkinter
| to graph the results.  The problem I'm getting is it is not printing out
the
| list that is in the dictionary, and gives no error for that, and the
| time.sleep() function fails.  I am on windows NT using ActivePython.  The
| script, output, and errors are below.  Any improvements would be
| appreciated.
| 
| Thanks
| Glen
| 
| 
| #!/usr/bin/env python
| 
| import os, urllib
| from time import *

Bad, bad.  It is not recommended to use "from-import-*".  Note that
this does NOT create a name at the module level called 'time'.

| def updateSpeedvar():
|         while 1:
|                 import time

Here you import time again.  Any reason?  (Other than to create the
binding 'time' to the module object, which wasn't done at the top)?

|                 first = time.time()
|                 print first
|  
| urllib.urlretrieve('http://theworks.tucows.com/files3/cooolftp.exe',
|                            'test')
|                 second = time.time()
|                 print second
|                 final = second - first
|                 print final
|                 speed1 = 1622/final
|                 speed = round(speed1, 1)
|                 print speed
|                 time = strftime("%X", localtime())
                  ^^^^^^
Here you rebind the local name 'time' to a string object.  It no
longer refers to the module object it used to.

|                 print time
|                 dict = {time:speed}
|                 dict.items()
|                 time.sleep(180)

Here time is a string and has no 'sleep' attribute.



I would highly recommend changing the 'from time import *' line at the
beginning to 'import time', then removing the import from inside the
loop (it is redundant now).  Then always qualify the functions.  Ex
use 'time.strftime' not 'strftime'.  As a final fix, change the name
of the local reference to a string to something other than 'time'.
Use 'time_str' or some other name.

The not recommended fix would be to remove the 'time.' from the sleep
call because 'sleep' (and other stuff) was already brought into the
module's namespace, and hasn't been rebound since then.

HTH,
-D


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


*****************************************************************************
If you are not the intended recipient of this e-mail, please notify 
the sender immediately. The contents of this e-mail do not amend 
any existing disclosures or agreements unless expressly stated.
*****************************************************************************


From rob@jam.rr.com  Wed Jun 20 19:31:26 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 20 Jun 2001 13:31:26 -0500
Subject: [Tutor] raw_input
References: <006601c0f9b5$a7d7abe0$010044c0@hal9000>
Message-ID: <003201c0f9b7$37b7d5e0$de00a8c0@planhouse5>

Your first line reads:

 >>> raw_input ("Enter your name:")

It should probably read:

>>> name = raw_input("Enter your name:")

This way you assign the user's raw input to the variable "name". And when
you ">>> print name" it should print the value assigned to name.

Woohoo I can help! 3;->

Rob
Useless Python
It's not just for breakfast anymore!
http://www.lowerstandard.com/python/index.html
----- Original Message -----
From: Brendhan Horne
To: tutor@python.org
Sent: Wednesday, June 20, 2001 1:20 PM
Subject: [Tutor] raw_input


>>> raw_input ("Enter your name:")
Enter your name:Brendhan
'Brendhan'
>>> print name
Traceback (innermost last):
  File "<pyshell#7>", line 1, in ?
    print name
NameError: There is no variable named 'name'

Okay What did I do wrong it should have printed my name after the print name
command.

--
Thanks,
Brendhan
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
D G(++) e+(++) h-- r++ y++*
------END GEEK CODE BLOCK------



From scarblac@pino.selwerd.nl  Wed Jun 20 19:31:50 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 20 Jun 2001 20:31:50 +0200
Subject: [Tutor] raw_input
In-Reply-To: <006601c0f9b5$a7d7abe0$010044c0@hal9000>; from brendhanhorne@yahoo.com on Wed, Jun 20, 2001 at 02:20:15PM -0400
References: <006601c0f9b5$a7d7abe0$010044c0@hal9000>
Message-ID: <20010620203150.A15168@pino.selwerd.nl>

On  0, Brendhan Horne <brendhanhorne@yahoo.com> wrote:
> >>> raw_input ("Enter your name:")
> Enter your name:Brendhan
> 'Brendhan'
> >>> print name
> Traceback (innermost last):
>   File "<pyshell#7>", line 1, in ?
>     print name
> NameError: There is no variable named 'name'
> 
> Okay What did I do wrong it should have printed my name after the print name
> command.

You never told Python the the result of raw_input() should be called 'name'.

Try instead:

>>> name = raw_input("Enter your name:")
Enter your name:Remco
>>> print name
Brendhan

You didn't assign the result to some variable, so the interpreter simply
printed the result on the screen (the 'Brendhan' on the line after you typed
it in).

-- 
Remco Gerlich


From deirdre@deirdre.net  Wed Jun 20 19:37:54 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Wed, 20 Jun 2001 11:37:54 -0700
Subject: [Tutor] raw_input
In-Reply-To: <006601c0f9b5$a7d7abe0$010044c0@hal9000>
References: <006601c0f9b5$a7d7abe0$010044c0@hal9000>
Message-ID: <a05100e13b7569dbff5f0@[169.254.218.155]>

At 2:20 PM -0400 6/20/01, Brendhan Horne wrote:
>  >>> raw_input ("Enter your name:")
>Enter your name:Brendhan
>'Brendhan'
>  >>> print name
>Traceback (innermost last):
>   File "<pyshell#7>", line 1, in ?
>     print name
>NameError: There is no variable named 'name'
>
>Okay What did I do wrong it should have printed my name after the print name
>command.

You forgot to assign the result of the raw_input to a variable.

>>>  name = raw_input("Enter your name:")
Enter your name:Deirdre
>>>  print name
Deirdre
>>>

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From pobrien@orbtech.com  Wed Jun 20 19:43:48 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 13:43:48 -0500
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144D9@mailcluster.lith.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBEEAMKBAA.pobrien@orbtech.com>

I agree with that sentiment. While I also use Boa, PythonWin and VPython, I
still like IDLE and usually pop it up for interactive use. What I really
want is the best of them all. I hate to see all these efforts recreating the
wheel. Of course, Boa and PythonWin both use Scintilla, although in slightly
different fashions. It might be nice if everyone standardized on Scintilla
for the core editing capabilities and spent the rest of their effort on
value-added stuff. (Though it wouldn't surprise me if Guido was reluctant to
go with that suggestion and I can't say I blame him.) I think everyone would
benefit if there was more code sharing and/or standard modules for the
standard features that any editor/IDE would have to have. And it would be
nice if these were GUI independent so that we could go from Tkinter to
wxWindows, for example, if we wanted to.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of
Israel Evans
Sent: Wednesday, June 20, 2001 1:16 PM
To: 'Guido van Rossum'; Kirby Urner
Cc: pobrien@orbtech.com; idle-dev@python.org; Python Edu SIG; Python Tutor
Subject: RE: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
requirement

I'd just like to say that I love IDLE.  It's the only thing I do Python in.
It's also the First tool that has made me comfortable with an interactive
interpreter.  Emacs just frightens me! Vim is Spooky! IDLE is just right!

~Israel~




From deirdre@deirdre.net  Wed Jun 20 19:27:51 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Wed, 20 Jun 2001 11:27:51 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r
 equirement
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144D9@mailcluster.lith.com>
References: <AF020C5FC551DD43A4958A679EA16A15A144D9@mailcluster.lith.com>
Message-ID: <a05100e12b7569ad9484a@[169.254.218.155]>

At 11:16 AM -0700 6/20/01, Israel Evans wrote:
>I'd just like to say that I love IDLE.  It's the only thing I do Python in.
>It's also the First tool that has made me comfortable with an interactive
>interpreter.  Emacs just frightens me! Vim is Spooky! IDLE is just right!

This really isn't on-topic, but it's one of my favorite stories, so 
bear with me. :)

My husband, Rick Moen, is an avid vi user. Once, when he was 
entertaining Richard Stallman (for those who may not know, the author 
of emacs), Rick teased RMS by saying, "I hope you don't mind sitting 
next to a vi user."

RMS responded, "we of the Church of emacs believe that use of vi is 
not a sin, but rather penance."

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From mats@laplaza.org  Wed Jun 20 19:57:25 2001
From: mats@laplaza.org (Mats Wichmann)
Date: Wed, 20 Jun 2001 12:57:25 -0600
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's
 save-before-run requirement
In-Reply-To: <NBBBIOJPGKJEKIECEMCBEEAMKBAA.pobrien@orbtech.com>
References: <AF020C5FC551DD43A4958A679EA16A15A144D9@mailcluster.lith.com>
Message-ID: <5.1.0.14.1.20010620125502.00ab55c8@laplaza.org>

 >And it would be
 >nice if these were GUI independent so that we could go from Tkinter to
 >wxWindows, for example, if we wanted to.

I once asked about something like this.  I believe right now
IDLE, at least, is not constructed in such a way that it
would be easy to rip out the Tkinter dependence so it could
be changed to something else, either permanently or for
plug-replacable graphics toolkits.

I wonder how much work that really would be, and if anybody
has any interest in it.  Not sure if there's really enough
value to be gained to make it worthwhile.

Mats



From Mark.Tobin@attcanada.com  Wed Jun 20 20:57:01 2001
From: Mark.Tobin@attcanada.com (Tobin, Mark)
Date: Wed, 20 Jun 2001 13:57:01 -0600
Subject: [Tutor] Killing threads
Message-ID: <3D7C088D6CCFD31190A5009027D30E9103391032@torex004.attcanada.ca>

Ok, I admit it, I can't figure this threading problem out.  I have two
threads called in the main() function:

#Code to follow

def main():
    a = Account()
    a.arp = [300]
    a.threads = []
    t = threading.Thread(target = a.checker, args = (a.arp))
    a.threads.append(t)
    u = threading.Thread(target = a.menu, args = ())
    a.threads.append(u)
    a.nthreads = range(len(a.threads))
    for i in a.nthreads:
        a.threads[i].start()
    for i in a.nthreads:
        a.threads[i].join()

One of the threads, u, is active and provides a (so far) basic interface for
the user through the menu method of the class account.  The second, t, is
generally dormant, but pops up once in a while to check a single flag, then
falls back to sleep.  I need for the active, u, thread to be able to kill
both threads by calling another function quitter().

I know this shouldn't be hard, but I have no idea how to accomplish this.
When I look in the documentation at threading.Thread I can't find any
obvious method to kill the threads.  Can somebody help me, or am I doing
this entirely wrong?  This whole threading concept is really new to me and
I'm just starting to get my head around the idea...

Thanks, 
Mark


From delza@alliances.org  Wed Jun 20 21:18:18 2001
From: delza@alliances.org (Dethe Elza)
Date: Wed, 20 Jun 2001 13:18:18 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
 requirement
In-Reply-To: <NBBBIOJPGKJEKIECEMCBEEAMKBAA.pobrien@orbtech.com>
Message-ID: <B756531A.CFD%delza@alliances.org>

on 01/6/20 11:43 AM, Patrick K. O'Brien at pobrien@orbtech.com wrote:

> I agree with that sentiment. While I also use Boa, PythonWin and VPython, I
> still like IDLE and usually pop it up for interactive use. What I really
> want is the best of them all. I hate to see all these efforts recreating the
> wheel. Of course, Boa and PythonWin both use Scintilla, although in slightly
> different fashions.

And as far as I know, Scintilla hasn't been ported to the Mac, and possibly
other python-enabled platforms.

> It might be nice if everyone standardized on Scintilla
> for the core editing capabilities and spent the rest of their effort on
> value-added stuff. (Though it wouldn't surprise me if Guido was reluctant to
> go with that suggestion and I can't say I blame him.) I think everyone would
> benefit if there was more code sharing and/or standard modules for the
> standard features that any editor/IDE would have to have. And it would be
> nice if these were GUI independent so that we could go from Tkinter to
> wxWindows, for example, if we wanted to.

I think that's the goal of Parrot [1], although I'd prefer to see an
XML-based language for GUI construction with engines for various
languages/platforms/toolkits.  But that just isn't going to happen anytime
soon (although the UIML[2] and XForms[3] projects are working in that
direction).  Since every language and platform seems to be developing ways
to encode their GUI resources in XML, and since the capabilities of GUI
toolkits seem to be approaching a useful common subset, maybe there's hope
someday.

--Dethe

[1] http://www.vision25.demon.co.uk/oss/parrot/intro.html
[2] http://www.uiml.org/
[3] http://www.w3.org/MarkUp/Forms/

> 
> ---
> Patrick K. O'Brien
> Orbtech
> "I am, therefore I think."
> 
> -----Original Message-----
> From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of
> Israel Evans
> Sent: Wednesday, June 20, 2001 1:16 PM
> To: 'Guido van Rossum'; Kirby Urner
> Cc: pobrien@orbtech.com; idle-dev@python.org; Python Edu SIG; Python Tutor
> Subject: RE: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
> requirement
> 
> I'd just like to say that I love IDLE.  It's the only thing I do Python in.
> It's also the First tool that has made me comfortable with an interactive
> interpreter.  Emacs just frightens me! Vim is Spooky! IDLE is just right!
> 
> ~Israel~
> 
> 
> 
> _______________________________________________
> Edu-sig mailing list
> Edu-sig@python.org
> http://mail.python.org/mailman/listinfo/edu-sig
> 

-- 

Dethe Elza 
Chief Mad Scientist
Burning Tiger Technologies




From delza@alliances.org  Wed Jun 20 21:20:04 2001
From: delza@alliances.org (Dethe Elza)
Date: Wed, 20 Jun 2001 13:20:04 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE "deemphasised"? Please not so...
In-Reply-To: <200106201806.f5KI6eN01330@odiug.digicool.com>
Message-ID: <B7565384.CFE%delza@alliances.org>

That's great news!  Are the VPython folks listening?

--Dethe

on 01/6/20 11:06 AM, Guido van Rossum at guido@digicool.com wrote:

>> It seems to me that the VPython folk are the perfect ones to pick up the
>> IDLE development reins.  They're actively working on IDLE already, have
>> already implemented the autosave mentioned, as well as some others, and
>> generally seem willing and interested.  I'm not sure what the reasoning is
>> for keeping the VPython IDLE off in its own fork and not bringing it in as
>> the official IDLE, since it is being actively developed.
> 
> I think it was that I wanted to keep control over the direction in
> which IDLE was going.  The idle-fork SourceForge project was created
> so they could do their development.  But I don't think much happened
> there, and I haven't really done much except stifle IDLE development,
> so I'm ready to relax my control.  I do have that subprocess-running
> code which I would like to get worked into IDLE first though...
> 
> --Guido van Rossum (home page: http://www.python.org/~guido/)
> 
> 

-- 

Dethe Elza 
Chief Mad Scientist
Burning Tiger Technologies




From DavidCraig@PIA.CA.GOV  Wed Jun 20 21:45:38 2001
From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV)
Date: Wed, 20 Jun 2001 13:45:38 -0700
Subject: [Tutor] Can't find my syntax error
Message-ID: <OF8EAF5736.A9C9C0AD-ON88256A71.007168BD@PIA.CA.GOV>

I have been working my way through the examples on "How to Think Like A
Computer Scientist (Python)".  I can't seem to find my error.  Help
Please!! I'm sure its simple, I just can't see it.  Thanks!

Dave


##PrintMultiplicationTable function with new parameter

def printMultiples(n, high):
    int i = 1
        while i <= high:
            print n*i,   '\t',
            i = i + 1
        print

def printMultTable(high):
    int i = 1
        while i <= high:
            printMultiples(i, high)
            i = i + 1

And gets me the following:

Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>>
  File "C:/Python21/Practice/printMultiplesn.py", line 4
    int i = 1
        ^
SyntaxError: invalid syntax


D. H. Craig, CSM




From israel@lith.com  Wed Jun 20 21:51:51 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 20 Jun 2001 13:51:51 -0700
Subject: [Tutor] Can't find my syntax error
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144DC@mailcluster.lith.com>

I'm kind of new to this but I think that you are declaring a type for i
which isn't nesecary in Python.  In a sense, you've declared two variables
here.  One name int and one name i.

Take out the int and see what happens

-----Original Message-----
From: DavidCraig@PIA.CA.GOV [mailto:DavidCraig@PIA.CA.GOV]
Sent: Wednesday, June 20, 2001 1:46 PM
To: tutor@python.org
Subject: [Tutor] Can't find my syntax error


I have been working my way through the examples on "How to Think Like A
Computer Scientist (Python)".  I can't seem to find my error.  Help
Please!! I'm sure its simple, I just can't see it.  Thanks!

Dave


##PrintMultiplicationTable function with new parameter

def printMultiples(n, high):
    int i = 1
        while i <= high:
            print n*i,   '\t',
            i = i + 1
        print

def printMultTable(high):
    int i = 1
        while i <= high:
            printMultiples(i, high)
            i = i + 1

And gets me the following:

Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>>
  File "C:/Python21/Practice/printMultiplesn.py", line 4
    int i = 1
        ^
SyntaxError: invalid syntax


D. H. Craig, CSM



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


From nstalkie@tvd.be  Thu Jun 21 22:12:07 2001
From: nstalkie@tvd.be (Sammy Mannaert)
Date: Thu, 21 Jun 2001 23:12:07 +0200
Subject: [Tutor] Can't find my syntax error
References: <OF8EAF5736.A9C9C0AD-ON88256A71.007168BD@PIA.CA.GOV>
Message-ID: <3B326327.78989B45@tvd.be>

DavidCraig@PIA.CA.GOV wrote:
> 
> I have been working my way through the examples on "How to Think Like A
> Computer Scientist (Python)".  I can't seem to find my error.  Help
> Please!! I'm sure its simple, I just can't see it.  Thanks!
> 
> Dave
> 
> ##PrintMultiplicationTable function with new parameter
> 
> def printMultiples(n, high):
>     int i = 1
>         while i <= high:
>             print n*i,   '\t',
>             i = i + 1
>         print

take out 'int'. in python you don't need to declare the
type of a variable. make sure you line up i = 1 with the
while statement.
(like this)
	i = 1
	while i <= high:

sammy

(in python int is a function)


From pobrien@orbtech.com  Wed Jun 20 22:21:11 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 16:21:11 -0500
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-runrequirement
In-Reply-To: <B756531A.CFD%delza@alliances.org>
Message-ID: <NBBBIOJPGKJEKIECEMCBEEBFKBAA.pobrien@orbtech.com>

Tkinter doesn't run on the Mac either, which means IDLE doesn't run on the
Mac (though, as Guido pointed out, there is an alternative). I'm not as
bothered by the fact that Scintilla isn't on the Mac as I am by the fact
that IDLE is intimately tied to Tkinter. Then again, I wonder how easy it
would be to "recreate" the same IDLE functionality with Scintilla. Since
Scintilla does so much cool text handling already, what else would have to
be added and how hard would it be to extract only the remaining pieces out
of IDLE? Wish I knew.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of
Dethe Elza
Sent: Wednesday, June 20, 2001 3:18 PM
To: idle-dev@python.org; Python Edu SIG; Python Tutor
Subject: Re: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's
save-before-runrequirement

on 01/6/20 11:43 AM, Patrick K. O'Brien at pobrien@orbtech.com wrote:

> I agree with that sentiment. While I also use Boa, PythonWin and VPython,
I
> still like IDLE and usually pop it up for interactive use. What I really
> want is the best of them all. I hate to see all these efforts recreating
the
> wheel. Of course, Boa and PythonWin both use Scintilla, although in
slightly
> different fashions.

And as far as I know, Scintilla hasn't been ported to the Mac, and possibly
other python-enabled platforms.

<snip>

--Dethe



From dyoo@hkn.eecs.berkeley.edu  Wed Jun 20 22:24:33 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 20 Jun 2001 14:24:33 -0700 (PDT)
Subject: [Tutor] Can't find my syntax error
In-Reply-To: <OF8EAF5736.A9C9C0AD-ON88256A71.007168BD@PIA.CA.GOV>
Message-ID: <Pine.LNX.4.21.0106201417340.11823-100000@hkn.eecs.berkeley.edu>

On Wed, 20 Jun 2001 DavidCraig@PIA.CA.GOV wrote:

> def printMultiples(n, high):
>     int i = 1

As people have pointed out, you don't need to tell Python that 'i' is an
integer.  Same thing in printMultTable().  In other languages, you might
need to do something like this, but in Python, it's not necessary.

By the way, 'int' itself is a Python function that tries to convert any
value into an integer.  If you're familiar with c-style programming, you
can think of it as a typecasting function:

###
>> int(42)                       ## int to an int doesn't do anything
42
>>> int("42")                    ## string to an int
42
>>> int(42.2)                    ## float to an int
42
>>> int("42.2")
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: invalid literal for int(): 42.2
>>> int(float("42.2"))
42
###

Good luck!



From pobrien@orbtech.com  Wed Jun 20 22:27:21 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 16:27:21 -0500
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's  save-before-run requirement
In-Reply-To: <5.1.0.14.1.20010620125502.00ab55c8@laplaza.org>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEBGKBAA.pobrien@orbtech.com>

If we wrapped the necessary bits around Scintilla it might not be too hard.
At least we'd be starting with a lot of editor functionality - colorizing,
key bindings, code folding, etc. From what I understand Boa and PythonWin
both borrowed from IDLE but used Scintilla. I love Boa but it's design goal
is not the same as IDLE's. I also like PythonWin, but again, different
design goal. So what I would propose is a Scintilla-based (for lack of a
better alternative) IDE that is cross-platform (to the extent possible, but
at least Win and Linux and, hopefully, Mac), interactive, easy, helpful and
part of the standard distribution. I could help manage the process, but I'm
not up to the challenge of doing all the code.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of
Mats Wichmann
Sent: Wednesday, June 20, 2001 1:57 PM
To: pobrien@orbtech.com; idle-dev@python.org; Python Edu SIG; Python Tutor
Subject: RE: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
requirement

 >And it would be
 >nice if these were GUI independent so that we could go from Tkinter to
 >wxWindows, for example, if we wanted to.

I once asked about something like this.  I believe right now
IDLE, at least, is not constructed in such a way that it
would be easy to rip out the Tkinter dependence so it could
be changed to something else, either permanently or for
plug-replacable graphics toolkits.

I wonder how much work that really would be, and if anybody
has any interest in it.  Not sure if there's really enough
value to be gained to make it worthwhile.

Mats


_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig



From DavidCraig@PIA.CA.GOV  Wed Jun 20 22:35:08 2001
From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV)
Date: Wed, 20 Jun 2001 14:35:08 -0700
Subject: [Tutor] Can't find my syntax error
Message-ID: <OF1719EB30.915A11E5-ON88256A71.0075E923@PIA.CA.GOV>

Thanks Israel and all.  I forgot that I didn't have to declare a type.
Interestingly enough, they do that often in the tutorial ("How to Think
Like A Computer Scientist (Python)").

Thanks to all it works now.  :))



D. H. Craig, CSM




From pobrien@orbtech.com  Wed Jun 20 22:34:57 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 16:34:57 -0500
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE "deemphasised"? Please not so...
In-Reply-To: <B7565384.CFE%delza@alliances.org>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEBHKBAA.pobrien@orbtech.com>

Except that the VPython folks have a design goal that is quite tangential to
IDLE's. They need a tool to support their visual python modules (which allow
the manipulation of 3D objects and should not to be confused with
ActiveState's IDE) and the teaching of physics. While I do think their needs
should be accomodated, I don't know that they would want to be responsible
for IDLE development as a whole. (But I could be wrong.)

I've added them to the recipients of this message. We'll see if they
respond. (The vpython list has been quiet lately.)
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Dethe Elza
Sent: Wednesday, June 20, 2001 3:20 PM
To: IDLE Developers List
Cc: Python Edu SIG; Python Tutor
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE "deemphasised"? Please
not so...

That's great news!  Are the VPython folks listening?

--Dethe

on 01/6/20 11:06 AM, Guido van Rossum at guido@digicool.com wrote:

>> It seems to me that the VPython folk are the perfect ones to pick up the
>> IDLE development reins.  They're actively working on IDLE already, have
>> already implemented the autosave mentioned, as well as some others, and
>> generally seem willing and interested.  I'm not sure what the reasoning
is
>> for keeping the VPython IDLE off in its own fork and not bringing it in
as
>> the official IDLE, since it is being actively developed.
>
> I think it was that I wanted to keep control over the direction in
> which IDLE was going.  The idle-fork SourceForge project was created
> so they could do their development.  But I don't think much happened
> there, and I haven't really done much except stifle IDLE development,
> so I'm ready to relax my control.  I do have that subprocess-running
> code which I would like to get worked into IDLE first though...
>
> --Guido van Rossum (home page: http://www.python.org/~guido/)
>
>

--

Dethe Elza
Chief Mad Scientist
Burning Tiger Technologies



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From guido@digicool.com  Wed Jun 20 22:44:17 2001
From: guido@digicool.com (Guido van Rossum)
Date: Wed, 20 Jun 2001 17:44:17 -0400
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: Your message of "Wed, 20 Jun 2001 16:27:21 CDT."
 <NBBBIOJPGKJEKIECEMCBAEBGKBAA.pobrien@orbtech.com>
References: <NBBBIOJPGKJEKIECEMCBAEBGKBAA.pobrien@orbtech.com>
Message-ID: <200106202144.f5KLiHa02304@odiug.digicool.com>

> So what I would propose is a Scintilla-based (for lack of a
> better alternative) IDE that is cross-platform (to the extent possible, but
> at least Win and Linux and, hopefully, Mac), interactive, easy, helpful and
> part of the standard distribution. I could help manage the process, but I'm
> not up to the challenge of doing all the code.

IDLE has most of the functionality (not code folding).

Why start over when there's probably a person-year of work in IDLE?

--Guido van Rossum (home page: http://www.python.org/~guido/)


From israel@lith.com  Wed Jun 20 22:49:07 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 20 Jun 2001 14:49:07 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r
 equirement
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144DE@mailcluster.lith.com>

What would switching over to using Scintilla accomplish that sticking with
IDLE and continuing it's development wouldn't?


-----Original Message-----
From: Guido van Rossum [mailto:guido@digicool.com]
Sent: Wednesday, June 20, 2001 2:44 PM
To: pobrien@orbtech.com
Cc: Mats Wichmann; idle-dev@python.org; Python Edu SIG; Python Tutor
Subject: Re: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
requirement


> So what I would propose is a Scintilla-based (for lack of a
> better alternative) IDE that is cross-platform (to the extent possible,
but
> at least Win and Linux and, hopefully, Mac), interactive, easy, helpful
and
> part of the standard distribution. I could help manage the process, but
I'm
> not up to the challenge of doing all the code.

IDLE has most of the functionality (not code folding).

Why start over when there's probably a person-year of work in IDLE?

--Guido van Rossum (home page: http://www.python.org/~guido/)

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


From allan.crooks@btinternet.com  Wed Jun 20 23:21:14 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Wed, 20 Jun 2001 23:21:14 +0100
Subject: [Tutor] Killing threads
Message-ID: <E15CqQf-0003xE-00@rhenium>

Hi,

Here we go with a solution. :)

# Your code
def main():
    a = Account()
    a.arp = [300]
    a.threads = []
    t = threading.Thread(target = a.checker, args = (a.arp))
    a.threads.append(t)
    u = threading.Thread(target = a.menu, args = ())
    a.threads.append(u)
    a.nthreads = range(len(a.threads))
    for i in a.nthreads:
        a.threads[i].start()
    for i in a.nthreads:
        a.threads[i].join()
        
Given that we don't have the Account class at hand, it's somewhat more problematic to show you a corrected version specifically for your code.

Note that I said it was "problematic", not "impossible". :)

First of all though, I'll point out a few things in your code.

#    t = threading.Thread(target = a.checker, args = (a.arp))

You may or may not intend this, it's hard to say, but if you want to supply a tuple with "a.arp" as an argument, you can put:
  args = (a.arp,)
  
Otherwise Python doesn't realise you mean a tuple. For any variable value x, (x) is the same as x.



Secondly, the for loops can be written like this:

    for x in a.threads:
       x.start()
       
It's a lot easier to read (and is one of the reasons I prefer Python over Java! :)

Now back to your question, how to stop threads.

Python doesn't provide a way to stop threads. The "threading" module is made to resemble Java's Thread objects, which supports the "stopping" of threads. But Python doesn't support it (for good reasons), so we have to simulate it ourselves.

There are two ways of doing this:
  1) Extending Thread objects.
  2) Using Condition objects.
  
Since I can only be bothered to write one solution, I'll go for the second one. :)

A condition object is a type of lock, which allows threads to use it as a signalling area. An appalling description, but it's the best I can come up with.

> One of the threads, u, is active and provides a (so far) basic interface for
> the user through the menu method of the class account.  The second, t, is
> generally dormant, but pops up once in a while to check a single flag, then
> falls back to sleep.  I need for the active, u, thread to be able to kill
> both threads by calling another function quitter().

Both threads will need to use the Condition object to stop themselves.

So let us assume that in the Account object, you have a field, "cond", which is the Condition object. We'll also have another field which indicates we want threads to stop.

# a.cond = Condition()
# a.halt = 0

The menu function needs to stop both threads. The checker function needs to be able to be told to stop.

So first, I'll write the checker function.

def checker(self):
   while not self.halt:
      # check flag, perhaps exit or do whatever
      self.cond.acquire()
      if not self.halt:
          self.cond.wait(x) # x is some value of seconds
      self.cond.release()
         
There are several different ways of writing this code (I've written at least 4 different versions), but I'll settle on this one. It may look odd that we're seeing if self.halt is tested twice, but hopefully it should make sense.

First of all, the checker function will run until it has been told to stop.

It performs the check it is intended to do. It then "acquires" the condition object, which means that there is no way somebody can be running code in another thread that has "acquired" the condition object.

If you've ever written threading code in java, the acquire / release methods are similar to the synchronized keyword. If you haven't, then it doesn't matter.

The reason we acquire the condition object, is because we need to be able to "wait" on it. You mentioned the checking thread sleeps. However, for the other thread to stop the checking thread, we need to tell the checking thread to stop.



It still may not be clear what the condition object does, or why we use it. What it does will be explained a bit later, but I'll explain why we use it.

As you can see, we are using a flag (halt) to tell the thread to stop. And there are two ways of doing this without condition objects.

The first is written like this:

def checker(self):
   while not self.halt:
      # check flag, perhaps exit or do whatever

Much simpler I'm sure you'll agree. The only problem is that the thread doesn't check "every now and then", but all the time. You could adjust the code to figure out how much time has elapsed since the last check and then execute it if a certain amount of time has elapsed. But that still doesn't do what you want, the thread is continously running the loop and using lots of processor time, even though it's just waiting for a certain amount of time to elapse. Which is a bad thing.



So to combat this, we should make the thread sleep. We can use the sleep function in the time module to pause.

Here's the second version:

def checker(self):
   while not self.halt:
      # check flag, perhaps exit or do whatever
      time.sleep(x) # x is however long you want it sleep for
      
However, say the thread starts to sleep 20 secs, and as soon as it starts sleeping, the other function tells it to stop. But the checker thread won't respond until it's woken up.

So we need a way for the thread to sleep, but to wake up if it's being told something.


Solution? Condition objects. :)


Back to the code I wrote:

def checker(self):
   while not self.halt:
      # check flag, perhaps exit or do whatever
      self.cond.acquire()
      if not self.halt:
          self.cond.wait(x) # x is some value of seconds
      self.cond.release()
      

So hopefully it should be clearer *why* we are using Condition objects. The other thread can wake the checker thread up, even if it was sleeping.

The wait method makes the thread sleep until someone wakes it up. We can either write:
   self.cond.wait() # or
   self.cond.wait(x)
   
The first wait will simply wait for eternity until it is woken up by another thread. But since we still want to wake up every now and then and check whatever flag we're checking, we write the second version. This means that by the time that line of code has been executed, it has either been woken up by another thread, or it has slept for x seconds without being woken up by the other thread.


Why the two checks of self.wait? Well, that's quite simple. Here's how it would look otherwise:

def checker(self):
   while not self.halt:
      # check flag, perhaps exit or do whatever
      self.cond.acquire()
      self.cond.wait(x) # x is some value of seconds
      self.cond.release()
      
      
This looks OK, but during the time we have been checking flags, we have been told to halt. But it would still go to sleep.

We could make the while loop an infinite loop, but it makes this:

def checker(self):
   while 1:
      # check flag, perhaps exit or do whatever
      self.cond.acquire()
      if not self.halt:
          self.cond.wait(x) # x is some value of seconds
          self.cond.release()
      else:
          self.cond.release()
          break
          
We still need to release the condition object even if we quit the loop. This should work, it's just the other version looks nicer.


OK, hopefully that's clear. Now we come to define the menu function.

def menu(self, *whatever_args_you_want):
   # do menu stuff
   # this bit afterwards is to stop other threads
   self.cond.acquire()
   self.halt = 1
   self.cond.notifyAll()
   self.cond.release()
   
This should be fairly straight forward to understand. The "notifyAll" method will simply wake up all threads which are sleeping (waiting on the condition object). You also have the "notify" method, which will wake up only one thread. It doesn't matter which one you do in this example.

I think that should work, I've got no code to test it on and no patience to write one myself.

If you were to have more than two threads, would this approach still work? It should do. All functions which do anything will have to look like checker (so they can respond to exits).


I'm ever so slightly dubious about what I've written, I presumed I would've written more, but I haven't. If this doesn't work, let us know.

Allan.



From pobrien@orbtech.com  Wed Jun 20 23:36:00 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 17:36:00 -0500
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: <200106202144.f5KLiHa02304@odiug.digicool.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBKEBKKBAA.pobrien@orbtech.com>

Maybe it's a really bad idea. My thinking went along these lines - Scintilla
seems to be getting a lot of support and other tools (Boa and PythonWin) are
using it. Those developers must have thought there was a compelling reason
to do so. If we went with Scintilla, that eliminates the whole text editing
burden and allows the tool to benefit from enhancements to Scintilla that
seem to be coming out at a nice pace. With that eliminated we could
concentrate on extracting the other good bits from IDLE and separating them
from the GUI so that one or more GUI toolkits could be used in addition to
Tkinter. Please understand that I'm just exploring an idea and meant no
disrespect. I can appreciate the effort that has gone into IDLE. Maybe my
suggestion is the wrong way to go about allowing IDLE development to
continue and to accommodate a variety of needs.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Guido van Rossum
Sent: Wednesday, June 20, 2001 4:44 PM
To: pobrien@orbtech.com
Cc: Mats Wichmann; idle-dev@python.org; Python Edu SIG; Python Tutor
Subject: Re: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
requirement

> So what I would propose is a Scintilla-based (for lack of a
> better alternative) IDE that is cross-platform (to the extent possible,
but
> at least Win and Linux and, hopefully, Mac), interactive, easy, helpful
and
> part of the standard distribution. I could help manage the process, but
I'm
> not up to the challenge of doing all the code.

IDLE has most of the functionality (not code folding).

Why start over when there's probably a person-year of work in IDLE?

--Guido van Rossum (home page: http://www.python.org/~guido/)

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From pobrien@orbtech.com  Wed Jun 20 23:58:03 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 17:58:03 -0500
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144DE@mailcluster.lith.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBGEBMKBAA.pobrien@orbtech.com>

I'm not 100% sure. I just have the impression that IDLE is too closely tied
to Tkinter, that Guido doesn't have as much time to devote to IDLE, that
Scintilla might remove part of the burden, and that Scintilla has been used
successfully by other tools, namely Boa and PythonWin. I just see a lot of
duplication of effort with basic editing/interactive functionality that
strikes me as a waste of resources. Here are the tools that I use that all
have separate code bases though they all borrowed from IDLE. (I don't really
want to use this many, but I have to for various reasons.)

IDLE
Boa Constructor
VPython (Visual Python)
PythonWin

Each of these is annoyingly different in rudimentary ways. For example, each
of these has separate keybindings and separate ways of modifying
keybindings. They don't all support the same command line options. They
don't all honor startup scripts. Not all python programs will run
successfully in all of these IDEs. Not all of these IDEs will run on all of
the platforms that Python itself will run on. Etc., etc.

There are just too darn many unnecessary variations, imho. I have spent way
too much time trying to get a productive environment in each of these tools
and getting them to all honor keystrokes and startup scripts that I find
useful.

To me it would be ideal if there were one or more core modules that
supported the editing of python files and interactive sessions. Each tool
would build on these modules for their own design goals, but the basics
would be there for everyone. The fact that all these tools have forked from
IDLE or borrowed heavily from IDLE suggests that there was something missing
or inadequate in the opinions of these other IDE developers. I'm trying to
understand what that missing element was and see if we can establish some
basic functionality, some architecture, rather than perpetuate this
diversity. I like Python because it has one right way for everything ...
except writing and running the actual code.

All I am asking is how do we apply the "one right way" attitude to the IDE
situation?

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Israel Evans
Sent: Wednesday, June 20, 2001 4:49 PM
To: 'Guido van Rossum'; pobrien@orbtech.com
Cc: Mats Wichmann; idle-dev@python.org; Python Edu SIG; Python Tutor
Subject: RE: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
requirement

What would switching over to using Scintilla accomplish that sticking with
IDLE and continuing it's development wouldn't?



From delza@alliances.org  Thu Jun 21 00:13:59 2001
From: delza@alliances.org (Dethe Elza)
Date: Wed, 20 Jun 2001 16:13:59 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run
 requirement
In-Reply-To: <NBBBIOJPGKJEKIECEMCBGEBMKBAA.pobrien@orbtech.com>
Message-ID: <B7567C47.D25%delza@alliances.org>

on 01/6/20 03:58 PM, Patrick K. O'Brien at pobrien@orbtech.com wrote:

> All I am asking is how do we apply the "one right way" attitude to the IDE
> situation?

I don't have an answer, but it's a damn good question.

-- 

Dethe Elza 
Chief Mad Scientist
Burning Tiger Technologies




From bas@andrew.cmu.edu  Thu Jun 21 00:29:59 2001
From: bas@andrew.cmu.edu (Bruce Sherwood)
Date: Wed, 20 Jun 2001 19:29:59 -0400
Subject: [Visualpython-users] RE: [Tutor] Re: [Edu-sig] RE: [Idle-dev]
 IDLE "deemphasised"? Please not so...
In-Reply-To: <NBBBIOJPGKJEKIECEMCBAEBHKBAA.pobrien@orbtech.com>
Message-ID: <927954124.993065399@HYPERON.REM.CMU.EDU>

Concerning VPython and IDLE:

At the same time that he created the Visual module, which provides 
remarkably easy 3D animated graphics for Python (Visual + Python = 
VPython), David Scherer made major changes to IDLE, including:

   executes scripts in a separate process for stability
   excludes system modules from tracebacks
   usability changes, including reorganized menus
   autosave on every run, with infinite un-do
   scrolling output has a header marking the start of each run

This has turned out to be an ideal environment for novices (as measured by 
use by a large number of physics students), and is also an excellent rapid 
edit-run environment for experts.

Alas, there is no active work on this at present, because Scherer is not 
currently in a situation where he can spend time on this, and we have no 
one else in the project currently capable of pushing this forward.

It is certainly the case that Scherer's version of IDLE is an exceptionally 
promising candidate to become the "official" IDLE, but unfortunately we are 
not able to lead the charge right now.

Bruce Sherwood

P.S. We have just released VPython for Python 2.1 on Windows:

   http://cil.andrew.cmu.edu/projects/visual

This new release installs Scherer's IDLE in Tools/idle_VPython, leaving the 
standard IDLE in place. Desktop and start-menu icons are added that access 
the VPython version of IDLE.



From rear@sirius.com  Thu Jun 21 01:53:27 2001
From: rear@sirius.com (Bob Rea)
Date: Wed, 20 Jun 2001 17:53:27 -0700
Subject: [Tutor] raw_input
In-Reply-To: <006601c0f9b5$a7d7abe0$010044c0@hal9000>
References: <006601c0f9b5$a7d7abe0$010044c0@hal9000>
Message-ID: <0106201753270F.01232@gandalf>

On Wednesday 20 June 2001 11:20 am, you wrote:

> > >>> raw_input ("Enter your name:")
>
> Enter your name:Brendhan
> 'Brendhan'
>
> >>> print name
>
> Traceback (innermost last):
>   File "<pyshell#7>", line 1, in ?
>     print name
> NameError: There is no variable named 'name'


You need to assign the raw_input to a variable
name = raw_input ("Enter your name:")
etc

-- 
Bob Rea

	Fear of Hell is pernicious;
                So is fear of Heaven.

rear@sirius.com   http://www.sirius.com/~rear


From kevino@tulane.edu  Thu Jun 21 01:48:36 2001
From: kevino@tulane.edu (Kevin Ollivier)
Date: Wed, 20 Jun 2001 20:48:36 -0400
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-runrequirement
References: <B7567C47.D25%delza@alliances.org>
Message-ID: <006e01c0f9eb$e7b985e0$6401a8c0@cox.rr.com>

Hi everyone,

I agree that it is a (ahem!) darn good question. =) And the issue Patrick
brought up about the many IDE projects "re-inventing the wheel" is a great
one as well. One trend I see with open source development is that there are
generally many projects being built to solve the same problem, but doing so
in slightly different ways. So there is no doubt that there is a lot of
'duplicate' code being written out there, and I feel the various IDE
developers out there should really work out some common standards. Of course
the issue with open source projects at least is that most of them are built
"to scratch an itch", so to speak, so the programmer is focused on meeting
his/her needs and issues like compatibility are not often addressed.

With regards to IDLE, if I may make a suggestion, I think before we decide
on how IDLE is to get where it is going, we should first decide on where it
is going. What features should IDLE have? What is the "vision" for IDLE?
Will it become a power-IDE with features galore attempting to replace the
IDEs out there, or stay clean and simple, like Python itself? Should it be
Win/Mac/Linux compatible in one package, or is it OK that the Mac
implementation is different? And to pose a question that was brought up on
the Edu-sig list last weekend: Should there be "teaching" features built
into IDLE to help beginners learn the language? (i.e. IDLE, in "training
mode", would pose programming problems and point out mistakes) More
importantly, who's going do do all this work?? =)

As a stray thought, how easy would it be to have some of these features
added "dynamically"? In other words, make features like the color coding and
code-folding, or even interactive training, into modules that could be
imported by the user. That sort of thing. I think Patrick touched upon this
in his earlier message. How much work would this be? Or has this sort of
thing already been done?

My two cents? I think it would be really cool to advance IDLE to have a
built-in "training mode" so that everything you need to get up and running
with Python comes "in the box". In a way, the CP4E and IDLE projects could
become one and the same! (OK, so maybe this is just a dream, but it's a nice
one!) Making a Win/Mac/Linux version seems like a good idea, but I think it
depends on how much work it is, or realistically how much work will be put
into future versions. The features of the editor itself don't seem to bad
too me personally. After playing with a lot of "full-featured" IDEs, I
settled with a text editor. (Embarrassingly enough, I did not realize that
IDLE was also a script editor - I thought it was only a interpreter!) I
found the other IDEs to be big and bulky, and the bigger they were, the more
bugs and stability problems they had. Of course, I'm on Windows too, so
there are other factors there... =)

What do others think? I hope I've not gotten on a soapbox and babbled here.
I do have a tendency to do that on occasion... <AHEM!> I'm actually new to
all this open-source, mailing list stuff so if I'm breaking etiquette rules
or something feel free to tell me! ^_^;

Thanks for listening!

Kevin Ollivier

----- Original Message -----
From: "Dethe Elza" <delza@alliances.org>
To: <idle-dev@python.org>; "Python Edu SIG" <Edu-sig@python.org>; "Python
Tutor" <tutor@python.org>
Sent: Wednesday, June 20, 2001 7:13 PM
Subject: Re: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's
save-before-runrequirement


> on 01/6/20 03:58 PM, Patrick K. O'Brien at pobrien@orbtech.com wrote:
>
> > All I am asking is how do we apply the "one right way" attitude to the
IDE
> > situation?
>
> I don't have an answer, but it's a damn good question.
>
> --
>
> Dethe Elza
> Chief Mad Scientist
> Burning Tiger Technologies
>
>
>
> _______________________________________________
> Edu-sig mailing list
> Edu-sig@python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>



From brendhanhorne@hotmail.com  Thu Jun 21 02:47:27 2001
From: brendhanhorne@hotmail.com (Brendhan Horne)
Date: Wed, 20 Jun 2001 21:47:27 -0400
Subject: [Tutor] Calculator functions
Message-ID: <OE55RcRKsAbiJhrIbxV00000010@hotmail.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0012_01C0F9D2.98EEA940
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have been reading the non programmers guide and it has been helpful =
but I think a point is just over my head. Here is what I am looking for:
Things in Parenthesis are my notes on what I want to happen.



First Number:    ( You than enter a single digit number from 0-9 )
Second Number:   ( You than enter a single digit number from 0-9 )
Answer:                  ( The  Product of First Number multiplied by =
Second Number )




I am thinking:
a =3D raw_input ("First Number:")
b =3D raw_input ("Second Number:")
a*b =3D raw_input ("Answer:")
but my thinking is not quite there a little help if you could. Thanks in =
advance.
Thanks,
Brendhan
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
D G(++) e+(++) h-- r++ y++*
------END GEEK CODE BLOCK------

------=_NextPart_000_0012_01C0F9D2.98EEA940
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 size=3D2>I have been reading the non programmers guide and it =
has been=20
helpful but I think a point is just over my head. Here is what I am =
looking=20
for:</FONT></DIV>
<DIV><FONT size=3D2>Things in Parenthesis are my notes on what I want to =

happen.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>First Number:&nbsp;&nbsp;&nbsp; ( You than enter a =
single=20
digit number from 0-9 )</FONT></DIV>
<DIV><FONT size=3D2>Second Number:&nbsp;&nbsp; ( You than enter a single =
digit=20
number from 0-9 )</FONT></DIV>
<DIV><FONT=20
size=3D2>Answer:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
( The&nbsp; Product of First Number multiplied by Second Number =
)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>I am thinking:</FONT></DIV>
<DIV><FONT size=3D2>a =3D raw_input ("First Number:")</FONT></DIV>
<DIV><FONT size=3D2>b =3D raw_input ("Second Number:")</FONT></DIV>
<DIV><FONT size=3D2>a*b =3D raw_input ("Answer:")</FONT></DIV>
<DIV><FONT size=3D2>but my thinking is not quite there a little help if =
you could.=20
Thanks in advance.</FONT></DIV>
<DIV><FONT size=3D2>Thanks,<BR>Brendhan<BR>-----BEGIN GEEK CODE=20
BLOCK-----<BR>Version: 3.1<BR>GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ =
o+ K-=20
w+<BR>O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++<BR>D G(++) =
e+(++) h--=20
r++ y++*<BR>------END GEEK CODE BLOCK------</FONT></DIV></BODY></HTML>

------=_NextPart_000_0012_01C0F9D2.98EEA940--


From pobrien@orbtech.com  Thu Jun 21 02:49:46 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 20 Jun 2001 20:49:46 -0500
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-runrequirement
In-Reply-To: <006e01c0f9eb$e7b985e0$6401a8c0@cox.rr.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBKECBKBAA.pobrien@orbtech.com>

Well said. I agree with all your suggestions and opinions, especially on
getting agreement on where we are going. I probably jumped the gun a bit by
suggesting a direction that might not be where everyone else wants to go.
Your take on the situation is much appreciated.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: idle-dev-admin@python.org [mailto:idle-dev-admin@python.org]On Behalf
Of Kevin Ollivier
Sent: Wednesday, June 20, 2001 7:49 PM
To: idle-dev@python.org; Python Edu SIG; Python Tutor
Subject: Re: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's
save-before-runrequirement

Hi everyone,

I agree that it is a (ahem!) darn good question. =) And the issue Patrick
brought up about the many IDE projects "re-inventing the wheel" is a great
one as well. One trend I see with open source development is that there are
generally many projects being built to solve the same problem, but doing so
in slightly different ways. So there is no doubt that there is a lot of
'duplicate' code being written out there, and I feel the various IDE
developers out there should really work out some common standards. Of course
the issue with open source projects at least is that most of them are built
"to scratch an itch", so to speak, so the programmer is focused on meeting
his/her needs and issues like compatibility are not often addressed.

With regards to IDLE, if I may make a suggestion, I think before we decide
on how IDLE is to get where it is going, we should first decide on where it
is going. What features should IDLE have? What is the "vision" for IDLE?
Will it become a power-IDE with features galore attempting to replace the
IDEs out there, or stay clean and simple, like Python itself? Should it be
Win/Mac/Linux compatible in one package, or is it OK that the Mac
implementation is different? And to pose a question that was brought up on
the Edu-sig list last weekend: Should there be "teaching" features built
into IDLE to help beginners learn the language? (i.e. IDLE, in "training
mode", would pose programming problems and point out mistakes) More
importantly, who's going do do all this work?? =)

As a stray thought, how easy would it be to have some of these features
added "dynamically"? In other words, make features like the color coding and
code-folding, or even interactive training, into modules that could be
imported by the user. That sort of thing. I think Patrick touched upon this
in his earlier message. How much work would this be? Or has this sort of
thing already been done?

My two cents? I think it would be really cool to advance IDLE to have a
built-in "training mode" so that everything you need to get up and running
with Python comes "in the box". In a way, the CP4E and IDLE projects could
become one and the same! (OK, so maybe this is just a dream, but it's a nice
one!) Making a Win/Mac/Linux version seems like a good idea, but I think it
depends on how much work it is, or realistically how much work will be put
into future versions. The features of the editor itself don't seem to bad
too me personally. After playing with a lot of "full-featured" IDEs, I
settled with a text editor. (Embarrassingly enough, I did not realize that
IDLE was also a script editor - I thought it was only a interpreter!) I
found the other IDEs to be big and bulky, and the bigger they were, the more
bugs and stability problems they had. Of course, I'm on Windows too, so
there are other factors there... =)

What do others think? I hope I've not gotten on a soapbox and babbled here.
I do have a tendency to do that on occasion... <AHEM!> I'm actually new to
all this open-source, mailing list stuff so if I'm breaking etiquette rules
or something feel free to tell me! ^_^;

Thanks for listening!

Kevin Ollivier




From brendhanhorne@hotmail.com  Thu Jun 21 03:46:21 2001
From: brendhanhorne@hotmail.com (Brendhan Horne)
Date: Wed, 20 Jun 2001 22:46:21 -0400
Subject: [Tutor] Calculator functions part II
Message-ID: <OE5279HrDPPkbKyND5N0000ecbd@hotmail.com>

This is a multi-part message in MIME format.

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

I got this response:
Close, but in most programming languages, the operations go on the right
and the result goes on the left.  That means you want

ans =3D a * b

Then all you need to do is print it, like this:

print 'Answer: ' , ans

So I now have this:
#Calculator functions
a =3D raw_input ("First Number:")
b =3D raw_input ("Second Number:")
ans =3D a*b
print 'Answer:', ans

I end up with this:
First Number:8   ( I typed in the 8 )
Second Number:7 ( Ityped in the 7)
Traceback (innermost last):
  File "C:\Python20\prog1.py", line 4, in ?
    ans =3D a*b
TypeError: can't multiply sequence with non-int
So I am definitly getting warmer just not quite. should I change line =
placement?
Thanks,
Brendhan
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
D G(++) e+(++) h-- r++ y++*
------END GEEK CODE BLOCK------


------=_NextPart_000_003D_01C0F9DA.D3888460
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 size=3D2>I got this response:</FONT></DIV>
<DIV><FONT size=3D2>Close, but in most programming languages, the =
operations go on=20
the right<BR>and the result goes on the left.&nbsp; That means you=20
want<BR><BR>ans =3D a * b<BR><BR>Then all you need to do is print it, =
like=20
this:<BR><BR>print 'Answer: ' , ans<BR><BR>So I now have =
this:</FONT></DIV>
<DIV><FONT size=3D2>#Calculator functions<BR>a =3D raw_input ("First =
Number:")<BR>b=20
=3D raw_input ("Second Number:")<BR>ans =3D a*b<BR>print 'Answer:',=20
ans<BR></FONT></DIV>
<DIV><FONT size=3D2>I end up with this:</FONT></DIV>
<DIV><FONT size=3D2>First Number:8&nbsp;&nbsp; ( I typed in the 8 =
)<BR>Second=20
Number:7 ( Ityped in the 7)<BR>Traceback (innermost last):<BR>&nbsp; =
File=20
"C:\Python20\prog1.py", line 4, in ?<BR>&nbsp;&nbsp;&nbsp; ans =3D=20
a*b<BR>TypeError: can't multiply sequence with non-int</FONT></DIV>
<DIV><FONT size=3D2>So I am definitly getting warmer just not quite. =
should I=20
change line placement?</FONT></DIV>
<DIV><FONT size=3D2>Thanks,<BR>Brendhan<BR>-----BEGIN GEEK CODE=20
BLOCK-----<BR>Version: 3.1<BR>GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ =
o+ K-=20
w+<BR>O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++<BR>D G(++) =
e+(++) h--=20
r++ y++*<BR>------END GEEK CODE =
BLOCK------<BR></DIV></FONT></BODY></HTML>

------=_NextPart_000_003D_01C0F9DA.D3888460--


From joejava@dragoncat.net  Thu Jun 21 04:00:01 2001
From: joejava@dragoncat.net (Joel Ricker)
Date: Wed, 20 Jun 2001 23:00:01 -0400
Subject: [Tutor] Python and web scripting
References: <01061820143700.02862@orion.andromeda> <3B2F5AF8.CF125658@bic.ch>
Message-ID: <001901c0f9fe$43db9f90$6ea1d6d1@joeltklrijxxms>

From: "Flynt" <rhess@bic.ch>
> which might be quicker in the first place to implement but gives not as
> much back, when you are going to more involved problems. And, in IMO,
> PHP is *web only*, whereas with Python you can work in just all areas.

But for those of us who don't have control over their servers and can use
Zope, you can do what I've been doing is using PHP for all web applications
which does have a fast creation time and shell out to Python to do complex
tasks.  The two make for a good web development pair.

Joel





From pdx4d@teleport.com  Thu Jun 21 04:03:10 2001
From: pdx4d@teleport.com (Kirby Urner)
Date: Wed, 20 Jun 2001 20:03:10 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: <200106201807.f5KI7dL01340@odiug.digicool.com>
References: <Your message of "Wed, 20 Jun 2001 09:23:44 PDT." <4.2.0.58.20010620092102.00a39f00@pop3.norton.antivirus>
 <Pine.LNX.4.31.0106181704000.12659-100000@emperor.deirdre.org>
 <4.2.0.58.20010620092102.00a39f00@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20010620200128.00948180@pop3.norton.antivirus>

At 02:07 PM 6/20/2001 -0400, Guido van Rossum wrote:

>But MacPython comes with its own IDE, built by Just van Rossum (my
>brother) using the native Mac toolbox.


So I presume MacPython has a shell for interactively importing
modules and using their contents.

Does it auto-color key words in the shell and in the editor
I wonder? ala IDLE in Win/Linux?

The reason I ask is (a) an interactive shell is very
important for learners and (b) iMacs are very popular in
many schools.

Kirby



From ak@silmarill.org  Thu Jun 21 04:03:10 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Wed, 20 Jun 2001 23:03:10 -0400
Subject: [Tutor] **kw and self
In-Reply-To: <"from w.richert"@gmx.net>
References: <01062018185800.09462@charybdis>
Message-ID: <20010620230310.A7838@sill.silmarill.org>

On Wed, Jun 20, 2001 at 06:18:58PM +0200, Willi Richert wrote:
> Hi,
> 
> as a bloody newbie (who as reverted already some others to Python) I walked 
> 34 times through the whole web and did not get the real meaning of **kw and 
> self.
> 
> Any help is very appreciated.
> willi
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

I had some trouble with self also, until I actually used it in a program,
then it all became clear. So, I'll give you an example from the program I'm
working on right now.

    def print_score(self, song):
        song = os.path.basename(song)
        if not self.score_dict.has_key(song):
            self.score_dict[song] = 35
        print 'Score: %d' % (self.score_dict[song])

As you can see, there's 'song' variable here that isn't prefixed by 'self.'
and score_dict variable that is. 

This function is inside a 'Player' class that represents an mp3 player. It has
methods like play() stop() etc. Normally, when any function is called, it
executes and when done, destroys all variables that weren't prefixed by 'self'.
When function I pasted here is called with a song name as its argument, this
name is created (in this example it's passed, but it doesn't necessarily have to, for instance I could have a line at the top saying blah = 1 and then using
that during the function run and after that it'd be gone also). 

But score_dict is different! As you can see just by looking at the function,
it's not assigned to anywhere, it's not passed as an argument to the function.
It's not destroyed when the function ends, of course. It's much more global
than the 'song' variable, which is a one time throw-away just for this function.
score_dict is used all over the class, it's used in play(), it's used in 
print_song_info(), and other places. 'self' means that this variable belongs
to the instance of this class - i.e. I have somewhere a statement
player = Player()
^           ^
instance    class

And after that inside a class I refer to these (i think they're called instance
variables) as self.variable, and outside class I refer to them as
player.variable. I may have many more instances, i.e. player01, player03 etc
and then they can all be individually referred to as player01.variable and
player03.varbiable.

Also, the rule of thumb is that to every method you define in your class, you
should generally pass the first argument called 'self'.

i.e. in my program I may have play(self, song) and stop(self) and so on.

So, in a nutshell, you don't need self. prefix for variables that are
used temporarily in a function and then thrown away. If you need to keep the
variable, you could either return it to the caller using return statement or
use self. prefix. The choice depends on how often the variable is used, if
it's used in many places, self. prefix is preferable.

-- 
Jupiter and Saturn Oberon Miranda
And Titania Neptune Titan
Stars can frighten
        - Syd


From lgwb@home.com  Thu Jun 21 04:07:41 2001
From: lgwb@home.com (Michael Schmitt)
Date: Wed, 20 Jun 2001 22:07:41 -0500
Subject: [Tutor] Calculator functions
References: <OE55RcRKsAbiJhrIbxV00000010@hotmail.com>
Message-ID: <00ef01c0f9ff$5635d880$0a0a0a0a@mntp1.il.home.com>

This is a multi-part message in MIME format.

------=_NextPart_000_00EC_01C0F9D5.6CD4CE90
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I think what you want is:

a =3D raw_input ("First Number:")
b =3D raw_input ("Second Number:")
print "Answer: %d" % (int(a)*int(b))


Michael Schmitt

  ----- Original Message -----=20
  From: Brendhan Horne=20
  To: tutor@python.org=20
  Sent: Wednesday, June 20, 2001 8:47 PM
  Subject: [Tutor] Calculator functions


  I have been reading the non programmers guide and it has been helpful =
but I think a point is just over my head. Here is what I am looking for:
  Things in Parenthesis are my notes on what I want to happen.



  First Number:    ( You than enter a single digit number from 0-9 )
  Second Number:   ( You than enter a single digit number from 0-9 )
  Answer:                  ( The  Product of First Number multiplied by =
Second Number )




  I am thinking:
  a =3D raw_input ("First Number:")
  b =3D raw_input ("Second Number:")
  a*b =3D raw_input ("Answer:")
  but my thinking is not quite there a little help if you could. Thanks =
in advance.
  Thanks,
  Brendhan
  -----BEGIN GEEK CODE BLOCK-----
  Version: 3.1
  GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
  O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
  D G(++) e+(++) h-- r++ y++*
  ------END GEEK CODE BLOCK------

------=_NextPart_000_00EC_01C0F9D5.6CD4CE90
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><FONT size=3D2>I think what you want is:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>a =3D raw_input ("First Number:")<BR>b =3D raw_input =
("Second=20
Number:")<BR>print "Answer: %d" % (int(a)*int(b))</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>Michael Schmitt<BR></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dbrendhanhorne@hotmail.com=20
  href=3D"mailto:brendhanhorne@hotmail.com">Brendhan Horne</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A title=3Dtutor@python.org =

  href=3D"mailto:tutor@python.org">tutor@python.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Wednesday, June 20, 2001 =
8:47=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] Calculator=20
  functions</DIV>
  <DIV><BR></DIV>
  <DIV><FONT size=3D2>I have been reading the non programmers guide and =
it has=20
  been helpful but I think a point is just over my head. Here is what I =
am=20
  looking for:</FONT></DIV>
  <DIV><FONT size=3D2>Things in Parenthesis are my notes on what I want =
to=20
  happen.</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT size=3D2>First Number:&nbsp;&nbsp;&nbsp; ( You than enter a =
single=20
  digit number from 0-9 )</FONT></DIV>
  <DIV><FONT size=3D2>Second Number:&nbsp;&nbsp; ( You than enter a =
single digit=20
  number from 0-9 )</FONT></DIV>
  <DIV><FONT=20
  =
size=3D2>Answer:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  ( The&nbsp; Product of First Number multiplied by Second Number =
)</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT size=3D2>I am thinking:</FONT></DIV>
  <DIV><FONT size=3D2>a =3D raw_input ("First Number:")</FONT></DIV>
  <DIV><FONT size=3D2>b =3D raw_input ("Second Number:")</FONT></DIV>
  <DIV><FONT size=3D2>a*b =3D raw_input ("Answer:")</FONT></DIV>
  <DIV><FONT size=3D2>but my thinking is not quite there a little help =
if you=20
  could. Thanks in advance.</FONT></DIV>
  <DIV><FONT size=3D2>Thanks,<BR>Brendhan<BR>-----BEGIN GEEK CODE=20
  BLOCK-----<BR>Version: 3.1<BR>GE d- s: a C++ U(++) P(++) L+(++) E- W+ =
N+ o+ K-=20
  w+<BR>O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++<BR>D G(++) =
e+(++)=20
  h-- r++ y++*<BR>------END GEEK CODE=20
BLOCK------</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_00EC_01C0F9D5.6CD4CE90--



From lgwb@home.com  Thu Jun 21 04:17:25 2001
From: lgwb@home.com (Michael Schmitt)
Date: Wed, 20 Jun 2001 22:17:25 -0500
Subject: [Tutor] Calculator functions part II
References: <OE5279HrDPPkbKyND5N0000ecbd@hotmail.com>
Message-ID: <00fd01c0fa00$b24ba5e0$0a0a0a0a@mntp1.il.home.com>

This is a multi-part message in MIME format.

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

Well you might try this as well.

a =3D int(raw_input ("First Number:"))
b =3D int(raw_input ("Second Number:"))
print "Answer: %d" % (a*b)

The problem you have below is that you are trying to multiple the two =
inputs which are still string values.

Just to give you an idea of what I mean change it to:
a =3D int(raw_input ("First Number:"))
b =3D raw_input ("Second Number:")
print "Answer: " , (a*b)

Then you will get the following
First Number:5
Second Number:9
Answer:  99999
=20
As string multiplication is done (5  "9" nines are printed)

Michael Schmitt

  ----- Original Message -----=20
  From: Brendhan Horne=20
  To: tutor@python.org=20
  Sent: Wednesday, June 20, 2001 9:46 PM
  Subject: [Tutor] Calculator functions part II


  I got this response:
  Close, but in most programming languages, the operations go on the =
right
  and the result goes on the left.  That means you want

  ans =3D a * b

  Then all you need to do is print it, like this:

  print 'Answer: ' , ans

  So I now have this:
  #Calculator functions
  a =3D raw_input ("First Number:")
  b =3D raw_input ("Second Number:")
  ans =3D a*b
  print 'Answer:', ans

  I end up with this:
  First Number:8   ( I typed in the 8 )
  Second Number:7 ( Ityped in the 7)
  Traceback (innermost last):
    File "C:\Python20\prog1.py", line 4, in ?
      ans =3D a*b
  TypeError: can't multiply sequence with non-int
  So I am definitly getting warmer just not quite. should I change line =
placement?
  Thanks,
  Brendhan
  -----BEGIN GEEK CODE BLOCK-----
  Version: 3.1
  GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
  O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
  D G(++) e+(++) h-- r++ y++*
  ------END GEEK CODE BLOCK------


------=_NextPart_000_00FA_01C0F9D6.C90799D0
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><FONT size=3D2>Well you might try this as well.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>a =3D int(raw_input ("First Number:"))<BR>b =3D =
int(raw_input=20
("Second Number:"))<BR>print "Answer: %d" % (a*b)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The problem you have below is that you are trying to =
multiple=20
the two inputs which are still string values.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Just to give you an idea of what I mean change it=20
to:</FONT></DIV>
<DIV><FONT size=3D2>a =3D int(raw_input ("First Number:"))<BR>b =3D =
raw_input ("Second=20
Number:")<BR>print "Answer: " , (a*b)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Then you will get the following</FONT></DIV>
<DIV><FONT size=3D2>First Number:5<BR>Second Number:9<BR>Answer:&nbsp;=20
99999</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;</FONT></DIV>
<DIV><FONT size=3D2>As string multiplication is done (5&nbsp; "9" nines =
are=20
printed)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>Michael Schmitt<BR></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dbrendhanhorne@hotmail.com=20
  href=3D"mailto:brendhanhorne@hotmail.com">Brendhan Horne</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A title=3Dtutor@python.org =

  href=3D"mailto:tutor@python.org">tutor@python.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Wednesday, June 20, 2001 =
9:46=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] Calculator =
functions=20
  part II</DIV>
  <DIV><BR></DIV>
  <DIV><FONT size=3D2>I got this response:</FONT></DIV>
  <DIV><FONT size=3D2>Close, but in most programming languages, the =
operations go=20
  on the right<BR>and the result goes on the left.&nbsp; That means you=20
  want<BR><BR>ans =3D a * b<BR><BR>Then all you need to do is print it, =
like=20
  this:<BR><BR>print 'Answer: ' , ans<BR><BR>So I now have =
this:</FONT></DIV>
  <DIV><FONT size=3D2>#Calculator functions<BR>a =3D raw_input ("First=20
  Number:")<BR>b =3D raw_input ("Second Number:")<BR>ans =3D =
a*b<BR>print 'Answer:',=20
  ans<BR></FONT></DIV>
  <DIV><FONT size=3D2>I end up with this:</FONT></DIV>
  <DIV><FONT size=3D2>First Number:8&nbsp;&nbsp; ( I typed in the 8 =
)<BR>Second=20
  Number:7 ( Ityped in the 7)<BR>Traceback (innermost last):<BR>&nbsp; =
File=20
  "C:\Python20\prog1.py", line 4, in ?<BR>&nbsp;&nbsp;&nbsp; ans =3D=20
  a*b<BR>TypeError: can't multiply sequence with non-int</FONT></DIV>
  <DIV><FONT size=3D2>So I am definitly getting warmer just not quite. =
should I=20
  change line placement?</FONT></DIV>
  <DIV><FONT size=3D2>Thanks,<BR>Brendhan<BR>-----BEGIN GEEK CODE=20
  BLOCK-----<BR>Version: 3.1<BR>GE d- s: a C++ U(++) P(++) L+(++) E- W+ =
N+ o+ K-=20
  w+<BR>O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++<BR>D G(++) =
e+(++)=20
  h-- r++ y++*<BR>------END GEEK CODE=20
BLOCK------<BR></DIV></BLOCKQUOTE></FONT></BODY></HTML>

------=_NextPart_000_00FA_01C0F9D6.C90799D0--



From ak@silmarill.org  Thu Jun 21 04:22:04 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Wed, 20 Jun 2001 23:22:04 -0400
Subject: [Tutor] Calculator functions part II
In-Reply-To: <"from brendhanhorne"@hotmail.com>
References: <OE5279HrDPPkbKyND5N0000ecbd@hotmail.com>
Message-ID: <20010620232204.B7838@sill.silmarill.org>

On Wed, Jun 20, 2001 at 10:46:21PM -0400, Brendhan Horne wrote:
> I got this response:
> Close, but in most programming languages, the operations go on the right
> and the result goes on the left.  That means you want
> 
> ans = a * b
> 
> Then all you need to do is print it, like this:
> 
> print 'Answer: ' , ans
> 
> So I now have this:
> #Calculator functions
> a = raw_input ("First Number:")
> b = raw_input ("Second Number:")

Now you got 2 strings, a and b. You want them to be integers, however.

> ans = a*b

ans = int(a)*int(b)

> print 'Answer:', ans
> 
> I end up with this:
> First Number:8   ( I typed in the 8 )
> Second Number:7 ( Ityped in the 7)
> Traceback (innermost last):
>   File "C:\Python20\prog1.py", line 4, in ?
>     ans = a*b
> TypeError: can't multiply sequence with non-int

string is a sequence type. you can multiply it by an integer, i.e. 
'ab'*3 is ababab, but '3'*'7' is meaningless. '7'*3 is 777 and what you really
need here is 3*7 (or whatever).

> So I am definitly getting warmer just not quite. should I change line placement?
> Thanks,
> Brendhan
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.1
> GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
> O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
> D G(++) e+(++) h-- r++ y++*
> ------END GEEK CODE BLOCK------
> 

-- 
Jupiter and Saturn Oberon Miranda
And Titania Neptune Titan
Stars can frighten
        - Syd


From pdx4d@teleport.com  Thu Jun 21 04:26:16 2001
From: pdx4d@teleport.com (Kirby Urner)
Date: Wed, 20 Jun 2001 20:26:16 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's
 save-before-runrequirement
In-Reply-To: <006e01c0f9eb$e7b985e0$6401a8c0@cox.rr.com>
References: <B7567C47.D25%delza@alliances.org>
Message-ID: <4.2.0.58.20010620201438.00d1c800@pop3.norton.antivirus>

>
>What do others think? I hope I've not gotten on a soapbox and babbled here.
>I do have a tendency to do that on occasion... <AHEM!> I'm actually new to
>all this open-source, mailing list stuff so if I'm breaking etiquette rules
>or something feel free to tell me! ^_^;
>
>Thanks for listening!
>
>Kevin Ollivier

I've always thought IDLE was 98% of what's needed.  I like these
widgets in other IDEs that prompt you with all the possible
class methods when you go >>> foo. -- but that's a bell I can
live without.

When it comes to teaching in the classroom, I think IDLE is a
fantastic tool -- as is.  Except it doesn't work on the Mac.
But maybe MacPython fills that void (wish wish).

The major shortcoming of IDLE seems to be that it doesn't do
the Tk stuff in a separate thread, so you quit IDLE when you
quit the Tkinter program you're working on.  So maybe that's
what Guido is talking about re running IDLE as a subprocess --
adding that before opening IDLE development to a larger group.

As another poster pointed out, a lot of the GUI-development
seems to be moving towards XML-based descriptions -- much as
HTML is used to spec out interactive forms, only x100 in power.
Perhaps GUI development is too much in flux across the board
to try hammering down some cross-platform "one right way" at
this point.  There will be more shake-outs down the road.

The main thing I like about IDLE is you can import modules in
shell mode and interact with them in a conversational manner.
You can have a lot of persistent handles to your objects, which
you can play with -- literally.

Basically, the user's mind becomes main(), the outer loop, and
you've got persistence for the duration of the session.

This is way different from just using an editor, where you have
to have all your ducks in a row up front, before you commit
the script to the interpreter.

I like the free form scratch pad feel of IDLE work, which makes
it feel a lot like an OS.

I think of the GUIs as various idioms in the toolbox -- like
that Glade stuff for Gnome (with which I have no personal experience
as yet).

Kirby



From pdx4d@teleport.com  Thu Jun 21 04:27:44 2001
From: pdx4d@teleport.com (Kirby Urner)
Date: Wed, 20 Jun 2001 20:27:44 -0700
Subject: [Visualpython-users] RE: [Tutor] Re: [Edu-sig] RE:
 [Idle-dev] IDLE "deemphasised"? Please not so...
In-Reply-To: <927954124.993065399@HYPERON.REM.CMU.EDU>
References: <NBBBIOJPGKJEKIECEMCBAEBHKBAA.pobrien@orbtech.com>
Message-ID: <4.2.0.58.20010620202719.00a6df00@pop3.norton.antivirus>

>
>P.S. We have just released VPython for Python 2.1 on Windows:
>
>   http://cil.andrew.cmu.edu/projects/visual
>
>This new release installs Scherer's IDLE in Tools/idle_VPython, leaving 
>the standard IDLE in place. Desktop and start-menu icons are added that 
>access the VPython version of IDLE.


Excellent!!

I'm gonna grab mine now.

Cheers,

Kirby



From pdx4d@teleport.com  Thu Jun 21 04:36:32 2001
From: pdx4d@teleport.com (Kirby Urner)
Date: Wed, 20 Jun 2001 20:36:32 -0700
Subject: [Visualpython-users] RE: [Tutor] Re: [Edu-sig] RE:
 [Idle-dev] IDLE "deemphasised"? Please not so...
In-Reply-To: <4.2.0.58.20010620202719.00a6df00@pop3.norton.antivirus>
References: <927954124.993065399@HYPERON.REM.CMU.EDU>
 <NBBBIOJPGKJEKIECEMCBAEBHKBAA.pobrien@orbtech.com>
Message-ID: <4.2.0.58.20010620203505.00cffce0@pop3.norton.antivirus>

At 08:27 PM 6/20/2001 -0700, Kirby Urner wrote:


>>P.S. We have just released VPython for Python 2.1 on Windows:
>>
>>   http://cil.andrew.cmu.edu/projects/visual
>>
>>This new release installs Scherer's IDLE in Tools/idle_VPython, leaving 
>>the standard IDLE in place. Desktop and start-menu icons are added that 
>>access the VPython version of IDLE.
>
>
>Excellent!!
>
>I'm gonna grab mine now.
>
>Cheers,
>
>Kirby

Took only seconds to grab and install.  Works like a charm.

Arthur, your PyGeo package is running way smoother now that I
have an official VPython 2.1.   Pascal3d is trouble free -- was
something of a mess earlier.  This is great!

Kirby



From brendhanhorne@hotmail.com  Thu Jun 21 04:38:10 2001
From: brendhanhorne@hotmail.com (Brendhan Horne)
Date: Wed, 20 Jun 2001 23:38:10 -0400
Subject: [Tutor] Calculator function silly questions
Message-ID: <OE32eDeBvLgz60i8juX0000db51@hotmail.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0070_01C0F9E2.10798B60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Wow what a great help you guys have been. Thank You. So as to not bask =
in ignorance. Let me update and ask questions
Michael Schmitt wrote:
I think what you want is:
=20
a =3D raw_input ("First Number:")
b =3D raw_input ("Second Number:")
print "Answer: %d" % (int(a)*int(b))
=20
 That worked really well. My question is What is happening in the third =
line? Can I expand on that and say add
c =3D raw_input ("Third Number:")
and then change the way final line works?

Nate Custer wrote:
I believe raw_input() returns all answers as strings. You need to =
convert your input into a number. I believe you need the line =
string.atio(x). BTW you must import the string module (import string) =
for this to work.

What exactly is importing a string is this something I have to add to =
Python. Please try not to laugh to hard when you answer that. I thought =
Strings input returned a number but I am really not sure of that.

Seabrook wrote:
Oops -- sorry!  I forgot that raw_input() returns a string type -- that
means that the '7' is not stored in memory as binary 00000111 but =
instead
as the ASCII character '7', which I'm guessing is 37hex or 00110111 --
don't remember...
Anyway, convert 'em to integers like this

ans =3D int(a) * int(b)

Okay I tried this:
#Calculator functions
a =3D raw_input ("First Number:")
b =3D raw_input ("Second Number:")
ans =3D int(a)* int(b)
It will let me enter the two numbers but gives no total. I am also =
beginning to think that there may be more than one way to write this =
program. Which is cool the more I can learn about this the more I will =
understand what the different functions do. So I think I was initially =
heading the right way.=20

Again thank you all for guiding me the right way. Ignorant but looking =
to change.:-)
Thanks,
Brendhan
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
D G(++) e+(++) h-- r++ y++*
------END GEEK CODE BLOCK------


------=_NextPart_000_0070_01C0F9E2.10798B60
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 size=3D2>Wow what a great help you guys have been. Thank You. =
So as to=20
not bask in ignorance. Let me update and ask questions</FONT></DIV>
<DIV><FONT size=3D2>Michael Schmitt wrote:</FONT></DIV>
<DIV><FONT size=3D2>
<DIV><EM><FONT size=3D2>I think what you want is:</FONT></EM></DIV>
<DIV><FONT size=3D2></FONT><EM>&nbsp;</EM></DIV>
<DIV><EM><FONT size=3D2>a =3D raw_input ("First Number:")<BR>b =3D =
raw_input ("Second=20
Number:")<BR>print "Answer: %d" % (int(a)*int(b))</FONT></EM></DIV>
<DIV><FONT size=3D2></FONT><EM>&nbsp;</EM></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;That worked really well. My question is =
What is=20
happening in the third line? Can I expand on that and say add</DIV>
<DIV>c =3D raw_input ("Third Number:")</DIV>
<DIV>and then change the way final line works?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Nate Custer wrote:</DIV>
<DIV><FONT size=3D2><EM>I believe raw_input() returns all answers as =
strings. You=20
need to convert your input into a number. I believe you need the line=20
string.atio(x). BTW you must import the string module (import string) =
for this=20
to work</EM>.</FONT><BR><FONT size=3D2></FONT><BR>What exactly is =
importing a=20
string is this something I have to add to Python. Please try not to =
laugh to=20
hard when you answer that. I thought Strings input returned a number but =
I am=20
really not sure of that.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Seabrook wrote:</DIV>
<DIV><EM>Oops -- sorry!&nbsp; I forgot that raw_input() returns a string =
type --=20
that<BR>means that the '7' is not stored in memory as binary 00000111 =
but=20
instead<BR>as the ASCII character '7', which I'm guessing is 37hex or =
00110111=20
--<BR>don't remember...<BR>Anyway, convert 'em to integers like =
this<BR><BR>ans=20
=3D int(a) * int(b)<BR><BR></EM>Okay I tried this:</DIV>
<DIV><EM>#Calculator functions<BR>a =3D raw_input ("First Number:")<BR>b =
=3D=20
raw_input ("Second Number:")<BR>ans =3D int(a)* int(b)<BR></EM>It will =
let me=20
enter the two numbers but gives no total. I am also beginning to think =
that=20
there may be more than one way to write this program. Which is cool the =
more I=20
can learn about this the more I will understand what the different =
functions do.=20
So I think I was initially heading the right way. </DIV>
<DIV>&nbsp;</DIV>
<DIV>Again thank you all for guiding me the right way. Ignorant but =
looking to=20
change.:-)</DIV>
<DIV>Thanks,<BR>Brendhan<BR>-----BEGIN GEEK CODE BLOCK-----<BR>Version:=20
3.1<BR>GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+<BR>O+ M V? =
PS+ Y=20
PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++<BR>D G(++) e+(++) h-- r++=20
y++*<BR>------END GEEK CODE BLOCK------</DIV>
<DIV>&nbsp;</DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_0070_01C0F9E2.10798B60--


From mikebacks@yahoo.com  Thu Jun 21 04:56:15 2001
From: mikebacks@yahoo.com (Michael Bacayo)
Date: Wed, 20 Jun 2001 20:56:15 -0700 (PDT)
Subject: [Tutor] Calling DOS Programs
Message-ID: <20010621035615.67695.qmail@web10405.mail.yahoo.com>

I need help!
I want to know how to call a DOS program with the
arguments from within a Python program. Exec* and
spawn* doesn't seem to work at all or sometimes it
generates an OSError file or program not found.


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/


From jgregorio@qwest.net  Thu Jun 21 05:13:04 2001
From: jgregorio@qwest.net (Josh Gregorio)
Date: Wed, 20 Jun 2001 21:13:04 -0700
Subject: [Tutor] Calculator functions part II
References: <OE5279HrDPPkbKyND5N0000ecbd@hotmail.com>
Message-ID: <004201c0fa08$78c48000$fb5be33f@computer>

This is a multi-part message in MIME format.

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

Here is what I did:

a =3D input("First number" )
b =3D input("Second number" )
answer =3D a * b
print "The answer is %d " % (answer)

This worked on my box. Was there a reason to use raw_input?=20

Josh

------=_NextPart_000_003F_01C0F9CD.CB83D380
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>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Here is what I did:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>a =3D input("First number" )<BR>b =3D =
input("Second=20
number" )<BR>answer =3D a * b<BR>print "The answer is %d " % =
(answer)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>This worked on my box. Was there a reason to use raw_input? </DIV>
<DIV>&nbsp;</DIV>
<DIV>Josh</DIV></FONT></DIV></FONT></BODY></HTML>

------=_NextPart_000_003F_01C0F9CD.CB83D380--



From ak@silmarill.org  Thu Jun 21 05:43:50 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Thu, 21 Jun 2001 00:43:50 -0400
Subject: [Tutor] Calculator functions part II
In-Reply-To: <"from jgregorio"@qwest.net>
References: <OE5279HrDPPkbKyND5N0000ecbd@hotmail.com>
 <004201c0fa08$78c48000$fb5be33f@computer>
Message-ID: <20010621004350.A8227@sill.silmarill.org>

On Wed, Jun 20, 2001 at 09:13:04PM -0700, Josh Gregorio wrote:
> Here is what I did:
> 
> a = input("First number" )
> b = input("Second number" )
> answer = a * b
> print "The answer is %d " % (answer)
> 
> This worked on my box. Was there a reason to use raw_input? 
> 
> Josh

input() executes results so if you make a typo it may mess up your program
or even delete files (that'd be quite a typo though). Also, it may be a security
threat.

-- 
Jupiter and Saturn Oberon Miranda
And Titania Neptune Titan
Stars can frighten
        - Syd


From ak@silmarill.org  Thu Jun 21 06:32:27 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Thu, 21 Jun 2001 01:32:27 -0400
Subject: [Tutor] Calling DOS Programs
In-Reply-To: <"from mikebacks"@yahoo.com>
References: <20010621035615.67695.qmail@web10405.mail.yahoo.com>
Message-ID: <20010621013227.C8227@sill.silmarill.org>

On Wed, Jun 20, 2001 at 08:56:15PM -0700, Michael Bacayo wrote:
> I need help!
> I want to know how to call a DOS program with the
> arguments from within a Python program. Exec* and
> spawn* doesn't seem to work at all or sometimes it
> generates an OSError file or program not found.

os.system('dos program here')

> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Jupiter and Saturn Oberon Miranda
And Titania Neptune Titan
Stars can frighten
        - Syd


From ak@silmarill.org  Thu Jun 21 06:31:53 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Thu, 21 Jun 2001 01:31:53 -0400
Subject: [Tutor] Calculator function silly questions
In-Reply-To: <"from brendhanhorne"@hotmail.com>
References: <OE32eDeBvLgz60i8juX0000db51@hotmail.com>
Message-ID: <20010621013153.B8227@sill.silmarill.org>

On Wed, Jun 20, 2001 at 11:38:10PM -0400, Brendhan Horne wrote:
> Wow what a great help you guys have been. Thank You. So as to not bask in ignorance. Let me update and ask questions
> Michael Schmitt wrote:
> I think what you want is:
>  
> a = raw_input ("First Number:")
> b = raw_input ("Second Number:")
> print "Answer: %d" % (int(a)*int(b))
>  
>  That worked really well. My question is What is happening in the third line? Can I expand on that and say add
> c = raw_input ("Third Number:")
> and then change the way final line works?
> 
> Nate Custer wrote:
> I believe raw_input() returns all answers as strings. You need to convert your input into a number. I believe you need the line string.atio(x). BTW you must import the string module (import string) for this to work.
> 
> What exactly is importing a string is this something I have to add to Python. Please try not to laugh to hard when you answer that. I thought Strings input returned a number but I am really not sure of that.

Never mind that, you convert string to integer by using int(string):

>>> a = '5'
>>> b = '3'
>>> a * b
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unsupported operand type(s) for *
>>> a = int(a)
>>> a
5
>>> b = int(b)
>>> a * b
15

> 
> Seabrook wrote:
> Oops -- sorry!  I forgot that raw_input() returns a string type -- that
> means that the '7' is not stored in memory as binary 00000111 but instead
> as the ASCII character '7', which I'm guessing is 37hex or 00110111 --
> don't remember...
> Anyway, convert 'em to integers like this
> 
> ans = int(a) * int(b)
> 
> Okay I tried this:
> #Calculator functions
> a = raw_input ("First Number:")
> b = raw_input ("Second Number:")
> ans = int(a)* int(b)
print ans
> It will let me enter the two numbers but gives no total. I am also beginning to think that there may be more than one way to write this program. Which is cool the more I can learn about this the more I will understand what the different functions do. So I think I was initially heading the right way. 
> 
> Again thank you all for guiding me the right way. Ignorant but looking to change.:-)
> Thanks,
> Brendhan
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.1
> GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
> O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
> D G(++) e+(++) h-- r++ y++*
> ------END GEEK CODE BLOCK------
> 

-- 
Jupiter and Saturn Oberon Miranda
And Titania Neptune Titan
Stars can frighten
        - Syd


From w.richert@gmx.net  Thu Jun 21 09:12:17 2001
From: w.richert@gmx.net (Willi Richert)
Date: Thu, 21 Jun 2001 10:12:17 +0200
Subject: [Tutor] **kw and self
In-Reply-To: <20010620185530.A14931@pino.selwerd.nl>
References: <01062018185800.09462@charybdis> <20010620185530.A14931@pino.selwerd.nl>
Message-ID: <01062110134301.16885@marcie>

Hi, thanks again. But one question just arrived ;-)

Why can't I just pass a dictionary? Why do I have to put ** before it?

Thanks,
willi
On Wed, 20 Jun 2001, you wrote:
> On  0, Willi Richert <w.richert@gmx.net> wrote:
> > as a bloody newbie (who as reverted already some others to Python) I walked 
> > 34 times through the whole web and did not get the real meaning of **kw and 
> > self.
> 
> *breathe in deeply*
> 
> Ok.
> 
> PART I: THE HEDGEHOG
> --------------------
> 
> No wait, that's wrong.
> 
> PART I, edited: KEYWORD ARGUMENTS
> ----------------------------------
> 
> (this has become quite long. probably the best way to understand it
> completely is to enter all the examples into an interpreter and play around
> with them).
> 
> Do you know what a default argument to a function is? Say we have a function
> like
> 
> def and_now_for(s = "something completely different"):
>    print "And now for...", s
> 
> It takes one argument, in principle:
> >>> and_now_for("more shrubberies")
> And now for... more shrubberies
> 
> But you can also take the argument off, so that the default is used:
> >>> and_now_for()
> And now for... something completely different
> 
> This is obviously useful. Now say we have a function that takes several
> arguments:
> 
> def recipe(ingr1="spam", ingr2="spam", ingr3="eggs", ingr4="spam"):
>    print ingr1, ingr1, ing3, "and", ingr4
> 
> It works fine when called with no arguments, or with some:
> >>> recipe()
> spam spam eggs and spam
> >>> recipe("beans")
> beans spam eggs and spam
> 
> But what if we want to leave all the default arguments in, except for the
> *last*? You can't give an argument except when you also enter all the ones
> before it, or Python doesn't know what you want. Enter keyword arguments:
> 
> >>> recipe(ingr4="shrubberies")
> spam spam eggs and shrubberies
> 
> Again, useful. You can fill in any argument like this. For instance in
> Tkinter GUIs, functions have lots and lots of default arguments and you
> usually only want to enter one or two, so you use keyword arguments.
> 
> Now this can be made even more general, with the **arguments construct.
> You don't bother to list the arguments and their defaults anymore, but let
> the user give any keyword arguments it wants, and they're passed in as a 
> *dictionary*. Consider:
> 
> def kwarg_demo(**kwargs):
>    print kwargs
> 
> >>> kwarg_demo(first="bla", second="whee")
> {'first': 'bla', 'second': 'whee'}
> 
> The function gets a dictionary, it can see which values were filled in
> (using kwargs.has_key or kwargs.keys(), for instance). It's flexible.
> 
> That's using **kwargs when you *define* a function. Since 2.0 it can also be
> used to pass in values. Say you have a function like
> 
> def two_arguments(first, second):
>    print "first =", first
>    print "second =", second
> 
> Now we know that the arguments are called first and second, and we've got
> some values for them in a dictionary:
> 
> dict = {
>    'first': 'silly party',
>    'second': 'very silly party'
>    }
> 
> Now, we can call the function using the dictionary, with
> >>> two_arguments(**dict)
> first = silly party
> second = very silly party
> 
> What that actually does is fill in the values from the dictionary, like
> two_arguments(first='silly party', second='very silly party')
> 
> So both when defining and calling a function, you can use the **arguments
> syntax to fake keyword arguments with a dictionary.
> 
> 
> (pause. you may reread that a few times. i think i laid out the reasoning
> sufficiently)
> 
> 
> There's a related syntax, with a single *. This is used for giving a
> function a variable number of arguments, that don't need their own names.
> 
> Say, we have some functions for adding numbers:
> 
> def add2(x,y): return x+y
> 
> def add3(x,y,z): return x+y+z
> 
> def add4(w,x,y,z): return w+x+y+z
> 
> Doesn't really look Pythonic, does it? We need a seperate function for every
> amount of numbers. In comes the * argument:
> 
> def add(*args):
>    sum = 0
>    for number in args:
>       sum += number
>    return sum
> 
> Now we can call it with as many numbers as we like!
> 
> >>> add(3,4,5,6)
> 18
> 
> The number are passed into the function as a tuple, and we can use a for
> loop to go through them. The other way around works as well, since Python 2.0;
> you can have any sequence, put a * in front and it passes them as individual
> arguments to the function:
> 
> >>> l = [1,2,3,4,5]
> >>> add(*l)
> 15
> >>> add(5, *l)
> 20
> >>> add(5, *l, 6)
>                ^
> SyntaxError: invalid syntax
> 
> Unfortunately, that one doesn't work. Any normal arguments must always come
> before the *args, and those must come before the **kwargs.
> 
> So if you want to make a function that takes a function as argument, plus
> any number of arguments and also keyword arguments, if any, and calls the
> function with it, you do it like this, in Python 2.0+:
> 
> def apply(f, *args, **kwargs):
>    return f(*args, **kwargs)
> 
> In older versions, you can't write this - but this apply() function is a
> builtin! And that's how you'd do it in older version, use apply().
> 
> >>> apply(add, (3,4,5))  # is equivalent to...
> 12
> >>> add(*(3,4,5))        # in newer versions.
> 
> Well, that was quite some text. Have to leave again now, hopefully someone
> else writes a tome on 'self' or otherwise I'll do that myself later tonight.
> 
> -- 
> Remco Gerlich
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 
Make laugh not war!


From w.richert@gmx.net  Thu Jun 21 09:16:33 2001
From: w.richert@gmx.net (Willi Richert)
Date: Thu, 21 Jun 2001 10:16:33 +0200
Subject: [Tutor] **kw and self
In-Reply-To: <a05100e09b7568ab27f77@[169.254.218.155]>
References: <01062018185800.09462@charybdis> <20010620185530.A14931@pino.selwerd.nl> <a05100e09b7568ab27f77@[169.254.218.155]>
Message-ID: <01062110173000.16926@marcie>

Hi,

do I have special features with this "self" or is it just because of Python's
design? Java and the like don't have self as an implied argument.

willi

On Wed, 20 Jun 2001, you wrote:
> At 6:55 PM +0200 6/20/01, Remco Gerlich wrote:
> >On  0, Willi Richert <w.richert@gmx.net> wrote:
> >>  as a bloody newbie (who as reverted already some others to Python) I walked
> >>  34 times through the whole web and did not get the real meaning of **kw and
> >>  self.
> >
> >*breathe in deeply*
> >
> >Ok.
> >
> >PART I: THE HEDGEHOG
> >--------------------
> >
> >No wait, that's wrong.
> 
> ::snort:;
> 
> Thanks for making my morning. I'm tired and grumpy, but this made me laugh.
> 
> Therefore I'll answer the self question. :)
> 
> self, when used with variables, means: "for this instance of this 
> class, this variable is set to that."
> 
> Most classes have multiple instances, meaning there's 52 cards or 7 
> robots or whatever.
> 
> When self is used with methods, it means "use the function that 
> belongs to this class."
> 
> Note that the first argument, implied when you pass something to a 
> class's method, is self.
> 
> consider the following example:
> 
> class robot:
>   def __init__(self, name, robotlist):
>    self.name = name
>    robotlist.append(self)
> 
> robotlist = []
> 
> robbie = robot('In',  robotlist)
> robbie = robot('A',   robotlist)
> robbie = robot('B',   robotlist)
> robbie = robot('C',   robotlist)
> robbie = robot('D',   robotlist)
> robbie = robot('E',   robotlist)
> robbie = robot('Out', robotlist)
> 
> for i in robotlist:
>   print i.name
> 
> -- 
> _Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
> "Cannot run out of time.... Is infinite time. You... are finite....
> Zathrus... is finite. This... is wrong tool!" -- Zathrus
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 
Make laugh not war!


From scarblac@pino.selwerd.nl  Thu Jun 21 09:32:54 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 21 Jun 2001 10:32:54 +0200
Subject: [Tutor] **kw and self
In-Reply-To: <01062110134301.16885@marcie>; from w.richert@gmx.net on Thu, Jun 21, 2001 at 10:12:17AM +0200
References: <01062018185800.09462@charybdis> <20010620185530.A14931@pino.selwerd.nl> <01062110134301.16885@marcie>
Message-ID: <20010621103254.A16040@pino.selwerd.nl>

On  0, Willi Richert <w.richert@gmx.net> wrote:
> Why can't I just pass a dictionary? Why do I have to put ** before it?

Because then it would be passed as just a dictionary, a single argument.

Like

>>> def add(a, b): return a+b
>>> dict = {'a': 1, 'b': 2}
>>> add(dict)
TypeError: add() takes exactly 2 arguments (1 given)

It's the same as
>>> add(a = {'a':1, 'b': 2})

which is an error because 'b' gets no value.

>>> add(**dict)
3

You need the ** to tell Python you want to use the dictionary for keyword
arguments.

-- 
Remco Gerlich


From scarblac@pino.selwerd.nl  Thu Jun 21 09:44:57 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 21 Jun 2001 10:44:57 +0200
Subject: [Tutor] **kw and self
In-Reply-To: <01062110173000.16926@marcie>; from w.richert@gmx.net on Thu, Jun 21, 2001 at 10:16:33AM +0200
References: <01062018185800.09462@charybdis> <20010620185530.A14931@pino.selwerd.nl> <a05100e09b7568ab27f77@[169.254.218.155]> <01062110173000.16926@marcie>
Message-ID: <20010621104456.A16055@pino.selwerd.nl>

On  0, Willi Richert <w.richert@gmx.net> wrote:
> do I have special features with this "self" or is it just because of Python's
> design? Java and the like don't have self as an implied argument.

This is just the way Python was designed.

In Python, if you assign to a variable, it's always a local variable, or a
module global if you said so with 'global x' for variable x.

So if you want to assign to something in another namespace (like an instance
variable), you have to explicitly write that: self.x = 3.

Python passes the instance as the first argument of a method. How else could
the local variable 'self' get a value?

So if we have a class:

class Spam:
   def some_method(self):
      # If this method is called on an instance, 'self' will refer to the
      # instance. Therefore, we can use it to set the instance variable 'x':
      self.x = 3

instance = Spam()
instance.somemethod()
print instance.x # Prints 3.

In Python, as much as possible, nothing 'magical' happens, everything must
be as explicit as possible. This improves readability.

Since 'self' is just a variable name, you could use any other name for it as
well, but everyone uses 'self'.

-- 
Remco Gerlich


From wheelege@tsn.cc  Thu Jun 21 10:10:13 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Thu, 21 Jun 2001 19:10:13 +1000
Subject: [Tutor] Calculator functions part II
References: <OE5279HrDPPkbKyND5N0000ecbd@hotmail.com> <004201c0fa08$78c48000$fb5be33f@computer>
Message-ID: <02b601c0fa31$fb494b40$0200a8c0@ACE>

This is a multi-part message in MIME format.

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

>> This worked on my box. Was there a reason to use raw_input?=20

  Simple - input is evil :)

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2><FONT face=3DArial size=3D2>&gt;&gt; =
This worked on my=20
box. Was there a reason to use raw_input? </FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DArial =
size=3D2></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Courier New" =
size=3D3>&nbsp; Simple -=20
input is evil :)</FONT></DIV></FONT></BODY></HTML>

------=_NextPart_000_02B3_01C0FA85.CC5E4B60--



From allan.crooks@btinternet.com  Thu Jun 21 10:30:34 2001
From: allan.crooks@btinternet.com (allan.crooks@btinternet.com)
Date: Thu, 21 Jun 2001 10:30:34 00100
Subject: [Tutor] Calculator function silly questions
Message-ID: <3b31beba.3c5d.0@btinternet.com>

>> a = raw_input ("First Number:")
>> b = raw_input ("Second Number:")
>> print "Answer: %d" % (int(a)*int(b))
>>  
>>  That worked really well. My question is What is 
happening in the third line? Can I expand on that and 
say add
>> c = raw_input ("Third Number:")
>> and then change the way final line works?

print "Answer: %d" % (int(a)*int(b))

Let's split the string up.

print - This makes everything that comes after it be 
printed out onto the screen.

int(a)*int(b) - Converts the strings to numbers (I know 
you're unsure about this, I'll explain this later) and 
multiplies them.

"Answer: %d" - Creates a string that gets printed out. 
You may notice that the %d part doesn't get printed 
when we run this.

"Answer: %d" % (int(a)*int(b))

The % sign (the second one, without the d next to it) is 
to do with string replacement. A new string is created, 
based on the first one, and replacing each %d (or %s or 
%f or whatever code you've put) and replacing it with 
the string value of the number you've multiplied with.

Here's an example.

s = "%s, my name is %s and I %s".
t = s % ("Hello", "Allan", "should be working.")
u = s % ("Good evening", "Allan's Boss", "am currently 
firing Allan.")

Now t is:
"Hello, my name is Allan and I should be working."

And u is:
"Good evening, my name is Allan's Boss and I am 
currently firing Allan."

The first string (t) is true. The second one (u) might be 
true if I'm not careful. :)

All that's happening is we're replacing the first %s with 
the first value, the second %s with the second value and 
so on. Since I'm not sure if you're knowledgeable about 
things like tuples in Python, I'll leave the explanation 
that far.

Don't worry about using %s and %d's, you won't need 
them at the moment (you can live without them if you 
want).

For three inputs, you can do this:

a = raw_input ("First Number:")
b = raw_input ("Second Number:")
c = raw_input ("Third Number:")
print "Answer", int(a)*int(b)*int(c)

You can print many things like this:

print a, b, c

and it will print the values of a, b and c, and put spaces 
between them. That should do for now (and it looks 
nicer than the previous answer anyhow :)

>> Nate Custer wrote:
>> What exactly is importing a string is this something 
I have to add to Python. Please try not to laugh to hard 
when you answer that. I thought Strings input returned a 
number but I am really not sure of that.

For a beginner to Python, I wouldn't worry 
about "importing". It's not necessary for this little 
program (though at some point you will need to 
understand it for later programming.

raw_input returns a string of characters.

I understand why you have problems understanding why 
entering 9 returns a string and not a number.

Here's some example code:

a = 5
b = "5"
c = a*5
d = b*5

a equals the number 5.
b equals the string "5".
c equals the number 5 multiplied to the value in a (5). 
5*5 = 25
d equals the string "55555". Why? Because for any 
string, if you multiply it, you get several repetitions of it.

For example:
a = "Spam"
b = a * 3

b now equals "SpamSpamSpam". The problem with this 
is that the multiplication sign (*) does different things 
depending on what you're using it with. If you're 
applying it to a string, it repeats it. If you're applying to 
a number, it multiplies it with the other number.

When raw_input reads in characters, it returns it as a 
string. It doesn't know how to interpret the string (even 
though we do). You may want the string "52" or the 
number 52.

So we have to convert the string into a number. Doing int
(a) converts it for us.

>> #Calculator functions
>> a = raw_input ("First Number:")
>> b = raw_input ("Second Number:")
>> ans = int(a)* int(b)
>print ans
>> It will let me enter the two numbers but gives no 
total.

Are you running this in Windows? The window is probably 
closing just after it's printed the total (not giving you 
enough time to read the value).

> I am also beginning to think that there may be more 
> than one way to write this program. Which is cool the 
> more I can learn about this the more I will understand 
> what the different functions do.

There are several different ways to write the code. I'd 
suggest doing it whatever way seems more natural and 
easier to write for you.

I apologise if any of the explanations were brief, but I 
*really* should be working at the moment. :)

Let us know if you need any more help,
Allan.



From alan.gauld@bt.com  Thu Jun 21 12:12:50 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 21 Jun 2001 12:12:50 +0100
Subject: [Tutor] **kw and self
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D844@mbtlipnt02.btlabs.bt.co.uk>

> > 34 times through the whole web and did not get the real 
> meaning of **kw and self.

Remco,

Great explanation! I hadn't realized till I read it that v2.0 had 
introduced those changes to the use of **kw and *args.

Thanks,

Alan G


From alan.gauld@bt.com  Thu Jun 21 12:43:31 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 21 Jun 2001 12:43:31 +0100
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r
 equirement
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D846@mbtlipnt02.btlabs.bt.co.uk>

> What would switching over to using Scintilla accomplish that 
> sticking with IDLE and continuing it's development wouldn't?

In a word "Reuse". That means one editor to maintain for most 
of the Python IDEs. Add a feature to Scintilla and its pretty 
trivial for all the IDEs to pick up the new feature without 
having to reimplemnent it from scratch. Effort gets concentrated 
on the value add bits rather than the nitty gritty of text editing.

At least that's the theory... In practice writing reusable 
solutions gets exponentially harder with the number of clients.
Thus trying to please multiple consumers might just wind up
stifleing the development of Scintilla!

Personally my favourite approach to IDEs is that taken by 
the old HP Unix product - provide a configurable framework and 
let the user select their own editor/compiler/interpreter/debugger
etc. The downside of this is that it restricts how much integration 
you can really have to how well integrated the selected tools are.
GNOME etc should make this approach more viable long term. 

Alan G


From alan.gauld@bt.com  Thu Jun 21 12:53:42 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 21 Jun 2001 12:53:42 +0100
Subject: [Tutor] Calculator function silly questions
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D847@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C0FA48.D1659A60
Content-type: text/plain; charset="iso-8859-1"

print "Answer: %d" % (int(a)*int(b))
 
 That worked really well. My question is What is happening in the third
line?  
...
What exactly is importing a string is this something I have to add to
Python. Please try not to laugh to hard when you answer that. I thought
Strings input returned a number but I am really not sure of that.
 

These and several other questions are answered in my tutor.
 
Thinking Like a CS is a fine tutor but takes a slightly different 
tack to mine. Compare the two and you will often find the answer in one that
the other misses out.

------_=_NextPart_001_01C0FA48.D1659A60
Content-type: text/html; charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.00.3013.2600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV>
  <DIV><FONT size=2><EM>print "Answer: %d" % (int(a)*int(b))</EM></FONT></DIV>
  <DIV><FONT size=2><EM>&nbsp;</EM></FONT></DIV>
  <DIV><FONT size=2>&nbsp;That worked really well. My question is What is 
  happening in the third line?&nbsp;<SPAN class=670310012-21062001><FONT 
  color=#0000ff face="Courier New">&nbsp;</FONT></SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
  class=670310012-21062001>...</SPAN></FONT></DIV>
  <DIV><FONT size=2>What exactly is importing a string is this something I have 
  to add to Python. Please try not to laugh to hard when you answer that. I 
  thought Strings input returned a number but I am really not sure of 
  that.</FONT></DIV>
  <DIV>&nbsp;</DIV></DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=670310012-21062001>These and several other questions are answered in my 
tutor.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=670310012-21062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=670310012-21062001>Thinking Like a CS is a fine tutor but takes a slightly 
different </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=670310012-21062001>tack to mine. Compare the two and you will often find 
the answer in one that the other misses out.</SPAN></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01C0FA48.D1659A60--


From NHYTRO@compuserve.com  Thu Jun 21 13:08:14 2001
From: NHYTRO@compuserve.com (Sharriff Aina)
Date: Thu, 21 Jun 2001 08:08:14 -0400
Subject: [Tutor] Unicode?
Message-ID: <200106210808_MC3-D687-82FA@compuserve.com>

Hi guys! could anyone help me out of this problem?

########### code
PythonWin 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on
win32. Portions Copyright 1994-2000 Mark Hammond (MarkH@ActiveState.com) =
-
see 'Help/About PythonWin' for further copyright information.

>>> a =3D unicode('=DCber'', 'latin-1')

>>> a u'\303\274ber'

>>> a.encode('latin-1')

'\303\274ber'

>>> print a.encode('latin-1')

=C3=83=C2=BCber

the unicode function doesnt work properly. I would like to store and
retrieve German characters in a database, the retrieved strings are then
outputted by a CGI script.


Thanks


Sharriff


From alan.gauld@bt.com  Thu Jun 21 12:56:47 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 21 Jun 2001 12:56:47 +0100
Subject: [Tutor] Calculator function silly questions
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D848@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C0FA49.3FD9F860
Content-type: text/plain; charset="ISO-8859-1"

print "Answer: %d" % (int(a)*int(b))
 
 That worked really well. My question is What is happening in the third
line?  
...
What exactly is importing a string  

Hmm, finger trouble caused a premature send... is that a medical condition?
 
I was suggesting comparing your tutor with mine. Its at:
 
http://www.crosswinds.net/~agauld <http://www.crosswinds.net/~agauld> 
 
The section you should look at first to answer your questions above 
is the "simple sequences" page.
 
Also the next one Raw Materials which covers types and conversions etc
 
HTH,
 
Alan G.

------_=_NextPart_001_01C0FA49.3FD9F860
Content-type: text/html; charset="ISO-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">


<META content="MSHTML 5.00.3013.2600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV>
  <DIV><FONT size=2><EM>print "Answer: %d" % (int(a)*int(b))</EM></FONT></DIV>
  <DIV><FONT size=2><EM>&nbsp;</EM></FONT></DIV>
  <DIV><FONT size=2>&nbsp;That worked really well. My question is What is 
  happening in the third line?&nbsp;<SPAN class=640200212-21062001><FONT 
  color=#0000ff face="Courier New">&nbsp;</FONT></SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
  class=640200212-21062001>...</SPAN></FONT></DIV>
  <DIV><FONT size=2>What exactly is importing a string&nbsp;<SPAN 
  class=640200212-21062001><FONT color=#0000ff 
  face="Courier New">&nbsp;</FONT></SPAN></FONT></DIV></DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001>Hmm, finger trouble caused a premature send... is that 
a medical condition?</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001>I was suggesting comparing your tutor with mine. Its 
at:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001><A 
href="http://www.crosswinds.net/~agauld">http://www.crosswinds.net/~agauld</A></SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001>The section you should look at first to answer your 
questions above </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001>is the "simple sequences" page.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001>Also the next one Raw Materials which covers types and 
conversions etc</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001>HTH,</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=640200212-21062001>Alan G.</SPAN></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01C0FA49.3FD9F860--


From alan.gauld@bt.com  Thu Jun 21 13:06:04 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 21 Jun 2001 13:06:04 +0100
Subject: [Tutor] **kw and self
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D849@mbtlipnt02.btlabs.bt.co.uk>

> Java and the like don't have self as an implied argument.

Actually they do.
In C++ and Java its called 'this'
In Delphi and Smallktalk (and objective C???) its called 'self'

The difference is it is implied and you don't need to declare it:
In C++:

class C
{
private:
   int aValue;
public:
   C(int n){aValue = n) 	// no 'this' here
   void foo(){ 			// no mention of 'this' here either
      cout << this->aValue;   // so where'd it come from?
   }
}

C *c;
c = new C(7);
c->foo();

The 'this' reference in foo() just appeared by magic 
because its implied in the language. When you create an 
instance and use it C++(and Java) automatically creates 
a this variable that points to the particular object.

You don't often need to use 'this' in C++ or Java, (altho' 
many professionals do so to distinguish class attributes 
from local variables) but python chooses to make it explicit 
so its harder to make a mistake. After a while you get to 
prefer it that way(at least I do :-)

HTH,

Alan G.


From Mark.Tobin@attcanada.com  Thu Jun 21 13:40:44 2001
From: Mark.Tobin@attcanada.com (Tobin, Mark)
Date: Thu, 21 Jun 2001 06:40:44 -0600
Subject: [Tutor] Killing threads
Message-ID: <3D7C088D6CCFD31190A5009027D30E9103391034@torex004.attcanada.ca>

Allan, 

Thanks for the solution... the code works now, but even more importantly I
am starting to get a handle on threading.  The threading.Condition() was
just what I knew had to be there somewhere but couldn't find because I
wasn't exactly sure what it should look like.

Again thanks for the effort you put into helping me out... I think this
newsgroup/listserve is the best thing (among many) that Python has going for
it.

Mark

> -----Original Message-----
> From:	Allan Crooks [SMTP:allan.crooks@btinternet.com]
> Sent:	Wednesday, June 20, 2001 6:21 PM
> To:	Mark.Tobin@attcanada.com; tutor@python.org
> Subject:	RE: [Tutor] Killing threads
> 
> Hi,
> 
> Here we go with a solution. :)
> 
> # Your code
> def main():
>     a = Account()
>     a.arp = [300]
>     a.threads = []
>     t = threading.Thread(target = a.checker, args = (a.arp))
>     a.threads.append(t)
>     u = threading.Thread(target = a.menu, args = ())
>     a.threads.append(u)
>     a.nthreads = range(len(a.threads))
>     for i in a.nthreads:
>         a.threads[i].start()
>     for i in a.nthreads:
>         a.threads[i].join()
>         
> Given that we don't have the Account class at hand, it's somewhat more
> problematic to show you a corrected version specifically for your code.
> 
> Note that I said it was "problematic", not "impossible". :)
> 
> First of all though, I'll point out a few things in your code.
> 
> #    t = threading.Thread(target = a.checker, args = (a.arp))
> 
> You may or may not intend this, it's hard to say, but if you want to
> supply a tuple with "a.arp" as an argument, you can put:
>   args = (a.arp,)
>   
> Otherwise Python doesn't realise you mean a tuple. For any variable value
> x, (x) is the same as x.
> 
> 
> 
> Secondly, the for loops can be written like this:
> 
>     for x in a.threads:
>        x.start()
>        
> It's a lot easier to read (and is one of the reasons I prefer Python over
> Java! :)
> 
> Now back to your question, how to stop threads.
> 
> Python doesn't provide a way to stop threads. The "threading" module is
> made to resemble Java's Thread objects, which supports the "stopping" of
> threads. But Python doesn't support it (for good reasons), so we have to
> simulate it ourselves.
> 
> There are two ways of doing this:
>   1) Extending Thread objects.
>   2) Using Condition objects.
>   
> Since I can only be bothered to write one solution, I'll go for the second
> one. :)
> 
> A condition object is a type of lock, which allows threads to use it as a
> signalling area. An appalling description, but it's the best I can come up
> with.
> 
> > One of the threads, u, is active and provides a (so far) basic interface
> for
> > the user through the menu method of the class account.  The second, t,
> is
> > generally dormant, but pops up once in a while to check a single flag,
> then
> > falls back to sleep.  I need for the active, u, thread to be able to
> kill
> > both threads by calling another function quitter().
> 
> Both threads will need to use the Condition object to stop themselves.
> 
> So let us assume that in the Account object, you have a field, "cond",
> which is the Condition object. We'll also have another field which
> indicates we want threads to stop.
> 
> # a.cond = Condition()
> # a.halt = 0
> 
> The menu function needs to stop both threads. The checker function needs
> to be able to be told to stop.
> 
> So first, I'll write the checker function.
> 
> def checker(self):
>    while not self.halt:
>       # check flag, perhaps exit or do whatever
>       self.cond.acquire()
>       if not self.halt:
>           self.cond.wait(x) # x is some value of seconds
>       self.cond.release()
>          
> There are several different ways of writing this code (I've written at
> least 4 different versions), but I'll settle on this one. It may look odd
> that we're seeing if self.halt is tested twice, but hopefully it should
> make sense.
> 
> First of all, the checker function will run until it has been told to
> stop.
> 
> It performs the check it is intended to do. It then "acquires" the
> condition object, which means that there is no way somebody can be running
> code in another thread that has "acquired" the condition object.
> 
> If you've ever written threading code in java, the acquire / release
> methods are similar to the synchronized keyword. If you haven't, then it
> doesn't matter.
> 
> The reason we acquire the condition object, is because we need to be able
> to "wait" on it. You mentioned the checking thread sleeps. However, for
> the other thread to stop the checking thread, we need to tell the checking
> thread to stop.
> 
> 
> 
> It still may not be clear what the condition object does, or why we use
> it. What it does will be explained a bit later, but I'll explain why we
> use it.
> 
> As you can see, we are using a flag (halt) to tell the thread to stop. And
> there are two ways of doing this without condition objects.
> 
> The first is written like this:
> 
> def checker(self):
>    while not self.halt:
>       # check flag, perhaps exit or do whatever
> 
> Much simpler I'm sure you'll agree. The only problem is that the thread
> doesn't check "every now and then", but all the time. You could adjust the
> code to figure out how much time has elapsed since the last check and then
> execute it if a certain amount of time has elapsed. But that still doesn't
> do what you want, the thread is continously running the loop and using
> lots of processor time, even though it's just waiting for a certain amount
> of time to elapse. Which is a bad thing.
> 
> 
> 
> So to combat this, we should make the thread sleep. We can use the sleep
> function in the time module to pause.
> 
> Here's the second version:
> 
> def checker(self):
>    while not self.halt:
>       # check flag, perhaps exit or do whatever
>       time.sleep(x) # x is however long you want it sleep for
>       
> However, say the thread starts to sleep 20 secs, and as soon as it starts
> sleeping, the other function tells it to stop. But the checker thread
> won't respond until it's woken up.
> 
> So we need a way for the thread to sleep, but to wake up if it's being
> told something.
> 
> 
> Solution? Condition objects. :)
> 
> 
> Back to the code I wrote:
> 
> def checker(self):
>    while not self.halt:
>       # check flag, perhaps exit or do whatever
>       self.cond.acquire()
>       if not self.halt:
>           self.cond.wait(x) # x is some value of seconds
>       self.cond.release()
>       
> 
> So hopefully it should be clearer *why* we are using Condition objects.
> The other thread can wake the checker thread up, even if it was sleeping.
> 
> The wait method makes the thread sleep until someone wakes it up. We can
> either write:
>    self.cond.wait() # or
>    self.cond.wait(x)
>    
> The first wait will simply wait for eternity until it is woken up by
> another thread. But since we still want to wake up every now and then and
> check whatever flag we're checking, we write the second version. This
> means that by the time that line of code has been executed, it has either
> been woken up by another thread, or it has slept for x seconds without
> being woken up by the other thread.
> 
> 
> Why the two checks of self.wait? Well, that's quite simple. Here's how it
> would look otherwise:
> 
> def checker(self):
>    while not self.halt:
>       # check flag, perhaps exit or do whatever
>       self.cond.acquire()
>       self.cond.wait(x) # x is some value of seconds
>       self.cond.release()
>       
>       
> This looks OK, but during the time we have been checking flags, we have
> been told to halt. But it would still go to sleep.
> 
> We could make the while loop an infinite loop, but it makes this:
> 
> def checker(self):
>    while 1:
>       # check flag, perhaps exit or do whatever
>       self.cond.acquire()
>       if not self.halt:
>           self.cond.wait(x) # x is some value of seconds
>           self.cond.release()
>       else:
>           self.cond.release()
>           break
>           
> We still need to release the condition object even if we quit the loop.
> This should work, it's just the other version looks nicer.
> 
> 
> OK, hopefully that's clear. Now we come to define the menu function.
> 
> def menu(self, *whatever_args_you_want):
>    # do menu stuff
>    # this bit afterwards is to stop other threads
>    self.cond.acquire()
>    self.halt = 1
>    self.cond.notifyAll()
>    self.cond.release()
>    
> This should be fairly straight forward to understand. The "notifyAll"
> method will simply wake up all threads which are sleeping (waiting on the
> condition object). You also have the "notify" method, which will wake up
> only one thread. It doesn't matter which one you do in this example.
> 
> I think that should work, I've got no code to test it on and no patience
> to write one myself.
> 
> If you were to have more than two threads, would this approach still work?
> It should do. All functions which do anything will have to look like
> checker (so they can respond to exits).
> 
> 
> I'm ever so slightly dubious about what I've written, I presumed I
> would've written more, but I haven't. If this doesn't work, let us know.
> 
> Allan.


From guido@digicool.com  Thu Jun 21 13:40:35 2001
From: guido@digicool.com (Guido van Rossum)
Date: Thu, 21 Jun 2001 08:40:35 -0400
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r equirement
In-Reply-To: Your message of "Thu, 21 Jun 2001 12:43:31 BST."
 <5104D4DBC598D211B5FE0000F8FE7EB20751D846@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D846@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <200106211240.IAA30865@cj20424-a.reston1.va.home.com>

> > What would switching over to using Scintilla accomplish that 
> > sticking with IDLE and continuing it's development wouldn't?
> 
> In a word "Reuse". That means one editor to maintain for most 
> of the Python IDEs. Add a feature to Scintilla and its pretty 
> trivial for all the IDEs to pick up the new feature without 
> having to reimplemnent it from scratch. Effort gets concentrated 
> on the value add bits rather than the nitty gritty of text editing.

But IDLE has a bunch of requirements that I don't think Scintilla can
provide.  IDLE has really two editing modes: the regular module/file
editor, and the "Python Shell".  IDLE's most redeeming feature, IMO,
is the Python Shell.  Compare editing an interactive session in
PythonWin's console window with IDLE's Python Shell.  IMO again, IDLE
is infinitely better, because it uses the exact same editing features
as the module/file editor, meaning you get proper syntax coloring,
automatic indentation, call tips, magic expansion; and on top of that
you get per-line syntax checking, whole-command editing, and history
recall.  In PythonWin's much more primitive console, it's very easy to
mess up the input or the output or confuse the auto-indenter.

(I'm an instant gratification person, so Python's interactive mode is
very important to me.)

I could be wrong about Scintilla not supporting this, but if it did,
why would PythonWin not use it for *its* console?

--Guido van Rossum (home page: http://www.python.org/~guido/)


From dyoo@hkn.eecs.berkeley.edu  Thu Jun 21 15:53:35 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 21 Jun 2001 07:53:35 -0700 (PDT)
Subject: [Tutor] Calculator function silly questions
In-Reply-To: <OE32eDeBvLgz60i8juX0000db51@hotmail.com>
Message-ID: <Pine.LNX.4.21.0106210739050.16754-100000@hkn.eecs.berkeley.edu>

On Wed, 20 Jun 2001, Brendhan Horne wrote:

> a = raw_input ("First Number:")
> b = raw_input ("Second Number:")
> print "Answer: %d" % (int(a)*int(b))
>  
>  That worked really well. My question is What is happening in the
> third line? Can I expand on that and say add

> c = raw_input ("Third Number:")
> and then change the way final line works?


Yes, then you can tell Python to print out the answer that's in 'c', and
there are actually several ways of doing this.  Here are two:

###
    print "Answer: %d" % c
    print "Answer:", c
###

The first method uses something called string formatting, which you'll
learn about later.  The second takes advantage of the fact that if we pass
"print" a bunch of stuff separated by commas, it'll print each in turn.


> I believe raw_input() returns all answers as strings. You need to
> convert your input into a number. I believe you need the line
> string.atio(x). BTW you must import the string module (import string)
> for this to work.
> 

> What exactly is importing a string is this something I have to add to
> Python. Please try not to laugh to hard when you answer that. I

By "import", we mean to borrow some definitions that the implementors of
Python have written for us.  There's a lot of "modules" that's available
for import, and each module takes responsibility for a subject.

For example, there's a 'math' module that provides some math functions
like 'math.sin' and 'math.cos'.

###
>>> import math
>>> math.acos(-1)
3.1415926535897931
###

The 'string' module provides a few things that work with strings.  Some of
the modules use really common names, so you'll need to distinguish between
strings that we can work with:

###
>>> mystr = "I am" + " a string"
>>> mystr
'I am a string'
###

and the 'string' module itself:

###
>>> import string
>>> string
<module 'string' from '/usr/local/lib/python2.1/string.pyc'>
>>> dir(string)
['_StringType', '__builtins__', '__doc__', '__file__', '__name__',
'_float', '_idmap', '_idmapL', '_int', '_long', 'atof', 'atof_error',
'atoi', 'atoi_error', 'atol', 'atol_error', 'capitalize', 'capwords',
'center', 'count', 'digits', 'expandtabs', 'find', 'hexdigits', 'index',
'index_error', 'join', 'joinfields', 'letters', 'ljust', 'lower',
'lowercase', 'lstrip', 'maketrans', 'octdigits', 'printable',
'punctuation', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split',
'splitfields', 'strip', 'swapcase', 'translate', 'upper', 'uppercase',
'whitespace', 'zfill']
###

If you want to browse through all the modules available in Python, take a
look here:

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

This is the documentation for the standard library that comes with Python.  
As you ask questions about Python, you'll find that we often recommend
people to try out modules from the Python library: it makes life much
easier.


> Okay I tried this:
> #Calculator functions
> a = raw_input ("First Number:")
> b = raw_input ("Second Number:")
> ans = int(a)* int(b)

> It will let me enter the two numbers but gives no total. I am also
> beginning to think that there may be more than one way to write this
> program. Which is cool the more I can learn about this the more I will


Once we've calculated 'ans', we should probably print it out to the
screen.  Try using 'print'.

If you have more questions, feel free to ask us.  Good luck!



From pobrien@orbtech.com  Thu Jun 21 16:16:33 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 21 Jun 2001 10:16:33 -0500
Subject: [Tutor] Python Shell - was: RE: IDLE's save-before-run r equirement
In-Reply-To: <200106211240.IAA30865@cj20424-a.reston1.va.home.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBCEDBKBAA.pobrien@orbtech.com>

Thank you, Guido, for bearing with me on this whole issue. I think we are
getting to the heart of the matter. Because I, too, am an instant
gratification person. So let's just talk about the Python Shell
(interactive) capabilities as they exist in the various IDEs. I will attempt
to explain my take on this situation, what bothers me, and what I'd like to
see happen.

The four tools under discussion. IDLE, Boa, PythonWin and VPython all have a
Python Shell capability. But they all vary in their support of keybindings,
coloring, indenting, etc. When someone uses all of these tools and makes use
of each Shell, they have to keep in mind all the variations that exist. This
is counter-productive and takes away from what should be "instant
gratification at all times." I would rather have a common feature set within
all Shells, even if it meant giving up features, rather than have the
variations that exist now. I would like to see the Python Shell exist as
some kind of plug-in or shared code base that all the IDEs could use so that
the Python Shell was uniform in all tools on all platforms. I think this
fits the Python philosophy and would make life a lot easier for beginners as
well as experts. It would also make the Shell available for new,
special-case tools that have been discussed, such as a Python Tutor or
Python Trivial Pursuit game, where the variations would be solely within the
value-add portions and not the fundamental Shell capability (and without
creating yet more forks).

Here are some specific examples of the variations that bother me (Please
don't anyone take offense at these comparisons. I believe they are all
objective, demonstrable differences and not just my opinion, though I am
clearly opinionated. And if I'm wrong about any of this please let me
know.):

PYTHONSTARTUP: IDLE and VPython support it with the -s command line switch.
Boa will have this feature in the next release (because I asked for it).
PythonWin has no support whatsoever for PYTHONSTARTUP to my knowledge.

Home key: Type a line of code at the shell prompt (>>>) and then hit the
Home key. PythonWin puts the cursor in front of your code (very nice). IDLE
and VPython put the cursor in front of the prompt and then beep when you try
to continue typing (yuck). Boa puts the cursor in front of the prompt and
lets you type over the prompt. When you hit enter it truncates the first
four characters from what you typed and tries to execute that (big yuck). I
use this feature a lot in PythonWin when I'm copying previous lines down and
want to get to the beginning of the line to add more code, like assigning to
a variable or some such. When I switch to one of the other tools I have to
do Home, Right, Right, Right, Right - way too many keystrokes.

Command history: IDLE and VPython have Alt-P (previous) and Alt-N (next),
which is very nice. PythonWin has a way to add these bindings, but by
default has Ctrl-Up and Ctrl-Down (just to be different?). I don't know how
to add the PythonWin bindings to IDLE or VPython. Boa has no command
history.

Call tips: PythonWin has the best as far as showing what is in a module.
IDLE/VPython have the best as far as showing function parameters and
docstrings. Boa is way behind.

Win32All: PythonWin is the only tool that can deal with the win extensions,
like dde or com. This is a major pain. There are times when I'd love to use
IDLE but since I'm developing a Windows app that requires DDE I can only use
PythonWin. (And I don't really understand why this is but it definitely
irritates me to no end.)

I'm sure there are other differences, but these are good enough to get my
point across. So I will finish with a question - What, if anything, can be
done about this situation, or am I barking up the wrong tree?

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: guido@cj20424-a.reston1.va.home.com
[mailto:guido@cj20424-a.reston1.va.home.com]On Behalf Of Guido van Rossum
Sent: Thursday, June 21, 2001 7:41 AM
To: alan.gauld@bt.com
Cc: israel@lith.com; pobrien@orbtech.com; mats@laplaza.org;
idle-dev@python.org; Edu-sig@python.org; tutor@python.org
Subject: Re: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r
equirement

> > What would switching over to using Scintilla accomplish that
> > sticking with IDLE and continuing it's development wouldn't?
>
> In a word "Reuse". That means one editor to maintain for most
> of the Python IDEs. Add a feature to Scintilla and its pretty
> trivial for all the IDEs to pick up the new feature without
> having to reimplemnent it from scratch. Effort gets concentrated
> on the value add bits rather than the nitty gritty of text editing.

But IDLE has a bunch of requirements that I don't think Scintilla can
provide.  IDLE has really two editing modes: the regular module/file
editor, and the "Python Shell".  IDLE's most redeeming feature, IMO,
is the Python Shell.  Compare editing an interactive session in
PythonWin's console window with IDLE's Python Shell.  IMO again, IDLE
is infinitely better, because it uses the exact same editing features
as the module/file editor, meaning you get proper syntax coloring,
automatic indentation, call tips, magic expansion; and on top of that
you get per-line syntax checking, whole-command editing, and history
recall.  In PythonWin's much more primitive console, it's very easy to
mess up the input or the output or confuse the auto-indenter.

(I'm an instant gratification person, so Python's interactive mode is
very important to me.)

I could be wrong about Scintilla not supporting this, but if it did,
why would PythonWin not use it for *its* console?

--Guido van Rossum (home page: http://www.python.org/~guido/)



From kbk@shore.net  Thu Jun 21 16:57:54 2001
From: kbk@shore.net (Kurt B. Kaiser)
Date: 21 Jun 2001 11:57:54 -0400
Subject: [Tutor] [Edu-sig] [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: <200106211240.IAA30865@cj20424-a.reston1.va.home.com>
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D846@mbtlipnt02.btlabs.bt.co.uk> <200106211240.IAA30865@cj20424-a.reston1.va.home.com>
Message-ID: <m3pubx25bx.fsf_-_@float.ne.mediaone.com>

Guido van Rossum <guido@digicool.com> writes:
 
> But IDLE has a bunch of requirements that I don't think Scintilla can
> provide.  IDLE has really two editing modes: the regular module/file
> editor, and the "Python Shell".  IDLE's most redeeming feature, IMO,
> is the Python Shell.  Compare editing an interactive session in
> PythonWin's console window with IDLE's Python Shell.  IMO again, IDLE
> is infinitely better, because it uses the exact same editing features
> as the module/file editor, meaning you get proper syntax coloring,
> automatic indentation, call tips, magic expansion; and on top of that
> you get per-line syntax checking, whole-command editing, and history
> recall.  In PythonWin's much more primitive console, it's very easy to
> mess up the input or the output or confuse the auto-indenter.
> 
> (I'm an instant gratification person, so Python's interactive mode is
> very important to me.)

An update of a post to idle-dev, made a couple of days ago:
IDLE is a very useful IDE for Python which has a unique set of features
compared to other solutions:

1. Open souce
2. Under ultimate control of GvR.
3. Portable via Tkinter.
4. Very usable by relatively inexperienced people.
5. Has a Python debugger.
6. Understands Python syntax and environment.
7. Provides an extended example of Python programming.
8. Distributed with most versions (no Mac because of current Tk limitations) 
   of Python at very reasonable cost, so available to first time, casual,
   or resource limited users.
9. Interactive shell has same features as module editor, e.g. colorizing

IMHO IDLE should remain at roughly the (apparent) level of complexity it's at
(or less?) to avoid reducing its usability for beginning/intermediate
programmers.  There are some things which can be done to further improve
usability and reliability, IMHO, like running the target code in a separate
process.

When people involved with Scheme, Forth, or Eiffel are looking for projects,
they tend to re-implement the language. Thank heavens that's not a major factor
with Python, thanks to GvR's leadership. But Pythonistas are clearly attracted
to implementing IDEs!

I can't see any reason why IDLE development should get tied in knots trying for
compatibility with other IDEs. That kind of thing can paralyze you! 

The plan last August, met with enthusiam at the time, was to continue to
develop IDLE on a separate fork to avoid the bottlenecks of new feature patch
review on the Python CVS. The hope was to merge back into the main branch in
the future. If that is to happen, we need to stay close to Guido's vision for
IDLE. When it comes to IDEs, there is more than one way to do it, but Guido has
shown us his way, and I'd vote for continuing along those lines.

With open source software, it appears to be extremely difficult to specify a
project via group interaction.  As just one example, take a look at LispOS
(archived at lists.tunes.org/archives/lispos).  A couple of dozen people argued
specs for nearly two years without any progress.  (Then a student at Utah
implemented in less than 10 hours a first cut at essentially what the LispOS
project was attempting and the project shut down.)  It appears that an initial
implementation is necessary, which can then be enhanced. Python does it by
formal PEP, GvR is suggesting a more informal approach for IDLE: simple
discussion on the idle-dev list.  IMHO, that will work for incremental change.
But as with PEPs, if the group response is favorable, the proposer is still
responsible for coding up a patch for evaluation.

Regards, KBK


From csmith@blakeschool.org  Thu Jun 21 17:11:54 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Thu, 21 Jun 2001 11:11:54 -0500
Subject: [Tutor] Calculator functions part II
In-Reply-To: <E15Cv8U-0001Gh-00@mail.python.org>
References: <E15Cv8U-0001Gh-00@mail.python.org>
Message-ID: <fc.004c4b6b0075a7553b9aca0092e0aec3.75a7b9@blakeschool.org>

Brendhan Horne is wondering why the following produces a run-time error:

ans = a * b
a = raw_input ("First Number:")
b = raw_input ("Second Number:")
ans = a*b

As someone pointed out, you have input two strings and string 
multiplication is undefined.  So you can either convert your strings to 
numbers with int() or float() *or* you can replace raw_input() with 
input().  
-----
Whereas raw_input records everything you type as a string, 
input() will allow you to enter any type of value.
-----
Example:

a=input("a:")
b=input("b:")
print a*b

If you enter 3.5 and then 2 you will see 7.0 printed.  If you enter "3" 
and 2 you will see 33 (because "3"*2 means to repeat the "3" two times) 
but if you enter "3" and "2" you will generate an error because "3"*"2" 
is not defined.  Here is the output of running the above code 3 times:

a:3.5
b:2
7.0
a:"3"
b:2
33
a:"3"
b:"2"
Traceback (most recent call last):
  File "<stdin>", line 2, in ?
  File "<stdin>", line 4, in go
TypeError: unsupported operand type(s) for *

Python is very different than something like BASIC where you can only use 
input to input a number.  As the above little program shows, you can 
enter any valid value for a and b and then if the multiplication operator 
is defined for the two things you enter then the correct result will be 
printed.

Hope this helps.

/c




From alan.gauld@bt.com  Thu Jun 21 17:33:22 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 21 Jun 2001 17:33:22 +0100
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r
 equirement
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D853@mbtlipnt02.btlabs.bt.co.uk>

> But IDLE has a bunch of requirements that I don't think Scintilla can
> provide.  

Possibly so, hence my comments about Scintilla being lumbered with an
extra customer to appease and reuse being expensive, but...

> is the Python Shell.  Compare editing an interactive session in
> PythonWin's console window with IDLE's Python Shell.  

I don't see much difference but confess to not using Pythonwin often 
- usually just for its superior debugger

> as the module/file editor, meaning you get 
> proper syntax coloring,

Seems OK to me

> automatic indentation,

Yes that works

> call tips, 

Yes,

> magic expansion; 

Wassat?

> you get per-line syntax checking, 

Not sure how that differs from PW

> whole-command editing, and 

And again wassat?

> history

Yes, got that too.

> recall.  In PythonWin's much more primitive console, it's very easy to
> mess up the input or the output or confuse the auto-indenter.

I can't say I've ever done that in eoither IDLE or PW but thats maybe 
again a reflection on how rarely I use PW...

> I could be wrong about Scintilla not supporting this, but if it did,
> why would PythonWin not use it for *its* console?

I think it does from what I see. It looks identical to a normal edit 
window to me...

Alan G

Note I'm on Python V2.0 with winall inbstalled not the ActiveState 
version in case that makes a difference.


From python.tutor@atrixnet.com  Thu Jun 21 21:11:48 2001
From: python.tutor@atrixnet.com (Tommy Butler)
Date: Thu, 21 Jun 2001 13:11:48 -0700
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run requirement
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D853@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <NFBBKCNOILDDLKCLBNFIEEJCCFAA.python.tutor@atrixnet.com>

  >Note I'm on Python V2.0 with winall inbstalled not the ActiveState 
  >version in case that makes a difference.

Where can one get a hold of that?
I use the ActiveState version, but
would opt to use the oss version
if one exists and I could find it.

	-tommy


From qhe@ydyn.com  Thu Jun 21 21:28:32 2001
From: qhe@ydyn.com (Peter He)
Date: Thu, 21 Jun 2001 15:28:32 -0500
Subject: [Tutor] releasing and reloading modules
Message-ID: <5.1.0.14.0.20010621151135.00af1da8@mail.ydyn.com.criticalpath.net>

Hi all,

I am a Python beginner. Recently, I noticed that Python won't release the 
imported module automatically after the program quit. So after I revised 
the module(which will be imported into the program) and re-run the program, 
there is no update! I think the reason is that since this module already 
exists in the memory, the Python just simply ignore the import command 
instead of checking its "version" and reload it. I know I can delete it in 
Python interactive window. But I was wondering how can I put this command 
inside the code somewhere such that the imported module will be deleted 
just before the program quit?

Thanks a lot!

Peter



From dsh8290@rit.edu  Thu Jun 21 21:43:43 2001
From: dsh8290@rit.edu (D-Man)
Date: Thu, 21 Jun 2001 16:43:43 -0400
Subject: [Tutor] releasing and reloading modules
In-Reply-To: <5.1.0.14.0.20010621151135.00af1da8@mail.ydyn.com.criticalpath.net>; from qhe@ydyn.com on Thu, Jun 21, 2001 at 03:28:32PM -0500
References: <5.1.0.14.0.20010621151135.00af1da8@mail.ydyn.com.criticalpath.net>
Message-ID: <20010621164343.A10175@harmony.cs.rit.edu>

On Thu, Jun 21, 2001 at 03:28:32PM -0500, Peter He wrote:
| Hi all,
| 
| I am a Python beginner. Recently, I noticed that Python won't release the 
| imported module automatically after the program quit. So after I revised 
| the module(which will be imported into the program) and re-run the program, 
| there is no update! I think the reason is that since this module already 
| exists in the memory, the Python just simply ignore the import command 
| instead of checking its "version" and reload it. I know I can delete it in 
| Python interactive window. But I was wondering how can I put this command 
| inside the code somewhere such that the imported module will be deleted 
| just before the program quit?

Once a module is loaded, it is never (and can't ever) be unloaded.
You can use 'del' to remove the name bound to the module object, but
the module isn't unloaded.  If you are working interactively and you
want to see changes you have made to a module on-disk use the reload
funciton.

reload( module_reference )


HTH,
-D



From jarrett@engineer.com  Thu Jun 21 23:42:25 2001
From: jarrett@engineer.com (W. Jarrett Campbell)
Date: Thu, 21 Jun 2001 17:42:25 -0500
Subject: [Tutor] releasing and reloading modules
In-Reply-To: <20010621164343.A10175@harmony.cs.rit.edu>
Message-ID: <NDBBLLANIGLGFCJPIECNKEOKCIAA.jarrett@engineer.com>

This drove me nuts with PythonWin.  I've used the following to get around
this.  For example, "mymodule" is either loaded or reloaded depending upon
whether it has been loaded prior:

try:
	reload(mymodule)
except NameError:
	import mymodule

Once I finish development, I remove the Try/Except statement and just leave
the import call.

My question is how does reload work if I were to use an "from mymodule
import myclass" command instead of importing the entire module into its own
namespace?

Jarett

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
D-Man
Sent: Thursday, June 21, 2001 3:44 PM
To: tutor@python.org
Subject: Re: [Tutor] releasing and reloading modules


On Thu, Jun 21, 2001 at 03:28:32PM -0500, Peter He wrote:
| Hi all,
|
| I am a Python beginner. Recently, I noticed that Python won't release the
| imported module automatically after the program quit. So after I revised
| the module(which will be imported into the program) and re-run the
program,
| there is no update! I think the reason is that since this module already
| exists in the memory, the Python just simply ignore the import command
| instead of checking its "version" and reload it. I know I can delete it in
| Python interactive window. But I was wondering how can I put this command
| inside the code somewhere such that the imported module will be deleted
| just before the program quit?

Once a module is loaded, it is never (and can't ever) be unloaded.
You can use 'del' to remove the name bound to the module object, but
the module isn't unloaded.  If you are working interactively and you
want to see changes you have made to a module on-disk use the reload
funciton.

reload( module_reference )


HTH,
-D


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From csmith@blakeschool.org  Thu Jun 21 23:47:49 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Thu, 21 Jun 2001 17:47:49 -0500
Subject: [Tutor] method to print in interpreter
Message-ID: <fc.004c4b6b0075ae89004c4b6b0075ae89.75af05@blakeschool.org>

Dear List,

I read about defining __str__ in a class so the interpreter will know how 
to process a print command but I have not yet found what I must do to be 
able to get it to print if, in the interpreter, you don't use a "print" 
command.  i.e. How can I get the evaluation itself to print instead of 
giving the address of the instance.  Here's a run to demonstrate what I 
mean.

>>> from my import point
>>> p=point(1,2)
>>> print p
(1,2)
>>> p
<my.point instance at 0x00c448b0>
>>> 

I would like ">>> p" to return something like '(1,2)', too.

Also, in the Runtime Services section of the library documentation, I 
see "cpickle" and "operator" listed and I find "test_cpickle.py" and 
"test_operator.py" on my disk, but I don't see the "cpickle.py" or 
"operator.py" anywhere.  Where are they?

/c



From scarblac@pino.selwerd.nl  Fri Jun 22 00:09:38 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 22 Jun 2001 01:09:38 +0200
Subject: [Tutor] method to print in interpreter
In-Reply-To: <fc.004c4b6b0075ae89004c4b6b0075ae89.75af05@blakeschool.org>; from csmith@blakeschool.org on Thu, Jun 21, 2001 at 05:47:49PM -0500
References: <fc.004c4b6b0075ae89004c4b6b0075ae89.75af05@blakeschool.org>
Message-ID: <20010622010938.A17017@pino.selwerd.nl>

On  0, Christopher Smith <csmith@blakeschool.org> wrote:
> Dear List,
> 
> I read about defining __str__ in a class so the interpreter will know how 
> to process a print command but I have not yet found what I must do to be 
> able to get it to print if, in the interpreter, you don't use a "print" 
> command.  i.e. How can I get the evaluation itself to print instead of 
> giving the address of the instance.  Here's a run to demonstrate what I 
> mean.
> 
> >>> from my import point
> >>> p=point(1,2)
> >>> print p
> (1,2)
> >>> p
> <my.point instance at 0x00c448b0>
> >>> 
> 
> I would like ">>> p" to return something like '(1,2)', too.

This uses the repr() of the object, not its str(). You need to define
__repr__().

> Also, in the Runtime Services section of the library documentation, I 
> see "cpickle" and "operator" listed and I find "test_cpickle.py" and 
> "test_operator.py" on my disk, but I don't see the "cpickle.py" or 
> "operator.py" anywhere.  Where are they?

They're written in C, not Python (that's what the c in CPickle means, it's
the faster equivalent of the Pickle module).

See Modules/cPickle.c and Modules/operator.c in the source distribution.

cPickle is nice C code, but operator.c is ugly, apparently just wrappers
around other interpreter functions.

-- 
Remco Gerlich


From allan.crooks@btinternet.com  Fri Jun 22 00:12:51 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Fri, 22 Jun 2001 00:12:51 +0100
Subject: [Tutor] method to print in interpreter
Message-ID: <E15DDiE-0005Cd-00@gadolinium.btinternet.com>

Hi,

<snip>

> >>> from my import point
> >>> p=point(1,2)
> >>> print p
> (1,2)
> >>> p
> <my.point instance at 0x00c448b0>
> >>> 
> 
> I would like ">>> p" to return something like '(1,2)', too.

Whenever you "print" an object, it will use the string returned by the str function.
Whenever you have an object that is displayed without using print, it uses the repr function.

So in your Point class, you could add this line:

def __repr__(self):
  return str(self)

Which returns the same string as when you print it.

I can explain why this is like it is, if you want. :)

> Also, in the Runtime Services section of the library documentation, I 
> see "cpickle" and "operator" listed and I find "test_cpickle.py" and 
> "test_operator.py" on my disk, but I don't see the "cpickle.py" or 
> "operator.py" anywhere.  Where are they?

Some Python modules are written in C as opposed to Python. Both cpickle and operator are written in C, and so they aren't available as .py files.

Hope that helps,
Allan.



From dsh8290@rit.edu  Fri Jun 22 01:25:32 2001
From: dsh8290@rit.edu (D-Man)
Date: Thu, 21 Jun 2001 20:25:32 -0400
Subject: [Tutor] releasing and reloading modules
In-Reply-To: <NDBBLLANIGLGFCJPIECNKEOKCIAA.jarrett@engineer.com>; from jarrett@engineer.com on Thu, Jun 21, 2001 at 05:42:25PM -0500
References: <20010621164343.A10175@harmony.cs.rit.edu> <NDBBLLANIGLGFCJPIECNKEOKCIAA.jarrett@engineer.com>
Message-ID: <20010621202532.A10307@harmony.cs.rit.edu>

On Thu, Jun 21, 2001 at 05:42:25PM -0500, W. Jarrett Campbell wrote:
| This drove me nuts with PythonWin.  I've used the following to get around
| this.  For example, "mymodule" is either loaded or reloaded depending upon
| whether it has been loaded prior:
| 
| try:
| 	reload(mymodule)
| except NameError:
| 	import mymodule
| 
| Once I finish development, I remove the Try/Except statement and just leave
| the import call.

Yeah, that works too.

| My question is how does reload work if I were to use an "from mymodule
| import myclass" command instead of importing the entire module into its own
| namespace?

reload works the same way -- it reads the .py file, executes the
module-level statements and binds a new module object in 
sys.modules[ <name> ].  It does NOT go back and re-execute the
from-import statements.  You would need to do that again to rebind all
the names in the (more) local scope.  It is another reason for
avoiding from-import.

-D



From lord_z99@hotmail.com  Fri Jun 22 02:28:20 2001
From: lord_z99@hotmail.com (micheal saunders)
Date: Thu, 21 Jun 2001 21:28:20 -0400
Subject: [Tutor] hello
Message-ID: <F103DgI6bXmdMJOtd3r00016269@hotmail.com>

<html><DIV>
<P>hello there,, this is mike and i wanted to learn how to use this program i think this program is to teach me how to hack im not sure but i would like to know</P>
<P>thnx<BR><BR></P></DIV><br clear=all><hr>Get Your Private, Free E-mail from MSN Hotmail at <a href="http://www.hotmail.com">http://www.hotmail.com</a>.<br></p></html>


From MarkH@ActiveState.com  Fri Jun 22 02:29:56 2001
From: MarkH@ActiveState.com (Mark Hammond)
Date: Fri, 22 Jun 2001 11:29:56 +1000
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r equirement
In-Reply-To: <200106211240.IAA30865@cj20424-a.reston1.va.home.com>
Message-ID: <LCEPIIGDJPKCOIHOBJEPIEPCEAAA.MarkH@ActiveState.com>

> I could be wrong about Scintilla not supporting this, but if it did,
> why would PythonWin not use it for *its* console?

Pythonwin does use scintilla for its console.  You are correct that it is
not integrated with the editor as tightly as IDLE.  This is mainly doe to
the fact pythonwin uses "... " as a secondary prompt, and also complications
with the scintilla lexer.

I agree that there would be significant work to get auto-indent and lexing
working correctly using scintilla as the console window.

As a "meta comment", over 12 months ago I added a feature to Pythonwin so
that new IDLE extensions could be used directly by both Pythonwin and IDLE.
In that time, not a single extra extension has been added (that I saw) and
IDLE changed its extension loading mechanism.

So while these things all sound good in theory, the reality is that people
need to actually _do_ it rather than speculate about how others could do it.
If we had a glut of new extensions being added to one environment and not
the other there would be a stronger case - but this simply isn't happening.
Witness the IDLE-fork project Guido mentioned - lots of talk, no action :(

Replying to Patrick's mail:

> What, if anything, can be
> done about this situation, or am I barking up the wrong tree?

You have 2 choices:  you can lobby for the various authors to make these
changes themselves, or you can submit patches to the authors.  I will let
you guess the most effective route :)  The commercial products may well do
it for "competitive advantage" reasons, or indeed they may _not_ do it for
exactly the same reasons!  The maintainers of the free software are likely
to be lacking any incentive, as their products generally work fine for them,
and probably have far more important things they could be doing (either for
free, or for their salary)

Mark.



From deirdre@deirdre.net  Fri Jun 22 02:57:04 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Thu, 21 Jun 2001 18:57:04 -0700
Subject: [Tutor] hello
In-Reply-To: <F103DgI6bXmdMJOtd3r00016269@hotmail.com>
References: <F103DgI6bXmdMJOtd3r00016269@hotmail.com>
Message-ID: <a05100e00b7585616b6a2@[10.20.0.37]>

>hello there,, this is mike and i wanted to learn how to use this 
>program i think this program is to teach me how to hack im not sure 
>but i would like to know

It is a language for learning how to program, yes.

If you mean that you intend to intrude into other people's systems 
(which is crack, not hack), please leave the list.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From rob@jam.rr.com  Fri Jun 22 02:59:20 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Thu, 21 Jun 2001 20:59:20 -0500
Subject: [Tutor] hello
In-Reply-To: <F103DgI6bXmdMJOtd3r00016269@hotmail.com>
Message-ID: <NFBBKIELCLIEEMGGIGKDCEENCAAA.rob@jam.rr.com>

If you are looking for a good programming language to help learn to hack,
Python is great. Now, different people mean different things by "hack". I
like the way ESR defines it in this article on hacking:

http://www.tuxedo.org/~esr/faqs/hacker-howto.html

Without knowing what you have in mind, here is a page full of links to
different Python tutorials, several of which are great for getting people
started programming from the beginning point:

http://www.lowerstandard.com/python/tutoriallinks.html

If you have some specific questions, we will be happy to help point you in
the right direction as much as possible.

Happy Thursday,
Rob

Useless Python:
Aw, heck, we love you guys!
http://www.lowerstandard.com/python/

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
micheal saunders
Sent: Thursday, June 21, 2001 8:28 PM
To: tutor@python.org
Subject: [Tutor] hello


hello there,, this is mike and i wanted to learn how to use this program i
think this program is to teach me how to hack im not sure but i would like
to know
thnx





Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

_______________________________________________ Tutor maillist -
Tutor@python.org http://mail.python.org/mailman/listinfo/tutor



From rhseabrook@mail.aacc.cc.md.us  Fri Jun 22 01:11:24 2001
From: rhseabrook@mail.aacc.cc.md.us (Seabrook, Richard)
Date: Thu, 21 Jun 2001 23:11:24 -0100
Subject: [Tutor] hello
In-Reply-To: <F103DgI6bXmdMJOtd3r00016269@hotmail.com>
Message-ID: <5.1.0.14.0.20010621230718.009fa7d0@mail.aacc.cc.md.us>

This may sound a little crazy but I seem to recall an identical message 
about 8-10 years ago, might have been in the old comp.lang.python list or 
whatever we were using then. Anyone ever heard of this guy or email handle?
At any rate, I suggest you ignore it.
Dick S.


At 09:28 PM 6/21/01 -0400, "micheal saunders" <lord_z99@hotmail.com>
wrote:

>hello there,, this is mike and i wanted to learn how to use this program i 
>think this program is to teach me how to hack im not sure but i would like 
>to know
>
>thnx
>
>
>
>----------
>Get Your Private, Free E-mail from MSN Hotmail at 
><http://www.hotmail.com>http://www.hotmail.com.
>_______________________________________________ Tutor maillist - 
>Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

-
Dick Seabrook ~ Computer Science ~ Information Systems ~ Programming
URL: enterprise.aacc.cc.md.us/~rhs _   rhseabrook@mail.aacc.cc.md.us
Anne Arundel Community College   //:-)                Speed the 
Net!



From tim.one@home.com  Fri Jun 22 04:16:10 2001
From: tim.one@home.com (Tim Peters)
Date: Thu, 21 Jun 2001 23:16:10 -0400
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r equirement
In-Reply-To: <LCEPIIGDJPKCOIHOBJEPIEPCEAAA.MarkH@ActiveState.com>
Message-ID: <LNBBLJKPBEHFEDALKOLCKEOCKJAA.tim.one@home.com>

Wow -- this has a giant distribution list!  I'll play along <wink>.

[Mark Hammond]
> Pythonwin does use scintilla for its console.  You are correct that it
> is not integrated with the editor as tightly as IDLE.  This is mainly
> doe to the fact pythonwin uses "... " as a secondary prompt, and also
> complications with the scintilla lexer.

FWIW, I wish IDLE used "... " too -- switching between a DOS-box Python and
IDLE is jarring.  In addition, the IDLE shell uses hard tab characters stuck
at 8-space indents (the latter is a limitation of the Tk Text widget), while
all the other edit windows use no hard tab characters and 4-space indents.
So in a *typical* IDLE session (where I've also got a DOS-box Python
running), I'm dealing with three distinct code presentations.  I can't say
it's a physical burden <wink>, but somehow or other it is tiring!

> I agree that there would be significant work to get auto-indent
> and lexing working correctly using scintilla as the console window.

Worth shooting for, though:  *that* uniformity between shell and edit buffer
is very nice to have.

> As a "meta comment", over 12 months ago I added a feature to Pythonwin
> so that new IDLE extensions could be used directly by both Pythonwin
> and IDLE.  In that time, not a single extra extension has been added
> (that I saw) and IDLE changed its extension loading mechanism.
>
> So while these things all sound good in theory, the reality is that
> people need to actually _do_ it rather than speculate about how others
> could do it.

I'm not sure, Mark, but you and I may be the only two people in the History
of the Universe to actively cooperate on sharing code between two GUI
systems (the auto-indent system shared by PythonWin and IDLE).  It wasn't
that painful, but I recall being utterly unable to get anyone else
interested in playing with us at the time.  Since then, IDLE has stagnated
but remained useful, while you've gone on to fame and riches.  See?  There's
no payback to cooperation <wink>.



From jgregorio@qwest.net  Fri Jun 22 05:48:21 2001
From: jgregorio@qwest.net (Josh Gregorio)
Date: Thu, 21 Jun 2001 21:48:21 -0700
Subject: [Tutor] Calculator functions part II
References: <OE5279HrDPPkbKyND5N0000ecbd@hotmail.com><004201c0fa08$78c48000$fb5be33f@computer> <20010621004350.A8227@sill.silmarill.org>
Message-ID: <004101c0fad6$90c74e20$ce70b4d1@computer>

Cool. I didn't know that. Is it generally better to convert strings to
integers, rather than use input()? When would input() be appropriate?
Thanks,
Josh

----- Original Message -----
From: <sill@optonline.net>
To: <tutor@python.org>
Sent: Wednesday, June 20, 2001 9:43 PM
Subject: Re: [Tutor] Calculator functions part II


> On Wed, Jun 20, 2001 at 09:13:04PM -0700, Josh Gregorio wrote:
> > Here is what I did:
> >
> > a = input("First number" )
> > b = input("Second number" )
> > answer = a * b
> > print "The answer is %d " % (answer)
> >
> > This worked on my box. Was there a reason to use raw_input?
> >
> > Josh
>
> input() executes results so if you make a typo it may mess up your program
> or even delete files (that'd be quite a typo though). Also, it may be a
security
> threat.
>
> --
> Jupiter and Saturn Oberon Miranda
> And Titania Neptune Titan
> Stars can frighten
>         - Syd
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From NHYTRO@compuserve.com  Fri Jun 22 07:04:54 2001
From: NHYTRO@compuserve.com (Sharriff Aina)
Date: Fri, 22 Jun 2001 02:04:54 -0400
Subject: [Tutor] Sorting against another list
Message-ID: <200106220205_MC3-D6A6-6E73@compuserve.com>

Hi!

I have a list that is created dynamically, how do I sort this list so tha=
t
it matches amother "mater template" list?

example:
[ 'aa', 'qq', 'ttt', 'hh']  # master list

my dynamic list cotains all or only a few of the elements in the master
list:

['ttt', 'hh', 'aa'] ### i would like to sort it to produce ['aa''ttt',
'hh']  accoriding to the sequense in the master list

or [ 'hh', 'qq' 'ttt'] ### would like ['qq', 'ttt', 'hh']
 =

I would like to sort these example list so that they at least follow the
order of the master list.


Thanks for any ideas


Sharriff


From scarblac@pino.selwerd.nl  Fri Jun 22 07:23:05 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 22 Jun 2001 08:23:05 +0200
Subject: [Tutor] Sorting against another list
In-Reply-To: <200106220205_MC3-D6A6-6E73@compuserve.com>; from NHYTRO@compuserve.com on Fri, Jun 22, 2001 at 02:04:54AM -0400
References: <200106220205_MC3-D6A6-6E73@compuserve.com>
Message-ID: <20010622082305.A17759@pino.selwerd.nl>

On  0, Sharriff Aina <NHYTRO@compuserve.com> wrote:
> I have a list that is created dynamically, how do I sort this list so that
> it matches amother "mater template" list?
> 
> example:
> [ 'aa', 'qq', 'ttt', 'hh']  # master list
> 
> my dynamic list cotains all or only a few of the elements in the master
> list:
> 
> ['ttt', 'hh', 'aa'] ### i would like to sort it to produce ['aa''ttt',
> 'hh']  accoriding to the sequense in the master list
> 
> or [ 'hh', 'qq' 'ttt'] ### would like ['qq', 'ttt', 'hh']
>  
> I would like to sort these example list so that they at least follow the
> order of the master list.

Hmm. Ok, we have two lists: 'master' and 'dynamic'.

You can give an argument to .sort(), an alternative way to compare two
items. You want to compare them using the order of the master list. The
easiest way to spell that is this:

def compare_using_master_list(a, b):
   # Compare the indices of the two items in the master list
   return cmp(master.index(a), master.index(b))

dynamic.sort(compare_using_master_list)

If any of the elements of dynamic doesn't occur in master, it gives an
exception, that seems like the right behavior to me.

If your lists are small (say, at most a few tens of items), this will work
fine. If they're bigger, the problem is that "master.index()" has to search
half the master list, on average, each time it's called. We can do better by
computing the indices first and caching them in a dictionary:

cachedict = {}
for i in range(len(master)):
   cachedict[master[i]] = i
   
def compare_using_master_cache(a, b):
   # Compare the cached index values of a and b
   return cmp(cachedict[a], cachedict[b])
   
dynamic.sort(compare_using_master_cache)

This should be faster with all but the most trivial lists (but I didn't test
it).

-- 
Remco Gerlich


From r.b.rigilink@chello.nl  Fri Jun 22 07:44:37 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Fri, 22 Jun 2001 08:44:37 +0200
Subject: [Tutor] Sorting against another list
References: <200106220205_MC3-D6A6-6E73@compuserve.com>
Message-ID: <3B32E955.D7AFA074@chello.nl>

Sharriff Aina wrote:
> 
> Hi!
> 
> I have a list that is created dynamically, how do I sort this list so that
> it matches amother "mater template" list?
> 
> example:
> [ 'aa', 'qq', 'ttt', 'hh']  # master list
> 
> my dynamic list cotains all or only a few of the elements in the master
> list:
> 
> ['ttt', 'hh', 'aa'] ### i would like to sort it to produce ['aa''ttt',
> 'hh']  accoriding to the sequense in the master list
> 
> or [ 'hh', 'qq' 'ttt'] ### would like ['qq', 'ttt', 'hh']
> 
> I would like to sort these example list so that they at least follow the
> order of the master list.
> 
> Thanks for any ideas
> 
> Sharriff
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


You can do a sort on a list with a custom comparison function

alist.sort(cmp_func)

The master list defines an order for it's elements, we can use this to
build a comparison function. Something like:

ordered_list = [ 'aa', 'qq', 'ttt', 'hh']

def cmp_func(a, b):
    '''A function returning
    -1 if a<b, 0  if a == b 1  if a>b
    ordering is based on the index of a and b in the global
'ordered_list'
    if a or b not in ordered_list, a ValueError is raised'''

    ord = ordered_list.index(a)-ordered_list.index(b)
    if ord < 0:
        return -1
    if ord > 0:
        return 1
    return 0

my_list = [ 'hh', 'qq', 'ttt']   
my_list.sort(cmp_func)
print mylist

will result in

['qq', 'ttt', 'hh']


Hope this helps.

Roeland
-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From dyoo@hkn.eecs.berkeley.edu  Fri Jun 22 08:42:54 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 22 Jun 2001 00:42:54 -0700 (PDT)
Subject: [Tutor] Sorting against another list
In-Reply-To: <200106220205_MC3-D6A6-6E73@compuserve.com>
Message-ID: <Pine.LNX.4.21.0106220031410.28894-100000@hkn.eecs.berkeley.edu>

On Fri, 22 Jun 2001, Sharriff Aina wrote:

> I have a list that is created dynamically, how do I sort this list so that
> it matches amother "mater template" list?
> 
> example:
> [ 'aa', 'qq', 'ttt', 'hh']  # master list
> 
> my dynamic list cotains all or only a few of the elements in the master
> list:
> 
> ['ttt', 'hh', 'aa'] ### i would like to sort it to produce ['aa''ttt',
> 'hh']  accoriding to the sequense in the master list
> 
> or [ 'hh', 'qq' 'ttt'] ### would like ['qq', 'ttt', 'hh']
>  
> I would like to sort these example list so that they at least follow the
> order of the master list.


Question: are we assuming that the dynamic list contains only elements
from the master list?  If so, then here's one idea to do this sort:

###
def myDirectedSort(master_list, dynamic_list):
    sorted_list = []
    for element in master_list:
        if element in dynamic_list:
            sorted_list.append(element)
    return sorted_list
###

Here's the idea of this function: let's march down the master list.  If
the element that we're looking at is in the dynamic list, it should
definitely be part of our sorted list.  By marching down the master list
in order, we're making sure that the sorted_list is always sorted relative
to the master list.  When we're done, we end up with a sorted list whose
elements must have come out of the dynamic_list.


This function assumes, however, that the dynamic_list is always a "subset"
of the master_list: it will break if we try something like this:

    s = myDirectedSort([1, 2, 3, 4], [3, 2, 2])

In this case, the myDirectedSort will not do the right thing, since there
are more '2's in the dynamic_list than in the master_list.

Hope this helps!



From learnpython@hotmail.com  Fri Jun 22 09:08:37 2001
From: learnpython@hotmail.com (Learn Python)
Date: Fri, 22 Jun 2001 08:08:37 -0000
Subject: [Tutor] trouble displaying instance attributes and methods
Message-ID: <F221W1JDvIr4N27HhXO00008ff1@hotmail.com>

hi all,

This is what i have,

class test:
   def __init__(self):
     self.data = 100
   def func(self):
     pass

if __name__ == '__main__':
   t = test()
   dir(t) ==> i want this to list data and func

But it does'nt list func :-(. What methods s'd i provide in addition so that 
dir( ) can recognize func() which happens to be a instance method attribute? 
I guess this s'd be possible bcos when i say
l = [] and then dir(l), i get all the list attributes. I want the same kind 
of behaviour for my class instance as well.

thanks
karthik.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



From dyoo@hkn.eecs.berkeley.edu  Fri Jun 22 09:10:21 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 22 Jun 2001 01:10:21 -0700 (PDT)
Subject: [Tutor] Calculator functions part II
In-Reply-To: <004101c0fad6$90c74e20$ce70b4d1@computer>
Message-ID: <Pine.LNX.4.21.0106220043510.28894-100000@hkn.eecs.berkeley.edu>

On Thu, 21 Jun 2001, Josh Gregorio wrote:

> Cool. I didn't know that. Is it generally better to convert strings to
> integers, rather than use input()? When would input() be appropriate?

It's usually better to convert strings to integers.  For your own casual
scripts, input() is perfectly fine.  In the outside world though, it's a
death-trap... *grin*

When we're entering commands into the Python interpreter, we can imagine
the following happening:

### simplified Python interpreter loop:
while 1:
    result = input(">>> ")
    print result
###

In a limited sense, the above is what we run when we type "python" at the
command prompt.  input() has as much power as we do, and anyone who can
enter something into input() can write their own one-line Python program.  
Using some imagination, you can see why we're hesitant to look at input()
favorably.

There are instances in the real world where people have done the
equivalent of plopping input() in their programs.  This is a Bad Thing, as
in Melissa Virus bad.


By the way, here's a small helper function that will make reading integers
safer for you:

###
def getInteger(prompt=None):
    try:
        if prompt: print prompt,
        return int(raw_input())
    except ValueError:               ## If bad things happen
        return getInteger(prompt)    ## try it again!
###

If you're not familiar with exceptions, you can think of it as telling
Python the following instructions: "Let's try the following ... And if
anything bad happens that deals with bad Values, let's do this ..."


Here's a small test of that function:

###
>>> mynumber = getInteger("Please enter a number:")
Please enter a number:muhahah
 Please enter a number:forty two
 Please enter a number:42

>>> mynumber
42
###

Some of the output formatting is off, but I hope the idea makes sense.  
Good luck!



From dyoo@hkn.eecs.berkeley.edu  Fri Jun 22 09:18:06 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 22 Jun 2001 01:18:06 -0700 (PDT)
Subject: [Tutor] trouble displaying instance attributes and methods
In-Reply-To: <F221W1JDvIr4N27HhXO00008ff1@hotmail.com>
Message-ID: <Pine.LNX.4.21.0106220111160.28894-100000@hkn.eecs.berkeley.edu>

On Fri, 22 Jun 2001, Learn Python wrote:

> 
> hi all,
> 
> This is what i have,
> 
> class test:
>    def __init__(self):
>      self.data = 100
>    def func(self):
>      pass
> 
> if __name__ == '__main__':
>    t = test()
>    dir(t) ==> i want this to list data and func
> 
> But it does'nt list func :-(. What methods s'd i provide in addition so that 

One small thing you forgot: you need to print the result of the
dir(); otherwise, you won't see anything.


Fixing that bug will still show some unusual behavior though:

###
>>> class test:
...     def __init__(self):
...         self.data = 100
...     def func(self): pass
... 
>>> t = test()
>>> dir(t)
['data']
###

As you might notice, t's dir() doesn't list func() out.  The reason is
because the methods stick around in the class, not the method, to avoid
duplicating the function over and over for each instance.  If we try
calling a method of an instance, and if it's not in the dir() of the
instance, Python will automagically look into the class itself for the
definition.

Let's use dir() on the class:

###
>>> dir(test)
['__doc__', '__init__', '__module__', 'func']
###


Hope this helps!



From scarblac@pino.selwerd.nl  Fri Jun 22 09:19:02 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 22 Jun 2001 10:19:02 +0200
Subject: [Tutor] trouble displaying instance attributes and methods
In-Reply-To: <F221W1JDvIr4N27HhXO00008ff1@hotmail.com>; from learnpython@hotmail.com on Fri, Jun 22, 2001 at 08:08:37AM -0000
References: <F221W1JDvIr4N27HhXO00008ff1@hotmail.com>
Message-ID: <20010622101902.A17983@pino.selwerd.nl>

On  0, Learn Python <learnpython@hotmail.com> wrote:
> This is what i have,
> 
> class test:
>    def __init__(self):
>      self.data = 100
>    def func(self):
>      pass
> 
> if __name__ == '__main__':
>    t = test()
>    dir(t) ==> i want this to list data and func
> 
> But it does'nt list func :-(. What methods s'd i provide in addition so that 
> dir( ) can recognize func() which happens to be a instance method attribute? 
> I guess this s'd be possible bcos when i say
> l = [] and then dir(l), i get all the list attributes. I want the same kind 
> of behaviour for my class instance as well.

Python instances simply don't work that way - the class has methods, the
instance doesn't.

You do 'self.data = 100', so the instance has the 'data' attribute, but the
function func() is defined in the class.

When you do t.func(), Python first looks for 'func' in the instance, where
it doesn't find it. Then, because t is an instance, it looks in the
instance's class, where the method is found, and this is when the 'self'
argument is filled in. It's therefore quite important to the way Python works.

Lists are different because they're not instances of some class written
Python; they're a type, written in C. Types and classes are different.

You can make your own function that recursively shows the dir() of the
instance and its base classes, e.g.

def deep_dir(object):
   import types
   
   result = dir(object)
   if type(object) is types.InstanceType:
      result.extend(deep_dir(object.__class__))
   elif type(object) is types.ClassType:
      for base in object.__bases__:
         result.extend(deep_dir(base))

   return result

But you can't do it with normal dir().

Why do you need it? Maybe there is some better way.

-- 
Remco Gerlich


From jprobinson@oxford.gov.uk  Fri Jun 22 10:00:40 2001
From: jprobinson@oxford.gov.uk (ROBINSON Julian)
Date: Fri, 22 Jun 2001 10:00:40 +0100
Subject: [Tutor] [Edu-sig] [Idle-dev] IDLE's save-before-run requireme
 nt
Message-ID: <EE55ED92A316D411B59B009027DC722602A6DC93@exchangesrv.oxford.gov.uk>

This is a multi-part message in MIME format.
--------------InterScan_NT_MIME_Boundary
Content-Type: text/plain

> kbk@shore.net wrote
> 
> 4. Very usable by relatively inexperienced people.
> 
> IMHO IDLE should remain at roughly the (apparent) level of complexity it's
> at
> (or less?) to avoid reducing its usability for beginning/intermediate
> programmers.
> 
- As someone who's working through the tutorials IDLE is perfect. I don't
need a fancy
IDE to get the hang of the language. When I get enough experience to write
large programmes
then my need for an all singing & dancing IDE will increase, but until
then......
- The set-up for IDLE is easy, I managed to do it first time. I downloaded
JBuilder and this package took me ages to set up so that I could use it even
halfway properly, this has put me off 'getting into' Java. Whereas after
about 2 mins, following the clear instructions I was able to start entering
Python code and see how the language worked, and have never looked
back.......



--------------InterScan_NT_MIME_Boundary
Content-Type: text/plain;
	name="InterScan_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="InterScan_Disclaimer.txt"

.
This email and any files transmitted with it are confidential and intended solely for the use of the individual to whom they are addressed.  
If you received this email in error please notify the sender by return email or contact Oxford City Council's IS dept. 01865-252111.
http://www.oxford.gov.uk
.

--------------InterScan_NT_MIME_Boundary--


From learnpython@hotmail.com  Fri Jun 22 11:33:22 2001
From: learnpython@hotmail.com (Learn Python)
Date: Fri, 22 Jun 2001 10:33:22 -0000
Subject: [Tutor] trouble displaying instance attributes and methods
Message-ID: <F93tPGtPrPrvCWO6hm80000ebe9@hotmail.com>

thanks daniel,

does this mean that given a class instance i w'd'nt be able to do a look up 
on all the methods supported by that class?
assuming that i have no idea of the method names ( iunderstand i can use 
getattr() if i know the name)

one more doubt.

If i have
s = 'hello'
l = []
dir(s) ==> gives all the attribute methods of string
dir(l) ==> also gives all the attribute methods of list

Then s'd'nt there be a way to get my class's instance methods as well?

thanks
karthik.






>From: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>
>To: Learn Python <learnpython@hotmail.com>
>CC: tutor@python.org
>Subject: Re: [Tutor] trouble displaying instance attributes and methods
>Date: Fri, 22 Jun 2001 01:18:06 -0700 (PDT)
>
>On Fri, 22 Jun 2001, Learn Python wrote:
>
> >
> > hi all,
> >
> > This is what i have,
> >
> > class test:
> >    def __init__(self):
> >      self.data = 100
> >    def func(self):
> >      pass
> >
> > if __name__ == '__main__':
> >    t = test()
> >    dir(t) ==> i want this to list data and func
> >
> > But it does'nt list func :-(. What methods s'd i provide in addition so 
>that
>
>One small thing you forgot: you need to print the result of the
>dir(); otherwise, you won't see anything.
>
>
>Fixing that bug will still show some unusual behavior though:
>
>###
> >>> class test:
>...     def __init__(self):
>...         self.data = 100
>...     def func(self): pass
>...
> >>> t = test()
> >>> dir(t)
>['data']
>###
>
>As you might notice, t's dir() doesn't list func() out.  The reason is
>because the methods stick around in the class, not the method, to avoid
>duplicating the function over and over for each instance.  If we try
>calling a method of an instance, and if it's not in the dir() of the
>instance, Python will automagically look into the class itself for the
>definition.
>
>Let's use dir() on the class:
>
>###
> >>> dir(test)
>['__doc__', '__init__', '__module__', 'func']
>###
>
>
>Hope this helps!
>

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



From guido@digicool.com  Fri Jun 22 14:31:13 2001
From: guido@digicool.com (Guido van Rossum)
Date: Fri, 22 Jun 2001 09:31:13 -0400
Subject: [Tutor] Re: [Edu-sig] RE: [Idle-dev] IDLE's save-before-run r equirement
In-Reply-To: Your message of "Thu, 21 Jun 2001 23:16:10 EDT."
 <LNBBLJKPBEHFEDALKOLCKEOCKJAA.tim.one@home.com>
References: <LNBBLJKPBEHFEDALKOLCKEOCKJAA.tim.one@home.com>
Message-ID: <200106221331.f5MDVEP06120@odiug.digicool.com>

> [Mark Hammond]
> > Pythonwin does use scintilla for its console.  You are correct that it
> > is not integrated with the editor as tightly as IDLE.  This is mainly
> > doe to the fact pythonwin uses "... " as a secondary prompt, and also
> > complications with the scintilla lexer.
> 
> FWIW, I wish IDLE used "... " too -- switching between a DOS-box Python and
> IDLE is jarring.  In addition, the IDLE shell uses hard tab characters stuck
> at 8-space indents (the latter is a limitation of the Tk Text widget), while
> all the other edit windows use no hard tab characters and 4-space indents.
> So in a *typical* IDLE session (where I've also got a DOS-box Python
> running), I'm dealing with three distinct code presentations.  I can't say
> it's a physical burden <wink>, but somehow or other it is tiring!

Actually, I just downloaded and ran the latest Pythonwin available
without downloading ActivePython, and it has roughly the same
characteristics as IDLE: in its console window it uses hard tabs at 8
space distances, in its module editing it uses 4 spaces.  IDLE uses
the same defaults.

Regarding the "..." prompt: I happen to hate this, and in Pythonwin it
makes copying and pasting multi-line text from the console into a
module window a pain (you have to manually remove all the "...").

> > As a "meta comment", over 12 months ago I added a feature to Pythonwin
> > so that new IDLE extensions could be used directly by both Pythonwin
> > and IDLE.  In that time, not a single extra extension has been added
> > (that I saw) and IDLE changed its extension loading mechanism.

Yes, but the API that extensions have to conform to didn't change.
It's just the sad case that in the last 12 months *my* interest in (or
at least my ability to work on) IDLE has lapsed, for a variety of
reasons, and that may have affected others' interest -- until the
recent thread.

> > So while these things all sound good in theory, the reality is that
> > people need to actually _do_ it rather than speculate about how others
> > could do it.
> 
> I'm not sure, Mark, but you and I may be the only two people in the History
> of the Universe to actively cooperate on sharing code between two GUI
> systems (the auto-indent system shared by PythonWin and IDLE).  It wasn't
> that painful, but I recall being utterly unable to get anyone else
> interested in playing with us at the time.  Since then, IDLE has stagnated
> but remained useful, while you've gone on to fame and riches.  See?  There's
> no payback to cooperation <wink>.

:-)

--Guido van Rossum (home page: http://www.python.org/~guido/)


From britt_green@hotmail.com  Fri Jun 22 17:13:46 2001
From: britt_green@hotmail.com (Britt Green)
Date: Fri, 22 Jun 2001 09:13:46 -0700
Subject: [Tutor] C++ Tutorial List?
Message-ID: <F109S6AATiyhGvDpEDi0000155a@hotmail.com>

I was wondering if anyone knew of a list similar to this one, but devoted to 
C++?

Britt

--
It is pitch black. You are likely to be eaten by a grue.
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



From dyoo@hkn.eecs.berkeley.edu  Fri Jun 22 19:00:41 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 22 Jun 2001 11:00:41 -0700 (PDT)
Subject: [Tutor] C++ Tutorial List?
In-Reply-To: <F109S6AATiyhGvDpEDi0000155a@hotmail.com>
Message-ID: <Pine.LNX.4.21.0106221029350.3529-100000@hkn.eecs.berkeley.edu>

On Fri, 22 Jun 2001, Britt Green wrote:

> I was wondering if anyone knew of a list similar to this one, but
> devoted to C++?

Hmmm... I haven't been able to find anything too official, but the link
here:

    http://www.faqs.org/faqs/C-faq/learn-c-cpp-today/

has a bunch of resources you can check out about learning C and C++.  
Also, the comp.lang.c++ newsgroup would probably be a good place to ask
questions.

    http://www.ibiblio.org/usenet-i/groups-html/comp.lang.c++.html

has some of the usage statistics on this newsgroup.



From csmith@blakeschool.org  Fri Jun 22 22:14:55 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Fri, 22 Jun 2001 16:14:55 -0500
Subject: [Tutor] Accessing calling module's globals in a module
Message-ID: <fc.004c4b6b0075bcfe004c4b6b0075bcfe.75bda8@blakeschool.org>

I would like to be able to print a list of variable names and id's in a 
function.  From the documentation I have been able to determine that 
the code below is wrong for 2 reasons:

>>> def idof2(*v):
...  n=globals().keys()
...  for vi in v:
...   for ni in n:
...    if id(ni)==id(vi): print ni,vi
... 
>>> idof2(a,b)
>>> 

1)  when loaded from a module, globals() only accessess the globals of 
the module not the globals of the module that called the function.

2)  the id of the global key (ni above) is not the same thing as the id of
the object associated with the key.  In writing this I caught the 
second error and replaced the definition with:

>>> a=2
>>> b=3
>>> def id1(*v):
...  n=globals()
...  for vi in v:
...   for nk in n.keys():
...    if id(n.get(nk))==id(vi):
...     print nk + "'s id = "+str(id(vi))
... 
>>> id1(a,b)
a's id = 14986968
b's id = 14986920

HOWEVER, if I put this in a module and try to import it it no longer 
works b/c of problem (1).  I've looked through the (very useful but no 
longer active(?) FAQ) and the documentation.  Can anyone point me 
toward how to access the calling modules global variables?

Thanks.

/c



From kpower2@home.com  Sat Jun 23 00:28:40 2001
From: kpower2@home.com (Ken Power)
Date: Fri, 22 Jun 2001 18:28:40 -0500
Subject: [Tutor] C++ Tutorial List?
In-Reply-To: <Pine.LNX.4.21.0106221029350.3529-100000@hkn.eecs.berkeley.edu>
Message-ID: <AKEDIMOHFMJFLDCDCNPDGEBNCAAA.kpower2@home.com>

Look for the news group
alt.comp.lang.learn.c-c++


> I was wondering if anyone knew of a list similar to this one, but
> devoted to C++?



From jessw@loop.com  Sat Jun 23 01:03:35 2001
From: jessw@loop.com (Jesse W)
Date: Fri, 22 Jun 2001 17:03:35 -0700
Subject: [Tutor] Accessing calling module's globals in a module
In-Reply-To: <fc.004c4b6b0075bcfe004c4b6b0075bcfe.75bda8@blakeschool.org>
Message-ID: <3B337A67.32758.144C0483@localhost>

Christopher Smith wrote:

> I would like to be able to print a list of variable names and id's in
> a function.

I am probably misunderstanding what you are trying to do, but would 
this work?
def show_ids(func):
    """Return a list of name and id tuples from a given function."""
    ans=[]
    for ref in dir(func):
        ans.append((ref, eval('id('+func.func_name+'.'+ref+')')))
    return ans
If it _is_ what you need, I will explain how it works in a future 
message.

		Wow-what-a-nice-list-l'y,
					Jesse W



From dyoo@hkn.eecs.berkeley.edu  Sat Jun 23 08:04:18 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 23 Jun 2001 00:04:18 -0700 (PDT)
Subject: [Tutor] hello
In-Reply-To: <5.1.0.14.0.20010621230718.009fa7d0@mail.aacc.cc.md.us>
Message-ID: <Pine.LNX.4.21.0106220013450.28894-100000@hkn.eecs.berkeley.edu>

On Thu, 21 Jun 2001, Seabrook, Richard wrote:

> This may sound a little crazy but I seem to recall an identical message 
> about 8-10 years ago, might have been in the old comp.lang.python list or 
> whatever we were using then. Anyone ever heard of this guy or email handle?
> At any rate, I suggest you ignore it.

Let's give Michael the benefit of the doubt on this one.  I know that the
word "hack" has some negative connotations associated with it, but he
might mean well by it.  ESR's introduction to hacking mentions Python as a
good language to learn programming, so we shouldn't get too riled up at
the word "hack".

However, if he says "hacking" but means "cracking", then he's going to get
bored of us quickly, since we seem to chat incoherantly about text
editors, loops, and programs to solve round robin tournaments.  *grin*


> hello there,, this is mike and i wanted to learn how to use this
> program i think this program is to teach me how to hack im not sure
> but i would like to know

No problem.  We're a tutor group for the Python programming language, a
programming language that we think is fairly fun to learn.  If you want to
learn some more about Python, you can take a look at:

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

There are some tutorials on this link, and you can browse through them to
see if this is the kind of stuff you're looking for.  Feel free to ask us
questions, and we'll do our best to answer them.



From rol9999@attglobal.net  Sat Jun 23 15:59:18 2001
From: rol9999@attglobal.net (Roland Schlenker)
Date: Sat, 23 Jun 2001 09:59:18 -0500
Subject: [Tutor] Accessing calling module's globals in a module
References: <fc.004c4b6b0075bcfe004c4b6b0075bcfe.75bda8@blakeschool.org>
Message-ID: <3B34AEC6.B5962C1@attglobal.net>

Christopher Smith wrote:
> 
> I would like to be able to print a list of variable names and id's in a
> function.  From the documentation I have been able to determine that
> the code below is wrong for 2 reasons:
> 
> >>> def idof2(*v):
> ...  n=globals().keys()
> ...  for vi in v:
> ...   for ni in n:
> ...    if id(ni)==id(vi): print ni,vi
> ...
> >>> idof2(a,b)
> >>>
> 
> 1)  when loaded from a module, globals() only accessess the globals of
> the module not the globals of the module that called the function.
> 
> 2)  the id of the global key (ni above) is not the same thing as the id of
> the object associated with the key.  In writing this I caught the
> second error and replaced the definition with:
> 
> >>> a=2
> >>> b=3
> >>> def id1(*v):
> ...  n=globals()
> ...  for vi in v:
> ...   for nk in n.keys():
> ...    if id(n.get(nk))==id(vi):
> ...     print nk + "'s id = "+str(id(vi))
> ...
> >>> id1(a,b)
> a's id = 14986968
> b's id = 14986920
> 
> HOWEVER, if I put this in a module and try to import it it no longer
> works b/c of problem (1).  I've looked through the (very useful but no
> longer active(?) FAQ) and the documentation.  Can anyone point me
> toward how to access the calling modules global variables?
> 
> Thanks.
> 
> /c
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

Simply pass your caller's globals to the function.

def id1(callerGlobals, *v):
    for vi in v:
        for k in callerGlobals.keys():
            if id(callerGlobals.get(k)) == id(vi):
                print k + "'s id = " + str(id(vi))

Use as:

id1(globals(), a, b)

I am curious, why do you need to know an objects memory location.

If you want to know if two objects are the same, use the keyword "is".

Python 2.0 (#0, Apr 14 2001, 21:24:22) 
[GCC 2.95.3 20010219 (prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> a = [1]
>>> b = [1]
>>> a is b
0
>>> c = a
>>> c is a
1
>>> c is b
0
>>> 

Roland Schlenker


From jessw@loop.com  Sat Jun 23 19:29:27 2001
From: jessw@loop.com (Jesse W)
Date: Sat, 23 Jun 2001 11:29:27 -0700
Subject: [Tutor] What are you all up to?
Message-ID: <3B347D97.16808.18409E90@localhost>

<color><param>0100,0100,0100</param>Hello Pythoneers,


	What are you all up to?  What projects are you working on?


	I am a 17 year old Python hacker-in-training.  I tend to write re-
implementations of games and interesting graphics hacks.  I am 
currently writing re-implementation of Miles Bones, a car racing 
card game, and a variation of the card game Uno, called Hot Death 
Uno.  I wrote the beginnings of a module to access and modify MIDI 
file data in Python, and many other small programs.


								Thank you for your time,

									Jesse W

<nofill>


From ak@silmarill.org  Sat Jun 23 20:20:55 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Sat, 23 Jun 2001 15:20:55 -0400
Subject: [Tutor] What are you all up to?
In-Reply-To: <"from jessw"@loop.com>
References: <3B347D97.16808.18409E90@localhost>
Message-ID: <20010623152055.A20076@sill.silmarill.org>

On Sat, Jun 23, 2001 at 11:29:27AM -0700, Jesse W wrote:
> Hello Pythoneers, 
> 
> 	What are you all up to?  What projects are you working on? 
> 
> 	I am a 17 year old Python hacker-in-training.  I tend to write 
> re- implementations of games and interesting graphics hacks.  I am  
> currently writing re-implementation of Miles Bones, a car racing  card 
> game, and a variation of the card game Uno, called Hot Death  Uno.  I 
> wrote the beginnings of a module to access and modify MIDI  file data 
> in Python, and many other small programs. 
> 
> 								Thank 
> you for your time, 
> 									
> Jesse W 

Hey,

I'm 21 and I completed one fairly usable program, cymbaline (learning mp3
player) and I also wrote a small irc bot and time management program that
I have to rewrite because it doesn't seem to work anymore. I have tons of
plans to write a game, a window manager, an irc client, some audio/music
program but all of these are too complex for me to do well right now.

I also wrote a dozen or two small scripts, but didn't everybody? ;P

> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline


From dyoo@hkn.eecs.berkeley.edu  Sat Jun 23 20:23:37 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 23 Jun 2001 12:23:37 -0700 (PDT)
Subject: [Tutor] What are you all up to?
In-Reply-To: <3B347D97.16808.18409E90@localhost>
Message-ID: <Pine.LNX.4.21.0106231216370.17875-100000@hkn.eecs.berkeley.edu>

On Sat, 23 Jun 2001, Jesse W wrote:

> 	What are you all up to?  What projects are you working on?

Welcome!  At the moment, no big projects.


> 	I am a 17 year old Python hacker-in-training.  I tend to write
> re- implementations of games and interesting graphics hacks.  I am
> currently writing re-implementation of Miles Bones, a car racing card
> game, and a variation of the card game Uno, called Hot Death Uno.  I
> wrote the beginnings of a module to access and modify MIDI file data
> in Python, and many other small programs.

Very cool!  I hope that we can help answer any questions you have.


Good luck!



From allan.crooks@btinternet.com  Sat Jun 23 20:38:27 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Sat, 23 Jun 2001 20:38:27 +0100
Subject: [Tutor] What are you all up to?
Message-ID: <E15DtGx-000KYh-00@mk-smarthost-1.mail.uk.worldonline.com>

> What are you all up to?  What projects are you working on?

An odd question, but since we're meant to answer people's questions, I suppose I should do the right thing and reply. :)

I'm 21, I've written one little measly Python script. Oh, and I'm supposedly helping out with the PythPat package (http://pythpat.sourceforge.net).

I'm also tempted to get involved in some open source project (in Python or Java, I do both), but I have too much "life" that needs taking care of. :)

I've just finished University, so I don't have really anything that I *have* to code at the present time. So I'm yet to put Python to good use. :(

Allan.



From tracey@transmeta.com  Sat Jun 23 20:51:24 2001
From: tracey@transmeta.com (Tracey Luke)
Date: Sat, 23 Jun 2001 12:51:24 -0700
Subject: [Tutor] What are you all up to?
In-Reply-To: <E15DtGx-000KYh-00@mk-smarthost-1.mail.uk.worldonline.com>; from allan.crooks@btinternet.com on Sat, Jun 23, 2001 at 08:38:27PM +0100
References: <E15DtGx-000KYh-00@mk-smarthost-1.mail.uk.worldonline.com>
Message-ID: <20010623125124.E8029@transmeta.com>

> > What are you all up to?  What projects are you working on?

Well, I'm new to Python so I'm still working on understand it. I have no actual
projects right now, but as I am a sys admin I'm sure I'll figure some out. I've
been attempting to learn Perl for the last few months and while I 'get' a lot
of it I'm unable to sit down and write programs without ending up in tears of
frustration. 

My dept at work is perl-centric, with one depertment (elsewhere in the company)  deviating into Ptyhon (needless to say, my department doesn't like this other one), but I was told to give Python a shot since I had issues with Perl. Here I am. I must admit it feels more comfortable to me.

A rather brief introduction but I'm here just absorbing everything and learning
as we go along.

~Tracey 


From budgester@budgester.com  Sat Jun 23 21:22:32 2001
From: budgester@budgester.com (Martin Stevens)
Date: Sat, 23 Jun 2001 21:22:32 +0100
Subject: [Tutor] What are you all up to?
In-Reply-To: <E15DtGx-000KYh-00@mk-smarthost-1.mail.uk.worldonline.com>; from allan.crooks@btinternet.com on Sat, Jun 23, 2001 at 08:38:27PM +0100
References: <E15DtGx-000KYh-00@mk-smarthost-1.mail.uk.worldonline.com>
Message-ID: <20010623212232.A20736@budgester.com>

> > What are you all up to?  What projects are you working on?
> 

I'm 28, UK, Sysadmin

Well, i'm still learning python but I find it usefull for knocking up
quick scripts in the sysadmin that I'm doing, but I'm mainly using it
to get my head back into the programming space, I was a hell of a lot
better at coding about 10 years ago but lost it due to being on a 
helpdesk for 3 years and not wanting to mess around with computers
for fun at home anymore, but I then found linux and it kinda reminded
me of the fun i used to have on my C64 and Amiga.

But mainly learning python for shits and giggles baby.

Martin



From kalle@gnupung.net  Sat Jun 23 21:25:04 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Sat, 23 Jun 2001 22:25:04 +0200
Subject: [Tutor] What are you all up to?
In-Reply-To: <3B347D97.16808.18409E90@localhost>
References: <3B347D97.16808.18409E90@localhost>
Message-ID: <20010623222504.B1990@gnupung.net>

Sez Jesse W:
> Hello Pythoneers, 
> 
> 	What are you all up to?  What projects are you working on? 

The latest thing I wrote was a traceroute implementation, to get more
familiar with sockets.  I'm also working on a log file parser for Linux
firewalls.

More generally, the programs I write tend to fall in one of two categories:
1) Scripts to help with system administration or associated text processing.
2) Implementations of concepts I'm learning about.

Peace,
  Kalle
-- 
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
 [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]


From jessw@loop.com  Sat Jun 23 21:29:30 2001
From: jessw@loop.com (Jesse W)
Date: Sat, 23 Jun 2001 13:29:30 -0700
Subject: [Tutor] The philosophy of versions
Message-ID: <3B3499BA.32214.18AE8AE4@localhost>

Honors to all tutor-ians,

	My major difficulty in Python is not precisely a programming 
problem but a meta-programming problem.  I (incorrectly) think of 
my programs as inexorably moving toward a final state of perfection, 
and I therefore have something of a mental block on the idea of 
releasing versions or writing changelogs and things like that.  I am 
quite aware that this is not a sane view, and I would like to work 
through this block, but I have not yet figured out how to do it.  If any 
of you have any comments, ideas, or responses to this, please post.

					Thank you for your time,
						Jesse W


From jessw@loop.com  Sat Jun 23 21:29:30 2001
From: jessw@loop.com (Jesse W)
Date: Sat, 23 Jun 2001 13:29:30 -0700
Subject: [Tutor] What are you all up to?
In-Reply-To: <20010623152055.A20076@sill.silmarill.org>
References: <"from jessw"@loop.com>
Message-ID: <3B3499BA.32731.18AE8A88@localhost>

Hello, sill, ak, or what-have-you,

sill@optonline.net wrote:
> Hey,
> 
> I'm 21 and I completed one fairly usable program, cymbaline (learning
> mp3 player) and I also wrote a small irc bot and time management
> program that I have to rewrite because it doesn't seem to work
> anymore. I have tons of plans to write a game, a window manager, an
> irc client, some audio/music program but all of these are too complex
> for me to do well right now.
Oy! Do I know about having plans that are too complicated to 
_actually_ write! 
> I also wrote a dozen or two small scripts, but didn't everybody? ;P
I think so. :-)
> 
> -- 
> Cymbaline: intelligent learning mp3 player - python, linux, console.
> get it at: http://silmarill.org/cymbaline
I will check it out.

							Jesse W 


From rab121@york.ac.uk  Sat Jun 23 21:37:08 2001
From: rab121@york.ac.uk (Russell)
Date: Sat, 23 Jun 2001 21:37:08 +0100
Subject: [Tutor] What are you all up to?
References: <3B347D97.16808.18409E90@localhost>
Message-ID: <3B34FDF4.31C1F078@york.ac.uk>

Jesse W wrote:
>What are you all up to? What projects are you working on?
My current (and first ever - I only started reading 'Learning Python' a
couple of weeks ago) is a simple analyser for log files produced by a
program that I use.  I'm really chuffed at how well it is coming
together, mostly I think because of Python's niceness.
 
>I am a 17 year old Python hacker-in-training. I tend to write re- >implementations of games 
Strangely enough I have a big project in mind to rewrite a old board
game ;o)  Long time in the future though, skills to learn ;o)

>and many other small programs.
This I think is one of the joys of Python, or any such language.  I
tried to learn to program in Visual Basic a few years back and used to
get so tied up in making things look pretty and adding new bits because
it looked good.  Now I pop open my text editor, jam down some code and I
have a working (well, almost) little thing that does something useful
for me.

Russell
-- 
When you look up into the night sky and see the millions of glittering
stars, do you ever stop and wonder whether there might be another family
somewhere up there, living their peaceful pink lives on some distant
blue moon?


From allan.crooks@btinternet.com  Sat Jun 23 23:50:07 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Sat, 23 Jun 2001 23:50:07 +0100
Subject: [Tutor] method to print in interpreter
Message-ID: <E15DwGS-000PEI-00@mk-smarthost-1.mail.uk.worldonline.com>

[str / repr]
> >I can explain why this is like it is, if you want. :)
> 
> Well, go ahead and give me a little more.  But keep in mind
> that I'm pretty new to this. 

Well, according to the online documentation (http://www.python.org/doc/lib/built-in-funcs.html), repr is used to return a string which when specified in eval, will return the same object.

For example:

>>> class MyObject:
..   def __init__(self, val):
..      self.val = val
..   def __repr__(self):
..      return "MyObject(%d)" % self.val
..   def __str__(self):
..      return "A MyObject that contains a value of %d." % self.val
..
>>> m1 = MyObject(12)
>>> print m1
A MyObject that contains a value of 12.
>>> m1
MyObject(12)
>>> s1 = `m1`
>>> s1
'MyObject(12)'
>>> m2 = eval(s1)
>>> m2
MyObject(12)
>>> m2.__class__
<class __main__.MyObject at 0079424C>
>>> print m2
A MyObject that contains a value of 12.

First of all, we create an m1 object. When we print m1, it uses the str representation. When just stating m1, it uses the repr REPResentation (now you know where repr comes from :). When we write `m1`, it converts m1 into the repr string (which we assign to s1).

Now, with the eval function, we supply a string object, which when executed should return an object which is the same as m1 (because we created the string s1 was based on the representation of m1).

So, in short, str defines a user readable way of describing an object, while repr defines a string which can be evaluated back to an object.

Now repr won't work with everything. Try:

eval(`apply`)

for example. But that's the difference between the two methods.

Now, it may or may not be easy for you to define a REPResentation for all objects (not all the time, anyway). You can choose to define repr in that way, but it may be more useful for you (especially in interactive mode) to make repr return the same as str does (i.e. a nice descriptive string).

> But where are these files?  I don't even find "cpickle".  Is this 
> just code that is compiled in with the application itself?

According to a previous post, they aren't distributed normally with the rest of the interpreter (well, I can say that it doesn't come with the Windows version of Python 2.1).

If you really want to see it, you could probably check out the online CVS repository (http://python.sf.net/). If you can't find it, I'll search it out for you. :)

Allan.



From csmith@blakeschool.org  Sun Jun 24 00:09:06 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Sat, 23 Jun 2001 18:09:06 -0500
Subject: [Tutor] Re: [Pythonmac-SIG] Interpreter on Mac
In-Reply-To: <E15DpqG-0006H8-00@mail.python.org>
References: <E15DpqG-0006H8-00@mail.python.org>
Message-ID: <fc.004c4b6b0075c44c3b9aca00a858a25d.75c450@blakeschool.org>

pythonmac-sig@python.org writes regarding the now-available patch that
fixes the Mac IDE:
>Download it via http://www.cwi.nl/~jack/macpython.html and please let
>me know wether it fixes the problem.

>>> print "Hello, World! :-)"
Hello, World! :-)

Thanks, Jack.  

Two notes, too.

1)  I am clearly not running Carbon (thanks for pointing out the 
obvious, Just):

Python 2.1 (#92, Apr 24 2001, 23:59:23)  [CW PPC GUSI2 THREADS] on mac

2)  This pressing-end-kills-the-interpreter behavior is only partly 
bad. It only boots you out of the interpreter IFF the cursor is on the 
last line.  If you have moved the cursor off the last line, pressing 
<end> moves you to the last line (and repeats the >>> prompt or else 
\n's the line you had been editing).  My personal hand-tic work-around 
is to press the up arrow before pressing the <end> key.  Could this be 
done through the software?  Catch the <end> key and preface it with an 
up-arrow first?

On the other hand, if it really is a ctrl-D that is being generated 
and for universal behavior you want the interpreter to quit at a 
ctrl-d then this isn't a good work around.

Finally, thanks for the help.  I've subscribed to tutor, edu-sig, and 
this group to help me learn the language b/c I am going to be teaching 
our school's first comp sci course next spring with Python.  This is 
my week of intense preparation before other concerns have to take 
priority this summer.  You've helped me make great returns on the 
investment.

Whoever has put together the Windows package has done a great job, 
too.  I helped my cousin who just graduated from HS get Python set up 
last night on her machine which runs windows.  I was impressed with 
how out-of-the box it was *with identical documentation* (Language 
Ref, Tutorial, etc...) built into the archive.  This is going to be a 
big plus when I have students who can set up Python at home under 
either Mac or Windows.

/c
-------------------------------------------------------------
Have you ever sung in Latin?  The sounds are so nice to sing.
Have you ever coded in Python? It's very much the same thing.



From pursang@interact.net.au  Sun Jun 24 10:21:50 2001
From: pursang@interact.net.au (John Murray)
Date: Sun, 24 Jun 2001 09:21:50 +0000
Subject: [Tutor] The philosophy of versions
In-Reply-To: <3B3499BA.32214.18AE8AE4@localhost>
References: <3B3499BA.32214.18AE8AE4@localhost>
Message-ID: <01062409215000.01436@localhost.localdomain>

On Saturday 23 June 2001 20:29, you wrote:
> Honors to all tutor-ians,
>
> 	My major difficulty in Python is not precisely a programming
> problem but a meta-programming problem.  I (incorrectly) think of
> my programs as inexorably moving toward a final state of perfection,

I  think that one of the most important things about programming is knowing 
when to stop. Does that text editor *really* need a built in flight 
simulator? ;-)

Cheers
John


From csmith@blakeschool.org  Sun Jun 24 01:55:50 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Sat, 23 Jun 2001 19:55:50 -0500
Subject: [Tutor] Accessing calling module's globals in a module
In-Reply-To: <3B34AEC6.B5962C1@attglobal.net>
References: <fc.004c4b6b0075bcfe004c4b6b0075bcfe.75bda8@blakeschool.org>
 <3B34AEC6.B5962C1@attglobal.net>
Message-ID: <fc.004c4b6b0075c473004c4b6b0075bcfe.75c49a@blakeschool.org>

Roland wrote about problem (1) below which I haven't yet solved:

> Christopher Smith wrote:
> > 
> > I would like to be able to print a list of variable names and 
> > id's in a function.  From the documentation I have been able to
> > determine that the code below is wrong for 2 reasons:
> > 
> > >>> def idof2(*v):
> > ...  n=globals().keys()
> > ...  for vi in v:
> > ...   for ni in n:
> > ...    if id(ni)==id(vi): print ni,vi
> > ...
> > >>> idof2(a,b)
> > >>>
> > 
> > 1)  when loaded from a module, globals() only accesses the 
> > globals of the module not the globals of the module that called 
> > the function.
> > 
> Simply pass your caller's globals to the function.
> 
> def id1(callerGlobals, *v):

That's a good way to solve the problem.  I guess my
imagination was stuck in the subroutine trying to figure out
how to reach back to the calling module.  But...

> 
> I am curious, why do you need to know an objects memory location.
> 

To show the identities of different objects all at once
instead of having to do several "is"s.  The question
originally arose like this:  the book I'm going through has
me checking the id's of things several times.  I want to
write a function that will allow me to pass the variables
that I'm interested in and it will show me the function names
and the values.  {Enter the modified version of the function
idof() that I posted.}  Now, I would like to move my clever
little function into my growing file of personal functions
from which I can load...and enter my dilemma: I can't seem to
figure out how to reach from the loaded module containing
"idof" back to the calling module.  While writing this it
occurred to me to write the following in a file name myf.py
located in the lib folder:

global globals

def f():
	global globals
	
	print dir()

So I'm trying to tell the module to make global the globals
(that maybe it would receive from the calling module) but
alas when I load and call f()...

Python 2.1 (#92, Apr 24 2001, 23:59:23)  [CW PPC GUSI2 THREADS] on mac
Type "copyright", "credits" or "license" for more information.
>>> import myf
>>> a=2
>>> myf.f()

I get a LOT printed regarding 'f', not the calling module:

{'f': <function f at 0x00cf3fc0>, '__doc__': None, '__file__':
'macintoshhd:  
**and 33 more lines**

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved., 'oct': <built-in function oct>, 'MemoryError':  
**and 23 more lines**

How would I use this beyond trying to solve my present
problem?  I might be able to have a function that sees if a
student is doing the right thing or not.  I tell them to pass
two variables that have the same id and *in my function* I
check them.  I don't have to write a clever parser in the
main program to see if they did the right thing.  In my
function I see if the id's are the same and then I print a
friendly message *including the names of the objects* that
tells them what they did wrong OR I can record what they did
in terms of variables (as opposed to id's which I wouldn't be
able to interpret...which raises abother possible solution: 
can you (as with ASCII codes and characters) go back and
forth between the id# and the associated variable name?

wishfully something like this:
>>> a=2
>>> id(2)
12335043  #some number
>>> nameof(12335043)
'a'

I'm also trying to learn my way around the object/local/global
environment...I'm used to programming in Fortran and Basic and this feels
a little like a house of mirrors at times but it's becoming
easier to orient myself.

/c



From toodles@yifan.net  Sun Jun 24 03:49:00 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Sun, 24 Jun 2001 10:49:00 +0800
Subject: [Tutor] What are you all up to?
In-Reply-To: <3B347D97.16808.18409E90@localhost>
Message-ID: <FPEHJJPEEOIPMAHOADBKKEEFCEAA.toodles@yifan.net>

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01C0FC9B.4704C800
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: base64

SG93ZHkgSmVzc2UsIEkgdGhvdWdodCBJJ2QgdGhyb3cgaW4gbXkgMSBjZW50IChBdXNzaWUgRG9s
bGFyISkNCg0KSSdtIGFsc28gYSAxNyB5ZWFyIG9sZCwgYnV0IEknbSBub3QgcmV3cml0aW5nIGdh
bWVzLi4ueWV0LiBUaGUgbGFzdCB0aGluZyBJIGRpZCB3YXMgYSByZWFsbHkgZG9kZ3kgTVVEIHNl
cnZlciBmcmFtZXdvcmsgY2FsbGVkIFBVRGRpbmcuLi5pZiB5b3Ugd2FudCB0byBjaGVjayBpdCBv
dXQ6DQpodHRwOi8vd3d3Lmxvd2Vyc3RhbmRhcmQuY29tL3B5dGhvbi91c2VsZXNzcHl0aG9uMS5o
dG1sDQpvciBtb3JlIHNwZWNpZmljYWxseSwgdGhlIGZpbGU6DQpodHRwOi8vd3d3Lmxvd2Vyc3Rh
bmRhcmQuY29tL3B5dGhvbi9wdWRkaW5nLlRBUi5neg0KKGJ1dCBiZSB3YXJuZWQsIGl0J3MgdWds
eSBhbmQgYmFkbHkgY29kZWQuLi5JJ20gc3RpbGwgYSBuZXdiaWUpDQoNCkF0IHRoZSBtb21lbnQg
SSdtIHdyaXRpbmcgYSB3ZWItZm9ydW0gZm9yIG15IGhvbWVwYWdlICh3ZWxsIGl0IHdvbid0IGJl
IHNwZWNpZmljYWxseSBmb3IgbXkgaG9tZXBhZ2UsIGl0J2xsIGJlIGFibGUgdG8gYmUgdHJhbnNw
b3J0ZWQuLi4pDQoNCkFwYXJ0IGZyb20gdGhhdCBJJ3ZlIG11Y2tlZCBhcm91bmQgd2l0aCBweWdh
bWUgYW5kIHB5b3BlbmdsIGEgbGl0dGxlIGFuZCBtYWRlIGEgY291cGxlIG9mIGRvZGd5IGdhbWVz
IGZvciBteSBsaXR0bGUgYnJvdGhlciB0byBwbGF5IF5fXg0KQXJlIHlvdSBnb2luZyB0byBjb25z
aWRlciBwb3N0aW5nIHlvdXIgZmluaXNoZWQgcHJvZ3JhbXMgdG8gVXNlbGVzcyBQeXRob24/IChJ
J20gbm90IG1ha2luZyBhbnkgYWNjdXNhdGlvbnMgb2YgdGhlbSBiZWluZyB1c2VsZXNzKQ0KDQpS
ZWdhcmRzLA0KQW5kcmV3DQogIC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQogIEZyb206IHR1
dG9yLWFkbWluQHB5dGhvbi5vcmcgW21haWx0bzp0dXRvci1hZG1pbkBweXRob24ub3JnXU9uIEJl
aGFsZiBPZiBKZXNzZSBXDQogIFNlbnQ6IFN1bmRheSwgMjQgSnVuZSAyMDAxIDI6MjkgQU0NCiAg
VG86IHR1dG9yQHB5dGhvbi5vcmcNCiAgU3ViamVjdDogW1R1dG9yXSBXaGF0IGFyZSB5b3UgYWxs
IHVwIHRvPw0KDQoNCiAgSGVsbG8gUHl0aG9uZWVycywNCg0KICBXaGF0IGFyZSB5b3UgYWxsIHVw
IHRvPyBXaGF0IHByb2plY3RzIGFyZSB5b3Ugd29ya2luZyBvbj8NCg0KICBJIGFtIGEgMTcgeWVh
ciBvbGQgUHl0aG9uIGhhY2tlci1pbi10cmFpbmluZy4gSSB0ZW5kIHRvIHdyaXRlIHJlLSBpbXBs
ZW1lbnRhdGlvbnMgb2YgZ2FtZXMgYW5kIGludGVyZXN0aW5nIGdyYXBoaWNzIGhhY2tzLiBJIGFt
IGN1cnJlbnRseSB3cml0aW5nIHJlLWltcGxlbWVudGF0aW9uIG9mIE1pbGVzIEJvbmVzLCBhIGNh
ciByYWNpbmcgY2FyZCBnYW1lLCBhbmQgYSB2YXJpYXRpb24gb2YgdGhlIGNhcmQgZ2FtZSBVbm8s
IGNhbGxlZCBIb3QgRGVhdGggVW5vLiBJIHdyb3RlIHRoZSBiZWdpbm5pbmdzIG9mIGEgbW9kdWxl
IHRvIGFjY2VzcyBhbmQgbW9kaWZ5IE1JREkgZmlsZSBkYXRhIGluIFB5dGhvbiwgYW5kIG1hbnkg
b3RoZXIgc21hbGwgcHJvZ3JhbXMuDQoNCiAgVGhhbmsgeW91IGZvciB5b3VyIHRpbWUsDQogIEpl
c3NlIFcNCg0KDQpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
Xw0KVHV0b3IgbWFpbGxpc3QgIC0gIFR1dG9yQHB5dGhvbi5vcmcNCmh0dHA6Ly9tYWlsLnB5dGhv
bi5vcmcvbWFpbG1hbi9saXN0aW5mby90dXRvcg0KDQoNCg==

------=_NextPart_000_0000_01C0FC9B.4704C800
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
L0VOIj4NCjw/Y29sb3I+PD9wYXJhbSAwMTAwLDAxMDAsMDEwMD48SFRNTD48SEVBRD4NCjxNRVRB
IGh0dHAtZXF1aXY9Q29udGVudC1UeXBlIGNvbnRlbnQ9InRleHQvaHRtbDsgY2hhcnNldD11cy1h
c2NpaSI+DQo8TUVUQSBjb250ZW50PSJNU0hUTUwgNS41MC40NjE2LjIwMCIgbmFtZT1HRU5FUkFU
T1I+PC9IRUFEPg0KPEJPRFk+DQo8RElWPjxTUEFOIGNsYXNzPTY4MDMwNDEwMi0yNDA2MjAwMT48
Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0jMDAwMGZmIHNpemU9Mj5Ib3dkeSANCkplc3NlLCBJIHRo
b3VnaHQgSSdkIHRocm93IGluIG15IDEgY2VudCAoQXVzc2llIERvbGxhciEpPC9GT05UPjwvU1BB
Tj48L0RJVj4NCjxESVY+PFNQQU4gY2xhc3M9NjgwMzA0MTAyLTI0MDYyMDAxPjxGT05UIGZhY2U9
VGFob21hIGNvbG9yPSMwMDAwZmYgDQpzaXplPTI+PC9GT05UPjwvU1BBTj4mbmJzcDs8L0RJVj4N
CjxESVY+PFNQQU4gY2xhc3M9NjgwMzA0MTAyLTI0MDYyMDAxPjxGT05UIGZhY2U9VGFob21hIGNv
bG9yPSMwMDAwZmYgc2l6ZT0yPkknbSANCmFsc28gYSAxNyB5ZWFyIG9sZCwgYnV0IEknbSBub3Qg
cmV3cml0aW5nIGdhbWVzLi4ueWV0LiBUaGUgbGFzdCB0aGluZyBJIGRpZCB3YXMgDQphIHJlYWxs
eSBkb2RneSBNVUQgc2VydmVyIGZyYW1ld29yayBjYWxsZWQgUFVEZGluZy4uLmlmIHlvdSB3YW50
IHRvIGNoZWNrIGl0IA0Kb3V0OjwvRk9OVD48L1NQQU4+PC9ESVY+DQo8RElWPjxTUEFOIGNsYXNz
PTY4MDMwNDEwMi0yNDA2MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0jMDAwMGZmIHNpemU9
Mj48QSANCmhyZWY9Imh0dHA6Ly93d3cubG93ZXJzdGFuZGFyZC5jb20vcHl0aG9uL3VzZWxlc3Nw
eXRob24xLmh0bWwiPmh0dHA6Ly93d3cubG93ZXJzdGFuZGFyZC5jb20vcHl0aG9uL3VzZWxlc3Nw
eXRob24xLmh0bWw8L0E+PC9GT05UPjwvU1BBTj48L0RJVj4NCjxESVY+PFNQQU4gY2xhc3M9Njgw
MzA0MTAyLTI0MDYyMDAxPjxGT05UIGZhY2U9VGFob21hIGNvbG9yPSMwMDAwZmYgc2l6ZT0yPm9y
IA0KbW9yZSBzcGVjaWZpY2FsbHksIHRoZSBmaWxlOjwvRk9OVD48L1NQQU4+PC9ESVY+DQo8RElW
PjxTUEFOIGNsYXNzPTY4MDMwNDEwMi0yNDA2MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0j
MDAwMGZmIHNpemU9Mj48QSANCmhyZWY9Imh0dHA6Ly93d3cubG93ZXJzdGFuZGFyZC5jb20vcHl0
aG9uL3B1ZGRpbmcuVEFSLmd6Ij5odHRwOi8vd3d3Lmxvd2Vyc3RhbmRhcmQuY29tL3B5dGhvbi9w
dWRkaW5nLlRBUi5nejwvQT48L0ZPTlQ+PC9TUEFOPjwvRElWPg0KPERJVj48U1BBTiBjbGFzcz02
ODAzMDQxMDItMjQwNjIwMDE+PEZPTlQgZmFjZT1UYWhvbWEgY29sb3I9IzAwMDBmZiBzaXplPTI+
KGJ1dCANCmJlIHdhcm5lZCwgaXQncyB1Z2x5IGFuZCBiYWRseSBjb2RlZC4uLkknbSBzdGlsbCBh
IG5ld2JpZSk8L0ZPTlQ+PC9TUEFOPjwvRElWPg0KPERJVj48U1BBTiBjbGFzcz02ODAzMDQxMDIt
MjQwNjIwMDE+PEZPTlQgZmFjZT1UYWhvbWEgY29sb3I9IzAwMDBmZiANCnNpemU9Mj48L0ZPTlQ+
PC9TUEFOPiZuYnNwOzwvRElWPg0KPERJVj48U1BBTiBjbGFzcz02ODAzMDQxMDItMjQwNjIwMDE+
PEZPTlQgZmFjZT1UYWhvbWEgY29sb3I9IzAwMDBmZiBzaXplPTI+QXQgDQp0aGUgbW9tZW50IEkn
bSB3cml0aW5nIGEgd2ViLWZvcnVtIGZvciBteSBob21lcGFnZSAod2VsbCBpdCB3b24ndCBiZSAN
CnNwZWNpZmljYWxseSBmb3IgbXkgaG9tZXBhZ2UsIGl0J2xsIGJlIGFibGUgdG8gYmUgDQp0cmFu
c3BvcnRlZC4uLik8L0ZPTlQ+PC9TUEFOPjwvRElWPg0KPERJVj48U1BBTiBjbGFzcz02ODAzMDQx
MDItMjQwNjIwMDE+PEZPTlQgZmFjZT1UYWhvbWEgY29sb3I9IzAwMDBmZiANCnNpemU9Mj48L0ZP
TlQ+PC9TUEFOPiZuYnNwOzwvRElWPg0KPERJVj48U1BBTiBjbGFzcz02ODAzMDQxMDItMjQwNjIw
MDE+PEZPTlQgZmFjZT1UYWhvbWEgY29sb3I9IzAwMDBmZiBzaXplPTI+QXBhcnQgDQpmcm9tIHRo
YXQgSSd2ZSBtdWNrZWQgYXJvdW5kIHdpdGggcHlnYW1lIGFuZCBweW9wZW5nbCBhIGxpdHRsZSBh
bmQgbWFkZSBhIGNvdXBsZSANCm9mIGRvZGd5IGdhbWVzIGZvciBteSBsaXR0bGUgYnJvdGhlciB0
byBwbGF5IF5fXjwvRk9OVD48L1NQQU4+PC9ESVY+DQo8RElWPjxTUEFOIGNsYXNzPTY4MDMwNDEw
Mi0yNDA2MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0jMDAwMGZmIHNpemU9Mj5BcmUgDQp5
b3UgZ29pbmcgdG8gY29uc2lkZXIgcG9zdGluZyB5b3VyIGZpbmlzaGVkIHByb2dyYW1zIHRvIFVz
ZWxlc3MgUHl0aG9uPyAoSSdtIG5vdCANCm1ha2luZyBhbnkgYWNjdXNhdGlvbnMgb2YgdGhlbSBi
ZWluZyB1c2VsZXNzKTwvRk9OVD48L1NQQU4+PC9ESVY+DQo8RElWPjxTUEFOIGNsYXNzPTY4MDMw
NDEwMi0yNDA2MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0jMDAwMGZmIA0Kc2l6ZT0yPjwv
Rk9OVD48L1NQQU4+Jm5ic3A7PC9ESVY+DQo8RElWPjxTUEFOIGNsYXNzPTY4MDMwNDEwMi0yNDA2
MjAwMT48Rk9OVCBmYWNlPVRhaG9tYSBjb2xvcj0jMDAwMGZmIA0Kc2l6ZT0yPlJlZ2FyZHMsPC9G
T05UPjwvU1BBTj48L0RJVj4NCjxESVY+PFNQQU4gY2xhc3M9NjgwMzA0MTAyLTI0MDYyMDAxPjxG
T05UIGZhY2U9VGFob21hIGNvbG9yPSMwMDAwZmYgDQpzaXplPTI+QW5kcmV3PC9GT05UPjwvU1BB
Tj48L0RJVj4NCjxCTE9DS1FVT1RFIGRpcj1sdHIgDQpzdHlsZT0iUEFERElORy1MRUZUOiA1cHg7
IE1BUkdJTi1MRUZUOiA1cHg7IEJPUkRFUi1MRUZUOiAjMDAwMGZmIDJweCBzb2xpZDsgTUFSR0lO
LVJJR0hUOiAwcHgiPg0KICA8RElWIGNsYXNzPU91dGxvb2tNZXNzYWdlSGVhZGVyIGRpcj1sdHIg
YWxpZ249bGVmdD48Rk9OVCBmYWNlPVRhaG9tYSANCiAgc2l6ZT0yPi0tLS0tT3JpZ2luYWwgTWVz
c2FnZS0tLS0tPEJSPjxCPkZyb206PC9CPiB0dXRvci1hZG1pbkBweXRob24ub3JnIA0KICBbbWFp
bHRvOnR1dG9yLWFkbWluQHB5dGhvbi5vcmddPEI+T24gQmVoYWxmIE9mIDwvQj5KZXNzZSBXPEJS
PjxCPlNlbnQ6PC9CPiANCiAgU3VuZGF5LCAyNCBKdW5lIDIwMDEgMjoyOSBBTTxCUj48Qj5Ubzo8
L0I+IHR1dG9yQHB5dGhvbi5vcmc8QlI+PEI+U3ViamVjdDo8L0I+IA0KICBbVHV0b3JdIFdoYXQg
YXJlIHlvdSBhbGwgdXAgdG8/PEJSPjxCUj48L0ZPTlQ+PC9ESVY+SGVsbG8gDQogIFB5dGhvbmVl
cnMsPEJSPjxCUj5XaGF0IGFyZSB5b3UgYWxsIHVwIHRvPyBXaGF0IHByb2plY3RzIGFyZSB5b3Ug
d29ya2luZyANCiAgb24/PEJSPjxCUj5JIGFtIGEgMTcgeWVhciBvbGQgUHl0aG9uIGhhY2tlci1p
bi10cmFpbmluZy4gSSB0ZW5kIHRvIHdyaXRlIHJlLSANCiAgaW1wbGVtZW50YXRpb25zIG9mIGdh
bWVzIGFuZCBpbnRlcmVzdGluZyBncmFwaGljcyBoYWNrcy4gSSBhbSBjdXJyZW50bHkgDQogIHdy
aXRpbmcgcmUtaW1wbGVtZW50YXRpb24gb2YgTWlsZXMgQm9uZXMsIGEgY2FyIHJhY2luZyBjYXJk
IGdhbWUsIGFuZCBhIA0KICB2YXJpYXRpb24gb2YgdGhlIGNhcmQgZ2FtZSBVbm8sIGNhbGxlZCBI
b3QgRGVhdGggVW5vLiBJIHdyb3RlIHRoZSBiZWdpbm5pbmdzIA0KICBvZiBhIG1vZHVsZSB0byBh
Y2Nlc3MgYW5kIG1vZGlmeSBNSURJIGZpbGUgZGF0YSBpbiBQeXRob24sIGFuZCBtYW55IG90aGVy
IA0KICBzbWFsbCBwcm9ncmFtcy48QlI+PEJSPlRoYW5rIHlvdSBmb3IgeW91ciB0aW1lLDxCUj5K
ZXNzZSBXPEJSPjxQUkU+DQpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fXw0KVHV0b3IgbWFpbGxpc3QgIC0gIFR1dG9yQHB5dGhvbi5vcmcNCmh0dHA6Ly9tYWls
LnB5dGhvbi5vcmcvbWFpbG1hbi9saXN0aW5mby90dXRvcg0KPC9QUkU+PC9CTE9DS1FVT1RFPjwv
Qk9EWT48L0hUTUw+DQo=

------=_NextPart_000_0000_01C0FC9B.4704C800--



From michael@trollope.org  Sun Jun 24 03:37:45 2001
From: michael@trollope.org (M.A. Powe)
Date: Sat, 23 Jun 2001 19:37:45 -0700
Subject: [Tutor] The philosophy of versions
In-Reply-To: <01062409215000.01436@localhost.localdomain> (message from John
 Murray on Sun, 24 Jun 2001 09:21:50 +0000)
References: <3B3499BA.32214.18AE8AE4@localhost> <01062409215000.01436@localhost.localdomain>
Message-ID: <200106240237.f5O2bjE28499@cecilia.trollope.org>

>>>>> "John" == John Murray <pursang@interact.net.au> writes:

    John> On Saturday 23 June 2001 20:29, you wrote:
    >> Honors to all tutor-ians,
    >> 
    >> My major difficulty in Python is not precisely a programming
    >> problem but a meta-programming problem.  I (incorrectly) think
    >> of my programs as inexorably moving toward a final state of
    >> perfection,

    John> I think that one of the most important things about
    John> programming is knowing when to stop. Does that text editor
    John> *really* need a built in flight simulator? ;-)

No, but that builtin game of tetris is indispensable.  ;-)

mp
 
-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From arthur.watts@gbst.com  Sun Jun 24 04:10:51 2001
From: arthur.watts@gbst.com (Arthur Watts)
Date: Sun, 24 Jun 2001 13:10:51 +1000
Subject: [Tutor] Elegance vs short-term expediency
Message-ID: <1CDB101F0CB6D311882F0000F806392403BAB09C@aquarius.bne.star.com.au>

Guys,

        I try to champion Python within our company whenever I'm given the
chance, but there are times when it is just plain easier to use Perl for a
given task. Here is an example of how I chose Perl over Python for a task
I've just spent several hours finishing :

        Our network admins are frustrated by the command line interface they
have to use to configure our plethora of Cisco routers. Basically, you
telnet onto the router, print out the existing config, wade thru it's poorly
formatted output and determine what you want to change. After issuing a
command to change something, the router then uses tftp to accomplish any
changes you  wish to make. 

	CPAN (the Perl archive) contains a great little module called
'Net::Telnet::Cisco' which makes automating the above really easy, so all I
had to do was run up the CGI code to get the necessary router IP and
relevant passwords. Presenting the user with a series of SUBMIT buttons for
a given function is also a trivial task : I had to spend a little time
parsing and formatting the output, but the main thing was that I had a
troublefree conduit to the router via the Perl module. It then becomes a
case of  'router object <-> CGI <-> browser', and I've been able to separate
all the router-specific code from the presentation code. Genericity,
reusability and all that good stuff :)

	Assuming that there was a Python module for this task (yes, I have a
basic idea of what would be required to write one .. too much like hard work
!), the big stumbling block would be the learning curve for the rest of the
company. The Network guys understand enough Perl to get themselves into
trouble, but the word 'Python' only draws blank stares. I guess its a
Catch-22 ('if you code it, they will learn'), and I know using Python would
result in more maintainable utilities, but I'm only human :}

Seeya,

Artie

Arthur Watts
Software Engineer GBST Automation
Global Banking & Securities Transactions

Telephone + 61 7 3331 5555
mailto: arthur.watts@gbst.com
www.gbst.com





From rob@jam.rr.com  Sun Jun 24 04:36:16 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sat, 23 Jun 2001 22:36:16 -0500
Subject: [Tutor] What are you all up to?
In-Reply-To: <3B347D97.16808.18409E90@localhost>
Message-ID: <NFBBKIELCLIEEMGGIGKDCEFICAAA.rob@jam.rr.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0002_01C0FC34.EA85A560
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Okay, I'll be a sport, too. I've been a recreational Pythoholic for a little
over a year, now. I actually use Python for calculation and other everyday
tasks at work and home. It all got started last May, when I was playing
Diablo late at night and feeling kinda bored with it.

Suddenly a bright light flashed and a dogawful noise blared. I looked around
to see three confused figures standing on top of my scrunched Lego
MindStorms bot, muttering in puzzlement. There was some European guy holding
a device that kinda looked like the one Quinn Mallory used in Sliders, only
I could tell that it was running the Palm OS and had some of what looked
like pseudocode to me scrolling along the screen.

The other two characters appeared to be assessing the situation and waiting
for a word from the guy with the TIMEBOY Palm. A cyborg or some such, with a
name tag bolted crudely across its lapel, seemed to be posting to
comp.lang.python via some sort of handheld. The name tag had been partly
scorched, so all I could make out was "TIM P".

The third moved quickly to repair my bot, adding a few enhancements just for
the jollies. I figured he'd be the easiest to turn to for an explanaiton,
because he had a U.C. Berkeley shirt on. He just might speak English!

But he didn't have time, because the one he had called "Guido" seemed
content that something had been "preemptively repaired in the current
sources." It was time to go. So he tossed me a Linux Journal bundled with a
special feature on Python.

That night I downloaded Python and found it to be a good time all around,
although I now have a chronic case of PDA envy.

And I've also got a bridge to sell,
Rob


Useless Python:
Aw, heck, we love you!
http://www.lowerstandard.com/python/

  -----Original Message-----
  From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Jesse W
  Sent: Saturday, June 23, 2001 1:29 PM
  To: tutor@python.org
  Subject: [Tutor] What are you all up to?


  Hello Pythoneers,

  What are you all up to? What projects are you working on?

  I am a 17 year old Python hacker-in-training. I tend to write re-
implementations of games and interesting graphics hacks. I am currently
writing re-implementation of Miles Bones, a car racing card game, and a
variation of the card game Uno, called Hot Death Uno. I wrote the beginnings
of a module to access and modify MIDI file data in Python, and many other
small programs.

  Thank you for your time,
  Jesse W


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?color><?param 0100,0100,0100><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></HEAD>
<BODY>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D000333602-24062001>Okay,=20
I'll be a sport, too. I've been a recreational Pythoholic for a little =
over a=20
year, now. I actually use Python for calculation and other everyday =
tasks at=20
work and home. It all got started last May, when I was playing Diablo =
late at=20
night and feeling kinda bored with it.</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D000333602-24062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D000333602-24062001>Suddenly a bright light flashed and a =
dogawful noise=20
blared. I looked around to see three confused figures standing on top of =
my=20
scrunched Lego MindStorms bot, muttering in puzzlement. There was some =
European=20
guy holding a device that kinda looked like the one Quinn Mallory used =
in=20
Sliders, only I could tell that it was running the Palm OS and had some =
of what=20
looked like pseudocode to me scrolling along the =
screen.</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D000333602-24062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D000333602-24062001>The=20
other two characters appeared to be assessing the situation and waiting =
for a=20
word from the guy with the TIMEBOY Palm.&nbsp;A cyborg or some such, =
with a name=20
tag bolted crudely across its lapel, seemed to be posting to =
comp.lang.python=20
via some sort of handheld.&nbsp;The name tag had been partly scorched, =
so all I=20
could make out was "TIM P".</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D000333602-24062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D000333602-24062001>The=20
third moved quickly to repair my bot, adding a few enhancements just for =
the=20
jollies. I figured he'd be the easiest to turn to for an explanaiton, =
because he=20
had a U.C. Berkeley shirt on. He just might speak =
English!</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D000333602-24062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D000333602-24062001>But he=20
didn't have time, because the one he had called "Guido" seemed content =
that=20
something had been "preemptively repaired in the current sources." It =
was time=20
to go. So he tossed me a Linux Journal bundled with a =
special&nbsp;feature on=20
Python.</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D000333602-24062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D000333602-24062001>That=20
night I downloaded Python and found it to be a good time all around, =
although I=20
now have a chronic case of PDA envy.</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D000333602-24062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D000333602-24062001>And=20
I've also got a bridge to sell,</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D000333602-24062001>Rob</SPAN></FONT></DIV><BR>
<P><FONT size=3D2>Useless Python:<BR>Aw, heck, we love you!<BR><A=20
href=3D"http://www.lowerstandard.com/python/"=20
target=3D_blank>http://www.lowerstandard.com/python/</A> </FONT></P>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px">
  <DIV align=3Dleft class=3DOutlookMessageHeader dir=3Dltr><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> =
tutor-admin@python.org=20
  [mailto:tutor-admin@python.org]<B>On Behalf Of </B>Jesse =
W<BR><B>Sent:</B>=20
  Saturday, June 23, 2001 1:29 PM<BR><B>To:</B>=20
  tutor@python.org<BR><B>Subject:</B> [Tutor] What are you all up=20
  to?<BR><BR></DIV></FONT>Hello Pythoneers,<BR><BR>What are you all up =
to? What=20
  projects are you working on?<BR><BR>I am a 17 year old Python=20
  hacker-in-training. I tend to write re- implementations of games and=20
  interesting graphics hacks. I am currently writing re-implementation =
of Miles=20
  Bones, a car racing card game, and a variation of the card game Uno, =
called=20
  Hot Death Uno. I wrote the beginnings of a module to access and modify =
MIDI=20
  file data in Python, and many other small programs.<BR><BR>Thank you =
for your=20
  time,<BR>Jesse W<BR><PRE>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor</PRE></BLOCKQUOTE></BODY></=
HTML>

------=_NextPart_000_0002_01C0FC34.EA85A560--



From sheila@thinkspot.net  Sun Jun 24 04:41:10 2001
From: sheila@thinkspot.net (Sheila King)
Date: Sat, 23 Jun 2001 20:41:10 -0700
Subject: [Tutor] What are you all up to?
In-Reply-To: <3B347D97.16808.18409E90@localhost>
References: <3B347D97.16808.18409E90@localhost>
Message-ID: <463694C4AF8@kserver.org>

On Sat, 23 Jun 2001 11:29:27 -0700, "Jesse W" <jessw@loop.com>  wrote
about [Tutor] What are you all up to?:

:	What are you all up to?  What projects are you working on?

I haven't had as much time for Python as I would like (started learning
it in January). As time goes on, I hope to have more and more time for
my web stuff and programming. (I just quit my job as a high school math
teacher and will be moving to university...hoping for more free time.)

So far what I've written: well, the numerous small learning scripts that
everyone writes. And then, I've written some things that I actually USE:

I have a script for filtering my mail at my webhost. It searches to
to/form fields of the e-mail message and decides whether it is likely to
be spam or not. It adds header tags for my mail client to filter on.

I wrote a short script that processes and mails the spam I want to
report to spamcop.net.

I've written a few cgi scripts for my web page. I have one for letting
the subscribers to my AP Computer Science teachers mailing list manage
their list settings, here:
http://www.thinkspot.net/sheila/computers/listManagement.html

My biggest project thus far, has been Gypsy Mail:
http://www.thinkspot.net/sheila/computers/software/gypsymail.html
which is an ongoing project.

I have a number of things I want to work on this next year. One of
which, is a robot moderator script for Usenet moderators (of which, I am
one).

I'd like to get into Tkinter and/or other GUIs.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




From python.tutor@atrixnet.com  Sun Jun 24 07:03:02 2001
From: python.tutor@atrixnet.com (Tommy Butler)
Date: Sat, 23 Jun 2001 23:03:02 -0700
Subject: [Tutor] Elegance vs short-term expediency
In-Reply-To: <1CDB101F0CB6D311882F0000F806392403BAB09C@aquarius.bne.star.com.au>
Message-ID: <MABBJNNKNGCCADBAELCHEEHPCDAA.python.tutor@atrixnet.com>

> Guys,
>
>         I try to champion Python within our company whenever I'm given the
> chance, but there are times when it is just plain easier to use Perl for a
> given task. Here is an example of how I chose Perl over Python for a task
> I've just spent several hours finishing :

Maybe the bit about "several hours" you just mentioned should tell you
something about why you should have used python instead.

Die, camel-boy! (Just kidding, of course!)  Unfortunately I'm doomed to
suffer the same tradgedy each day where I work.  I think my guys will come
around though.  I'm beginning to think there's only so long you can "use
Perl;" while improving your python skills and save any time.

	-t



From jstanley@start.com.au  Sun Jun 24 06:00:06 2001
From: jstanley@start.com.au (Jordan Stanley)
Date: Sun, 24 Jun 2001 15:00:06 +1000
Subject: [Tutor] Re: What are you you all up to
Message-ID: <B3003407304@i01sv4071.ids1.intelonline.com>

>Message: 1
>From: "Jesse W" <jessw@loop.com>
>To: tutor@python.org
>Date: Sat, 23 Jun 2001 11:29:27 -0700
>Subject: [Tutor] What are you all up to?
>
>ello Pythoneers,
>
>	What are you all up to?  What projects are you working on?
>
>
>	I am a 17 year old Python hacker-in-training.  I tend to write re-
>implementations of games and interesting graphics hacks.  I am 
>currently writing re-implementation of Miles Bones, a car racing 
>card game, and a variation of the card game Uno, called Hot Death 
>Uno.  I wrote the beginnings of a module to access and modify MIDI 
>file data in Python, and many other small programs.

sounds great
keep us informed about your projects

I am 23, I am currently learning Python and VB. I just started last
month. as you say about scripts, thats what I have written so far.

I can identify with what another 'pythoneer' said about remembering
the good old days with C64 and Amiga. it reminds me of them as well.

It is a lot of fun, and I have gotten great support from the members
of this list.

thank you all

and good luck to everyone


__________________________________________________________________
Get your free Australian email account at http://www.start.com.au



From dyoo@hkn.eecs.berkeley.edu  Sun Jun 24 09:35:05 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 24 Jun 2001 01:35:05 -0700 (PDT)
Subject: [Tutor] Elegance vs short-term expediency
In-Reply-To: <MABBJNNKNGCCADBAELCHEEHPCDAA.python.tutor@atrixnet.com>
Message-ID: <Pine.LNX.4.21.0106240131390.24906-100000@hkn.eecs.berkeley.edu>

On Sat, 23 Jun 2001, Tommy Butler wrote:

> > I try to champion Python within our company whenever I'm given the >
> chance, but there are times when it is just plain easier to use Perl
> for a > given task. Here is an example of how I chose Perl over Python
> for a task > I've just spent several hours finishing :
> 
> Maybe the bit about "several hours" you just mentioned should tell you
> something about why you should have used python instead.

The guys at Digital Creations are developing the PyPerl module, which lets
us create the unholy combination of Perl and Python... *grin*

    ftp://ftp.activestate.com/Zope-Perl/

That is, if there's a module in Perl that seems really neat, then,
technically, nothing stops us from pulling it into Python.  I haven't
played too extensively with it yet, but it seems like a great module to
try out.



From arcege@speakeasy.net  Sun Jun 24 11:13:05 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Sun, 24 Jun 2001 06:13:05 -0400 (EDT)
Subject: [Tutor] The philosophy of versions
In-Reply-To: <3B3499BA.32214.18AE8AE4@localhost> from "Jesse W" at Jun 23, 2001 01:29:30 PM
Message-ID: <200106241013.f5OAD5W06954@dsl092-074-184.bos1.dsl.speakeasy.net>

Jesse W wrote
> Honors to all tutor-ians,
> 
> 	My major difficulty in Python is not precisely a programming 
> problem but a meta-programming problem.  I (incorrectly) think of 
> my programs as inexorably moving toward a final state of perfection, 
> and I therefore have something of a mental block on the idea of 
> releasing versions or writing changelogs and things like that.  I am 
> quite aware that this is not a sane view, and I would like to work 
> through this block, but I have not yet figured out how to do it.  If any 
> of you have any comments, ideas, or responses to this, please post.

Hi, Jesse.

I won't try to convince you of anything, just give a few of my thoughts
as a corporate release manager, having to deal with these issues for
corporate products.  In the industry, there is always the same fight
you are having; Engineering wants more development time and testing,
Sales wants it made they day after they sold it.  When do you release?
Well,  open source software has different reasons for being released
luckily, but the question still remains: when do you release?

Some companies put complicated mechanisms in place to say when the
software is ready, depending on the severity of the defects (I worked for
one company where they released the product as soon as "it compiles").
They put processes in place to make sure things get done correctly and
they have some paper-trail in case the customer complains about a lack
of testing.

Don't worry about process; the best processes are the ones that don't
hinder you, but just make things better (I would suggest using source
code controls tho, e.g. CVS).  There is a common saying with open
source software: release early, release often.  The idea behind this
is: get the product in people's hands, let them help you find the bugs,
let them help you find the new features that they want, but above all,
trust in yourself to direct where _your_ program should go.

Take a page from Guido himself,  he isn't quite the control freak some
might think: he had been pretty much _the_ Python developer up until
fairly recently.  It wasn't because he was afraid that people would
"destroy" his work.  More that he had a clear vision of what he thought
Python should be, listen to people's ideas, rejected the ones which didn't
seem to fit the vision and incorporate the ones that did.  More recently,
he's gotten a development team for Python.

If you think your program(s) are never finished, then I give this advice.
Don't think of a release as a culmination of the product, but as a step
in the evolution.  Enjoy "Software Darwinism." ;)

  -Arcege

PS: Excuse the rambling, if I did..  haven't been feeling well the last
month or so, and the mind gets off-track a little.  Going to nurse the
resulting headache.  Good luck.

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From ak@silmarill.org  Sun Jun 24 12:20:36 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Sun, 24 Jun 2001 07:20:36 -0400
Subject: [Tutor] The philosophy of versions
In-Reply-To: <"from arcege"@dsl092-074-184.bos1.dsl.speakeasy.net>
References: <3B3499BA.32214.18AE8AE4@localhost>
 <200106241013.f5OAD5W06954@dsl092-074-184.bos1.dsl.speakeasy.net>
Message-ID: <20010624072036.A22998@sill.silmarill.org>

> Jesse W wrote
> > Honors to all tutor-ians,
> > 
> > 	My major difficulty in Python is not precisely a programming 
> > problem but a meta-programming problem.  I (incorrectly) think of 
> > my programs as inexorably moving toward a final state of perfection, 
> > and I therefore have something of a mental block on the idea of 
> > releasing versions or writing changelogs and things like that.  I am 
> > quite aware that this is not a sane view, and I would like to work 
> > through this block, but I have not yet figured out how to do it.  If any 
> > of you have any comments, ideas, or responses to this, please post.

Is the program useful? If you answered yes, release it. If you released it
yesterday, and today it's even more useful, release new version. It's not
like releasing it stops all further development! ;-)

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline


From bill-bell@bill-bell.hamilton.on.ca  Sun Jun 24 16:33:11 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Sun, 24 Jun 2001 11:33:11 -0400
Subject: [Tutor] Re: What are you all up to?
In-Reply-To: <E15DzuU-0006Ib-00@mail.python.org>
Message-ID: <3B35CFF7.11435.43AB99D@localhost>

>  What are you all up to?  What projects are you working on?
> 
>  I am a 17 year old Python hacker-in-training.  I tend to write re-
> implementations of games and interesting graphics hacks. ...

Welcome, Jesse!

I am a 54-year-old software developer. (Yes, really--about the age I 
mean.) I am new to Python, and have just worked out how to build 
a local COM server that is capable of sinking calls on its methods 
from several other processes and displaying just one instance of its 
GUI written in wxPython. I'm building an adjunct to Internet 
Explorer as part of a research team. I'm convinced that my life will 
be a lot easier in Python than it has been using MSVC, which is 
why I pressed to be permitted to use Python! Having mastered a 
few languages and systems in my time I know I have about a tonne 
of idioms and other stuff to get my head around.

Hope you enjoy ~your~ experience.

Bill


From rab121@york.ac.uk  Sun Jun 24 19:10:48 2001
From: rab121@york.ac.uk (Russell)
Date: Sun, 24 Jun 2001 19:10:48 +0100
Subject: [Tutor] Two Quick Questions
Message-ID: <3B362D28.7DEF3DF8@york.ac.uk>

Hello,

First, a general programming thingy.  Beyond the recent discussion of
version releases, is there a generally accepted way of actually giving
version numbers?  I tend to work on majorversion.minorchanges but is
there a more conventional way of handling it?  I never have figured out
the third number in some version either...

Secondly a, probably absurdly stupid, Puthon question (I'm only a
beginner ;o).  Fiddling around I discovered that using:

if not x in y:

and

if x not in y:

both give the same result for simple things.  E.g. for:

L = ['a', 'b', 'c']
S = 'g'

both:

if not S in L:
	print 'shrubbery'

and:

if S not in L:
	print 'shrubbery'

will give me a small decorative tree arrangement.

My question is:  Does the difference in order of nots and variables make
any difference when used in more complex, subtle ways?  If not, what is
the usual way of ordering it?  I prefer the second beacuse it sounds
nicer, but still ;o)

Thankyou for your help,

Russell
-- 
When you look up into the night sky and see the millions of glittering
stars, do you ever stop and wonder whether there might be another family
somewhere up there, living their peaceful pink lives on some distant
blue moon?


From bsass@freenet.edmonton.ab.ca  Sun Jun 24 22:41:46 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Sun, 24 Jun 2001 15:41:46 -0600 (MDT)
Subject: [Tutor] What are you all up to?
In-Reply-To: <3B347D97.16808.18409E90@localhost>
Message-ID: <Pine.LNX.4.33.0106241440090.32508-100000@bms>

On Sat, 23 Jun 2001, Jesse W wrote:
> 	What are you all up to?  What projects are you working on?

Hi,

I'm having fun with my Linux box.  Since I have no pressures to
produce I tend to bounce around and explore whatever strikes me as
interesting; lately that has been literate programming, and most
recently I've been thinking about a general scheme for filtering
source code to generate a ".py"... just because being able to do,

	python sourcefile
and
	someditor sourcefile
even
	sourcefile   # i.e., sourcefile is an executable

would be both neat|groovy|super|awesome|cool and useful.  Especially if
"sourcefile" is allowed to contain an entire package, and executing it
results in a full installation of the software.


- Bruce



From bsass@freenet.edmonton.ab.ca  Sun Jun 24 22:42:34 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Sun, 24 Jun 2001 15:42:34 -0600 (MDT)
Subject: [Tutor] method to print in interpreter
In-Reply-To: <E15DDiE-0005Cd-00@gadolinium.btinternet.com>
Message-ID: <Pine.LNX.4.33.0106241151390.32508-100000@bms>

On Fri, 22 Jun 2001, Allan Crooks wrote:
> > I would like ">>> p" to return something like '(1,2)', too.
>
> Whenever you "print" an object, it will use the string returned by the str function.
> Whenever you have an object that is displayed without using print, it uses the repr function.
>
> So in your Point class, you could add this line:
>
> def __repr__(self):
>   return str(self)
>
> Which returns the same string as when you print it.

...or you can do...

	def __str__(self):
	    return ...

	__repr__ = __str__

...and save on a def, but you probably really want...

	def __str__(self):
	    return ...

	def __repr__(self):
	    return "Point(" + repr(x) + ", " + repr(y) + ")"

...so you can do...

	a = Point(1,2)
	b = eval(repr(a))

...and have it work as you would expect (i.e., b == Point(1,2)).


- Bruce





From jessw@loop.com  Sun Jun 24 23:04:51 2001
From: jessw@loop.com (Jesse W)
Date: Sun, 24 Jun 2001 15:04:51 -0700
Subject: [Tutor] A Challenge solution
Message-ID: <3B360194.13496.1E2C6ADE@localhost>

--Message-Boundary-20185
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

Oh Honorable Lord of Python(s),
 Enclosed is my solution to the calculator challenge on Useless 
Python.  Please let me know when my certified 14ft. long Useless 
Python(Pythonicus uslessium) will be arriving. ;-)

 Thank you, and happy hacking,
  Jesse Weinstein

And to all you of at tutor:
	Any comments, suggestions, patches, gripes, or simple 
screams of emotion are welcomed.  Please only post to the list.

(Oh, so you want an explanation of why this message is apperently 
only going to the list, not to anyone at Useless Python?  Well, I sent 
it once before, but I put tutor's address in wrong.  So I am resending 
it to you guys, but I don't have to resend it to the people at Useless 
Python.  Plus, I think most of the people at Useless are also on the 
list. :-) Happy?)


--Message-Boundary-20185
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'calculator.py'

#Simple calculator app with a GUI front end, as per the "Python Challenge".
#Written in __exactly__ 1 hour.
#By Jesse Weinstein-jessw@loop.com
#Released on June 24, 2001, at 2:42 PM, Pacific Standard Time

from Tkinter import *

class Calculator:
    def __init__(self, font_size=12):
        self.font_size=font_size
        self.make_window()
    def make_window(self):
        self.root=Tk()
        self.root.title('Calculator')
        self.opersF=Frame(self.root)
        self.opers=[]
        for item in ['+', '-', '*', '/']:
            self.opers.append(Button(self.opersF, text=item[0],\
                                     height=1, width=2,\
                                     font=('', `self.font_size`, '')))
            self.opers[-1].bind('<1>', self.buttonCB)
            self.opers[-1].pack(side=TOP)

        self.display=Entry(self.root, font=('', `self.font_size`, ''),\
                           state=DISABLED, width=2)
        
        self.numsF=Frame(self.root)
        self.nums=[]
        for item in range(1, 10):
            self.nums.append(Button(self.numsF, text=`item`,\
                                    height=1, width=2, \
                                    font=('', `self.font_size`, '')))
            self.nums[-1].bind('<1>', self.buttonCB)
            self.nums[-1].grid(column=(item-1) % 3, row=(item-1)/3)
        self.othersF=Frame(self.root)
        self.others=[]
        for item in [('=', self.equals), ('C', self.clear),\
                     ('d', self.backspace)]:
            self.others.append(Button(self.othersF, text=item[0],\
                                      command=item[1], height=1, width=2,
                                      font=('', `self.font_size`, '')))
            self.others[-1].pack(side=RIGHT)
            
        self.display.grid(column=0, row=0, columnspan=4, sticky=NW+E)
        self.opersF.grid(column=3, row=1, rowspan=2, sticky=W)
        self.numsF.grid(column=0, row=1, columnspan=3, sticky=SE)
        self.othersF.grid(column=2, row=2, sticky=NE)
    def buttonCB(self, event):
        val=event.widget.cget('text')
        self.display.config(state=NORMAL)
        self.display.insert(END, val)
        self.display.config(state=DISABLED)
    def equals(self):
        if self.display.get():
            ans=eval(self.display.get())
            self.display.config(state=NORMAL)
            self.display.delete(0, END)
            self.display.insert(0, ans)
            self.display.config(state=DISABLED)
    def clear(self):
        self.display.config(state=NORMAL)
        self.display.delete(0, END)
        self.display.config(state=DISABLED)
    def backspace(self):
        self.display.config(state=NORMAL)
        self.display.delete(len(self.display.get())-1)
        self.display.config(state=DISABLED)
        
if __name__=='__main__':
    it=Calculator()
    print """If you are seeing this message because nothing else has appeared
on your screen, then I suggest you run this from IDLE, or uncomment out the line
directly below this one, which starts a Tkinter mainloop.  (If you start a
mainloop in IDLE, it locks up.)"""
    #it.root.mainloop()
    #Note: the above should be uncommented if running outside of IDLE

--Message-Boundary-20185--


From rob@jam.rr.com  Sun Jun 24 23:55:59 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sun, 24 Jun 2001 17:55:59 -0500
Subject: [Tutor] A Challenge solution
In-Reply-To: <3B360194.13496.1E2C6ADE@localhost>
Message-ID: <NFBBKIELCLIEEMGGIGKDKEFLCAAA.rob@jam.rr.com>

# -----Original Message-----

# Oh Honorable Lord of Python(s),
#  Enclosed is my solution to the calculator challenge on Useless
# Python.  Please let me know when my certified 14ft. long Useless
# Python(Pythonicus uslessium) will be arriving. ;-)
#
#  Thank you, and happy hacking,
#   Jesse Weinstein
#
# And to all you of at tutor:
# 	Any comments, suggestions, patches, gripes, or simple
# screams of emotion are welcomed.  Please only post to the list.
#
# (Oh, so you want an explanation of why this message is apperently
# only going to the list, not to anyone at Useless Python?  Well, I sent
# it once before, but I put tutor's address in wrong.  So I am resending
# it to you guys, but I don't have to resend it to the people at Useless
# Python.  Plus, I think most of the people at Useless are also on the
# list. :-) Happy?)
#
#

Ahh, if only the Perl JAPHs could see how much respect they'd get from
people if they were just nicer! 3;->

Heehee. Any time you mention Useless Python in an email to the tutor list,
you can be nearly guaranteed that my narcissistic glance will fall upon it.
Shortly thereafter it will become Useless indeed.

Unfortunately, we are a bit short on certified Pythons. It seems that some
cartel had been smuggling coke in them recently, and a big DEA bust this
week has them all awaiting their bondsmen. Certification just doesn't mean
as much as it used to, apparently.

However, you'll be credited for your bravery in having solved a challenge.
And if I'm not mistaken, you also have turned in the first UNSW solution to
date. I'll keep you posted when the Pythons have been exonerated.

Uselessly,
Rob

"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/



From python.tutor@atrixnet.com  Mon Jun 25 06:37:36 2001
From: python.tutor@atrixnet.com (Tommy Butler)
Date: Sun, 24 Jun 2001 22:37:36 -0700
Subject: [Tutor] A Challenge solution
In-Reply-To: <3B360194.13496.1E2C6ADE@localhost>
Message-ID: <MABBJNNKNGCCADBAELCHMEJBCDAA.python.tutor@atrixnet.com>

Uh, oh...

Exception in Tkinter callback
Traceback (most recent call last):
  File "c:\python21\lib\lib-tk\Tkinter.py", line 1285, in __call__
    return apply(self.func, args)
  File "C:\temp\calculator.py", line 55, in equals
    ans=eval(self.display.get())
OverflowError: integer literal too large




-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Jesse W
Sent: Sunday, June 24, 2001 3:05 PM
To: tutor@python.org
Subject: [Tutor] A Challenge solution

[snip]

And to all you of at tutor:
	Any comments, suggestions, patches, gripes, or simple 
screams of emotion are welcomed.  Please only post to the list.



From fontameise@web.de  Sun Jun 24 21:14:58 2001
From: fontameise@web.de (Inka Menne)
Date: Sun, 24 Jun 2001 22:14:58 +0200
Subject: [Tutor] Help
Message-ID: <3B364A42.D1CEB620@web.de>

Hello,
today I started lerarning python. I hope to manage it. I never learned a
progam language bevor. I am a designer, working in the font buisness. Is
there someone how knows something about python and FontLab 4? How much
Python must do I have learn to deal with FontLab 4?
I'm working with a book from Ivan laningham to learn Python. At  the
moment I'm on page 77 and it is very strange for me.
regards
Inka



From alan.gauld@bt.com  Mon Jun 25 11:06:36 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 25 Jun 2001 11:06:36 +0100
Subject: [Tutor] trouble displaying instance attributes and methods
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D85A@mbtlipnt02.btlabs.bt.co.uk>

> does this mean that given a class instance i w'd'nt be able 
> to do a look up on all the methods supported by that class?

Not at all it just means you have to do a bit of work thats all.

There was a thread on this very recently - last month?
It gave a helper function which showed how to do this 
- you need to get the class from the instance then get 
that class's "parents" and so on to the top of the 
inheritance tree. Not exactly trivial but not rocket 
science either.

Alan G.


From alan.gauld@bt.com  Mon Jun 25 10:56:37 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 25 Jun 2001 10:56:37 +0100
Subject: [Tutor] Sorting against another list
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D858@mbtlipnt02.btlabs.bt.co.uk>

This idea is untested but seems like it should work!

> [ 'aa', 'qq', 'ttt', 'hh']  # master list

Convert list to dictionary keyed by item and valued by 
list index

ie: 
master = {'aa':0,'qq':1...'hh':3}

Now write a cmp() function that checks the index of your list 
items against the dictionary index value.

Something like:

def cmp(a,b):
   return master[a] - master[b]

I think....

Alan G.


From Eugene.Leitl@lrz.uni-muenchen.de  Mon Jun 25 11:37:27 2001
From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl)
Date: Mon, 25 Jun 2001 12:37:27 +0200 (MET DST)
Subject: [Tutor] Python XML tree representation
Message-ID: <Pine.SOL.4.33.0106251235520.2105-100000@sun1.lrz-muenchen.de>

I'm looking for a tree representation (not event switcher) OOP XML parser
in Python (after parsing, there's an object tree in memory representing
the file parsed). Any suggestions?

TIA,

-- Eugen* Leitl <a href="http://www.lrz.de/~ui22204/">leitl</a>
______________________________________________________________
ICBMTO  : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204
57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3



From iamgod@st.jyu.fi  Mon Jun 25 12:06:14 2001
From: iamgod@st.jyu.fi (Risto Peranen)
Date: Mon, 25 Jun 2001 14:06:14 +0300 (EEST)
Subject: [Tutor] Re: Tutor digest, Vol 1 #909 - 10 msgs
In-Reply-To: <E15ECJu-0005Ga-00@mail.python.org>
Message-ID: <Pine.LNX.4.33.0106251355590.27044-100000@silmu.st.jyu.fi>

Hey folks.

<intro>
I'm part of game programming project.
Does anyone know where can I find
info or even existing modules for
talk-ai.

In the game you can just negotiate with
strangers rather than kill 'em all. That's
our problem but it would be cool if you
can also talk with strangers - even with
limited ai. Sure I know the basics of
making such a silly ai, but I have
never made one.

Risto Peranen
040 756 94 12
iamgod@st.jyu.fi

Ihminen on syntynyt vaivaan, kuten kipinat ovat syntyneet
nousemaan taivaalle



From Eugene.Leitl@lrz.uni-muenchen.de  Mon Jun 25 12:16:05 2001
From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl)
Date: Mon, 25 Jun 2001 13:16:05 +0200 (MET DST)
Subject: [Tutor] Python XML tree representation
In-Reply-To: <Pine.SOL.4.33.0106251235520.2105-100000@sun1.lrz-muenchen.de>
Message-ID: <Pine.SOL.4.33.0106251315330.2105-100000@sun1.lrz-muenchen.de>

Nevermind, I figured out it was DOM from PyXML I was looking for.

On Mon, 25 Jun 2001, Eugene Leitl wrote:

> I'm looking for a tree representation (not event switcher) OOP XML parser
> in Python (after parsing, there's an object tree in memory representing
> the file parsed). Any suggestions?

-- Eugen* Leitl <a href="http://www.lrz.de/~ui22204/">leitl</a>
______________________________________________________________
ICBMTO  : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204
57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3



From s.lastinger@computernetdesign.com  Mon Jun 25 12:34:26 2001
From: s.lastinger@computernetdesign.com (Stephen Lastinger)
Date: Mon, 25 Jun 2001 07:34:26 -0400 (EDT)
Subject: [Tutor] What are you all up to?
In-Reply-To: <3B347D97.16808.18409E90@localhost>
Message-ID: <Pine.LNX.4.31.0106250704140.888-100000@icepick.computernetdesign.com>

Damn, why doesn't everyone just make me feel old
: )

I'm a 31 year old sr. Linux/Unix sys adm. and so far have mainly used it
to (somewhat - keyword here is 'learning') used it to add to my
administrative abilities.  I took a look at perl (no I'm not trying to
start a holy war here), but the syntax drove me nutty!

I'm really interested in using tk but haven't quite gotten that
far yet.

As far as projects....well I won't list any of the too serious ones, but
as far as scratching an itch goes, I would love to write (not
in any particular order):
* a gui configuration util. for my (current) fav. window mgr.
* a much more eyecandy/colorful cd player than xplaycd
  (and on that note, the same applies to xmixer)
* a kick-ass widget set based on/using tk and pmw and apps based on said
widget set.

There are others, but I figure by the time I finish these, then I will be
ready to write commercial grade multi-platform server
applications (or helper apps ; )
- even if just the front ends and prototyping the engine for
later recode in something like c, or c++.

I really see Python being like a faster development language and usable in
places where most would see java - but then again that may just be my
inexperience and lack of desire to learn java talking.

-Stephen

On Sat, 23 Jun 2001, Jesse W wrote:
> Subject: [Tutor] What are you all up to?

>What are you all up to?  What projects are you working on?
>
>
> I am a 17 year old Python hacker-in-training.  I tend to write re-
> implementations of games and interesting graphics hacks.  I am
> currently writing re-implementation of Miles Bones, a car racing
> card game, and a variation of the card game Uno, called Hot Death
> Uno.  I wrote the beginnings of a module to access and modify MIDI
> file data in Python, and many other small programs.
>
> Thank you for your time,
> Jesse W

--
Stephen Lastinger	 - s.lastinger@computernetdesign.com
Computer Network Design,Inc.  - http://www.computernetdesign.com



From albertthiel <athiel@vintagetransport.com>  Mon Jun 25 11:45:48 2001
From: albertthiel <athiel@vintagetransport.com> (albertthiel)
Date: Mon, 25 Jun 2001 06:45:48 -0400
Subject: [Tutor] (no subject)
Message-ID: <144505637207.20010625064548@vintagetransport.com>

Vintage Transport is a blanket wrap service located in Atlanta, but
operating nationwide. We have been serving the needs of dealers in
antiques and designers, as well as individuals for over 15 years. Our
incidence of damage is very low because we take extra precautions to
ensure your valuables are safely packed, protected and stored in our
air-ride trucks.

You can visit our web site to gain more information and even obtain an
online quote at : http://www.vintagetransport.com or
http://www.antiquedelivery.net

This email is sent to you based on a list obtained from an email
house. If you wish to be removed from our list please reply and enter
REMOVE in the subject line.

Should you have any questions feel free to email me back.

You can also reach us at 800 333 0056

Albert



From arcege@speakeasy.net  Mon Jun 25 12:35:18 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Mon, 25 Jun 2001 07:35:18 -0400 (EDT)
Subject: [Tutor] What are you all up to?
In-Reply-To: <3B347D97.16808.18409E90@localhost> from "Jesse W" at Jun 23, 2001 11:29:27 AM
Message-ID: <200106251135.f5PBZIH10278@dsl092-074-184.bos1.dsl.speakeasy.net>

Jesse W wrote
> 
> <color><param>0100,0100,0100</param>Hello Pythoneers,
> 
> 
> 	What are you all up to?  What projects are you working on?

I'm a 32yo release engineer.  I've been writing a test package for VoIP
(voice-over-IP) simulations to help my company to test our product out.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From alan.gauld@bt.com  Mon Jun 25 12:18:13 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 25 Jun 2001 12:18:13 +0100
Subject: [Tutor] C++ Tutorial List?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D85B@mbtlipnt02.btlabs.bt.co.uk>

> I was wondering if anyone knew of a list similar to this one, 
> but devoted to 
> C++?

There used to be one for Borland C++ Builder which tended to 
cover lots of beginner stuff too.

It was on the ZiffDavis network someplace.
But I haven't looked near it for about 3 years.

Address was:

bcb-list@orionlink.net

If that helps,

Alan G


From alan.gauld@bt.com  Mon Jun 25 12:32:41 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 25 Jun 2001 12:32:41 +0100
Subject: [Tutor] What are you all up to?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D85C@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C0FD6A.8B385760
Content-type: text/plain; charset="ISO-8859-1"

        What are you all up to? What projects are you working on?  

Oh Ok, I'll play...
I use Python at work mainly to prototype ideas for bigger 
projects that I am the overall designer for, eg:
 
"Can I get the customer data from such-and-such a web site, 
and if so what would it look like?"
 
"Can I place an order using DCOM to that IIS web server 
rather than through http?"
 
"What kind of algorithm will I need to sort these bonus 
returns into ascending order to show which salesman had 
the greatest number of sales versus the greatest sales revenue?" 
 
etc etc...
 
At home I'm converting an Analog Electronic Design program from Pascal 
to Python and intending to add a GUI to that when its finished. 
It might wind up on Useless Python if it ever gets done!
 
And along with teaching myself Java, Scheme and Haskell that seems 
to be my programming time pretty well filled!!
 
Alan G

------_=_NextPart_001_01C0FD6A.8B385760
Content-type: text/html; charset="ISO-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<TITLE></TITLE>

<META content="MSHTML 5.00.3013.2600" name=GENERATOR></HEAD>
<BODY>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px">
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#010101>What are you 
  all up to? What projects are you working on?&nbsp;</FONT><FONT color=#0000ff 
  face="Courier New" size=2><SPAN 
  class=310443411-25062001>&nbsp;</SPAN></FONT></P></BLOCKQUOTE>
<DIV><SPAN class=310443411-25062001><FONT color=#0000ff face="Courier New" 
size=2>Oh Ok, I'll play...</FONT></SPAN></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=310443411-25062001>I use Python at work mainly&nbsp;to prototype ideas for 
bigger </SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=310443411-25062001>projects that I am the overall designer for, 
eg:</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=310443411-25062001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>"Can I get the customer data from such-and-such a web 
site, </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>and if so what would it look like?"</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff><FONT size=2><FONT face="Courier New"><SPAN 
class=310443411-25062001>"Can I place an order using DCOM&nbsp;to that IIS web 
server </SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT color=#0000ff><FONT size=2><FONT face="Courier New"><SPAN 
class=310443411-25062001>rather than t</SPAN><SPAN 
class=310443411-25062001>hrough http?"</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT color=#0000ff><FONT size=2><FONT face="Courier New"><SPAN 
class=310443411-25062001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>"What kind of algorithm will I need to sort these bonus 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>returns into ascending order to show which salesman had 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>the greatest number of </SPAN></FONT><SPAN 
class=310443411-25062001><FONT color=#0000ff face="Courier New" size=2>sales 
versus the greatest sales revenue?" </FONT></SPAN></DIV>
<DIV><SPAN class=310443411-25062001><FONT color=#0000ff face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=310443411-25062001><FONT color=#0000ff face="Courier New" 
size=2>etc etc...</FONT></SPAN></DIV>
<DIV><SPAN class=310443411-25062001></SPAN>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>At home I'm converting an Analog Electronic Design 
program from Pascal </SPAN></FONT><SPAN class=310443411-25062001><BR><FONT 
color=#0000ff face="Courier New" size=2>to Python and intending to add a GUI to 
that when its finished. <BR>It might wind up on Useless Python if it ever gets 
done!</FONT></SPAN></DIV>
<DIV><SPAN class=310443411-25062001></SPAN>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>And along with teaching myself Java, Scheme and Haskell 
that seems </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>to be my programming time pretty well 
filled!!</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=310443411-25062001>Alan G</SPAN></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01C0FD6A.8B385760--


From alan.gauld@bt.com  Mon Jun 25 12:49:23 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 25 Jun 2001 12:49:23 +0100
Subject: [Tutor] Python XML tree representation
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D85E@mbtlipnt02.btlabs.bt.co.uk>

> I'm looking for a tree representation (not event switcher) 
> OOP XML parser in Python (after parsing, there's an object tree in memory 

That's what the DOM does and there is a python DOM parser in
the standard distribution I think...

Alan G.


From ppathiyi@cisco.com  Mon Jun 25 13:03:48 2001
From: ppathiyi@cisco.com (Praveen Pathiyil)
Date: Mon, 25 Jun 2001 17:33:48 +0530
Subject: [Tutor] What are you all up to?
References: <3B347D97.16808.18409E90@localhost>
Message-ID: <011f01c0fd6e$e46a5e60$37ef87c0@ppathiyipc>

This is a multi-part message in MIME format.

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

Hi All,

        Couldn't resist adding some of my own (especially since nobody =
seems to be mentioning solaris:-) ). We are doing protocol simulations =
in python to run on solaris. Till now we have made SIP and ISUP protocol =
simulators. Currently on to making a TCAP over IP simulation. Inbetween =
one Telnet server also......
        But since this is official duty, not able to find much time for =
fun stuff.

Praveen.

----- Original Message -----=20
  From: Jesse W=20
  To: tutor@python.org=20
  Sent: Saturday, June 23, 2001 11:59 PM
  Subject: [Tutor] What are you all up to?


  Hello Pythoneers,

  What are you all up to? What projects are you working on?

  I am a 17 year old Python hacker-in-training. I tend to write re- =
implementations of games and interesting graphics hacks. I am currently =
writing re-implementation of Miles Bones, a car racing card game, and a =
variation of the card game Uno, called Hot Death Uno. I wrote the =
beginnings of a module to access and modify MIDI file data in Python, =
and many other small programs.

  Thank you for your time,
  Jesse W


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?color><?param 0100,0100,0100><HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi All,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
Couldn't=20
resist adding some of my own (especially since nobody seems to be =
mentioning=20
solaris:-) ). We are doing protocol simulations in python to run on =
solaris.=20
Till now we have made SIP and ISUP protocol simulators. Currently on to =
making a=20
TCAP over IP simulation. Inbetween one Telnet server =
also......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
But since=20
this is official duty, not able to find much time for fun =
stuff.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Praveen.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A href=3D"mailto:jessw@loop.com" title=3Djessw@loop.com>Jesse W</A> =
</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
href=3D"mailto:tutor@python.org"=20
  title=3Dtutor@python.org>tutor@python.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Saturday, June 23, 2001 =
11:59=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] What are you =
all up=20
  to?</DIV>
  <DIV><BR></DIV>Hello Pythoneers,<BR><BR>What are you all up to? What =
projects=20
  are you working on?<BR><BR>I am a 17 year old Python =
hacker-in-training. I=20
  tend to write re- implementations of games and interesting graphics =
hacks. I=20
  am currently writing re-implementation of Miles Bones, a car racing =
card game,=20
  and a variation of the card game Uno, called Hot Death Uno. I wrote =
the=20
  beginnings of a module to access and modify MIDI file data in Python, =
and many=20
  other small programs.<BR><BR>Thank you for your time,<BR>Jesse =
W<BR><PRE>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
</PRE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_011C_01C0FD9C.FDF325F0--



From Eugene.Leitl@lrz.uni-muenchen.de  Mon Jun 25 13:11:15 2001
From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl)
Date: Mon, 25 Jun 2001 14:11:15 +0200 (MET DST)
Subject: [Tutor] What are you all up to?
In-Reply-To: <011f01c0fd6e$e46a5e60$37ef87c0@ppathiyipc>
Message-ID: <Pine.SOL.4.33.0106251409350.2105-100000@sun1.lrz-muenchen.de>

On Mon, 25 Jun 2001, Praveen Pathiyil wrote:

> Hi All,
>         Couldn't resist adding some of my own (especially since nobody
> seems to be mentioning solaris:-) ). We are doing protocol simulations

Solaris, AIX, Linux here. Porting a chemical synthesis tree package to
web, starting with AIX.

> in python to run on solaris. Till now we have made SIP and ISUP
> protocol simulators. Currently on to making a TCAP over IP simulation.
> Inbetween one Telnet server also......
>         But since this is official duty, not able to find much time for fun stuff.

Ditto here. Will be hacking Python at home, though.

-- Eugen* Leitl <a href="http://www.lrz.de/~ui22204/">leitl</a>
______________________________________________________________
ICBMTO  : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204
57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3



From richert@c-lab.de  Mon Jun 25 13:39:35 2001
From: richert@c-lab.de (Willi Richert)
Date: Mon, 25 Jun 2001 14:39:35 +0200 (MET DST)
Subject: [Tutor] Exper. with pykde?
Message-ID: <Pine.GSO.4.21.0106251438290.25516-100000@dogbert>

Hi,

since thekompany.com is down for some time now, do you know, where I can
download the pykde package (RPM?).

Does anybody have experience with this library?

Thanks,
willi

Make laugh not war!



From dyoo@hkn.eecs.berkeley.edu  Mon Jun 25 16:20:49 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 25 Jun 2001 08:20:49 -0700 (PDT)
Subject: [Tutor] Help
In-Reply-To: <3B364A42.D1CEB620@web.de>
Message-ID: <Pine.LNX.4.21.0106250815070.18222-100000@hkn.eecs.berkeley.edu>

On Sun, 24 Jun 2001, Inka Menne wrote:

> today I started lerarning python. I hope to manage it. I never learned
> a progam language bevor. I am a designer, working in the font
> buisness. Is there someone how knows something about python and
> FontLab 4? How much Python must do I have learn to deal with FontLab
> 4? I'm working with a book from Ivan laningham to learn Python. At the
> moment I'm on page 77 and it is very strange for me. regards Inka

Hmmm... not quite sure about this one.  I'd expect that you'll need to
learn enough Python to use modules or objects.  Have you found any web
resources that explain how to work with Fontlab's Python stuff yet?

What sort of stuff is feeling strange in the Python book?  Perhaps we can
help clear things up!

Hope to talk to you later!



From dyoo@hkn.eecs.berkeley.edu  Mon Jun 25 16:40:45 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 25 Jun 2001 08:40:45 -0700 (PDT)
Subject: [Tutor] Exper. with pykde?
In-Reply-To: <Pine.GSO.4.21.0106251438290.25516-100000@dogbert>
Message-ID: <Pine.LNX.4.21.0106250833470.18222-100000@hkn.eecs.berkeley.edu>

On Mon, 25 Jun 2001, Willi Richert wrote:

> since thekompany.com is down for some time now, do you know, where I can
> download the pykde package (RPM?).

thekompany.com seems to be back up for me; can you check to see if it
works now?

    http://www.thekompany.com/projects/pykde/?dhtml_ok=0

There's a link to rpms from rpmfind.net:

http://rpmfind.net/linux/RPM/ASP/blackcat-linux/6.2/tools/i386/PyKDE-0.10-3.i386.html

However, it might be better to download the source code instead: the rpm
appears to be a bit dated.


> Does anybody have experience with this library?

I haven't touched pykde before.  However, there are some good resources
out there.  For example:

    http://www.xs4all.nl/~bsarempt/python/resources.html

and

    http://developer.kde.org/language-bindings/python/index.html

will be really helpful.  You may want to talk with the kde developers as
well: they'll definitely have more experience with this sort of
stuff.  They have several mailing lists set up here:

    http://www.kde.org/mailinglists.html

Good luck to you!



From jessw@loop.com  Mon Jun 25 19:47:00 2001
From: jessw@loop.com (Jesse W)
Date: Mon, 25 Jun 2001 11:47:00 -0700
Subject: [Tutor] A Challenge solution
In-Reply-To: <3B36D825.3366E0B3@aon.at>
Message-ID: <3B3724B4.17671.229DCC9A@localhost>

Dear Rabid Pythonics,
Gregor Lingl wrote: (in non-list e-mail)
> I was able to use your calculator to calcultate
> 10 * 9 in the following way:
> 
>    11 - 1 = * 9 =
> 
> result: 90
> 
> But how do I calculate 10 * 10 ?
> Regards
> Gregor Lingl
> 
> P.S.: Perhaps you should add "(" and ")"
> or, even better, "0"?
	Oh my.  Wow.  Ooof.  I really did- I really left- <hysterical, 
surprised laughter> I really left _zero_ off the calculator.  <closes 
his jaw, with a snap>  Oh.  Well, I'll go fix that now.  Thank you very 
much. :-)

					Jesse W



From jessw@loop.com  Mon Jun 25 19:56:36 2001
From: jessw@loop.com (Jesse W)
Date: Mon, 25 Jun 2001 11:56:36 -0700
Subject: [Tutor] Please send messages only to the list.
Message-ID: <3B3726F4.25331.22A6998F@localhost>

<Ding>,
Now I mean this with the greatest respect, but...

	I am getting pretty tired of getting two(2) copies of all the 
messages on tutor relating to threads I started.  I _am_ on the list, 
guys.  If all of you could only send messages to the list, not to me 
personally, that would be very appreciated.

	I apologize for whatever traces of smoke or flame may be 
creeping out of this message.  They are not intended.(Mostly :-))

		Thank you very much for your time,
				Jesse W


From rob@jam.rr.com  Mon Jun 25 20:17:12 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Mon, 25 Jun 2001 14:17:12 -0500
Subject: [Tutor] Please send messages only to the list.
References: <3B3726F4.25331.22A6998F@localhost>
Message-ID: <001901c0fdab$703aa3a0$de00a8c0@planhouse5>

> I am getting pretty tired of getting two(2) copies of all the
> messages on tutor relating to threads I started.  I _am_ on the list,
> guys.  If all of you could only send messages to the list, not to me
> personally, that would be very appreciated.
>

I'm sure no ill is intended by it. The default "reply to" points to the
sender, and respondents have to actually remember to add the list itself to
the reply fields.

Rob

Useless Python
It's not just for breakfast anymore!
http://www.lowerstandard.com/python/index.html



From sheila@thinkspot.net  Mon Jun 25 20:21:02 2001
From: sheila@thinkspot.net (Sheila King)
Date: Mon, 25 Jun 2001 12:21:02 -0700
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <001901c0fdab$703aa3a0$de00a8c0@planhouse5>
References: <3B3726F4.25331.22A6998F@localhost> <001901c0fdab$703aa3a0$de00a8c0@planhouse5>
Message-ID: <1992B94541@kserver.org>

On Mon, 25 Jun 2001 14:17:12 -0500, "Rob Andrews" <rob@jam.rr.com>
wrote about Re: [Tutor] Please send messages only to the list.:

:> I am getting pretty tired of getting two(2) copies of all the
:> messages on tutor relating to threads I started.  I _am_ on the list,
:> guys.  If all of you could only send messages to the list, not to me
:> personally, that would be very appreciated.
:>
:
:I'm sure no ill is intended by it. The default "reply to" points to the
:sender, and respondents have to actually remember to add the list itself to
:the reply fields.

Well, either that. Or some people use the "Reply To All" feature to get
around the limitation that "Reply To" only replies to the sender.
However, "Reply To All" will reply to the list AND the sender. This
means, to reply to the list only, you have to edit out the author's
e-mail address.

Having been a member of this list for several months (and being a member
of quite a number of other lists), it seems to me that this list's
culture indicates most subscribers use the "Reply To All" and that
everyone more or less accepts that they get two replies.

I've learned to live with it. No biggie.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From DavidCraig@PIA.CA.GOV  Mon Jun 25 20:29:00 2001
From: DavidCraig@PIA.CA.GOV (DavidCraig@PIA.CA.GOV)
Date: Mon, 25 Jun 2001 12:29:00 -0700
Subject: [Tutor] What am I missing on the index?
Message-ID: <OF7F09D5DE.00B5B224-ON88256A76.006A3074@PIA.CA.GOV>

Sorry to bother you all again.  I have been trying this one all weekend.
What am I doing wrong.  This is an exercise from How to Think Like a
Computer Scientist (Python):

The exercise is to write a function that takes a string as an argument that
and outputs the letters backwards, one per line.

## stringloop function prints a string backwards

def stringback(string):
    string = "David"
    index = 0
    while index < len(string):
        letter = string[index]
        print letter
        index = index - 1

And my output back is:

Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>>
stringback(string)
D
d
i
v
a
D
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in ?
    stringback(string)
  File "C:/Python21/Practice/stringback.py", line 7, in stringback
    letter = string[index]
IndexError: string index out of range


Any help would be appreciated.  I just can't seem to see it.

Thanks , Dave
D. H. Craig, CSM




From ak@silmarill.org  Mon Jun 25 20:33:24 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Mon, 25 Jun 2001 15:33:24 -0400
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <"from sheila"@thinkspot.net>
References: <3B3726F4.25331.22A6998F@localhost>
 <001901c0fdab$703aa3a0$de00a8c0@planhouse5> <1992B94541@kserver.org>
Message-ID: <20010625153324.A31073@sill.silmarill.org>

On Mon, Jun 25, 2001 at 12:21:02PM -0700, Sheila King wrote:
> On Mon, 25 Jun 2001 14:17:12 -0500, "Rob Andrews" <rob@jam.rr.com>
> wrote about Re: [Tutor] Please send messages only to the list.:
> 
> :> I am getting pretty tired of getting two(2) copies of all the
> :> messages on tutor relating to threads I started.  I _am_ on the list,
> :> guys.  If all of you could only send messages to the list, not to me
> :> personally, that would be very appreciated.
> :>
> :
> :I'm sure no ill is intended by it. The default "reply to" points to the
> :sender, and respondents have to actually remember to add the list itself to
> :the reply fields.
> 
> Well, either that. Or some people use the "Reply To All" feature to get
> around the limitation that "Reply To" only replies to the sender.
> However, "Reply To All" will reply to the list AND the sender. This
> means, to reply to the list only, you have to edit out the author's
> e-mail address.
> 
> Having been a member of this list for several months (and being a member
> of quite a number of other lists), it seems to me that this list's
> culture indicates most subscribers use the "Reply To All" and that
> everyone more or less accepts that they get two replies.
> 
> I've learned to live with it. No biggie.

I think mutt's 'L' command replies only to list, do other mail clients
have similar commands? I myself never got a double message from this
list but I guess it could be somewhat annoying if it was happening all
the time.

> 
> --
> Sheila King
> http://www.thinkspot.net/sheila/
> http://www.k12groups.org/
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline


From sheila@thinkspot.net  Mon Jun 25 20:39:40 2001
From: sheila@thinkspot.net (Sheila King)
Date: Mon, 25 Jun 2001 12:39:40 -0700
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <20010625153324.A31073@sill.silmarill.org>
References: <3B3726F4.25331.22A6998F@localhost> <001901c0fdab$703aa3a0$de00a8c0@planhouse5> <1992B94541@kserver.org> <"from sheila"@thinkspot.net> <20010625153324.A31073@sill.silmarill.org>
Message-ID: <2A8CF954CB@kserver.org>

On Mon, 25 Jun 2001 15:33:24 -0400, sill@optonline.net  wrote about Re:
[Tutor] Please send messages only to the list.:

:
:I think mutt's 'L' command replies only to list, do other mail clients
:have similar commands? I myself never got a double message from this
:list but I guess it could be somewhat annoying if it was happening all
:the time.

I think that mutt's "L" command is fairly unique. I, personally, know of
no other client that has this.

I almost always get double replies to this list, but as I noted, it
doesn't bother me. (I just made a decision that it wasn't worth it to
fuss over, because I wouldn't change everyone's opinion on this one.)
Now, you are using mutt, and apparently used the "L" command, so I
didn't get two copies of *this* message.

Are you getting two copies of mine? I use Agent and used the "Reply To
All" command, and it has both the list and your e-mail address in the
message I'm composing.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From deirdre@deirdre.net  Mon Jun 25 20:39:38 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Mon, 25 Jun 2001 12:39:38 -0700
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <3B3726F4.25331.22A6998F@localhost>
References: <3B3726F4.25331.22A6998F@localhost>
Message-ID: <a05101005b75d43a61f26@[10.20.0.138]>

At 11:56 AM -0700 6/25/01, Jesse W wrote:
><Ding>,
>Now I mean this with the greatest respect, but...
>
>	I am getting pretty tired of getting two(2) copies of all the
>messages on tutor relating to threads I started.  I _am_ on the list,
>guys.  If all of you could only send messages to the list, not to me
>personally, that would be very appreciated.

Learn to use procmail.

There are reasons I send both copies and I prefer my habit, nor do I 
need to see the need to justify it. If it bothers you, there ARE 
technological solutions.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From cynic@mail.cz  Mon Jun 25 20:50:35 2001
From: cynic@mail.cz (Cynic)
Date: Mon, 25 Jun 2001 21:50:35 +0200
Subject: [Tutor] What am I missing on the index?
In-Reply-To: <OF7F09D5DE.00B5B224-ON88256A76.006A3074@PIA.CA.GOV>
Message-ID: <5.1.0.14.2.20010625214747.01f7d008@mail.cz>

At 21:29 6/25/2001, DavidCraig@PIA.CA.GOV wrote the following:
-------------------------------------------------------------- 
>The exercise is to write a function that takes a string as an argument that
>and outputs the letters backwards, one per line.
>
>## stringloop function prints a string backwards
>
>def stringback(string):
>    string = "David"
    index = len(string)
    while 0 < index:
        letter = string[index-1]
>       print letter
         index = index - 1




cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
    - Book of Installation chapt 3 sec 7 



From nstalkie@tvd.be  Mon Jun 25 20:58:33 2001
From: nstalkie@tvd.be (Sammy Mannaert)
Date: Mon, 25 Jun 2001 21:58:33 +0200
Subject: [Tutor] What am I missing on the index?
References: <OF7F09D5DE.00B5B224-ON88256A76.006A3074@PIA.CA.GOV>
Message-ID: <3B3797E9.7EE96F6E@tvd.be>

DavidCraig@PIA.CA.GOV wrote:
> 
> Sorry to bother you all again.  I have been trying this one all weekend.
> What am I doing wrong.  This is an exercise from How to Think Like a
> Computer Scientist (Python):
> 
> The exercise is to write a function that takes a string as an argument that
> and outputs the letters backwards, one per line.
> 
> ## stringloop function prints a string backwards
> 
> def stringback(string):
>     string = "David"
>     index = 0
>     while index < len(string):
>         letter = string[index]
>         print letter
>         index = index - 1
> 
> 

look at the 'index' variable. the first time you 
enter the loop what is it's value ?

0 -> D gets printed

next time in the loop it is :
-1 -> d gets printed
-2 -> i
-3 -> ...

you will keep going more and more negative because
index will stay lower than len(string)


def stringback(string):
    string = "David"
    index = len(string) - 1
    while index >= 0:
        print string[index]
        index = index - 1

this is a corrected version : i start from the top
and work my way down to the bottom ..


From richert@c-lab.de  Mon Jun 25 21:03:20 2001
From: richert@c-lab.de (Willi Richert)
Date: Mon, 25 Jun 2001 22:03:20 +0200 (MET DST)
Subject: [Tutor] Problems installing PyKDE
Message-ID: <Pine.GSO.4.21.0106252201540.27836-100000@dogbert>

Hi,

when I try to make PyKDE (after successfully having installed sip and
PyQT) I get

> make
make  all-recursive
make[1]: Entering directory `/home/willi/install/pykde/PyKDE-2.4'
Making all in kdecore
make[2]: Entering directory `/home/willi/install/pykde/PyKDE-2.4/kdecore'
c++ -DHAVE_CONFIG_H -I. -I. -I..  -I/usr/include/python2.0
-I/usr/local/include/sip -I/usr/lib/qt2//include  -I/usr/X11R6/include
-I/opt/kde/include  -fno-exceptions -O2 -c -o sip_helper.o `test -f
sip_helper.cpp || echo './'`sip_helper.cpp
/bin/sh ../libtool --mode=link c++ -fno-exceptions -O2   -o sip_helper
sip_helper.o
mkdir .libs
c++ -fno-exceptions -O2 -o sip_helper sip_helper.o
./sip_helper >sipkdecoreVersion.h
c++ -E -I/usr/include/python2.0 -I/usr/local/include/sip
-I/usr/lib/qt2//include  -I/usr/X11R6/include -I/opt/kde/include -o
moc_sipkdecoreProxykdecore.h sipkdecoreProxykdecore.h
/usr/lib/qt2//bin/moc -o sipkdecoreProxykdecore.moc
moc_sipkdecoreProxykdecore.h
/bin/sh ../libtool --mode=compile c++ -DHAVE_CONFIG_H
-I. -I. -I..  -I/usr/include/python2.0 -I/usr/local/include/sip
-I/usr/lib/qt2//include
 -I/usr/X11R6/include -I/opt/kde/include  -fno-exceptions -O2 -c -o
kdecorecmodule.lo `test -f kdecorecmodule.cpp || echo
'./'`kdecorecmodule.cpp
c++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/python2.0
-I/usr/local/include/sip -I/usr/lib/qt2//include -I/usr/X11R6/include
-I/opt/kde/include -fno-exceptions -O2 -c kdecorecmodule.cpp  -fPIC -DPIC
-o kdecorecmodule.lo
In file included from kdecorecmodule.cpp:32:
kdrag.sip:16: drag.h: No such file or directory
In file included from sipkdecoreKApplication.h:47,
                 from kdecorecmodule.cpp:35:
kdrag.sip:45: drag.h: No such file or directory
In file included from kdecorecmodule.cpp:39:
kcolorgroup.sip:18: kcolorgroup.h: No such file or directory
In file included from kdecorecmodule.cpp:42:
kdrag.sip:29: drag.h: No such file or directory
In file included from kdecorecmodule.cpp:44:
kdrag.sip:120: drag.h: No such file or directory
make[2]: *** [kdecorecmodule.lo] Error 1
make[2]: Leaving directory `/home/willi/install/pykde/PyKDE-2.4/kdecore'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/willi/install/pykde/PyKDE-2.4'
make: *** [all-redirect] Error 2

Does anybody know what is wrong? I don't find this nasty drag.h on my
harddrive.

Thanks very much,
willi

Make laugh not war!



From dyoo@hkn.eecs.berkeley.edu  Mon Jun 25 21:14:52 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 25 Jun 2001 13:14:52 -0700 (PDT)
Subject: [Tutor] Problems installing PyKDE
In-Reply-To: <Pine.GSO.4.21.0106252201540.27836-100000@dogbert>
Message-ID: <Pine.LNX.4.21.0106251306360.21547-100000@hkn.eecs.berkeley.edu>

On Mon, 25 Jun 2001, Willi Richert wrote:

> -I/usr/local/include/sip -I/usr/lib/qt2//include -I/usr/X11R6/include
> -I/opt/kde/include -fno-exceptions -O2 -c kdecorecmodule.cpp  -fPIC -DPIC
> -o kdecorecmodule.lo
> In file included from kdecorecmodule.cpp:32:
> kdrag.sip:16: drag.h: No such file or directory
> In file included from sipkdecoreKApplication.h:47,
>                  from kdecorecmodule.cpp:35:
> kdrag.sip:45: drag.h: No such file or directory
> In file included from kdecorecmodule.cpp:39:
> kcolorgroup.sip:18: kcolorgroup.h: No such file or directory
> In file included from kdecorecmodule.cpp:42:
> kdrag.sip:29: drag.h: No such file or directory
> In file included from kdecorecmodule.cpp:44:
> kdrag.sip:120: drag.h: No such file or directory
> make[2]: *** [kdecorecmodule.lo] Error 1
> make[2]: Leaving directory `/home/willi/install/pykde/PyKDE-2.4/kdecore'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/home/willi/install/pykde/PyKDE-2.4'
> make: *** [all-redirect] Error 2

It looks like it's trying to find a header file for either KDE or QT...
checking... yes, "drag.h" is a header from the kde system.
 
You may want to check to see if you've installed the kde development
package.  Are you running Red Hat Linux?  If so, you'll probably want to
make sure you have the "kdelibs-devel" package installed.  Try this
command on your prompt:

###
$ rpm -qa | grep kdelibs-devel
###

The command above will search your system to see if the kdelibs-devel RPM
was installed --- it's not by default, so I'd expect this to be the reason
for the error message.  If you don't see anything print out, then that
confirms that you need to install kdelibs-devel.

There's a link to kdelibs-devel on any Red Hat mirror.  For example:

ftp://ftp.linuxberg.com/pub/distributions/RedHat/i386/en/RedHat/RPMS/kdelibs-devel-1.1.2-24.i386.rpm

should be a valid link.  After you install kdelibs-devel, try recompiling
PyKDE.  With luck, that should fix things.

If you have more questions, feel free to ask!



From dsh8290@rit.edu  Mon Jun 25 21:31:04 2001
From: dsh8290@rit.edu (D-Man)
Date: Mon, 25 Jun 2001 16:31:04 -0400
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <2A8CF954CB@kserver.org>; from sheila@thinkspot.net on Mon, Jun 25, 2001 at 12:39:40PM -0700
References: <3B3726F4.25331.22A6998F@localhost> <001901c0fdab$703aa3a0$de00a8c0@planhouse5> <1992B94541@kserver.org> <"from <20010625153324.A31073@sill.silmarill.org> <2A8CF954CB@kserver.org>
Message-ID: <20010625163104.B14134@harmony.cs.rit.edu>

On Mon, Jun 25, 2001 at 12:39:40PM -0700, Sheila King wrote:
| On Mon, 25 Jun 2001 15:33:24 -0400, sill@optonline.net  wrote about Re:
| [Tutor] Please send messages only to the list.:
| 
| :I think mutt's 'L' command replies only to list, do other mail clients
| :have similar commands? I myself never got a double message from this
| :list but I guess it could be somewhat annoying if it was happening all
| :the time.
| 
| I think that mutt's "L" command is fairly unique. I, personally, know of
| no other client that has this.

gnus has it too (or whatever the email part of emacs is called,
obviously I use mutt too -- check the X-Mailer header).  There is a
header called "Mail-Followup-To" that lists where followups should be
sent.  Mutt allows me to specify lists that I am subscribed to, and
lists that you are not.  When I send a message to a list I am
subscribed to the Mail-Followup-To has only the list's address.  When
someone else use's the list-reply function ("L" in mutt) the reply is
sent only to the list.  If I am not subscribed to a list I send a
message to (or I specify that I want a double copy) mutt puts my
address in that header field as well.  It is a pretty cool feature,
really, because people get to choose whether or not they get the extra
copy from other people.

(BTW mutt also allows customization of which headers are displayed and
in what order when viewing a message.  I really like this too :-))

| I almost always get double replies to this list, but as I noted, it
| doesn't bother me. (I just made a decision that it wasn't worth it to
| fuss over, because I wouldn't change everyone's opinion on this one.)

I don't pay enough attention to whether or not I got a double copy.  I
just delete the extra one and move the other to the list's folder.

| Now, you are using mutt, and apparently used the "L" command, so I
| didn't get two copies of *this* message.

That means you don't have your address in the Mail-Followup-To header.
I just went back and checked, there is no Mail-Followup-To header in
your message, so mutt didn't give you an extra copy.  Some (most,
AFAIK) mailers just ignore the header.

| Are you getting two copies of mine? I use Agent and used the "Reply To
| All" command, and it has both the list and your e-mail address in the
| message I'm composing.

He did (I'm assuming he's subscribed <wink>).  Your headers have :

--------
 To: ak@silmarill.org
 Cc: tutor@python.org
--------


-D

PS.  I'm not trying to argue here, just provide some trivia that I've
     noticed.



From ak@silmarill.org  Mon Jun 25 21:52:53 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Mon, 25 Jun 2001 16:52:53 -0400
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <"from sheila"@thinkspot.net>
References: <3B3726F4.25331.22A6998F@localhost>
 <001901c0fdab$703aa3a0$de00a8c0@planhouse5> <1992B94541@kserver.org>
Message-ID: <20010625165253.A31435@sill.silmarill.org>

On Mon, Jun 25, 2001 at 12:39:40PM -0700, Sheila King wrote:
> On Mon, 25 Jun 2001 15:33:24 -0400, sill@optonline.net  wrote about Re:
> [Tutor] Please send messages only to the list.:
> 
> :
> :I think mutt's 'L' command replies only to list, do other mail clients
> :have similar commands? I myself never got a double message from this
> :list but I guess it could be somewhat annoying if it was happening all
> :the time.
> 
> I think that mutt's "L" command is fairly unique. I, personally, know of
> no other client that has this.
> 
> I almost always get double replies to this list, but as I noted, it
> doesn't bother me. (I just made a decision that it wasn't worth it to
> fuss over, because I wouldn't change everyone's opinion on this one.)
> Now, you are using mutt, and apparently used the "L" command, so I
> didn't get two copies of *this* message.
> 
> Are you getting two copies of mine? I use Agent and used the "Reply To
> All" command, and it has both the list and your e-mail address in the
> message I'm composing.

Yep, got two of these..

This issue came up some time ago and as I recall someone wanted list to change
it's behaviour so that doing 'reply' to a message would just send it to the
list, and someone else pointed out a few reasons why it's not a good idea,
(in particular, poster's original email may get lost if he has it only in
'reply-to' part of header), and said that all decent clients should be able
to reply to just the list. 

I think Eudora pro should have that and emacs and pine, netscape or all/most
webmails and Outlook don't, i'll bet.

> 
> --
> Sheila King
> http://www.thinkspot.net/sheila/
> http://www.k12groups.org/
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline


From deirdre@deirdre.net  Mon Jun 25 22:05:54 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Mon, 25 Jun 2001 14:05:54 -0700
Subject: Stop thread please Re: [Tutor] Please send messages only to the
 list.
In-Reply-To: <20010625165253.A31435@sill.silmarill.org>
References: <3B3726F4.25331.22A6998F@localhost>
 <001901c0fdab$703aa3a0$de00a8c0@planhouse5> <1992B94541@kserver.org>
 <20010625165253.A31435@sill.silmarill.org>
Message-ID: <a05101008b75d57d1d8a4@[10.20.0.138]>

List owner directive: Enough. :)

Let's get back to talking about Python and not people's nits with 
mail readers, writers of mail, etc.

Ultimately, it doesn't matter: no matter what way any given person 
picks, it'll annoy someone else.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From kromag@nsacom.net  Tue Jun 26 00:38:05 2001
From: kromag@nsacom.net (kromag@nsacom.net)
Date: Mon, 25 Jun 2001 16:38:05 -0700 (PDT)
Subject: [Tutor] Brainbench certification
Message-ID: <200106252338.f5PNc5d23733@pop.nsacom.net>

Well, I tried taking the brainbench python1.5 certification.

I am now going home to dab soothing ungents upon my footprint-covered 
buttocks.

For those of us who never dealt with python previous to 2.0... you guys had 
some UUUUUGLY lookin' stuff going on back in the day.

BTW, I got a 2.45, 2.75 is required to pass. I really doubt that I deserved 
the 2.45 as I am sure I guessed at at least 1/3 of them. (Okay, half) The 
hardest thing about the test is having the fortitude to not paste all the 
example code into your interpreter!

Be warned: the writer of this particular test has a deep and abiding 
understanding of numeric functions. If you do not, save your $20.00 until you 
do! :-)

And that is the news from the newbie front.

d


P.S. Are there any other quiz-type sites like this that would help a poltroon 
learn all the weird bits?


From brett@earthlight.co.nz  Mon Jun 25 22:27:24 2001
From: brett@earthlight.co.nz (Brett Shand)
Date: Tue, 26 Jun 2001 09:27:24 +1200
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <20010625165253.A31435@sill.silmarill.org>
References: <"from sheila"@thinkspot.net>
Message-ID: <3B38557C.789.F547DB7@localhost>

On 25 Jun 2001, at 16:52, sill@optonline.net wrote:

> > I think that mutt's "L" command is fairly unique. I, personally,
> > know of no other client that has this.

... or if you are stuck using windoze (as i am) or have a mac use 
pegasus mail, a wonderful freeware email client and set the 
"advanced reply" option. 

http://www.pmail.com/

brett


From michael@trollope.org  Mon Jun 25 22:31:30 2001
From: michael@trollope.org (M.A. Powe)
Date: Mon, 25 Jun 2001 14:31:30 -0700
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <20010625163104.B14134@harmony.cs.rit.edu> (message from D-Man on
 Mon, 25 Jun 2001 16:31:04 -0400)
References: <3B3726F4.25331.22A6998F@localhost> <001901c0fdab$703aa3a0$de00a8c0@planhouse5> <1992B94541@kserver.org> <"from <20010625153324.A31073@sill.silmarill.org> <2A8CF954CB@kserver.org> <20010625163104.B14134@harmony.cs.rit.edu>
Message-ID: <200106252131.f5PLVUK17306@shell1.aracnet.com>

>>>>> "D-Man" == D-Man  <dsh8290@rit.edu> writes:

    D-Man> On Mon, Jun 25, 2001 at 12:39:40PM -0700, Sheila King
    D-Man> wrote: | On Mon, 25 Jun 2001 15:33:24 -0400,
    D-Man> sill@optonline.net wrote about Re: | [Tutor] Please send
    D-Man> messages only to the list.: | | :I think mutt's 'L' command
    D-Man> replies only to list, do other mail clients | :have similar
    D-Man> commands? I myself never got a double message from this |
    D-Man> :list but I guess it could be somewhat annoying if it was
    D-Man> happening all | :the time.  | | I think that mutt's "L"
    D-Man> command is fairly unique. I, personally, know of | no other
    D-Man> client that has this.

    D-Man> gnus has it too (or whatever the email part of emacs is
    D-Man> called, obviously I use mutt too -- check the X-Mailer
    D-Man> header).  There is a header called "Mail-Followup-To" that
    D-Man> lists where followups should be sent.  Mutt allows me to
    D-Man> specify lists that I am subscribed to, and lists that you
    D-Man> are not.  When I send a message to a list I am subscribed
    D-Man> to the Mail-Followup-To has only the list's address.  When
    D-Man> someone else use's the list-reply function ("L" in mutt)
    D-Man> the reply is sent only to the list.  If I am not subscribed
    D-Man> to a list I send a message to (or I specify that I want a
    D-Man> double copy) mutt puts my address in that header field as
    D-Man> well.  It is a pretty cool feature, really, because people
    D-Man> get to choose whether or not they get the extra copy from
    D-Man> other people.

    D-Man> (BTW mutt also allows customization of which headers are
    D-Man> displayed and in what order when viewing a message.  I
    D-Man> really like this too :-))

    D-Man> | I almost always get double replies to this list, but as I
    D-Man> noted, it | doesn't bother me. (I just made a decision that
    D-Man> it wasn't worth it to | fuss over, because I wouldn't
    D-Man> change everyone's opinion on this one.)

    D-Man> I don't pay enough attention to whether or not I got a
    D-Man> double copy.  I just delete the extra one and move the
    D-Man> other to the list's folder.

    D-Man> | Now, you are using mutt, and apparently used the "L"
    D-Man> command, so I | didn't get two copies of *this* message.

    D-Man> That means you don't have your address in the
    D-Man> Mail-Followup-To header.  I just went back and checked,
    D-Man> there is no Mail-Followup-To header in your message, so
    D-Man> mutt didn't give you an extra copy.  Some (most, AFAIK)
    D-Man> mailers just ignore the header.

In fact, MailMan's default behavior is just broken.  Sorry, but the
'reply-to munging harmful' arguments don't wash. 90% of the mailing
list users should not have to adjust their mailers to accomodate the
10% who don't want to.  Speaking as a listowner who uses MailMan.  The
default behavior should be 'reply to list.'

mp

-- 
			     Michael Powe
	      looie@aracnet.com     michael@trollope.org
	  "All we are basically are monkeys with car keys."
			 -- Northern Exposure


From csmith@blakeschool.org  Mon Jun 25 23:11:22 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Mon, 25 Jun 2001 17:11:22 -0500
Subject: [Tutor] Accessing calling module's globals in a module
In-Reply-To: <3B376097.84548DD9@attglobal.net>
References: <fc.004c4b6b0075bcfe004c4b6b0075bcfe.75bda8@blakeschool.org>
 <	>
 <3B34AEC6.B5962C1@attglobal.net>
 <fc.004c4b6b0075c473004c4b6b0075bcfe.75c49a@blakeschool.org>
 <3B376097.84548DD9@attglobal.net>
Message-ID: <fc.004c4b6b0075d85a004c4b6b0075bcfe.75d85d@blakeschool.org>

rol9999@attglobal.net writes:
>> wishfully something like this:
>> >>> a=2
>> >>> id(2)
>> 12335043  #some number
>> >>> nameof(12335043)
>> 'a'
>
>If a do this:
>
>>>> a = 2
>>>> b = a
>>>> c = b
>>>> id(2)
>12335043
>>>> nameof(12335043)
>
>What name should be returned?
>
>In Python an object can have many names. 
>Also, string objects and some integer objects are interned.

I see that you are right.  In addition, a variable may have passed through
several functions/modules on the way to the present function/module so
saying what variable it is that you are dealing with is not really that
useful.  

Thanks for the feedback.

/c



From scarblac@pino.selwerd.nl  Mon Jun 25 23:18:38 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 26 Jun 2001 00:18:38 +0200
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <20010625153324.A31073@sill.silmarill.org>; from sill@optonline.net on Mon, Jun 25, 2001 at 03:33:24PM -0400
References: <3B3726F4.25331.22A6998F@localhost> <001901c0fdab$703aa3a0$de00a8c0@planhouse5> <1992B94541@kserver.org> <"from <20010625153324.A31073@sill.silmarill.org>
Message-ID: <20010626001837.A23235@pino.selwerd.nl>

On  0, sill@optonline.net wrote:
> I think mutt's 'L' command replies only to list,

Stop right there. I use mutt. How does the 'L' command work? For me it says,
"no mailing lists found."

-- 
Remco Gerlich


From ak@silmarill.org  Mon Jun 25 23:32:09 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Mon, 25 Jun 2001 18:32:09 -0400
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <"from scarblac"@pino.selwerd.nl>
References: <3B3726F4.25331.22A6998F@localhost>
 <001901c0fdab$703aa3a0$de00a8c0@planhouse5> <1992B94541@kserver.org>
Message-ID: <20010625183209.A31721@sill.silmarill.org>

On Tue, Jun 26, 2001 at 12:18:38AM +0200, Remco Gerlich wrote:
> On  0, sill@optonline.net wrote:
> > I think mutt's 'L' command replies only to list,
> 
> Stop right there. I use mutt. How does the 'L' command work? For me it says,
> "no mailing lists found."
> 
> -- 
> Remco Gerlich

You have to have this line in your .muttrc:

subscribe tutor

> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline


From bsass@freenet.edmonton.ab.ca  Mon Jun 25 23:46:56 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Mon, 25 Jun 2001 16:46:56 -0600 (MDT)
Subject: [Tutor] Problems installing PyKDE
In-Reply-To: <Pine.GSO.4.21.0106252201540.27836-100000@dogbert>
Message-ID: <Pine.LNX.4.33.0106251643320.19074-100000@bms>

On Mon, 25 Jun 2001, Willi Richert wrote:
> when I try to make PyKDE (after successfully having installed sip and
> PyQT) I get
>
> > make
> make  all-recursive
> make[1]: Entering directory `/home/willi/install/pykde/PyKDE-2.4'
> Making all in kdecore
> make[2]: Entering directory `/home/willi/install/pykde/PyKDE-2.4/kdecore'
> c++ -DHAVE_CONFIG_H -I. -I. -I..  -I/usr/include/python2.0
> -I/usr/local/include/sip -I/usr/lib/qt2//include  -I/usr/X11R6/include
                                     ^^^^^
I thought KDE-1.x needed Qt-1.x

<...>
> Does anybody know what is wrong? I don't find this nasty drag.h on my
> harddrive.

Are you using KDE1 or KDE2?

PyKDE only works with KDE-1.x.

PyKDE2 is more than a month away.


- Bruce



From w.richert@gmx.net  Tue Jun 26 11:02:34 2001
From: w.richert@gmx.net (Willi Richert)
Date: Tue, 26 Jun 2001 12:02:34 +0200
Subject: [Tutor] Problems installing PyKDE
In-Reply-To: <Pine.LNX.4.33.0106251643320.19074-100000@bms>
References: <Pine.LNX.4.33.0106251643320.19074-100000@bms>
Message-ID: <01062612030800.08832@woodstock>

Oh thanks,

yes, I have kde2. So I just have to wait.

willi

On Tue, 26 Jun 2001, you wrote:
> On Mon, 25 Jun 2001, Willi Richert wrote:
> > when I try to make PyKDE (after successfully having installed sip and
> > PyQT) I get
> >
> > > make
> > make  all-recursive
> > make[1]: Entering directory `/home/willi/install/pykde/PyKDE-2.4'
> > Making all in kdecore
> > make[2]: Entering directory `/home/willi/install/pykde/PyKDE-2.4/kdecore'
> > c++ -DHAVE_CONFIG_H -I. -I. -I..  -I/usr/include/python2.0
> > -I/usr/local/include/sip -I/usr/lib/qt2//include  -I/usr/X11R6/include
>                                      ^^^^^
> I thought KDE-1.x needed Qt-1.x
> 
> <...>
> > Does anybody know what is wrong? I don't find this nasty drag.h on my
> > harddrive.
> 
> Are you using KDE1 or KDE2?
> 
> PyKDE only works with KDE-1.x.
> 
> PyKDE2 is more than a month away.
> 
> 
> - Bruce
-- 
Make laugh not war!


From steve@mercury.in.cqsl.com  Tue Jun 26 13:43:58 2001
From: steve@mercury.in.cqsl.com (lonetwin@yahoo.com)
Date: Tue, 26 Jun 2001 18:13:58 +0530 (IST)
Subject: [Tutor] Curses programming
Message-ID: <Pine.LNX.4.21.0106261744320.3738-100000@mercury.in.cqsl.com>

Greetings everybody,
 b4 I ask for help, lemme tell u this, this list is ultra-cool, all u guys
are either ^^really nice^^ ppl (the kind who'd help an old lady cross the
road... weather she actually want to or not, well..eh..umm..eh..) or have got
too much time on u r hands :)
 No, seriously tho' this list is one o' the most helpful and cordial list I've
joined.
 N E Ways, what I want help on, is not a particular problem as such. I'm trying
to get my hands dirty with curses programming under linux using python. I've
never done n e curses/ncurses programming using C. I've read the curses howto
for python and have managed to draw boxes and buttons and stuff on the console.
	Problem is since I have never ever created a (G)UI application, I'm at a
loss as to how to go about it...I mean the design part, an' that is y 'm here,
I'd REALLY appreciate it if somebody cud guide me ....an' I'd give my pet frog
to anyone who could lead-me-into/work-with-me to create an' actual curses based
application (that's always been the only way I learn...take up a project, an'
learn whatever is requiem to get it done) (no wonder I learn so less <grin>).
	I already have a few small ideas as far as the applications go (didn't
somebody mention a tetris-extension for an editor sometime back ....well I use
vi ....hmmmmmmmmmmm)....so, that's it....if I haven't been clear 'nuff
(my effective communication quotient = -0.5) plz say so.

Thanx everyone
Peace
Steve

-- 
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||	
|||/\##|||||||||##/\||	
|/    \#########/    \	
|\     \#######/     /	
||\____/#######\____/|	
=====================================	
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
====================================



From ak@silmarill.org  Tue Jun 26 14:19:56 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Tue, 26 Jun 2001 09:19:56 -0400
Subject: [Tutor] Curses programming
In-Reply-To: <"from steve"@mercury.in.cqsl.com>
References: <Pine.LNX.4.21.0106261744320.3738-100000@mercury.in.cqsl.com>
Message-ID: <20010626091956.A652@sill.silmarill.org>

On Tue, Jun 26, 2001 at 06:13:58PM +0530, lonetwin@yahoo.com wrote:
> Greetings everybody,
>  b4 I ask for help, lemme tell u this, this list is ultra-cool, all u guys
> are either ^^really nice^^ ppl (the kind who'd help an old lady cross the
> road... weather she actually want to or not, well..eh..umm..eh..) or have got
> too much time on u r hands :)
>  No, seriously tho' this list is one o' the most helpful and cordial list I've
> joined.
>  N E Ways, what I want help on, is not a particular problem as such. I'm trying
> to get my hands dirty with curses programming under linux using python. I've
> never done n e curses/ncurses programming using C. I've read the curses howto
> for python and have managed to draw boxes and buttons and stuff on the console.
> 	Problem is since I have never ever created a (G)UI application, I'm at a
> loss as to how to go about it...I mean the design part, an' that is y 'm here,
> I'd REALLY appreciate it if somebody cud guide me ....an' I'd give my pet frog
> to anyone who could lead-me-into/work-with-me to create an' actual curses based
> application (that's always been the only way I learn...take up a project, an'
> learn whatever is requiem to get it done) (no wonder I learn so less <grin>).
> 	I already have a few small ideas as far as the applications go (didn't
> somebody mention a tetris-extension for an editor sometime back ....well I use
> vi ....hmmmmmmmmmmm)....so, that's it....if I haven't been clear 'nuff
> (my effective communication quotient = -0.5) plz say so.
> 
> Thanx everyone
> Peace
> Steve

Try looking at some existing curses-based application, I know that's hard but
personally tutoring someone through a complete application, well, people who
are *that* nice are probably too busy working for red cross. ;-)

OTOH I'm also meaning to start working on a curses-based irc client real-soon-
now. I guess if I do get around to that, I could post incremental versions
online, that's probably much easier to study by than looking at a huge
completed program.

> 
> -- 
> ||||||||||||||||||||||
> |||||||||#####||||||||
> ||||||||#######|||||||
> ||||||||# O O #|||||||
> ||||||||#\ ~ /#|||||||
> ||||||##||\_/||##|||||
> |||||#||||||||||##||||
> ||||#||||||||||||##|||
> ||||#|||||||||||||##||	
> |||/\##|||||||||##/\||	
> |/    \#########/    \	
> |\     \#######/     /	
> ||\____/#######\____/|	
> =====================================	
> Hello.  Just walk along and try NOT to think about your INTESTINES
> being almost FORTY YARDS LONG!!
> ====================================
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline


From Eugene.Leitl@lrz.uni-muenchen.de  Tue Jun 26 15:32:16 2001
From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl)
Date: Tue, 26 Jun 2001 16:32:16 +0200 (MET DST)
Subject: [Tutor] traversing DOM with TreeWalker
Message-ID: <Pine.SOL.4.33.0106261626060.7078-100000@sun1.lrz-muenchen.de>

I have some random bit of XML (see below) which I would like to to mange
with DOM functions. I can use dom_from_xml_file.py from PyXML-0.6.5 just
fine, but the documentation on DOM, especially TreeWalker, is very thin.
Can someone point me towards demo DOM code?

Much appreciated.

Here's the XML I've been parsing via python dom_from_xml_file.py react2.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE TREE>
<TREE>
  <NBRANCH>3</NBRANCH>

<TARGETMOL>4Cl_o_8Cl_o_1_g_2_o_1_k_3_o_1_m_4_o_2_k_5_o_3_g_6_o_5_g_7_o_6_k_7_o_7_m_8.</TARGETMOL>
  <BRANCH>
    <NED>2</NED>

<ED>4Cl_o_8N_o_1_g_2_o_1_k_3_o_1_m_4_o_2_k_5_o_3_g_6_o_5_g_7_o_6_k_7_o_7_m_8.</ED>
    <ED>1Cu_o_1_a_V2_z__o_2Cl_o_3Cl_o_1_m_2_o_1_m_3.</ED>
    <RECORD>00123456</RECORD>
    <DOCUMENT>81-001137</DOCUMENT>
    <TITLE>DIREKTE UMWANDLUNG VON ARYLAMINEN IN HALOGENIDE DURCH
DESAMINIERUNG MIT THIONITRIL ODER VERWANDTEN VERBINDUNGEN UND WASSERFREIEN
KUPFER(II)-HALOGENIDEN.</TITLE>
    <AUTHOR>S. OAE, K. SHINHAMA, Y. H. KIM</AUTHOR>
    <CITATION>BULL. CHEM. SOC. JAP. 1980, 53, NO 4, 1065-1069</CITATION>
    <LANGUAGE>ENG</LANGUAGE>
    <LOCATION>DEP. OF CHEM., UNIV. OF TSUKUBA, NIIHARIGUN, IBARAKI
305.</LOCATION>
    <CONDITIONS>CuCl2, </CONDITIONS>
    <DETAILS>B</DETAILS>
  </BRANCH>
  <BRANCH>
    <NED>2</NED>

<ED>4O_o_10O_o_12Cl_o_1_g_2_o_1_k_3_o_1_m_4_o_2_k_5_o_2_m_6_o_3_g_7_o_3_m_8_o_5_g_9_o_6_i_10_o_6_m_11_o_7_k_9_o_9_m_12.</ED>

<ED>7O_o_8O_o_10O_o_1_g_2_o_1_k_3_o_1_m_4_o_2_k_5_o_3_g_6_o_4_i_7_o_4_m_8_o_5_g_9_o_6_k_9_o_9_m_10_o_10_m_11.</ED>
    <RECORD>00654321</RECORD>
    <DOCUMENT>84-003669</DOCUMENT>
    <TITLE>SYNTHESIS AND SCREENING OF SOME 1,3-PROPANE DIONES AND
FLAVONES</TITLE>
    <AUTHOR>K. A. THAKAR, C. H. GILL</AUTHOR>
    <CITATION>J. INDIAN CHEM. SOC., 1983, 60, N 7, 668-670</CITATION>
    <ISSN>0019-4522</ISSN>
    <LANGUAGE>ENG</LANGUAGE>
  </BRANCH>
  <BRANCH>
    <NED>2</NED>

<ED>5N_o_6O_o_7N_o_12S_o_16Cl_o_1_e_2_o_1_d_3_o_1_m_4_o_2_e_5_o_2_i_6_o_3_e_7_o_4_m_8_o_5_e_9_o_7_e_9_o_8_g_10_o_8_k_11_o_9_i_12_o_10_k_13_o_11_g_14_o_13_g_15_o_14_k_15_o_15_m_16.</ED>
    <ED>1I_o_1_m_2.</ED>
    <RECORD>00345455</RECORD>
    <DOCUMENT>82-007691</DOCUMENT>
    <TITLE>PYRIMIDONE AND THIOPYRIMIDONE DERIVATIVES</TITLE>
    <AUTHOR>T. H. BROWN, G. J. DURANT, J. C. EMMETT, C. R.
GANELLIN</AUTHOR>
    <PATOWNER>SMITH KLINE AND FRENCH LAB., LTD.</PATOWNER>
    <PATCOUNTRY>GB
</PATCOUNTRY>
    <PATNUMBER>1595291
</PATNUMBER>
    <PATCLASS>C 07 D 41/12;A 61 K 31/505</PATCLASS>
  </BRANCH>
</TREE>

bash-2.01$ cat dom_from_xml_file.py
from xml.dom import ext
from xml.dom.ext.reader import PyExpat

def read_xml_from_file(fileName):
    #build a DOM tree from the file
    reader = PyExpat.Reader()
    xml_dom_object = reader.fromUri(fileName)

    ext.PrettyPrint(xml_dom_object)

    #reclaim the object
    reader.releaseNode(xml_dom_object)

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

Pointers to demo DOM code highly appreciated.

TIA,

-- Eugen* Leitl <a href="http://www.lrz.de/~ui22204/">leitl</a>
______________________________________________________________
ICBMTO  : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204
57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3



From Greg.Furmanek@hit.cendant.com  Tue Jun 26 16:49:43 2001
From: Greg.Furmanek@hit.cendant.com (Furmanek, Greg)
Date: Tue, 26 Jun 2001 11:49:43 -0400
Subject: [Tutor] Curses programming
Message-ID: <E5468D0C0B2DD411AE52009027B0FA3F8D9DEF@hit-phx-mail-3.hfscorp.com>

That would be great.

I would like to see your work.

greg

-----Original Message-----
From: sill@optonline.net [mailto:sill@optonline.net]
Sent: Tuesday, June 26, 2001 6:20 AM
To: Python Tutor list
Subject: Re: [Tutor] Curses programming


On Tue, Jun 26, 2001 at 06:13:58PM +0530, lonetwin@yahoo.com wrote:
> Greetings everybody,
>  b4 I ask for help, lemme tell u this, this list is ultra-cool, all u guys
> are either ^^really nice^^ ppl (the kind who'd help an old lady cross the
> road... weather she actually want to or not, well..eh..umm..eh..) or have
got
> too much time on u r hands :)
>  No, seriously tho' this list is one o' the most helpful and cordial list
I've
> joined.
>  N E Ways, what I want help on, is not a particular problem as such. I'm
trying
> to get my hands dirty with curses programming under linux using python.
I've
> never done n e curses/ncurses programming using C. I've read the curses
howto
> for python and have managed to draw boxes and buttons and stuff on the
console.
> 	Problem is since I have never ever created a (G)UI application, I'm
at a
> loss as to how to go about it...I mean the design part, an' that is y 'm
here,
> I'd REALLY appreciate it if somebody cud guide me ....an' I'd give my pet
frog
> to anyone who could lead-me-into/work-with-me to create an' actual curses
based
> application (that's always been the only way I learn...take up a project,
an'
> learn whatever is requiem to get it done) (no wonder I learn so less
<grin>).
> 	I already have a few small ideas as far as the applications go
(didn't
> somebody mention a tetris-extension for an editor sometime back ....well I
use
> vi ....hmmmmmmmmmmm)....so, that's it....if I haven't been clear 'nuff
> (my effective communication quotient = -0.5) plz say so.
> 
> Thanx everyone
> Peace
> Steve

Try looking at some existing curses-based application, I know that's hard
but
personally tutoring someone through a complete application, well, people who
are *that* nice are probably too busy working for red cross. ;-)

OTOH I'm also meaning to start working on a curses-based irc client
real-soon-
now. I guess if I do get around to that, I could post incremental versions
online, that's probably much easier to study by than looking at a huge
completed program.

> 
> -- 
> ||||||||||||||||||||||
> |||||||||#####||||||||
> ||||||||#######|||||||
> ||||||||# O O #|||||||
> ||||||||#\ ~ /#|||||||
> ||||||##||\_/||##|||||
> |||||#||||||||||##||||
> ||||#||||||||||||##|||
> ||||#|||||||||||||##||	
> |||/\##|||||||||##/\||	
> |/    \#########/    \	
> |\     \#######/     /	
> ||\____/#######\____/|	
> =====================================	
> Hello.  Just walk along and try NOT to think about your INTESTINES
> being almost FORTY YARDS LONG!!
> ====================================
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


"The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent.  This message
and its attachments could have been infected during transmission.  By
reading the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects.  The sender's employer is not liable for any loss or damage
arising in any way from this message or its attachments."


From AnthonyBeaman@trginc.com  Tue Jun 26 17:46:29 2001
From: AnthonyBeaman@trginc.com (Anthony Beaman)
Date: Tue, 26 Jun 2001 12:46:29 -0400
Subject: [Tutor] General Programming Question
Message-ID: <6D19AB695BA8D311A8420008C7CF285A020A8F08@trgmail>

Hi! I've posted before but I'm a complete newbie to programming. I've almost
completed the "Python in 24 Hours" book and will begin with a new book next.
My question is when should I begin looking at other languages? Should I move
on to something like Programming Python or should I begin looking into some
other language? Thanks! 


From sheila@thinkspot.net  Tue Jun 26 18:08:31 2001
From: sheila@thinkspot.net (Sheila King)
Date: Tue, 26 Jun 2001 10:08:31 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <6D19AB695BA8D311A8420008C7CF285A020A8F08@trgmail>
References: <6D19AB695BA8D311A8420008C7CF285A020A8F08@trgmail>
Message-ID: <4C704894CF0@kserver.org>

On Tue, 26 Jun 2001 12:46:29 -0400, Anthony Beaman
<AnthonyBeaman@trginc.com>  wrote about [Tutor] General Programming
Question:

:Hi! I've posted before but I'm a complete newbie to programming. I've almost
:completed the "Python in 24 Hours" book and will begin with a new book next.
:My question is when should I begin looking at other languages? Should I move
:on to something like Programming Python or should I begin looking into some
:other language? Thanks! 

Well, personally I would wait until I felt proficient in my first
language, before I started moving on to another. Pick some projects that
you would like and complete them. When you feel like you can do a few
useful things in Python, then maybe consider to look at another
language.

Just my $0.02.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




From pobrien@orbtech.com  Tue Jun 26 18:16:10 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Tue, 26 Jun 2001 12:16:10 -0500
Subject: [Tutor] General Programming Question
In-Reply-To: <6D19AB695BA8D311A8420008C7CF285A020A8F08@trgmail>
Message-ID: <NBBBIOJPGKJEKIECEMCBAELPKBAA.pobrien@orbtech.com>

That really depends on what you are trying to accomplish. There are plenty
of us that have programmed in other languages and found Python to be a nice
place to settle down. I think Python is the best all-around language out
there. Of course, it doesn't do *everything*. So if you want to be a "true"
programmer you would never limit yourself to one language. (I'm quite happy
to do 99.9% of my programming in Python.) You would use the language that
was most appropriate to the task at hand. So, what is your goal?

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Anthony Beaman
Sent: Tuesday, June 26, 2001 11:46 AM
To: 'tutor@python.org'
Subject: [Tutor] General Programming Question

Hi! I've posted before but I'm a complete newbie to programming. I've almost
completed the "Python in 24 Hours" book and will begin with a new book next.
My question is when should I begin looking at other languages? Should I move
on to something like Programming Python or should I begin looking into some
other language? Thanks!

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From arcege@speakeasy.net  Tue Jun 26 18:43:19 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Tue, 26 Jun 2001 13:43:19 -0400 (EDT)
Subject: [Tutor] Curses programming
In-Reply-To: <20010626091956.A652@sill.silmarill.org> from "sill@optonline.net" at Jun 26, 2001 09:19:56 AM
Message-ID: <200106261743.f5QHhJj02344@dsl092-074-184.bos1.dsl.speakeasy.net>

sill@optonline.net wrote
> Try looking at some existing curses-based application, I know that's hard but
> personally tutoring someone through a complete application, well, people who
> are *that* nice are probably too busy working for red cross. ;-)
> 
> OTOH I'm also meaning to start working on a curses-based irc client real-soon-
> now. I guess if I do get around to that, I could post incremental versions
> online, that's probably much easier to study by than looking at a huge
> completed program.

A couple of years ago I created an irc client that could handle (and comes
with) a tkinter and a curses interface, as well as dummy/batch interface.
It is probably overly complicated, but I designed it all as a framework,
not a specific client.

<URL: ftp://starship.python.net/pub/crew/arcege/Pyirc-1.5.1.tar.gz>

No docs, probably not a lot of comments, unfinished.  But it might give
you some ideas how to get curses working well, and how they match up
with GUI systems.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From jessw@loop.com  Tue Jun 26 18:51:05 2001
From: jessw@loop.com (Jesse W)
Date: Tue, 26 Jun 2001 10:51:05 -0700
Subject: [Tutor] New version of calculator.py
Message-ID: <3B386919.30470.27912AE0@localhost>

Hey ho-

	Here is the new version of the simple calculator I wrote for one 
of the Pyhon Challanges.  It now includes a zero button (thank you, 
Gregor Lingl), and I think the integer overflow problem is solved 
(thank you, Tommy Butler)

Copying from my previous message:
Any comments, suggestions, patches, gripes, or simple 
screams of emotion are welcomed.  Please only post to the list.

					Thank you for your time and support,
						Jesse W


From jessw@loop.com  Tue Jun 26 18:51:55 2001
From: jessw@loop.com (Jesse W)
Date: Tue, 26 Jun 2001 10:51:55 -0700
Subject: [Tutor] New version of calculator.py
Message-ID: <3B38694B.9341.2791ED55@localhost>

Hey ho-

	Here is the new version of the simple calculator I wrote for one 
of the Pyhon Challanges.  It now includes a zero button (thank you, 
Gregor Lingl), and I think the integer overflow problem is solved 
(thank you, Tommy Butler)

Copying from my previous message:
Any comments, suggestions, patches, gripes, or simple 
screams of emotion are welcomed.  Please only post to the list.

Note to Rob:
	If you want to put this updated version on the Useless site, 
you are welcome to do so.

					Thank you for your time and support,
						Jesse W


From kojo@hal-pc.org  Tue Jun 26 18:46:05 2001
From: kojo@hal-pc.org (Kojo Idrissa)
Date: Tue, 26 Jun 2001 12:46:05 -0500
Subject: [Tutor] General Programming Question
In-Reply-To: <6D19AB695BA8D311A8420008C7CF285A020A8F08@trgmail>
Message-ID: <5.1.0.14.0.20010626123735.00ad6e08@Pop3.norton.antivirus>

I'd agree with others; There's no real reason to start looking at other 
languages now unless you actually NEED to know another language.

Are you a casual programmer?  If so, I'd say stick with Python, as it will 
do most of what you'll need to do.

Are you a Comp. Sci. or MIS student/worker (my case...soon to be a CS and 
perhaps an MIS student too...don't ask, I'm just bizzare)?  If so, you may 
want to find out what languages you'll be learning in your courses/need to 
know for work and start looking at those.  In this situation, I'd start by 
translating some of the Python programs you've written into these other 
languages to help you learn them.

Are you facing a situation where you just won't be able to use Python?  My 
ISP only supports Perl as a CGI language, not Python, so I'll have to 
convert at least one of my programs (probably more in the future) from Py 
to Perl.

Again, if you just want to learn other languages, the "translate what I've 
done into Python is a good route.  It let's you build on your prior 
work.  Talk about Code ReUse!!

:-)

At 12:46 PM 6/26/2001 -0400, Anthony Beaman wrote:
>Hi! I've posted before but I'm a complete newbie to programming. I've almost
>completed the "Python in 24 Hours" book and will begin with a new book next.
>My question is when should I begin looking at other languages? Should I move
>on to something like Programming Python or should I begin looking into some
>other language? Thanks!
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************



From rsh@hctc.com  Tue Jun 26 19:07:01 2001
From: rsh@hctc.com (Rob Hayes)
Date: Tue, 26 Jun 2001 11:07:01 -0700
Subject: [Tutor] Module / import problem
Message-ID: <002f01c0fe6a$ccd3e080$4fa819d0@dads>

This is a multi-part message in MIME format.

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

Hi,

I am very new to python and programing.  About half way through my first =
online
tutorial.  On a break from my lesson, I downloaded and installed pygame.

I opened the "chimp example" in IDLE.  When I ran the program, I get an
import error.=20

import pygame, pygame.font, pygame.image, pygame.mixer
ImportError: No module named pygame

I think my install of pygame was incorrect?  Any help on what I am doing =
wrong
would be appreciated.  If this is the wrong list for the this question, =
please
point me in the right direction.

Thanks Rob...


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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am very new to python and =
programing.&nbsp; About=20
half way through my first online</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>tutorial.&nbsp; On a break from my =
lesson, I=20
downloaded and installed pygame.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I opened the "chimp example" in =
IDLE.&nbsp; When I=20
ran the program, I get an</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>import error. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>import pygame, pygame.font, =
pygame.image,=20
pygame.mixer<BR>ImportError: No module named pygame</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I think my install of pygame was =
incorrect?&nbsp;=20
Any help on what I am doing wrong</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>would be appreciated.&nbsp; If this is =
the wrong=20
list for the this question, please</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>point me in the right =
direction.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks =
Rob...<BR></DIV></FONT></BODY></HTML>

------=_NextPart_000_002C_01C0FE30.1FBC66E0--



From jessw@loop.com  Tue Jun 26 19:09:49 2001
From: jessw@loop.com (Jesse W)
Date: Tue, 26 Jun 2001 11:09:49 -0700
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: <20010625183209.A31721@sill.silmarill.org>
References: <"from scarblac"@pino.selwerd.nl>
Message-ID: <3B386D7D.10454.27A2517D@localhost>

	Wow.  I have started a monster.  I am amazed and aghast.  The 
doubled messages did not bother me that much, I just thought it 
might be a misunderstanding or an easily fixable issue.  I see it is 
_definitely_ not.  Thank you all for your patience. ;-)
	Oh, and viva Pegasus! (at least for those on Windows or Mac)

						Jesse W


From dyoo@hkn.eecs.berkeley.edu  Tue Jun 26 19:19:18 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 26 Jun 2001 11:19:18 -0700 (PDT)
Subject: [Tutor] Module / import problem
In-Reply-To: <002f01c0fe6a$ccd3e080$4fa819d0@dads>
Message-ID: <Pine.LNX.4.21.0106261115230.6424-100000@hkn.eecs.berkeley.edu>

On Tue, 26 Jun 2001, Rob Hayes wrote:

> I am very new to python and programing.  About half way through my
> first online tutorial.  On a break from my lesson, I downloaded and
> installed pygame.
> 
> I opened the "chimp example" in IDLE.  When I ran the program, I get
> an import error.
> 
> import pygame, pygame.font, pygame.image, pygame.mixer
> ImportError: No module named pygame
>
> I think my install of pygame was incorrect?  Any help on what I am
> doing wrong would be appreciated.  If this is the wrong list for the
> this question, please point me in the right direction.

Hi Rob,

Can you tell us a little more about how you installed it?  That might give
us some ideas why Python wasn't able to find pygame.  My initial guess is
that pygame didn't install in a place that Python expected, but we need
more information.

If we can't give a good answer, then you might want to talk with the
pygame mailing list too.  They're located here:

    http://pygame.seul.org/info.shtml#maillist

and they might know more about the peculiarities of pygame.


Good luck to you!



From jessw@loop.com  Tue Jun 26 19:23:02 2001
From: jessw@loop.com (Jesse W)
Date: Tue, 26 Jun 2001 11:23:02 -0700
Subject: [Tutor] New version of calculator.py-I only meant to send one copy!
Message-ID: <3B387096.16375.27AE6A15@localhost>

Dear tutor-ians,
 Sorry.  This was _truly_ just an accident.
 The Nameless works in mysterious(and generally horribly 
humorous ways)

        Jesse W


From dyoo@hkn.eecs.berkeley.edu  Tue Jun 26 19:32:33 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 26 Jun 2001 11:32:33 -0700 (PDT)
Subject: [Tutor] General Programming Question
In-Reply-To: <4C704894CF0@kserver.org>
Message-ID: <Pine.LNX.4.21.0106261119580.6424-100000@hkn.eecs.berkeley.edu>

On Tue, 26 Jun 2001, Sheila King wrote:

> On Tue, 26 Jun 2001 12:46:29 -0400, Anthony Beaman
> <AnthonyBeaman@trginc.com>  wrote about [Tutor] General Programming
> Question:
> 
> :Hi! I've posted before but I'm a complete newbie to programming. I've almost
> :completed the "Python in 24 Hours" book and will begin with a new book next.
> :My question is when should I begin looking at other languages? Should I move
> :on to something like Programming Python or should I begin looking into some
> :other language? Thanks! 
> 
> Well, personally I would wait until I felt proficient in my first
> language, before I started moving on to another. Pick some projects that
> you would like and complete them. When you feel like you can do a few
> useful things in Python, then maybe consider to look at another
> language.

I agree on this one: it might be good to take a breather from learning
language syntax, and start trying out programs that you're interested in.  
That'll help to cement what you're learning, now that you know enough to
express some neat things in Python.

Looking at Programming Python will be helpful too, but it's still a little
passive, since it's "book reading".  That's why we encourage people to try
one's hand on a project, because it's actively engaging and personally
creative.  Several projects are listed on the Useless Python challenges:

    http://www.lowerstandard.com/python/pythonchallenge.html

But perhaps you have some project of your own that you're thinking of.  
Feel free to experiment!  Most of all, take it easy and get some
experience first.  Experience will help when you do begin looking at
another language.

Good luck!



From vishnja@web.de  Tue Jun 26 21:37:00 2001
From: vishnja@web.de (Kathrin Kirsch)
Date: Tue, 26 Jun 2001 22:37:00 +0200
Subject: [Tutor] another Module / import problem
In-Reply-To: <002f01c0fe6a$ccd3e080$4fa819d0@dads>
References: <002f01c0fe6a$ccd3e080$4fa819d0@dads>
Message-ID: <01062622294901.06734@localhost>

Hi, 
I got a similiar problem using tkinter since installing python 2.1 on linux.

The error message looks like:
 File "/usr/lib/python2.1/lib-tk/Tkinter.py", line 35, in ?
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: shared object not open
 


I installed the tkinter version 2.1.2:
If I try a "locate tkinter" I get this one:

/usr/lib/apache/lib/python2.0/lib-dynload/_tkinter.so
/usr/lib/python2.0/lib-dynload/_tkinter.so
/usr/lib/python2.0/site-packages/Gtkinter.py
/usr/lib/python2.0/site-packages/Gtkinter.pyc
/usr/lib/python2.0/site-packages/Gtkinter.pyo
/usr/lib/python2.1/lib-dynload/_tkinter.so
/usr/lib/python2.1/site-packages/Gtkinter.py
/usr/lib/python2.1/site-packages/Gtkinter.pyc
/usr/lib/python2.1/site-packages/Gtkinter.pyo

But there is no dir python2.0 anymore. The tkinter modules are
now in /usr/lib/python2.1/lib-tk.
So how can I tell my system?


Greeting, Kathrin



From python.tutor@atrixnet.com  Tue Jun 26 21:59:42 2001
From: python.tutor@atrixnet.com (Tommy Butler)
Date: Tue, 26 Jun 2001 13:59:42 -0700
Subject: [Tutor] New version of calculator.py
In-Reply-To: <3B38694B.9341.2791ED55@localhost>
Message-ID: <NFBBKCNOILDDLKCLBNFIAEAPCGAA.python.tutor@atrixnet.com>

>Hey ho-
>
>	Here is the new version of the simple calculator I wrote for one
>of the Pyhon Challanges.

Where, Jesse?  Got a link?

  - Tommy Butler
    Atrixnet Web Development  =BA =B0 =BA    Tomorrow is Now.

    web  http://Atrixnet.com
            email   mailto:tommy@Atrixnet.com
                    tel   8 1 7 . 4 6 8 . 7 7 1 6
                            fax   8 0 0 . 3 0 7 . 8 1 0 5

    6711 Forest Park Drive    =BA =B0 =BA  Arlington, TX  76001



From rob@jam.rr.com  Tue Jun 26 20:10:04 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Tue, 26 Jun 2001 14:10:04 -0500
Subject: [Tutor] General Programming Question
References: <6D19AB695BA8D311A8420008C7CF285A020A8F08@trgmail>
Message-ID: <006101c0fe73$9bad64a0$de00a8c0@planhouse5>

----- Original Message -----
From: "Anthony Beaman" <AnthonyBeaman@trginc.com>
To: <tutor@python.org>
Sent: Tuesday, June 26, 2001 11:46 AM
Subject: [Tutor] General Programming Question


> Hi! I've posted before but I'm a complete newbie to programming. I've
almost
> completed the "Python in 24 Hours" book and will begin with a new book
next.
> My question is when should I begin looking at other languages? Should I
move
> on to something like Programming Python or should I begin looking into
some
> other language? Thanks!
>

It can be quite informative to look at code in different languages to see
how they do the same things. You never know what interesting stuff you'll
pick up! But you will likely advance more quickly into more advanced
progamming skills if you try hacking out programs of your own and modifying
other people's code to make it do different things.

That's what Useless Python is for. In addition to the Challenges (Thanks for
mentioning it, Danny), you can browse through a healthy collection of
beginner and intermediate programs you can attack to your heart's content.

Enjoy,
Rob
Useless Python
It's not just for breakfast anymore!
http://www.lowerstandard.com/python/index.html



From israel@lith.com  Tue Jun 26 20:43:29 2001
From: israel@lith.com (Israel Evans)
Date: Tue, 26 Jun 2001 12:43:29 -0700
Subject: [Tutor] Internet game thingy...
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144E7@mailcluster.lith.com>

Hello all.


In order to develop my Pythoneering skills and allow further competitive
communication between us and our exchange student, I've set myself the task
of recreating an internet version of a board game my wife and our exchange
student made up.  I'd like to set it so that the game can be played over the
internet but I'm not sure of how to approach it.  Should I do an internet
only app that allows the server to do most of the work, say using Zope or
something? Or should I try to make a stand alone Python app that allows one
to connect to the internet and find players there?

 I could see if the game were something that worked on the server both
players logged on to, then neither would neccesarily need Python on their
machines.  If the game was something they both downloaded and one player
became the server and the other, the client, then their games would either
require Python on their machine or having some subset of python via the
Py2exe doohickey or whatever it's called ( some sort of distutils
contraption).

Any suggestions?  Has anybody out there done something similar?

~Israel~







From vishnja@web.de  Tue Jun 26 23:00:52 2001
From: vishnja@web.de (Kathrin Kirsch)
Date: Wed, 27 Jun 2001 00:00:52 +0200
Subject: [Tutor] another Module / import problem
In-Reply-To: <01062622294901.06734@localhost>
References: <002f01c0fe6a$ccd3e080$4fa819d0@dads> <01062622294901.06734@localhost>
Message-ID: <01062700005201.00748@localhost>

ok, I updated my db, so now the locate message is:

/usr/lib/python/rhtkinter.py
/usr/lib/python/rhtkinter.pyc
/usr/lib/python2.1/lib-dynload/_tkinter.so
/usr/lib/python2.1/lib-tk/Tkinter.py
/usr/lib/python2.1/lib-tk/Tkinter.pyc
/usr/lib/python2.1/lib-tk/Tkinter.pyo  

And.. I cannot load any other modules (like cgi.py) either
"import cgi
  File "/usr/lib/python2.1/cgi.py", line 39, in ?
    import urllib
  File "/usr/lib/python2.1/urllib.py", line 26, in ?
    import socket
  File "/usr/lib/python2.1/socket.py", line 41, in ?
    from _socket import *
ImportError: shared object not open"        


Kathrin


Am Dienstag, 26. Juni 2001 22:37 schrieb Kathrin Kirsch:
> Hi,
> I got a similiar problem using tkinter since installing python 2.1 on
> linux.
>
> The error message looks like:
>  File "/usr/lib/python2.1/lib-tk/Tkinter.py", line 35, in ?
>     import _tkinter # If this fails your Python may not be configured for
> Tk ImportError: shared object not open
>
>
>
> I installed the tkinter version 2.1.2:
> If I try a "locate tkinter" I get this one:
>
> /usr/lib/apache/lib/python2.0/lib-dynload/_tkinter.so
> /usr/lib/python2.0/lib-dynload/_tkinter.so
> /usr/lib/python2.0/site-packages/Gtkinter.py
> /usr/lib/python2.0/site-packages/Gtkinter.pyc
> /usr/lib/python2.0/site-packages/Gtkinter.pyo
> /usr/lib/python2.1/lib-dynload/_tkinter.so
> /usr/lib/python2.1/site-packages/Gtkinter.py
> /usr/lib/python2.1/site-packages/Gtkinter.pyc
> /usr/lib/python2.1/site-packages/Gtkinter.pyo
>
> But there is no dir python2.0 anymore. The tkinter modules are
> now in /usr/lib/python2.1/lib-tk.
> So how can I tell my system?
>
>
> Greeting, Kathrin
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


From AnthonyBeaman@trginc.com  Tue Jun 26 20:57:48 2001
From: AnthonyBeaman@trginc.com (Anthony Beaman)
Date: Tue, 26 Jun 2001 15:57:48 -0400
Subject: [Tutor] General Programming Question
Message-ID: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail>

Thanks for the advice (this includes EVERYONE)! I really like Python and I
really wish that I could find some graded (beginner/intermediate/advanced)
scripts since I've mostly done stuff via a book (what I find is usually too
advanced and I get frustrated). My goals are toward system administration
and networking. My interest lies in learning how a computer works and what
goes on inside that produces the output. I'm a MCSE but I feel that I'm a
point and clicker at best and that programmers really understand what's
going on. I've goofed around with C, Perl, and Assembly and I feel that I'm
beginning to understand how things work. I've always been "wowed" by those
that discover exploits and bugs without resorting to prewritten scripts and
tools. Plus it seems that the best admins are those that code also. This is
why I feel that I should look at other languages. Also, if I wanted to go
into software development then I suspect that I'll need C++, VB, Java, etc.
Anyone have any thoughts? Agree? Disagree? Any advice? Thanks!  

		-----Original Message-----
		From:	Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
		Sent:	Tuesday, June 26, 2001 2:33 PM
		To:	Anthony Beaman
		Cc:	'tutor@python.org'
		Subject:	Re: [Tutor] General Programming Question

		On Tue, 26 Jun 2001, Sheila King wrote:

		> On Tue, 26 Jun 2001 12:46:29 -0400, Anthony Beaman
		> <AnthonyBeaman@trginc.com>  wrote about [Tutor] General
Programming
		> Question:
		> 
		> :Hi! I've posted before but I'm a complete newbie to
programming. I've almost
		> :completed the "Python in 24 Hours" book and will begin
with a new book next.
		> :My question is when should I begin looking at other
languages? Should I move
		> :on to something like Programming Python or should I begin
looking into some
		> :other language? Thanks! 
		> 
		> Well, personally I would wait until I felt proficient in
my first
		> language, before I started moving on to another. Pick some
projects that
		> you would like and complete them. When you feel like you
can do a few
		> useful things in Python, then maybe consider to look at
another
		> language.

		I agree on this one: it might be good to take a breather
from learning
		language syntax, and start trying out programs that you're
interested in.  
		That'll help to cement what you're learning, now that you
know enough to
		express some neat things in Python.

		Looking at Programming Python will be helpful too, but it's
still a little
		passive, since it's "book reading".  That's why we encourage
people to try
		one's hand on a project, because it's actively engaging and
personally
		creative.  Several projects are listed on the Useless Python
challenges:

		    http://www.lowerstandard.com/python/pythonchallenge.html

		But perhaps you have some project of your own that you're
thinking of.  
		Feel free to experiment!  Most of all, take it easy and get
some
		experience first.  Experience will help when you do begin
looking at
		another language.

		Good luck!


From pobrien@orbtech.com  Tue Jun 26 21:28:47 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Tue, 26 Jun 2001 15:28:47 -0500
Subject: [Tutor] General Programming Question
In-Reply-To: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail>
Message-ID: <NBBBIOJPGKJEKIECEMCBGEMJKBAA.pobrien@orbtech.com>

If you really want to understand how the computer works then you should look
at assembler. Everything else is an abstraction that turns the real thing
into a bit of magic. Of course, if you just want to get things done, it is a
lot easier to wave a magic wand. Assembler was fun, but I'd rather pull
rabbits out of a hat. Customers are a lot more impressed by magic than they
are by assembler. <wink>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Anthony Beaman
Sent: Tuesday, June 26, 2001 2:58 PM
To: 'Danny Yoo'
Cc: 'tutor@python.org'
Subject: RE: [Tutor] General Programming Question

Thanks for the advice (this includes EVERYONE)! I really like Python and I
really wish that I could find some graded (beginner/intermediate/advanced)
scripts since I've mostly done stuff via a book (what I find is usually too
advanced and I get frustrated). My goals are toward system administration
and networking. My interest lies in learning how a computer works and what
goes on inside that produces the output. I'm a MCSE but I feel that I'm a
point and clicker at best and that programmers really understand what's
going on. I've goofed around with C, Perl, and Assembly and I feel that I'm
beginning to understand how things work. I've always been "wowed" by those
that discover exploits and bugs without resorting to prewritten scripts and
tools. Plus it seems that the best admins are those that code also. This is
why I feel that I should look at other languages. Also, if I wanted to go
into software development then I suspect that I'll need C++, VB, Java, etc.
Anyone have any thoughts? Agree? Disagree? Any advice? Thanks!



From deirdre@deirdre.net  Tue Jun 26 21:26:35 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Tue, 26 Jun 2001 13:26:35 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail>
References: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail>
Message-ID: <a05101033b75e9db9ac59@[10.20.0.138]>

>I'm a MCSE but I feel that I'm a point and clicker at best and that 
>programmers really understand what's going on.

We do. :)

>  Plus it seems that the best admins are those that code also. This is
>why I feel that I should look at other languages.

Knowledge of programming will never hurt.

>Also, if I wanted to go
>into software development then I suspect that I'll need C++, VB, Java, etc.
>Anyone have any thoughts? Agree? Disagree? Any advice? Thanks!

What you need depends on what aspect(s) of programming you go into. 
Regardless of what you ultimately choose, Python is a transparent 
enough

For example, if you wanted to program in MIS, you'd probably need 
Java and/or VB and/or Cobol.

If you wanted to do (operating) systems programming, you'd need C (in 
rare cases, C++).

If you wanted to do expert systems, Prolog.

Applications (shrink-wrap) development, C++ or Objective-C or Pascal variants.

Defense (at least in the US), Ada.

Scientific programming, well, Fortran knowledge never hurts. :)

A lot of programming doesn't fit into any distinct category; I spend 
a lot of my time programming in Python, though it pains me to admit 
that I currently program in Java for a living. (I am not a fan of the 
language)

This is based on my own experience, even so, there is no "One True 
Language" for any given task. There's usually more than one suitable 
language and a bunch one can rule out as being impractical or 
politically infeasible.

If you don't know what field of programming you want to do more of, 
I'd recommend going through a B.S. or M.S. degree in Computer Science 
to get broader exposure to the possibilities.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From Blake.Garretson@dana.com  Tue Jun 26 21:29:26 2001
From: Blake.Garretson@dana.com (Blake.Garretson@dana.com)
Date: Tue, 26 Jun 2001 16:29:26 -0400
Subject: [Tutor] Tkinter: Bad Quality Images
Message-ID: <OF785BC305.D3A93FA8-ON85256A77.006E18D7@dana.com>

I've been programming Tkinter GUI's for about a month now and I've yet to
figure out why my color gif files look so bad.  They are all grainy, as if
Tkinter is reducing the 256 colors down to 16 and dithering it or
something.  This happens with the regular PhotoImage widget and in PIL's
Image widget.  I have even cranked up the "palette" option which controls
the number of colors (or greyscale shades) to use, but my images always
look grainy.  Anybody have any experience with this?

Thanks,
Blake




From glingl@aon.at  Tue Jun 26 21:42:31 2001
From: glingl@aon.at (Gregor Lingl)
Date: Tue, 26 Jun 2001 22:42:31 +0200
Subject: [Tutor] New version of calculator.py
References: <3B38694B.9341.2791ED55@localhost>
Message-ID: <3B38F3B7.A5A2E070@aon.at>

Dear Jesse!
I really cannot imagine, why this time I cannot find
the sourcecode of your enhanced calculator in your
numerous postings.
Gregor Lingl



Jesse W schrieb:

> Hey ho-
>
>         Here is the new version of the simple calculator I wrote for one
> of the Pyhon Challanges.  It now includes a zero button (thank you,
> Gregor Lingl), and I think the integer overflow problem is solved
> (thank you, Tommy Butler)
>
> Copying from my previous message:
> Any comments, suggestions, patches, gripes, or simple
> screams of emotion are welcomed.  Please only post to the list.
>
> Note to Rob:
>         If you want to put this updated version on the Useless site,
> you are welcome to do so.
>
>                                         Thank you for your time and support,
>                                                 Jesse W
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



From israel@lith.com  Tue Jun 26 21:40:52 2001
From: israel@lith.com (Israel Evans)
Date: Tue, 26 Jun 2001 13:40:52 -0700
Subject: [Tutor] General Programming Question
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144EA@mailcluster.lith.com>

In response to Dierdre on a slight deviation from the topic...

I'd like to know if there was a way to compile Python to native machine
code, would it run as fast as say C++ or Java?  If it did would there be
anything in the way of Guido World Domination?  :)


From deirdre@deirdre.net  Tue Jun 26 21:42:08 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Tue, 26 Jun 2001 13:42:08 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <a05101033b75e9db9ac59@[10.20.0.138]>
References: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail>
 <a05101033b75e9db9ac59@[10.20.0.138]>
Message-ID: <a05101035b75ea3750455@[10.20.0.138]>

At 1:26 PM -0700 6/26/01, Deirdre Saoirse Moen wrote:
>What you need depends on what aspect(s) of programming you go into. 
>Regardless of what you ultimately choose, Python is a transparent 
>enough

Gah, I got interrupted mid-sentence again and forgot to go back and edit. Boo.

Python's syntax is transparent enough, and you can use it in enough 
different kinds of ways, that if you learned Python fully, you'd know 
how to do procedural programming (i.e. C, Fortran, Pascal), OO 
programming (Squeak, Smalltalk, Objective-C, and, to a lesser extent, 
C++ and Java), and Functional Programming (Lisp, Guile, ML).

Thus, a transition to any of those languages would be relatively easy.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From deirdre@deirdre.net  Tue Jun 26 21:48:57 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Tue, 26 Jun 2001 13:48:57 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144EA@mailcluster.lith.com>
References: <AF020C5FC551DD43A4958A679EA16A15A144EA@mailcluster.lith.com>
Message-ID: <a05101037b75ea5767caf@[10.20.0.138]>

At 1:40 PM -0700 6/26/01, Israel Evans wrote:
>In response to Dierdre on a slight deviation from the topic...
>
>I'd like to know if there was a way to compile Python to native machine
>code, would it run as fast as say C++ or Java?  If it did would there be
>anything in the way of Guido World Domination?  :)

There are reasons that Python is difficult to write a compiler for. 
However, these are subtle issues that compiler people argue over and 
most of the arguments are over my head. (I have written compilers, 
but not very complex ones).
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From israel@lith.com  Tue Jun 26 22:01:32 2001
From: israel@lith.com (Israel Evans)
Date: Tue, 26 Jun 2001 14:01:32 -0700
Subject: [Tutor] General Programming Question
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144EB@mailcluster.lith.com>

Do you know of anyone with that most quixotic of goals ( writing a compiler
for Python ) in mind?

~Israel~


From deirdre@deirdre.net  Tue Jun 26 22:02:43 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Tue, 26 Jun 2001 14:02:43 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144EB@mailcluster.lith.com>
References: <AF020C5FC551DD43A4958A679EA16A15A144EB@mailcluster.lith.com>
Message-ID: <a05101039b75ea8df48eb@[10.20.0.138]>

At 2:01 PM -0700 6/26/01, Israel Evans wrote:
>Do you know of anyone with that most quixotic of goals ( writing a compiler
>for Python ) in mind?

You'd have to search the comp.lang.python archives.

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From israel@lith.com  Tue Jun 26 22:07:22 2001
From: israel@lith.com (Israel Evans)
Date: Tue, 26 Jun 2001 14:07:22 -0700
Subject: [Tutor] General Programming Question
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144EC@mailcluster.lith.com>

I've been snooping around and have found a site that might interest any
compiler developers out there.  The site is www.cminusminus.org .  The
philosophy is on of clarity and portability.   It seems this might be a good
target for any would be Python Compilers.

~Israel~
-----Original Message-----
From: Deirdre Saoirse Moen [mailto:deirdre@deirdre.net]
Sent: Tuesday, June 26, 2001 1:49 PM
To: Israel Evans; tutor@python.org
Subject: RE: [Tutor] General Programming Question


At 1:40 PM -0700 6/26/01, Israel Evans wrote:
>In response to Dierdre on a slight deviation from the topic...
>
>I'd like to know if there was a way to compile Python to native machine
>code, would it run as fast as say C++ or Java?  If it did would there be
>anything in the way of Guido World Domination?  :)

There are reasons that Python is difficult to write a compiler for. 
However, these are subtle issues that compiler people argue over and 
most of the arguments are over my head. (I have written compilers, 
but not very complex ones).
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


From ak@silmarill.org  Tue Jun 26 23:24:51 2001
From: ak@silmarill.org (ak@silmarill.org)
Date: Tue, 26 Jun 2001 18:24:51 -0400
Subject: [Tutor] Curses programming
In-Reply-To: <"from arcege"@dsl092-074-184.bos1.dsl.speakeasy.net>
References: <20010626091956.A652@sill.silmarill.org>
 <200106261743.f5QHhJj02344@dsl092-074-184.bos1.dsl.speakeasy.net>
Message-ID: <20010626182451.A1585@sill.silmarill.org>

On Tue, Jun 26, 2001 at 01:43:19PM -0400, Michael P. Reilly wrote:
> sill@optonline.net wrote
> > Try looking at some existing curses-based application, I know that's hard but
> > personally tutoring someone through a complete application, well, people who
> > are *that* nice are probably too busy working for red cross. ;-)
> > 
> > OTOH I'm also meaning to start working on a curses-based irc client real-soon-
> > now. I guess if I do get around to that, I could post incremental versions
> > online, that's probably much easier to study by than looking at a huge
> > completed program.
> 
> A couple of years ago I created an irc client that could handle (and comes
> with) a tkinter and a curses interface, as well as dummy/batch interface.
> It is probably overly complicated, but I designed it all as a framework,
> not a specific client.
> 
> <URL: ftp://starship.python.net/pub/crew/arcege/Pyirc-1.5.1.tar.gz>
> 
> No docs, probably not a lot of comments, unfinished.  But it might give
> you some ideas how to get curses working well, and how they match up
> with GUI systems.

Yeah, I was looking at it a few months before and I think the problem was that
I couldn't connect to EFnet in it (OPN worked fine though). Also, I'm not good
enough at python to understand how it works, there's too many interwining
classes inheriting from here and there, so I sort of got lost in it. I couldn't
quite wrap my brains around the OO framework. Although that was a while ago,
now I that I got much more python under my belt, I think I'll take another look
:-). 

By the way, do you use it actively for your own irc'ing?

> 
>   -Arcege
> 
> -- 
> +----------------------------------+-----------------------------------+
> | Michael P. Reilly                | arcege@speakeasy.net              |
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline


From lha2@thesquare.com  Tue Jun 26 23:32:23 2001
From: lha2@thesquare.com (lha2)
Date: Tue, 26 Jun 2001 18:32:23 -0400
Subject: [Tutor] f5 in IDLE--unexpected behavior
Message-ID: <200106261832.AA480182312@mail.thesquare.com>

So I'm teaching Python at a math camp, and we're having the darndest time figuring out why Python seems to be ignoring the student's module when we import it using <f5> in the active window in IDLE.

It turns out that if the document has the same name as an internal or toolbox module (in this case, the student had named the document in her a: drive to be "time.py"), IDLE will import the toolbox module, not the one in which f5 is being pressed.

Don't know whether this is documented behavior, but thought I'd post it as a something to look out for.

-Lloyd Hugh Allen


From dyoo@hkn.eecs.berkeley.edu  Tue Jun 26 23:35:52 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 26 Jun 2001 15:35:52 -0700 (PDT)
Subject: [Tutor] Re: Tutor digest, Vol 1 #909 - 10 msgs
In-Reply-To: <Pine.LNX.4.33.0106251355590.27044-100000@silmu.st.jyu.fi>
Message-ID: <Pine.LNX.4.21.0106261530470.10939-100000@hkn.eecs.berkeley.edu>

On Mon, 25 Jun 2001, Risto Peranen wrote:

> I'm part of game programming project. Does anyone know where can I
> find info or even existing modules for talk-ai.

Hmmmm!  This sounds interesting!


> In the game you can just negotiate with strangers rather than kill 'em
> all. That's our problem but it would be cool if you can also talk with
> strangers - even with limited ai. Sure I know the basics of making
> such a silly ai, but I have never made one.

There's a program called AliceBot:

    http://www.alicebot.org/

that I've heard rave reviews from.  Supposedly, the conversations with
AliceBot border on something almost coherant.  *grin*

However, I haven't been able to find Python bindings for it yet --- you
might be able to request them from the author.  (Or perhaps make it a
Useless Challenge for someone to try out!)  It would be very neat if you
could get it working in your game.


One of the first AI programs written was called Eliza, and someone's
written an Eliza program in Python here:

    http://www.strout.net/python/ai/



From dyoo@hkn.eecs.berkeley.edu  Tue Jun 26 23:37:24 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 26 Jun 2001 15:37:24 -0700 (PDT)
Subject: [Tutor] Brainbench certification
In-Reply-To: <200106252338.f5PNc5d23733@pop.nsacom.net>
Message-ID: <Pine.LNX.4.21.0106261536280.10939-100000@hkn.eecs.berkeley.edu>

On Mon, 25 Jun 2001 kromag@nsacom.net wrote:

> Well, I tried taking the brainbench python1.5 certification.

> I am now going home to dab soothing ungents upon my footprint-covered 
> buttocks.

Ouch!


> Be warned: the writer of this particular test has a deep and abiding
> understanding of numeric functions. If you do not, save your $20.00
> until you do! :-)

What sort of questions did they ask?  I'm interested to see what sort of
things they emphasized on the test.

Talk to you later!



From dsh8290@rit.edu  Wed Jun 27 00:24:08 2001
From: dsh8290@rit.edu (D-Man)
Date: Tue, 26 Jun 2001 19:24:08 -0400
Subject: [Tutor] General Programming Question
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144EA@mailcluster.lith.com>; from israel@lith.com on Tue, Jun 26, 2001 at 01:40:52PM -0700
References: <AF020C5FC551DD43A4958A679EA16A15A144EA@mailcluster.lith.com>
Message-ID: <20010626192408.C16690@harmony.cs.rit.edu>

On Tue, Jun 26, 2001 at 01:40:52PM -0700, Israel Evans wrote:
| 
| In response to Dierdre on a slight deviation from the topic...
| 
| I'd like to know if there was a way to compile Python to native machine
| code, would it run as fast as say C++ or Java?  If it did would there be

Depending on how complex you get you can use Jython to compile to Java
byte-code, then use gcj to get native machine code.  Will it be
faster?  Probably not since Python is so dynamic that the compilers
don't really know anything.  Also, when jythonc compiles to java
bytecode it generates some Java source that basically consists of
calls to the interpreter.  The python is still being interpreted one
way or the other.

I don't know of anyone who really wants to create a gcc frontend for
python because the only people I hear complaining about python's speed
are those who haven't used it yet ;-).

-D



From michael@trollope.org  Wed Jun 27 00:26:49 2001
From: michael@trollope.org (M.A. Powe)
Date: Tue, 26 Jun 2001 16:26:49 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail> (message from
 Anthony Beaman on Tue, 26 Jun 2001 15:57:48 -0400)
References: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail>
Message-ID: <200106262326.f5QNQnd31699@cecilia.trollope.org>

>>>>> "Anthony" == Anthony Beaman <AnthonyBeaman@trginc.com> writes:

    Anthony> Thanks for the advice (this includes EVERYONE)! I really
    Anthony> like Python and I really wish that I could find some
    Anthony> graded (beginner/intermediate/advanced) scripts since
    Anthony> I've mostly done stuff via a book (what I find is usually
    Anthony> too advanced and I get frustrated). My goals are toward
    Anthony> system administration and networking. My interest lies in
    Anthony> learning how a computer works and what goes on inside
    Anthony> that produces the output. I'm a MCSE but I feel that I'm

Assembler.  If you want to get close to the iron, start at the
beginning of the alphabet.  A really, really good book is Andrew
Tanenbaum's <Structured Computer Organization>.  Parts of it are
quite dense, but if you plough through, you will learn a lot about
how modern 'puters work.

    Anthony> a point and clicker at best and that programmers really
    Anthony> understand what's going on. I've goofed around with C,
    Anthony> Perl, and Assembly and I feel that I'm beginning to
    Anthony> understand how things work. I've always been "wowed" by
    Anthony> those that discover exploits and bugs without resorting
    Anthony> to prewritten scripts and tools. Plus it seems that the

Actually, the real security experts have suites of tools they use for
testing.  Most of that stuff is not discovered by accident, they're
looking for it.

    Anthony> best admins are those that code also. This is why I feel
    Anthony> that I should look at other languages. Also, if I wanted
    Anthony> to go into software development then I suspect that I'll
    Anthony> need C++, VB, Java, etc.  Anyone have any thoughts?
    Anthony> Agree? Disagree? Any advice? Thanks!

Three languages interest me: Scheme, C and python.  C is the mother
tongue -- 'nuff said.  Scheme is the most elegant language I've seen.
If you can do it in three lines in python, you can do it in one line
in Scheme and it makes sense.  Python is the obligatory 'OOPs'
language and the main alternative to the 'fad' language -- Perl.
There are perl books all over the desks here, except mine.  

I don't seem to be smart enough to do Scheme on my own -- I'll just
keep hammering away at it periodically because I'm stubborn.  C --
okay, as long as I stay away from pointers to pointers to pointers,
I'm pretty good.  Python -- the unclimbed mountain upon whose slopes I
presently sun myself.  And, well, ... ah ... I just started a class in
*cough*java*cough* this week.  Oh Lord! It's just so I can learn OOP
-- honest! 'Struth!

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From dyoo@hkn.eecs.berkeley.edu  Wed Jun 27 00:33:27 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 26 Jun 2001 16:33:27 -0700 (PDT)
Subject: [Tutor] General Programming Question
In-Reply-To: <20010626192408.C16690@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.21.0106261628020.12433-100000@hkn.eecs.berkeley.edu>

On Tue, 26 Jun 2001, D-Man wrote:

> On Tue, Jun 26, 2001 at 01:40:52PM -0700, Israel Evans wrote:
> | 
> | In response to Dierdre on a slight deviation from the topic...
> | 
> | I'd like to know if there was a way to compile Python to native machine
> | code, would it run as fast as say C++ or Java?  If it did would there be
> 
> Depending on how complex you get you can use Jython to compile to Java
> byte-code, then use gcj to get native machine code.  Will it be
> faster?  Probably not since Python is so dynamic that the compilers
> don't really know anything.  Also, when jythonc compiles to java
> bytecode it generates some Java source that basically consists of
> calls to the interpreter.  The python is still being interpreted one
> way or the other.

ActiveState is working on a .NET compiler for Python:

    http://www.activestate.com/Initiatives/NET/Research.html

so, with luck, we'll get blazingly fast compiled Python some day... but I
think it will take a while.

Hope this helps!



From rob@jam.rr.com  Wed Jun 27 01:37:21 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Tue, 26 Jun 2001 19:37:21 -0500
Subject: [Tutor] [maybe OT]: how Useless began
Message-ID: <NFBBKIELCLIEEMGGIGKDGEGPCAAA.rob@jam.rr.com>

I started to draft a simple page to explain why Useless got started, but got
creative instead. Can anyone figure out who the block quote is from without
consulting the Tutor Archives? There may be slight historical and
entertainment value in this, and the relevant point in the Archive is linked
to from the page.

http://www.lowerstandard.com/python/whatsthepoint.html

If you were a part of that fateful moment, you may want to make sure you
haven't been viciously misrepresented! (But I won't mention Danny's name.)

Uselessly,
Rob

"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/



From tracey@transmeta.com  Wed Jun 27 01:44:35 2001
From: tracey@transmeta.com (Tracey Luke)
Date: Tue, 26 Jun 2001 17:44:35 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <200106262326.f5QNQnd31699@cecilia.trollope.org>; from michael@trollope.org on Tue, Jun 26, 2001 at 04:26:49PM -0700
References: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail> <200106262326.f5QNQnd31699@cecilia.trollope.org>
Message-ID: <20010626174435.D24384@transmeta.com>

For learning scheme, you might consider the book:

"Structure and Interpretationof Computer Programs" by Harold Abelson, Gerald Jay Sussman and Julie Sussman.

This is what is used at Berkeley to teach begining programming :)

It's also availible in its entirety online at:

http://mitpress.mit.edu/sicp/

On Tue, Jun 26, 2001 at 04:26:49PM -0700, M.A. Powe wrote:
> 
> I don't seem to be smart enough to do Scheme on my own -- I'll just
> keep hammering away at it periodically because I'm stubborn.  C --
> okay, as long as I stay away from pointers to pointers to pointers,
> I'm pretty good.  Python -- the unclimbed mountain upon whose slopes I
> presently sun myself.  And, well, ... ah ... I just started a class in
> *cough*java*cough* this week.  Oh Lord! It's just so I can learn OOP
> -- honest! 'Struth!
 


From dan@webmind.com  Wed Jun 27 01:59:52 2001
From: dan@webmind.com (Dan Tropp)
Date: Wed, 27 Jun 2001 10:59:52 +1000
Subject: [Tutor] re.findall() weirdness.
In-Reply-To: <200106262326.f5QNQnd31699@cecilia.trollope.org>
Message-ID: <000201c0fea4$799392a0$0601c10a@oz.intelligenesis.net>

I tried these in my python shell. Why do the last two give what they do?

>>> print re.findall('<.*?>','<a> </a> <a> </a>')
['<a>', '</a>', '<a>', '</a>']
>>> print re.findall('<.*?>','<1> </2> \n<3> </4>')
['<1>', '</2>', '<3>', '</4>']
>>> print re.findall('<.*?>','<1> </2> \n<3> </4>', re.I|re.S)
[]
>>> print re.findall('<.*?>','<1> </2> \n<3> </4>', re.I)
['</2>', '<3>', '</4>']
>>> 

Dan Tropp
Dept Psychology, University of Melbourne, Australia
ph:+61 3 8344 0396   fax:+61 3 9347 6618 




From rufmetal@home.com  Wed Jun 27 02:56:42 2001
From: rufmetal@home.com (Chris Keelan)
Date: Tue, 26 Jun 2001 20:56:42 -0500
Subject: [Tutor] General Programming Question
In-Reply-To: <20010626174435.D24384@transmeta.com>
References: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail> <200106262326.f5QNQnd31699@cecilia.trollope.org> <20010626174435.D24384@transmeta.com>
Message-ID: <01062620564200.10643@tygesen>

On Tuesday 26 June 2001 19:44, you wrote:
> For learning scheme, you might consider the book:
>
> "Structure and Interpretationof Computer Programs" by Harold Abelson,
> Gerald Jay Sussman and Julie Sussman.

That's pretty heavy if you're brand new to programming. A more gentle 
introduction would be 'How To Design Programs', which is also available 
online at http://www.htdp.org.

I'm using this book and Learning Python at the same time. Program logic 
translates well between Scheme and Python and they're both beautifully 
readable.

- C
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


From dyoo@hkn.eecs.berkeley.edu  Wed Jun 27 02:43:20 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 26 Jun 2001 18:43:20 -0700 (PDT)
Subject: [Tutor] re.findall() weirdness.   [looks like a bug!]
In-Reply-To: <000201c0fea4$799392a0$0601c10a@oz.intelligenesis.net>
Message-ID: <Pine.LNX.4.21.0106261815040.14151-100000@hkn.eecs.berkeley.edu>

On Wed, 27 Jun 2001, Dan Tropp wrote:

> I tried these in my python shell. Why do the last two give what they do?
> 
> >>> print re.findall('<.*?>','<a> </a> <a> </a>')
> ['<a>', '</a>', '<a>', '</a>']
> >>> print re.findall('<.*?>','<1> </2> \n<3> </4>')
> ['<1>', '</2>', '<3>', '</4>']
> >>> print re.findall('<.*?>','<1> </2> \n<3> </4>', re.I|re.S)
> []
> >>> print re.findall('<.*?>','<1> </2> \n<3> </4>', re.I)
> ['</2>', '<3>', '</4>']

Now this is curious, because according to the documentation at:

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

re.findall() is only supposed to take in two arguments.  In fact, in
Python 1.52, Python complains that:

###
# in Python 1.52:
>> print re.findall('<.*?>','<1> </2> \n<3> </4>', re.I)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: too many arguments; expected 2, got 3
##


Let me check if the same behavior happens in 2.1:

###
# in Python 2.1
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', re.I)
['</2>', '<3>', '</4>']
###

Now that is weird!  This looks like it might be a bug.  Let's take a look
at the source code, to see why it's doing that.


###
## source code in sre.py
def findall(pattern, string, maxsplit=0):
    """Return a list of all non-overlapping matches in the string.

    If one or more groups are present in the pattern, return a
    list of groups; this will be a list of tuples if the pattern
    has more than one group.

    Empty matches are included in the result."""
    return _compile(pattern, 0).findall(string, maxsplit)
###

Weird!  findall() in its current incarnation does take in a third
argument, contrary to the HTML documentation.  But this makes no sense to
me.  Why should findall need a maxsplit parameter, when maxsplit is
something that the split()ing operator works with?  This really looks like
a bug to me.


Hmmm... well, the definition to findall() is adjacent to split(), so
perhaps someone made a mistake and accidently added maxsplit as an
argument.  I believe that the corrected code in sre.py should be:

###
def findall(pattern, string):
    """Return a list of all non-overlapping matches in the string.

    If one or more groups are present in the pattern, return a
    list of groups; this will be a list of tuples if the pattern
    has more than one group.

    Empty matches are included in the result."""
    return _compile(pattern, 0).findall(string)
###

instead.

Ever since June 1, 2000, the findall() code in sre.py has contained this
weird behavior:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Lib/sre.py?rev=1.5&content-type=text/vnd.viewcvs-markup

and even in the current development sources, it still has it!

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Lib/sre.py?rev=1.25.2.1&content-type=text/vnd.viewcvs-markup


Dan, I think we should report this to the Implementors and see what they
think about it.  Good catch!  *grin*  Do you want to submit this to
sourceforge?



From dyoo@hkn.eecs.berkeley.edu  Wed Jun 27 03:13:23 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 26 Jun 2001 19:13:23 -0700 (PDT)
Subject: [Tutor] re.findall() weirdness.   [looks like a bug!]
In-Reply-To: <Pine.LNX.4.21.0106261815040.14151-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.21.0106261900380.14151-100000@hkn.eecs.berkeley.edu>

I've been looking at the source code a bit more.  It's definitely a bug,
and I'm really happy that you found it!  *grin*  Wow.

[note --- I'm in a very excited "hackish" mode right now, so this will
probably not make sense.  *grin* If you don't know C, you probably
don't want to read this message.]








In any case, there's an undocumented reason why we were getting those
results: apparently, Python's findall() internally takes in 3 arguments:
the string we're searching through, and the 'begin' and 'end' positions of
that string.  Normally, Python sets up the 'begin' and 'end' to be '0' and
the largest integer in the world, respectively, but with the bug in
findall(), something bad happens.

If we look at the C source code for regular expressions, we can see this
undocumented behavior in Modules/_sre.c.  For those that are curious, I'll
snip the part that's relevant:


###
static PyObject*
pattern_findall(PatternObject* self, PyObject* args, PyObject* kw)
{
    SRE_STATE state;
    PyObject* list;
    int status;
    int i;

    PyObject* string;
    int start = 0;
    int end = INT_MAX;
    static char* kwlist[] = { "source", "pos", "endpos", NULL };
    if (!PyArg_ParseTupleAndKeywords(args, kw, "O|ii:findall", kwlist,
                                     &string, &start, &end))

    [ ... code omitted]
###

So, internally at the C level, findall takes in three parameters:
"source", "pos", and "endpos".  Here's a guess to explain what was
happening before in the buggy findall:

###
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', re.I)
###

It helps if we look at the value of 're.I' --- not only is re.I a great
place to get outdoor supplies, but it's also an integer:

###
>>> re.I
2
###

What I think was happening was that the findall was trying to start
searching for all instances of '<.*?>', but beginning at position 2 of our
string.  We can confirm this by experiment:


###
## Using the buggy sre.py
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 2)
['</2>', '<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 3)
['</2>', '<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 4)
['</2>', '<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 5)
['<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 6)
['<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 7)
['<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 8)
['<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 9)
['<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 10)
['<3>', '</4>']
>>> re.findall('<.*?>','<1> </2> \n<3> </4>', 11)
['</4>']
###

Of course re.findall is never supposed to do this, but it's nice to know
WHY it was doing that...

Ok, I'm pooped out.  Wake me up in the morning.  *grin*



From dyoo@hkn.eecs.berkeley.edu  Wed Jun 27 03:23:31 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 26 Jun 2001 19:23:31 -0700 (PDT)
Subject: [Tutor] re.findall() weirdness.   [looks like a bug!]
In-Reply-To: <000301c0feae$901984d0$0601c10a@oz.intelligenesis.net>
Message-ID: <Pine.LNX.4.21.0106261913370.14151-100000@hkn.eecs.berkeley.edu>

On Wed, 27 Jun 2001, Dan Tropp wrote:

> Thanks for your excellent reply. I didn't actually check the
> documentation, I just assumed that you could include flags like
> re.search(). I guess these sort of bugs are hard to stop in an untyped
> language which allows default arguments!
> 
> I'll register it on sourceforge.

Ok.  Thanks for pointing that out; it was a fun bug to catch!  It's
something that Guido and Friends most likely need to fix, so you don't
need to apologize for assuming this.  I would assume the same thing, since
re.search() and re.findall() do very similar things.

By the way, to get things to behave the way you wanted it to behave (with
flags for case insensitivity and other stuff), we could make the following
enhancement to sre.py:

###
# An enhanced findall:
def findall(pattern, string, flags=0):
    """Return a list of all non-overlapping matches in the string.

    If one or more groups are present in the pattern, return a
    list of groups; this will be a list of tuples if the pattern
    has more than one group.

    Empty matches are included in the result."""
    return _compile(pattern, flags).findall(string)
###

Then things behave the way they probably should have in the first place:

###
## Using the enhanced sre.py
>>> print re.findall('<.*?>','<1> </2> \n<3> </4>', re.I|re.S)
['<1>', '</2>', '<3>', '</4>']
>>> print re.findall('python','pythonPythonPYTHON', re.I)
['python', 'Python', 'PYTHON']
###

Of course, this makes our enhanced findall() completely incompatible with
Python 1.52.  Maybe it can make it into Python 2.2!  *grin*

Hope this helps!



From kojo@hal-pc.org  Wed Jun 27 03:19:30 2001
From: kojo@hal-pc.org (Kojo Idrissa)
Date: Tue, 26 Jun 2001 21:19:30 -0500
Subject: [Tutor] General Programming Question
In-Reply-To: <01062620564200.10643@tygesen>
References: <20010626174435.D24384@transmeta.com>
 <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail>
 <200106262326.f5QNQnd31699@cecilia.trollope.org>
 <20010626174435.D24384@transmeta.com>
Message-ID: <5.1.0.14.0.20010626211353.00ad6e40@Pop3.norton.antivirus>

'How To Design Programs' is a good book, but the site is not functioning at 
the moment.  I was reading the book too, but when you go to the site now, 
it redirects you to some Casino site.

I sent an email to the Rice University Programming Languages Team (PLT) 
yesterday, as members of that team are the authors of the book.  I got a 
response back today saying the domain has been taken over by a squatter, 
but they're working to get it back or find another site for it.


At 08:56 PM 6/26/2001 -0500, Chris Keelan wrote:
>On Tuesday 26 June 2001 19:44, you wrote:
> > For learning scheme, you might consider the book:
> >
> > "Structure and Interpretationof Computer Programs" by Harold Abelson,
> > Gerald Jay Sussman and Julie Sussman.
>
>That's pretty heavy if you're brand new to programming. A more gentle
>introduction would be 'How To Design Programs', which is also available
>online at http://www.htdp.org.
>
>I'm using this book and Learning Python at the same time. Program logic
>translates well between Scheme and Python and they're both beautifully
>readable.
>
>- C
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************



From rufmetal@home.com  Wed Jun 27 04:59:06 2001
From: rufmetal@home.com (Chris Keelan)
Date: Tue, 26 Jun 2001 22:59:06 -0500
Subject: [Tutor] General Programming Question
In-Reply-To: <5.1.0.14.0.20010626211353.00ad6e40@Pop3.norton.antivirus>
References: <20010626174435.D24384@transmeta.com> <5.1.0.14.0.20010626211353.00ad6e40@Pop3.norton.antivirus>
Message-ID: <01062622590600.01321@tygesen>

On Tuesday 26 June 2001 21:19, Kojo Idrissa wrote:
> 'How To Design Programs' is a good book, but the site is not functioning at
> the moment.  I was reading the book too, but when you go to the site now,
> it redirects you to some Casino site.
>
> I sent an email to the Rice University Programming Languages Team (PLT)
> yesterday, as members of that team are the authors of the book.  I got a
> response back today saying the domain has been taken over by a squatter,
> but they're working to get it back or find another site for it.

I'd snarfed the site using wget and saved it as an html tree on my local 
drive. If anyone wants me to mail it to them, let me know. I'll tar it up and 
send it over.

- Chris


From michael@trollope.org  Wed Jun 27 06:48:50 2001
From: michael@trollope.org (M.A. Powe)
Date: Tue, 26 Jun 2001 22:48:50 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <20010626174435.D24384@transmeta.com> (message from Tracey Luke
 on Tue, 26 Jun 2001 17:44:35 -0700)
References: <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail> <200106262326.f5QNQnd31699@cecilia.trollope.org> <20010626174435.D24384@transmeta.com>
Message-ID: <200106270548.f5R5mo231990@cecilia.trollope.org>

>>>>> "Tracey" == Tracey Luke <tracey@transmeta.com> writes:

    Tracey> For learning scheme, you might consider the book:
    Tracey> "Structure and Interpretationof Computer Programs" by
    Tracey> Harold Abelson, Gerald Jay Sussman and Julie Sussman.

    Tracey> This is what is used at Berkeley to teach begining
    Tracey> programming :)

Yes, and well they should!  Unfortunately, it's not a good book for an
autodidact unless you've a pretty good mathematical background or some
kind of natural skill with math concepts.  <Scheme and the Art of
Programming> is better but still a tough row to hoe.  I have a goodly
collection of Scheme books.  Books are no substitute for grey matter,
I'm afraid.  At least <The Little Schemer> was fun!

I'm going to spend the next few months getting OOP down as best I can,
so I can get a decent handle on python.  Hey -- no recursion!!  Yeah!
;-)

mp
 
-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From bsass@freenet.edmonton.ab.ca  Wed Jun 27 08:40:00 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Wed, 27 Jun 2001 01:40:00 -0600 (MDT)
Subject: [Tutor] Module / import problem
In-Reply-To: <002f01c0fe6a$ccd3e080$4fa819d0@dads>
Message-ID: <Pine.LNX.4.33.0106270132310.1748-100000@bms>

On Tue, 26 Jun 2001, Rob Hayes wrote:
> I am very new to python and programing.  About half way through my first online
> tutorial.  On a break from my lesson, I downloaded and installed pygame.
>
> I opened the "chimp example" in IDLE.  When I ran the program, I get an
> import error.
>
> import pygame, pygame.font, pygame.image, pygame.mixer
> ImportError: No module named pygame
>
> I think my install of pygame was incorrect?  Any help on what I am doing wrong
> would be appreciated.  If this is the wrong list for the this question, please
> point me in the right direction.

Is pygame installed where python can find it,
i.e., in one of the directories listed when you do...
	import sys ; sys.path
?

If not...
either reinstall in the sys.path,
or append where it did install to sys.path.

If so, or which of the above is best in this case
and how to do it on a MS system,
I dunno.


- Bruce



From bsass@freenet.edmonton.ab.ca  Wed Jun 27 09:03:50 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Wed, 27 Jun 2001 02:03:50 -0600 (MDT)
Subject: [Tutor] another Module / import problem
In-Reply-To: <01062700005201.00748@localhost>
Message-ID: <Pine.LNX.4.33.0106270141220.1748-100000@bms>

On Wed, 27 Jun 2001, Kathrin Kirsch wrote:

> ok, I updated my db, so now the locate message is:
>
> /usr/lib/python/rhtkinter.py
> /usr/lib/python/rhtkinter.pyc
> /usr/lib/python2.1/lib-dynload/_tkinter.so
> /usr/lib/python2.1/lib-tk/Tkinter.py
> /usr/lib/python2.1/lib-tk/Tkinter.pyc
> /usr/lib/python2.1/lib-tk/Tkinter.pyo
>
> And.. I cannot load any other modules (like cgi.py) either
> "import cgi
>   File "/usr/lib/python2.1/cgi.py", line 39, in ?
>     import urllib
>   File "/usr/lib/python2.1/urllib.py", line 26, in ?
>     import socket
>   File "/usr/lib/python2.1/socket.py", line 41, in ?
>     from _socket import *
> ImportError: shared object not open"

So, it can't find /usr/lib/python-2.1/lib-dynload/_socket.so...

> > I got a similiar problem using tkinter since installing python 2.1 on
> > linux.
> >
> > The error message looks like:
> >  File "/usr/lib/python2.1/lib-tk/Tkinter.py", line 35, in ?
> >     import _tkinter # If this fails your Python may not be configured for
> > Tk ImportError: shared object not open

...which is also a .../lib-dynload error, this time with _tkinter.so

Is lib-dynload is sys.path?

ld.so doesn't need to know about them, well...
	ldconfig -p | grep lib-dynload
has no output on my system, and everything works.


- Bruce

p.s. - Just curious, whose packages and which version of the
distribution, or did you build from source into /usr?



From Daxesh Patwa" <dpatwa@cisco.com  Wed Jun 27 09:14:14 2001
From: Daxesh Patwa" <dpatwa@cisco.com (Daxesh Patwa)
Date: Wed, 27 Jun 2001 13:44:14 +0530
Subject: [Tutor] Creating Table using Tkinter
Message-ID: <37f401c0fee1$27425850$c6ef87c0@dpatwapc>

This is a multi-part message in MIME format.

------=_NextPart_000_37F1_01C0FF0F.40BEEAE0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi All,

Any help on how to creat a table using Tkinter.

My problem :

I am developing a GUI, using Tkinter. I want to display differnet =
choices in a list box,which user can scroll in to and choose one of the =
displayed list.

But as I know I can display only one choice per row of the list and I =
cant have multiple elements on the same row.

If I can create table with more then one column, I may be able to =
display all these columns.(That is what I am guessing)

Any other work around or pointer for this problem will be quite helpful.

Thanks and Regards
Daxesh=20

------=_NextPart_000_37F1_01C0FF0F.40BEEAE0
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.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi All,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any help on how to creat a table using=20
Tkinter.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My problem :</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am developing a GUI, using Tkinter. I =
want to=20
display differnet choices in a list box,which user can scroll in to and =
choose=20
one of the displayed list.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>But as I know I can display only one =
choice per row=20
of the list and I cant have multiple elements on the same =
row.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>If I can create table with more then =
one column, I=20
may be able to display all these columns.(That is what I am=20
guessing)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any other work around or pointer for =
this problem=20
will be quite helpful.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks and Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Daxesh</FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_37F1_01C0FF0F.40BEEAE0--



From glingl@aon.at  Wed Jun 27 10:31:51 2001
From: glingl@aon.at (Gregor Lingl)
Date: Wed, 27 Jun 2001 11:31:51 +0200
Subject: [Tutor] Dining philosophers?
References: <37f401c0fee1$27425850$c6ef87c0@dpatwapc>
Message-ID: <3B39A806.C1E34E7@aon.at>


Dear Pythonistas!
Has anybody come across an implementation
fo the dining philosophers problem in Python?
(I know of  the one of Tim Peters', but could not
find it. Even Tim himself does not know if it still
exists somewhere)
Gregor Lingl



From rob@jam.rr.com  Wed Jun 27 12:32:37 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Wed, 27 Jun 2001 06:32:37 -0500
Subject: [Tutor] Python Server Pages
Message-ID: <NFBBKIELCLIEEMGGIGKDGEHDCAAA.rob@jam.rr.com>

I'm sleepily glancing over PSP info on this site:

http://www.ciobriefings.com/psp/

and am curious if anyone on the list has spent any time with Python Server
Pages. The rusty gears in my mind are turning, and I'm trying to think what
sort of interesting Challenges we could come up with if I came up with a way
to provide some access to a server where people could do a little PSP
development.

Any ideas, suggestions, warnings?
Rob

"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/



From lsloan@umich.edu  Wed Jun 27 14:32:19 2001
From: lsloan@umich.edu (Lance E Sloan)
Date: Wed, 27 Jun 2001 09:32:19 -0400
Subject: [Tutor] Please send messages only to the list.
In-Reply-To: Your message of "Tue, 26 Jun 2001 11:09:49 PDT."
 <3B386D7D.10454.27A2517D@localhost>
Message-ID: <200106271332.JAA27084@birds.us.itd.umich.edu>

"Jesse W" wrote:
> Wow.  I have started a monster.  I am amazed and aghast.  The 
> doubled messages did not bother me that much, I just thought it 
> might be a misunderstanding or an easily fixable issue.  I see it is 
> _definitely_ not.  Thank you all for your patience. ;-)
> Oh, and viva Pegasus! (at least for those on Windows or Mac)

I didn't see this mentioned already, so please forgive me if I do
repeat something that's been written before.

I'm subscribed to the tutor digest.  The digest itself has a
"Reply-to:  tutor@python.org" header, but the messages within the
digest do not.  My mail client is a recent version of MH.  When I use
MH's "burst" command to break the digest into individual messages for
easier reading and replying, those individual messages don't have
"Reply-to" headers unless the sender set one.  For example, Michael set
one on the message with subject "Re: [Tutor] Curses programming".

I don't know whether burst behaves properly or if it should be using
the "Reply-to" from the digest headers.  Anyway, I just mean to point
out that it doesn't require somebody to reply to all to get the sender
of a tutor message.  I just used the vanilla reply command, and it
inserted your name, Jesse, into the "To" header.

Well, to make sure my message has some Python content in it (and not so
much rat), here's an idea for a Python Challenge (TM).  A program that
will eliminate duplicate email messages from the user's inbox.

Speaking from a UNIX point-of-view, it would accept an email message
from stdin and parse the headers for its "Message-ID" header.  Once
found, the ID is looked up in a list of recently received IDs.  If it's
found, the message is either discarded or stored in a file of dupes.
If it's not found, store the message in the user's inbox
(/var/spool/mail/[username]) or place it somewhere else (like use some
MH command to store it in a folder).  Such a program could be written
to work like the UCB vacation program, so it can be used in the
system-wide /etc/mail/aliases file or in a user's ~/.forward file.

Of course, this could be done in conjunction with procmail to make
the storing of the message easier.  In fact, procmail could probably
handle all of this without any Python involved, but that wouldn't
be fun, would it?

--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting.  Specializing in Perl & Python CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"


From qhe@ydyn.com  Wed Jun 27 15:07:02 2001
From: qhe@ydyn.com (Peter He)
Date: Wed, 27 Jun 2001 09:07:02 -0500
Subject: [Tutor] GUI die when execute sys.exit()
Message-ID: <5.1.0.14.0.20010627085908.00aebe78@mail.ydyn.com.criticalpath.net>

Hi, there,

Here is a small example from Mark Lutz's book -- Programming Python 2nd 
Edition.

from Tkinter import *

class HelloClass:
     def __init__(self):
         widget = Button(None, text='Hello event world', command=self.quit)
         widget.pack()
     def quit(self):
         print 'Hello class method world'    # self.quit is a bound method
         import sys; sys.exit()              # retains the self+quit pair

HelloClass()
mainloop()


When I run it and click the button, the gui die and I got the following 
message:

 >>> Unhandled exception while debugging...
Traceback (most recent call last):
   File "C:\PP2ndEd\Examples\PP2E\Gui\Intro\gui3c.py", line 9, in quit
     import sys; sys.exit()              # retains the self+quit pair
SystemExit

I am using Pythonwin IDE from ActiveStates and windows 2000. I got the same 
problems when I run other similar examples from other books too.

Thank you in advance!

Peter



From mtobin@bigfoot.com  Wed Jun 27 15:22:42 2001
From: mtobin@bigfoot.com (Mark Tobin)
Date: Wed, 27 Jun 2001 10:22:42 -0400
Subject: [Tutor] Text to GUI with Tkinter
Message-ID: <3B39B3F2.18941.848A31@localhost>

Does anybody have any general suggestions for taking a 
(somewhat) complete text based program and translating it to a 
Tkinter GUI?  Is there a procedure or process that makes this a 
simpler task then it appears on the surface?  What steps have you 
taken to do this?  Should I have been planning to GUIfy the 
program from the beginning, and now I'm essentially going to have 
to rewrite the program?  I'm just looking for some broad ideas.

Thanks,
Mark


From rufmetal@home.com  Wed Jun 27 20:18:30 2001
From: rufmetal@home.com (Chris Keelan)
Date: Wed, 27 Jun 2001 14:18:30 -0500
Subject: [Tutor] Re: General Programming Question
Message-ID: <01062714183005.02420@tygesen>

On Wednesday 27 June 2001 00:48, Michael wrote:

> Yes, and well they should!  Unfortunately, it's not a good book for an
> autodidact unless you've a pretty good mathematical background or some
> kind of natural skill with math concepts.

I've resigned myself to the fact that it will take me about five years to 
work my way through SICP. This because I don't have an engineering/ 
mathematics bacground and programming isn't my "real job". Still, I think 
it's worth the slog. 

>  <Scheme and the Art of
> Programming> is better but still a tough row to hoe.  I have a goodly
> collection of Scheme books.  Books are no substitute for grey matter,
> I'm afraid.  At least <The Little Schemer> was fun!

Agree with you there. TLS, side-by-side with How To Design Programs is an 
excellent way to get introduced to Scheme. And I think that functional 
programming with Scheme is a great adjunct to developing with Python.

- Chris
On Wednesday 27 June 2001 00:48, you wrote:
> Yes, and well they should!  Unfortunately, it's not a good book for an
> autodidact unless you've a pretty good mathematical background or some
> kind of natural skill with math concepts.

I've resigned myself to the fact that it will take me about five years to
work my way through SICP. This because I don't have an engineering/
mathematics bacground and programming isn't my "real job". Still, I think
it's worth the slog.

>  <Scheme and the Art of
> Programming> is better but still a tough row to hoe.  I have a goodly
> collection of Scheme books.  Books are no substitute for grey matter,
> I'm afraid.  At least <The Little Schemer> was fun!

Agree with you there. TLS, side-by-side with How To Design Programs is an
excellent way to get introduced to Scheme. And I think that functional
programming with Scheme is a great adjunct to developing with Python.

- Chris



From lonetwin@yahoo.com  Wed Jun 27 19:43:22 2001
From: lonetwin@yahoo.com (steve)
Date: Thu, 28 Jun 2001 00:13:22 +0530
Subject: [Tutor] Text to GUI with Tkinter
In-Reply-To: <01062800123300.07051@mercury.in.cqsl.com>
References: <3B39B3F2.18941.848A31@localhost> <01062800123300.07051@mercury.in.cqsl.com>
Message-ID: <01062800132201.07051@mercury.in.cqsl.com>

On Thursday 28 June 2001 00:12, you wrote:
> Hi every,
>  This is *NOT* a reply to the question..
>
> > Does anybody have any general suggestions for taking a
> > (somewhat) complete text based program and translating it to a
> > Tkinter GUI?  Is there a procedure or process that makes this a
> > simpler task then it appears on the surface?  What steps have you
> > taken to do this?  Should I have been planning to GUIfy the
> > program from the beginning, and now I'm essentially going to have
> > to rewrite the program?  I'm just looking for some broad ideas.
> >
> > Thanks,
> > Mark
>
>  Anybody who does reply to the above query, cud really help me out too.
> Sometime back I meant to ask something of the similar nature but petern=
ing
> to a curses based UI, [Subject was given as 'Curses Programming']. The
> problem tho' was I'm not too good at communicating stuff, so...N E ways=
, I
> too am looking for 'broad' ideas, stuff like how does one approach the
> design of a (G)UI based application, do I code all the working of the a=
pp
> first an' then plug the UI in, or do I design the app. alongwith the UI=
=2E
>
> BTW ...I'd like to thank sill (that u r name??) and Arcege (I downloade=
d
> Pyirc...tho' cudn't get it functioning...and t'was a "bit" complex to
> understand....but that was just the first skim-thru' ...didn't get 'nuf=
f
> time..) for replying.
>
> Peace
> Steve
>
> -------------------------
>
> |||||||||#####||||||||
> ||||||||
> ||||||||#######|||||||
> ||||||||# O O #|||||||
> ||||||||#\ ~ /#|||||||
> ||||||
> ||||||##||\_/||##|||||
> |||||
> |||||#||||||||||##||||
> ||||
> ||||#||||||||||||##|||
> ||||#|||||||||||||##||
> |||
> |||/\##|||||||||##/\||
> |
> |/    \#########/    \
> |\     \#######/     /
> |
> ||\____/#######\____/|
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Hello.  Just walk along and try NOT to think about your INTESTINES
> being almost FORTY YARDS LONG!!
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

--=20
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||=09
|||/\##|||||||||##/\||=09
|/    \#########/    \=09
|\     \#######/     /=09
||\____/#######\____/|=09
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=09
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


From michael@trollope.org  Wed Jun 27 19:40:18 2001
From: michael@trollope.org (Michael Powe)
Date: Wed, 27 Jun 2001 11:40:18 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <5.1.0.14.0.20010626211353.00ad6e40@Pop3.norton.antivirus>
 (message from Kojo Idrissa on Tue, 26 Jun 2001 21:19:30 -0500)
References: <20010626174435.D24384@transmeta.com>
 <6D19AB695BA8D311A8420008C7CF285A020A8F09@trgmail>
 <200106262326.f5QNQnd31699@cecilia.trollope.org>
 <20010626174435.D24384@transmeta.com> <5.1.0.14.0.20010626211353.00ad6e40@Pop3.norton.antivirus>
Message-ID: <200106271840.f5RIeIa32553@cecilia.trollope.org>

>>>>> "Kojo" == Kojo Idrissa <kojo@hal-pc.org> writes:

    Kojo> 'How To Design Programs' is a good book, but the site is not
    Kojo> functioning at the moment.  I was reading the book too, but
    Kojo> when you go to the site now, it redirects you to some Casino
    Kojo> site.

Well, according to register.com, www.htdp.org is 'available,' so I
guess someone screwed up somewhere.  All http://www.htdp.org gets
me is a 404.  Too bad.  Couldn't pull up anything useful in the google
cache, either.

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From lonetwin@yahoo.com  Wed Jun 27 20:02:17 2001
From: lonetwin@yahoo.com (steve)
Date: Thu, 28 Jun 2001 00:32:17 +0530
Subject: [Tutor] Text to GUI with Tkinter
In-Reply-To: <01062800132201.07051@mercury.in.cqsl.com>
References: <3B39B3F2.18941.848A31@localhost> <01062800123300.07051@mercury.in.cqsl.com> <01062800132201.07051@mercury.in.cqsl.com>
Message-ID: <01062800321704.07051@mercury.in.cqsl.com>

FOO !!!
 The previous msg. from me was accidently "Reply-to'ed" to Mark, so I wen=
t to=20
the sent mail box and "Send-again'ed" it, an' that's y the leading '>' an=
d=20
the double signatures......my apologies ....AHHHHH...I feel like an' ass!=
!

ME sorry
Steve


From JoachimThoene@web.de  Thu Jun 28 02:21:40 2001
From: JoachimThoene@web.de (Joachim =?iso-8859-1?Q?Th=F6ne?=)
Date: Wed, 27 Jun 2001 21:21:40 -0400
Subject: [Tutor] Python and SQL
Message-ID: <3B3A86A4.B29FF3F4@web.de>

Hello all,
I'm new to this list and not very expierienced with Python. For I want
to write an application that uses Python and the Postgresql database I
need Information how to use the Python API for Postgres (Example: how to
call Databasecommands like 'SELECT * FROM Database', or how to log in to
a Database from a Python Script).
Does anybody know a tutorial and where I can find somethin about that?

Thanks and sorry for my bad English, its not my native language.

Joachim


From deirdre@deirdre.net  Wed Jun 27 20:31:40 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Wed, 27 Jun 2001 12:31:40 -0700
Subject: [Tutor] Python and SQL
In-Reply-To: <3B3A86A4.B29FF3F4@web.de>
References: <3B3A86A4.B29FF3F4@web.de>
Message-ID: <a05101059b75fe3421cab@[10.20.0.138]>

At 9:21 PM -0400 6/27/01, Joachim Th=F6ne wrote:
>Hello all,
>I'm new to this list and not very expierienced with Python. For I want
>to write an application that uses Python and the Postgresql database I
>need Information how to use the Python API for Postgres (Example: how to
>call Databasecommands like 'SELECT * FROM Database', or how to log in to
>a Database from a Python Script).
>Does anybody know a tutorial and where I can find somethin about that?

You want to look at the database sig stuff:

http://www.python.org/topics/database/

And also:

http://www.druid.net/pygresql/


http://www.amk.ca/python/writing/DB-API.html (it's mostly the same 
for postgres, but a little different)

>Thanks and sorry for my bad English, its not my native language.

Quite alright, it's better than my German. :)

Basically, the process is something like:

1) Open the database
2) Create a cursor
3) Execute a statement with that cursor
4) Fetch one or more result rows

A mini example can be found here:

http://mail.python.org/pipermail/db-sig/2001-June/001783.html
http://mail.python.org/pipermail/db-sig/2001-June/001786.html
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From qhe@ydyn.com  Wed Jun 27 20:33:36 2001
From: qhe@ydyn.com (Peter He)
Date: Wed, 27 Jun 2001 14:33:36 -0500
Subject: [Tutor] question about displays in listbox
Message-ID: <5.1.0.14.0.20010627140918.00ae5958@mail.ydyn.com.criticalpath.net>

Hi all,

I want to insert the following lines into a listbox and display them in 
spreadsheet format:

OXTHICK01           Ellipsometer        UP          10      0
ASML01              Scanner             UP          35      5
ASML02              Scanner             DOWN        35      5
CANON01             Stepper             BUSY        45      8
CDSEM01             SEM                 UP          15      3
CDSEM02             SEM                 UP          15      3
LAM01               Etcher              UP          17      2
LAM02               Etcher              BUSY        19      5
CDSEM01             SEM                 UP          15      3
CDSEM02             SEM                 UP          15      3

The problem is: how can I guarantee that each column is aligned left? I 
used the following code to organize each line:

tool = '%-20s%-20s%-12s%-8d%-8d'%(tool_pair['toolname'], 
tool_pair['tooltype'], tool_pair['toolstate'], tool_pair['meanproctime'], 
tool_pair['stdevproctime'])

Then I insert it into the listbox:

self.listbox.inser('end', tool)

I think the possible reason is that  space has smaller width than letter, 
and even letters have different widths -- 'w' is wider than 'l'.

I think this problem is related to the used font, because it's aligned 
properly in Python shell. So what kind of font should I use in my listbox?

Is there a table/spreadsheet widget I can use? or How to use tixGrid or 
tixTList from Tix in Python?

Thank you,

Peter



From dsh8290@rit.edu  Wed Jun 27 20:40:27 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 27 Jun 2001 15:40:27 -0400
Subject: [Tutor] GUI die when execute sys.exit()
In-Reply-To: <5.1.0.14.0.20010627085908.00aebe78@mail.ydyn.com.criticalpath.net>; from qhe@ydyn.com on Wed, Jun 27, 2001 at 09:07:02AM -0500
References: <5.1.0.14.0.20010627085908.00aebe78@mail.ydyn.com.criticalpath.net>
Message-ID: <20010627154027.B17245@harmony.cs.rit.edu>

On Wed, Jun 27, 2001 at 09:07:02AM -0500, Peter He wrote:
| When I run it and click the button, the gui die and I got the following 
| message:
| 
|  >>> Unhandled exception while debugging...
| Traceback (most recent call last):
|    File "C:\PP2ndEd\Examples\PP2E\Gui\Intro\gui3c.py", line 9, in quit
|      import sys; sys.exit()              # retains the self+quit pair
| SystemExit

This is supposed to happen.

| I am using Pythonwin IDE from ActiveStates and windows 2000. I got
| the same problems when I run other similar examples from other books
| too.

Well, the debugger doesn't know it, but it is supposed to be that way ;-).


sys.exit() works by raising the exception 'SystemExit'.  This allows
try-finally clauses to work to perform any cleanup necessary before
the program terminates.  You expected the program to quit (gui to
die), didn't you <wink>?  If you run the program outside of the
debugger it will look fine (you won't see the stacktrace).  Oh, yeah,
I should mention that the current python IDEs (PythonWin and IDLE come
to mind) run your code in the same interpreter the IDE runs in.  If
you call sys.exit(), well, it will exit <wink>.  (I guess that's what
you meant, PythonWin died, not "the gui")

-D



From glingl@aon.at  Wed Jun 27 21:00:29 2001
From: glingl@aon.at (Gregor Lingl)
Date: Wed, 27 Jun 2001 22:00:29 +0200
Subject: [Tutor] GUI die when execute sys.exit()
References: <5.1.0.14.0.20010627085908.00aebe78@mail.ydyn.com.criticalpath.net> <20010627154027.B17245@harmony.cs.rit.edu>
Message-ID: <3B3A3B5D.B3C27F3@aon.at>


D-Man schrieb:

Oh, yeah, I should mention that the current python IDEs (PythonWin
and IDLE come to mind) run your code in the same interpreter the IDE runs in.
If
you call sys.exit(), well, it will exit <wink>.  (I guess that's what
you meant, PythonWin died, not "the gui")
-----

Couldn't that bei fixed by using different threads for the gui and the app?
Why is this not done?
Gregor



From gibbs05@flash.net  Wed Jun 27 20:54:38 2001
From: gibbs05@flash.net (Archimedes)
Date: Wed, 27 Jun 2001 14:54:38 -0500
Subject: [Tutor] Text to GUI with Tkinter
References: <3B39B3F2.18941.848A31@localhost> <01062800123300.07051@mercury.in.cqsl.com> <01062800132201.07051@mercury.in.cqsl.com>
Message-ID: <002c01c0ff43$04cb54e0$50de3040@gibbs05>

Greetings Mark, Steve, and anyone interested,

On Thursday 28 June 2001 00:12, you wrote:
> Hi every,
>  This is *NOT* a reply to the question..
>
> > Does anybody have any general suggestions for taking a
> > (somewhat) complete text based program and translating it to a
> > Tkinter GUI?  Is there a procedure or process that makes this a
> > simpler task then it appears on the surface?  What steps have you
> > taken to do this?  Should I have been planning to GUIfy the
> > program from the beginning, and now I'm essentially going to have
> > to rewrite the program?  I'm just looking for some broad ideas.
> >
> > Thanks,
> > Mark
>

I'll give this issue a shot, but I have to keep it short.

Multiple user interfaces isn't a python issue as much as a design issue.
You'd have the same concerns if you were programming in Java, C++, Ada,
Perl, etc.

What you'll want to do is separate the core functionality of your program
and its user interface(s) into separate modules.  You may know you need a
character based user interface today, but tomorrow you may need a web
interface or a GUI.  You also gain the advantage of being able to test the
different pieces of your program separately.


Here's how I'd proceed with this in Python.

Step 1:
   Remove the core functionality of your program into it's own module.

Step 2:
   Create tests for every important feature of your core module using
unittest.py.  There's debate whether its better to place these tests within
the core module itself or in yet another module specifically created for
doing the tests.  Do what seems best.  Once you're experienced with this
sort of thing consider doing step 2 before step 1.

Step 3:
   Run the tests. Debug. Test. Debug...

Step 4:
   Create your text based interface module.  Import your core module and use
it just as you would any other Python module.  Test it.  Writing interfaces
is much easier when you already know the core module works.

Step 5:
   Create another module for your Tkinter interface.  Import your tried and
true core module. Test it.  It really doesn't matter what order you do steps
4 and 5 :-)


Hmmm.  Actually I think I did something similar to this for a dice roller I
submitted to Useless Python back when I was first learning Tkinter.


Hope this helps some,
Sam

>  Anybody who does reply to the above query, cud really help me out too.
> Sometime back I meant to ask something of the similar nature but peterning
> to a curses based UI, [Subject was given as 'Curses Programming']. The
> problem tho' was I'm not too good at communicating stuff, so...N E ways, I
> too am looking for 'broad' ideas, stuff like how does one approach the
> design of a (G)UI based application, do I code all the working of the app
> first an' then plug the UI in, or do I design the app. alongwith the UI.
>
> BTW ...I'd like to thank sill (that u r name??) and Arcege (I downloaded
> Pyirc...tho' cudn't get it functioning...and t'was a "bit" complex to
> understand....but that was just the first skim-thru' ...didn't get 'nuff
> time..) for replying.
>
> Peace
> Steve
>
> -------------------------
>
> |||||||||#####||||||||
> ||||||||
> ||||||||#######|||||||
> ||||||||# O O #|||||||
> ||||||||#\ ~ /#|||||||
> ||||||
> ||||||##||\_/||##|||||
> |||||
> |||||#||||||||||##||||
> ||||
> ||||#||||||||||||##|||
> ||||#|||||||||||||##||
> |||
> |||/\##|||||||||##/\||
> |
> |/    \#########/    \
> |\     \#######/     /
> |
> ||\____/#######\____/|
>
> =====================================
> Hello.  Just walk along and try NOT to think about your INTESTINES
> being almost FORTY YARDS LONG!!
> ====================================

--
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||
|||/\##|||||||||##/\||
|/    \#########/    \
|\     \#######/     /
||\____/#######\____/|
=====================================
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
====================================

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From dsh8290@rit.edu  Wed Jun 27 21:18:12 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 27 Jun 2001 16:18:12 -0400
Subject: [Tutor] GUI die when execute sys.exit()
In-Reply-To: <3B3A3B5D.B3C27F3@aon.at>; from glingl@aon.at on Wed, Jun 27, 2001 at 10:00:29PM +0200
References: <5.1.0.14.0.20010627085908.00aebe78@mail.ydyn.com.criticalpath.net> <20010627154027.B17245@harmony.cs.rit.edu> <3B3A3B5D.B3C27F3@aon.at>
Message-ID: <20010627161812.A17338@harmony.cs.rit.edu>

On Wed, Jun 27, 2001 at 10:00:29PM +0200, Gregor Lingl wrote:
| D-Man schrieb:
| 
| | Oh, yeah, I should mention that the current python IDEs (PythonWin
| | and IDLE come to mind) run your code in the same interpreter the
| | IDE runs in.  If you call sys.exit(), well, it will exit <wink>.
| | (I guess that's what you meant, PythonWin died, not "the gui")
| -----
| 
| Couldn't that bei fixed by using different threads for the gui and the app?

No, it would still be in the same process.  The code probably is run
in a different thread (certainly not the GUI's event thread -- if it
was the GUI would "freeze").

| Why is this not done?

It needs to be run in a separate process (intpreter).  This is hard to
do, especially to provide the sort of control you need when debugging.
No one has volunteered to implement this sort of thing yet.

-D



From mtobin@bigfoot.com  Wed Jun 27 21:30:09 2001
From: mtobin@bigfoot.com (Mark Tobin)
Date: Wed, 27 Jun 2001 16:30:09 -0400
Subject: [Tutor] Text to GUI with Tkinter
Message-ID: <20010627203128.QFV2007@anonymous>

On 28 Jun 2001, at 0:18, Roman Suzi wrote:

> On Wed, 27 Jun 2001, Mark Tobin wrote:
> 
> >Does anybody have any general suggestions for taking a
> >(somewhat) complete text based program and translating it to a
> >Tkinter GUI?  Is there a procedure or process that makes this a
> >simpler task then it appears on the surface?  What steps have you
> >taken to do this?  Should I have been planning to GUIfy the
> >program from the beginning, and now I'm essentially going to have
> >to rewrite the program?  I'm just looking for some broad ideas.
> 
> The answer depends on what the program does and how fat is it's
> connection to user: how much controls it has.

Hmmm.. I see what you're saying... in my particular app the 
interface simply controls the execution of some functions and 
displays results (pretty simple), but I'm really asking from a larger 
design perspective...

> 
> I think the best approach is:
> 
> To sort out everything concerned with program controls and parameters.
> Decide what of that set goes to config-files and what needs to be
> presented to the user in GUI form.
> 
> For example, GUI for the CD writing software could be very
> different:
> 
> EasyCD gives user several buttons to choose from, while gcombust has
> several screens full of options and lists for the user to tweak
> (and, in fact, gcombust uses comman-line tools like cdrecord
> and mkisofs (those have lots of CLUI options!)).

Good example... I think I see

> 
> So, "guifying" is very depending on the tasks target user need to perform.
> 
> The wise solution is to separate program logic from GUI.  This way you
> could change both with less trouble later.

That's sort of what Archimedes suggested and in retrospect makes 
a fair bit of sense, but I wish I knew that when I started... oh well.. 
next time ;-)

> 
> Why do you need GUI?

I don't really, I just want to figure this stuff out...
 
> >Thanks,
> >Mark
> 
> Sincerely yours, Roman Suzi
Thanks Again, Mark
> -- 
> _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd@onego.ru _/
> _/ Wednesday, June 27, 2001 _/ Powered by Linux RedHat 6.2 _/
> _/ "No sense being pessimistic. It wouldn't work anyway." _/
> 




From JoachimThoene@web.de  Thu Jun 28 03:38:19 2001
From: JoachimThoene@web.de (Joachim =?iso-8859-1?Q?Th=F6ne?=)
Date: Wed, 27 Jun 2001 22:38:19 -0400
Subject: [Tutor] Python and SQL
References: <3B3A86A4.B29FF3F4@web.de> <a05101059b75fe3421cab@[10.20.0.138]>
Message-ID: <3B3A989B.654BC07F@web.de>

Deirdre Saoirse Moen schrieb:
>=20
> At 9:21 PM -0400 6/27/01, Joachim Th=F6ne wrote:
> >Hello all,
> >I'm new to this list and not very expierienced with Python. For I want
> >to write an application that uses Python and the Postgresql database I
> >need Information how to use the Python API for Postgres (Example: how =
to
> >call Databasecommands like 'SELECT * FROM Database', or how to log in =
to
> >a Database from a Python Script).
> >Does anybody know a tutorial and where I can find somethin about that?
>=20
> You want to look at the database sig stuff:
>=20
> http://www.python.org/topics/database/
>=20
> And also:
>=20
> http://www.druid.net/pygresql/
>=20
> http://www.amk.ca/python/writing/DB-API.html (it's mostly the same
> for postgres, but a little different)
>=20
> >Thanks and sorry for my bad English, its not my native language.
>=20
> Quite alright, it's better than my German. :)
>=20
> Basically, the process is something like:
>=20
> 1) Open the database
> 2) Create a cursor
> 3) Execute a statement with that cursor
> 4) Fetch one or more result rows
>=20
> A mini example can be found here:
>=20
> http://mail.python.org/pipermail/db-sig/2001-June/001783.html
> http://mail.python.org/pipermail/db-sig/2001-June/001786.html
> --
> _Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
> "Cannot run out of time.... Is infinite time. You... are finite....
> Zathrus... is finite. This... is wrong tool!" -- Zathrus
>=20
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

By trying what I've just learned ( Thanks Deidre), Idle displayed the
following error message:

>>> import pgdb
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in ?
    import pgdb
  File "/usr/lib/python2.1/site-packages/pgdb.py", line 65, in ?
    except ImportError: import DateTime
ImportError: No module named DateTime
>>>=20

As a Python newbie of course I don't know a Module named 'DataTime'. So
here is my question:
Where can I find that module?

Thanks
Joachim


From deirdre@deirdre.net  Wed Jun 27 21:41:26 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Wed, 27 Jun 2001 13:41:26 -0700
Subject: [Tutor] Python and SQL
In-Reply-To: <3B3A989B.654BC07F@web.de>
References: <3B3A86A4.B29FF3F4@web.de>
 <a05101059b75fe3421cab@[10.20.0.138]> <3B3A989B.654BC07F@web.de>
Message-ID: <a05101002b75ff54054a6@[10.20.0.138]>

At 10:38 PM -0400 6/27/01, Joachim Th=F6ne wrote:
>By trying what I've just learned ( Thanks Deidre), Idle displayed the
>following error message:
>
>>>>  import pgdb
>Traceback (most recent call last):
>   File "<pyshell#0>", line 1, in ?
>     import pgdb
>   File "/usr/lib/python2.1/site-packages/pgdb.py", line 65, in ?
>     except ImportError: import DateTime
>ImportError: No module named DateTime
>>>>
>
>As a Python newbie of course I don't know a Module named 'DataTime'. So
>here is my question:
>Where can I find that module?

A lot of the database libraries rely on mxDateTime (which allows 
dates outside the Unix epoch). I can't remember where to find that 
offhand.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From jessw@loop.com  Wed Jun 27 21:42:36 2001
From: jessw@loop.com (Jesse W)
Date: Wed, 27 Jun 2001 13:42:36 -0700
Subject: [Tutor] Creating Table using Tkinter
In-Reply-To: <37f401c0fee1$27425850$c6ef87c0@dpatwapc>
Message-ID: <3B39E2CC.18007.22F553@localhost>

Daxesh Patwa wrote:
<snip>
> 
> I am developing a GUI, using Tkinter. I want to display differnet
> choices in a list box,which user can scroll in to and choose one of
> the displayed list.
> 
> But as I know I can display only one choice per row of the list and I
> cant have multiple elements on the same row.
Why don't you just make more than one listbox next to each other?
Then you would not need more than one column in each list box.
You could do this using the grid geometry manager.

<snip>
> Thanks and Regards
> Daxesh 

				Hope-this-is-helpful-l'y,
						Jesse W




From dyoo@hkn.eecs.berkeley.edu  Wed Jun 27 21:55:53 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 27 Jun 2001 13:55:53 -0700 (PDT)
Subject: [Tutor] Python and SQL
In-Reply-To: <a05101002b75ff54054a6@[10.20.0.138]>
Message-ID: <Pine.LNX.4.21.0106271354350.26318-100000@hkn.eecs.berkeley.edu>

On Wed, 27 Jun 2001, Deirdre Saoirse Moen wrote:

> At 10:38 PM -0400 6/27/01, Joachim Th=F6ne wrote:
> >By trying what I've just learned ( Thanks Deidre), Idle displayed the
> >following error message:
> >
> >>>>  import pgdb
> >Traceback (most recent call last):
> >   File "<pyshell#0>", line 1, in ?
> >     import pgdb
> >   File "/usr/lib/python2.1/site-packages/pgdb.py", line 65, in ?
> >     except ImportError: import DateTime
> >ImportError: No module named DateTime
> >>>>
> >
> >As a Python newbie of course I don't know a Module named 'DataTime'. So
> >here is my question:
> >Where can I find that module?
>=20
> A lot of the database libraries rely on mxDateTime (which allows=20
> dates outside the Unix epoch). I can't remember where to find that=20
> offhand.
>=20

mxDateTime is a part of the collection of modules in mx-base here:

    http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#mxBASE

There's a windows installer, so with some luck, it should install well.



From bsass@freenet.edmonton.ab.ca  Wed Jun 27 22:12:13 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Wed, 27 Jun 2001 15:12:13 -0600 (MDT)
Subject: [Tutor] Text to GUI with Tkinter
In-Reply-To: <20010627203128.QFV2007@anonymous>
Message-ID: <Pine.LNX.4.33.0106271445280.3326-100000@bms>

On Wed, 27 Jun 2001, Mark Tobin wrote:
> On 28 Jun 2001, at 0:18, Roman Suzi wrote:
> > On Wed, 27 Jun 2001, Mark Tobin wrote:
> >
> > >Does anybody have any general suggestions for taking a
> > >(somewhat) complete text based program and translating it to a
> > >Tkinter GUI?  Is there a procedure or process that makes this a
> > >simpler task then it appears on the surface?  What steps have you
> > >taken to do this?  Should I have been planning to GUIfy the
> > >program from the beginning, and now I'm essentially going to have
> > >to rewrite the program?  I'm just looking for some broad ideas.
> >
> > The answer depends on what the program does and how fat is it's
> > connection to user: how much controls it has.
>
> Hmmm.. I see what you're saying... in my particular app the
> interface simply controls the execution of some functions and
> displays results (pretty simple), but I'm really asking from a larger
> design perspective...
<...>
> > The wise solution is to separate program logic from GUI.  This way you
> > could change both with less trouble later.
>
> That's sort of what Archimedes suggested and in retrospect makes
> a fair bit of sense, but I wish I knew that when I started... oh well..
> next time ;-)

You also need to decide if you want prg-gui and prg-tui, or just prg.

Archimedes seemed to be heading towards the former, where the UI is
the main thing and the user runs different programs depending on which
UI (s)he wants.

Having a single program that can spit out to either a text UI or a
graphics UI may be the way to go though, depending on the
circumstances.  Using this design paradigm you end up with a core, a
generic UI layer, and modules for the actual GUI and TUI code.  It is
a little trickier to code, but can be very flexible.  e.g. (and not
saying that this is actually how it is coded), I can start xemacs in a
GUI environment then login to a text console and do

	gnuclient somefile

which starts up a text interface to the same instance of xemacs that
is displaying to a window on the GUI.

> > Why do you need GUI?
>
> I don't really, I just want to figure this stuff out...

A much better reason than, `the boss is making me...'.  :)


- Bruce



From qhe@ydyn.com  Wed Jun 27 22:14:40 2001
From: qhe@ydyn.com (Peter He)
Date: Wed, 27 Jun 2001 16:14:40 -0500
Subject: [Tutor] Re: GUI die when execute sys.exit() (D-Man)
In-Reply-To: <E15FM4Z-0005g3-00@mail.python.org>
Message-ID: <5.1.0.14.0.20010627160301.00afae58@mail.ydyn.com.criticalpath.net>

>Message: 8
>Date: Wed, 27 Jun 2001 15:40:27 -0400
>From: D-Man <dsh8290@rit.edu>
>To: "tutor-request-python.org" <tutor@python.org>
>Subject: Re: [Tutor] GUI die when execute sys.exit()
>
>On Wed, Jun 27, 2001 at 09:07:02AM -0500, Peter He wrote:
>| When I run it and click the button, the gui die and I got the following
>| message:
>|
>|  >>> Unhandled exception while debugging...
>| Traceback (most recent call last):
>|    File "C:\PP2ndEd\Examples\PP2E\Gui\Intro\gui3c.py", line 9, in quit
>|      import sys; sys.exit()              # retains the self+quit pair
>| SystemExit
>
>This is supposed to happen.
>
>| I am using Pythonwin IDE from ActiveStates and windows 2000. I got
>| the same problems when I run other similar examples from other books
>| too.
>
>Well, the debugger doesn't know it, but it is supposed to be that way ;-).
>
>
>sys.exit() works by raising the exception 'SystemExit'.  This allows
>try-finally clauses to work to perform any cleanup necessary before
>the program terminates.  You expected the program to quit (gui to
>die), didn't you <wink>?  If you run the program outside of the
>debugger it will look fine (you won't see the stacktrace).  Oh, yeah,
>I should mention that the current python IDEs (PythonWin and IDLE come
>to mind) run your code in the same interpreter the IDE runs in.  If
>you call sys.exit(), well, it will exit <wink>.  (I guess that's what
>you meant, PythonWin died, not "the gui")
>
>-D


I used 'GUI die' in my last question. What I actually meant is that the GUI 
freezes. GUI is still there but you can't close it and no response when you 
click the buttons on it. So I have to restart Python to get rid of it.

Peter




From kromag@nsacom.net  Thu Jun 28 01:13:59 2001
From: kromag@nsacom.net (kromag@nsacom.net)
Date: Wed, 27 Jun 2001 17:13:59 -0700 (PDT)
Subject: [Tutor] BrainBench Python1.5 test outline
Message-ID: <200106280013.f5S0Dxd24041@pop.nsacom.net>

Since you asked so nice! 

The following is guffed from brainbench (http://www.brainbench.com/
It picks out a random group of questions from a large database, YMMV.


Test Outline 

Built-In Functions 
 Applicative Functions 
 File Handling 
 Introspective Functions 
 Magic Methods, Functions and Attributes 
 Meta-functions 
 Numeric Functions 

Conversions 
 ConfigParser, getopt 
 Internet Formats 
 md5, crypt, gzip 
 sgmllib,xmllib 

Core Language 
 Comparison and Boolean Operators 
 Defining Functions and Classes 
 Dictionary Operators and Methods 
 Exception Handling 
 Flow Control Statements 
 Formatting strings 
 Namespaces 
 Numeric Operators  
 Sequence Operators and Methods 
 Syntax  

Internet Modules 
 CGI 
 htmllib 
 Other Protocols 
 Servers 
 urllib, urlparse 

Process Management 
 os, posix, win32 
 pstats, profile 
 thread, threading 

Python Environments 
 Environment Variables 
 Idle 
 Interactive Mode 

Storage and Persistence 
 *dbm 
 Pickle, shelve, marshal 

String-related Modules 
 re 
 String 
 StringIO/cStringIO  
 



From rufmetal@home.com  Thu Jun 28 00:27:46 2001
From: rufmetal@home.com (Chris Keelan)
Date: Wed, 27 Jun 2001 18:27:46 -0500
Subject: [Tutor] OT: HTDP
Message-ID: <01062718274601.05253@tygesen>

As the "general programming question" thread revealed, the htdp.org people 
are having trouble with their domain and "How To Design Programs" is 
temporarily unavailable.

I had snarfed the site a while ago and I've put the tarball on my personal 
site at http://members.home.net/rufmetal , which I'll leave up until the 
official version of the book comes back online.

Hope that helps those who are interested.

- Chris 


From allan.crooks@btinternet.com  Thu Jun 28 00:17:23 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Thu, 28 Jun 2001 00:17:23 +0100
Subject: [Tutor] Two Quick Questions
Message-ID: <E15FOYk-00072w-00@rhenium>

Hi,

Don't know if you ever got an answer to this, so I'm answering it. :)

> My question is:  Does the difference in order of nots and variables make
> any difference when used in more complex, subtle ways?  If not, what is
> the usual way of ordering it?  I prefer the second beacuse it sounds
> nicer, but still ;o)

As far as I'm aware, it doesn't make the slightest bit of difference.

I assume that it was designed to prevent people accidently swapping the position of the not and getting the entire logic of the if statement reversed.

Should you want to test if the negative of an object is in a sequence (rather than if an object is not in a sequence), you just use brackets.

>>> L = [0, 1]
>>> S = 0
>>> if S not in L: print "Hello"
..
>>> if not S in L: print "Hello"
..
>>> if (not S) in L: print "Hello"
..
Hello
>>> if not S not in L: print "Hello"
..
Hello
>>>

I don't know why I did the last example. I was just seeing if it worked. It did, and it's a fairly frightening sentence to write, so let's forget all about double negatives. :)

Allan.



From dsh8290@rit.edu  Thu Jun 28 00:29:16 2001
From: dsh8290@rit.edu (D-Man)
Date: Wed, 27 Jun 2001 19:29:16 -0400
Subject: [Tutor] Re: GUI die when execute sys.exit() (D-Man)
In-Reply-To: <5.1.0.14.0.20010627160301.00afae58@mail.ydyn.com.criticalpath.net>; from qhe@ydyn.com on Wed, Jun 27, 2001 at 04:14:40PM -0500
References: <E15FM4Z-0005g3-00@mail.python.org> <5.1.0.14.0.20010627160301.00afae58@mail.ydyn.com.criticalpath.net>
Message-ID: <20010627192916.A17497@harmony.cs.rit.edu>

On Wed, Jun 27, 2001 at 04:14:40PM -0500, Peter He wrote:
| 
| I used 'GUI die' in my last question. What I actually meant is that the GUI 
| freezes. GUI is still there but you can't close it and no response when you 
| click the buttons on it. So I have to restart Python to get rid of it.

The question is "which gui?" -- is it your gui (that you made with the
sample code) or the PythonWin gui?  In either case, PythonWin and IDLE
and other IDEs don't work with GUI apps.  Just use python directly
from the command line (DOS shell).

-D



From pobrien@orbtech.com  Thu Jun 28 01:52:27 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 27 Jun 2001 19:52:27 -0500
Subject: [Tutor] GUI die when execute sys.exit()
In-Reply-To: <20010627161812.A17338@harmony.cs.rit.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEPMKBAA.pobrien@orbtech.com>

A revitalization effort has begun for IDLE, with Guido's blessings, and
adding this feature (app in separate process) is probably *the* top
priority. Join the IDLE Developers discussion list to keep up with the new
project.

http://sourceforge.net/projects/idlefork/

http://mail.python.org/mailman/listinfo/idle-dev

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
D-Man
Sent: Wednesday, June 27, 2001 3:18 PM
To: tutor-request-python.org
Subject: Re: [Tutor] GUI die when execute sys.exit()

On Wed, Jun 27, 2001 at 10:00:29PM +0200, Gregor Lingl wrote:
| D-Man schrieb:
|
| | Oh, yeah, I should mention that the current python IDEs (PythonWin
| | and IDLE come to mind) run your code in the same interpreter the
| | IDE runs in.  If you call sys.exit(), well, it will exit <wink>.
| | (I guess that's what you meant, PythonWin died, not "the gui")
| -----
|
| Couldn't that bei fixed by using different threads for the gui and the
app?

No, it would still be in the same process.  The code probably is run
in a different thread (certainly not the GUI's event thread -- if it
was the GUI would "freeze").

| Why is this not done?

It needs to be run in a separate process (intpreter).  This is hard to
do, especially to provide the sort of control you need when debugging.
No one has volunteered to implement this sort of thing yet.

-D


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From dan@webmind.com  Thu Jun 28 02:15:24 2001
From: dan@webmind.com (Dan Tropp)
Date: Thu, 28 Jun 2001 11:15:24 +1000
Subject: [Tutor] How do you manipulate dates? ie. one month before 1/1/2001 = ??
Message-ID: <002401c0ff6f$cf7aacf0$0601c10a@oz.intelligenesis.net>

The time module allows you to print, format and create time tuples and epoch
time, but how do you calculate the date in two days, or three months ago
(including rolling the months and accounting for daylight savings time??

utc time - 60*60*24*numDays does not work for daylightsavings changes.

I guess I'm looking for something like java.util.Calendar.add(DAY_OF_MONTH,
numDays)

Dan Tropp



From dyoo@hkn.eecs.berkeley.edu  Thu Jun 28 05:36:57 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 27 Jun 2001 21:36:57 -0700 (PDT)
Subject: [Tutor] How do you manipulate dates? ie. one month before 1/1/2001
 = ??
In-Reply-To: <002401c0ff6f$cf7aacf0$0601c10a@oz.intelligenesis.net>
Message-ID: <Pine.LNX.4.21.0106271936120.32060-100000@hkn.eecs.berkeley.edu>

On Thu, 28 Jun 2001, Dan Tropp wrote:

> The time module allows you to print, format and create time tuples and epoch
> time, but how do you calculate the date in two days, or three months ago
> (including rolling the months and accounting for daylight savings time??
> 
> utc time - 60*60*24*numDays does not work for daylightsavings changes.
> 
> I guess I'm looking for something like java.util.Calendar.add(DAY_OF_MONTH,
> numDays)

It looks like the mxDateTime module might be what you're looking for.  In
the example on:

    http://www.lemburg.com/files/python/mxDateTime.html

the author does examples like this:

###
# add one month
>>> print now() + RelativeDateTime(months=+1)
1998-09-11 16:46:24.59

# Last Sunday in October 1998
>>> print Date(1998) + RelativeDateTime(weekday=(Sunday,-1),month=10)
1998-10-25 00:00:00.00
###

so mxDateTime makes it easy to add and subtract dates from each
other.

Good luck to you!



From van@lindbergs.org  Thu Jun 28 06:13:34 2001
From: van@lindbergs.org (VanL)
Date: Wed, 27 Jun 2001 23:13:34 -0600
Subject: [Tutor] Search and Replace
Message-ID: <3B3ABCFE.2090502@lindbergs.org>

Hello,

I just did a search and replace script.  It works, but I am wondering if 
there is something better.

I use os.path.walk to walk through a directory tree, calling the 
visitfile function on each file (quoted below).

By the way, I know that I scan through the file multiple times; I have a 
version that doesn't do that, but I did it this way first to get a 
little better debugging output.  Just ignore that inefficiency.

def visitfile(fname, sarstrings):
	stext, rtext = sarstrings[0], sarstrings[1]
	matcher = re.compile(stext) 
	try:
		if not listonly:
			if os.path.splitext(fname)[1] in skipexts:
				debug('Skipping: ' + fname)
			elif string.find(open(fname).read(), stext) != -1:
				debug('%s has %s' % (fname, stext))
				linelist = open(fname, 'rb+').readlines()
				file = open(fname, 'wb', 0)
				for line in linelist:
					line = matcher.sub(rtext, line)
					file.write(line)
				file.close()
				fcount = fcount + 1
	except: pass 




Like I said, this works... but it worries me a little because I truncate 
the file to 0 length and then rewrite it from the in-memory list.  This 
could very easily be a problem for very large files.  Moreover, if the 
script is interrupted, the curent file will be lost.

Is there a better way to do an in-place change?  

Thanks,

Van



From r.b.rigilink@chello.nl  Thu Jun 28 07:17:31 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Thu, 28 Jun 2001 08:17:31 +0200
Subject: [Tutor] Search and Replace
References: <3B3ABCFE.2090502@lindbergs.org>
Message-ID: <3B3ACBFB.C51C05F9@chello.nl>

Hi Van,

A couple of comments, and the version I use, which also has a couple of
problems.

Why use regular expressions, when there is a perfectly good
string.replace() function that does exactly what you want?

For the inner loop, how about:

for i in xrange(len(linelist)):
    linelist[i] = matcher.sub(rtext, linelist[i])
    # or linelist[i].replace(stext, rtext)
file = open(fname, 'w')
file.writelines(linelist)

listonly and skipext are globals, why not do these tests before you call
visitfile?

if not listonly and ext not in skipext:
    visitfile(fname)

I think the biggest nono in this script, is silently catching all
errors. You will never notice anything going wrong (undefined listonly
and skipexts, for example, but also erorrs in opening, reading and
writing files)

At least do something like:
except:
    debug('An error occured, ignoring...')

VanL wrote:
> 
> Hello,
> 
> I just did a search and replace script.  It works, but I am wondering if
> there is something better.
> 
> I use os.path.walk to walk through a directory tree, calling the
> visitfile function on each file (quoted below).
> 
> By the way, I know that I scan through the file multiple times; I have a
> version that doesn't do that, but I did it this way first to get a
> little better debugging output.  Just ignore that inefficiency.
> 

Actually, it's a good reason, I do too, see below.

> def visitfile(fname, sarstrings):
>         stext, rtext = sarstrings[0], sarstrings[1]
>         matcher = re.compile(stext)
>         try:
>                 if not listonly:
>                         if os.path.splitext(fname)[1] in skipexts:
>                                 debug('Skipping: ' + fname)
>                         elif string.find(open(fname).read(), stext) != -1:
>                                 debug('%s has %s' % (fname, stext))
>                                 linelist = open(fname, 'rb+').readlines()
>                                 file = open(fname, 'wb', 0)
>                                 for line in linelist:
>                                         line = matcher.sub(rtext, line)
>                                         file.write(line)
>                                 file.close()
>                                 fcount = fcount + 1
>         except: pass
> 
> Like I said, this works... but it worries me a little because I truncate
> the file to 0 length and then rewrite it from the in-memory list.  This
> could very easily be a problem for very large files.  Moreover, if the
> script is interrupted, the curent file will be lost.
> 
> Is there a better way to do an in-place change?
> 
> Thanks,
> 
> Van
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

My version

Ugly, no function, not reusable, bad exception handling, but hey, it
works.
An in-memory copy of the file is also not very efficient. But I really
only want to replace the file if anything is changed.

better inner loop:

for i in xrange(len(lines)):
    if lines[i].find(repl_old) != -1:
        changed = 1
    lines[i] = lines[i].replace(repl_old, repl_new)


#!/data/software/bin/python
import sys

if len(sys.argv) < 4:
    print 'Usage : file_replace replace_old replace_new file1 file2 ...
filen'
    
repl_old = sys.argv[1]
repl_new = sys.argv[2]
filelist = sys.argv[3:]

for filename in filelist:
    try:
        f = open(filename,'r')
        new_lines = []
        changed = 0
        lines = f.readlines()
        for l in lines:
            nl = l.replace(repl_old, repl_new)
            new_lines.append(nl)
            if nl != l:
                changed = 1
        if changed:
            print 'Updating :', filename
            f = open(filename,'w')
            f.writelines(new_lines)
    except:
        print 'Error replacing %s with %s in %s' % (repl_old, repl_new,
filename)
 
Hope this helps,

Roeland

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From NHYTRO@compuserve.com  Thu Jun 28 07:29:55 2001
From: NHYTRO@compuserve.com (Sharriff Aina)
Date: Thu, 28 Jun 2001 02:29:55 -0400
Subject: [Tutor] Coding style ?
Message-ID: <200106280230_MC3-D76B-9EF2@compuserve.com>

Now that I=B4m beggining to lose my Python training wheels, my code seems=

very cludgy. Is  there an official coding suggestion, beutifyer, or codin=
g
style URL for Python somewhere? just curious



Regards


Sharriff


From ppathiyi@cisco.com  Thu Jun 28 07:43:58 2001
From: ppathiyi@cisco.com (Praveen Pathiyil)
Date: Thu, 28 Jun 2001 12:13:58 +0530
Subject: [Tutor] Coding style ?
References: <200106280230_MC3-D76B-9EF2@compuserve.com>
Message-ID: <068201c0ff9d$b5d509c0$37ef87c0@ppathiyipc>

Hi,

You can try out http://www.python.org/doc/essays/styleguide.html

I haven't gone through this :-)).... So not very sure about the contents =
..

Rgds,
Praveen.

----- Original Message -----
From: "Sharriff Aina" <NHYTRO@compuserve.com>
To: <tutor@python.org>
Sent: Thursday, June 28, 2001 11:59 AM
Subject: [Tutor] Coding style ?


> Now that I=B4m beggining to lose my Python training wheels, my code see=
ms
> very cludgy. Is  there an official coding suggestion, beutifyer, or cod=
ing
> style URL for Python somewhere? just curious
>
>
>
> Regards
>
>
> Sharriff
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From van@lindbergs.org  Thu Jun 28 08:00:37 2001
From: van@lindbergs.org (VanL)
Date: Thu, 28 Jun 2001 01:00:37 -0600
Subject: [Tutor] Search and Replace
References: <3B3ABCFE.2090502@lindbergs.org> <3B3ACBFB.C51C05F9@chello.nl>
Message-ID: <3B3AD615.6040107@lindbergs.org>

Hello,  tahks for the comments.

Roeland Rengelink wrote:

>
>Why use regular expressions, when there is a perfectly good
>string.replace() function that does exactly what you want?
>
Because using regexes makes it a bit more general, and because (in this 
case) I needed to match a regex.
I am thinking of rewriting and expanding this to include a mode 
argument, with modes 0,1,2 = string replacement, regex, compiled regex 
object.

>I think the biggest nono in this script, is silently catching all
>errors. You will never notice anything going wrong (undefined listonly
>and skipexts, for example, but also erorrs in opening, reading and
>writing files)
>
>At least do something like:
>except:
>    debug('An error occured, ignoring...')
>
Good idea.  Thnx.

>My version
>
[snip]

Thanks for letting me see how another person did it.  It is a good idea 
to only change the file if it needs changing.  But I notice that you do 
the same sort of thying that worried me about mine:


                if changed:
                        print 'Updating :', filename
                        f = open(filename, 'w')
                        f.writelines(new_lines)

This, once again, truncates the file and then writes it out.  I am 
worried about possible data loss;  Ideally, I would
open the file for reading and writing, read in one line, change it, 
write it back out, read another line, etc.  That way, if the script was 
stopped halfway through execution, the replacement wouldn't be finished, 
but the file contents would not be lost.

>
>Hope this helps,
>
>Roeland
>
Once again, Thanks!

Van



From scarblac@pino.selwerd.nl  Thu Jun 28 08:05:00 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 28 Jun 2001 09:05:00 +0200
Subject: [Tutor] Search and Replace
In-Reply-To: <3B3AD615.6040107@lindbergs.org>; from van@lindbergs.org on Thu, Jun 28, 2001 at 01:00:37AM -0600
References: <3B3ABCFE.2090502@lindbergs.org> <3B3ACBFB.C51C05F9@chello.nl> <3B3AD615.6040107@lindbergs.org>
Message-ID: <20010628090459.A28386@pino.selwerd.nl>

On  0, VanL <van@lindbergs.org> wrote:
> This, once again, truncates the file and then writes it out.  I am 
> worried about possible data loss;  Ideally, I would
> open the file for reading and writing, read in one line, change it, 
> write it back out, read another line, etc.  That way, if the script was 
> stopped halfway through execution, the replacement wouldn't be finished, 
> but the file contents would not be lost.

That won't work if the two strings don't have the same length.

It would be easier to write a temporary file, when that is done, remove the
old one and rename the temp file.

The fileinput module can do something similar: it can move the file to a
backup name, give you its contents line by line, and anything you print will
go to the old filename. It works like this:

import fileinput

def replace_in_file(filename, oldstring, newstring):
   for line in fileinput.input(filename, inplace=1, backup='.bak'):
      print line.replace(oldstring, newstring)

-- 
Remco Gerlich


From r.b.rigilink@chello.nl  Thu Jun 28 08:22:58 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Thu, 28 Jun 2001 09:22:58 +0200
Subject: [Tutor] Search and Replace
References: <3B3ABCFE.2090502@lindbergs.org> <3B3ACBFB.C51C05F9@chello.nl> <3B3AD615.6040107@lindbergs.org>
Message-ID: <3B3ADB52.CF4838E1@chello.nl>

VanL wrote:
> 
> Hello,  tahks for the comments.
> 
> Roeland Rengelink wrote:
> 
> >
> >Why use regular expressions, when there is a perfectly good
> >string.replace() function that does exactly what you want?
> >
> Because using regexes makes it a bit more general, and because (in this
> case) I needed to match a regex.
> I am thinking of rewriting and expanding this to include a mode
> argument, with modes 0,1,2 = string replacement, regex, compiled regex
> object.
> 

I see now, sounds good.

<snip>
> 
> This, once again, truncates the file and then writes it out.  I am
> worried about possible data loss;  Ideally, I would
> open the file for reading and writing, read in one line, change it,
> write it back out, read another line, etc.  That way, if the script was
> stopped halfway through execution, the replacement wouldn't be finished,
> but the file contents would not be lost.
> 

How about, after reading the file, renaming it to something like
fname.backup
(renaming could be made reasonably save on most OSs), and only if this
is succesfull
writing the new file ?

Roeland

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From wheelege@tsn.cc  Thu Jun 28 08:59:53 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Thu, 28 Jun 2001 17:59:53 +1000
Subject: [Tutor] Re: GUI die when execute sys.exit() (D-Man)
References: <E15FM4Z-0005g3-00@mail.python.org> <5.1.0.14.0.20010627160301.00afae58@mail.ydyn.com.criticalpath.net> <20010627192916.A17497@harmony.cs.rit.edu>
Message-ID: <036b01c0ffa8$50b67fa0$0200a8c0@ACE>

> On Wed, Jun 27, 2001 at 04:14:40PM -0500, Peter He wrote:
> |
> | I used 'GUI die' in my last question. What I actually meant is that the
GUI
> | freezes. GUI is still there but you can't close it and no response when
you
> | click the buttons on it. So I have to restart Python to get rid of it.
>
> The question is "which gui?" -- is it your gui (that you made with the
> sample code) or the PythonWin gui?  In either case, PythonWin and IDLE
> and other IDEs don't work with GUI apps.  Just use python directly
> from the command line (DOS shell).
>

  I believe that PythonWin works fine with tkinter apps - at least it has
with every tkinter app I've written.  Something to do with the fact that it
is not written in tcl/tk itself, unlike IDLE.

  Glen.


> -D
>
\



From sak@nwlink.com  Thu Jun 28 09:54:45 2001
From: sak@nwlink.com (Sak)
Date: Thu, 28 Jun 2001 01:54:45 -0700
Subject: [Tutor] Python 101 at devshed.com confusion
Message-ID: <01062801544500.02181@ci.nodomain.net>

Hey everyone,

I'm just learning Python, and have been enjoying working through the Python 
101 articles on devshed.  I'm confused about something in part 2 of the 
Python 101 article, under the Sliced And Diced section...

http://www.devshed.com/Server_Side/Python/Python101_2/page6.html

At the beginning of the example, I'm told that the index of a string begins 
with 0 at the first character.  Where I get confused is right away when I 
extract a substring...

>>> str = "hobgoblin"
>>> str[3:9]
'goblin'
>>>

When I walk through this in my Python interpreter, I get an error when I try 
this...

>>> str = "hobgoblin"
>>> str[9]
Traceback (innermost last):
  File "<stdin>", line 1, in ?
IndexError: string index out of range
>>>

It makes perfect sense to me when using the len() function that I get a 
response that there are 9 characters in the string, but when I count through, 
starting at 0 for the first character, I only come up with eight for the last 
character too, just like the interpreter did.  So how come the first example, 
indexing [3:9] works?

Thanks,
-- 
Sak.


From bren@europe.nl.com  Thu Jun 28 09:59:14 2001
From: bren@europe.nl.com (Brendon)
Date: Thu, 28 Jun 2001 10:59:14 +0200
Subject: [Tutor] Newbie problems
Message-ID: <0106281058520B.20991@yatsu>

Hello List,

I'm trying to learn Python but when using one of the examples on 
http://www.crosswinds.net/~agauld/ i get an error.

the example:

>>>class Address:
...   def __init__(self, Hs, St, Town, Zip):
...     self.HsNumber = Hs
...     self.Street = St
...     self.Town = Town
...     self.ZipCode = Zip

Addr = Address(7,"High St","Anytown","123 456")


which gives the following error:
---
Traceback (innermost last):
  File "<stdin>", line 1, in ?
NameError: Address
---
Any help would be greatly appreciated.


Brendon


From scarblac@pino.selwerd.nl  Thu Jun 28 10:01:24 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 28 Jun 2001 11:01:24 +0200
Subject: [Tutor] Python 101 at devshed.com confusion
In-Reply-To: <01062801544500.02181@ci.nodomain.net>; from sak@nwlink.com on Thu, Jun 28, 2001 at 01:54:45AM -0700
References: <01062801544500.02181@ci.nodomain.net>
Message-ID: <20010628110124.A28625@pino.selwerd.nl>

On  0, Sak <sak@nwlink.com> wrote:
> I'm just learning Python, and have been enjoying working through the Python 
> 101 articles on devshed.  I'm confused about something in part 2 of the 
> Python 101 article, under the Sliced And Diced section...
> 
> http://www.devshed.com/Server_Side/Python/Python101_2/page6.html
> 
> At the beginning of the example, I'm told that the index of a string begins 
> with 0 at the first character.  Where I get confused is right away when I 
> extract a substring...
> 
> >>> str = "hobgoblin"
> >>> str[3:9]
> 'goblin'
> >>>
> 
> When I walk through this in my Python interpreter, I get an error when I try 
> this...
> 
> >>> str = "hobgoblin"
> >>> str[9]
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> IndexError: string index out of range
> >>>
> 
> It makes perfect sense to me when using the len() function that I get a 
> response that there are 9 characters in the string, but when I count through, 
> starting at 0 for the first character, I only come up with eight for the last 
> character too, just like the interpreter did.  So how come the first example, 
> indexing [3:9] works?

Slices are different from normal indexing.

You can only index actually existing characters (0-8, and -1 to -9 counting
from the end).

Slices are more liberal - if some part of a string you specify doesn't
exist, it simply puts an empty string there. 

>>> "hobgoblin"[12-14]
''

This also works for other sequences, like lists:
>>> x = [1, 2, 3]
>>> x[5:17]
[]

Note that slices give you the parts of the string *excluding* the last index,
so "hobgoblin"[0:8] gives "hobgobli".

These things may look odd at first, but in practice it turns out both of
these are exactly the right choice, it makes programming with slices easy.

-- 
Remco Gerlich


From scarblac@pino.selwerd.nl  Thu Jun 28 10:03:21 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 28 Jun 2001 11:03:21 +0200
Subject: [Tutor] Newbie problems
In-Reply-To: <0106281058520B.20991@yatsu>; from bren@europe.nl.com on Thu, Jun 28, 2001 at 10:59:14AM +0200
References: <0106281058520B.20991@yatsu>
Message-ID: <20010628110321.B28625@pino.selwerd.nl>

On  0, Brendon <bren@europe.nl.com> wrote:
> >>>class Address:
> ...   def __init__(self, Hs, St, Town, Zip):
> ...     self.HsNumber = Hs
> ...     self.Street = St
> ...     self.Town = Town
> ...     self.ZipCode = Zip
> 
> Addr = Address(7,"High St","Anytown","123 456")
> 
> 
> which gives the following error:
> ---
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> NameError: Address

This should work fine. Are you sure typed the "Addr =" line after the class
definition, back at the ">>>" prompt? If the prompt was still "..." then you
need an empty line there to end the class.

Otherwise, maybe a typo?

-- 
Remco Gerlich


From wheelege@tsn.cc  Thu Jun 28 10:03:05 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Thu, 28 Jun 2001 19:03:05 +1000
Subject: [Tutor] Newbie problems
References: <0106281058520B.20991@yatsu>
Message-ID: <03a701c0ffb1$256145c0$0200a8c0@ACE>


> Hello List,

  Hi! :)

>
> I'm trying to learn Python but when using one of the examples on
> http://www.crosswinds.net/~agauld/ i get an error.
>
> the example:
>
> >>>class Address:
> ...   def __init__(self, Hs, St, Town, Zip):
> ...     self.HsNumber = Hs
> ...     self.Street = St
> ...     self.Town = Town
> ...     self.ZipCode = Zip
>
> Addr = Address(7,"High St","Anytown","123 456")
>
>
> which gives the following error:
> ---
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> NameError: Address
> ---
> Any help would be greatly appreciated.
>
>

  Well, from first look nothing appears wrong.  A NameError means that
Python can't find the object your talking about - in this case it's Address,
and that's the class.  How are you running this?  Here is my attempt at the
interepreter...

>>> class Address:
...  def __init__(self, Hs, St, Town, Zip):
...   self.HsNumber = Hs
...   self.Street = St
...   self.Town = Town
...   self.ZipCode = Zip
...
>>> Addr = Address(7,"High St", "Anytown", "123 456")
>>> print Addr.HsNumber
7
>>>  ## etc

  Can you try again, and if you still have trouble post again in more
detail?

  Thanks,
  Glen.



From bren@europe.nl.com  Thu Jun 28 10:20:05 2001
From: bren@europe.nl.com (Brendon)
Date: Thu, 28 Jun 2001 11:20:05 +0200
Subject: [Tutor] Newbie problems
In-Reply-To: <20010628110321.B28625@pino.selwerd.nl>
References: <0106281058520B.20991@yatsu> <20010628110321.B28625@pino.selwerd.nl>
Message-ID: <0106281120050D.20991@yatsu>

On Thursday 28 June 2001 11:03, you wrote:
> On  0, Brendon <bren@europe.nl.com> wrote:
> > >>>class Address:
> >
> > ...   def __init__(self, Hs, St, Town, Zip):
> > ...     self.HsNumber = Hs
> > ...     self.Street = St
> > ...     self.Town = Town
> > ...     self.ZipCode = Zip
> >
> > Addr = Address(7,"High St","Anytown","123 456")
> >
> >
> > which gives the following error:
> > ---
> > Traceback (innermost last):
> >   File "<stdin>", line 1, in ?
> > NameError: Address
>
> This should work fine. Are you sure typed the "Addr =" line after the class
> definition, back at the ">>>" prompt? If the prompt was still "..." then
> you need an empty line there to end the class.

ah, thanks everyone. i didnt know an empty line was required.

cheers, 


Brendon


From wheelege@tsn.cc  Thu Jun 28 10:15:29 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Thu, 28 Jun 2001 19:15:29 +1000
Subject: [Tutor] Python 101 at devshed.com confusion
References: <01062801544500.02181@ci.nodomain.net>
Message-ID: <03ed01c0ffb2$e0a75c60$0200a8c0@ACE>

> Hey everyone,
>
> I'm just learning Python, and have been enjoying working through the
Python
> 101 articles on devshed.  I'm confused about something in part 2 of the
> Python 101 article, under the Sliced And Diced section...
>
> http://www.devshed.com/Server_Side/Python/Python101_2/page6.html
>
> At the beginning of the example, I'm told that the index of a string
begins
> with 0 at the first character.  Where I get confused is right away when I
> extract a substring...
>
> >>> str = "hobgoblin"
> >>> str[3:9]
> 'goblin'
> >>>
>
> When I walk through this in my Python interpreter, I get an error when I
try
> this...
>
> >>> str = "hobgoblin"
> >>> str[9]
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> IndexError: string index out of range
> >>>
>
> It makes perfect sense to me when using the len() function that I get a
> response that there are 9 characters in the string, but when I count
through,
> starting at 0 for the first character, I only come up with eight for the
last
> character too, just like the interpreter did.  So how come the first
example,
> indexing [3:9] works?

  Yup yup, well have a look at this little session...

>>> s = 'Jimbo McJim'
>>> s[1:3]
'im'            ## uh-huh, we knew that
>>> s[:10]
'Jimbo McJi'    ## yup, again expected
>>> s[10]
'm'             ## the 'cutting place' for slices is to the left of that
index
>>> s[:11]
'Jimbo McJim'   ## again, expected
>>> s[:12]
'Jimbo McJim'   ## hmmm seems it just truncates down to the available
characters...
>>> s[:155]
'Jimbo McJim'   ## how convenient!

  As you can see, the slice would of worked it is was str[3:124].  However,
when we want all of a list from a point, we can use str[3:] - sort of like
str[3:len(str)].
  Hope that helped,
  Glen.



From amoreira@mercury.ubi.pt  Thu Jun 28 10:39:55 2001
From: amoreira@mercury.ubi.pt (Jose Amoreira)
Date: Thu, 28 Jun 2001 10:39:55 +0100
Subject: [Tutor] Newbie problems
References: <0106281058520B.20991@yatsu> <20010628110321.B28625@pino.selwerd.nl> <0106281120050D.20991@yatsu>
Message-ID: <3B3AFB6B.7FF3D8B@mercury.ubi.pt>

Brendon wrote:

>
> ah, thanks everyone. i didnt know an empty line was required.
>
> cheers,
>
> Brendon

Note that the blank line is only required at the python interactive interpreter,
to signal the end of the block. In a standalone python program, you may simply
unindent the code after the end of the class definition. Of course, it won't
hurt if you supply a blank line as well!
Cheers,
Ze



From toodles@yifan.net  Thu Jun 28 10:54:42 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Thu, 28 Jun 2001 17:54:42 +0800
Subject: [Tutor] exec vs. eval
Message-ID: <FPEHJJPEEOIPMAHOADBKEEFNCEAA.toodles@yifan.net>

Hi folks,

In an attempt to emulate my graphics calculator, I've started by creating a
function program. Just for background info, it works by specifying a list of
functions (or just one). Code is at the end of the email.

eg. dfunc(['y=x+1'])
eg. dfunc(['x=0'])

However at the moment, the code isn't very secure...it uses the exec()
function. As an example of how this could be utilised (and this is a very
mild example):

dfunc(['import sys','sys.exit()'])
#this will exit the interpreter

Should I be using the RExec module to fix this, or is there an easier
approach?

TIA, Andrew

###################################

def dfunc(funcs,xrange=[0,100,1]):
  values={}
  for n in range(xrange[0],xrange[1],xrange[2]):
    x=y=n
    for func in funcs: exec(func)
    values[x]=y
    return values




From alan.gauld@bt.com  Thu Jun 28 10:43:54 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 10:43:54 +0100
Subject: [Tutor] General Programming Question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D872@mbtlipnt02.btlabs.bt.co.uk>

> I'd like to know if there was a way to compile Python to 
> native machine code, 

Of course its possible to do this since *every* program you run 
runs as native machine code - there aint no other way! But in Pythons 
case the native machine code of the interpreter is translating the 
program as it goes... To build a truly native code compiler for 
Python would be intensely difficult given Pythons very dynamic 
nature - we can construct code based on user input and then execute 
it - you need the interpreter functionality builtb into every 
program anyway!

> would it run as fast as say C++ or Java?  

Given the above  even if you built a native code compiler its 
speed would depend on how the author wrote the program - if it 
used dynamic code generation then no - OTOH you can't write 
that kind of code at all in Java or C++!

BUT in my informal tests Python is very oftenb as fast, or faster 
than Java so thats not an issue. It is however significantly slower 
than C++ (just as Java is - about 5-10 times depending on JVMs etc).

Alan G


From alan.gauld@bt.com  Thu Jun 28 10:47:06 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 10:47:06 +0100
Subject: [Tutor] General Programming Question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D873@mbtlipnt02.btlabs.bt.co.uk>

> ActiveState is working on a .NET compiler for Python:
> 
>     http://www.activestate.com/Initiatives/NET/Research.html
> 
> so, with luck, we'll get blazingly fast compiled Python some 

Blazingly fast? .NET?

Shurely shum mishtake....?

Its flexible, its potentially multiplatform it is a competitor 
to Java but nobody ever said fast!

Alan G


From toodles@yifan.net  Thu Jun 28 11:06:27 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Thu, 28 Jun 2001 18:06:27 +0800
Subject: [Tutor] rexec (was exec vs. eval)
In-Reply-To: <FPEHJJPEEOIPMAHOADBKEEFNCEAA.toodles@yifan.net>
Message-ID: <FPEHJJPEEOIPMAHOADBKAEFOCEAA.toodles@yifan.net>

Hmm strange subject name? I forgot to change it.
Anyway I had a snoop into rexec and the HOWTO...and could only think of
this:

import rexec

r_env=rexec.RExec()
r_env.ok_builtin_modules=() #don't need to import anything...

But this still allows the functions to access other objects...and apparently
rexec doesn't look at the global namespace:

Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>> import rexec
>>> r_env=rexec.RExec()
>>> y=1
>>> r_env.ok_builtin_modules=()
>>> r_env.r_exec('x=y')
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in ?
    r_env.r_exec('x=y')
  File "c:\python21\lib\rexec.py", line 264, in r_exec
    exec code in m.__dict__
  File "<string>", line 1, in ?
NameError: name 'y' is not defined

Any ideas?

TIA (again),
Andrew

> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Andrew Wilkins
> Sent: Thursday, 28 June 2001 5:55 PM
> To: tutor@python.org
> Subject: [Tutor] exec vs. eval
>
>
> Hi folks,
>
> In an attempt to emulate my graphics calculator, I've started by
> creating a
> function program. Just for background info, it works by
> specifying a list of
> functions (or just one). Code is at the end of the email.
>
> eg. dfunc(['y=x+1'])
> eg. dfunc(['x=0'])
>
> However at the moment, the code isn't very secure...it uses the exec()
> function. As an example of how this could be utilised (and this is a very
> mild example):
>
> dfunc(['import sys','sys.exit()'])
> #this will exit the interpreter
>
> Should I be using the RExec module to fix this, or is there an easier
> approach?
>
> TIA, Andrew
>
> ###################################
>
> def dfunc(funcs,xrange=[0,100,1]):
>   values={}
>   for n in range(xrange[0],xrange[1],xrange[2]):
>     x=y=n
>     for func in funcs: exec(func)
>     values[x]=y
>     return values
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>




From scarblac@pino.selwerd.nl  Thu Jun 28 10:59:53 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 28 Jun 2001 11:59:53 +0200
Subject: [Tutor] exec vs. eval
In-Reply-To: <FPEHJJPEEOIPMAHOADBKEEFNCEAA.toodles@yifan.net>; from toodles@yifan.net on Thu, Jun 28, 2001 at 05:54:42PM +0800
References: <FPEHJJPEEOIPMAHOADBKEEFNCEAA.toodles@yifan.net>
Message-ID: <20010628115953.A28777@pino.selwerd.nl>

On  0, Andrew Wilkins <toodles@yifan.net> wrote:
> In an attempt to emulate my graphics calculator, I've started by creating a
> function program. Just for background info, it works by specifying a list of
> functions (or just one). Code is at the end of the email.
> 
> eg. dfunc(['y=x+1'])
> eg. dfunc(['x=0'])
> 
> However at the moment, the code isn't very secure...it uses the exec()
> function. As an example of how this could be utilised (and this is a very
> mild example):
> 
> dfunc(['import sys','sys.exit()'])
> #this will exit the interpreter
> 
> Should I be using the RExec module to fix this, or is there an easier
> approach?

No, this is what rexec is for.

Without rexec, the user basically gets the chance to run whatever Python
code he wants with the same rights as your program, and to change the
running program.

-- 
Remco Gerlich


From scarblac@pino.selwerd.nl  Thu Jun 28 11:16:53 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 28 Jun 2001 12:16:53 +0200
Subject: [Tutor] rexec (was exec vs. eval)
In-Reply-To: <FPEHJJPEEOIPMAHOADBKAEFOCEAA.toodles@yifan.net>; from toodles@yifan.net on Thu, Jun 28, 2001 at 06:06:27PM +0800
References: <FPEHJJPEEOIPMAHOADBKEEFNCEAA.toodles@yifan.net> <FPEHJJPEEOIPMAHOADBKAEFOCEAA.toodles@yifan.net>
Message-ID: <20010628121653.A28818@pino.selwerd.nl>

On  0, Andrew Wilkins <toodles@yifan.net> wrote:
> Hmm strange subject name? I forgot to change it.
> Anyway I had a snoop into rexec and the HOWTO...and could only think of
> this:
> 
> import rexec
> 
> r_env=rexec.RExec()
> r_env.ok_builtin_modules=() #don't need to import anything...
> 
> But this still allows the functions to access other objects...and apparently
> rexec doesn't look at the global namespace:
> 
> Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
> >>> import rexec
> >>> r_env=rexec.RExec()
> >>> y=1
> >>> r_env.ok_builtin_modules=()
> >>> r_env.r_exec('x=y')
> Traceback (most recent call last):
>   File "<pyshell#4>", line 1, in ?
>     r_env.r_exec('x=y')
>   File "c:\python21\lib\rexec.py", line 264, in r_exec
>     exec code in m.__dict__
>   File "<string>", line 1, in ?
> NameError: name 'y' is not defined
> 
> Any ideas?

The global namespace isn't visible from inside the r_exec. Any values you
want to have available should be put in first (with appropriate r_exec
statements, I suppose) and can be read out with r_eval later. Maybe you can
get at the __dict__ of the enviroment from the outside (I haven't used rexec
myself).

I just noticed that by default, sys can be imported, but only a few of its
members can be used - but that includes sys.exit(). Strangely enough,
setting ok_builtin_modules doesn't change that.

Did you find the rexec howto at http://py-howto.sourceforge.net/rexec/ ?

-- 
Remco Gerlich

> 
> TIA (again),
> Andrew
> 
> > -----Original Message-----
> > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> > Andrew Wilkins
> > Sent: Thursday, 28 June 2001 5:55 PM
> > To: tutor@python.org
> > Subject: [Tutor] exec vs. eval
> >
> >
> > Hi folks,
> >
> > In an attempt to emulate my graphics calculator, I've started by
> > creating a
> > function program. Just for background info, it works by
> > specifying a list of
> > functions (or just one). Code is at the end of the email.
> >
> > eg. dfunc(['y=x+1'])
> > eg. dfunc(['x=0'])
> >
> > However at the moment, the code isn't very secure...it uses the exec()
> > function. As an example of how this could be utilised (and this is a very
> > mild example):
> >
> > dfunc(['import sys','sys.exit()'])
> > #this will exit the interpreter
> >
> > Should I be using the RExec module to fix this, or is there an easier
> > approach?
> >
> > TIA, Andrew
> >
> > ###################################
> >
> > def dfunc(funcs,xrange=[0,100,1]):
> >   values={}
> >   for n in range(xrange[0],xrange[1],xrange[2]):
> >     x=y=n
> >     for func in funcs: exec(func)
> >     values[x]=y
> >     return values
> >
> >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


From rhess@bic.ch  Thu Jun 28 11:31:56 2001
From: rhess@bic.ch (Flynt)
Date: Thu, 28 Jun 2001 12:31:56 +0200
Subject: [Tutor] Python 101 at devshed.com confusion
References: <01062801544500.02181@ci.nodomain.net>
Message-ID: <3B3B079C.FD582BF8@bic.ch>

Sak wrote:
> 
> Hey everyone,
> 
> I'm just learning Python, and have been enjoying working through the Python
> 101 articles on devshed.  I'm confused about something in part 2 of the
> Python 101 article, under the Sliced And Diced section...
> 
> http://www.devshed.com/Server_Side/Python/Python101_2/page6.html
> 
> At the beginning of the example, I'm told that the index of a string begins
> with 0 at the first character.  Where I get confused is right away when I
> extract a substring...
> 
> >>> str = "hobgoblin"
> >>> str[3:9]
> 'goblin'
> >>>
> 
> When I walk through this in my Python interpreter, I get an error when I try
> this...
> 
> >>> str = "hobgoblin"
> >>> str[9]
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> IndexError: string index out of range
> >>>
> 
> It makes perfect sense to me when using the len() function that I get a
> response that there are 9 characters in the string, but when I count through,
> starting at 0 for the first character, I only come up with eight for the last
> character too, just like the interpreter did.  So how come the first example,
> indexing [3:9] works?
> 
> Thanks,
> --
> Sak.
> 

Hi Sak

len() gives you nine characters and the indices in this list go from 0
to 8. That means, if you try to access str[9], you get the *out of
range* IndexError, simply because there is none.

Now, for the slice operator, you have to ask for str[3:9]:
Is index number 3 included or not in your slice ?
Is index number 9 included or not in your slice ?
This is not a priori self evident.

The rule for slicing is the following:

s[i:j] extracts a subsequence from s consisting of the elements with
index k where i <= k < j (which means index i is included in the slice,
but index 9 is not included in the slice).

In other words, the indices you pick by slicing in the form s[3:9] are:
s[3], s[4], s[5], s[6], s[7], s[8]
Index number 3 is included, but index number 9 (which would raise the
error) is **not** included any more !

HTH
--- Flynt


From alan.gauld@bt.com  Thu Jun 28 11:40:11 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 11:40:11 +0100
Subject: [Tutor] General Programming Question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D874@mbtlipnt02.btlabs.bt.co.uk>

> For learning scheme, you might consider the book:
> 
> "Structure and Interpretationof Computer Programs" by Harold 
> Abelson, Gerald Jay Sussman and Julie Sussman.

Having just finished it I'll second the motion. Its a very good 
book that anyone intertested on programming should read. However 
it does tend to suffer(like many Lisp books) from the "When all 
you have is a hammer, every problem looks like a nail" approach 
to life. Recursion is all - other loop constructs are not mentioned.



> 
> This is what is used at Berkeley to teach begining programming :)
> 
> It's also availible in its entirety online at:
> 
> http://mitpress.mit.edu/sicp/
> 
> On Tue, Jun 26, 2001 at 04:26:49PM -0700, M.A. Powe wrote:
> > 
> > I don't seem to be smart enough to do Scheme on my own -- I'll just
> > keep hammering away at it periodically because I'm stubborn.  C --
> > okay, as long as I stay away from pointers to pointers to pointers,
> > I'm pretty good.  Python -- the unclimbed mountain upon 
> whose slopes I
> > presently sun myself.  And, well, ... ah ... I just started 
> a class in
> > *cough*java*cough* this week.  Oh Lord! It's just so I can learn OOP
> > -- honest! 'Struth!
>  
> 
> 


From Eugene.Leitl@lrz.uni-muenchen.de  Thu Jun 28 12:02:50 2001
From: Eugene.Leitl@lrz.uni-muenchen.de (Eugene Leitl)
Date: Thu, 28 Jun 2001 13:02:50 +0200 (MET DST)
Subject: [Tutor] General Programming Question
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D874@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.SOL.4.33.0106281301160.13134-100000@sun1.lrz-muenchen.de>

On Thu, 28 Jun 2001 alan.gauld@bt.com wrote:

> Recursion is all - other loop constructs are not mentioned.

Recursion doesn't necessarily have to be expensive, if not resulting in
excessive stack frame allocation (the evils of C strike here). Also, tail
recursion (the thing SICP usually does) is usually compiled into a simple
jump.

-- Eugen* Leitl <a href="http://www.lrz.de/~ui22204/">leitl</a>
______________________________________________________________
ICBMTO  : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204
57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3



From alan.gauld@bt.com  Thu Jun 28 12:03:29 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 12:03:29 +0100
Subject: [Tutor] GUI die when execute sys.exit()
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D876@mbtlipnt02.btlabs.bt.co.uk>

> When I run it and click the button, the gui die and I got the 
> following message:
> 
>  >>> Unhandled exception while debugging...
> Traceback (most recent call last):
>    File "C:\PP2ndEd\Examples\PP2E\Gui\Intro\gui3c.py", line 9, in quit
>      import sys; sys.exit()              # retains the self+quit pair
> SystemExit
> 
> I am using Pythonwin IDE from ActiveStates and windows 2000. 

ISTR thats correct behaviour from Pythonwin - it catches SystemExit 
errors so that the IDE doesn't shut down, just the program you are 
running. If you run your script from a Command window(aka DOS box) it 
should work just fine.

Alan G


From alan.gauld@bt.com  Thu Jun 28 12:01:31 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 12:01:31 +0100
Subject: [Tutor] Text to GUI with Tkinter
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D875@mbtlipnt02.btlabs.bt.co.uk>

> Does anybody have any general suggestions for taking a 
> (somewhat) complete text based program and translating it to a 
> Tkinter GUI?  Is there a procedure or process that makes this a 
> simpler task then it appears on the surface?  What steps have you 
> taken to do this?  Should I have been planning to GUIfy the 
> program from the beginning, and now I'm essentially going to have 
> to rewrite the program?  I'm just looking for some broad ideas.

I have an example of doing this on my web tutor(the Case Study) and
also in my book (both Case Studies).

Its one of the things Tkinter ius best suited to IMHO.

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


From bren@europe.nl.com  Thu Jun 28 12:52:47 2001
From: bren@europe.nl.com (Brendon)
Date: Thu, 28 Jun 2001 13:52:47 +0200
Subject: [Tutor] a little OT
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D876@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D876@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <0106281352470E.20991@yatsu>

Though i'd try asking here because perhaps other people use this app aswell.

when trying to run pybber on debian unstable i get the following error:

Traceback (innermost last):
  File "/usr/local/bin/pybberrun.py", line 5, in ?
    import pybber
  File "/usr/lib/python1.5/site-packages/pybber.py", line 11, in ?
    import PyRecode
ImportError: /usr/lib/python1.5/site-packages/PyRecodemodule.so: undefined 
symbol: list_all_charsets

as always i have no clue what's going wrong here. has anyone else run into 
this?


Brendon


From arcege@speakeasy.net  Thu Jun 28 12:58:24 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Thu, 28 Jun 2001 07:58:24 -0400 (EDT)
Subject: [Tutor] Creating Table using Tkinter
In-Reply-To: <37f401c0fee1$27425850$c6ef87c0@dpatwapc> from "Daxesh Patwa" at Jun 27, 2001 01:44:14 PM
Message-ID: <200106281158.f5SBwOG08236@dsl092-074-184.bos1.dsl.speakeasy.net>

Daxesh Patwa wrote
> Any help on how to creat a table using Tkinter.
> 
> My problem :
> 
> I am developing a GUI, using Tkinter. I want to display differnet =
> choices in a list box,which user can scroll in to and choose one of the =
> displayed list.
> 
> But as I know I can display only one choice per row of the list and I =
> cant have multiple elements on the same row.
> 
> If I can create table with more then one column, I may be able to =
> display all these columns.(That is what I am guessing)
> 
> Any other work around or pointer for this problem will be quite helpful.

The scrolling is the difficult part.  A Frame widget is not scrollable,
and for the most part, scrolling works with a single widget.  But you
can get it to work.

One suggestion (sorry that I can't really put up tested code, not really
feeling well) would be to get a list of listbox objects, create a callback
for Scrollbar that distributes the scrolling across the list.

I did this once, but can't find the code unfortunately.  I seem to
remember that it didn't really work well.

If you are attempting to make a clickable table, then you might think
about using the Text widget and tag_bind, with a fixed font (like
Courier).

Good luck,
  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From alan.gauld@bt.com  Thu Jun 28 13:50:02 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 13:50:02 +0100
Subject: [Tutor] General Programming Question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D878@mbtlipnt02.btlabs.bt.co.uk>

> On Thu, 28 Jun 2001 alan.gauld@bt.com wrote:
> 
> > Recursion is all - other loop constructs are not mentioned.

So that message did go out - it dissappeared while I was typing, 
presumably I found the hot key for Send...

> Recursion doesn't necessarily have to be expensive, 

Its not about expense per se its about flexibility of program 
construction. There are many different loop constructs, some of 
which can be replicated using recursion(while, for, etc) but others 
are much harder(*) - and very much more obscure when done via 
recursion.

Other things that spring to minfd as "nails" are data structures 
where in the "Structure" book everything has to be reduced to 
pairs because thats the only data structure we have!

OTOH the books coverage of OO vv stream based programming is 
very good and the obligatory Lisp example of implementing the 
Lisp engine in Lisp is better explained than in many other texts.

I just think it tends to take a very singular view of programming.

Alan g.

(*) Of course some of the harder ones should perhaps be 
discouraged anyway...multi exit paths and multi decision 
points for example.


From pboennec@capgemini.fr  Thu Jun 28 15:42:58 2001
From: pboennec@capgemini.fr (Pascal Boennec)
Date: Thu, 28 Jun 2001 16:42:58 +0200
Subject: [Tutor] Help on Ptyhon graphic environment installation
Message-ID: <GFNA7M$INtOaR7oO7uqGS2KblsJ0BrYyFC1jJSg_Z@capgemini.fr>

Hi !
I've just downloaded Python 2.1 under win95.
At the moment I've only used the DOS window (>>> prompt) to test 
the basic commands.
I'd like now to install a "better" developpment environement 
(graphic one), but I don't know whet are the mandatory steps to 
perform it ! 
I believed that downloding Python 2.1 and install it was enough.
But it doesn't seem to be so easy (python.exe for example doesn't 
react to a mouse double-click...)

My email for your answer
pboennec@capgemini.fr

Thanks very much for your help !
Pascal



From jason@oppel.net  Thu Jun 28 16:00:19 2001
From: jason@oppel.net (Jason Oppel)
Date: Thu, 28 Jun 2001 11:00:19 -0400 (EDT)
Subject: [Tutor] When to Chop Suey...
Message-ID: <Pine.LNX.4.33.0106281054100.2719-100000@smtp.triadinternetsystems.com>

Greetings all!  I'm a Python newb and I've been lurking on this list for
about two weeks now and I'm really excited about all the great advice
that's being given out here.  Thanks to all who take the time to provide
answers to those of us wandering in the programming wilderness!

I am writing a med sized program and I'm wondering if anyone has advice on
when to chop off a bunch of classes from my main module and put it in
another one?  Are there any general guide lines that I could be keeping in
mind when coding about when I should start seperating code into their own
modules?  Any replies are greatly appreciated!

-Jason <Pato>

========================================================================
The fates lead the willing, and drag the unwilling.  --Seneca



From jason@oppel.net  Thu Jun 28 16:06:41 2001
From: jason@oppel.net (Jason Oppel)
Date: Thu, 28 Jun 2001 11:06:41 -0400 (EDT)
Subject: [Tutor] Help on Ptyhon graphic environment installation
In-Reply-To: <GFNA7M$INtOaR7oO7uqGS2KblsJ0BrYyFC1jJSg_Z@capgemini.fr>
Message-ID: <Pine.LNX.4.33.0106281101390.2719-100000@smtp.triadinternetsystems.com>

Actually you already have a quite nice graphical IDE which you got bundled
with Python 2.1 called IDLE.  It should be in your 'Python 2.1' folder
(unless you called it something else when it was installing).  IDLE starts
up at the old familiar python shell but yor can create new modules, open
existing ones etc.  IDLE has some nice features like syntax highlighting
and auto-indentation.  Play around with it a bit!  Danny Yoo recently
wrote an introduction to Python using IDLE at:

http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/

It should give you a good start!

-Jason <Pato>

On Thu, 28 Jun 2001, Pascal Boennec wrote:

> Hi !
> I've just downloaded Python 2.1 under win95.
> At the moment I've only used the DOS window (>>> prompt) to test
> the basic commands.
> I'd like now to install a "better" developpment environement
> (graphic one), but I don't know whet are the mandatory steps to
> perform it !
> I believed that downloding Python 2.1 and install it was enough.
> But it doesn't seem to be so easy (python.exe for example doesn't
> react to a mouse double-click...)
>
> My email for your answer
> pboennec@capgemini.fr
>
> Thanks very much for your help !
> Pascal
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>

========================================================================
The fates lead the willing, and drag the unwilling.  --Seneca



From pobrien@orbtech.com  Thu Jun 28 15:58:36 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 28 Jun 2001 09:58:36 -0500
Subject: [Tutor] Help on Ptyhon graphic environment installation
In-Reply-To: <GFNA7M$INtOaR7oO7uqGS2KblsJ0BrYyFC1jJSg_Z@capgemini.fr>
Message-ID: <NBBBIOJPGKJEKIECEMCBMEANKCAA.pobrien@orbtech.com>

IDLE is what you should try next. The installer should have added a menu
choice to your Start menu. There is a good introduction to IDLE at
http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Pascal Boennec
Sent: Thursday, June 28, 2001 9:43 AM
To: tutor@python.org
Cc: pboennec@capgemini.fr
Subject: [Tutor] Help on Ptyhon graphic environment installation

Hi !
I've just downloaded Python 2.1 under win95.
At the moment I've only used the DOS window (>>> prompt) to test
the basic commands.
I'd like now to install a "better" developpment environement
(graphic one), but I don't know whet are the mandatory steps to
perform it !
I believed that downloding Python 2.1 and install it was enough.
But it doesn't seem to be so easy (python.exe for example doesn't
react to a mouse double-click...)

My email for your answer
pboennec@capgemini.fr

Thanks very much for your help !
Pascal


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From karimy@nipltd.com  Thu Jun 28 16:01:51 2001
From: karimy@nipltd.com (Karim Yaici)
Date: Thu, 28 Jun 2001 16:01:51 +0100
Subject: [Tutor] Help on Ptyhon graphic environment installation
References: <GFNA7M$INtOaR7oO7uqGS2KblsJ0BrYyFC1jJSg_Z@capgemini.fr>
Message-ID: <018401c0ffe3$436c3d40$a5020a0a@private.nipltd.com>

Hi Pascal,

>I'd like now to install a "better" developpment environement
>(graphic one), but I don't know whet are the mandatory steps to
>perform it !

I think that IDLE is quite good IDE for Python, but if you want a more
Windows look-and-feel application then you can try PythonWin. It come with
an IDE and Python COM extensions (COM is basically a framwork to program
under the Windoze environment)

oh yes...here is the link for download
http://aspn.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all

Bon courage,

Karim



From pobrien@orbtech.com  Thu Jun 28 16:08:17 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 28 Jun 2001 10:08:17 -0500
Subject: [Tutor] When to Chop Suey...
In-Reply-To: <Pine.LNX.4.33.0106281054100.2719-100000@smtp.triadinternetsystems.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBGEAPKCAA.pobrien@orbtech.com>

1. Python makes this easy, so do it whenever it feels right.
2. Do it if a class is useful to more than one application or module.
3. Look at all the souce code that comes with Python as a guide.
4. Look at the source code to IDLE as an example app written by the BDFL
himself.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Jason Oppel
Sent: Thursday, June 28, 2001 10:00 AM
To: tutor@python.org
Subject: [Tutor] When to Chop Suey...

Greetings all!  I'm a Python newb and I've been lurking on this list for
about two weeks now and I'm really excited about all the great advice
that's being given out here.  Thanks to all who take the time to provide
answers to those of us wandering in the programming wilderness!

I am writing a med sized program and I'm wondering if anyone has advice on
when to chop off a bunch of classes from my main module and put it in
another one?  Are there any general guide lines that I could be keeping in
mind when coding about when I should start seperating code into their own
modules?  Any replies are greatly appreciated!

-Jason <Pato>

========================================================================
The fates lead the willing, and drag the unwilling.  --Seneca


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From deirdre@deirdre.net  Thu Jun 28 16:21:40 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Thu, 28 Jun 2001 08:21:40 -0700
Subject: [Tutor] When to Chop Suey...
In-Reply-To: <Pine.LNX.4.33.0106281054100.2719-100000@smtp.triadinternetsystems.com>
References: <Pine.LNX.4.33.0106281054100.2719-100000@smtp.triadinternetsystems.com>
Message-ID: <a0510101ab760fb21120a@[10.20.0.138]>

>I am writing a med sized program and I'm wondering if anyone has advice on
>when to chop off a bunch of classes from my main module and put it in
>another one?  Are there any general guide lines that I could be keeping in
>mind when coding about when I should start seperating code into their own
>modules?  Any replies are greatly appreciated!

Actually, I usually start my project with them separate. Very old 
coder habit I suspect.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From bren@europe.nl.com  Thu Jun 28 16:25:27 2001
From: bren@europe.nl.com (Brendon)
Date: Thu, 28 Jun 2001 17:25:27 +0200
Subject: [Tutor] Python 1.5 or 2.01?
Message-ID: <01062817252700.20361@yatsu>

Is there a great difference between the two?

I quickly checked the python.org website but couldn't find a comparison. 


Brendon


From pobrien@orbtech.com  Thu Jun 28 16:32:36 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 28 Jun 2001 10:32:36 -0500
Subject: [Tutor] Python 1.5 or 2.01?
In-Reply-To: <01062817252700.20361@yatsu>
Message-ID: <NBBBIOJPGKJEKIECEMCBCEBAKCAA.pobrien@orbtech.com>

Unless you have a compelling reason not to, I would suggest you use the
latest version - 2.1. Unlike others, the python folks do not release buggy
crap. There are feature comparisons out there but I don't have any links at
hand.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Brendon
Sent: Thursday, June 28, 2001 10:25 AM
To: tutor@python.org
Subject: [Tutor] Python 1.5 or 2.01?

Is there a great difference between the two?

I quickly checked the python.org website but couldn't find a comparison.


Brendon

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From SBrunning@trisystems.co.uk  Thu Jun 28 16:30:27 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Thu, 28 Jun 2001 16:30:27 +0100
Subject: [Tutor] Python 1.5 or 2.01?
Message-ID: <31575A892FF6D1118F5800600846864D78BDD8@intrepid>

> From:	Brendon [SMTP:bren@europe.nl.com]
> Is there a great difference between the two?
> 
> I quickly checked the python.org website but couldn't find a comparison. 
 
2.0.1 is just a bugfix of 2.0 - see here
<http://www.python.org/2.0/new-python.html> for a summary of new stuff in
2.0.

But I'd go for 2.1 myself. See here <http://www.amk.ca/python/2.1/> for
details of what's new in 2.1. There isn't a bugfix for 2.1, yet, but I
haven't had any problems with it myself. YMMV.

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 scarblac@pino.selwerd.nl  Thu Jun 28 16:34:01 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 28 Jun 2001 17:34:01 +0200
Subject: [Tutor] Python 1.5 or 2.01?
In-Reply-To: <01062817252700.20361@yatsu>; from bren@europe.nl.com on Thu, Jun 28, 2001 at 05:25:27PM +0200
References: <01062817252700.20361@yatsu>
Message-ID: <20010628173401.A29223@pino.selwerd.nl>

On  0, Brendon <bren@europe.nl.com> wrote:
> Is there a great difference between the two?
> 
> I quickly checked the python.org website but couldn't find a comparison. 

You should get 2.1, that is the newest. 2.0.1 is a bugfix release of 2.0.
1.5.2 is two years old.

See the "what's new" lists of:

1.6   http://www.python.org/1.6
     Mostly Unicode, string methods, new regular expression engine,
     f(*arg, **kwarg) syntax, new modules
2.0   http://www.python.org/2.0/new-python.html
     Lots. List comprehensions, augmented assignment, garbage collection,
     print >>, more XML support, more new modules, etc
2.1   www.amk.ca seems to be down, so
     http://www.google.com/search?q=cache:0S9hRbIy5o4:www.amk.ca/python/2.1/+new+in+python+2.1
     Nested scopes (if you use a directive; will be standard in 2.2), weak
     references, warnings, new and improved modules
     
Taken together, a *lot* has happened in the last two years :-)

-- 
Remco Gerlich


From alan.gauld@bt.com  Thu Jun 28 16:23:40 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 16:23:40 +0100
Subject: [Tutor] Search and Replace
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D87B@mbtlipnt02.btlabs.bt.co.uk>

>                 if changed:
>                         print 'Updating :', filename
>                         f = open(filename, 'w')
>                         f.writelines(new_lines)
> 
> This, once again, truncates the file and then writes it out.  I am 
> worried about possible data loss;  

The normal way to deal with this is to create a backup copy of the 
original file then write the new one to a temporary file, then if 
successful delete the original, rename the temporary to the original 
and then only if all that works delete the backup. Thats pretty 
bulletproof if you are worried about data loss.

Alan G.


From alan.gauld@bt.com  Thu Jun 28 16:54:59 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 16:54:59 +0100
Subject: [Tutor] Newbie problems
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D87D@mbtlipnt02.btlabs.bt.co.uk>

> I'm trying to learn Python but when using one of the examples on 
> http://www.crosswinds.net/~agauld/ i get an error.

I guess I'd better have a go then?!

> >>>class Address:
> ...   def __init__(self, Hs, St, Town, Zip):
> ...     self.HsNumber = Hs
> ...     self.Street = St
> ...     self.Town = Town
> ...     self.ZipCode = Zip
> 
> Addr = Address(7,"High St","Anytown","123 456")
> 
> 
> which gives the following error:

Have you checked the special section(in yellow) at the end 
of the raw materials chapter which explains this example 
line by line?

The usual errors made here are using single underscores for 
__init__ or not observing the indentation levels closely enough.
>From your posted code it looks like you've avoided those mistakes 
the only concern I have is that I'd expect to see the python 
prompt >>> in front of the Addr = ... line. Otherwise it looks OK
and should work.

Alan G


From alan.gauld@bt.com  Thu Jun 28 16:48:52 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 16:48:52 +0100
Subject: [Tutor] Python 101 at devshed.com confusion
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D87C@mbtlipnt02.btlabs.bt.co.uk>

> It makes perfect sense to me when using the len() function 
> that I get a response that there are 9 characters in the string, but when 
> I count through, starting at 0 for the first character, I only come up
with 
> eight for the last character too, just like the interpreter did.  

Thats right the index runs from 0 to len()-1

> So how come the first example, indexing [3:9] works?

Because you are not using *indexing* you are using *slicing*.
A slice [min:max] runs from min to max-1.

This is explained in more detail in the python tutor in section 
"3.1.2 Strings" (Python 2.0 tutor)


Alan g


From alan.gauld@bt.com  Thu Jun 28 17:02:01 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 17:02:01 +0100
Subject: [Tutor] General Programming Question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D87E@mbtlipnt02.btlabs.bt.co.uk>

> > For learning scheme, you might consider the book:
> > 
> > "Structure and Interpretationof Computer Programs" by Harold 
> > Abelson, Gerald Jay Sussman and Julie Sussman.
> 
> Having just finished it I'll second the motion. Its a very good 
> book that anyone intertested on programming should read. However 
> it does tend to suffer(like many Lisp books) from the "When all 
> you have is a hammer, every problem looks like a nail" approach 
> to life. Recursion is all - other loop constructs are not mentioned.

Having sent this prematurely due to finger trouble I'll add the line 
I meant to type:

> to life. Recursion is all - other loop constructs are not mentioned.

Despite the fact that Lisp does support other more conventional 
loop contructs.

sorry,

Alan G.

PS Does anyone know the hot key for Send in Outlook?
I'd like to disable it coz I've been bitten by this several 
times (coz I'm a fast and careless 2 fingered typist!).


From alan.gauld@bt.com  Thu Jun 28 17:09:17 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 28 Jun 2001 17:09:17 +0100
Subject: [Tutor] When to Chop Suey...
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D87F@mbtlipnt02.btlabs.bt.co.uk>

> I am writing a med sized program and I'm wondering if anyone 
> has advice on when to chop off a bunch of classes from my 
> main module and put it in another one?  

Generally I always put class definitions in separate modules to 
the main program. That way I can reuse the classes and the main 
program just creates some objects and uses them.

As to how many classes per module I suggest that mutually dependant 
classes go in the same module - thus if you can't create an A without 
also having to create a B keep A and B together. As somebody famous 
said (Robert Martin?) "the unit of reuse is the category" which is a 
reference to the old Booch notation for a group of classes that work 
together. Categories in Booch translate to modules in Python.

Alan G


From MLange@atmedicausa.com  Thu Jun 28 17:22:36 2001
From: MLange@atmedicausa.com (Mike Lange)
Date: Thu, 28 Jun 2001 10:22:36 -0600
Subject: [Tutor] re: Python IVR work?
Message-ID: <OF8BF71926.4D322C10-ON87256A79.0059CDEE@atmedicausa.com>

This is a multipart message in MIME format.
--=_alternative 005A78F287256A79_=
Content-Type: text/plain; charset="us-ascii"

Does anyone know of a module or any work out there using Python to 
implement IVR (Interactive Voice Response or something along those lines) 
?

Thanks,



Mike Lange
Atmedica USA LLC.
mlange@atmedicausa.com
Phone:   801-517-6944
Fax:        801-517-6990

"What's in your hands, I think and hope, is intelligence: the ability to 
see the machine as more than when you were first led up to it, that you 
can make it more."
-Alan J. Perlis
--=_alternative 005A78F287256A79_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">Does anyone know of a module or any work out there using Python to implement IVR (Interactive Voice Response or something along those lines) ?</font>
<br>
<br><font size=2 face="sans-serif">Thanks,</font>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">Mike Lange<br>
Atmedica USA LLC.<br>
mlange@atmedicausa.com<br>
Phone: &nbsp; 801-517-6944<br>
Fax: &nbsp; &nbsp; &nbsp; &nbsp;801-517-6990<br>
<br>
&quot;What's in your hands, I think and hope, is intelligence: the ability to see the machine as more than when you were first led up to it, that you can make it more.&quot;<br>
-Alan J. Perlis</font>
--=_alternative 005A78F287256A79_=--


From michael@trollope.org  Thu Jun 28 17:53:07 2001
From: michael@trollope.org (Michael Powe)
Date: Thu, 28 Jun 2001 09:53:07 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D878@mbtlipnt02.btlabs.bt.co.uk>
 (alan.gauld@bt.com)
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D878@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <200106281653.f5SGr7301289@cecilia.trollope.org>

>>>>> "alan" == alan gauld <alan.gauld@bt.com> writes:

    >> On Thu, 28 Jun 2001 alan.gauld@bt.com wrote:
    >> 
    >> > Recursion is all - other loop constructs are not mentioned.

    alan> So that message did go out - it dissappeared while I was
    alan> typing, presumably I found the hot key for Send...

    >> Recursion doesn't necessarily have to be expensive,

    alan> Its not about expense per se its about flexibility of
    alan> program construction. There are many different loop
    alan> constructs, some of which can be replicated using
    alan> recursion(while, for, etc) but others are much harder(*) -
    alan> and very much more obscure when done via recursion.

I think this misses the point.  Recursion is not a 'looping
construct,' although it can be used that way.  It is a design
paradigm.  The dialect of Lisp used in SCIP is Scheme.  Scheme is
defined as, "...a statically scoped and properly tail-recursive
dialect of the Lisp programming language ... "  

To continue quoting from the Scheme home page: "It was designed to
have an exceptionally clear and simple semantics and few different
ways to form expressions. A wide variety of programming paradigms,
including imperative, functional, and message passing styles, find
convenient expression in Scheme."  I think that pretty well covers it.

    alan> Other things that spring to minfd as "nails" are data
    alan> structures where in the "Structure" book everything has to
    alan> be reduced to pairs because thats the only data structure we
    alan> have!

    alan> OTOH the books coverage of OO vv stream based programming is
    alan> very good and the obligatory Lisp example of implementing
    alan> the Lisp engine in Lisp is better explained than in many
    alan> other texts.

    alan> I just think it tends to take a very singular view of
    alan> programming.

However, this is like criticizing a dog for having four legs and not
walking on only two.  Take a look at some of the peculiarities of
Python.  There must be a reason (whether a good one or no) why there's
no increment operator.  I take it that in python, it is a design
paradigm that you do not increment through loops.  No switch
statement, either.  Again, it's a part of the python paradigm that you
do not design programs that use those kinds of constructs.  From my
point of view (coming from C), that's a limitation.  I doubt
'pythonistas' would agree with me.

Every language requires you to adopt its paradigm.  Is SmallTalk
defective because it's purely OO?  I'd be the first to champion C
because you do everything in it.  Everybody knows what torture it is
to do string parsing in C.  You CAN do it, though.  ... uh-oh, I feel
... oh, no, I can't resist -- "There's more than one way to do it."
Aaaahhhhh!

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From dsh8290@rit.edu  Thu Jun 28 18:04:39 2001
From: dsh8290@rit.edu (D-Man)
Date: Thu, 28 Jun 2001 13:04:39 -0400
Subject: [Tutor] Re: GUI die when execute sys.exit() (D-Man)
In-Reply-To: <036b01c0ffa8$50b67fa0$0200a8c0@ACE>; from wheelege@tsn.cc on Thu, Jun 28, 2001 at 05:59:53PM +1000
References: <E15FM4Z-0005g3-00@mail.python.org> <5.1.0.14.0.20010627160301.00afae58@mail.ydyn.com.criticalpath.net> <20010627192916.A17497@harmony.cs.rit.edu> <036b01c0ffa8$50b67fa0$0200a8c0@ACE>
Message-ID: <20010628130439.A19498@harmony.cs.rit.edu>

On Thu, Jun 28, 2001 at 05:59:53PM +1000, Glen Wheeler wrote:
| > On Wed, Jun 27, 2001 at 04:14:40PM -0500, Peter He wrote:
| > |
| > | I used 'GUI die' in my last question. What I actually meant is
| > | that the GUI freezes. GUI is still there but you can't close it
| > | and no response when you click the buttons on it. So I have to
| > | restart Python to get rid of it.
| >
| > The question is "which gui?" -- is it your gui (that you made with the
| > sample code) or the PythonWin gui?  In either case, PythonWin and IDLE
| > and other IDEs don't work with GUI apps.  Just use python directly
| > from the command line (DOS shell).
| 
|   I believe that PythonWin works fine with tkinter apps - at least it has
| with every tkinter app I've written.  Something to do with the fact that it
| is not written in tcl/tk itself, unlike IDLE.

Oh.  Ok.  I have never used either IDE (my preference is vim+bash, but
that is beside the point).  I have half-listened to some discussions
wrt IDEs on python-list though.

-D



From rhseabrook@mail.aacc.cc.md.us  Thu Jun 28 15:17:06 2001
From: rhseabrook@mail.aacc.cc.md.us (Seabrook, Richard)
Date: Thu, 28 Jun 2001 13:17:06 -0100
Subject: [Tutor] Language truce
Message-ID: <5.1.0.14.0.20010628131423.00a71950@pop.starpower.net>

Folks, let's stop the language war now before it gets further.
Scheme has its place.  Python has its place.  This is a great list for 
helping beginning Python users and instructors.  I hope it continues.
Dick S.


-
Dick Seabrook ~ Computer Science ~ Information Systems ~ Programming
URL: enterprise.aacc.cc.md.us/~rhs _   rhseabrook@mail.aacc.cc.md.us
Anne Arundel Community College   //:-)                Speed the 
Net!



From michael@trollope.org  Thu Jun 28 18:28:57 2001
From: michael@trollope.org (Michael Powe)
Date: Thu, 28 Jun 2001 10:28:57 -0700
Subject: [Tutor] Language truce
In-Reply-To: <5.1.0.14.0.20010628131423.00a71950@pop.starpower.net>
 (rhseabrook@mail.aacc.cc.md.us)
References: <5.1.0.14.0.20010628131423.00a71950@pop.starpower.net>
Message-ID: <200106281728.f5SHSvI01357@cecilia.trollope.org>

>>>>> "Seabrook," == Seabrook, Richard <rhseabrook@mail.aacc.cc.md.us> writes:

    Seabrook,> Folks, let's stop the language war now before it gets
    Seabrook,> further.  Scheme has its place.  Python has its place.
    Seabrook,> This is a great list for helping beginning Python users
    Seabrook,> and instructors.  I hope it continues.  Dick S.

Huh?  Where's the 'war'?  If I wrote something offensive, it was
certainly unintentionally.  Geez, I even made a joke at the end!  And,
I'm waiting for someone to take up the challenge re: the python
paradigm.  I think that's an important issue and should not just be
brushed aside.

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From israel@lith.com  Thu Jun 28 18:47:06 2001
From: israel@lith.com (Israel Evans)
Date: Thu, 28 Jun 2001 10:47:06 -0700
Subject: [Tutor] Language truce
Message-ID: <AF020C5FC551DD43A4958A679EA16A15A144FB@mailcluster.lith.com>

What exactly IS the Python Programming Paradigm---(PPP)  :)   ???

Everything is Beautiful and Easy.

Strolling Leisurely towards Nirvana?




From michael@trollope.org  Thu Jun 28 19:04:43 2001
From: michael@trollope.org (Michael Powe)
Date: Thu, 28 Jun 2001 11:04:43 -0700
Subject: [Tutor] Language truce
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15A144FB@mailcluster.lith.com>
 (message from Israel Evans on Thu, 28 Jun 2001 10:47:06 -0700)
References: <AF020C5FC551DD43A4958A679EA16A15A144FB@mailcluster.lith.com>
Message-ID: <200106281804.f5SI4hr01395@cecilia.trollope.org>

>>>>> "Israel" == Israel Evans <israel@lith.com> writes:

    Israel> What exactly IS the Python Programming Paradigm---(PPP) :)
    Israel> ???

    Israel> Everything is Beautiful and Easy.

    Israel> Strolling Leisurely towards Nirvana?

Would that it were so.  

A couple things I mentioned, like you can't increment through loops.
But, also, it occurs to me that another part of the paradigm appears
to be that you can't create new data types, aka structs in C.

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From dyoo@hkn.eecs.berkeley.edu  Thu Jun 28 19:49:03 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 28 Jun 2001 11:49:03 -0700 (PDT)
Subject: [Tutor] Language truce
In-Reply-To: <200106281804.f5SI4hr01395@cecilia.trollope.org>
Message-ID: <Pine.LNX.4.21.0106281127530.9400-100000@hkn.eecs.berkeley.edu>

On Thu, 28 Jun 2001, Michael Powe wrote:

> >>>>> "Israel" == Israel Evans <israel@lith.com> writes:
> 
>     Israel> What exactly IS the Python Programming Paradigm---(PPP) :)
>     Israel> ???

Tim Peters has written on "The Python Way", which, tongue-in-cheek, tries
to capture the spirit of Python:

###
    Beautiful is better than ugly. 

    Explicit is better than implicit. 

    Simple is better than complex. 

    Complex is better than complicated. 

    Flat is better than nested. 

    Sparse is better than dense. 

    Readability counts. 

    Special cases aren't special enough to break the rules. 

    Although practicality beats purity. 

    Errors should never pass silently. 

    Unless explicitly silenced. 

    In the face of ambiguity, refuse the temptation to guess. 

    There should be one -- and preferably only one -- obvious way to do
it.
###



> A couple things I mentioned, like you can't increment through loops.

I'm a little confused by what you mean by "incrementing through loops".  
Can you give an example of what you mean?



> But, also, it occurs to me that another part of the paradigm appears
> to be that you can't create new data types, aka structs in C.

We can make new data types work in by using classes.  For example, if we
want to make a Balloon class that has a shape and color, we can do the
following:

###
class Balloon:
    def __init__(self, shape, color):
        self.shape, self.color = shape, color
###


Afterwards, we can treat it as a regular structure:

###
myballoon = Balloon('airplane', 'blue')
print myballoon.color, 'is the color of my balloon.'
balloon_bag = [ Balloon('heart', 'red'),
                Balloon('robot', 'silver'),
                Balloon('blimp', 'black') ]
###

To give our data type interesting behavior, we can tell Python about more
operations.  If we wanted to "add" two balloons together (although I have
NO idea what that would mean... I guess it would be like tying them
together), we could add something to the Balloon definition:


###
class Balloon:
    def __init__(self, shape, color):
        self.shape, self.color = shape, color
    def __add__(self, other):
        return Balloon('%s tied with %s' % (self.shape, other.shape),
                       '%s-%s' % (self.color, other.color))
###

Let's see what happens:


###
>>> b1 = Balloon('tree', 'red')
>>> b2 = Balloon('bear', 'gold')
>>> b1 + b2
<__main__.Balloon instance at 80ccd30>
>>> b3 = b1 + b2
>>> print b3.shape
tree tied with bear
>>> print b3.color
red-gold
###

I'm just clowning around here.  *grin*


Hope this helps!



From dsh8290@rit.edu  Thu Jun 28 19:53:53 2001
From: dsh8290@rit.edu (D-Man)
Date: Thu, 28 Jun 2001 14:53:53 -0400
Subject: [Tutor] Language truce
In-Reply-To: <200106281804.f5SI4hr01395@cecilia.trollope.org>; from michael@trollope.org on Thu, Jun 28, 2001 at 11:04:43AM -0700
References: <AF020C5FC551DD43A4958A679EA16A15A144FB@mailcluster.lith.com> <200106281804.f5SI4hr01395@cecilia.trollope.org>
Message-ID: <20010628145353.C19571@harmony.cs.rit.edu>

On Thu, Jun 28, 2001 at 11:04:43AM -0700, Michael Powe wrote:
| >>>>> "Israel" == Israel Evans <israel@lith.com> writes:
| 
|     Israel> What exactly IS the Python Programming Paradigm---(PPP) :)
|     Israel> ???
| 
|     Israel> Everything is Beautiful and Easy.
| 
|     Israel> Strolling Leisurely towards Nirvana?
| 
| Would that it were so.  
| 
| A couple things I mentioned, like you can't increment through loops.

There are 2 answers to this :

1)  you can,  ex

    i = 0
    while i < 10 :
        print i
        i += 1  # increment!!

2)  you don't need to, ex

    for i in range( 10 ) :
        print i

I really like the latter because i don't need to explain how to
iterate a certain number of time, it just works.

| But, also, it occurs to me that another part of the paradigm appears
| to be that you can't create new data types, aka structs in C.

Actually you can create as many data types as you want, and they are
better than structs in C.  Structs in C only hold _data_ together, no
operations.  The 'class' construct in Python allows you to define a
new data type that has both data and operations that can be performed
on the data.

See 
    http://www.python.org/doc/current/tut/node11.html
and
    http://www.crosswinds.net/~agauld/tutclass.htm
for more information.  Then feel free to ask any questions you have
regarding classes and OOP :-).

-D



From bren@europe.nl.com  Thu Jun 28 20:09:14 2001
From: bren@europe.nl.com (Brendon)
Date: Thu, 28 Jun 2001 21:09:14 +0200
Subject: [Tutor] more newbie questions: variables without a value
Message-ID: <01062821091400.26891@yatsu>

in the following code..
----
#!/usr/bin/python

class Message:
	def __init__(self, aString):
		self.text = aString
	def printIt(self):
		print self.text
		
m1 = Message("Hello World")
m2 = Message("So long, it was short bu sweet.")

note = [m1, m2]
for msg in note:
	msg.printIt()
----

the variable 'msg' was never given a value, yet msg.printIt() displays the 
list note. how is this?

the line: "for msg in note:" doesn't seem to make sense because "msg" has no 
value nor is it pointing to "note".


Brendon


From bsass@freenet.edmonton.ab.ca  Thu Jun 28 20:13:27 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Thu, 28 Jun 2001 13:13:27 -0600 (MDT)
Subject: [Tutor] Python 101 at devshed.com confusion
In-Reply-To: <01062801544500.02181@ci.nodomain.net>
Message-ID: <Pine.LNX.4.33.0106281300320.11263-100000@bms>

On Thu, 28 Jun 2001, Sak wrote:
<...>
> At the beginning of the example, I'm told that the index of a string begins
> with 0 at the first character.  Where I get confused is right away when I
> extract a substring...
>
> >>> str = "hobgoblin"
> >>> str[3:9]
> 'goblin'
> >>>

ya got lotsa answers, but I think this is the most succinct way to
explain it...

given sequence: abcd

indexed:
         a   b   c   d
         |   |   |   |
         0   1   2   3
        -4  -3  -2  -1

sliced:
         a   b   c   d
       |   |   |   |   |
       0   1   2   3   4
      -4  -3  -2  -1

where a missing slice point defaults to just past the end, or just
before the beginning of the sequence.
i.e., "abcd"[-1:] == 'd' and "abcd"[:1] == 'a'


- Bruce



From seedseven@home.nl  Thu Jun 28 19:59:15 2001
From: seedseven@home.nl (Ingo)
Date: Thu, 28 Jun 2001 20:59:15 +0200
Subject: [Tutor] parsing?
Message-ID: <MWMail.fgohjmia@host.none>

I'm tying to make something that can read some values and functions from a file 
and then use these to create a parametric surface in triangles to be rendered 
by POV-Ray. The triangle generation isn't the problem, but reading the 
functions into the program. 

If I have a line read from a textfile that says:

u=2

how do I manage to make a value u=2 available to the program, that read the 
textfile, so it can do some calculations with it? 

The same, but now for a function:

Function Fx(u,v,R)=R*sin(u)*cos(v)

How do I make the above available in the program as if the below was part of it?

def Fx (u,v,R):
    x=R*sin(u)*cos(v)
    return x


TIA,

Ingo

-- 
Photography:  http://members.home.nl/ingoogni/
POV-Ray:  http://members.home.nl/seed7/



From deirdre@deirdre.net  Thu Jun 28 20:13:57 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Thu, 28 Jun 2001 12:13:57 -0700
Subject: [Tutor] Language truce
In-Reply-To: <Pine.LNX.4.21.0106281127530.9400-100000@hkn.eecs.berkeley.edu>
References: <Pine.LNX.4.21.0106281127530.9400-100000@hkn.eecs.berkeley.edu>
Message-ID: <a05101020b761312598f7@[10.20.0.138]>

At 11:49 AM -0700 6/28/01, Danny Yoo wrote:
>  > A couple things I mentioned, like you can't increment through loops.
>
>I'm a little confused by what you mean by "incrementing through loops". 
>Can you give an example of what you mean?


That means incrementing (or decrementing) the loop counter while in 
the loop. From something I'm currently translating from C:

	for (k = 0; k < j9; k++)
		path[k] = getnum("ROOM #") - 1;

		if (k <= 1)
			continue;

		if (path[k] != path[k - 2])
	  		continue;

		print "Arrows aren't that crooked - try another room"
		k--;

In other words, if a set of circumstances occurs, do something weird 
with the counter. This causes a LOT of subtle bugs, which is one 
reason why the range is immutable in Python.

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From deirdre@deirdre.net  Thu Jun 28 20:19:23 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Thu, 28 Jun 2001 12:19:23 -0700
Subject: [Tutor] more newbie questions: variables without a value
In-Reply-To: <01062821091400.26891@yatsu>
References: <01062821091400.26891@yatsu>
Message-ID: <a05101021b761332c12bf@[10.20.0.138]>

At 9:09 PM +0200 6/28/01, Brendon wrote:
>in the following code..
>----
>#!/usr/bin/python
>
>class Message:
>	def __init__(self, aString):
>		self.text = aString
>	def printIt(self):
>		print self.text
>
>m1 = Message("Hello World")
>m2 = Message("So long, it was short bu sweet.")
>
>note = [m1, m2]
>for msg in note:
>	msg.printIt()
>----
>
>the variable 'msg' was never given a value, yet msg.printIt() displays the
>list note. how is this?

It is. msg is declared in the "for msg in note"

Meaning that, for each value of note, set msg equal to that.

>the line: "for msg in note:" doesn't seem to make sense because "msg" has no
>value nor is it pointing to "note".

There's an implied assignment that the first variable is assigned to 
the current value of the second part. Like:

for i in xrange(25, 51, 5):
  print i

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From bren@europe.nl.com  Thu Jun 28 20:33:43 2001
From: bren@europe.nl.com (Brendon)
Date: Thu, 28 Jun 2001 21:33:43 +0200
Subject: [Tutor] more newbie questions: variables without a value
In-Reply-To: <a05101021b761332c12bf@[10.20.0.138]>
References: <01062821091400.26891@yatsu> <a05101021b761332c12bf@[10.20.0.138]>
Message-ID: <01062821334301.26891@yatsu>

On Thursday 28 June 2001 21:19, you wrote:
> At 9:09 PM +0200 6/28/01, Brendon wrote:
> >in the following code..
> >----
> >#!/usr/bin/python
> >
> >class Message:
> >	def __init__(self, aString):
> >		self.text = aString
> >	def printIt(self):
> >		print self.text
> >
> >m1 = Message("Hello World")
> >m2 = Message("So long, it was short bu sweet.")
> >
> >note = [m1, m2]
> >for msg in note:
> >	msg.printIt()
> >----
> >
> >the variable 'msg' was never given a value, yet msg.printIt() displays the
> >list note. how is this?
>
> It is. msg is declared in the "for msg in note"
>
> Meaning that, for each value of note, set msg equal to that.

but.. eh..

> >the line: "for msg in note:" doesn't seem to make sense because "msg" has
> > no value nor is it pointing to "note".
>
> There's an implied assignment that the first variable is assigned to
> the current value of the second part. Like:
>
> for i in xrange(25, 51, 5):
>   print i

oh, ofcourse.. (!..) sorry, i keepon thinking about C loops :)


From deirdre@deirdre.net  Thu Jun 28 20:44:02 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Thu, 28 Jun 2001 12:44:02 -0700
Subject: [Tutor] more newbie questions: variables without a value
In-Reply-To: <01062821334301.26891@yatsu>
References: <01062821091400.26891@yatsu>
 <a05101021b761332c12bf@[10.20.0.138]> <01062821334301.26891@yatsu>
Message-ID: <a05101002b76138e16954@[10.20.0.138]>

At 9:33 PM +0200 6/28/01, Brendon wrote:
>  > >the line: "for msg in note:" doesn't seem to make sense because "msg" has
>>  > no value nor is it pointing to "note".
>>
>>  There's an implied assignment that the first variable is assigned to
>>  the current value of the second part. Like:
>>
>>  for i in xrange(25, 51, 5):
>>    print i
>
>oh, ofcourse.. (!..) sorry, i keepon thinking about C loops :)

In C, the assignment is more explicit:

for (i = 25; i < 51; i++)
  printf("%d\n", i);

Strangely, this is the first time I've thought the C syntax was more 
obvious simply and only because the python syntax confused you.

The "x in foo" construct is also used in SQL, so I'm used to seeing it.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From michael@trollope.org  Thu Jun 28 20:40:31 2001
From: michael@trollope.org (Michael Powe)
Date: Thu, 28 Jun 2001 12:40:31 -0700
Subject: [Tutor] Language truce
In-Reply-To: <Pine.LNX.4.21.0106281127530.9400-100000@hkn.eecs.berkeley.edu>
 (message from Danny Yoo on Thu, 28 Jun 2001 11:49:03 -0700 (PDT))
References: <Pine.LNX.4.21.0106281127530.9400-100000@hkn.eecs.berkeley.edu>
Message-ID: <200106281940.f5SJeV801515@cecilia.trollope.org>

>>>>> "Danny" == Danny Yoo <dyoo@hkn.eecs.berkeley.edu> writes:

    Danny> On Thu, 28 Jun 2001, Michael Powe wrote:

    >> A couple things I mentioned, like you can't increment through
    >> loops.

    Danny> I'm a little confused by what you mean by "incrementing
    Danny> through loops".  Can you give an example of what you mean?

The standard C (for i=0; i < n; i++), which uses the increment
operator (i++) which is not present in python.  I'm sure there must be
some discussion somewhere about why the decision was made to leave
this out, I just have not come across it.

Yes, as someone else points out, you can use range(), but obviously
that is not the same thing. (In some cases, it may be functionally
equivalent and maybe that is the point.)  Also, maybe it's just me,
but I consider

k = k+1

as a loop counter to just be unacceptably clumsy.  Forcing me to use
that construct tells me that I should not be designing my program that
way. 

    >> But, also, it occurs to me that another part of the paradigm
    >> appears to be that you can't create new data types, aka structs
    >> in C.

    Danny> We can make new data types work in by using classes.  For
    Danny> example, if we want to make a Balloon class that has a
    Danny> shape and color, we can do the following:

    Danny> ### class Balloon: def __init__(self, shape, color):
    Danny> self.shape, self.color = shape, color ###

Ah, yes.  I should have realized, we just started going over classes
in my java course last night.  

My 'teach-yourself-python' project is an address book.  I happen to
need one and I don't like anything that's already available.
Unfortunately, the python books just aren't making it as instructional
tools.  I know quite a bit about python syntax &c and practically
nothing about actually writing programs in python.  Anyway, I have the
data entry part and the write-to-file parts completed -- that was
easy.  But, the file-reading and data storage parts are more
interesting.  In C, I would just use a struct and a linked list and
write/read the structs to/from a binary file -- I've done all that
type of stuff before.

I had just about determined to use dictionaries with tuple keys for
reading in the data (even though that seems complicated to me).
Deleting entries from the book becomes an issue, though.  Also,
there's issues with duplicate names.

A class is probably the way to go.  Might be a little while before I
get a handle on that, though.

    Danny> Hope this helps!

Yep, thanks!

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From bsass@freenet.edmonton.ab.ca  Thu Jun 28 20:47:23 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Thu, 28 Jun 2001 13:47:23 -0600 (MDT)
Subject: [Tutor] General Programming Question
In-Reply-To: <200106281653.f5SGr7301289@cecilia.trollope.org>
Message-ID: <Pine.LNX.4.33.0106281323450.11263-100000@bms>

On Thu, 28 Jun 2001, Michael Powe wrote:
<...>
> No switch
> statement, either.  Again, it's a part of the python paradigm that you
> do not design programs that use those kinds of constructs.  From my
> point of view (coming from C), that's a limitation.  I doubt
> 'pythonistas' would agree with me.

It is just spelled differently...

fun_dict = {'case1': func1, 'case2': func2}

try:
    fun_dict[case]()
except KeyError:
    print "no such case %s" % (case,)

fun_dict takes care of the case-s,
try...except looks after the switch and default.

> Every language requires you to adopt its paradigm.

Well, at least recognize how the very few operations there are in
programming are translated into the multitude of paradigms you see.
It is pretty easy to get into a "can't see the forest for the trees"
with a new language, the trees are all the fancy constructs wrapped
around the basics (moving data, comparing stuff, executing pieces of
code).


- Bruce




From dsh8290@rit.edu  Thu Jun 28 21:08:46 2001
From: dsh8290@rit.edu (D-Man)
Date: Thu, 28 Jun 2001 16:08:46 -0400
Subject: [Tutor] Language truce
In-Reply-To: <200106281940.f5SJeV801515@cecilia.trollope.org>; from michael@trollope.org on Thu, Jun 28, 2001 at 12:40:31PM -0700
References: <Pine.LNX.4.21.0106281127530.9400-100000@hkn.eecs.berkeley.edu> <200106281940.f5SJeV801515@cecilia.trollope.org>
Message-ID: <20010628160846.C19895@harmony.cs.rit.edu>

On Thu, Jun 28, 2001 at 12:40:31PM -0700, Michael Powe wrote:
| >>>>> "Danny" == Danny Yoo <dyoo@hkn.eecs.berkeley.edu> writes:
| 
|     Danny> On Thu, 28 Jun 2001, Michael Powe wrote:
| 
|     >> A couple things I mentioned, like you can't increment through
|     >> loops.
| 
|     Danny> I'm a little confused by what you mean by "incrementing
|     Danny> through loops".  Can you give an example of what you mean?
| 
| The standard C (for i=0; i < n; i++), which uses the increment
| operator (i++) which is not present in python.  I'm sure there must be
| some discussion somewhere about why the decision was made to leave
| this out, I just have not come across it.

Prior to Python 2.0 there was no augmented assignment either.  There
was quite a bit of discussion on c.l.py about how to add them and
whether or not the increment/decrement operator made sense.

First I'll explain how augmented assignment works.  You can define a
class such as

class Foo1 :
    def __iadd__( self , other ) :
        self.append( other )  # assume append is defined
        return self

this does an in-place addition, like what would happen to a list.  The
odd-looking 'return self' is because the interpreter assigns to the
LHS whatever was returned by the __iadd__ method.  So

o = Foo1()
o += 1
print o

would show that 'o' had changed.  The following shows that 'o' is
really the same object :

o = Foo1()
print id( o )
o += 1
print id( o )


This works for any type, mutable or immutable.  For a tuple the
implementation would be more like :

class Foo2 :
    def __iadd__( self , other ) :
        return self + other  # __add__ returns a new instance, BTW

so the result is 2 different objects :

o2 = Foo2()
print id( o2 )
print o2
o2 += 1
print id( o2 )
print o2


The issue with '++' and '--' is that what does it mean to "add 1" to a
list, string, tuple, or class instance?  Also, not every object can be
modified in-place.  The conclusion was that '++' is only syntax sugar
for the special case '+= 1', and that the implementation of augmented
assignment (briefly explained above) works nicely for both mutable and
immutable types, and all types of objects.

| Yes, as someone else points out, you can use range(), but obviously
| that is not the same thing. (In some cases, it may be functionally
| equivalent and maybe that is the point.)  Also, maybe it's just me,
| but I consider
| 
| k = k+1
| 
| as a loop counter to just be unacceptably clumsy.  Forcing me to use
| that construct tells me that I should not be designing my program that
| way. 

It is just a different spelling of the same operation and this
argument apparently has more aesthetic content than technical content.

-D



From michael@trollope.org  Thu Jun 28 21:03:19 2001
From: michael@trollope.org (Michael Powe)
Date: Thu, 28 Jun 2001 13:03:19 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <Pine.LNX.4.33.0106281323450.11263-100000@bms> (message from
 Bruce Sass on Thu, 28 Jun 2001 13:47:23 -0600 (MDT))
References: <Pine.LNX.4.33.0106281323450.11263-100000@bms>
Message-ID: <200106282003.f5SK3JU01543@cecilia.trollope.org>

>>>>> "Bruce" == Bruce Sass <bsass@freenet.edmonton.ab.ca> writes:

    Bruce> On Thu, 28 Jun 2001, Michael Powe wrote: <...>
    >> No switch statement, either.  Again, it's a part of the python
    >> paradigm that you do not design programs that use those kinds
    >> of constructs.  From my point of view (coming from C), that's a
    >> limitation.  I doubt 'pythonistas' would agree with me.

    Bruce> It is just spelled differently...

    Bruce> fun_dict = {'case1': func1, 'case2': func2}

    Bruce> try: fun_dict[case]() except KeyError: print "no such case
    Bruce> %s" % (case,)

    Bruce> fun_dict takes care of the case-s, try...except looks after
    Bruce> the switch and default.

This is a good case (whoops) in point.  It's not really a switch
statement, it's a dictionary, but it can be used to accomplish the
task.

    >> Every language requires you to adopt its paradigm.

    Bruce> Well, at least recognize how the very few operations there
    Bruce> are in programming are translated into the multitude of
    Bruce> paradigms you see.  It is pretty easy to get into a "can't
    Bruce> see the forest for the trees" with a new language, the
    Bruce> trees are all the fancy constructs wrapped around the
    Bruce> basics (moving data, comparing stuff, executing pieces of
    Bruce> code).

Yep.

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From pobrien@orbtech.com  Thu Jun 28 21:56:05 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 28 Jun 2001 15:56:05 -0500
Subject: [Tutor] Language truce
In-Reply-To: <200106281804.f5SI4hr01395@cecilia.trollope.org>
Message-ID: <NBBBIOJPGKJEKIECEMCBIEBLKCAA.pobrien@orbtech.com>

>From the Python Tutorial:

9.7 Odds and Ends
Sometimes it is useful to have a data type similar to the Pascal ``record''
or C ``struct'', bundling together a couple of named data items. An empty
class definition will do nicely, e.g.:
class Employee:
    pass

john = Employee() # Create an empty employee record

# Fill the fields of the record
john.name = 'John Doe'
john.dept = 'computer lab'
john.salary = 1000
A piece of Python code that expects a particular abstract data type can
often be passed a class that emulates the methods of that data type instead.
For instance, if you have a function that formats some data from a file
object, you can define a class with methods read() and readline() that gets
the data from a string buffer instead, and pass it as an argument.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Michael Powe
Sent: Thursday, June 28, 2001 1:05 PM
To: tutor@python.org
Subject: Re: [Tutor] Language truce

>>>>> "Israel" == Israel Evans <israel@lith.com> writes:

    Israel> What exactly IS the Python Programming Paradigm---(PPP) :)
    Israel> ???

    Israel> Everything is Beautiful and Easy.

    Israel> Strolling Leisurely towards Nirvana?

Would that it were so.

A couple things I mentioned, like you can't increment through loops.
But, also, it occurs to me that another part of the paradigm appears
to be that you can't create new data types, aka structs in C.

mp

--
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Thu Jun 28 22:20:58 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 28 Jun 2001 14:20:58 -0700 (PDT)
Subject: [Tutor] Language truce
In-Reply-To: <200106281940.f5SJeV801515@cecilia.trollope.org>
Message-ID: <Pine.LNX.4.21.0106281403220.9400-100000@hkn.eecs.berkeley.edu>

On Thu, 28 Jun 2001, Michael Powe wrote:

> >>>>> "Danny" == Danny Yoo <dyoo@hkn.eecs.berkeley.edu> writes:
> 
>     Danny> On Thu, 28 Jun 2001, Michael Powe wrote:
> 
>     >> A couple things I mentioned, like you can't increment through
>     >> loops.
> 
>     Danny> I'm a little confused by what you mean by "incrementing
>     Danny> through loops".  Can you give an example of what you mean?
> 
> The standard C (for i=0; i < n; i++), which uses the increment
> operator (i++) which is not present in python.  I'm sure there must be
> some discussion somewhere about why the decision was made to leave
> this out, I just have not come across it.
> 
> Yes, as someone else points out, you can use range(), but obviously
> that is not the same thing. (In some cases, it may be functionally

You're right that converting C's:

    for (i = 0; i < n ; i++) { ... }

isn't quite the same as Python's

    for i in range(n): ...

but it comes pretty close --- the extra thing that Python is doing is
actually constructing a list 'n' elements wide before going looping.

One reason that 'for/in' might be preferred is because we are guaranteed
that the loop will always terminate: there can only be a finite number of
elements in a list.  That's one big advantage of a loop construct that
goes along elements --- theoretically, we'll never get into infinite
loops.

On the other hand, there's a little bit of inefficiency due to actually
constructing that n-element list.  If we're just constructing the list,
and then just picking out the numbers in order "1...2...3...", it seems a
little wasteful to make that whole list.

In this case, Python provides an "xrange" function ("extended" range).  
It looks very much like range(), but it actually doesn't construct a
list.  So:

    for i in xrange(n):

works exactly like the C equivalent, without the messy syntax... *grin*



> equivalent and maybe that is the point.)  Also, maybe it's just me,
> but I consider
> 
> k = k+1
> 
> as a loop counter to just be unacceptably clumsy.  Forcing me to use
> that construct tells me that I should not be designing my program that
> way. 

Very true, but there are many ways to avoid the explicit maintenance of a
loop counter.  range/xrange is one way to avoid loop counters.  Another
function that Python provides is called the 'map' function.  map is very
neat, but we'll need an example to shows why:


###
>>> messy_strings = ['    this string has leading spaces     ',
...                  'and trailing spaces too        ',
...                  '    we can use map to strip all the strings   ',
...                  'in one shot!']              
>>> import string
>>> clean_strings = map(string.strip, messy_strings)
>>> clean_strings
['this string has leading spaces', 'and trailing spaces too',
 'we can use map to strip all the strings', 'in one shot!']
###

The cleanest code is that which doesn't exist.  *grin*



> My 'teach-yourself-python' project is an address book.  I happen to
> need one and I don't like anything that's already available.
> Unfortunately, the python books just aren't making it as instructional
> tools.  I know quite a bit about python syntax &c and practically
> nothing about actually writing programs in python.  Anyway, I have the
> data entry part and the write-to-file parts completed -- that was
> easy.  But, the file-reading and data storage parts are more
> interesting.  In C, I would just use a struct and a linked list and
> write/read the structs to/from a binary file -- I've done all that
> type of stuff before.

It's nice to see a fellow C programmer here!  Yeah, it will take a while
to get used to Python's way of doing things, but it's very much worth it
--- I've found that my own C programs look a lot better after learning
Python.


To save your address book to disk, you might be interested in the 'pickle'
module: it handles writing structures directly to disk and back, so it
makes saving most things ridiculously easy.

    http://python.org/doc/lib/module-pickle.html


We're here, so if you have any questions, feel free to ask them.  If you
want to express your questions in C terms, that's ok too.


Good luck!



From bsass@freenet.edmonton.ab.ca  Thu Jun 28 22:59:45 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Thu, 28 Jun 2001 15:59:45 -0600 (MDT)
Subject: [Tutor] parsing?
In-Reply-To: <MWMail.fgohjmia@host.none>
Message-ID: <Pine.LNX.4.33.0106281544240.11263-100000@bms>

On Thu, 28 Jun 2001, Ingo wrote:

> I'm tying to make something that can read some values and functions from a file
> and then use these to create a parametric surface in triangles to be rendered
> by POV-Ray. The triangle generation isn't the problem, but reading the
> functions into the program.
>
> If I have a line read from a textfile that says:
>
> u=2
>
> how do I manage to make a value u=2 available to the program, that read the
> textfile, so it can do some calculations with it?

This is what you want...

>>> s = "u=2"
>>> u
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'u' is not defined
>>> exec(s)
>>> u
2

...but do read the docs for the rexec module before you use it;
and maybe use it instead of exec even if you are not worried about
malicious lines in the textfile, it should also be usable to give you
better control over what happens if you are reading in a corrupted
textfile (who knows what kind of strange error you will get if you
try to "exec" garbage).


- Bruce



From ma@infogen.net.nz  Thu Jun 28 23:38:25 2001
From: ma@infogen.net.nz (Maurice Arthur)
Date: Fri, 29 Jun 2001 10:38:25 +1200
Subject: [Tutor] (no subject)
Message-ID: <005b01c10023$1fb81e60$3e14b9d2@whyme>

This is a multi-part message in MIME format.

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

confirm 393550

------=_NextPart_000_0058_01C10087.A07FCE80
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>confirm 393550</DIV></BODY></HTML>

------=_NextPart_000_0058_01C10087.A07FCE80--



From scarblac@pino.selwerd.nl  Fri Jun 29 00:15:49 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 29 Jun 2001 01:15:49 +0200
Subject: [Tutor] Language truce
In-Reply-To: <200106281940.f5SJeV801515@cecilia.trollope.org>; from michael@trollope.org on Thu, Jun 28, 2001 at 12:40:31PM -0700
References: <Pine.LNX.4.21.0106281127530.9400-100000@hkn.eecs.berkeley.edu> <200106281940.f5SJeV801515@cecilia.trollope.org>
Message-ID: <20010629011549.A30188@pino.selwerd.nl>

On  0, Michael Powe <michael@trollope.org> wrote:
> >>>>> "Danny" == Danny Yoo <dyoo@hkn.eecs.berkeley.edu> writes:
> 
>     Danny> On Thu, 28 Jun 2001, Michael Powe wrote:
> 
>     >> A couple things I mentioned, like you can't increment through
>     >> loops.
> 
>     Danny> I'm a little confused by what you mean by "incrementing
>     Danny> through loops".  Can you give an example of what you mean?
> 
> The standard C (for i=0; i < n; i++), which uses the increment
> operator (i++) which is not present in python.  I'm sure there must be
> some discussion somewhere about why the decision was made to leave
> this out, I just have not come across it.

It's simple. Assignment isn't an operator in Python, and operators can't
change bindings.

It's not possible to write a function inc(x) in Python, since a function
can't change the local binding 'x'.

It would be possible to make keywords "inc" and "dec", and introduce
statements "inc x" and "dec x", but that would be overkill for something
that can just as easily be spelled "x = x+1", or even "x += 1" nowadays.
Needless special casing.

> Yes, as someone else points out, you can use range(), but obviously
> that is not the same thing. (In some cases, it may be functionally
> equivalent and maybe that is the point.)  Also, maybe it's just me,
> but I consider
> 
> k = k+1
> 
> as a loop counter to just be unacceptably clumsy.  Forcing me to use
> that construct tells me that I should not be designing my program that
> way.

Get over it. Sheesh. (well ok, it probably means you should be using range()).


(snip)
> Anyway, I have the
> data entry part and the write-to-file parts completed -- that was
> easy.  But, the file-reading and data storage parts are more
> interesting.  In C, I would just use a struct and a linked list and
> write/read the structs to/from a binary file -- I've done all that
> type of stuff before.

Reading the file is simply the opposite of writing to it. You might also
want to pickle your classes, or read C structs using the struct module. I
don't know what your problem is exactly.

-- 
Remco Gerlich


From r.b.rigilink@chello.nl  Fri Jun 29 00:31:41 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Fri, 29 Jun 2001 01:31:41 +0200
Subject: [Tutor] Language truce
References: <Pine.LNX.4.21.0106281403220.9400-100000@hkn.eecs.berkeley.edu>
Message-ID: <3B3BBE5D.8A410487@chello.nl>

I haven't followed this completely, so maybe this is gibberish, but..

Danny Yoo wrote:
> 
> On Thu, 28 Jun 2001, Michael Powe wrote:
> 
> > >>>>> "Danny" == Danny Yoo <dyoo@hkn.eecs.berkeley.edu> writes:
> >
> >     Danny> On Thu, 28 Jun 2001, Michael Powe wrote:
> >
> >     >> A couple things I mentioned, like you can't increment through
> >     >> loops.
> >
> >     Danny> I'm a little confused by what you mean by "incrementing
> >     Danny> through loops".  Can you give an example of what you mean?
> >
> > The standard C (for i=0; i < n; i++), which uses the increment
> > operator (i++) which is not present in python.  I'm sure there must be
> > some discussion somewhere about why the decision was made to leave
> > this out, I just have not come across it.
> >
> > Yes, as someone else points out, you can use range(), but obviously
> > that is not the same thing. (In some cases, it may be functionally
> 
> You're right that converting C's:
> 
>     for (i = 0; i < n ; i++) { ... }
> 
> isn't quite the same as Python's
> 
>     for i in range(n): ...
> 

In comparing how Python and C handle this I think it's very important to
ask what's happening in {...}. Yes, the above seems a pretty
straightforward translation, though not literally the same. However,
this misses the point of the true differences between C and Python.
Consider:

for (i=0; i<n; i++){
   a = array_of_as[i];
   do_something(a);
}

This is one of the idiomatic usages of the C loop construct, i.e. as an
index. You would never translate this into Python as:

for i in range(n):
    a = list_of_as[i]
    do_something(a)

but as:

for a in list_of_as:
    do_something(a)

The difference in paradigm between Python and C here, is not illustrated
by the difference in the C example and the first Python example, but by
the difference between the first Python example and the second. (I think
though, that even these differences are too small to constitute a
paradigm difference)

By the way, the most literal translation of the general C loop into
Python is:

i = 0
while i<n:
    ...
    i+=1 

This may look like a very different way of expressing it, but it does
_exactly_ the same thing, both conceptually, and implementation-wise.
This construct also allows for playing around with i in the body of the
loop ("increment through loops").

Now, you may rarely see this in practice, but that's not because Python
lacks an increment operator ;)

<snip>

> > k = k+1
> >
> > as a loop counter to just be unacceptably clumsy.  Forcing me to use
> > that construct tells me that I should not be designing my program that
> > way.
> 

I agree with your conclusion, although I would say that you don't use
loops in Python as you'd do in C not so much because Python doesn't have
an increment operator, but because C doesn't have lists/tuples/strings.

In fact, I think that that's the comment I really wanted to make. I
think you're right that there are different paradigms underlying C and
Python, but this is not reflected in the rather incidental presence or
absence of the syntactic sugarish case statement and increment operator.
Rather, think object-oriented vs imperative, high-level vs low-level,
dynamic vs static, objects vs pointers, etc. etc.

<snip> 
> > My 'teach-yourself-python' project is an address book.  I happen to
> > need one and I don't like anything that's already available.
> > Unfortunately, the python books just aren't making it as instructional
> > tools.  I know quite a bit about python syntax &c and practically
> > nothing about actually writing programs in python.  Anyway, I have the
> > data entry part and the write-to-file parts completed -- that was
> > easy.  But, the file-reading and data storage parts are more
> > interesting.  In C, I would just use a struct and a linked list and
> > write/read the structs to/from a binary file -- I've done all that
> > type of stuff before.
> 

In Python a class in stead of a struct, and a list or dict in stead of a
linked list.
Of course you can build a general linked list data-structure in Python
too. It's actually 
a fun way to learn about classes. In practice I think you'll find that
you rarely need one.

> It's nice to see a fellow C programmer here!  Yeah, it will take a while
> to get used to Python's way of doing things, but it's very much worth it
> --- I've found that my own C programs look a lot better after learning
> Python.
> 

I can second that (and my C++ has improved too)

Just some ramblings,

Roeland
-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From scarblac@pino.selwerd.nl  Fri Jun 29 00:19:32 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 29 Jun 2001 01:19:32 +0200
Subject: [Tutor] parsing?
In-Reply-To: <MWMail.fgohjmia@host.none>; from seedseven@home.nl on Thu, Jun 28, 2001 at 08:59:15PM +0200
References: <MWMail.fgohjmia@host.none>
Message-ID: <20010629011932.B30188@pino.selwerd.nl>

On  0, Ingo <seedseven@home.nl> wrote:
> I'm tying to make something that can read some values and functions from a file 
> and then use these to create a parametric surface in triangles to be rendered 
> by POV-Ray. The triangle generation isn't the problem, but reading the 
> functions into the program. 
> 
> If I have a line read from a textfile that says:
> 
> u=2
> 
> how do I manage to make a value u=2 available to the program, that read the 
> textfile, so it can do some calculations with it?

It depends. What do the rest of the lines look like?

If the file only contains lines like that, it's legal Python, so you could
simply import it :-)

-- 
Remco Gerlich


From r.b.rigilink@chello.nl  Fri Jun 29 01:11:15 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Fri, 29 Jun 2001 02:11:15 +0200
Subject: [Tutor] parsing?
References: <MWMail.fgohjmia@host.none>
Message-ID: <3B3BC7A3.84AC7A66@chello.nl>

Ingo wrote:
> 
> I'm tying to make something that can read some values and functions from a file
> and then use these to create a parametric surface in triangles to be rendered
> by POV-Ray. The triangle generation isn't the problem, but reading the
> functions into the program.
> 

Unfortunately, in general this is not trivial.

Presumably, the file you read contains statements in some kind of
programming language. It is certainly possible to build a parser in
Python for that language which then allows you to execute those
statements in Python, as it were. This is not easy, and may not be the
right solution anyway.

On the other hand:

> If I have a line read from a textfile that says:
> 
> u=2

This one is also a valid python statement, so you can use exec().

> 
> how do I manage to make a value u=2 available to the program, that read the
> textfile, so it can do some calculations with it?
> 
> The same, but now for a function:
> 
> Function Fx(u,v,R)=R*sin(u)*cos(v)
> 
>
> How do I make the above available in the program as if the below was part of it?
> 
> def Fx (u,v,R):
>     x=R*sin(u)*cos(v)
>     return x
>

This is the tricky one, though it may be as easy as (could be coded
nicer)

str = "Function Fx(u,v,R)=R*sin(u)*cos(v)"
str = str.replace('Function', '') 
str = str.split('=')
func_head, func_body = str[0], str[1]
ecex('def %s:\n\treturn %s\n' % func_head, func_body)

The last line being equivalent to

exec('''def Fx(u. v, R):
            return R*sin(u)*cos(v)
     '''


> TIA,
> 
> Ingo
> 
> --
> Photography:  http://members.home.nl/ingoogni/
> POV-Ray:  http://members.home.nl/seed7/
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"


From bill-bell@bill-bell.hamilton.on.ca  Thu Jun 28 21:07:53 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Thu, 28 Jun 2001 16:07:53 -0400
Subject: [Tutor] Re: parsing?
In-Reply-To: <E15FhGk-00086x-00@mail.python.org>
Message-ID: <3B3B5659.392.435DA0F@localhost>

Ingo <seedseven@home.nl> wrote, in part:
> I'm tying to make something that can read some values and functions
> from a file and then use these to create a parametric surface in
> triangles to be rendered by POV-Ray. The triangle generation isn't the
> problem, but reading the functions into the program. 
> 
> If I have a line read from a textfile that says:
> 
> u=2
> 
> how do I manage to make a value u=2 available to the program, that
> read the textfile, so it can do some calculations with it? 
> 
> The same, but now for a function:
> 
> Function Fx(u,v,R)=R*sin(u)*cos(v)
> 
> How do I make the above available in the program as if the below was
> part of it?
> 
> def Fx (u,v,R):
>     x=R*sin(u)*cos(v)
>     return x

Ingo,

You can use the Python 'exec' statement to handle at least part of 
this problem.

For example,

>>> import math
>>> strFx = "def Fx (u,v,R): return R*math.sin(u)*math.cos(v)"
>>> exec strFx
>>> exec "u=1.57"
>>> Fx(u,3.14,5)
-4.9999920732988814

You could just as easily read the Python statements from a file 
and arrange to make their results available in the current 
namespace using this technique. The harder part would have to do 
with translating the usual mathematical notation into Python. 
However, if you're able to allow that that would be unnecessary 
then you could just input the functions and other items that you 
need in Python syntax.

I notice that there a Python constructs related to 'exec' that are 
probably useful in this context.

Bill


From shalehperry@home.com  Fri Jun 29 07:35:00 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Thu, 28 Jun 2001 23:35:00 -0700 (PDT)
Subject: [Tutor] a little OT
In-Reply-To: <0106281352470E.20991@yatsu>
Message-ID: <XFMail.20010628233500.shalehperry@home.com>

On 28-Jun-2001 Brendon wrote:
> Though i'd try asking here because perhaps other people use this app aswell.
> 
> when trying to run pybber on debian unstable i get the following error:
> 
> Traceback (innermost last):
>   File "/usr/local/bin/pybberrun.py", line 5, in ?
>     import pybber
>   File "/usr/lib/python1.5/site-packages/pybber.py", line 11, in ?
>     import PyRecode
> ImportError: /usr/lib/python1.5/site-packages/PyRecodemodule.so: undefined 
> symbol: list_all_charsets
> 
> as always i have no clue what's going wrong here. has anyone else run into 
> this?
> 

gut reaction is either something is missing or a version is skewed.  There is a
debian-python mailing list that all developers who maintain a python package
are subscribed.  Should be able to get help there.  Debian's list are open no
need to subscribe just let people know to CC you.


From bren@europe.nl.com  Fri Jun 29 08:46:44 2001
From: bren@europe.nl.com (Brendon)
Date: Fri, 29 Jun 2001 09:46:44 +0200
Subject: [Tutor] a little OT
In-Reply-To: <XFMail.20010628233500.shalehperry@home.com>
References: <XFMail.20010628233500.shalehperry@home.com>
Message-ID: <01062909464405.26891@yatsu>

On Friday 29 June 2001 08:35, you wrote:
> On 28-Jun-2001 Brendon wrote:
> > Though i'd try asking here because perhaps other people use this app
> > aswell.
> >
> > when trying to run pybber on debian unstable i get the following error:
> >
> > Traceback (innermost last):
> >   File "/usr/local/bin/pybberrun.py", line 5, in ?
> >     import pybber
> >   File "/usr/lib/python1.5/site-packages/pybber.py", line 11, in ?
> >     import PyRecode
> > ImportError: /usr/lib/python1.5/site-packages/PyRecodemodule.so:
> > undefined symbol: list_all_charsets
> >
> > as always i have no clue what's going wrong here. has anyone else run
> > into this?
>
> gut reaction is either something is missing or a version is skewed.  There
> is a debian-python mailing list that all developers who maintain a python
> package are subscribed.  Should be able to get help there.  Debian's list
> are open no need to subscribe just let people know to CC you.

"I've already run into this problem, it's because the recode library
available in Debian Woody is incompatible with pyrecode.

I've suspended the development of Pybber until Python 2.x gets into
Debian, since it have UNICODE features (and I want to use them), it
won't need pyrecode." --Claudemir Todo Bom (author of pybber)

going to have to wait i'm afraid. gives me more time to study it now though :)

Brendon
-- 

"if we live by an "eye for an eye and a tooth for a tooth"...before long, 
the whole world will be blind and toothless." 
         --Tevye, Fiddler on the Roof


From alan.gauld@bt.com  Fri Jun 29 10:39:00 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 29 Jun 2001 10:39:00 +0100
Subject: [Tutor] General Programming Question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D882@mbtlipnt02.btlabs.bt.co.uk>

> I think this misses the point.  Recursion is not a 'looping
> construct,' although it can be used that way.  

Oh I agree, and have no beef about  recursion which is IMHO 
a necessary part of any programming language.

> The dialect of Lisp used in SCIP is Scheme.  

Yes and that's fine too.

>     alan> I just think it tends to take a very singular view of
>     alan> programming.
> However, this is like criticizing a dog for having four legs and not
> walking on only two.  Take a look at some of the peculiarities of
> Python.  

But here is the important point SCIP does not explicitly purport
to be about Scheme per se but rather about programming in general.
In that sense I believe it presents a very narrow view of programming, 
albeit a very pure and mathematically well formed view. But I don't 
think it would, make it easy for the reader to adapt to other more 
commonly seen languages. It is still a good book, and I do think 
many Pythonistas would learn a lot from it but I just don't think it
addresses the basics of programming - I/O is barely touched on for 
example.

> Every language requires you to adopt its paradigm.

Sure and when I program in Python I do it very differently to how 
I do it when I use Lisp(mainly in emacs!) but SCIP purports to be 
about something more than just teahing the Scheme language.  Thus 
once someone has learnt Python picking up SCIP and reading it will 
open up a whole new viewpoint on wehat programming is about. A useful 
read and the lessons translate well back into Python but I'd never 
recommend SCIP as a first book on programming. Now in a college 
context with tutors available etc thats a different story...

Alan G



From alan.gauld@bt.com  Fri Jun 29 10:53:24 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 29 Jun 2001 10:53:24 +0100
Subject: [Tutor] more newbie questions: variables without a value
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D884@mbtlipnt02.btlabs.bt.co.uk>

> in the following code..

Which looks suspiciously familiar...

> m1 = Message("Hello World")
> m2 = Message("So long, it was short bu sweet.")

create two message objects

> 
> note = [m1, m2]

put them in a list

> for msg in note:

assign msg to each item in the list

> 	msg.printIt()

perform an action on msg

Its no different to:

for n in range(5):
   print n

range(5) is identical to:
[0,1,2,3,4]

so we could have written:

for n in [0,1,2,3,4]:
   print n

> the line: "for msg in note:" doesn't seem to make sense 
> because "msg" has no value nor is it pointing to "note".

Check my tutor page on loops:

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

for more detail.

Alan G.


From alan.gauld@bt.com  Fri Jun 29 10:43:41 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 29 Jun 2001 10:43:41 +0100
Subject: [Tutor] Language truce
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D883@mbtlipnt02.btlabs.bt.co.uk>

> Folks, let's stop the language war now before it gets further.
> Scheme has its place.  Python has its place.  

I wasn't aware I'd started a language war! Scheme is a great 
language as is Python, I use both. I was commenting on the 
rather narrow presentation of programming in SCIP.

Scheme as a language actually supports other constructs, which
is the point I was making the book in question simply chooses 
not to discuss the loop or do commands and use recursion as if 
it were the only choice. ie i was objecting to the book not Scheme.

Ho hum, sorry if I've offended anyone. And BTW the book is 
actually very good at what it does do. And many Pythonistas 
would find it interesting reading.

Alan G



From alan.gauld@bt.com  Fri Jun 29 11:42:06 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 29 Jun 2001 11:42:06 +0100
Subject: [Tutor] Language truce
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D885@mbtlipnt02.btlabs.bt.co.uk>

> Ah, yes.  I should have realized, we just started going over classes
> in my java course last night.  

Classes are the equivalent.

> easy.  But, the file-reading and data storage parts are more
> interesting.  In C, I would just use a struct and a linked list and
> write/read the structs to/from a binary file -- I've done all that
> type of stuff before.

In Python the nearest equivalent is to use the pickle module 
which looks after writing objects to files. There is a struct 
module too but that involves much more work and seems best 
suited to reading/writing binary dfiles that must be shared 
with non python apps.

> A class is probably the way to go.  Might be a little while before I
> get a handle on that, though.

You can try my tuor page ;-)

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


Alan g


From alan.gauld@bt.com  Fri Jun 29 11:45:41 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 29 Jun 2001 11:45:41 +0100
Subject: [Tutor] General Programming Question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D886@mbtlipnt02.btlabs.bt.co.uk>

> > Every language requires you to adopt its paradigm.
> 
> Well, at least recognize how the very few operations there are in
> programming are translated into the multitude of paradigms you see.

An excellent point and the reason my web tutor uses 3 languages
rather than just Python (which my book does at my publishers 
insistence) because I strongly believe that seeiung the same 
construct in 3 different ways emphasises the construct rather 
than the language idioms. Of course that does introduce an 
element of confusuion until that whole premis sinks in.

Alan g


From bren@europe.nl.com  Fri Jun 29 12:05:06 2001
From: bren@europe.nl.com (Brendon)
Date: Fri, 29 Jun 2001 13:05:06 +0200
Subject: [Tutor] more newbie questions: variables without a value
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D884@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D884@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <01062913050607.26891@yatsu>

On Friday 29 June 2001 11:53, you wrote:
> > in the following code..
>
> Which looks suspiciously familiar...
>
> > m1 = Message("Hello World")
> > m2 = Message("So long, it was short bu sweet.")
>
> create two message objects
>
> > note = [m1, m2]
>
> put them in a list
>
> > for msg in note:
>
> assign msg to each item in the list
>
> > 	msg.printIt()
>
> perform an action on msg
>
> Its no different to:
>
> for n in range(5):
>    print n
>
> range(5) is identical to:
> [0,1,2,3,4]
>
> so we could have written:
>
> for n in [0,1,2,3,4]:
>    print n
>
> > the line: "for msg in note:" doesn't seem to make sense
> > because "msg" has no value nor is it pointing to "note".
>
> Check my tutor page on loops:
>
> http://www.crosswinds.net/~agauld/tutloops.htm

that's where i got it from obviously :)

perhaps an extra explanation for C/C++/anyother language with similar loops, 
would be a good idea to add. i'm still very easily confused with this one. 
somewhere there should be very clearly noted that in

for n in [0,1,2,3,4]:
   print n

"n" is passed on to the loop with the first value of "[0,1,2,3,4]", goes 
through the loop and changes to the next value in the list/variable, repeats 
the loop etc. until all the members of the list/variable have been passed to 
"n" and run through the loop.

err, okay.. so i never was good in explaining :) nonetheless, i feel 
something should be added to comfort the C/C++ programmers.

Brendon
-- 

"if we live by an "eye for an eye and a tooth for a tooth"...before long, 
the whole world will be blind and toothless." 
         --Tevye, Fiddler on the Roof


From rnd@onego.ru  Fri Jun 29 12:28:38 2001
From: rnd@onego.ru (Roman Suzi)
Date: Fri, 29 Jun 2001 15:28:38 +0400 (MSD)
Subject: [Tutor] General Programming Question
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D886@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.LNX.4.21.BCL.0106291516560.22325-100000@suzi.com.onego.ru>

On Fri, 29 Jun 2001 alan.gauld@bt.com wrote:

> > > Every language requires you to adopt its paradigm.

In fact, every language adopts one or more paradigms. So, Pascal, C and
Basic are the same languages. Only syntax (to some extent) differs.

Python has multiple paradigms, and thus is similar to Pascal, etc, if we
look only in context of structured programming.

Thus, Python is useful to teach structural, OO and functional programming.
(if only elemnts of the last one).
 
> > Well, at least recognize how the very few operations there are in
> > programming are translated into the multitude of paradigms you see.
> 
> An excellent point and the reason my web tutor uses 3 languages
> rather than just Python (which my book does at my publishers 
> insistence) because I strongly believe that seeiung the same 
> construct in 3 different ways emphasises the construct rather 
> than the language idioms. Of course that does introduce an 
> element of confusuion until that whole premis sinks in.

Yes, it is certain plus, even if languages arent that different.

The different point is HOW to teach programming at all. My point is, that
language doesn't matter at initial stage. (It an be everything, including
programmable calculator code). Programming skill is universal. After
getting it (getting thru barrier), one can learn whatever s/he chooses
easily.
 
> Alan g

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd@onego.ru -
 




From zilp@village.uunet.be  Fri Jun 29 13:12:32 2001
From: zilp@village.uunet.be (Philippe Smets)
Date: Fri, 29 Jun 2001 14:12:32 +0200
Subject: [Tutor] Tkinter problem (updating labels)
Message-ID: <B7623D4F.592%zilp@village.uunet.be>

I'm trying to make my first program in Python. I'm also using Tkinter.
It's a little game for my 8 year old daugther.
In that game I need to place images on labels. I wrote the following code
for that:

from Tkinter import*
import Image, ImageTk, os, random

class Bord:
    def __init__(self,master):
        frame=Frame(master)
        frame.grid()
        tellerrow = 0
        tellercol = 0
        colorlist =
['red','green','yellow','blue','orange','pink','brown','gold', 'brown']
        self.labelist = {}
        self.Imgg = ""
        for i in range(72):
            colorchoice = colorlist[tellerrow]
            self.i = Labeltest(i,i,"",colorchoice,tellerrow, tellercol)
            self.labelist[i]=self.i
            tellercol = tellercol + 1
            if tellercol >8:
                tellercol = 0
                tellerrow = tellerrow + 1
                
            
        Under=Frame(height = 30, width=600, bg = 'white')
        Under.grid(row = 9, column = 0, columnspan = 16, sticky = W)
        
        testButn =  Button(root,text ="placeImg")
        testButn.grid(row = 9, column = 0)
        testButn.bind("<Button-1>",lambda event,b = self.testturn:b())
    
    
    def testturn(self):
        number = random.randrange(0, 4)
        images = os.listdir("images")
        imagelist = ["Zia.jpg", "Ilja.jpg","Lynn.jpg","Philippe.jpg"]
        masterImg = Image.open(os.path.join("images",imagelist[number]))
            masterImg.thumbnail((40, 40))
            imge = ImageTk.PhotoImage(masterImg)
        self.Imgg = imge
        self.labelist[random.randrange(0, 72)].zconfig(self.Imgg)
        
class Labeltest:
    def __init__(self,naam,tekst,image,colorchoice,rij,kolomn):
        self.kleur = colorchoice
        self.tekst = tekst
        self.image = image
        self.rij=rij
        self.kolomn= kolomn
        self.naam = naam
        self.i=Frame(height = 50, width=50, bg = colorchoice, bd = 5,
relief= RIDGE)
        self.i.label=Label(text = self.tekst, bg = self.kleur)
        self.i.label.grid(row = self.rij, column = self.kolomn)
        self.i.grid(row = self.rij, column =  self.kolomn, sticky = NSEW)
        
    def zconfig(self,arg):
        self.i.label.config(image = arg)
root = Tk()
app = Bord(root)

root.mainloop()

The problem is that I want the images to stay on the labels when the button
testButn is pushed so that in the end most labels will contain an image.

With my code the image of the previously changed label is erased.
I can't figure out why, because I'm not changing the image value of that
label.

 So I'm stuck with this.

Any help would be greatly appreciated.

Philippe Smets




From SBrunning@trisystems.co.uk  Fri Jun 29 14:42:39 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Fri, 29 Jun 2001 14:42:39 +0100
Subject: [Tutor] URLs for urllib.urlopen
Message-ID: <31575A892FF6D1118F5800600846864D78BDEF@intrepid>

Can someone explain this to me?

PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see
'Help/About PythonWin' for further copyright information.
>>> import urllib, pprint
>>> page = urllib.urlopen('http://www.python.org')
>>> data = page.readlines()
>>> pprint.pprint(data)
['<html><head><title>Error</title></head><body>The parameter is incorrect.
</body></html>']
>>> page = urllib.urlopen('http://www.python.org/')
>>> data = page.readlines()
>>> pprint.pprint(data)
['<HTML>\n',
 '<!-- THIS PAGE IS AUTOMATICALLY GENERATED.  DO NOT EDIT. -->\n',
(... snip)

It appears that urllib requires a trailing slash, but in the examples in the
effbot's PSL book, he doesn't give one. Any ideas?

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 dyoo@hkn.eecs.berkeley.edu  Fri Jun 29 17:39:43 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 29 Jun 2001 09:39:43 -0700 (PDT)
Subject: [Tutor] URLs for urllib.urlopen
In-Reply-To: <31575A892FF6D1118F5800600846864D78BDEF@intrepid>
Message-ID: <Pine.LNX.4.21.0106290935560.26119-100000@hkn.eecs.berkeley.edu>

On Fri, 29 Jun 2001, Simon Brunning wrote:

> Can someone explain this to me?
> 
> PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32.
> Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see
> 'Help/About PythonWin' for further copyright information.
> >>> import urllib, pprint
> >>> page = urllib.urlopen('http://www.python.org')
> >>> data = page.readlines()
> >>> pprint.pprint(data)
> ['<html><head><title>Error</title></head><body>The parameter is incorrect.
> </body></html>']

Very strange!  This seems to work for me, trailing slash or not.  Can you
check to see if that error happens again?  Does anyone else know what
would cause the above?




From rufmetal@home.com  Fri Jun 29 18:51:41 2001
From: rufmetal@home.com (Chris Keelan)
Date: Fri, 29 Jun 2001 12:51:41 -0500
Subject: [Tutor] General Programming Question
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D882@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D882@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <01062912514100.02172@tygesen>

On Friday 29 June 2001 04:39, alan.gauld@bt.com wrote:

> A useful read and the lessons translate well back into Python but I'd never
> recommend SCIP as a first book on programming.

What would you recommend?

- Chris (just getting started)


From bren@europe.nl.com  Fri Jun 29 19:22:26 2001
From: bren@europe.nl.com (Brendon)
Date: Fri, 29 Jun 2001 20:22:26 +0200
Subject: [Tutor] OOP with Tk/Tkinter
Message-ID: <01062920222602.31904@yatsu>

Now that i've been through the tutorial on http://www.crosswinds.net/~agauld/ 
I'm not sure where to go next. I want to learn more about GUI object 
orientated programming with Tk/Tkinter. I've only be able to find two 
tutorials for Tk/Tkinter and both were not OO.

Any suggestions anyone?

Brendon
--

"if we live by an "eye for an eye and a tooth for a tooth"...before long, 
the whole world will be blind and toothless." 
         --Tevye, Fiddler on the Roof


From michael@trollope.org  Fri Jun 29 19:53:54 2001
From: michael@trollope.org (M.A. Powe)
Date: Fri, 29 Jun 2001 11:53:54 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D882@mbtlipnt02.btlabs.bt.co.uk>
 (alan.gauld@bt.com)
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D882@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <200106291853.f5TIrs202488@cecilia.trollope.org>

>>>>> "alan" == alan gauld <alan.gauld@bt.com> writes:

    alan> I just think it tends to take a very singular view of
    alan> programming.

    >> However, this is like criticizing a dog for having four legs
    >> and not walking on only two.  Take a look at some of the
    >> peculiarities of Python.

    alan> But here is the important point SCIP does not explicitly
    alan> purport to be about Scheme per se but rather about
    alan> programming in general.  In that sense I believe it presents
    alan> a very narrow view of programming, albeit a very pure and
    alan> mathematically well formed view. But I don't think it would,
    alan> make it easy for the reader to adapt to other more commonly
    alan> seen languages. It is still a good book, and I do think many
    alan> Pythonistas would learn a lot from it but I just don't think
    alan> it addresses the basics of programming - I/O is barely
    alan> touched on for example.

But, programming is not about I/O.  Implementation is about I/O.
Programming is about designing solutions to problems.

    >> Every language requires you to adopt its paradigm.

    alan> Sure and when I program in Python I do it very differently
    alan> to how I do it when I use Lisp(mainly in emacs!) but SCIP
    alan> purports to be about something more than just teahing the
    alan> Scheme language.  Thus once someone has learnt Python
    alan> picking up SCIP and reading it will open up a whole new
    alan> viewpoint on wehat programming is about. A useful read and
    alan> the lessons translate well back into Python but I'd never
    alan> recommend SCIP as a first book on programming. Now in a
    alan> college context with tutors available etc thats a different
    alan> story...

No, I wouldn't recommend it either, since it totally snowed me.  ;-)
It definitely is a classroom text book, and like most such books,
assumes an instructor and an interactive environment such as the
classroom. 

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From michael@trollope.org  Fri Jun 29 20:06:07 2001
From: michael@trollope.org (M.A. Powe)
Date: Fri, 29 Jun 2001 12:06:07 -0700
Subject: [Tutor] General Programming Question
In-Reply-To: <Pine.LNX.4.21.BCL.0106291516560.22325-100000@suzi.com.onego.ru>
 (message from Roman Suzi on Fri, 29 Jun 2001 15:28:38 +0400 (MSD))
References: <Pine.LNX.4.21.BCL.0106291516560.22325-100000@suzi.com.onego.ru>
Message-ID: <200106291906.f5TJ67i02506@cecilia.trollope.org>

>>>>> "Roman" == Roman Suzi <rnd@onego.ru> writes:
 
    >> > Well, at least recognize how the very few operations there
    >> are in > programming are translated into the multitude of
    >> paradigms you see.

    >> An excellent point and the reason my web tutor uses 3 languages
    >> rather than just Python (which my book does at my publishers
    >> insistence) because I strongly believe that seeiung the same
    >> construct in 3 different ways emphasises the construct rather
    >> than the language idioms. Of course that does introduce an
    >> element of confusuion until that whole premis sinks in.

    Roman> Yes, it is certain plus, even if languages arent that
    Roman> different.

    Roman> The different point is HOW to teach programming at all. My
    Roman> point is, that language doesn't matter at initial
    Roman> stage. (It an be everything, including programmable
    Roman> calculator code). Programming skill is universal. After
    Roman> getting it (getting thru barrier), one can learn whatever
    Roman> s/he chooses easily.

Language does matter, I think.  The big argument over language is, how
much time do you spend teaching syntax vs how much time do you spend
teach actual programming?  Unfortunately, IMO, for too many people,
programming == language.  

The point of using Scheme is that it has an extremely simple syntax
which can be learned, literally, in a few days.  You can't even get
close to an OO language without first slogging through the theory of
OOP. This makes OO languages poor choices for a 'how to program'
courses.  Unfortunately, these days almost all these courses are
taught using C++ or Java because of the false equivalence stated
above. 

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America


From dyoo@hkn.eecs.berkeley.edu  Fri Jun 29 22:03:08 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 29 Jun 2001 14:03:08 -0700 (PDT)
Subject: [Tutor] General Programming Question
In-Reply-To: <01062912514100.02172@tygesen>
Message-ID: <Pine.LNX.4.21.0106291345300.29611-100000@hkn.eecs.berkeley.edu>

On Fri, 29 Jun 2001, Chris Keelan wrote:

> On Friday 29 June 2001 04:39, alan.gauld@bt.com wrote:
> 
> > A useful read and the lessons translate well back into Python but I'd
> > never recommend SICP as a first book on programming.
> 
> What would you recommend?


I'd recommend Alan Gauld's "Learn to Program Using Python".  There's a
reference to the book here:

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

It's one of the better books I've seen on introductory programming.



From dyoo@hkn.eecs.berkeley.edu  Fri Jun 29 22:07:41 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 29 Jun 2001 14:07:41 -0700 (PDT)
Subject: [Tutor] OOP with Tk/Tkinter
In-Reply-To: <01062920222602.31904@yatsu>
Message-ID: <Pine.LNX.4.21.0106291403180.29611-100000@hkn.eecs.berkeley.edu>

On Fri, 29 Jun 2001, Brendon wrote:

> Now that i've been through the tutorial on
> http://www.crosswinds.net/~agauld/

> I'm not sure where to go next. I want to learn more about GUI object
> orientated programming with Tk/Tkinter. I've only be able to find two
> tutorials for Tk/Tkinter and both were not OO.

Hiya Brendon,

If you're thinking about Tkinter stuff, then Grayson's book, "Python and
Tkinter Programming", is essential --- there's a lot of good material, and
its emphasis is on object oriented gui's.  There's even a section that
talks about general Python tips, so it's a good book.

Also, you can ask us for examples of OOP'ed GUI's, and we'll be glad to
oblige.  What sort of program do you want to write?



From bren@europe.nl.com  Fri Jun 29 22:22:47 2001
From: bren@europe.nl.com (Brendon)
Date: Fri, 29 Jun 2001 23:22:47 +0200
Subject: [Tutor] OOP with Tk/Tkinter
In-Reply-To: <Pine.LNX.4.21.0106291403180.29611-100000@hkn.eecs.berkeley.edu>
References: <Pine.LNX.4.21.0106291403180.29611-100000@hkn.eecs.berkeley.edu>
Message-ID: <01062923224700.04540@yatsu>

On Friday 29 June 2001 23:07, you wrote:
> On Fri, 29 Jun 2001, Brendon wrote:
> > Now that i've been through the tutorial on
> > http://www.crosswinds.net/~agauld/
> >
> > I'm not sure where to go next. I want to learn more about GUI object
> > orientated programming with Tk/Tkinter. I've only be able to find two
> > tutorials for Tk/Tkinter and both were not OO.
>
> If you're thinking about Tkinter stuff, then Grayson's book, "Python and
> Tkinter Programming", is essential --- there's a lot of good material, and
> its emphasis is on object oriented gui's.  There's even a section that
> talks about general Python tips, so it's a good book.

I'll look into it :)

> Also, you can ask us for examples of OOP'ed GUI's, and we'll be glad to
> oblige.  What sort of program do you want to write?

Well, eventually i want to be able to write a simple jabber client (not using 
any code from pybber) and although i'd rather do it in qt/kde there doesn't 
seem to be a python binding for kde2, so Tkinter it will be.

I still don't know enough python and Tkinter to even start this, which is why 
i'm looking for a(/another) good tutorial but examples would be fine also i 
guess.

I've seen a AOL messenger client which could have been useful, but again.. it 
wasn't object orientated. Ofcourse i could simply use pybber, but a) it's a 
little too large and b) it uses gtk, which i want to avoid.
-- 

"if we live by an "eye for an eye and a tooth for a tooth"...before long, 
the whole world will be blind and toothless." 
         --Tevye, Fiddler on the Roof


From tim.one@home.com  Fri Jun 29 22:49:13 2001
From: tim.one@home.com (Tim Peters)
Date: Fri, 29 Jun 2001 17:49:13 -0400
Subject: [Tutor] Language truce
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D883@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <LNBBLJKPBEHFEDALKOLCGEIJKLAA.tim.one@home.com>

[alan.gauld@bt.com]
> I wasn't aware I'd started a language war!

Na, you didn't.

> Scheme is a great language as is Python, I use both. I was commenting
> on the rather narrow presentation of programming in SCIP.
>
> Scheme as a language actually supports other constructs, which
> is the point I was making the book in question simply chooses
> not to discuss the loop or do commands and use recursion as if
> it were the only choice. ie i was objecting to the book not Scheme.

Well, "Scheme" is a family of languages, and even "Official Scheme" has gone
thru many revisions.  I do believe that, at the start, it didn't have a loop
macro, and SICP dates back quite a while.  From an academic view, I doubt
that the SICP authors would use it even now:  they're not trying to teach
*pragmatics*, and the loop macro is "only a convenience".  In the half a
page it would take to explain it, they could come up with three more
exercises to explode your brain instead <wink>.

> Ho hum, sorry if I've offended anyone. And BTW the book is
> actually very good at what it does do. And many Pythonistas
> would find it interesting reading.

All true.  Hard going for a beginner, though!  SICP is really about
"Computer Science" more than *programming*.



From deirdre@deirdre.net  Fri Jun 29 22:59:57 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Fri, 29 Jun 2001 14:59:57 -0700
Subject: [Tutor] Language truce
In-Reply-To: <LNBBLJKPBEHFEDALKOLCGEIJKLAA.tim.one@home.com>
References: <LNBBLJKPBEHFEDALKOLCGEIJKLAA.tim.one@home.com>
Message-ID: <a0510100cb762a95748f3@[10.0.1.7]>

At 5:49 PM -0400 6/29/01, Tim Peters wrote:
>[alan.gauld@bt.com]
>  > Ho hum, sorry if I've offended anyone. And BTW the book is
>>  actually very good at what it does do. And many Pythonistas
>>  would find it interesting reading.
>
>All true.  Hard going for a beginner, though!  SICP is really about
>"Computer Science" more than *programming*.

Ah, this reminds me of a particular grad school hell (I'm now in the 
12th, of 12, of these, woohoo!) -- the obligatory Programming 
Languages class.

Nothing quite like taking someone who's coded pretty much the same 
style for 20 years and saying, "here, try THIS paradigm on your brain 
for a week!" "No, wait, THIS one!"

I remember being the only student to get partial credit for an ML 
problem in which the prof wanted a solution that required only two 
parameters be passed. I did it in an entirely different way, but 
couldn't figure out how to get it down from three to two. No one else 
did either, not even the functional programming fans.

The only class that hurt worse (in terms of brain frying) was 
probably Modeling and Simulation. I did all my code for that class in 
Python -- much to the chagrin of my professor.
-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From bren@europe.nl.com  Fri Jun 29 23:37:18 2001
From: bren@europe.nl.com (Brendon)
Date: Sat, 30 Jun 2001 00:37:18 +0200
Subject: [Tutor] OOP with Tk/Tkinter
In-Reply-To: <01062923224700.04540@yatsu>
References: <Pine.LNX.4.21.0106291403180.29611-100000@hkn.eecs.berkeley.edu> <01062923224700.04540@yatsu>
Message-ID: <01063000371801.04540@yatsu>

On Friday 29 June 2001 23:22, you wrote:
> On Friday 29 June 2001 23:07, you wrote:
> > On Fri, 29 Jun 2001, Brendon wrote:
> > > Now that i've been through the tutorial on
> > > http://www.crosswinds.net/~agauld/
> > >
> > > I'm not sure where to go next. I want to learn more about GUI object
> > > orientated programming with Tk/Tkinter. I've only be able to find two
> > > tutorials for Tk/Tkinter and both were not OO.
> >
>
> > Also, you can ask us for examples of OOP'ed GUI's, and we'll be glad to
> > oblige.  What sort of program do you want to write?
>
> Well, eventually i want to be able to write a simple jabber client (not
> using any code from pybber) and although i'd rather do it in qt/kde there
> doesn't seem to be a python binding for kde2, so Tkinter it will be.
>

suppose i should be a little more specific.

what i need is:

a) a way to gather information from an entry textbox 

b) a way to create a tcp connection to a given port

and c) a way to parse xml

Brendon
-- 

"if we live by an "eye for an eye and a tooth for a tooth"...before long, 
the whole world will be blind and toothless." 
         --Tevye, Fiddler on the Roof


From DgallatinG@netscape.net  Sat Jun 30 00:58:02 2001
From: DgallatinG@netscape.net (Daryl Gallatin)
Date: Fri, 29 Jun 2001 19:58:02 -0400
Subject: [Tutor] socketserver
Message-ID: <21E1608F.5D5200CD.0AE436B3@netscape.net>

Hi, are there any examples anywhere that use socketserver besides the Programming Python book by Mark Lutz



I'm trying to write a chat program, so I need to use the socketserver module so multiple clients can connect to the server at the same time.

Also, since this is gui based, is there a method in the TK widgets that make the window priority so it will appear above any other windows that may be on screen ?

Thanks
__________________________________________________________________
Get your own FREE, personal Netscape Webmail account today at http://webmail.netscape.com/


From dyoo@hkn.eecs.berkeley.edu  Sat Jun 30 01:04:09 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 29 Jun 2001 17:04:09 -0700 (PDT)
Subject: [Tutor] OOP with Tk/Tkinter
In-Reply-To: <01063000371801.04540@yatsu>
Message-ID: <Pine.LNX.4.21.0106291642180.32520-100000@hkn.eecs.berkeley.edu>

On Sat, 30 Jun 2001, Brendon wrote:

> > > Also, you can ask us for examples of OOP'ed GUI's, and we'll be glad to
> > > oblige.  What sort of program do you want to write?
> >
> > Well, eventually i want to be able to write a simple jabber client (not
> > using any code from pybber) and although i'd rather do it in qt/kde there
> > doesn't seem to be a python binding for kde2, so Tkinter it will be.
> 
> suppose i should be a little more specific.

> a) a way to gather information from an entry textbox 


Here's an example of using an Tkinter Entry:

###
from Tkinter import *

class GUI(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        Label(self, text="Enter something here:").pack(side=LEFT)
        self.textvariable = StringVar()
        Entry(self, textvariable=self.textvariable).pack(side=LEFT)
        Button(self, text="Run Command",
               command=self.doIt).pack(side=LEFT)

    def doIt(self):
        print "We should do something here."
        print "Here's what our entry contained: ", self.textvariable.get()


if __name__ == '__main__':
    root = Tk()
    GUI(root).pack(side=TOP)
    mainloop()
###



You'll also find some of Python's library modules useful for your
program.

> b) a way to create a tcp connection to a given port

You'll probably want to use the 'socket' module for this one:

    http://python.org/doc/lib/module-socket.html



> and c) a way to parse xml

and xml.sax to parse Jabber XML tags:

    http://python.org/doc/lib/module-xml.sax.html


Hope this helps!



From tim.one@home.com  Sat Jun 30 01:20:38 2001
From: tim.one@home.com (Tim Peters)
Date: Fri, 29 Jun 2001 20:20:38 -0400
Subject: [Tutor] Dining Philosophers
Message-ID: <LNBBLJKPBEHFEDALKOLCAEIPKLAA.tim.one@home.com>

Someone recently asked to see a Dining Philosphers solution in Python.
Finally found it:

    http://aspn.activestate.com/ASPN/Mail/Message/249937

People who aren't interested in academic exercises involving threads,
philosophers and spaghetti should run the other way <wink>.




From deirdre@deirdre.net  Sat Jun 30 01:34:00 2001
From: deirdre@deirdre.net (Deirdre Saoirse Moen)
Date: Fri, 29 Jun 2001 17:34:00 -0700
Subject: [Tutor] Dining Philosophers
In-Reply-To: <LNBBLJKPBEHFEDALKOLCAEIPKLAA.tim.one@home.com>
References: <LNBBLJKPBEHFEDALKOLCAEIPKLAA.tim.one@home.com>
Message-ID: <a0510100fb762cd2badb4@[10.0.1.7]>

>Someone recently asked to see a Dining Philosphers solution in Python.
>Finally found it:
>
>     http://aspn.activestate.com/ASPN/Mail/Message/249937
>
>People who aren't interested in academic exercises involving threads,
>philosophers and spaghetti should run the other way <wink>.

Very cool. I'd never seen any Ruby before really (like I need another 
programming language in my life atm), but the comparison here was 
especially interesting.

-- 
_Deirdre    Stash-o-Matic: http://weirdre.com    http://deirdre.net
"Cannot run out of time.... Is infinite time. You... are finite....
Zathrus... is finite. This... is wrong tool!" -- Zathrus


From rtyuio@korea.com  Fri Jun 29 20:51:01 2001
From: rtyuio@korea.com (rtyuio@korea.com)
Date: Åä, 30 6 2001 09:51:22
Subject: [Tutor] ±¤°í¸áÀÔ´Ï´Ùº¸Áö¸¶¼¼¿ä
Message-ID: <340.485989.649316@korea.com>

ÃÖ½ÅÇüPC
CPU¡¦¡¦¡¦.933 (ÀÎÅÚ)
RAM¡¦¡¦¡¦128 (»ï¼ºÁ¤Ç°133)
HDD¡¦¡¦¡¦20 G
MONITER.17"(»ï¼º77E)

¸ðµÎ43¸¸¿ø

°ü½ÉÀÖÀ¸¼¼¿ä

 http://comzon.atozpia.com/news/news.html

À̸®·Î ¿À¼¼¿ä


From rob@jam.rr.com  Sat Jun 30 03:03:29 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Fri, 29 Jun 2001 21:03:29 -0500
Subject: [Tutor] URLs for urllib.urlopen
In-Reply-To: <Pine.LNX.4.21.0106290935560.26119-100000@hkn.eecs.berkeley.edu>
Message-ID: <NFBBKIELCLIEEMGGIGKDKEJBCAAA.rob@jam.rr.com>

It dumped a page of HTML into my PythonWin window when I copied and pasted
from this code directly into mine. This is what it looked like:

PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see
'Help/About PythonWin' for further copyright information.
>>> import urllib, pprint
>>> page = urllib.urlopen('http://www.python.org')
>>> data = page.readlines()
>>> pprint.pprint(data)
['<HTML>\n',
 '<!-- THIS PAGE IS AUTOMATICALLY GENERATED.  DO NOT EDIT. -->\n',
 '<!-- Thu Jun 28 15:47:15 2001 -->\n',
# snip

Rob

"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/

# -----Original Message-----
# From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
# Danny Yoo
# Sent: Friday, June 29, 2001 11:40 AM
# To: Simon Brunning
# Cc: Python Tutor (E-mail); Mark Gash
# Subject: Re: [Tutor] URLs for urllib.urlopen
#
#
# On Fri, 29 Jun 2001, Simon Brunning wrote:
#
# > Can someone explain this to me?
# >
# > PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)]
# on win32.
# > Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see
# > 'Help/About PythonWin' for further copyright information.
# > >>> import urllib, pprint
# > >>> page = urllib.urlopen('http://www.python.org')
# > >>> data = page.readlines()
# > >>> pprint.pprint(data)
# > ['<html><head><title>Error</title></head><body>The parameter is
# incorrect.
# > </body></html>']
#
# Very strange!  This seems to work for me, trailing slash or not.  Can you
# check to see if that error happens again?  Does anyone else know what
# would cause the above?
#
#
#
# _______________________________________________
# Tutor maillist  -  Tutor@python.org
# http://mail.python.org/mailman/listinfo/tutor



From pd@localhost.localdomain  Sat Jun 30 04:38:16 2001
From: pd@localhost.localdomain (pd)
Date: Sat, 30 Jun 2001 13:38:16 +1000 (EST)
Subject: [Tutor] Getting my IP
Message-ID: <Pine.LNX.4.21.0106301320460.1846-100000@localhost.localdomain>

Hi,
   Im writing a script that posts IP number to a page on my website. This
script is nearly complete except I cannot figure out how to actually get 
my IP address. I have tried using the socket module, but it  appears that
this justs takes a look in my /etc/hosts file. What I need is my dynamic
IP that gets assigned every time I connect to the net.



Python 2.0 (#1, Apr 11 2001, 19:18:08) 
[GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux-i386
Type "copyright", "credits" or "license" for more information.
>>> from socket import *
>>> gethostbyname(gethostname())
'127.0.0.1'
>>> gethostbyaddr(gethostname())
('localhost.localdomain', ['localhost'], ['127.0.0.1'])
>>> gethostbyname('kaneda')
'127.0.0.1'
>>> getfqdn()
'localhost.localdomain'
>>> gethostnyname('kaneda')




[pd@localhost pd]$ cat /etc/hosts
127.0.0.1		localhost.localdomain localhost
127.0.0.1		localhost.localdomain kaneda
[pd@localhost pd]$ 




From sheila@thinkspot.net  Sat Jun 30 04:54:26 2001
From: sheila@thinkspot.net (Sheila King)
Date: Fri, 29 Jun 2001 20:54:26 -0700
Subject: [Tutor] Getting my IP
In-Reply-To: <Pine.LNX.4.21.0106301320460.1846-100000@localhost.localdomain>
References: <Pine.LNX.4.21.0106301320460.1846-100000@localhost.localdomain>
Message-ID: <B6597D85752@kserver.org>

On Sat, 30 Jun 2001 13:38:16 +1000 (EST), pd <pd@localhost.localdomain>
wrote about [Tutor] Getting my IP:

:Hi,
:   Im writing a script that posts IP number to a page on my website. This
:script is nearly complete except I cannot figure out how to actually get 
:my IP address. I have tried using the socket module, but it  appears that
:this justs takes a look in my /etc/hosts file. What I need is my dynamic
:IP that gets assigned every time I connect to the net.

What you want to use, are the environment variables from your CGI
script.

Here is a CGI script that will post all the environment variables, plus
some other stuff:

---------------------------------------------------------
#!/usr/bin/env python

import os

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

print "<html>\n"

print "<Head>"
print "<Title>Obligatory Python Test Script</Title>"
print "</Head>\n"

print "<Body>\n"
print "<H3>Hello</H3>"
print "<b>This is the obligatory<br> Python 'Hello\' test
script<br></b>"
print "<i>Ta-da</i><br><br>"

print "NEW STUFF: testing environment variables<br>"
print os.environ["REMOTE_ADDR"],"<br><br>"
print "<p>And now, all the environment variables:<br>"
print "<b>",
for el in os.environ.keys():
	print el, " = ", os.environ[el], "<br>"
print "</b>"
print "THE END"

print "</body>\n</html>"
---------------------------------------------------------

It should display your IP number. You can see this script run here:
http://www.thinkspot.net/cgi-bin/pytestscriptenviron.py
Notice that the environment variable you need is REMOTE_ADDR.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/


From gibbs05@flash.net  Sat Jun 30 05:36:11 2001
From: gibbs05@flash.net (Archimedes)
Date: Fri, 29 Jun 2001 23:36:11 -0500
Subject: [Tutor] Getting my IP
References: <Pine.LNX.4.21.0106301320460.1846-100000@localhost.localdomain>
Message-ID: <003701c1011e$354a6840$93dd3040@gibbs05>

----- Original Message -----
From: "pd" <pd@localhost.localdomain>
To: <tutor@python.org>
Sent: Friday, June 29, 2001 10:38 PM
Subject: [Tutor] Getting my IP


> Hi,
>    Im writing a script that posts IP number to a page on my website. This
> script is nearly complete except I cannot figure out how to actually get
> my IP address. I have tried using the socket module, but it  appears that
> this justs takes a look in my /etc/hosts file. What I need is my dynamic
> IP that gets assigned every time I connect to the net.

If you have CGI access on your site, Sheila's method is the best way to do
this.

Otherwise there are many web servers that have scripts to echo your IP
address back to you.  Calliope has a script for this at
http://www.scaper.com/cgi-bin/addr.cgi  It returns simple text; your address
followed by a newline character.

Here's a brute force example:

>>> import urllib
>>> print urllib.urlopen('http://www.scaper.com/cgi-bin/addr.cgi').read()
64.48.221.147

Just an option.


Sam




From sheila@thinkspot.net  Sat Jun 30 05:56:06 2001
From: sheila@thinkspot.net (Sheila King)
Date: Fri, 29 Jun 2001 21:56:06 -0700
Subject: [Tutor] Getting my IP
In-Reply-To: <003701c1011e$354a6840$93dd3040@gibbs05>
References: <Pine.LNX.4.21.0106301320460.1846-100000@localhost.localdomain> <003701c1011e$354a6840$93dd3040@gibbs05>
Message-ID: <B9DFBCB6F53@kserver.org>

On Fri, 29 Jun 2001 23:36:11 -0500, "Archimedes" <gibbs05@flash.net>
wrote about Re: [Tutor] Getting my IP:

:If you have CGI access on your site, Sheila's method is the best way to do
:this.
:
:Otherwise there are many web servers that have scripts to echo your IP
:address back to you.  Calliope has a script for this at
:http://www.scaper.com/cgi-bin/addr.cgi  It returns simple text; your address
:followed by a newline character.
:
:Here's a brute force example:
:
:>>> import urllib
:>>> print urllib.urlopen('http://www.scaper.com/cgi-bin/addr.cgi').read()
:64.48.221.147
:
:Just an option.

Actually, I think I may have misunderstood what he was asking for. Maybe
he is not running a CGI script at all. (He never mentions CGI in his
original post.)

Anyhow, maybe what you want is this command from the socket module:
getpeername()

documentation says:
"Return the remote address to which the socket is connected. This is
useful to find out the port number of a remote IP socket, for instance.
(The format of the address returned depends on the address family -- see
above.) On some systems this function is not supported."

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




From pd@localhost.localdomain  Sat Jun 30 07:31:15 2001
From: pd@localhost.localdomain (pd)
Date: Sat, 30 Jun 2001 16:31:15 +1000 (EST)
Subject: [Tutor] Getting my IP
Message-ID: <Pine.LNX.4.21.0106301547541.1396-100000@localhost.localdomain>

Hi,
   I dont think I made myself clear when I posted my original
message. The purpose of the script is to post the ip address
of my home pc to a webpage running on a remote host. This is what is going
on.

1. I execute the script on my home pc.
2. The script fetches a html page from the web.
3. It reads the html page into a list.
4. It searches the list for a specific point (<!--IP-->) .
5. It inserts my IP address into the list after the marker.
6. It writes the processed list to a html file.
7. It sends this modified html file via ftp to
my webpage.

Any details that I need to enter are stored inside a config file which the
script accesses It is almost done except I cannot figure out how to find
out what *my* ip address is. Up until now I have just included it as a
variable (myIP = 218.13.23.45) for testing purposes. When I use 
the following line of code, I get my loopback address, as opposed to my 
dynamic IP address.

>>> from socket import *
>>> gethostbyname(gethostname())
'127.0.0.1'


I do not know much about networking/programming/sockets so detailed
answers will be greatly appreciated. I am using python 2.0, on a linux
box. 



From daniel@longbeach.goldinc.com  Sat Jun 30 08:03:10 2001
From: daniel@longbeach.goldinc.com (Daniel)
Date: Sat, 30 Jun 2001 02:03:10 -0500 (CDT)
Subject: [Tutor] Getting my IP
In-Reply-To: <Pine.LNX.4.21.0106301547541.1396-100000@localhost.localdomain>
Message-ID: <Pine.LNX.3.93.1010630015812.29760B-100000@longbeach.goldinc.com>

This is the first thing that came to my mind,  you might have to replace
the interface to match with yours and change the slicing but you
should still get the idea of what I'm doing,  just a cheesy os.popen  :)

>>> import os
>>> ip = os.popen('/sbin/ifconfig eth0 |grep inet').read()[20:-37]
>>> ip
'10.0.1.3  '



					--
					DEV


On Sat, 30 Jun 2001, pd wrote:

> Hi,
>    I dont think I made myself clear when I posted my original
> message. The purpose of the script is to post the ip address
> of my home pc to a webpage running on a remote host. This is what is going
> on.
> 
> 1. I execute the script on my home pc.
> 2. The script fetches a html page from the web.
> 3. It reads the html page into a list.
> 4. It searches the list for a specific point (<!--IP-->) .
> 5. It inserts my IP address into the list after the marker.
> 6. It writes the processed list to a html file.
> 7. It sends this modified html file via ftp to
> my webpage.
> 
> Any details that I need to enter are stored inside a config file which the
> script accesses It is almost done except I cannot figure out how to find
> out what *my* ip address is. Up until now I have just included it as a
> variable (myIP = 218.13.23.45) for testing purposes. When I use 
> the following line of code, I get my loopback address, as opposed to my 
> dynamic IP address.
> 
> >>> from socket import *
> >>> gethostbyname(gethostname())
> '127.0.0.1'
> 
> 
> I do not know much about networking/programming/sockets so detailed
> answers will be greatly appreciated. I am using python 2.0, on a linux
> box. 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



From pd@localhost.localdomain  Sat Jun 30 11:29:21 2001
From: pd@localhost.localdomain (pd)
Date: Sat, 30 Jun 2001 20:29:21 +1000 (EST)
Subject: [Tutor] Getting my IP
In-Reply-To: <Pine.LNX.3.93.1010630015812.29760B-100000@longbeach.goldinc.com>
Message-ID: <Pine.LNX.4.21.0106302018290.1460-100000@localhost.localdomain>

On Sat, 30 Jun 2001, Daniel wrote:
Thanks,
	This did the trick. Although I have been a user of unix
systems for a couple of years, I only recently switched to linux for my
home computing. I didnt know about the ifconfig command. Needless to say,
it looks like I will be having a look at the os module tonight.


> This is the first thing that came to my mind,  you might have to replace
> the interface to match with yours and change the slicing but you
> should still get the idea of what I'm doing,  just a cheesy os.popen  :)
> 
> >>> import os
> >>> ip = os.popen('/sbin/ifconfig eth0 |grep inet').read()[20:-37]
> >>> ip
> '10.0.1.3  '
> 
> 
> 
> 					--
> 					DEV
> 
> 
> On Sat, 30 Jun 2001, pd wrote:
> 
> > Hi,
> >    I dont think I made myself clear when I posted my original
> > message. The purpose of the script is to post the ip address
> > of my home pc to a webpage running on a remote host. This is what is going
> > on.
> > 
> > 1. I execute the script on my home pc.
> > 2. The script fetches a html page from the web.
> > 3. It reads the html page into a list.
> > 4. It searches the list for a specific point (<!--IP-->) .
> > 5. It inserts my IP address into the list after the marker.
> > 6. It writes the processed list to a html file.
> > 7. It sends this modified html file via ftp to
> > my webpage.
> > 
> > Any details that I need to enter are stored inside a config file which the
> > script accesses It is almost done except I cannot figure out how to find
> > out what *my* ip address is. Up until now I have just included it as a
> > variable (myIP = 218.13.23.45) for testing purposes. When I use 
> > the following line of code, I get my loopback address, as opposed to my 
> > dynamic IP address.
> > 
> > >>> from socket import *
> > >>> gethostbyname(gethostname())
> > '127.0.0.1'
> > 
> > 
> > I do not know much about networking/programming/sockets so detailed
> > answers will be greatly appreciated. I am using python 2.0, on a linux
> > box. 
> > 
> > 
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> > 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



From bill-bell@bill-bell.hamilton.on.ca  Sat Jun 30 13:48:14 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Sat, 30 Jun 2001 08:48:14 -0400
Subject: [Tutor] Re: URLs for urllib.urlopen
In-Reply-To: <E15G0hw-0004Yy-00@mail.python.org>
Message-ID: <3B3D924E.851.20FB3BE@localhost>

Simon Brunning <SBrunning@trisystems.co.uk> wrote:
> Can someone explain this to me?
> 
> PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on
> win32. Portions Copyright 1994-2001 Mark Hammond
> (MarkH@ActiveState.com) - see 'Help/About PythonWin' for further
> copyright information. >>> import urllib, pprint >>> page =
> urllib.urlopen('http://www.python.org') >>> data = page.readlines()
> >>> pprint.pprint(data)
> ['<html><head><title>Error</title></head><body>The parameter is
> incorrect. </body></html>'] >>> page =
> urllib.urlopen('http://www.python.org/') >>> data = page.readlines()
> >>> pprint.pprint(data) ['<HTML>\n',
>  '<!-- THIS PAGE IS AUTOMATICALLY GENERATED.  DO NOT EDIT. -->\n',
> (... snip)
> 
> It appears that urllib requires a trailing slash, but in the examples
> in the effbot's PSL book, he doesn't give one. Any ideas?

Simon, I just executed the lines of code in PythonWin (ActiveState 
build 203) without the trailing slash and received the following 

>>> import urllib, pprint
>>> page = urllib.urlopen('http://www.python.org')
>>> data = page.readlines()
>>> pprint.pprint(data)
['<HTML>\n',
 '<!-- THIS PAGE IS AUTOMATICALLY GENERATED.  DO NOT 
EDIT. -->\n',
 '<!-- Thu Jun 28 15:47:15 2001 -->\n',
 '<!-- USING HT2HTML 1.1 -->\n',
<SNIP>

Or, IOW, worked for me. Possible transient error at python.org? Or 
that you're using an earlier version of Python?

Bill


From pd@localhost.localdomain  Sat Jun 30 16:12:51 2001
From: pd@localhost.localdomain (pd)
Date: Sun, 1 Jul 2001 01:12:51 +1000 (EST)
Subject: [Tutor] Getting my IP
Message-ID: <Pine.LNX.4.21.0107010107370.1379-100000@localhost.localdomain>


---------- Forwarded message ----------
Thanks,
	After changing the slice it did the trick. Although I have been a
user of unix systems for a couple of years, I only recently switched to linux for my 
home computing. I didnt know about the ifconfig command. Needless to say,
it looks like I will be having a look at the os module tonight.


> This is the first thing that came to my mind,  you might have to replace
> the interface to match with yours and change the slicing but you
> should still get the idea of what I'm doing,  just a cheesy os.popen  :)
> 
> >>> import os
> >>> ip = os.popen('/sbin/ifconfig eth0 |grep inet').read()[20:-37]
> >>> ip
> '10.0.1.3  '
> 
> 
> 
> 					--
> 					DEV
> 
> 
> On Sat, 30 Jun 2001, pd wrote:
> 
> > Hi,
> >    I dont think I made myself clear when I posted my original
> > message. The purpose of the script is to post the ip address
> > of my home pc to a webpage running on a remote host. This is what is going
> > on.
> > 
> > 1. I execute the script on my home pc.
> > 2. The script fetches a html page from the web.
> > 3. It reads the html page into a list.
> > 4. It searches the list for a specific point (<!--IP-->) .
> > 5. It inserts my IP address into the list after the marker.
> > 6. It writes the processed list to a html file.
> > 7. It sends this modified html file via ftp to
> > my webpage.
> > 
> > Any details that I need to enter are stored inside a config file which the
> > script accesses It is almost done except I cannot figure out how to find
> > out what *my* ip address is. Up until now I have just included it as a
> > variable (myIP = 218.13.23.45) for testing purposes. When I use 
> > the following line of code, I get my loopback address, as opposed to my 
> > dynamic IP address.
> > 
> > >>> from socket import *
> > >>> gethostbyname(gethostname())
> > '127.0.0.1'
> > 
> > 
> > I do not know much about networking/programming/sockets so detailed
> > answers will be greatly appreciated. I am using python 2.0, on a linux
> > box. 
> > 
> > 
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> > 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 




From budgester@budgester.com  Sat Jun 30 21:23:45 2001
From: budgester@budgester.com (Martin Stevens)
Date: Sat, 30 Jun 2001 21:23:45 +0100
Subject: [Tutor] OOP with Tk/Tkinter
In-Reply-To: <01063000371801.04540@yatsu>; from bren@europe.nl.com on Sat, Jun 30, 2001 at 12:37:18AM +0200
References: <Pine.LNX.4.21.0106291403180.29611-100000@hkn.eecs.berkeley.edu> <01062923224700.04540@yatsu> <01063000371801.04540@yatsu>
Message-ID: <20010630212345.A279@budgester.com>

On Sat, Jun 30, 2001 at 12:37:18AM +0200, Brendon wrote:
> suppose i should be a little more specific.
> 
> what i need is:
> 
> a) a way to gather information from an entry textbox 
> 

For this bit I have a script on useless python that would do this
the rest of it I haven't done yet.

Martin Stevens


From michael@trollope.org  Sat Jun 30 20:37:48 2001
From: michael@trollope.org (M.A. Powe)
Date: Sat, 30 Jun 2001 12:37:48 -0700
Subject: [Tutor] OT: HTDP
In-Reply-To: <01062718274601.05253@tygesen> (message from Chris Keelan on Wed,
 27 Jun 2001 18:27:46 -0500)
References: <01062718274601.05253@tygesen>
Message-ID: <200106301937.f5UJbmw04856@cecilia.trollope.org>

>>>>> "Chris" == Chris Keelan <rufmetal@home.com> writes:

    Chris> As the "general programming question" thread revealed, the
    Chris> htdp.org people are having trouble with their domain and
    Chris> "How To Design Programs" is temporarily unavailable.

    Chris> I had snarfed the site a while ago and I've put the tarball
    Chris> on my personal site at http://members.home.net/rufmetal ,
    Chris> which I'll leave up until the official version of the book
    Chris> comes back online.

    Chris> Hope that helps those who are interested.

I picked it up, thanks.  I'd like the paper version but at $65 I have
to be ... prudent.  ;-)

mp

-- 
  Michael Powe                                 Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.'  -- Hilary Rosen, President, Recording Industry Association
of America