From abu@trabas.co.id  Tue May  2 07:38:08 2000
From: abu@trabas.co.id (Abu Hudzaefah)
Date: Tue, 02 May 2000 13:38:08 +0700
Subject: [Tutor] sme
Message-ID: <390E77D0.2FE53BE4@trabas.co.id>




From bc@intelinside.com  Tue May  2 12:04:57 2000
From: bc@intelinside.com (bart)
Date: Tue, 2 May 2000 07:04:57 -0400
Subject: [Tutor] sme
References: <390E77D0.2FE53BE4@trabas.co.id>
Message-ID: <000701bfb426$408e7ca0$100e000a@unitedbank.net>

how do i get a python program to talk to the application layer of the osi
model via tcp/ip?

----- Original Message -----
From: "Abu Hudzaefah" <abu@trabas.co.id>
To: <tutor@python.org>
Sent: Tuesday, May 02, 2000 2:38 AM
Subject: [Tutor] sme


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



From kmoulfi@emirates.net.ae  Tue May  2 15:03:16 2000
From: kmoulfi@emirates.net.ae (Khalid MOULFI)
Date: Tue, 02 May 2000 18:03:16 +0400
Subject: [Tutor] Python source installation v1.5.2 on AIX 4.2.1.0 !
Message-ID: <1.5.4.32.20000502140316.0066a91c@emirates.net.ae>

Hi every body,

following the download of python source v1.5.2 from the python.org site, I
tried to compile it on RS6000 IBM machine with AIX 4.2.1.0.  
I did not find any solution on help or FAQ python site.
I launched the ./configure command but I had this message :
=========
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

configure:608: checking MACHDEP...aix4
configure:653: checking CCC...
configure:669: checking for --without-gcc...no
configure:746: checking for gcc...no
configure:776: checking for cc...no
configure: error: no acceptable cc found in $PATH
=========

I tried to launch with the options : ./configure --without-gcc and I had this :

Output on the screen :
creating cache ./config.cache
checking MACHDEP... aix4
checking CCC... 
checking for --without-gcc... yes
checking for gcc... cc
checking whether the C compiler (cc  ) works... no
configure: error: installation or configuration problem: C compiler cannot
create  executables.
=============================================
Output in the config.log :

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

configure:608: checking MACHDEP
configure:653: checking CCC
configure:669: checking for --without-gcc
configure:746: checking for gcc
configure:859: checking whether the C compiler (cc  ) works
configure:875: cc -o conftest    conftest.c  1>&5
./configure[874]: cc:  not found
configure: failed program was:

#line 870 "configure"
#include "confdefs.h"

main(){return(0);}
=================
If you have any solution I would really appreciate.

Thank you.

Khalid







From arcege@shore.net  Tue May  2 18:00:38 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Tue, 2 May 2000 13:00:38 -0400 (EDT)
Subject: [Tutor] Python source installation v1.5.2 on AIX 4.2.1.0 !
In-Reply-To: <1.5.4.32.20000502140316.0066a91c@emirates.net.ae> from "Khalid MOULFI" at May 02, 2000 06:03:16 PM
Message-ID: <200005021700.NAA05975@northshore.shore.net>

> following the download of python source v1.5.2 from the python.org site, I
> tried to compile it on RS6000 IBM machine with AIX 4.2.1.0.  
> I did not find any solution on help or FAQ python site.

There are AIX specific notes in Misc/AIX-NOTES.

  -Arcege

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


From ivanlan@home.com  Wed May  3 13:25:04 2000
From: ivanlan@home.com (Ivan Van Laningham)
Date: Wed, 03 May 2000 06:25:04 -0600
Subject: [Tutor] Teach Yourself Python Book/Website
Message-ID: <39101AA0.CBA45BD0@home.com>

Hi All--
Just a little BSP here. ...

1)  I finally got to see my book in an actual bookstore here in Salt
Lake City.  Sam Weller's, in downtown, had a copy.  They had a Perl book
faceout, so I replaced it with mine;-)  Barnes & Noble and Borders, both
having several stores in the area, had no copies and couldn't find it
their databases;-(

2)  Those of you who, for whatever misguided reason, wish to visit the
book's website and are having trouble because pauahtun.org isn't
responding or isn't in the nameserver tables, may do so at the below
URL:

	http://63.64.27.76/TYPython/

I'm no longer working for Callware, who used to provide a connection to
the internet for my server.  I'm putting up a new server today at one of
our local ISPs, Aros.net, so in a little while the real address,

	http://www.pauahtun.org/TYPython/

will start to be resolvable as the new IP records start to percolate
through the nameservers on the net.

The IP address above will only work for about a week.

<wink-wink-nudge-nudge>-ly y'rs,
Ivan
----------------------------------------------
Ivan Van Laningham
Axent, Inc.
http://www.pauahtun.org and
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours


From alan.gauld@bt.com  Wed May  3 14:37:07 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 3 May 2000 14:37:07 +0100
Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D0DF@mbtlipnt02.btlabs.bt.co.uk>

>> I was planning my own book for absolute programming beginners,
>> and I have an offer to do that. Would you say this makes still
>> sense after your work, or do you know whether someone else
>> is already writing such a thing?
> 
>
> Alan Gauld is writing one, I think.

Yes, Just back from vacation which I spent proof reading 
the 'final' (never say final ;-) draft.

I'm hoping it will be out before the end of the year.

Since last mentioned I have dropped the VB and JScript 
bits at the request of the reviewers so its now purely 
Python(and a couple of other snippets in QBASIC where Python 
wouldn't quite hack it - demonstrating GOTO and INKEY$ etc).

I have Ivan's book on order and it should be with me soon 
so I'll be able to say how much overlap there is when I see it!

Alan G.

PS. The other book I read on holiday was The Pragmatic Programmer
on Addison Wesley - highly recommended to anyone who has passed 
the complete newbie phase.


From deirdre@deirdre.net  Wed May  3 18:57:17 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Wed, 3 May 2000 10:57:17 -0700 (PDT)
Subject: Beginning Python books was Re: [Tutor] _Teach_Yourself_Python_in_24_Hours_
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D0DF@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.LNX.4.10.10005031056220.19287-100000@rockhopper.deirdre.org>

On Wed, 3 May 2000 alan.gauld@bt.com wrote:

> >> I was planning my own book for absolute programming beginners,
> >> and I have an offer to do that. Would you say this makes still
> >> sense after your work, or do you know whether someone else
> >> is already writing such a thing?
> >
> > Alan Gauld is writing one, I think.
> 
> Yes, Just back from vacation which I spent proof reading 
> the 'final' (never say final ;-) draft.

I'm pleased to announce that my coauthor Robert Doiel and I have just
received the contracts from IDG for "Python for Dummies."

-- 
_Deirdre   *   http://www.linuxcabal.org   *   http://www.deirdre.net
"Dictators ride to and fro upon tigers which they dare not dismount.
 And the tigers are getting hungry." -- Winston Churchill



From ddfarms@earthlink.net  Wed May  3 18:57:07 2000
From: ddfarms@earthlink.net (DDFarms)
Date: Wed, 03 May 2000 12:57:07 -0500
Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20751D0DF@mbtlipnt02.btlabs
 .bt.co.uk>
Message-ID: <4.3.2.20000503125122.00be7f00@mail.earthlink.net>

At 02:37 PM 5/3/00 +0100, alan.gauld@bt.com wrote: [About his new book.] . . .
>I have Ivan's book on order and it should be with me soon
>so I'll be able to say how much overlap there is when I see it!

Says DD: Go for it. Who buys just one book to learn from? The different 
approaches speed learning. I like Ivan's book. But I blame him personally 
for getting me into Python. (Thank you Ivan for so doing.) Uh, I hope your 
book tells how to get out.



From ddfarms@earthlink.net  Wed May  3 19:24:25 2000
From: ddfarms@earthlink.net (DDFarms)
Date: Wed, 03 May 2000 13:24:25 -0500
Subject: [Tutor] Re: Beginning Python books
In-Reply-To: <Pine.LNX.4.10.10005031056220.19287-100000@rockhopper.deird
 re.org>
References: <5104D4DBC598D211B5FE0000F8FE7EB20751D0DF@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <4.3.2.20000503132048.00b02f00@mail.earthlink.net>

At 10:57 AM 5/3/00 -0700, Deirdre Saoirse wrote:

>I'm pleased to announce that my coauthor Robert Doiel and I have just
>received the contracts from IDG for "Python for Dummies."

Says DD: Why do I get the feeling that either this group is having too much 
fun, or there is a really big interest in Python? I want all of those 
books. Ivan's I already have. I like it. Alan's I want. But Python for 
Dummies, is a must buy. Best, DD



From ivanlan@home.com  Wed May  3 19:26:37 2000
From: ivanlan@home.com (Ivan Van Laningham)
Date: Wed, 03 May 2000 12:26:37 -0600
Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_
References: <4.3.2.20000503125122.00be7f00@mail.earthlink.net>
Message-ID: <39106F5D.6945CEE1@home.com>

Hi All--

DDFarms wrote:
> 
> At 02:37 PM 5/3/00 +0100, alan.gauld@bt.com wrote: [About his new book.] . . .
> >I have Ivan's book on order and it should be with me soon
> >so I'll be able to say how much overlap there is when I see it!
> 
> Says DD: Go for it. Who buys just one book to learn from? The different
> approaches speed learning. I like Ivan's book. But I blame him personally
> for getting me into Python. (Thank you Ivan for so doing.) Uh, I hope your
> book tells how to get out.
> 

Nope, sorry. Once you're in it, you're hooked for life.

<walk-this-way>-ly y'rs,
Ivan;-)
----------------------------------------------
Ivan Van Laningham
Axent, Inc.
http://www.pauahtun.org and
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours


From ivanlan@home.com  Wed May  3 19:28:48 2000
From: ivanlan@home.com (Ivan Van Laningham)
Date: Wed, 03 May 2000 12:28:48 -0600
Subject: [Tutor] Re: Beginning Python books was Re: [Tutor]
 _Teach_Yourself_Python_in_24_Hours_
References: <Pine.LNX.4.10.10005031056220.19287-100000@rockhopper.deirdre.org>
Message-ID: <39106FE0.A2768A1D@home.com>

Hi All--

Deirdre Saoirse wrote:
> 
> On Wed, 3 May 2000 alan.gauld@bt.com wrote:
> 
> > >> I was planning my own book for absolute programming beginners,
> > >> and I have an offer to do that. Would you say this makes still
> > >> sense after your work, or do you know whether someone else
> > >> is already writing such a thing?
> > >
> > > Alan Gauld is writing one, I think.
> >
> > Yes, Just back from vacation which I spent proof reading
> > the 'final' (never say final ;-) draft.
> 
> I'm pleased to announce that my coauthor Robert Doiel and I have just
> received the contracts from IDG for "Python for Dummies."
> 

Congratulations!  The more the merrier!  Python world domination. ...

<we'll-suck-them-all-in-yet>-ly y'rs,
Ivan
----------------------------------------------
Ivan Van Laningham
Axent, Inc.
http://www.pauahtun.org and
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours


From ksipos@netaxs.com  Wed May  3 20:00:40 2000
From: ksipos@netaxs.com (kalak)
Date: Wed, 3 May 2000 15:00:40 -0400 (EDT)
Subject: [Tutor] Re: Real time vector maps via browser
Message-ID: <200005031900.PAA21222@mail.netaxs.com>

 
>I am trying to put vector maps on the web  intranet.
>

I would like to put autocad, microstation, mapinfo, esri
maps and photographs on the intranet for editing and updating.

Has anyone used Python for this effort

Any assitance appreciated.


>thanks
>
>
>Ken
>Philadelphia
>ksipos@netaxs.com
>
 



From ohad_ho@zahav.net.il  Fri May  5 21:12:13 2000
From: ohad_ho@zahav.net.il (ohad_ho)
Date: Fri, 05 May 2000 22:12:13 +0200
Subject: [Tutor] using PlaySound
Message-ID: <39132B1D.B7CC247A@zahav.net.il>

Can someone please give an example of using the PlaySound function?
Should I include any any file in the begin of the program (I came from C
programming..)
Thanks.



From kevin@vcn.bc.ca  Wed May 10 02:21:59 2000
From: kevin@vcn.bc.ca (Kevin Liang)
Date: Tue, 9 May 2000 21:21:59 -0400
Subject: [Tutor] importance of quotes ..
In-Reply-To: <20000504160010.D3D001CDA4@dinsdale.python.org>; from tutor-request@python.org on Thu, May 04, 2000 at 12:00:10PM -0400
References: <20000504160010.D3D001CDA4@dinsdale.python.org>
Message-ID: <20000509212159.A2771@vcn.bc.ca>

Hi all,
	I was just working on ch.6, exercise 2  of Learning Python.  I 
came to the point when I had copied word-for-word the answer to the question 
(or so I thought), yet it still refused to run properly.. then I looked carefully,
and noticed a *return* statement had '''' quotes instead of `````.  I changed
it , and it worked..  Now, I'm a little confused as to why this is so important..
I'm always bogged down on things like this.  thanks

kevin 


From zarie@ucc.gu.uwa.edu.au  Wed May 10 05:38:18 2000
From: zarie@ucc.gu.uwa.edu.au (Tracey Brown)
Date: Wed, 10 May 2000 12:38:18 +0800 (WST)
Subject: [Tutor] importance of quotes ..
In-Reply-To: <20000509212159.A2771@vcn.bc.ca>
Message-ID: <Pine.LNX.4.21.0005101233290.17782-100000@mermaid.ucc.gu.uwa.edu.au>

Hi :)

'' quotes are used to define characters...

`` (backquotes) are used, but I don't know how to explain what they're
used for :P sorry.

BB,

zarie

On Tue, 9 May 2000, Kevin Liang wrote:

> Hi all,
> 	I was just working on ch.6, exercise 2  of Learning Python.  I 
> came to the point when I had copied word-for-word the answer to the question 
> (or so I thought), yet it still refused to run properly.. then I looked carefully,
> and noticed a *return* statement had '''' quotes instead of `````.  I changed
> it , and it worked..  Now, I'm a little confused as to why this is so important..
> I'm always bogged down on things like this.  thanks
> 
> kevin 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 


@}-->---
"Can you get spank-safe deposit boxes?"
       (Bryden on the way back from Lancelin '99)
                                         ---<--{@



From wolfkin@freedomspace.net  Wed May 10 16:19:23 2000
From: wolfkin@freedomspace.net (Randall Randall)
Date: Wed, 10 May 2000 11:19:23 -0400 (EDT)
Subject: [Tutor] importance of quotes ..
In-Reply-To: <20000509212159.A2771@vcn.bc.ca>
Message-ID: <XFMail.20000510111923.wolfkin@freedomspace.net>

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


On 10-May-2000 Kevin Liang wrote:
>  Hi all,
>       I was just working on ch.6, exercise 2  of Learning Python.  I 
>  came to the point when I had copied word-for-word the answer to the question
>  (or so I thought), yet it still refused to run properly.. then I looked
>  carefully,
>  and noticed a *return* statement had '''' quotes instead of `````.  I
>  changed
>  it , and it worked..  Now, I'm a little confused as to why this is so
>  important..
>  I'm always bogged down on things like this.  thanks

The back quotes are used as a kind of shorthand,
where you would otherwise use "repr()".  They
convert whatever is inside them into a string.

- -- 
Wolfkin (wolfkin@freedomspace.net).
Crypto key: www.freedomspace.net/~wolfkin/crypto.text
On a visible but distant shore, a new image of man;
The shape of his own future, now in his own hands.-- Johnny Clegg.

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

iD8DBQE5GX378SWFrcg/i1gRAgYXAKCkjquzN8u3cKEGgDUBJ/hGln2N3QCfZRM7
7u6cspvK3Rdr01ujI7ht84A=
=y9RD
-----END PGP SIGNATURE-----


From mjboylan@sover.net  Wed May 10 13:48:35 2000
From: mjboylan@sover.net (Michael J. Boylan)
Date: Wed, 10 May 2000 12:48:35
Subject: [Tutor] van Laningham's book
Message-ID: <3.0.1.16.20000510124835.3247b098@mail.sover.net>

I'm struggling through van Laningham's book, "Teach Yourself Python in 24
Hours", and was doing quite well until chapter 6. Bogged down in tuples,
with lists next. This is my first attempt at programming, and find this a
bit much. How does one remember the syntax, functions, indentations, etc?
Does it just take time and practice? I tried tutor for non-programmers, and
could do the programs (not understanding some of them of course), and
initally found van Laningham's book better, but am getting stuck here in
chapter 6. 

Any recommendations on best way to learn Python?

Appreciate it. 

Mike


From wolfkin@freedomspace.net  Wed May 10 20:47:31 2000
From: wolfkin@freedomspace.net (Randall Randall)
Date: Wed, 10 May 2000 15:47:31 -0400 (EDT)
Subject: [Tutor] van Laningham's book
In-Reply-To: <3.0.1.16.20000510124835.3247b098@mail.sover.net>
Message-ID: <XFMail.20000510154731.wolfkin@freedomspace.net>

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


On 10-May-2000 Michael J. Boylan wrote:
>  I'm struggling through van Laningham's book, "Teach Yourself Python in 24
>  Hours", and was doing quite well until chapter 6. Bogged down in tuples,
>  with lists next. This is my first attempt at programming, and find this a
>  bit much. How does one remember the syntax, functions, indentations, etc?
>  Does it just take time and practice? I tried tutor for non-programmers, and
>  could do the programs (not understanding some of them of course), and
>  initally found van Laningham's book better, but am getting stuck here in
>  chapter 6. 

This probably won't help, but I've gotta say it:
Python is the easiest language to learn that I've
ever come across. :)

>  Any recommendations on best way to learn Python?

Well, for me, doing tutorials on *other* languages
first seemed to make something click when I finally
stumbled upon Python.  

- -- 
Wolfkin (wolfkin@freedomspace.net).
Crypto key: www.freedomspace.net/~wolfkin/crypto.text
On a visible but distant shore, a new image of man;
The shape of his own future, now in his own hands.-- Johnny Clegg.

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

iD8DBQE5GbzT8SWFrcg/i1gRArSOAJwISNuIEFgZJWE+txwDUhLKtPf5GwCfU00G
QR6e8TZntw82gBUwGi1n8Ts=
=CXGT
-----END PGP SIGNATURE-----


From genius@idirect.com  Wed May 10 22:13:46 2000
From: genius@idirect.com (Charles Takacs)
Date: Wed, 10 May 2000 17:13:46 -0400
Subject: [Tutor] van Laningham's book
Message-ID: <001b01bfbac4$a2fcdc20$450a9ad8@charlest>

Hi Michael :-))
By coincidence I am at the same Chapter .  Being a Newbie myself my advice
should be considered as coming from such.

Let me share with you a "Programming Concept" which I read some where, and
found it to be absolutely the best advice to follow.
(actually I think it was said by "Eric Raymond").

Here it goes:
        "Reading a book is not enough.  The best way To Learn is;
 to constantly Read-Code and Write-Code".

BTY:  I noticed also, that Ivan in his introduction page (in the 3rd.
paragraph) makes this important reference.  ie. "Concentrate on practising
Python, not on understanding it".  Etc.....  I think unfortunatelly many
people will just glance at the Introduction page.  I've read this page
several times and each time I found something New to understand. I recommend
you do the same.

There is another Tutorial which I really like;  which is, "Learning to
Program" by Alan Gauld.  If you haven't read it then I suggest you to do so.

You seem to be on the right track.  Don't wory to much about the misteries
of the {}, [ ], () or the syntax, indentations etc. The worst thing can
happen is that you get an error message.  But each time you write them down
you will understand it better and become better.  At least this is how I am
progressing toward becoming a GeNiUs :-).

Best regards
Charles Takacs

The best way for you to

-----Original Message-----
From: Michael J. Boylan <mjboylan@sover.net>
To: tutor@python.org <tutor@python.org>
Date: Wednesday, May 10, 2000 12:48 PM
Subject: [Tutor] van Laningham's book


>I'm struggling through van Laningham's book, "Teach Yourself Python in 24
>Hours", and was doing quite well until chapter 6. Bogged down in tuples,
>with lists next. This is my first attempt at programming, and find this a
>bit much. How does one remember the syntax, functions, indentations, etc?
>Does it just take time and practice? I tried tutor for non-programmers, and
>could do the programs (not understanding some of them of course), and
>initally found van Laningham's book better, but am getting stuck here in
>chapter 6.
>
>Any recommendations on best way to learn Python?
>
>Appreciate it.
>
>Mike
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://www.python.org/mailman/listinfo/tutor



From rbl@hal.cwru.edu  Wed May 10 22:33:02 2000
From: rbl@hal.cwru.edu (Robin B. Lake)
Date: Wed, 10 May 2000 17:33:02 -0400 (EDT)
Subject: [Tutor] van Laningham's book
Message-ID: <200005102133.RAA01115@hal.epbi.cwru.edu>

I'm a newbie to Python, but not to programming.  I'm outlining
a book on learning programming from the ground up and plan to use
Python as the example language.  Here are my principles, learned
through sitting thru far too many years of badly-taught programming
courses (too many of them mine):

Just as we do with our kids, you have to learn to read before you
can write.  But learning to read about a dog does little good
if you don't have a "dog concept".  In programming, it does little
good to read a program unless you have some concept about what
a program DOES  ...  
	-  Accepts information
	-  Stores information
	-  Transforms information
	-  Retrieves information
	-  Displays (outputs) information.

Now, of course, we need a concept of "information" to build upon.
I am going to TRY (in the book) to explain "information" as a selection
of alternatives IN A GIVEN CONTEXT.  I'm thinking how to get this
concept over easily.  Giving bit-patterns in the context of the ASCII
standard alphabet is one example;  another likely example is selecting
a pixel color and intensity as a set of bit patterns.  And a sound
as a sequence of bit patterns in the context of an allowed range of
voltage values (sound pressures?).  Got to introduce computer instructions
as selections, too.  

THEN we can get to the meat of programming ---  pseudo-code to do each
of the 5 program functions listed above.  This will lead to data
structures (easy with Python, eh?).

Anyhow, as soon as I have something to show, I'll let the e-list know.
Still trying to resolve the issue of getting hand-drawn figures onto
the Web page without the .gif overhead when downloading.

Cheers,
Rob Lake
rbl@hal.cwru.edu

> To: <tutor@python.org>, "Michael J. Boylan" <mjboylan@sover.net>
> Subject: Re: [Tutor] van Laningham's book
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
> X-BeenThere: tutor@python.org
> X-Mailman-Version: 2.0beta3
> List-Id: Discussion for learning programming with Python <tutor.python.org>
> 
> Hi Michael :-))
> By coincidence I am at the same Chapter .  Being a Newbie myself my advice
> should be considered as coming from such.
> 
> Let me share with you a "Programming Concept" which I read some where, and
> found it to be absolutely the best advice to follow.
> (actually I think it was said by "Eric Raymond").
> 
> Here it goes:
>         "Reading a book is not enough.  The best way To Learn is;
>  to constantly Read-Code and Write-Code".
> 
> BTY:  I noticed also, that Ivan in his introduction page (in the 3rd.
> paragraph) makes this important reference.  ie. "Concentrate on practising
> Python, not on understanding it".  Etc.....  I think unfortunatelly many
> people will just glance at the Introduction page.  I've read this page
> several times and each time I found something New to understand. I recommend
> you do the same.
> 
> There is another Tutorial which I really like;  which is, "Learning to
> Program" by Alan Gauld.  If you haven't read it then I suggest you to do so.
> 
> You seem to be on the right track.  Don't wory to much about the misteries
> of the {}, [ ], () or the syntax, indentations etc. The worst thing can
> happen is that you get an error message.  But each time you write them down
> you will understand it better and become better.  At least this is how I am
> progressing toward becoming a GeNiUs :-).
> 
> Best regards
> Charles Takacs
> 
> The best way for you to
> 
> -----Original Message-----
> From: Michael J. Boylan <mjboylan@sover.net>
> To: tutor@python.org <tutor@python.org>
> Date: Wednesday, May 10, 2000 12:48 PM
> Subject: [Tutor] van Laningham's book
> 
> 
> >I'm struggling through van Laningham's book, "Teach Yourself Python in 24
> >Hours", and was doing quite well until chapter 6. Bogged down in tuples,
> >with lists next. This is my first attempt at programming, and find this a
> >bit much. How does one remember the syntax, functions, indentations, etc?
> >Does it just take time and practice? I tried tutor for non-programmers, and
> >could do the programs (not understanding some of them of course), and
> >initally found van Laningham's book better, but am getting stuck here in
> >chapter 6.
> >
> >Any recommendations on best way to learn Python?
> >
> >Appreciate it.
> >
> >Mike
> >
> >_______________________________________________
> >Tutor maillist  -  Tutor@python.org
> >http://www.python.org/mailman/listinfo/tutor
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 


From satori@dlcwest.com  Thu May 11 00:06:47 2000
From: satori@dlcwest.com (satori)
Date: Wed, 10 May 2000 17:06:47 -0600
Subject: [Tutor] trig functions
Message-ID: <004501bfbad4$6aa207a0$49ac53cc@default>

Hey gang,

I've looked through a few of the Python books and I can't find this.  Can we
do trig functions (specifically cos and sin) in Python?

I'm doing a school assignment (university), nobody's heard of Python in the
lab
(including the lab instructors) and I can use the language of my choice.
I'd like to use Python if I can.

I want to build 3 3x3 arrays, filling one with data from the user, the
second with answers to trig-based functions and the third by doing a matrix
multiplication (which I will write) multiplying the first and second arrays.

I have the 1.5.2 release for windows.

Any info (and tips) will be HUGELY appreciated.

Thanks in advance.

Jim Schubert

PS.  I've already written it and compiled it in C++, and I have the pseudo
code I wrote, but I want to introduce the lab instructors to Python if I
can.





From wolfkin@freedomspace.net  Thu May 11 01:03:55 2000
From: wolfkin@freedomspace.net (Randall Randall)
Date: Wed, 10 May 2000 20:03:55 -0400 (EDT)
Subject: [Tutor] trig functions
In-Reply-To: <004501bfbad4$6aa207a0$49ac53cc@default>
Message-ID: <XFMail.20000510200355.wolfkin@freedomspace.net>

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


On 10-May-2000 satori wrote:
>  Hey gang,
>  
>  I've looked through a few of the Python books and I can't find this.  Can we
>  do trig functions (specifically cos and sin) in Python?

This page will likely have what you want:

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

- -- 
Wolfkin (wolfkin@freedomspace.net).
Crypto key: www.freedomspace.net/~wolfkin/crypto.text
On a visible but distant shore, a new image of man;
The shape of his own future, now in his own hands.-- Johnny Clegg.

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

iD8DBQE5Gfjr8SWFrcg/i1gRAmhiAJ9+c4u3knFq3Bc3alPogs6p4LdZWQCgynJA
Dn7CjiwW6hvwOa5DjaAqtzE=
=JnZI
-----END PGP SIGNATURE-----


From cwebster@nevada.edu  Thu May 11 01:48:13 2000
From: cwebster@nevada.edu (Corran Webster)
Date: Wed, 10 May 2000 17:48:13 -0700
Subject: [Tutor] trig functions
In-Reply-To: <004501bfbad4$6aa207a0$49ac53cc@default>
Message-ID: <l03130304b53fb2ae5818@[10.0.2.3]>

At 5:06 PM -0600 10/5/00, satori wrote:
> Hey gang,
>
> I've looked through a few of the Python books and I can't find this.  Can we
> do trig functions (specifically cos and sin) in Python?

Yep - the standard math functions (and constants like pi) are available in
the math module.  Just do

from math import *

and away you go.  See the documentation for exactly which functions are
available (it's basically what you get from C's math.h, I think).

> I'm doing a school assignment (university), nobody's heard of Python in the
> lab
> (including the lab instructors) and I can use the language of my choice.
> I'd like to use Python if I can.
>
> I want to build 3 3x3 arrays, filling one with data from the user, the
> second with answers to trig-based functions and the third by doing a matrix
> multiplication (which I will write) multiplying the first and second arrays.

If you are doing matrix based stuff, have a look at numerical python (sorry
I don't have the URL handy, but it's available at www.sourceforge.org).  Of
course if it's an assignment, using a specialised package may be considered
as having too much assistance from outside sources.


Regards,
Corran




From Moshe Zadka <moshez@math.huji.ac.il>  Thu May 11 06:40:07 2000
From: Moshe Zadka <moshez@math.huji.ac.il> (Moshe Zadka)
Date: Thu, 11 May 2000 08:40:07 +0300 (IDT)
Subject: [Tutor] importance of quotes ..
In-Reply-To: <Pine.LNX.4.21.0005101233290.17782-100000@mermaid.ucc.gu.uwa.edu.au>
Message-ID: <Pine.GSO.4.10.10005110839060.14977-100000@sundial>

On Wed, 10 May 2000, Tracey Brown wrote:

> '' quotes are used to define characters...

strings, really

> `` (backquotes) are used, but I don't know how to explain what they're
> used for :P sorry.

Syntactic sugar for repr():

`x` is equivalent to repr(x). Read up on repr() in the library reference.

--
Moshe Zadka <moshez@math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com



From jcm@bigskytel.com  Thu May 11 07:00:00 2000
From: jcm@bigskytel.com (David Porter)
Date: Thu, 11 May 2000 00:00:00 -0600
Subject: [Tutor] van Laningham's book
In-Reply-To: <3.0.1.16.20000510124835.3247b098@mail.sover.net>; from mjboylan@sover.net on Wed, May 10, 2000 at 12:48:35PM +0000
References: <3.0.1.16.20000510124835.3247b098@mail.sover.net>
Message-ID: <20000511000000.D1880@bigskytel.com>

* Michael J. Boylan <mjboylan@sover.net>:
> I'm struggling through van Laningham's book, "Teach Yourself Python in 24
> Hours", and was doing quite well until chapter 6. Bogged down in tuples,
> with lists next. This is my first attempt at programming, and find this a
> bit much. How does one remember the syntax, functions, indentations, etc?
> Does it just take time and practice? I tried tutor for non-programmers, and
> could do the programs (not understanding some of them of course), and
> initally found van Laningham's book better, but am getting stuck here in
> chapter 6. 
> 
> Any recommendations on best way to learn Python?
>

Since I am only beginning, I can only say what I have found successful. I
don't know how far chapter six of this book gets you into Python, but maybe
you should take a break from the book for a bit and just play around with
the interpreter. 

I found that I could repeat what tutorials said to do, but not quite
understand *why* it worked. Using the interpreter and trying things out from
a few different angles to figure out exactly what's going on really helped
me. Actually applying all this information which may seem arbitrary at first
will help it make some sense.

After that, writing your own scripts you can learn even more. It's best
though if you can execute them immediately after making some changes, so you
can try lots of things. I do this in Emacs with python-mode (
http://www.python.org/emacs/python-mode/ ), though you can also do it with
IDLE ( http://www.python.org/idle/ ) if you don't have/want Emacs.

Then finally, you can even look at other peoples scripts. I benefitted from
toying with scripts such as those at Joe Strout's page (
http://www.strout.net/python/tidbits.html ).

Maybe when you come back it will make more sense. If it doesn't, ask the
list!


    David


From craig@osa.att.ne.jp  Thu May 11 16:09:32 2000
From: craig@osa.att.ne.jp (Craig Hagerman)
Date: Fri, 12 May 2000 00:09:32 +0900
Subject: [Tutor] passing messages to another class?
Message-ID: <v03102700b5407a6499a1@[165.76.248.90]>

Hi,

I am in need of some guidance related to message passing between classes. I
have a program I have been working on with a Tkinter front end. I have
divided the program into four classes, a Display class (for the GUI) a
Data_Manipulation class, an instantiation of that class (for
specialization) and a Facilitator class to assist in the execution. In
brief my problem is that I want be able to display status messages
(pertaining to the program's operation) at the bottom of the GUI (in a
simple Entry widget). What is displayed will mostly depend on what data is
being processed so part of the actual message displayed can not be known
ahead of time - it must be gleaned from the Data_Manipulation class. I
thought that I could add a little function to the Display class:

def status(self,msg)
	self.status_contents.set(msg)

But how on earth to I call that from another class. I tried various ways
such as adding a function in the Data_Manipulation class:

def message(self,msg)
	Display.status(msg)

and many other variations on the theme but I am just spinning my wheels. I
am no expert but from my reading on OOP design I guess that normally this
is not a good way to program. Please advise.

Thanks,

Craig Hagerman




From Thomas_A._Williams@NEWYORKLIFE.COM  Thu May 11 17:16:33 2000
From: Thomas_A._Williams@NEWYORKLIFE.COM (Thomas A. Williams)
Date: Thu, 11 May 2000 12:16:33 -0400
Subject: [Tutor] van Laningham's book
Message-ID: <852568DC.00596D15.00@Email.NewYorkLife.com>

I can understand the struggle to learn a new language
especially for the first time.  Thanks for the great
feedback from all.  I think what also helps is to work,
code, and study with others.  Going the solo route
is rough and it is easy to go off on a tagent. Many times
I've found myself spining my wheels for days, weeks.

Try forming a virtual team/study group of others
who are going through or may wish to go through
Laningham's book.  Also remember to throw
in plenty of coding time   :-)

I'm a newbie to Python, I've started learning Python
this week from online tutorials.  I'm experienced in C/C++,
SQL, PL/SQL, and Perl.  Learning Python appears
to be enjoyable.

Also where can I find the tutorial "Learning to Program
by Alan Gauld???

Enjoy The Journey,
TomW

---------------------- Forwarded by Thomas A. Williams/NYLIC on 05/11/2000 12:02
PM ---------------------------


"Michael J. Boylan" <mjboylan@sover.net> on 05/10/2000 08:48:35 AM

To:   tutor@python.org
cc:    (bcc: Thomas A. Williams/NYLIC)
Subject:  [Tutor] van Laningham's book




I'm struggling through van Laningham's book, "Teach Yourself Python in 24
Hours", and was doing quite well until chapter 6. Bogged down in tuples,
with lists next. This is my first attempt at programming, and find this a
bit much. How does one remember the syntax, functions, indentations, etc?
Does it just take time and practice? I tried tutor for non-programmers, and
could do the programs (not understanding some of them of course), and
initally found van Laningham's book better, but am getting stuck here in
chapter 6.

Any recommendations on best way to learn Python?

Appreciate it.

Mike

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





From genius@idirect.com  Thu May 11 18:26:05 2000
From: genius@idirect.com (Charles Takacs)
Date: Thu, 11 May 2000 13:26:05 -0400
Subject: [Tutor] van Laningham's book
Message-ID: <002e01bfbb6d$fdea8de0$f3009ad8@charlest>

For Alan's as well as Other Tutorials start here:
                        http://www.python.org/doc/Intros.html

You indicate as being experienced in other Programming so you should also
check Guido's Tutorial
                http://www.python.org/doc/current/tut/tut.html
Best regards
Charles
-----Original Message-----
From: Thomas A. Williams <Thomas_A._Williams@NEWYORKLIFE.COM>
To: tutor@python.org <tutor@python.org>; mjboylan@sover.net
<mjboylan@sover.net>; Genius@idirect.com <Genius@idirect.com>
Date: Thursday, May 11, 2000 12:20 PM
Subject: [Tutor] van Laningham's book


>I can understand the struggle to learn a new language
>especially for the first time.  Thanks for the great
>feedback from all.  I think what also helps is to work,
>code, and study with others.  Going the solo route
>is rough and it is easy to go off on a tagent. Many times
>I've found myself spining my wheels for days, weeks.
>
>Try forming a virtual team/study group of others
>who are going through or may wish to go through
>Laningham's book.  Also remember to throw
>in plenty of coding time   :-)
>
>I'm a newbie to Python, I've started learning Python
>this week from online tutorials.  I'm experienced in C/C++,
>SQL, PL/SQL, and Perl.  Learning Python appears
>to be enjoyable.
>
>Also where can I find the tutorial "Learning to Program
>by Alan Gauld???
>
>Enjoy The Journey,
>TomW
>
>---------------------- Forwarded by Thomas A. Williams/NYLIC on 05/11/2000
12:02
>PM ---------------------------
>
>
>"Michael J. Boylan" <mjboylan@sover.net> on 05/10/2000 08:48:35 AM
>
>To:   tutor@python.org
>cc:    (bcc: Thomas A. Williams/NYLIC)
>Subject:  [Tutor] van Laningham's book
>
>
>
>
>I'm struggling through van Laningham's book, "Teach Yourself Python in 24
>Hours", and was doing quite well until chapter 6. Bogged down in tuples,
>with lists next. This is my first attempt at programming, and find this a
>bit much. How does one remember the syntax, functions, indentations, etc?
>Does it just take time and practice? I tried tutor for non-programmers, and
>could do the programs (not understanding some of them of course), and
>initally found van Laningham's book better, but am getting stuck here in
>chapter 6.
>
>Any recommendations on best way to learn Python?
>
>Appreciate it.
>
>Mike
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://www.python.org/mailman/listinfo/tutor
>
>
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://www.python.org/mailman/listinfo/tutor



From alan.gauld@bt.com  Thu May 11 17:36:06 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 11 May 2000 17:36:06 +0100
Subject: [Tutor] passing messages to another class?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D113@mbtlipnt02.btlabs.bt.co.uk>

> I am in need of some guidance related to message passing 
> between classes. 

Here lies the problem. You don't pass messages between classes 
you pass them between objects, ie instances of classes.

> have a program I have been working on with a Tkinter front end. I have
> divided the program into four classes, a Display class (for the GUI) a
> Data_Manipulation class, an instantiation of that class (for
> specialization) and a Facilitator class 

Thats 3 classes and one object...

> thought that I could add a little function to the Display class:

Being picky thats a method - and needs a colon at the 
end of the first line...

> 
> def status(self,msg)
> 	self.status_contents.set(msg)
> 
> But how on earth to I call that from another class. I tried 
> various ways
> such as adding a function in the Data_Manipulation class:
> 
> def message(self,msg)
> 	Display.status(msg)

You need to create an instance of Display and store a reference 
to it in your Data_Manipulation class:

class Data_Manipulator:
	def __init__(self):
		# do whatever you do
		self.UI = Display()

	def message(self,msg):
		self.UI.status(msg)

Or more likely you'll create a global UI object or maybe 
even have an application class that has fields for each 
of your  objects... lots of ways but the key point is 
you need to have instances of the classes not just the 
classes.

[ actually you could possibly get away with a single instance
  and calling the class methods directly and passing self in:

  def message(self,msg):
	Display.status(self,msg)

  And your instance could call 

  Data_Manipulator.message(self,msg)

  But its a horrible way to write code and certainly 
  isn't what OOP is about! ]

Alan g.


From kevin@vcn.bc.ca  Thu May 11 16:14:34 2000
From: kevin@vcn.bc.ca (Kevin Liang)
Date: Thu, 11 May 2000 11:14:34 -0400
Subject: [Tutor] question on getattr..
In-Reply-To: <20000510160011.B93331CD25@dinsdale.python.org>; from tutor-request@python.org on Wed, May 10, 2000 at 12:00:11PM -0400
References: <20000510160011.B93331CD25@dinsdale.python.org>
Message-ID: <20000511111434.A806@vcn.bc.ca>

Hi,
   I'm stumped on a line of code about the getattr function..

class wrapper:
	def __init__(self,object):
		self.wrapped = object
	def __getattr__(self, attrname):
		print 'Trace:', attrname
		return getattr(self.wrapped, attrname)

  I know you need the last line to acutally use built-in functions for lists,
dictionaries, etc.. (e.g. append something), but what does it mean ? Why is a return needed ?  I keep thinking its supposed to print something..


-- 

"Do not go where the path may lead, go instead where there is no
path and leave a trail"  -Ralph Waldo Emerson


From amoreira@mercury.ubi.pt  Fri May 12 11:40:35 2000
From: amoreira@mercury.ubi.pt (amoreira@mercury.ubi.pt)
Date: Fri, 12 May 2000 10:40:35 +0000
Subject: [Tutor] list.index method
Message-ID: <391BDFA3.3826E9EA@mercury.ubi.pt>

Hello!
I've been thinking about the definition of some list methods, like
list.index and list.remove, and there's something that is itching me,
ever since I started using python (not that very long ago, anyway). Take
list.index(x), for instance. This method returns the position of the
first list element that is equal to x. So, when some of the list items
are equal, there may be some problems. Take an example:
>>> l=[]
>>> for i in range(3):
...  l.append(abs(i-1.))
...
#This is a funny way to define this simple list, but I want it to verify
l[0]==l[2] *and* not(l[0] is l[2]),
#that is, l[0] and l[2] are not references to the same object, but the
objects wich they point to are #equal. (Sorry if I can't explain this
any better, I'm a Fortran programmer not very familiar with this
#object, pointer, and god knows what else mess)
#Let's check this list:
>>> l
[1.0, 0.0, 1.0]
>>> l[0] == l[2]
1
>>> l[0] is l[2]
0
#OK, this is exactly what I wanted. Now look at this:
>>> for x in l:
...  print l.index(x)
...
0
1
0

What is itching me is that I'd rather have this code print 0,1,2, the
indexes of each of the elements of the list. I'd say that it would be
better if the definition of list.index(x) would be: return the smallest
i such that list[i] is x, instead of the smallest i such that
list[i]==x...
Is there any reason for this behaviour?
Sorry for such a long post, and thank you all!
Ze
amoreira@mercury.ubi.pt



From emile@fenx.com  Fri May 12 15:05:26 2000
From: emile@fenx.com (Emile van Sebille)
Date: Fri, 12 May 2000 07:05:26 -0700
Subject: [Tutor] list.index method
References: <391BDFA3.3826E9EA@mercury.ubi.pt>
Message-ID: <08e801bfbc1b$3209b8a0$1906a8c0@fc.fenx.com>

You can extend UserList and change index
to get what you want:

import UserList

class MyList(UserList.UserList):
  def index(self, item):
    cont_from = 0
    while cont_from <= len(self.data):
      retval = self.data[cont_from:].index(item)
      if self.data[cont_from + retval] is item:
        return retval + cont_from
      else:
        cont_from = cont_from + retval + 1

l = MyList()
for i in range(3):
  l.append(abs(i-1.))

for i in l:
  print l.index(i)

print l[0] is l[2]
print l[0] == l[2]

print l.index(4)



Emile van Sebille
emile@fenx.com
-------------------


----- Original Message -----
From: <amoreira@mercury.ubi.pt>
To: <tutor@python.org>
Sent: Friday, May 12, 2000 3:40 AM
Subject: [Tutor] list.index method


> Hello!
> I've been thinking about the definition of some list methods, like
> list.index and list.remove, and there's something that is itching me,
> ever since I started using python (not that very long ago, anyway).
Take
> list.index(x), for instance. This method returns the position of the
> first list element that is equal to x. So, when some of the list items
> are equal, there may be some problems. Take an example:
> >>> l=[]
> >>> for i in range(3):
> ...  l.append(abs(i-1.))
> ...
> #This is a funny way to define this simple list, but I want it to
verify
> l[0]==l[2] *and* not(l[0] is l[2]),
> #that is, l[0] and l[2] are not references to the same object, but the
> objects wich they point to are #equal. (Sorry if I can't explain this
> any better, I'm a Fortran programmer not very familiar with this
> #object, pointer, and god knows what else mess)
> #Let's check this list:
> >>> l
> [1.0, 0.0, 1.0]
> >>> l[0] == l[2]
> 1
> >>> l[0] is l[2]
> 0
> #OK, this is exactly what I wanted. Now look at this:
> >>> for x in l:
> ...  print l.index(x)
> ...
> 0
> 1
> 0
>
> What is itching me is that I'd rather have this code print 0,1,2, the
> indexes of each of the elements of the list. I'd say that it would be

> better if the definition of list.index(x) would be: return the
smallest
> i such that list[i] is x, instead of the smallest i such that
> list[i]==x...
> Is there any reason for this behaviour?
> Sorry for such a long post, and thank you all!
> Ze
> amoreira@mercury.ubi.pt
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>



From amoreira@mercury.ubi.pt  Fri May 12 17:22:09 2000
From: amoreira@mercury.ubi.pt (amoreira@mercury.ubi.pt)
Date: Fri, 12 May 2000 16:22:09 +0000
Subject: [Tutor] list.index method
References: <391BDFA3.3826E9EA@mercury.ubi.pt> <08e801bfbc1b$3209b8a0$1906a8c0@fc.fenx.com>
Message-ID: <391C2FB1.474E936E@mercury.ubi.pt>

Thanks for your reply!

Yes, I did that as well (or something very much like it), but still, it has
the possible drawback that it
is a method implemented in python, instead of beeing builtin at the
C-level. I don't really know if
this means a much slower execution, but I suspect so. Anyway, this is just
a matter of aestetics
(how do we spell this in english?). I'm used to fortran arrays, where you
have to search the array
by iterating over the array index (fortran90/95 very much improved this,
with array syntax), so I
know how to solve my problem, but in an very ugly way... At least for
python standards. Extending
UserList  is much more beautifull, but I keep wondering why the list.index
method was designed as
it is. Optimization issues, perhaps?

But please, don't take my mutterings as criticism of the language, or as
proposals to change it's
definition! I like it as it is, and I am taking a great deal of fun
learning it. At the same time, I'm also
learning OOP, wich is something completly out of my previous programming
experience.
And if I want raw speed, I can use numpy or get it done in fortran!

Again, thanks.
Cheers!
Ze Amoreira,
amoreira@mercury.ubi.pt




Emile van Sebille wrote:

> You can extend UserList and change index
> to get what you want:
>
> import UserList
>
> class MyList(UserList.UserList):
>   def index(self, item):
>     cont_from = 0
>     while cont_from <= len(self.data):
>       retval = self.data[cont_from:].index(item)
>       if self.data[cont_from + retval] is item:
>         return retval + cont_from
>       else:
>         cont_from = cont_from + retval + 1
> [...]



From arcege@shore.net  Fri May 12 16:43:37 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Fri, 12 May 2000 11:43:37 -0400 (EDT)
Subject: [Tutor] list.index method
In-Reply-To: <391C2FB1.474E936E@mercury.ubi.pt> from "amoreira@mercury.ubi.pt" at May 12, 2000 04:22:09 PM
Message-ID: <200005121543.LAA18950@northshore.shore.net>

> Yes, I did that as well (or something very much like it), but still, it has
> the possible drawback that it
> is a method implemented in python, instead of beeing builtin at the
> C-level. I don't really know if
> this means a much slower execution, but I suspect so. Anyway, this is just
> a matter of aestetics
> (how do we spell this in english?). I'm used to fortran arrays, where you
> have to search the array
> by iterating over the array index (fortran90/95 very much improved this,
> with array syntax), so I
> know how to solve my problem, but in an very ugly way... At least for
> python standards. Extending
> UserList  is much more beautifull, but I keep wondering why the list.index
> method was designed as
> it is. Optimization issues, perhaps?

It is not for optimization, it is simply so class instance, which are
to create abstractions of data, can be searched inside lists as be
equal but not unique.  As soon as you start testing, by default, by
uniqueness, then a large number of applications will be out of reach.

For example.. 
>>> class A:     # test with "is", by default
...   def __init__(self, v):
...     self.value = v
...
>>> class B(A):  # test by value (==)
...   def __cmp__(self, other):
...     return cmp(self.value, other)
...   def __rcmp__(self, other):          # don't worry about data cases
...     return cmp(B(other), self.value)  # this is overly simplified
...
>>> list1 = [ A(0.0), A(1.0), A(2.0), A(1.0) ]
>>> list1.index( 1.0 )
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: list.index(x): x not in list
>>> list1.index( list1[3] )
3
>>> list2 = [ B(0.0), B(1.0), B(2.0), B(1.0) ]
>>> list2.index( 1.0 )
1
>>> list2.index( list2[3] )
1
>>> list2.count( 1.0 )
2
>>> list2.count( 1.0 )
0
>>>

If list.index (and list.count) tested by uniqueness, then you could not
create abstract objects to interact with other objects "objA == objB",
and that is likely to be more valuable in the general application than
always testing by uniqueness.

The default for instances is to compare by uniqueness (is) - unless you
define __cmp__/__rcmp__ methods in the class hierarchy, then it is by
equivalence (==/!=/</>/<=/>=).

For these methods, it is up to the object, not the list.index method
(or list.count, or...) to determine what kind of test.  As Emile has
shown, it is easy enough to make an alternative method to do what you
want. :)

  -Arcege

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


From amoreira@mercury.ubi.pt  Fri May 12 18:15:45 2000
From: amoreira@mercury.ubi.pt (amoreira@mercury.ubi.pt)
Date: Fri, 12 May 2000 17:15:45 +0000
Subject: [Tutor] list.index method
References: <200005121543.LAA18950@northshore.shore.net>
Message-ID: <391C3C41.25690406@mercury.ubi.pt>

OK!
I'll have to do some more OOP to come up with that kind of stuff myself!
Thanks a lot for your answers.

Cheers,
Ze Amoreira
amoreira@mercury.ubi.pt



From emile@fenx.com  Fri May 12 17:52:44 2000
From: emile@fenx.com (Emile van Sebille)
Date: Fri, 12 May 2000 09:52:44 -0700
Subject: [Tutor] list.index method
References: <391BDFA3.3826E9EA@mercury.ubi.pt> <08e801bfbc1b$3209b8a0$1906a8c0@fc.fenx.com> <391C2FB1.474E936E@mercury.ubi.pt>
Message-ID: <0a3601bfbc32$90e55ac0$1906a8c0@fc.fenx.com>

You could also try:

>>> li = map(lambda x: id(x), l)
>>> li
[8690552, 8690600, 8690536]
>>> for i in l:
 print li.index(id(i))

 
0
1
2
>>> 

aesthetics

I-don't-know-where-the-first-copy-of-this-went-ly y'rs

Emile van Sebille
emile@fenx.com
-------------------




From emile@fenx.com  Fri May 12 18:55:12 2000
From: emile@fenx.com (emile@fenx.com)
Date: Fri, 12 May 2000 10:55:12 -0700
Subject: [Tutor] Re: Easy way to print numbers with thousand separators?
Message-ID: <391C4580.91DDCE8@fenx.com>

John,

This is because your copy of python was compiled without _locale
support.

You'll need to recompile to fix this.  This is how I do it on my RH6
system.
in dist/src/Modules, modify Setup by removing the leading # in the line:

#_locale _localemodule.c # access to ISO C locale support

I update python to the CVS version every couple of weeks.  I've got an
update
script in /usr/src/python that reads:
cvs -z6 -q up -P -d
cd dist/src
make clean
./configure --with-thread --prefix /usr
make
make test
make install

If you've installed the sources, you should be able to recompile
starting
with 'make clean' and on from above.

If recompiling isn't a real option, you'll need to adapt some code to 
do the formatting.  see http://deja.com/getdoc.xp?AN=588167809 for a
start.

HTH,

Emile van Sebille
emile@fenx.com


John Villalovos <john@nwjohn.jf.intel.com> wrote in message
news:<8fh63s$ds8$1@nwjohn.jf.intel.com>...
> Thanks!
> 
> But now when using a Red Hat 6.2 system when I type: import locale
> I get the following:
> 
> Python 1.5.2 (#1, Feb  1 2000, 16:32:16)  [GCC egcs-2.91.66 19990314/Linux\
>  (egcs- on linux-i386
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import locale
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python1.5/locale.py", line 4, in ?
>     from _locale import *
> ImportError: No module named _locale
> >>>
> 
> I can see the locale.py, locale.pyc, & locale.pyo files in /usr/lib/python1.5/
> 
> Is there a configuration file option that will make it work?
> 
> Thanks,
> John
> 
> In article <391B4F36.57EE6313@fenx.com>,  <emile@fenx.com> wrote:
> >>>> import locale
> >>>> locale.setlocale(locale.LC_ALL,"")
> >'English_United States.1252'
> >>>> print locale.format("%12.2f",1234567.89,1)
> >  1,234,567.89
> >
> >Emile van Sebille
> >emile@fenx.com
> >
> >John Villalovos <john@nwjohn.jf.intel.com> wrote in message
> >news:<8ffdtg$dav$1@nwjohn.jf.intel.com>...
> >> I was wondering if there was an easy way to print numbers with thousand
> >> separators in them?
> >> 
> >> For example I want to print the number:  1234567890
> >> 			            as:  1,234,567,890
> >> 
> >> I know I can write a simple little program to do it but I was hoping that there
> >> was already something in the libraries to do this.
> >> 
> >> Thanks,
> >> John
> >> -- 
> >> http://www.python.org/mailman/listinfo/python-list
> >>
> >
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
>


From dworkin@ccs.neu.edu  Fri May 12 23:25:24 2000
From: dworkin@ccs.neu.edu (Justin Sheehy)
Date: 12 May 2000 18:25:24 -0400
Subject: [Tutor] question on getattr..
In-Reply-To: Kevin Liang's message of "Thu, 11 May 2000 11:14:34 -0400"
References: <20000510160011.B93331CD25@dinsdale.python.org>
 <20000511111434.A806@vcn.bc.ca>
Message-ID: <vndk8gz1k4r.fsf@camelot-new.ccs.neu.edu>

Kevin Liang <kevin@vcn.bc.ca> writes:

> class wrapper:
> 	def __init__(self,object):
> 		self.wrapped = object
> 	def __getattr__(self, attrname):
> 		print 'Trace:', attrname
> 		return getattr(self.wrapped, attrname)
> 
>   I know you need the last line to acutally use built-in functions
>   for lists, > dictionaries, etc.. (e.g. append something), but what
>   does it mean ? Why is a return needed ?  I keep thinking its
>   supposed to print something..

I'm not sure what you mean by needing that line to use builtin
functions, etc.  getattr() is just a way to dynamically access any
member of an object.  

This:

attrname = 'eggs'
x = getattr(self.wrapped, attrname) 

is basically equivalent to:

x = self.wrapped.eggs

If that doesn't make it clear, then reading the standard Python
documentation on the builtin function getattr() might be useful.

This class is presumably used by whoever wrote it for debugging
purposes.  It simply contains an object and prints to stdout when
instance members are referenced through it.  It uses the special class 
method __getattr__() to achieve this.  Handy stuff that's hard to do
in many other languages.

For instance:

>>> class X:
...  pass
... 
>>> x = X()
>>> x.spam = 1
>>> y = wrapper(x)
>>> y.spam
Trace: spam
1

The last line was returned by the __getattr__(), the one before it was 
emitted by the print statement.

-Justin

 


From dyoo@hkn.EECS.Berkeley.EDU  Sun May 14 09:12:37 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Sun, 14 May 2000 01:12:37 -0700 (PDT)
Subject: [Tutor] Re: Tutor digest, Vol 1 #306 - 8 msgs
In-Reply-To: <20000512160012.B48C51CDC8@dinsdale.python.org>
Message-ID: <Pine.LNX.4.21.0005140045410.32322-100000@hkn.EECS.Berkeley.EDU>

> Hours", and was doing quite well until chapter 6. Bogged down in tuples,
> with lists next. This is my first attempt at programming, and find this a
> bit much. How does one remember the syntax, functions, indentations, etc?

If this is your first time encoutering lists and tuples, then it'll take a
little while to understand their usage and usefulness.  Practice and
familiarity definitely help, but I wouldn't call it all mechanical syntax
--- there's something conceptually interesting about having a list.  A
list is a collection of data.  You might be familiar with shopping lists,
and in python, we'd represent that as a list of strings, like this:

  shopping_list = ['apple', 'ketchup', 'cottage cheese']

and if I wanted to get the first item of my strange diet, I'd say

  shopping_list[0]

It might feel weird to ask for the zeroth thing on your list.  That part
is a little hard to explain for me, so try to put that on the back burner
for now.

What may surprise you, though, is that you've already been introduced to a
list-like variable already!  You're probably already familiar enough with
single variables, like numbers and strings.

  book = "Teach Yourself Python in 21 Days"
  day = 24

But let's take a closer look at that 'book'.  First of all, let's take a
look at how long it is.

  len(book)

Python says "32".  But 32...what?  32 characters!  That is, a string can
be thought of as a collection (or, as your book calls them, sequences) of
characters.  It makes sense that a word is made up of letters.  Let's try
to make the analogy between lists and strings a little more clear.

  book[0]

will say 'T'.  What we've done is ask python, What is the first character
in our sentence "Teach Yourself Python in 21 Days"?

If we wanted to see every other letter in our sentence, we could try
something like:

  print book[0], book[2], book[4], book[6],

but already it's getting wearisome to keep on writing book[some even
number] in there.  That's why we use something like a loop to do things
with these list-like things:

  length = len(book)
  position = 0
  while position < length:
    print book[position],
    position = position + 2

(That comma at the end of the print statement is intentional.  See what
happens if you take it out)

So strings, lists, and tuples are all sequence structures.  You can ask
what they contain at a specific location, and this is called
"subscripting".  Start slow, explore what you can do, and experiment with
python a little more --- make sure that things make sense, and if they
don't, feel free to ask for clarification.  Hope this helps!



From curtis.larsen@Covance.Com  Mon May 15 18:19:18 2000
From: curtis.larsen@Covance.Com (Curtis Larsen)
Date: Mon, 15 May 2000 12:19:18 -0500
Subject: [Tutor] DLLs and Python?
Message-ID: <s91feb64.055@madmail.truax.covance.com>

At the risk of asking a Really Dumb Question [too late], is there a
straight-forward way for (WX) Python to access application-specific
objects/APIs vendors have made available with(in) DLL files, similar to
how it can be done in [gasp] VBA?

If I can avoid VBA, and use Python instead...
(Code snippets / URLs / Docs most welcome.)



-----------------------------------------------------
Confidentiality Notice: This e-mail transmission 
may contain confidential or legally privileged 
information that is intended only for the individual 
or entity named in the e-mail address. If you are not 
the intended recipient, you are hereby notified that 
any disclosure, copying, distribution, or reliance 
upon the contents of this e-mail is strictly prohibited. 

If you have received this e-mail transmission in error, 
please reply to the sender, so that Covance can arrange 
for proper delivery, and then please delete the message 
from your inbox. Thank you.
begin 644 TEXT.htm
M/"%$3T-465!%($A434P@4%5"3$E#("(M+R]7,T,O+T141"!(5$U,(#0N,"!4
M<F%N<VET:6]N86PO+T5.(CX-"CQ(5$U,/CQ(14%$/@T*/$U%5$$@8V]N=&5N
M=#TB=&5X="]H=&UL.R!C:&%R<V5T/6ES;RTX.#4Y+3$B(&AT='`M97%U:78]
M0V]N=&5N="U4>7!E/@T*/$U%5$$@8V]N=&5N=#TB35-(5$U,(#4N,#`N,CDQ
M.2XV,S`W(B!N86UE/4=%3D52051/4CX\+TA%040^#0H\0D]$62!B9T-O;&]R
M/2-F9F9F9F8@#0IS='EL93TB1D].5#H@,3!P="!!<FEA;#L@34%21TE.+4Q%
M1E0Z(#)P>#L@34%21TE.+51/4#H@,G!X(CX-"CQ$258^070@=&AE(')I<VL@
M;V8@87-K:6YG(&$@4F5A;&QY($1U;6(@475E<W1I;VX@6W1O;R!L871E72PF
M;F)S<#MI<R!T:&5R92!A(`T*<W1R86EG:'0M9F]R=V%R9"!W87D@9F]R("A7
M6"D@4'ET:&]N('1O(&%C8V5S<R!A<'!L:6-A=&EO;BUS<&5C:69I8R!O8FIE
M8W1S+T%027,@#0IV96YD;W)S(&AA=F4@;6%D92!A=F%I;&%B;&4@=VET:"AI
M;BD@1$Q,(&9I;&5S+"!S:6UI;&%R('1O(&AO=R!I="!C86X@8F4@9&]N92!I
M;B`-"EMG87-P72!60D$_/"]$258^#0H\1$E6/B9N8G-P.SPO1$E6/@T*/$1)
M5CY)9B!)(&-A;B!A=F]I9"!60D$L(&%N9"!U<V4@4'ET:&]N(&EN<W1E860N
M+BX\+T1)5CX-"CQ$258^*$-O9&4@<VYI<'!E=',@+R!54DQS("\@1&]C<R!M
M;W-T('=E;&-O;64N*3PO1$E6/@T*/$1)5CXF;F)S<#L\+T1)5CX\+T)/1%D^
)/"](5$U,/@T*
`
end


From knm850@peoplepc.com  Tue May 16 08:24:03 2000
From: knm850@peoplepc.com (Kris Miller)
Date: Tue, 16 May 2000 01:24:03 -0600
Subject: [Tutor] tutor mailing list
Message-ID: <000801bfbf09$2fdbad40$55ece13f@kris>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01BFBED5.6BBFB2E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Please add me to your tutor mailing list.  Thank you

------=_NextPart_000_0005_01BFBED5.6BBFB2E0
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=3D"Comic Sans MS" size=3D2>Please add me to your tutor =
mailing=20
list.&nbsp; Thank you</FONT></DIV></BODY></HTML>

------=_NextPart_000_0005_01BFBED5.6BBFB2E0--



From johnc@greatentertaining.com  Tue May 16 08:45:40 2000
From: johnc@greatentertaining.com (John Choi)
Date: Tue, 16 May 2000 00:45:40 -0700
Subject: [Tutor] does anyone know the time module
Message-ID: <NDBBIKOHLKEBLKDLNMENGEHACCAA.johnc@greatentertaining.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0002_01BFBED0.0F10FDB0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi everyone:

I've been working my way through Ivan's book and find the examples to be the
biggest help in learning Python.  Most excellent learning guide Ivan!

I'd like to start doing stuff with time...

Using two dates as user-input strings in this format DD-MM-YY, find the
number of days between them.

I'd also like to put to use the leap.py program to determine Gregorian leap
years, i.e 365 versus 366 days in a year.

Any and all help would be great.

Cheers,

J.C.

------=_NextPart_000_0002_01BFBED0.0F10FDB0
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></HEAD>
<BODY>
<DIV><SPAN class=3D038553407-16052000>Hi everyone:</SPAN></DIV>
<DIV><SPAN class=3D038553407-16052000></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D038553407-16052000>I've been working my way through =
Ivan's book=20
and find the examples to be the biggest help in learning Python.&nbsp; =
Most=20
excellent learning guide Ivan!</SPAN></DIV>
<DIV><SPAN class=3D038553407-16052000></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D038553407-16052000>I'd like to start doing stuff with =

time...</SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=3D038553407-16052000>Using two dates as user-input =
strings in=20
this format DD-MM-YY, find the number of days between them.&nbsp; =
</SPAN></DIV>
<DIV><SPAN class=3D038553407-16052000></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D038553407-16052000>I'd also like to put to use the =
leap.py=20
program to determine Gregorian leap years, i.e 365 versus 366 days in a=20
year.</SPAN></DIV>
<DIV><SPAN class=3D038553407-16052000></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D038553407-16052000>Any and all help would be=20
great.</SPAN></DIV>
<DIV><SPAN class=3D038553407-16052000></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D038553407-16052000>Cheers,</SPAN></DIV>
<DIV><SPAN class=3D038553407-16052000></SPAN>&nbsp;</DIV>
<DIV align=3Dleft><FONT size=3D2><FONT face=3DTahoma>J<SPAN=20
class=3D038553407-16052000>.C.</SPAN></FONT></FONT></DIV></BODY></HTML>

------=_NextPart_000_0002_01BFBED0.0F10FDB0--



From ivanlan@home.com  Tue May 16 13:26:41 2000
From: ivanlan@home.com (Ivan Van Laningham)
Date: Tue, 16 May 2000 06:26:41 -0600
Subject: [Tutor] does anyone know the time module
References: <NDBBIKOHLKEBLKDLNMENGEHACCAA.johnc@greatentertaining.com>
Message-ID: <39213E81.BD0D41AA@home.com>

Hi All--

> John Choi wrote:
> 
> Hi everyone:
> 
> I've been working my way through Ivan's book and find the examples to
> be the biggest help in learning Python.  Most excellent learning guide
> Ivan!
> 

Thanks!

> I'd like to start doing stuff with time...
> 
> Using two dates as user-input strings in this format DD-MM-YY, find
> the number of days between them.
> 

Unless you want to figure out exactly how this is done to help you learn
more about the mechanics of calendrical systems, you might look into
Mark-Andre's mxDateTime package.  Check 

	http://www.python.org/

for links, or check Parnassus

	http://www.vex.net/parnassus/

If you want to find out more about calendars, look at the Calendar FAQ:

	http://www.pauahtun.org/CalendarFAQ/

> I'd also like to put to use the leap.py program to determine Gregorian
> leap years, i.e 365 versus 366 days in a year.
> 

python leap.py 0 100 200 300 400

;-)  You can modify the source to have it print out the number of days
in a year if you want.

<the-downward-road-is-crowded-crowded>-ly y'rs,
Ivan
----------------------------------------------
Ivan Van Laningham
Axent Technologies, Inc.
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours


From alan.gauld@bt.com  Tue May 16 17:31:39 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 16 May 2000 17:31:39 +0100
Subject: [Tutor] does anyone know the time module
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D134@mbtlipnt02.btlabs.bt.co.uk>

> > be the biggest help in learning Python.  Most excellent learning guide
> > Ivan!

Dunno if this is old news but I noticed an article on the 
O'Reilly web site giving Ivan's book a sideways plug as 
being the most suitable one available for complete 
beginners (as opposed to their own Learning Python
which is officially for those who can already program).

Apparently they tried to put a link to it from the ORA page 
but SAMS site won't accept links other than to the top level...

All-publicity-is-good-publicitly-yrs,

Alan G.


From vdbroekw@wxs.nl  Tue May 16 21:14:11 2000
From: vdbroekw@wxs.nl (W.W. van den Broek)
Date: Tue, 16 May 2000 22:14:11 +0200
Subject: [Tutor] Internet programming with python
Message-ID: <3921AC13.5B617BE6@wxs.nl>

I am looking for this book, no where to find, does someone know were i
can buy it, or does anyone have a copy for me
thanks walter
-- 
W.W. van den Broek	e-mail:		vandenbroek@psyd.azr.nl
AZR-Dijkzigt		fax:		010-4633217
afdeling psychiatrie	tel:		010-4639222
Postbus 2040		e-mail		vdbroekw@wxs.nl (thuis)
3000 CA Rotterdam	homepage:	http://home.planet.nl/~vdbroekw


From DOUGS@oceanic.com  Tue May 16 23:07:45 2000
From: DOUGS@oceanic.com (Doug Stanfield)
Date: Tue, 16 May 2000 12:07:45 -1000
Subject: [Tutor] Internet programming with python
Message-ID: <8457258D741DD411BD3D0050DA62365907A182@huina.oceanic.com>

I got my second copy through Amazon.com.

Its out of print and they don't stock it but they help you to find it and
buy from a third party.

-Doug-

If the person who got my first copy happens to read this, I don't need it
back but you still owe me ;-)

> -----Original Message-----
> From: W.W. van den Broek [mailto:vdbroekw@wxs.nl]
> Sent: Tuesday, May 16, 2000 10:14 AM
> To: tutor@python.org
> Subject: [Tutor] Internet programming with python
> 
> 
> I am looking for this book, no where to find, does someone know were i
> can buy it, or does anyone have a copy for me
> thanks walter
> -- 
> W.W. van den Broek	e-mail:		vandenbroek@psyd.azr.nl
> AZR-Dijkzigt		fax:		010-4633217
> afdeling psychiatrie	tel:		010-4639222
> Postbus 2040		e-mail		vdbroekw@wxs.nl (thuis)
> 3000 CA Rotterdam	homepage:	http://home.planet.nl/~vdbroekw
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 


From rbl@hal.cwru.edu  Wed May 17 00:06:58 2000
From: rbl@hal.cwru.edu (Robin B. Lake)
Date: Tue, 16 May 2000 19:06:58 -0400 (EDT)
Subject: [Tutor] Internet programming with python
Message-ID: <200005162306.TAA26205@hal.epbi.cwru.edu>

Several weeks ago, the Borders Outlet Store east of Cleveland had
copies for about $3.00, as I recall.  I'll look next time I'm out there
and report back.

Cheers,
Rob Lake
rbl@hal.cwru.edu

> From tutor-admin@python.org Tue May 16 18:02:20 2000
> Delivered-To: tutor@python.org
> To: "'W.W. van den Broek'" <vdbroekw@wxs.nl>, tutor@python.org
> Subject: RE: [Tutor] Internet programming with python
> MIME-Version: 1.0
> X-BeenThere: tutor@python.org
> X-Mailman-Version: 2.0beta3
> List-Id: Discussion for learning programming with Python <tutor.python.org>
> 
> I got my second copy through Amazon.com.
> 
> Its out of print and they don't stock it but they help you to find it and
> buy from a third party.
> 
> -Doug-
> 
> If the person who got my first copy happens to read this, I don't need it
> back but you still owe me ;-)
> 
> > -----Original Message-----
> > From: W.W. van den Broek [mailto:vdbroekw@wxs.nl]
> > Sent: Tuesday, May 16, 2000 10:14 AM
> > To: tutor@python.org
> > Subject: [Tutor] Internet programming with python
> > 
> > 
> > I am looking for this book, no where to find, does someone know were i
> > can buy it, or does anyone have a copy for me
> > thanks walter
> > -- 
> > W.W. van den Broek	e-mail:		vandenbroek@psyd.azr.nl
> > AZR-Dijkzigt		fax:		010-4633217
> > afdeling psychiatrie	tel:		010-4639222
> > Postbus 2040		e-mail		vdbroekw@wxs.nl (thuis)
> > 3000 CA Rotterdam	homepage:	http://home.planet.nl/~vdbroekw
> > 
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://www.python.org/mailman/listinfo/tutor
> > 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 


From danstar@execpc.com  Wed May 17 00:28:04 2000
From: danstar@execpc.com (Dan Star)
Date: Tue, 16 May 2000 18:28:04 -0500
Subject: [Tutor] Internet programming with python
References: <200005162306.TAA26205@hal.epbi.cwru.edu>
Message-ID: <3921D984.E1314315@execpc.com>

What book is this

"Robin B. Lake" wrote:
> 
> Several weeks ago, the Borders Outlet Store east of Cleveland had
> copies for about $3.00, as I recall.  I'll look next time I'm out there
> and report back.
> 
> Cheers,
> Rob Lake
> rbl@hal.cwru.edu
> 
> > From tutor-admin@python.org Tue May 16 18:02:20 2000
> > Delivered-To: tutor@python.org
> > To: "'W.W. van den Broek'" <vdbroekw@wxs.nl>, tutor@python.org
> > Subject: RE: [Tutor] Internet programming with python
> > MIME-Version: 1.0
> > X-BeenThere: tutor@python.org
> > X-Mailman-Version: 2.0beta3
> > List-Id: Discussion for learning programming with Python <tutor.python.org>
> >
> > I got my second copy through Amazon.com.
> >
> > Its out of print and they don't stock it but they help you to find it and
> > buy from a third party.
> >
> > -Doug-
> >
> > If the person who got my first copy happens to read this, I don't need it
> > back but you still owe me ;-)
> >
> > > -----Original Message-----
> > > From: W.W. van den Broek [mailto:vdbroekw@wxs.nl]
> > > Sent: Tuesday, May 16, 2000 10:14 AM
> > > To: tutor@python.org
> > > Subject: [Tutor] Internet programming with python
> > >
> > >
> > > I am looking for this book, no where to find, does someone know were i
> > > can buy it, or does anyone have a copy for me
> > > thanks walter
> > > --
> > > W.W. van den Broek  e-mail:         vandenbroek@psyd.azr.nl
> > > AZR-Dijkzigt                fax:            010-4633217
> > > afdeling psychiatrie        tel:            010-4639222
> > > Postbus 2040                e-mail          vdbroekw@wxs.nl (thuis)
> > > 3000 CA Rotterdam   homepage:       http://home.planet.nl/~vdbroekw
> > >
> > > _______________________________________________
> > > Tutor maillist  -  Tutor@python.org
> > > http://www.python.org/mailman/listinfo/tutor
> > >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://www.python.org/mailman/listinfo/tutor
> >
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor


From blink1eighty2@juno.com  Wed May 17 02:03:54 2000
From: blink1eighty2@juno.com (Crash Course)
Date: Tue, 16 May 2000 20:03:54 -0500
Subject: [Tutor] Drex is the name
Message-ID: <20000516.200402.-634761.2.Blink1eighty2@juno.com>

i want to learn the languages of hacking 
could you send me some info about it
-Drex
________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.


From lukeamdor@hotmail.com  Wed May 17 13:29:14 2000
From: lukeamdor@hotmail.com (Luke Amdor)
Date: Wed, 17 May 2000 07:29:14 CDT
Subject: [Tutor] Disconnecting Dial-up Networking
Message-ID: <20000517122914.35656.qmail@hotmail.com>

Hi,
i'm using windows 95 and i was wondering if there was a way to disconnect 
from dial-up networking so that i may connect, get the data i need, and then 
disconnect. if any you have any idea how i could accomplish disconnecting, 
please respond. your help would be greatly appreciated.

thanks,
luke
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com



From rbl@hal.cwru.edu  Wed May 17 17:03:59 2000
From: rbl@hal.cwru.edu (Robin B. Lake)
Date: Wed, 17 May 2000 12:03:59 -0400 (EDT)
Subject: [Tutor] How to?
Message-ID: <200005171603.MAA29226@hal.epbi.cwru.edu>

I've RTFM, but can't quite see how to do this in Python.  Could do it
in UNIX sed, but can't get the Python twist to it yet.

I have a file of HTML, with lines like:
<TR ALIGN=left VALIGN=top><TD><A HREF="RMP_DTL$FAC.QueryView?P_FACILITY_ID=14206">14206</A><TD>1000 0015 0034<TD>ALASKA NITROGEN PRODUCS LLC<TD>KENAI<TD>AK<TD>25-JUN-1999

I want to extract the value following the FACILITY_ID= section of the string,
that is 14206 for this line.  I'll then use that to create a
urllib.openurl command with params = urllib.urlencode({'P_FACILITY_ID':that-value})
and get the next lower level of information.

Thanks for any help or suggestions.

Cheers,
Rob Lake
rbl@hal.cwru.edu


From rbl@hal.cwru.edu  Wed May 17 17:52:43 2000
From: rbl@hal.cwru.edu (Robin B. Lake)
Date: Wed, 17 May 2000 12:52:43 -0400 (EDT)
Subject: [Tutor] How to get rid of a " in a string?
Message-ID: <200005171652.MAA29620@hal.epbi.cwru.edu>

I've resolved the previous posting, but some of the numbers are
4 digit instead of 5 digit.  I have a string with 1234"  and tried
string.replace(mystring, '\"','') but that does not work.

On a Mac, Python 1.6.1 (I guess).

Thanks,
Rob Lake
rbl@hal.cwru.edu


From makani@encommerce.com  Wed May 17 17:57:07 2000
From: makani@encommerce.com (Makani Lum)
Date: Wed, 17 May 2000 09:57:07 -0700
Subject: [Tutor] ftp
Message-ID: <NDBBKKDBCLJJKHHODHHPMEFECEAA.makani@encommerce.com>

I am working on a project that requires FTP between Solaris and Win 98/NT
machines.  I was able to FTP to the Solaris machine but was unable to get or
put anything on the machine.  I can only list the directories if I follow
the sample that is posted in the Documentation.  Do you know the commands
for the basics such as get, put, change directory, etc...?  Also is it
possible to go from Win to Win?

Thanks,
Makani

Makani Lum
Software Engineer, System Performance Engineering
makani@encommerce.com
enCommerce, Inc.
2901 Patrick Henry Drive
Santa Clara, Ca. 95054




From rbl@hal.cwru.edu  Wed May 17 17:57:17 2000
From: rbl@hal.cwru.edu (Robin B. Lake)
Date: Wed, 17 May 2000 12:57:17 -0400 (EDT)
Subject: [Tutor] Answering my own question ...
Message-ID: <200005171657.MAA29700@hal.epbi.cwru.edu>

Duh!  Strings are immuatable, so
string.replace(mystring, '\"', '') won't work, but
newstring = string.replace(mystring, '\"', '')  works just fine!

Sorry for the bother.

Cheers,
Rob Lake


From Moshe Zadka <moshez@math.huji.ac.il>  Wed May 17 21:32:34 2000
From: Moshe Zadka <moshez@math.huji.ac.il> (Moshe Zadka)
Date: Wed, 17 May 2000 23:32:34 +0300 (IDT)
Subject: [Tutor] How to?
In-Reply-To: <200005171603.MAA29226@hal.epbi.cwru.edu>
Message-ID: <Pine.GSO.4.10.10005172330210.10825-100000@sundial>

On Wed, 17 May 2000, Robin B. Lake wrote:

> I've RTFM, but can't quite see how to do this in Python.  Could do it
> in UNIX sed, but can't get the Python twist to it yet.
> 
> I have a file of HTML, with lines like:
> <TR ALIGN=left VALIGN=top><TD><A HREF="RMP_DTL$FAC.QueryView?P_FACILITY_ID=14206">14206</A><TD>1000 0015 0034<TD>ALASKA NITROGEN PRODUCS LLC<TD>KENAI<TD>AK<TD>25-JUN-1999
> 
> I want to extract the value following the FACILITY_ID= section of the string,
> that is 14206 for this line.  I'll then use that to create a
> urllib.openurl command with params = urllib.urlencode({'P_FACILITY_ID':that-value})
> and get the next lower level of information.
> 
> Thanks for any help or suggestions.

Have you specifically read the htmllib and urllib modules' documentation?
And the "urlparse" module?

The steps involved are:

1. Use htmllib to get the anchor list
2. Use urlparse to break it into parts
3. Use urllib to get the page




From Vincent.Raaijmakers@Casi-Rusco.com  Wed May 17 22:00:03 2000
From: Vincent.Raaijmakers@Casi-Rusco.com (Vincent Raaijmakers)
Date: Wed, 17 May 2000 17:00:03 -0400
Subject: [Tutor] Newbee needs information about tcl/tk
Message-ID: <9B6977074BA8D311B3B30090279C703B287CBA@bctexc10.casi-rusco.com>

	Hello,

	I'm very new with python. I learned the basic things and are very
interested in the 
	Corba possibilities within Python.  Though, the question I have is
not yet in this area. I'm also 
	very interested in the tcl/tk stuff. However, I'm not able to find
the information 
	needed to make easily a graphical application. The demo's shows very
nice things, 
	but looking at the code I get scared.

	Is there information available about tools, doc's of writing
graphical applications 
	using python?

	Best regards,
	Vincent Raaijmakers



From deirdre@deirdre.net  Thu May 18 01:09:03 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Wed, 17 May 2000 17:09:03 -0700 (PDT)
Subject: [Tutor] Newbee needs information about tcl/tk
In-Reply-To: <9B6977074BA8D311B3B30090279C703B287CBA@bctexc10.casi-rusco.com>
Message-ID: <Pine.LNX.4.10.10005171706530.11546-100000@rockhopper.deirdre.org>

On Wed, 17 May 2000, Vincent Raaijmakers wrote:

> 	I'm very new with python. I learned the basic things and are
> very interested in the Corba possibilities within Python.  Though, the
> question I have is not yet in this area. I'm also very interested in
> the tcl/tk stuff. However, I'm not able to find the information needed
> to make easily a graphical application. The demo's shows very nice
> things, but looking at the code I get scared.

I presume you're using Windows? If so, you may wish to look at wxWindows.
As it doesn't run on the platforms I prefer, I don't use it.

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"Linux means never having to delete your love mail." -- Don Marti



From nmr@techspot.com  Thu May 18 09:04:24 2000
From: nmr@techspot.com (nmr@techspot.com)
Date: Thu, 18 May 2000 04:04:24 -0400 (EDT)
Subject: [Tutor] howto?
Message-ID: <00051804042424.11952@webb3.iname.net>

Hello
I have started a few days ago reading the Python
Documentation and now I'm writing very easy and 
little programs on this language, but since I'm
not much familiar with english language (my mater
language is spanish) i have not understanded very
well the part of the documentation that explains how
to run the programs when i write them in a text editor for example windows note pad or Linux pico text editor.
I will appreciate a lot any help.






From scarblac@pino.selwerd.nl  Thu May 18 09:19:54 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 18 May 2000 10:19:54 +0200
Subject: [Tutor] howto?
In-Reply-To: <00051804042424.11952@webb3.iname.net>; from nmr@techspot.com on Thu, May 18, 2000 at 04:04:24AM -0400
References: <00051804042424.11952@webb3.iname.net>
Message-ID: <20000518101954.A9095@pino.selwerd.nl>

On Thu, May 18, 2000 at 04:04:24AM -0400, nmr@techspot.com wrote:
> Hello
> I have started a few days ago reading the Python
> Documentation and now I'm writing very easy and 
> little programs on this language, but since I'm
> not much familiar with english language (my mater
> language is spanish) i have not understanded very
> well the part of the documentation that explains how
> to run the programs when i write them in a text editor for example windows note pad or Linux pico text editor.
> I will appreciate a lot any help.

Under Windows, just make sure the filename ends with '.py' and then click on
it.

Under both Windows and Linux, get a command line, go to the directory with
the file in it, and type "python <filename>".

Under Linux, put "#!/usr/local/bin/python" on the first line of the file (or
whatever the path to your python is), make it executable (chmod +x
<filename>) and then just start it like any other program.

Also note the three links at
http://www.python.org/doc/NonEnglish.html#spanish .

-- 
Remco Gerlich,  scarblac@pino.selwerd.nl


From kmoulfi@emirates.net.ae  Thu May 18 11:30:18 2000
From: kmoulfi@emirates.net.ae (Khalid MOULFI)
Date: Thu, 18 May 2000 14:30:18 +0400
Subject: [Tutor] Read a file text and write on another one !
Message-ID: <1.5.4.32.20000518103018.0068e848@emirates.net.ae>

Hi python world, every body,

first thanks to all who help me to install pyhon 1.5.2 on AIX 3.2.5.
Really, thank you !

Second, I have a request as I'm new and try to program with python.

I would like to read a text file formated as follow :

7043         710980033          05/09/2000 10:00:36
2044         710930005          05/09/2000 10:02:17
7043         710950008          05/09/2000 10:02:23
2044         710900001          05/09/2000 10:03:33
2044         710900004          05/09/2000 10:04:55
2044         710900003          05/09/2000 10:05:25
7043         710900019          05/09/2000 10:06:19

and try to read lines 49,66,72,89,95,112,...
to put these lines in another text file, sorted by the first column.

Some questions :

Is there any command to read the number of lines of the input file text ?
Like this, I will try to use the while command.

Is there anyway after sorting the output file to have the number of lines
per user
which is the first column ?

Another request :

I tried in a test file to launch the command :

----
import os

file = open('t1.txt','r')
os.system('ls -al ' + file)

I had when I launched it the following outputs :

<closed file '/test/koko.startup', mode 'w' at 20095078>
Traceback (innermost last):
  File "ex3.py", line 25, in ?
  	cmd = 'ls -al ' + file
TypeError: illegal argument type for built-in operation
----

Thanks to anybody who can help me!

khalid




From steve@spvi.com  Thu May 18 13:12:20 2000
From: steve@spvi.com (Steve Spicklemire)
Date: Thu, 18 May 2000 07:12:20 -0500 (EST)
Subject: [Tutor] Read a file text and write on another one !
In-Reply-To: <1.5.4.32.20000518103018.0068e848@emirates.net.ae> (message from
 Khalid MOULFI on Thu, 18 May 2000 14:30:18 +0400)
Message-ID: <200005181212.HAA21284@mercury.spvi.com>

Hi Khalid,

>>>>> "Khalid" == Khalid MOULFI <kmoulfi@emirates.net.ae> writes:


    Khalid> and try to read lines 49,66,72,89,95,112,...  to put these
    Khalid> lines in another text file, sorted by the first column.

    Khalid> Some questions :

    Khalid> Is there any command to read the number of lines of the
    Khalid> input file text ?  Like this, I will try to use the while
    Khalid> command.

lines = file.readlines()

print len(lines)


    Khalid> Is there anyway after sorting the output file to have the
    Khalid> number of lines per user which is the first column ?

Hmm.. I don't think I follow this one... 

    Khalid> Another request :

    Khalid> I tried in a test file to launch the command :

    Khalid> ---- import os

    Khalid> file = open('t1.txt','r') os.system('ls -al ' + file)

'file' is a file object
'ls -al' is a string

what is it you are trying to find out about the file? You
might look at the os.stat function and the stat module.

For what it's worth.. you can put the whole think in
a list of lists and sort the list on the first item

def cmp1st(x, y):
	if x[0] < y[0]:
		return -1
	elif x[0] == y[0]:
		return 0
	else:
		return 1

list = []
for line in lines: # lines from above...
	list.append(string.split(line))


def cmp1st(x, y):
	if x[0] < y[0]:
		return -1
	elif x[0] == y[0]:
		return 0
	else:
		return 1


list.sort(cmp1st)

print list

    Khalid> Thanks to anybody who can help me!

    Khalid> khalid


Good Luck!
-steve


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



From steve@spvi.com  Thu May 18 13:17:18 2000
From: steve@spvi.com (Steve Spicklemire)
Date: Thu, 18 May 2000 07:17:18 -0500 (EST)
Subject: [Tutor] Read a file text and write on another one !
In-Reply-To: <200005181212.HAA21284@mercury.spvi.com> (message from Steve
 Spicklemire on Thu, 18 May 2000 07:12:20 -0500 (EST))
Message-ID: <200005181217.HAA21321@mercury.spvi.com>

Ack.. I somehow got cmp1st in there twice! Programming
in email is never easy. ;-) Also.. I should point
out that string.split() returns a list of *strings*.
If you want to interpret the values as numbers, you'll
need to enforce that coersion manually... 

e.g., 


list=[]
for line in lines:
	list.apened(string.split.. etc...)
	list[-1][0] = string.atoi(list[-1][0])  # convert the 
						# first item in the 
						# last added list to int...


-steve


From borgulya@pons.sote.hu  Thu May 18 16:10:21 2000
From: borgulya@pons.sote.hu (Borgulya Gabor)
Date: Thu, 18 May 2000 17:10:21 +0200 (CEST)
Subject: [Tutor] Read a file text and write on another one !
In-Reply-To: <1.5.4.32.20000518103018.0068e848@emirates.net.ae>
Message-ID: <Pine.LNX.3.96.1000518162827.11479B-100000@Pons.sote.hu>


On Thu, 18 May 2000, Khalid MOULFI wrote:
> file = open('t1.txt','r')
> os.system('ls -al ' + file)
> 
> I had when I launched it the following outputs :
> 
> <closed file '/test/koko.startup', mode 'w' at 20095078>
> Traceback (innermost last):
>   File "ex3.py", line 25, in ?
>   	cmd = 'ls -al ' + file
> TypeError: illegal argument type for built-in operation

The following code should work (although there is shurely a better
solution):

filename='t1.txt'
os.system('ls -al ' + filename + ' > ls_output.txt')
file = open('ls_output.txt','r')

Gabor



From alan.gauld@bt.com  Thu May 18 17:31:30 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 18 May 2000 17:31:30 +0100
Subject: [Tutor] howto?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D154@mbtlipnt02.btlabs.bt.co.uk>

> Under Windows, just make sure the filename ends with '.py' 
> and then click on it.

Its also a good idea to add this line to the end of 
the program if you want to see printed output:

raw_input('Hit any key to exit')

That will prevent the DOS box from opening and 
printing the output and then immediately closing again!

Alan G.


From alan.gauld@bt.com  Thu May 18 17:22:52 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 18 May 2000 17:22:52 +0100
Subject: [Tutor] ftp
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D151@mbtlipnt02.btlabs.bt.co.uk>

> machines.  I was able to FTP to the Solaris machine but was 
> unable to get or put anything on the machine.  

Do you have permissions set on the Solaris machine
- ie the user account that you login to ftp with?

> Also is it possible to go from Win to Win?

Yes, provided the accessed machine is running an 
ftp daemon or service. I don';t think you get one 
with Win 9x, you do with NT. But there are several 
3rd party ftpd's around for Win32.

Beware security implications on Win9x machines tho...

Alan G.


From alan.gauld@bt.com  Thu May 18 17:25:49 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 18 May 2000 17:25:49 +0100
Subject: [Tutor] Newbee needs information about tcl/tk
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D152@mbtlipnt02.btlabs.bt.co.uk>

Look on python.org for the Tkinter tutorials.

F/'s tutor is very good, better when its completed!

You can look at my web tutor for some very basic 
intro too, under event driven programs and the 
Case Study. but theres not a lot of Tkinter stuff 
there, just some examples with a little explanation.

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



From alan.gauld@bt.com  Thu May 18 17:29:29 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 18 May 2000 17:29:29 +0100
Subject: [Tutor] howto?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D153@mbtlipnt02.btlabs.bt.co.uk>

> not much familiar with english language (my mater
> language is spanish) i have not understanded very
> well the part of the documentation that explains how
> to run the programs when i write them in a text editor for 
> example windows note pad or Linux pico text editor.

Sorry I can't offer immediate help but I hope to have 
a Spanish translation of my online tutor available 
soon - one of my readers has volunteered, its not 
in my hands...

Meantime, try posting your specific problems here 
and we will do our best. 

Maybe someone who speaks Spanish will volunteer 
for some 1:1 help. (I assume somebody on the lists 
speaks Spanish!?)

Alan G.


From MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV  Thu May 18 18:32:14 2000
From: MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV (MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV)
Date: Thu, 18 May 2000 13:32:14 -0400
Subject: Re[2]: [Tutor] howto?
Message-ID: <3047260156@customs.treas.gov>

     Actually this should be:
     raw_input("Hit enter to exit")
     raw_input doesn't do character reads, it waits for the newline.
     
     Mike W.


______________________________ Reply Separator _________________________________
Subject: RE: [Tutor] howto?
Author:  alan.gauld@bt.com at smtplink
Date:    5/18/00 12:31 PM


> Under Windows, just make sure the filename ends with '.py' 
> and then click on it.
     
Its also a good idea to add this line to the end of 
the program if you want to see printed output:
     
raw_input('Hit any key to exit')
     
That will prevent the DOS box from opening and 
printing the output and then immediately closing again!
     
Alan G.
     
_______________________________________________ 
Tutor maillist  -  Tutor@python.org
http://www.python.org/mailman/listinfo/tutor
     



From joanca@typerware.com  Thu May 18 19:02:42 2000
From: joanca@typerware.com (JoanCarles p Casas=?ISO-8859-1?Q?=edn?=)
Date: Thu, 18 May 2000 20:02:42 +0200
Subject: [Tutor] howto?
Message-ID: <20000518180215.A286B1CE58@dinsdale.python.org>

At 18/5/00 18:29 alan.gauld@bt.com wrote:

>> not much familiar with english language (my mater
>> language is spanish) i have not understanded very
>> well the part of the documentation that explains how
>> to run the programs when i write them in a text editor for 
>> example windows note pad or Linux pico text editor.
>
>Sorry I can't offer immediate help but I hope to have 
>a Spanish translation of my online tutor available 
>soon - one of my readers has volunteered, its not 
>in my hands...

Drop a line here when it's available, please.

>Meantime, try posting your specific problems here 
>and we will do our best. 
>
>Maybe someone who speaks Spanish will volunteer 
>for some 1:1 help. (I assume somebody on the lists 
>speaks Spanish!?)

I do, but maybe the problem is I don't know too much Python ;)
But I offer help if I can...


-> JoanCarles


From bwisti@hotmail.com  Fri May 19 21:23:33 2000
From: bwisti@hotmail.com (Brian Wisti)
Date: Fri, 19 May 2000 13:23:33 PDT
Subject: [Tutor] Global Regular Expressions?
Message-ID: <20000519202333.5092.qmail@hotmail.com>

Hi all,

I'm sure that this is just staring me in the face, but I can't figure out 
how to step through a string with a regular expression.  I know how I want 
to do this in Perl.  How about I show you what I mean in Perl?

-- Perl Code --
#!/usr/bin/env perl

# A simple example of the strings I'm looking at.
my $string = "<td>item1</td> <td>item2</td><td>item3</td>";

# Find the text within each table cell, and show each match
while ($string =~ m!<td>(.+?)</td>!g) {
	print "Matched: ", $1, "\n";
}

print "All done!\n";
-- End of Code --

So how do I say it in Python?  Would I be able to use a while loop, or is 
there some other construct (splitting, or whatever) that I should be using?

Thanks ahead of time for any ideas,
Brian Wisti
bwisti@hotmail.com
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com



From bwisti@hotmail.com  Fri May 19 23:46:19 2000
From: bwisti@hotmail.com (Brian Wisti)
Date: Fri, 19 May 2000 15:46:19 PDT
Subject: [Tutor] Regular Expressions part 2
Message-ID: <20000519224620.1412.qmail@hotmail.com>

Hi all,

Okay, so I figured out that re.findall() does a global search.  Well and 
good.

Now I am on to a new strangeness.  Although I can print out the resulting 
list, and use "for item in matches" to step through the list, I cannot use 
array notation to access the list that results from a re.findall().

For some strange reason, this thing that looks like an array (it even has a 
length of 2) tells me about "list index out of range" when I try to access 
matches[0].

Umm... what am I missing now?

Thanks,
Brian Wisti
bwisti@hotmail.com
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com



From charlie@intelligenesis.net  Sat May 20 00:00:52 2000
From: charlie@intelligenesis.net (Charlie Derr)
Date: Fri, 19 May 2000 19:00:52 -0400
Subject: [Tutor] Regular Expressions part 2
In-Reply-To: <20000519224620.1412.qmail@hotmail.com>
Message-ID: <NDBBLJJLLFOJMLCMJPLOKEEGDPAA.charlie@intelligenesis.net>

I think you need to post your code.

I tried what you said and it worked for me:

>>> import re
>>> g = "bbbbbbkkdkdkdkdk"
>>> r = re.findall('b',g)
>>> type(r)
<type 'list'>
>>> r
['b', 'b', 'b', 'b', 'b', 'b']
>>> len(r)
6
>>> r[0]
'b'
>>>


|-----Original Message-----
|From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
|Brian Wisti
|Sent: Friday, May 19, 2000 6:46 PM
|To: tutor@python.org
|Subject: [Tutor] Regular Expressions part 2
|
|
|Hi all,
|
|Okay, so I figured out that re.findall() does a global search.  Well and
|good.
|
|Now I am on to a new strangeness.  Although I can print out the resulting
|list, and use "for item in matches" to step through the list, I cannot use
|array notation to access the list that results from a re.findall().
|
|For some strange reason, this thing that looks like an array (it
|even has a
|length of 2) tells me about "list index out of range" when I try to access
|matches[0].
|
|Umm... what am I missing now?
|
|Thanks,
|Brian Wisti
|bwisti@hotmail.com
|________________________________________________________________________
|Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
|
|
|_______________________________________________
|Tutor maillist  -  Tutor@python.org
|http://www.python.org/mailman/listinfo/tutor
|



From bwisti@hotmail.com  Sat May 20 00:36:14 2000
From: bwisti@hotmail.com (Brian Wisti)
Date: Fri, 19 May 2000 16:36:14 PDT
Subject: [Tutor] Regular Expressions part 2
Message-ID: <20000519233614.95745.qmail@hotmail.com>

Charlie,

Thanks for responding so quickly.  The original code is a little intricate 
(going crazy on the OO stuff), but here is the least contrived facsmile I 
can come up with.

-- Begin Python Mystery Meat --
import re

sampleString = "<td><b>SPAM</b></td><td>eggs</td>"
resultFormat = re.compile(r'<td>(.+?)</td>')

detailItems = resultFormat.findall(result)
print len(detailItems)
print type(detailItems)
print detailItems

# This is the line that chokes
print detailItems[0]

--End of Mystery Meat--

>From: "Charlie Derr" <charlie@intelligenesis.net>
>To: "Brian Wisti" <bwisti@hotmail.com>, <tutor@python.org>
>Subject: RE: [Tutor] Regular Expressions part 2
>Date: Fri, 19 May 2000 19:00:52 -0400
>
>I think you need to post your code.
>
>I tried what you said and it worked for me:
>
> >>> import re
> >>> g = "bbbbbbkkdkdkdkdk"
> >>> r = re.findall('b',g)
> >>> type(r)
><type 'list'>
> >>> r
>['b', 'b', 'b', 'b', 'b', 'b']
> >>> len(r)
>6
> >>> r[0]
>'b'
> >>>
>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com



From bwisti@hotmail.com  Sat May 20 00:39:30 2000
From: bwisti@hotmail.com (Brian Wisti)
Date: Fri, 19 May 2000 16:39:30 PDT
Subject: [Tutor] I need to go home (Last regex mystery solved)
Message-ID: <20000519233930.22502.qmail@hotmail.com>

Hi everybody,

I got it figured out... I forgot to check for an empty set.  You know, no 
match?  As soon as I put that check in, it worked like a charm.

Sorry to fill people's time with what amounted to a silly mistake.

Thanks,
Brian
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com



From arcege@shore.net  Sat May 20 00:52:47 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Fri, 19 May 2000 19:52:47 -0400 (EDT)
Subject: [Tutor] Regular Expressions part 2
In-Reply-To: <NDBBLJJLLFOJMLCMJPLOKEEGDPAA.charlie@intelligenesis.net> from "Charlie Derr" at May 19, 2000 07:00:52 PM
Message-ID: <200005192352.TAA26813@northshore.shore.net>

> I think you need to post your code.
> 
> I tried what you said and it worked for me:
> 
> >>> import re
> >>> g = "bbbbbbkkdkdkdkdk"
> >>> r = re.findall('b',g)
> >>> type(r)
> <type 'list'>
> >>> r
> ['b', 'b', 'b', 'b', 'b', 'b']
> >>> len(r)
> 6
> >>> r[0]
> 'b'
> >>>

Using findall is well and good.. but it doesn't give context to what is
found, just "these are the strings found".  What is probably more
useful is retrieving the match objects and using those:

Python 1.5.2 (#2, May 11 1999, 17:14:37)  [GCC 2.7.2.1] on freebsd3
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import re
>>> s = 'bbbbbbkkdkdkdkdk'
>>> r = re.findall('b', s)
>>> r
['b', 'b', 'b', 'b', 'b', 'b']
>>> type(r[0])
<type 'string'>
>>> p = re.compile('b')
>>> i = 0
>>> while i < len(s):
...   m = p.match(s, i)
...   if not m: # no match found
...     break
...   (st, ed) = (m.start(0), m.end(0))
...   print (st, ed), m.string[st:ed]
...   i = ed
...
(0, 1) b
(1, 2) b
(2, 3) b
(3, 4) b
(4, 5) b
(5, 6) b
>>>

The first returns just strings, going through the loop can get the
positions inside the strings.  It's fairly easy to abstract this into
something like findall, but I'll leave that as an exercise.

  -Arcege

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


From charlie@intelligenesis.net  Sat May 20 01:00:57 2000
From: charlie@intelligenesis.net (Charlie Derr)
Date: Fri, 19 May 2000 20:00:57 -0400
Subject: [Tutor] Regular Expressions part 2
In-Reply-To: <20000519233614.95745.qmail@hotmail.com>
Message-ID: <NDBBLJJLLFOJMLCMJPLOEEEIDPAA.charlie@intelligenesis.net>

Brian,
	It still works for me :-]

>>>sampleString = "<td><b>SPAM</b></td><td>eggs</td>"
>>> resultFormat = re.compile(r'<td>(.+?)</td>')
>>> detailItems = resultFormat.findall(result)
Traceback (innermost last):
  File "<pyshell#16>", line 1, in ?
    detailItems = resultFormat.findall(result)
NameError: result
>>> detailItems = resultFormat.findall(sampleString)
>>> print len(detailItems)
2
>>> print type(detailItems)
<type 'list'>
>>> print detailItems
['<b>SPAM</b>', 'eggs']
>>> print detailItems[0]
<b>SPAM</b>
>>>




as you can see, i assumed result was a typo and replaced it with
sampleString


at this point i'm at a loss as to why you're having problems

does this same code choke if you enter it into an interpreter like i am
doing?

	good luck,
		~c



|-----Original Message-----
|From: Brian Wisti [mailto:bwisti@hotmail.com]
|Sent: Friday, May 19, 2000 7:36 PM
|To: charlie@intelligenesis.net; tutor@python.org
|Subject: RE: [Tutor] Regular Expressions part 2
|
|
|Charlie,
|
|Thanks for responding so quickly.  The original code is a little intricate
|(going crazy on the OO stuff), but here is the least contrived facsmile I
|can come up with.
|
|-- Begin Python Mystery Meat --
|import re
|
|sampleString = "<td><b>SPAM</b></td><td>eggs</td>"
|resultFormat = re.compile(r'<td>(.+?)</td>')
|
|detailItems = resultFormat.findall(result)
|print len(detailItems)
|print type(detailItems)
|print detailItems
|
|# This is the line that chokes
|print detailItems[0]
|
|--End of Mystery Meat--
|
|>From: "Charlie Derr" <charlie@intelligenesis.net>
|>To: "Brian Wisti" <bwisti@hotmail.com>, <tutor@python.org>
|>Subject: RE: [Tutor] Regular Expressions part 2
|>Date: Fri, 19 May 2000 19:00:52 -0400
|>
|>I think you need to post your code.
|>
|>I tried what you said and it worked for me:
|>
|> >>> import re
|> >>> g = "bbbbbbkkdkdkdkdk"
|> >>> r = re.findall('b',g)
|> >>> type(r)
|><type 'list'>
|> >>> r
|>['b', 'b', 'b', 'b', 'b', 'b']
|> >>> len(r)
|>6
|> >>> r[0]
|>'b'
|> >>>
|>
|________________________________________________________________________
|Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
|



From martinpozzi@yahoo.com  Sat May 20 15:47:28 2000
From: martinpozzi@yahoo.com (=?iso-8859-1?Q?Mart=EDn_Pozzi?=)
Date: Sat, 20 May 2000 11:47:28 -0300
Subject: [Tutor] Window titles in Tkinter
Message-ID: <000101bfc26b$88b02e40$c17a33c8@default>

Dear friends,

I am new to Python, and I am very excited about this wonderful language! I
am using
Python + Tkinter in Windows, but it seems I can't change the window's title,
which reads "tk". I ran Alan's 'case of study' and though he put "Grammar
checker" as a title to the window, it just shows up as "tk". Anyone can
help? Thanks a lot...

By the way, though I'm not an expert in Python -as you'd have noticed- I
speak Spanish so I can do my best to help those with little knowledge of
English. In case it becomes tough for me to answer, I can translate the
questions. Buena suerte para todos!

Martín Pozzi (martinpozzi@yahoo.com)



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


From vdbroekw@wxs.nl  Sat May 20 17:26:06 2000
From: vdbroekw@wxs.nl (W.W. van den Broek)
Date: Sat, 20 May 2000 18:26:06 +0200
Subject: [Tutor] Re: Tutor digest, Vol 1 #313 - 8 msgs
References: <20000520160016.A02C01CDC4@dinsdale.python.org>
Message-ID: <3926BC9E.EA309FC3@wxs.nl>

tutor-request@python.org wrote:
> =

> Send Tutor mailing list submissions to
>         tutor@python.org
> =

> To subscribe or unsubscribe via the World Wide Web, visit
>         http://www.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>         tutor-request@python.org
> =

> You can reach the person managing the list at
>         tutor-admin@python.org
> =

> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
> =

> Today's Topics:
> =

>   1. Global Regular Expressions? (Brian Wisti)
>   2. Regular Expressions part 2 (Brian Wisti)
>   3. RE: Regular Expressions part 2 (Charlie Derr)
>   4. RE: Regular Expressions part 2 (Brian Wisti)
>   5. I need to go home (Last regex mystery solved) (Brian Wisti)
>   6. Re: Regular Expressions part 2 (Michael P. Reilly)
>   7. RE: Regular Expressions part 2 (Charlie Derr)
>   8. Window titles in Tkinter (=3D?iso-8859-1?Q?Mart=3DEDn_Pozzi?=3D)
> =

> --__--__--
> =

> Message: 1
> From: "Brian Wisti" <bwisti@hotmail.com>
> To: tutor@python.org
> Date: Fri, 19 May 2000 13:23:33 PDT
> Subject: [Tutor] Global Regular Expressions?
> =

> Hi all,
> =

> I'm sure that this is just staring me in the face, but I can't figure o=
ut
> how to step through a string with a regular expression.  I know how I w=
ant
> to do this in Perl.  How about I show you what I mean in Perl?
> =

> -- Perl Code --
> #!/usr/bin/env perl
> =

> # A simple example of the strings I'm looking at.
> my $string =3D "<td>item1</td> <td>item2</td><td>item3</td>";
> =

> # Find the text within each table cell, and show each match
> while ($string =3D~ m!<td>(.+?)</td>!g) {
>         print "Matched: ", $1, "\n";
> }
> =

> print "All done!\n";
> -- End of Code --
> =

> So how do I say it in Python?  Would I be able to use a while loop, or =
is
> there some other construct (splitting, or whatever) that I should be us=
ing?
> =

> Thanks ahead of time for any ideas,
> Brian Wisti
> bwisti@hotmail.com
> _______________________________________________________________________=
_
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.co=
m
> =

> --__--__--
> =

> Message: 2
> From: "Brian Wisti" <bwisti@hotmail.com>
> To: tutor@python.org
> Date: Fri, 19 May 2000 15:46:19 PDT
> Subject: [Tutor] Regular Expressions part 2
> =

> Hi all,
> =

> Okay, so I figured out that re.findall() does a global search.  Well an=
d
> good.
> =

> Now I am on to a new strangeness.  Although I can print out the resulti=
ng
> list, and use "for item in matches" to step through the list, I cannot =
use
> array notation to access the list that results from a re.findall().
> =

> For some strange reason, this thing that looks like an array (it even h=
as a
> length of 2) tells me about "list index out of range" when I try to acc=
ess
> matches[0].
> =

> Umm... what am I missing now?
> =

> Thanks,
> Brian Wisti
> bwisti@hotmail.com
> _______________________________________________________________________=
_
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.co=
m
> =

> --__--__--
> =

> Message: 3
> From: "Charlie Derr" <charlie@intelligenesis.net>
> To: "Brian Wisti" <bwisti@hotmail.com>, <tutor@python.org>
> Subject: RE: [Tutor] Regular Expressions part 2
> Date: Fri, 19 May 2000 19:00:52 -0400
> charset=3D"iso-8859-1"
> =

> I think you need to post your code.
> =

> I tried what you said and it worked for me:
> =

> >>> import re
> >>> g =3D "bbbbbbkkdkdkdkdk"
> >>> r =3D re.findall('b',g)
> >>> type(r)
> <type 'list'>
> >>> r
> ['b', 'b', 'b', 'b', 'b', 'b']
> >>> len(r)
> 6
> >>> r[0]
> 'b'
> >>>
> =

> |-----Original Message-----
> |From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf =
Of
> |Brian Wisti
> |Sent: Friday, May 19, 2000 6:46 PM
> |To: tutor@python.org
> |Subject: [Tutor] Regular Expressions part 2
> |
> |
> |Hi all,
> |
> |Okay, so I figured out that re.findall() does a global search.  Well a=
nd
> |good.
> |
> |Now I am on to a new strangeness.  Although I can print out the result=
ing
> |list, and use "for item in matches" to step through the list, I cannot=
 use
> |array notation to access the list that results from a re.findall().
> |
> |For some strange reason, this thing that looks like an array (it
> |even has a
> |length of 2) tells me about "list index out of range" when I try to ac=
cess
> |matches[0].
> |
> |Umm... what am I missing now?
> |
> |Thanks,
> |Brian Wisti
> |bwisti@hotmail.com
> |______________________________________________________________________=
__
> |Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.c=
om
> |
> |
> |_______________________________________________
> |Tutor maillist  -  Tutor@python.org
> |http://www.python.org/mailman/listinfo/tutor
> |
> =

> --__--__--
> =

> Message: 4
> From: "Brian Wisti" <bwisti@hotmail.com>
> To: charlie@intelligenesis.net, tutor@python.org
> Subject: RE: [Tutor] Regular Expressions part 2
> Date: Fri, 19 May 2000 16:36:14 PDT
> =

> Charlie,
> =

> Thanks for responding so quickly.  The original code is a little intric=
ate
> (going crazy on the OO stuff), but here is the least contrived facsmile=
 I
> can come up with.
> =

> -- Begin Python Mystery Meat --
> import re
> =

> sampleString =3D "<td><b>SPAM</b></td><td>eggs</td>"
> resultFormat =3D re.compile(r'<td>(.+?)</td>')
> =

> detailItems =3D resultFormat.findall(result)
> print len(detailItems)
> print type(detailItems)
> print detailItems
> =

> # This is the line that chokes
> print detailItems[0]
> =

> --End of Mystery Meat--
> =

> >From: "Charlie Derr" <charlie@intelligenesis.net>
> >To: "Brian Wisti" <bwisti@hotmail.com>, <tutor@python.org>
> >Subject: RE: [Tutor] Regular Expressions part 2
> >Date: Fri, 19 May 2000 19:00:52 -0400
> >
> >I think you need to post your code.
> >
> >I tried what you said and it worked for me:
> >
> > >>> import re
> > >>> g =3D "bbbbbbkkdkdkdkdk"
> > >>> r =3D re.findall('b',g)
> > >>> type(r)
> ><type 'list'>
> > >>> r
> >['b', 'b', 'b', 'b', 'b', 'b']
> > >>> len(r)
> >6
> > >>> r[0]
> >'b'
> > >>>
> >
> _______________________________________________________________________=
_
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.co=
m
> =

> --__--__--
> =

> Message: 5
> From: "Brian Wisti" <bwisti@hotmail.com>
> To: tutor@python.org
> Date: Fri, 19 May 2000 16:39:30 PDT
> Subject: [Tutor] I need to go home (Last regex mystery solved)
> =

> Hi everybody,
> =

> I got it figured out... I forgot to check for an empty set.  You know, =
no
> match?  As soon as I put that check in, it worked like a charm.
> =

> Sorry to fill people's time with what amounted to a silly mistake.
> =

> Thanks,
> Brian
> _______________________________________________________________________=
_
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.co=
m
> =

> --__--__--
> =

> Message: 6
> From: "Michael P. Reilly" <arcege@shore.net>
> Subject: Re: [Tutor] Regular Expressions part 2
> To: charlie@intelligenesis.net (Charlie Derr)
> Date: Fri, 19 May 2000 19:52:47 -0400 (EDT)
> Cc: bwisti@hotmail.com (Brian Wisti), tutor@python.org
> Reply-To: arcege@shore.net
> =

> > I think you need to post your code.
> >
> > I tried what you said and it worked for me:
> >
> > >>> import re
> > >>> g =3D "bbbbbbkkdkdkdkdk"
> > >>> r =3D re.findall('b',g)
> > >>> type(r)
> > <type 'list'>
> > >>> r
> > ['b', 'b', 'b', 'b', 'b', 'b']
> > >>> len(r)
> > 6
> > >>> r[0]
> > 'b'
> > >>>
> =

> Using findall is well and good.. but it doesn't give context to what is=

> found, just "these are the strings found".  What is probably more
> useful is retrieving the match objects and using those:
> =

> Python 1.5.2 (#2, May 11 1999, 17:14:37)  [GCC 2.7.2.1] on freebsd3
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import re
> >>> s =3D 'bbbbbbkkdkdkdkdk'
> >>> r =3D re.findall('b', s)
> >>> r
> ['b', 'b', 'b', 'b', 'b', 'b']
> >>> type(r[0])
> <type 'string'>
> >>> p =3D re.compile('b')
> >>> i =3D 0
> >>> while i < len(s):
> ...   m =3D p.match(s, i)
> ...   if not m: # no match found
> ...     break
> ...   (st, ed) =3D (m.start(0), m.end(0))
> ...   print (st, ed), m.string[st:ed]
> ...   i =3D ed
> ...
> (0, 1) b
> (1, 2) b
> (2, 3) b
> (3, 4) b
> (4, 5) b
> (5, 6) b
> >>>
> =

> The first returns just strings, going through the loop can get the
> positions inside the strings.  It's fairly easy to abstract this into
> something like findall, but I'll leave that as an exercise.
> =

>   -Arcege
> =

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

> --__--__--
> =

> Message: 7
> From: "Charlie Derr" <charlie@intelligenesis.net>
> To: "Brian Wisti" <bwisti@hotmail.com>, <tutor@python.org>
> Subject: RE: [Tutor] Regular Expressions part 2
> Date: Fri, 19 May 2000 20:00:57 -0400
> charset=3D"iso-8859-1"
> =

> Brian,
>         It still works for me :-]
> =

> >>>sampleString =3D "<td><b>SPAM</b></td><td>eggs</td>"
> >>> resultFormat =3D re.compile(r'<td>(.+?)</td>')
> >>> detailItems =3D resultFormat.findall(result)
> Traceback (innermost last):
>   File "<pyshell#16>", line 1, in ?
>     detailItems =3D resultFormat.findall(result)
> NameError: result
> >>> detailItems =3D resultFormat.findall(sampleString)
> >>> print len(detailItems)
> 2
> >>> print type(detailItems)
> <type 'list'>
> >>> print detailItems
> ['<b>SPAM</b>', 'eggs']
> >>> print detailItems[0]
> <b>SPAM</b>
> >>>
> =

> as you can see, i assumed result was a typo and replaced it with
> sampleString
> =

> at this point i'm at a loss as to why you're having problems
> =

> does this same code choke if you enter it into an interpreter like i am=

> doing?
> =

>         good luck,
>                 ~c
> =

> |-----Original Message-----
> |From: Brian Wisti [mailto:bwisti@hotmail.com]
> |Sent: Friday, May 19, 2000 7:36 PM
> |To: charlie@intelligenesis.net; tutor@python.org
> |Subject: RE: [Tutor] Regular Expressions part 2
> |
> |
> |Charlie,
> |
> |Thanks for responding so quickly.  The original code is a little intri=
cate
> |(going crazy on the OO stuff), but here is the least contrived facsmil=
e I
> |can come up with.
> |
> |-- Begin Python Mystery Meat --
> |import re
> |
> |sampleString =3D "<td><b>SPAM</b></td><td>eggs</td>"
> |resultFormat =3D re.compile(r'<td>(.+?)</td>')
> |
> |detailItems =3D resultFormat.findall(result)
> |print len(detailItems)
> |print type(detailItems)
> |print detailItems
> |
> |# This is the line that chokes
> |print detailItems[0]
> |
> |--End of Mystery Meat--
> |
> |>From: "Charlie Derr" <charlie@intelligenesis.net>
> |>To: "Brian Wisti" <bwisti@hotmail.com>, <tutor@python.org>
> |>Subject: RE: [Tutor] Regular Expressions part 2
> |>Date: Fri, 19 May 2000 19:00:52 -0400
> |>
> |>I think you need to post your code.
> |>
> |>I tried what you said and it worked for me:
> |>
> |> >>> import re
> |> >>> g =3D "bbbbbbkkdkdkdkdk"
> |> >>> r =3D re.findall('b',g)
> |> >>> type(r)
> |><type 'list'>
> |> >>> r
> |>['b', 'b', 'b', 'b', 'b', 'b']
> |> >>> len(r)
> |>6
> |> >>> r[0]
> |>'b'
> |> >>>
> |>
> |______________________________________________________________________=
__
> |Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.c=
om
> |
> =

> --__--__--
> =

> Message: 8
> From: "=3D?iso-8859-1?Q?Mart=3DEDn_Pozzi?=3D" <martinpozzi@yahoo.com>
> To: <tutor@python.org>
> Date: Sat, 20 May 2000 11:47:28 -0300
> charset=3D"iso-8859-1"
> Subject: [Tutor] Window titles in Tkinter
> =

> Dear friends,
> =

> I am new to Python, and I am very excited about this wonderful language=
! I
> am using
> Python + Tkinter in Windows, but it seems I can't change the window's t=
itle,
> which reads "tk". I ran Alan's 'case of study' and though he put "Gramm=
ar
> checker" as a title to the window, it just shows up as "tk". Anyone can=

> help? Thanks a lot...
> =

> By the way, though I'm not an expert in Python -as you'd have noticed- =
I
> speak Spanish so I can do my best to help those with little knowledge o=
f
> English. In case it becomes tough for me to answer, I can translate the=

> questions. Buena suerte para todos!
> =

> Mart=EDn Pozzi (martinpozzi@yahoo.com)
> =

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

> --__--__--
> =

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

> End of Tutor Digest_______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
Hi =

I am using python on suse 6.3, cannot find the python command for
executing scripts. Tried /user/bin, /usr/sbin, /usr/local/bin,
/usr/local/sbin, /usr/bin/env python
Does anybody know were it is on suse 6.3??
Thanks walter
-- =

W.W. van den Broek	e-mail:		vandenbroek@psyd.azr.nl
AZR-Dijkzigt		fax:		010-4633217
afdeling psychiatrie	tel:		010-4639222
Postbus 2040		e-mail		vdbroekw@wxs.nl (thuis)
3000 CA Rotterdam	homepage:	http://home.planet.nl/~vdbroekw


From jcm@bigskytel.com  Sat May 20 22:27:18 2000
From: jcm@bigskytel.com (David Porter)
Date: Sat, 20 May 2000 15:27:18 -0600
Subject: [Tutor] Re: Tutor digest, Vol 1 #313 - 8 msgs
In-Reply-To: <3926BC9E.EA309FC3@wxs.nl>; from vdbroekw@wxs.nl on Sat, May 20, 2000 at 06:26:06PM +0200
References: <20000520160016.A02C01CDC4@dinsdale.python.org> <3926BC9E.EA309FC3@wxs.nl>
Message-ID: <20000520152718.A31421@bigskytel.com>

* W.W. van den Broek <vdbroekw@wxs.nl>:
[monstrous snip]
> I am using python on suse 6.3, cannot find the python command for
> executing scripts. Tried /user/bin, /usr/sbin, /usr/local/bin,
> /usr/local/sbin, /usr/bin/env python
> Does anybody know were it is on suse 6.3??

The python command for executing scripts is 'python', as in:

  python your_script.py

To make your script executable in itself, you need to do two things. First
add this line to the beginning of the script:

  #!/usr/bin/env python 

then, make the script executable:

  chmod +x your_script.py
  

    \david

    
PS, could you please not quote the entire message you are replying to,
especially when it is so long (436 out of 460 lines in your mail) and has
nothing to do with your message? It is best to only quote the relevent part
of a message that you are replying to.



From bwinton@iname.com  Sat May 20 22:44:00 2000
From: bwinton@iname.com (Blake Winton)
Date: Sat, 20 May 2000 17:44:00 -0400
Subject: [Tutor] Re: Tutor digest, Vol 1 #313 - 8 msgs
In-Reply-To: <20000520152718.A31421@bigskytel.com>
References: <20000520160016.A02C01CDC4@dinsdale.python.org> <3926BC9E.EA309FC3@wxs.nl> <20000520152718.A31421@bigskytel.com>
Message-ID: <20000520174400.A522@tor.dhs.org>

* David Porter <jcm@bigskytel.com> [000520 16:31]:
> 
> * W.W. van den Broek <vdbroekw@wxs.nl>:
> [monstrous snip]
> > I am using python on suse 6.3, cannot find the python command for
> > executing scripts. Tried /user/bin, /usr/sbin, /usr/local/bin,
> > /usr/local/sbin, /usr/bin/env python
> > Does anybody know were it is on suse 6.3??
> The python command for executing scripts is 'python', as in:
>   #!/usr/bin/env python 


Or, if you really wanted to find the executable, you could type
one of the following two lines.
locate python
find / -name "python" -print

locate is preferable, since it goes to a database to find files,
and thus takes less time, and is nicer to your hard drive.

Later,
Blake.
-- 
5:40pm up 28 days, 21:50, 1 user, load average: 1.00, 1.00, 1.00


From vdbroekw@wxs.nl  Sun May 21 19:55:58 2000
From: vdbroekw@wxs.nl (W.W. van den Broek)
Date: Sun, 21 May 2000 20:55:58 +0200
Subject: [Tutor] Re: Tutor digest, Vol 1 #314 - 3 msgs
References: <20000521160015.5D3A31CDB9@dinsdale.python.org>
Message-ID: <3928313E.26C1E78B@wxs.nl>

> Message: 2
> Date: Sat, 20 May 2000 15:27:18 -0600
> From: David Porter <jcm@bigskytel.com>
> To: Python Tutor <tutor@python.org>
> Subject: Re: [Tutor] Re: Tutor digest, Vol 1 #313 - 8 msgs
> Organization: (a Conspiracy of doves)
> 
> * W.W. van den Broek <vdbroekw@wxs.nl>:
> [monstrous snip]
> > I am using python on suse 6.3, cannot find the python command for
> > executing scripts. Tried /user/bin, /usr/sbin, /usr/local/bin,
> > /usr/local/sbin, /usr/bin/env python
> > Does anybody know were it is on suse 6.3??
> 
>
> To make your script executable in itself, you need to do two things. First
> add this line to the beginning of the script:
> 
>   #!/usr/bin/env python
> 
> then, make the script executable:
> 
>   chmod +x your_script.py
 Tried that no luck
walter
> 
>     \david
> 
>


From jcm@bigskytel.com  Sun May 21 21:27:45 2000
From: jcm@bigskytel.com (David Porter)
Date: Sun, 21 May 2000 14:27:45 -0600
Subject: [Tutor] Re: Tutor digest, Vol 1 #314 - 3 msgs
In-Reply-To: <3928313E.26C1E78B@wxs.nl>; from vdbroekw@wxs.nl on Sun, May 21, 2000 at 08:55:58PM +0200
References: <20000521160015.5D3A31CDB9@dinsdale.python.org> <3928313E.26C1E78B@wxs.nl>
Message-ID: <20000521142745.A8868@bigskytel.com>

* W.W. van den Broek <vdbroekw@wxs.nl>:

> > To make your script executable in itself, you need to do two things. First
> > add this line to the beginning of the script:
> > 
> >   #!/usr/bin/env python
> > 
> > then, make the script executable:
> > 
> >   chmod +x your_script.py
>  Tried that no luck

What does your script do? What happens if you type:

  python your_script.py 

If that doesn't do anything, then your script has no visible output (you
have python installed, right?). You can test this by making a simple script:

  print "See, it does work!"

and do what I suggested above with it. 

> >     \david

PS, if you don't have the current directory in your path (i.e., if you are
running as root), then you will have to type ./your_script.py to execute it.


From alan.gauld@bt.com  Mon May 22 11:35:20 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 22 May 2000 11:35:20 +0100
Subject: [Tutor] Window titles in Tkinter
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D15A@mbtlipnt02.btlabs.bt.co.uk>

> which reads "tk". I ran Alan's 'case of study' and though he 
> put "Grammar checker" as a title to the window, it just 
> shows up as "tk". 

Yes... If anyone can answer that I'd be interested. 
Oddly enough I was trying to get it working at the 
weekend and wound up just deleting that line from 
the code in my book- cop out!!!

It does seem to work on Linux but not in Windows.
It would be nice to set the window title properly 
within Tkinter.

Alan G.


From rhicks@rma.edu  Mon May 22 21:29:19 2000
From: rhicks@rma.edu (Robert)
Date: Mon, 22 May 2000 16:29:19 -0400
Subject: [Tutor] Re: Tutor digest, Vol 1 #315 - 3 msgs
References: <20000522160013.8984F1CD6E@dinsdale.python.org>
Message-ID: <001b01bfc42c$68f735e0$d90c97ce@bhicks>

You can do:

In the import section:

root.title('What-ever-the-title-is')

Or as a class:

self.root = master
self.root.title("What-ever-your-title-is")

Both of these were snipped out of the Tkinter programming book by Grayson
and they both work.

Bob






| --__--__--
|
| Message: 3
| From: alan.gauld@bt.com
| To: martinpozzi@yahoo.com, tutor@python.org
| Subject: RE: [Tutor] Window titles in Tkinter
| Date: Mon, 22 May 2000 11:35:20 +0100
|
| > which reads "tk". I ran Alan's 'case of study' and though he
| > put "Grammar checker" as a title to the window, it just
| > shows up as "tk".
|
| Yes... If anyone can answer that I'd be interested.
| Oddly enough I was trying to get it working at the
| weekend and wound up just deleting that line from
| the code in my book- cop out!!!
|
| It does seem to work on Linux but not in Windows.
| It would be nice to set the window title properly
| within Tkinter.
|
| Alan G.
|
|
|
| --__--__--
|
| _______________________________________________
| Tutor maillist  -  Tutor@python.org
| http://www.python.org/mailman/listinfo/tutor
|
|
| End of Tutor Digest_______________________________________________
| Tutor maillist  -  Tutor@python.org
| http://www.python.org/mailman/listinfo/tutor



From natecuster@hotmail.com  Tue May 23 09:43:59 2000
From: natecuster@hotmail.com (Nate Custer)
Date: Tue, 23 May 2000 04:43:59 EDT
Subject: [Tutor] Help w/ Datatypes
Message-ID: <20000523084400.80721.qmail@hotmail.com>

Hey all,

Is there anyway to make an integer variable to a string variable?

Thanks in advance,

Nate Custer
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com



From scarblac@pino.selwerd.nl  Tue May 23 09:58:46 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 23 May 2000 10:58:46 +0200
Subject: [Tutor] Help w/ Datatypes
In-Reply-To: <20000523084400.80721.qmail@hotmail.com>; from natecuster@hotmail.com on Tue, May 23, 2000 at 04:43:59AM -0400
References: <20000523084400.80721.qmail@hotmail.com>
Message-ID: <20000523105846.A21761@pino.selwerd.nl>

On Tue, May 23, 2000 at 04:43:59AM -0400, Nate Custer wrote:
> Is there anyway to make an integer variable to a string variable?

Sure, just use the str() function.

>>> str(3)
'3'

Similarly, try int("4"), float("4.1"), tuple([1, 2]), list((3, 4))
and so on.

-- 
Remco Gerlich,  scarblac@pino.selwerd.nl


From alan.gauld@bt.com  Tue May 23 17:37:56 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 23 May 2000 17:37:56 +0100
Subject: [Tutor] Re: Tutor digest, Vol 1 #315 - 3 msgs
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D16D@mbtlipnt02.btlabs.bt.co.uk>

> Or as a class:
> 
> self.root = master
> self.root.title("What-ever-your-title-is")
> 
> Both of these were snipped out of the Tkinter programming 
> book by Grayson

So they do! I was looking in Grayson's book but the only 
info I could see was the wm_title stuff. I need to look 
again.

Thanks,

Alan G.


From fabwing@math.uni-muenster.de  Tue May 23 21:49:43 2000
From: fabwing@math.uni-muenster.de (Fabian Wissing)
Date: Tue, 23 May 2000 22:49:43 +0200
Subject: [Tutor] Little questions !
Message-ID: <000701bfc4f8$6d56c5c0$4ac8c8c8@309>

This is a multi-part message in MIME format.

------=_NextPart_000_0004_01BFC509.2FDC2F80
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hallo !

I hope it is possible to solve my problems with programming python.
*1: What can I do to send arguments with "command"  to another method, =
without calling the method immediately. But after activating the button.
*2: IWhy can I not do this ? (Error with the Index) How is it possible ?
Thanks Fabian
(fabwing@uni-muenster.de) =20
import Tkinter

class XXX (Tkinter.Frame):
=20
 rows =3D 8
 columns =3D 8
=20
 def __init__(self, root):=20
  Tkinter.Frame.__init__ (self, root)
  self.butt =3D []
  self.butt =3D [self.butt]*self.rows
  for row in range (self.rows):
   self.butt [row] =3D [self.butt] * self.columns
   for column in range (self.columns):
           self.butt [row][column] =3D Tkinter.Button(text =3D 'xxx', =
background =3D 'white', command =3D self.surrounding(row, column)) *1
    self.butt [row][column].grid(row=3Drow, column=3Dcolumn)
 =20
=20
 def surrounding (self, row, column):    ## I know this is not a good =
algorithem
 =20
  if row =3D=3D 0:
   if column =3D=3D 0:
    self.change (0, 1)
    self.change (1, 0)
    self.change (1, 1)
   elif column =3D=3D self.columns:
    self.change (0, 2)
    self.change (1, 2)
    self.change (1, 3)
   else:
    self.change (0, column-1)
    self.change (0, column+1)
    self.change (1, column-1)
    self.change (1, column)
    self.change (1, column+1)
  elif row =3D=3D self.rows:
   if column =3D=3D 0:
    self.change (row-1, 0)
    self.change (row-1, 1)
    self.change (row, 1)
   elif column =3D=3D self.columns:
    self.change (row, column-1)
    self.change (row-1, column-1)
    self.change (row-1, column)
   else:
    self.change (row, column-1)
    self.change (row-1, column-1)
    self.change (row-1, column)
    self.change (row-1, column+1)
    self.change (row, column+1)
  else:
   if column =3D=3D 0:
    self.change (row-1, column)
    self.change (row-1, column+1)
    self.change (row, column+1)
    self.change (row+1, column+1)
    self.change (row+1, column)
   elif column =3D=3D self.columns:
    self.change (row+1, column)
    self.change (row+1, column-1)
    self.change (row, column-1)
    self.change (row-1, column-1)
    self.change (row-1, column)
   else:
    self.change (row+1, column)
    self.change (row+1, column-1)
    self.change (row, column-1)
    self.change (row-1, column-1)
    self.change (row-1, column)
    self.change (row-1, column+1)
    self.change (row, column+1)
    self.change (row+1, column+1)
=20
 def change (self, row, column):
  ##if self.butt [row] [column] ["background" =3D=3D "white"]: *2=20
  ## self.butt [row] [column] ["background"] =3D "black"
  ##else:
  ## self.butt [row] [column] ["background"] =3D "white"
  print row, column ##only example
def main ():
 app =3D XXX (Tkinter.Tk())
 app.pack()
 app.mainloop()
if __name__ =3D=3D '__main__':
 main()

------=_NextPart_000_0004_01BFC509.2FDC2F80
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#fffff0>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT =
color=3D#000000><STRONG>Hallo=20
!</FONT></FONT><FONT color=3D#000000></FONT></STRONG></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
color=3D#000000><STRONG></FONT></FONT><FONT=20
color=3D#000000></FONT></STRONG>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><FONT color=3D#000000><STRONG>I hope it =
is possible=20
to solve my problems with programming python.</FONT></FONT><FONT=20
color=3D#000000></FONT></STRONG></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT color=3D#000000 =
face=3DArial=20
size=3D2><STRONG>*1: What can I do to send arguments with=20
&quot;command&quot;&nbsp; to another method, without calling the method=20
immediately. But after activating the button.</FONT></STRONG></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><STRONG>*2: IWhy can I =
not do this ?=20
(Error with the Index) How is it possible ?</FONT></STRONG></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><STRONG>Thanks=20
Fabian</FONT></STRONG></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><A=20
href=3D"mailto:(fabwing@uni-muenster.de"><STRONG>(fabwing@uni-muenster.de=
</A>)&nbsp;=20
</FONT></STRONG></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>import =
Tkinter</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>class XXX=20
(Tkinter.Frame):<BR>&nbsp;<BR>&nbsp;rows =3D 8<BR>&nbsp;columns =3D=20
8<BR>&nbsp;<BR>&nbsp;def __init__(self, root): <BR>&nbsp; =
Tkinter.Frame.__init__=20
(self, root)<BR>&nbsp; self.butt =3D []<BR>&nbsp; self.butt =3D=20
[self.butt]*self.rows<BR>&nbsp; for row in range =
(self.rows):<BR>&nbsp;&nbsp;=20
self.butt [row] =3D [self.butt] * self.columns<BR>&nbsp;&nbsp; for =
column in range=20
(self.columns):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;=20
self.butt [row][column] =3D Tkinter.Button(text =3D 'xxx', background =
=3D 'white',=20
<FONT color=3D#000000 face=3DArial size=3D4><STRONG>command =3D =
self.surrounding(row,=20
column)) *1</STRONG></FONT><BR>&nbsp;&nbsp;&nbsp; self.butt=20
[row][column].grid(row=3Drow, column=3Dcolumn)<BR>&nbsp; =
<BR>&nbsp;<BR>&nbsp;def=20
surrounding (self, row, column):&nbsp;&nbsp;&nbsp; ## I know this is not =
a good=20
algorithem<BR>&nbsp; <BR>&nbsp; if row =3D=3D 0:<BR>&nbsp;&nbsp; if =
column =3D=3D=20
0:<BR>&nbsp;&nbsp;&nbsp; self.change (0, 1)<BR>&nbsp;&nbsp;&nbsp; =
self.change=20
(1, 0)<BR>&nbsp;&nbsp;&nbsp; self.change (1, 1)<BR>&nbsp;&nbsp; elif =
column =3D=3D=20
self.columns:<BR>&nbsp;&nbsp;&nbsp; self.change (0, =
2)<BR>&nbsp;&nbsp;&nbsp;=20
self.change (1, 2)<BR>&nbsp;&nbsp;&nbsp; self.change (1, =
3)<BR>&nbsp;&nbsp;=20
else:<BR>&nbsp;&nbsp;&nbsp; self.change (0, =
column-1)<BR>&nbsp;&nbsp;&nbsp;=20
self.change (0, column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (1,=20
column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (1, =
column)<BR>&nbsp;&nbsp;&nbsp;=20
self.change (1, column+1)<BR>&nbsp; elif row =3D=3D =
self.rows:<BR>&nbsp;&nbsp; if=20
column =3D=3D 0:<BR>&nbsp;&nbsp;&nbsp; self.change (row-1, =
0)<BR>&nbsp;&nbsp;&nbsp;=20
self.change (row-1, 1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
1)<BR>&nbsp;&nbsp; elif column =3D=3D =
self.columns:<BR>&nbsp;&nbsp;&nbsp;=20
self.change (row, column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1, =
column)<BR>&nbsp;&nbsp;=20
else:<BR>&nbsp;&nbsp;&nbsp; self.change (row, =
column-1)<BR>&nbsp;&nbsp;&nbsp;=20
self.change (row-1, column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
column)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row, column+1)<BR>&nbsp;=20
else:<BR>&nbsp;&nbsp; if column =3D=3D 0:<BR>&nbsp;&nbsp;&nbsp; =
self.change (row-1,=20
column)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row+1,=20
column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row+1, =
column)<BR>&nbsp;&nbsp; elif=20
column =3D=3D self.columns:<BR>&nbsp;&nbsp;&nbsp; self.change (row+1,=20
column)<BR>&nbsp;&nbsp;&nbsp; self.change (row+1,=20
column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1, =
column)<BR>&nbsp;&nbsp;=20
else:<BR>&nbsp;&nbsp;&nbsp; self.change (row+1, =
column)<BR>&nbsp;&nbsp;&nbsp;=20
self.change (row+1, column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
column)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row+1,=20
column+1)<BR>&nbsp;<BR>&nbsp;def change (self, row, column):<BR><FONT=20
color=3D#000000 face=3DArial size=3D4><STRONG>&nbsp; ##if self.butt =
[row] [column]=20
[&quot;background&quot; =3D=3D &quot;white&quot;]: *2 <BR>&nbsp; ## =
self.butt [row]=20
[column] [&quot;background&quot;] =3D &quot;black&quot;<BR>&nbsp;=20
##else:<BR>&nbsp; ## self.butt [row] [column] [&quot;background&quot;] =
=3D=20
&quot;white&quot;<BR></STRONG></FONT>&nbsp; print row, column ##only=20
example<BR>def main ():<BR>&nbsp;app =3D XXX=20
(Tkinter.Tk())<BR>&nbsp;app.pack()<BR>&nbsp;app.mainloop()<BR>if =
__name__ =3D=3D=20
'__main__':<BR>&nbsp;main()</FONT></DIV></BODY></HTML>

------=_NextPart_000_0004_01BFC509.2FDC2F80--



From uncle_wiggly@bigfoot.com  Tue May 23 22:00:07 2000
From: uncle_wiggly@bigfoot.com (K P)
Date: Tue, 23 May 2000 16:00:07 -0500
Subject: [Tutor] Embedding Question
Message-ID: <200005232102.QAA05219@solaris1.mysolution.com>

After much effort I finally have a small grasp on embedding Python 
in my own program (and by extension, extending Python). Not 
small task I think for a self-taught programmer (embedding in C++ 
program under DOS using DJGPP, fun). My goal is to use Python 
as my program's scripting language (similar to VBA for MS Office 
on Windows platforms). Here's where I need some clues, to ensure 
I understand the process:
	1) Decide what methods/functions/etc I want to 'expose' to 
Python
	2) Write an extension that allows Python to access these 
methods/etc
	3) Embed both extension and Python in my program

Is that (in simplified terms) the 'correct' way to approach it? Is there 
a more efficient way? I guess that means I would also need call-
back methods for my program to use Python objects......

Ken



From arcege@shore.net  Wed May 24 15:55:56 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Wed, 24 May 2000 10:55:56 -0400 (EDT)
Subject: [Tutor] Little questions !
In-Reply-To: <000701bfc4f8$6d56c5c0$4ac8c8c8@309> from "Fabian Wissing" at May 23, 2000 10:49:43 PM
Message-ID: <200005241455.KAA27302@northshore.shore.net>

> 
> This is a multi-part message in MIME format.
> 
> ------=_NextPart_000_0004_01BFC509.2FDC2F80
> Content-Type: text/plain;
> 	charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> Hallo !
> 
> I hope it is possible to solve my problems with programming python.
> *1: What can I do to send arguments with "command"  to another method, =
> without calling the method immediately. But after activating the button.
> *2: IWhy can I not do this ? (Error with the Index) How is it possible ?
> Thanks Fabian
> (fabwing@uni-muenster.de) =20

Hi,

The reason is that you are setting the callback to the _result_ of
the "self.surrounding()" method call, not to the a callable itself.
How about: 
  ... = Tkinter.Button(text='xxx', ...,
    command = lambda r=row, c=column, s=self: s.surrounding(r, c)
  )

This creates an "anonymous function" that saves the values you want
(as default parameters) and sets that function as the callback, which
will call the surrounding method when it, itself, is called.

Also, you replicate the _same_ list object when you use [self.butt]*
self.rows. (Not to mention that you are creating a HUGE number of self
references with the "self.butt[row] = [self.butt]*self.columns"
statement.)  You will want to put that in the loop (since you go thru
the bother anyway):

  self.butt = []
  for row in range(self.rows):
    # create a new list and put it in its place
    self.append([None] * self.columns)
    for column in range(self.columns):
      ...

  -Arcege

> import Tkinter
> 
> class XXX (Tkinter.Frame):
> =20
>  rows =3D 8
>  columns =3D 8
> =20
>  def __init__(self, root):=20
>   Tkinter.Frame.__init__ (self, root)
>   self.butt =3D []
>   self.butt =3D [self.butt]*self.rows
>   for row in range (self.rows):
>    self.butt [row] =3D [self.butt] * self.columns
>    for column in range (self.columns):
>            self.butt [row][column] =3D Tkinter.Button(text =3D 'xxx', =
> background =3D 'white', command =3D self.surrounding(row, column)) *1
>     self.butt [row][column].grid(row=3Drow, column=3Dcolumn)
>  =20
> =20
>  def surrounding (self, row, column):    ## I know this is not a good =
> algorithem
>  =20
>   if row =3D=3D 0:
>    if column =3D=3D 0:
>     self.change (0, 1)
>     self.change (1, 0)
>     self.change (1, 1)
>    elif column =3D=3D self.columns:
>     self.change (0, 2)
>     self.change (1, 2)
>     self.change (1, 3)
>    else:
>     self.change (0, column-1)
>     self.change (0, column+1)
>     self.change (1, column-1)
>     self.change (1, column)
>     self.change (1, column+1)
>   elif row =3D=3D self.rows:
>    if column =3D=3D 0:
>     self.change (row-1, 0)
>     self.change (row-1, 1)
>     self.change (row, 1)
>    elif column =3D=3D self.columns:
>     self.change (row, column-1)
>     self.change (row-1, column-1)
>     self.change (row-1, column)
>    else:
>     self.change (row, column-1)
>     self.change (row-1, column-1)
>     self.change (row-1, column)
>     self.change (row-1, column+1)
>     self.change (row, column+1)
>   else:
>    if column =3D=3D 0:
>     self.change (row-1, column)
>     self.change (row-1, column+1)
>     self.change (row, column+1)
>     self.change (row+1, column+1)
>     self.change (row+1, column)
>    elif column =3D=3D self.columns:
>     self.change (row+1, column)
>     self.change (row+1, column-1)
>     self.change (row, column-1)
>     self.change (row-1, column-1)
>     self.change (row-1, column)
>    else:
>     self.change (row+1, column)
>     self.change (row+1, column-1)
>     self.change (row, column-1)
>     self.change (row-1, column-1)
>     self.change (row-1, column)
>     self.change (row-1, column+1)
>     self.change (row, column+1)
>     self.change (row+1, column+1)
> =20
>  def change (self, row, column):
>   ##if self.butt [row] [column] ["background" =3D=3D "white"]: *2=20
>   ## self.butt [row] [column] ["background"] =3D "black"
>   ##else:
>   ## self.butt [row] [column] ["background"] =3D "white"
>   print row, column ##only example
> def main ():
>  app =3D XXX (Tkinter.Tk())
>  app.pack()
>  app.mainloop()
> if __name__ =3D=3D '__main__':
>  main()
> 
> ------=_NextPart_000_0004_01BFC509.2FDC2F80
> Content-Type: text/html;
> 	charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
> <HTML>
> <HEAD>
> 
> <META content=3Dtext/html;charset=3Diso-8859-1 =
> http-equiv=3DContent-Type>
> <META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
> </HEAD>
> <BODY bgColor=3D#fffff0>
> <DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT =
> color=3D#000000><STRONG>Hallo=20
> !</FONT></FONT><FONT color=3D#000000></FONT></STRONG></DIV>
> <DIV><FONT face=3DArial size=3D2><FONT =
> color=3D#000000><STRONG></FONT></FONT><FONT=20
> color=3D#000000></FONT></STRONG>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2><FONT color=3D#000000><STRONG>I hope it =
> is possible=20
> to solve my problems with programming python.</FONT></FONT><FONT=20
> color=3D#000000></FONT></STRONG></DIV>
> <DIV><FONT face=3DArial size=3D2></FONT><FONT color=3D#000000 =
> face=3DArial=20
> size=3D2><STRONG>*1: What can I do to send arguments with=20
> &quot;command&quot;&nbsp; to another method, without calling the method=20
> immediately. But after activating the button.</FONT></STRONG></DIV>
> <DIV><FONT color=3D#000000 face=3DArial size=3D2><STRONG>*2: IWhy can I =
> not do this ?=20
> (Error with the Index) How is it possible ?</FONT></STRONG></DIV>
> <DIV><FONT color=3D#000000 face=3DArial size=3D2><STRONG>Thanks=20
> Fabian</FONT></STRONG></DIV>
> <DIV><FONT color=3D#000000 face=3DArial size=3D2><A=20
> href=3D"mailto:(fabwing@uni-muenster.de"><STRONG>(fabwing@uni-muenster.de=
> </A>)&nbsp;=20
> </FONT></STRONG></DIV>
> <DIV><FONT color=3D#000000 face=3DArial size=3D2>import =
> Tkinter</FONT></DIV>
> <DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT>&nbsp;</DIV>
> <DIV><FONT color=3D#000000 face=3DArial size=3D2>class XXX=20
> (Tkinter.Frame):<BR>&nbsp;<BR>&nbsp;rows =3D 8<BR>&nbsp;columns =3D=20
> 8<BR>&nbsp;<BR>&nbsp;def __init__(self, root): <BR>&nbsp; =
> Tkinter.Frame.__init__=20
> (self, root)<BR>&nbsp; self.butt =3D []<BR>&nbsp; self.butt =3D=20
> [self.butt]*self.rows<BR>&nbsp; for row in range =
> (self.rows):<BR>&nbsp;&nbsp;=20
> self.butt [row] =3D [self.butt] * self.columns<BR>&nbsp;&nbsp; for =
> column in range=20
> (self.columns):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
> &nbsp;=20
> self.butt [row][column] =3D Tkinter.Button(text =3D 'xxx', background =
> =3D 'white',=20
> <FONT color=3D#000000 face=3DArial size=3D4><STRONG>command =3D =
> self.surrounding(row,=20
> column)) *1</STRONG></FONT><BR>&nbsp;&nbsp;&nbsp; self.butt=20
> [row][column].grid(row=3Drow, column=3Dcolumn)<BR>&nbsp; =
> <BR>&nbsp;<BR>&nbsp;def=20
> surrounding (self, row, column):&nbsp;&nbsp;&nbsp; ## I know this is not =
> a good=20
> algorithem<BR>&nbsp; <BR>&nbsp; if row =3D=3D 0:<BR>&nbsp;&nbsp; if =
> column =3D=3D=20
> 0:<BR>&nbsp;&nbsp;&nbsp; self.change (0, 1)<BR>&nbsp;&nbsp;&nbsp; =
> self.change=20
> (1, 0)<BR>&nbsp;&nbsp;&nbsp; self.change (1, 1)<BR>&nbsp;&nbsp; elif =
> column =3D=3D=20
> self.columns:<BR>&nbsp;&nbsp;&nbsp; self.change (0, =
> 2)<BR>&nbsp;&nbsp;&nbsp;=20
> self.change (1, 2)<BR>&nbsp;&nbsp;&nbsp; self.change (1, =
> 3)<BR>&nbsp;&nbsp;=20
> else:<BR>&nbsp;&nbsp;&nbsp; self.change (0, =
> column-1)<BR>&nbsp;&nbsp;&nbsp;=20
> self.change (0, column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (1,=20
> column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (1, =
> column)<BR>&nbsp;&nbsp;&nbsp;=20
> self.change (1, column+1)<BR>&nbsp; elif row =3D=3D =
> self.rows:<BR>&nbsp;&nbsp; if=20
> column =3D=3D 0:<BR>&nbsp;&nbsp;&nbsp; self.change (row-1, =
> 0)<BR>&nbsp;&nbsp;&nbsp;=20
> self.change (row-1, 1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
> 1)<BR>&nbsp;&nbsp; elif column =3D=3D =
> self.columns:<BR>&nbsp;&nbsp;&nbsp;=20
> self.change (row, column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
> column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1, =
> column)<BR>&nbsp;&nbsp;=20
> else:<BR>&nbsp;&nbsp;&nbsp; self.change (row, =
> column-1)<BR>&nbsp;&nbsp;&nbsp;=20
> self.change (row-1, column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
> column)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
> column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row, column+1)<BR>&nbsp;=20
> else:<BR>&nbsp;&nbsp; if column =3D=3D 0:<BR>&nbsp;&nbsp;&nbsp; =
> self.change (row-1,=20
> column)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
> column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
> column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row+1,=20
> column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row+1, =
> column)<BR>&nbsp;&nbsp; elif=20
> column =3D=3D self.columns:<BR>&nbsp;&nbsp;&nbsp; self.change (row+1,=20
> column)<BR>&nbsp;&nbsp;&nbsp; self.change (row+1,=20
> column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
> column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
> column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1, =
> column)<BR>&nbsp;&nbsp;=20
> else:<BR>&nbsp;&nbsp;&nbsp; self.change (row+1, =
> column)<BR>&nbsp;&nbsp;&nbsp;=20
> self.change (row+1, column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
> column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
> column-1)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
> column)<BR>&nbsp;&nbsp;&nbsp; self.change (row-1,=20
> column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row,=20
> column+1)<BR>&nbsp;&nbsp;&nbsp; self.change (row+1,=20
> column+1)<BR>&nbsp;<BR>&nbsp;def change (self, row, column):<BR><FONT=20
> color=3D#000000 face=3DArial size=3D4><STRONG>&nbsp; ##if self.butt =
> [row] [column]=20
> [&quot;background&quot; =3D=3D &quot;white&quot;]: *2 <BR>&nbsp; ## =
> self.butt [row]=20
> [column] [&quot;background&quot;] =3D &quot;black&quot;<BR>&nbsp;=20
> ##else:<BR>&nbsp; ## self.butt [row] [column] [&quot;background&quot;] =
> =3D=20
> &quot;white&quot;<BR></STRONG></FONT>&nbsp; print row, column ##only=20
> example<BR>def main ():<BR>&nbsp;app =3D XXX=20
> (Tkinter.Tk())<BR>&nbsp;app.pack()<BR>&nbsp;app.mainloop()<BR>if =
> __name__ =3D=3D=20
> '__main__':<BR>&nbsp;main()</FONT></DIV></BODY></HTML>
> 
> ------=_NextPart_000_0004_01BFC509.2FDC2F80--
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 


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


From martinpozzi@yahoo.com  Thu May 25 00:38:20 2000
From: martinpozzi@yahoo.com (=?iso-8859-1?Q?Mart=EDn_Pozzi?=)
Date: Wed, 24 May 2000 20:38:20 -0300
Subject: [Tutor] printer output with Python
Message-ID: <000201bfc5d9$2b2fef00$521033c8@default>

Dear friends,

I need to print a sort of form on paper (using a printer), instead of the
screen. How can I do that in Phyton?. I read all the faqs and the tutorials,
but I couldn't find any reference to working with printers in Phyton. Thank
you very much.

Martin Pozzi
martinpozzi@yahoo.com


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


From kmoulfi@emirates.net.ae  Thu May 25 10:07:10 2000
From: kmoulfi@emirates.net.ae (Khalid MOULFI)
Date: Thu, 25 May 2000 13:07:10 +0400
Subject: [Tutor] Counting lines per 1st column from an text file ?
Message-ID: <1.5.4.32.20000525090710.006ee464@emirates.net.ae>

Hello everybody,

thanks to guys who answered me last time, you really helped me.

I have another request, I have a text file with following lines :

1000    12345678        10/01/00        12:09:14        8
1005    12345678        10/01/00        12:09:14        8
1000    12345678        10/01/00        12:09:14        8
1006    12345678        10/01/00        12:09:14        8
1006    12345678        10/01/00        12:09:14        8
1005    12345678        10/01/00        12:09:14        8
1000    12345678        10/01/00        12:09:14        8
2004    12345678        10/01/00        12:09:14        8
2004    12345678        10/01/00        12:09:14        8

I would like to know if it's possible to have the following outputs:

1/
        1st column      Nbr of lines
        1000            3
        1005            2      
        1006            2
        2004            2

2/
        if fist character from the the first column is:

                1 so I'l have total of lines 7
                2 so I'l have total of lines 2
                3..
                4...
        and the print out could be : 
                                1 -- 7
                                2 -- 2

Thanks to anybody who ould help me

Khalid




From emile@fenx.com  Thu May 25 13:04:35 2000
From: emile@fenx.com (Emile van Sebille)
Date: Thu, 25 May 2000 05:04:35 -0700
Subject: [Tutor] Counting lines per 1st column from an text file ?
References: <1.5.4.32.20000525090710.006ee464@emirates.net.ae>
Message-ID: <09fd01bfc641$6e938a00$1906a8c0@fc.fenx.com>

To get you started, look at using readlines() to get
the file, string.split to break it into columns, 
dictionaries to store the results, and slices to 
pick off the first character.

HTH,

Emile van Sebille
emile@fenx.com
-------------------


----- Original Message ----- 
From: Khalid MOULFI <kmoulfi@emirates.net.ae>
To: <tutor@python.org>
Sent: Thursday, May 25, 2000 2:07 AM
Subject: [Tutor] Counting lines per 1st column from an text file ?


> Hello everybody,
> 
> thanks to guys who answered me last time, you really helped me.
> 
> I have another request, I have a text file with following lines :
> 
> 1000    12345678        10/01/00        12:09:14        8
> 1005    12345678        10/01/00        12:09:14        8
> 1000    12345678        10/01/00        12:09:14        8
> 1006    12345678        10/01/00        12:09:14        8
> 1006    12345678        10/01/00        12:09:14        8
> 1005    12345678        10/01/00        12:09:14        8
> 1000    12345678        10/01/00        12:09:14        8
> 2004    12345678        10/01/00        12:09:14        8
> 2004    12345678        10/01/00        12:09:14        8
> 
> I would like to know if it's possible to have the following outputs:
> 
> 1/
>         1st column      Nbr of lines
>         1000            3
>         1005            2      
>         1006            2
>         2004            2
> 
> 2/
>         if fist character from the the first column is:
> 
>                 1 so I'l have total of lines 7
>                 2 so I'l have total of lines 2
>                 3..
>                 4...
>         and the print out could be : 
>                                 1 -- 7
>                                 2 -- 2
> 
> Thanks to anybody who ould help me
> 
> Khalid
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 



From gbaronio@siosistemi.it  Thu May 25 15:19:56 2000
From: gbaronio@siosistemi.it (Gianmarco Baronio)
Date: Thu, 25 May 2000 16:19:56 +0200
Subject: [Tutor] open the default mailer
Message-ID: <392D368C.B929F22C@siosistemi.it>

This is a cryptographically signed message in MIME format.

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

Hello everybody,

How can I open the default mailer with some fields (subject or To: or
CC:) precompiled in a Windows platform?

I tried with windll and mapi32.dll, and then with mapi.pyd but
nothing....

Have you some tricks?

Thanks



--------------ms33FED5CC2E9CF7E10BF9278C
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIIH9AYJKoZIhvcNAQcCoIIH5TCCB+ECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCC
BcUwggKpMIICEqADAgECAgMCMHwwDQYJKoZIhvcNAQEEBQAwgZQxCzAJBgNVBAYTAlpBMRUw
EwYDVQQIEwxXZXN0ZXJuIENhcGUxFDASBgNVBAcTC0R1cmJhbnZpbGxlMQ8wDQYDVQQKEwZU
aGF3dGUxHTAbBgNVBAsTFENlcnRpZmljYXRlIFNlcnZpY2VzMSgwJgYDVQQDEx9QZXJzb25h
bCBGcmVlbWFpbCBSU0EgMTk5OS45LjE2MB4XDTAwMDIyOTEyMDEwMVoXDTAxMDIyODEyMDEw
MVowSDEfMB0GA1UEAxMWVGhhd3RlIEZyZWVtYWlsIE1lbWJlcjElMCMGCSqGSIb3DQEJARYW
Z2Jhcm9uaW9Ac2lvc2lzdGVtaS5pdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAzzdh
dtamiMyRC7A7eZJgZiB8/HESCZ6OSL+GYkX0wgdvV3BuEhh9T7UJSICH6+r9g9Dc0QlXswuT
dAM89Pku0kepdkS/wbINyJH61brQqB70U9M14RVbNAXzRFJtnX4lACVGWjxTxe+alHt4q4Aw
v7v7A0amkTzK7SHgPIOQatMCAwEAAaNUMFIwIQYDVR0RBBowGIEWZ2Jhcm9uaW9Ac2lvc2lz
dGVtaS5pdDAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFIir8WCDZlX05FjHRh3AYb0j18OM
MA0GCSqGSIb3DQEBBAUAA4GBAJNTdfbJj52Wrs9MHUsY8pOORQIuYIx/LO0kh1T77Vg3UTyr
I/L8uKGgmVtyAsNxVe9fPPkI2ec82skX2YgLQEfigIyDxW5quXcgGx/IdxQuZYDMrXNiSJmI
y85s+Qh3svBUnuHkUytvRyXR8MzppilouPytubGSNcShpJWb0PZZMIIDFDCCAn2gAwIBAgIB
CzANBgkqhkiG9w0BAQQFADCB0TELMAkGA1UEBhMCWkExFTATBgNVBAgTDFdlc3Rlcm4gQ2Fw
ZTESMBAGA1UEBxMJQ2FwZSBUb3duMRowGAYDVQQKExFUaGF3dGUgQ29uc3VsdGluZzEoMCYG
A1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEkMCIGA1UEAxMbVGhhd3Rl
IFBlcnNvbmFsIEZyZWVtYWlsIENBMSswKQYJKoZIhvcNAQkBFhxwZXJzb25hbC1mcmVlbWFp
bEB0aGF3dGUuY29tMB4XDTk5MDkxNjE0MDE0MFoXDTAxMDkxNTE0MDE0MFowgZQxCzAJBgNV
BAYTAlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxFDASBgNVBAcTC0R1cmJhbnZpbGxlMQ8w
DQYDVQQKEwZUaGF3dGUxHTAbBgNVBAsTFENlcnRpZmljYXRlIFNlcnZpY2VzMSgwJgYDVQQD
Ex9QZXJzb25hbCBGcmVlbWFpbCBSU0EgMTk5OS45LjE2MIGfMA0GCSqGSIb3DQEBAQUAA4GN
ADCBiQKBgQCzaVqX1NAWC3q1xV3pIZwjcs0STEv3fs/H+8pyJPRCUqxXleN7YXoXhOf9cjk4
lLTq7WWnkgZeveBl9hm7lHl2TD65aHB1hBz0EXQAvAUsTwkDFzHM9EHUcsamXeKIRLCLLsRN
8fDWhT5s85WUeJF+QOmc0Y0VV47Cc+Uw3kb1TwIDAQABozcwNTASBgNVHRMBAf8ECDAGAQH/
AgEAMB8GA1UdIwQYMBaAFHJJwnM0xlX0C3ZygX539IfnxrIOMA0GCSqGSIb3DQEBBAUAA4GB
AGvGWekx+um27LED2N9ycv6RYEjqxlXde/BnjsZhcOdtwqU32J23FyhWBYvdXHVvxpGQxmxm
cRPQEHxrkW+G4CE2LcHX6rIJrc8tbcaDUpv7u/6ch538t+l0kuRcl678fqzKDW9yemcsa3P1
hvmd9QBu9B0Hzp2egmMp75MJflXeMYIB9zCCAfMCAQEwgZwwgZQxCzAJBgNVBAYTAlpBMRUw
EwYDVQQIEwxXZXN0ZXJuIENhcGUxFDASBgNVBAcTC0R1cmJhbnZpbGxlMQ8wDQYDVQQKEwZU
aGF3dGUxHTAbBgNVBAsTFENlcnRpZmljYXRlIFNlcnZpY2VzMSgwJgYDVQQDEx9QZXJzb25h
bCBGcmVlbWFpbCBSU0EgMTk5OS45LjE2AgMCMHwwCQYFKw4DAhoFAKCBsTAYBgkqhkiG9w0B
CQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wMDA1MjUxNDE5NTZaMCMGCSqGSIb3
DQEJBDEWBBTXEZeNv6N4qzz00wxPoIdkMNhPxjBSBgkqhkiG9w0BCQ8xRTBDMAoGCCqGSIb3
DQMHMA4GCCqGSIb3DQMCAgIAgDAHBgUrDgMCBzANBggqhkiG9w0DAgIBQDANBggqhkiG9w0D
AgIBKDANBgkqhkiG9w0BAQEFAASBgGw/CP4M0y82bbqwJlHOeMyvV39eQNTq7hQHBsfhDWHV
deDmpDTKeGgreLcBICpPPx0olKdIBeanYyAt6DsRai/RMVIDk4h8vkMrAzQ6Bu8jf1PbLMmH
13g5q2c4N0+lDzZmEjMJwIk9aIbKsxuMgcXXZjuy2OgobZCEPloKW3LO
--------------ms33FED5CC2E9CF7E10BF9278C--



From bwinton@tor.dhs.org  Thu May 25 15:01:25 2000
From: bwinton@tor.dhs.org (Blake Winton)
Date: Thu, 25 May 2000 10:01:25 -0400
Subject: [Tutor] open the default mailer
In-Reply-To: <392D368C.B929F22C@siosistemi.it>
References: <392D368C.B929F22C@siosistemi.it>
Message-ID: <20000525100125.A3649@tor.dhs.org>

* Gianmarco Baronio <gbaronio@siosistemi.it> [000525 09:23]:
> How can I open the default mailer with some fields (subject or To: or
> CC:) precompiled in a Windows platform?
> Have you some tricks?

Well, it's ugly, but since you only wanted to run on Windows anyway,
you could always use 
os.system( "start mailto:email@mail.com?subject=Testing" )

(Note: untested code.  Just an idea to help you along.)

Later,
Blake.
-- 
9:58am up 2 days, 2:05, 1 user, load average: 0.00, 0.00, 0.00


From gbaronio@siosistemi.it  Thu May 25 16:34:28 2000
From: gbaronio@siosistemi.it (Gianmarco Baronio)
Date: Thu, 25 May 2000 17:34:28 +0200
Subject: [Tutor] open the default mailer
References: <392D368C.B929F22C@siosistemi.it> <20000525100125.A3649@tor.dhs.org>
Message-ID: <392D4804.225E7493@siosistemi.it>

This is a cryptographically signed message in MIME format.

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

Thanks Blake,

For the moment goes right, it's a good idea!


>>> import win32api
>>> shresult =
win32api.ShellExecute(0,'open','mailto:email@mail.com?subject=Testing&body=Thanks
Blake','' , '', 0)


Blake Winton wrote:

> * Gianmarco Baronio <gbaronio@siosistemi.it> [000525 09:23]:
> > How can I open the default mailer with some fields (subject or To: or
> > CC:) precompiled in a Windows platform?
> > Have you some tricks?
>
> Well, it's ugly, but since you only wanted to run on Windows anyway,
> you could always use
> os.system( "start mailto:email@mail.com?subject=Testing" )
>
> (Note: untested code.  Just an idea to help you along.)
>
> Later,
> Blake.
> --
> 9:58am up 2 days, 2:05, 1 user, load average: 0.00, 0.00, 0.00
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

--------------ms579537E6BF48FFE1D4BA1E7B
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIIH9AYJKoZIhvcNAQcCoIIH5TCCB+ECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCC
BcUwggKpMIICEqADAgECAgMCMHwwDQYJKoZIhvcNAQEEBQAwgZQxCzAJBgNVBAYTAlpBMRUw
EwYDVQQIEwxXZXN0ZXJuIENhcGUxFDASBgNVBAcTC0R1cmJhbnZpbGxlMQ8wDQYDVQQKEwZU
aGF3dGUxHTAbBgNVBAsTFENlcnRpZmljYXRlIFNlcnZpY2VzMSgwJgYDVQQDEx9QZXJzb25h
bCBGcmVlbWFpbCBSU0EgMTk5OS45LjE2MB4XDTAwMDIyOTEyMDEwMVoXDTAxMDIyODEyMDEw
MVowSDEfMB0GA1UEAxMWVGhhd3RlIEZyZWVtYWlsIE1lbWJlcjElMCMGCSqGSIb3DQEJARYW
Z2Jhcm9uaW9Ac2lvc2lzdGVtaS5pdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAzzdh
dtamiMyRC7A7eZJgZiB8/HESCZ6OSL+GYkX0wgdvV3BuEhh9T7UJSICH6+r9g9Dc0QlXswuT
dAM89Pku0kepdkS/wbINyJH61brQqB70U9M14RVbNAXzRFJtnX4lACVGWjxTxe+alHt4q4Aw
v7v7A0amkTzK7SHgPIOQatMCAwEAAaNUMFIwIQYDVR0RBBowGIEWZ2Jhcm9uaW9Ac2lvc2lz
dGVtaS5pdDAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFIir8WCDZlX05FjHRh3AYb0j18OM
MA0GCSqGSIb3DQEBBAUAA4GBAJNTdfbJj52Wrs9MHUsY8pOORQIuYIx/LO0kh1T77Vg3UTyr
I/L8uKGgmVtyAsNxVe9fPPkI2ec82skX2YgLQEfigIyDxW5quXcgGx/IdxQuZYDMrXNiSJmI
y85s+Qh3svBUnuHkUytvRyXR8MzppilouPytubGSNcShpJWb0PZZMIIDFDCCAn2gAwIBAgIB
CzANBgkqhkiG9w0BAQQFADCB0TELMAkGA1UEBhMCWkExFTATBgNVBAgTDFdlc3Rlcm4gQ2Fw
ZTESMBAGA1UEBxMJQ2FwZSBUb3duMRowGAYDVQQKExFUaGF3dGUgQ29uc3VsdGluZzEoMCYG
A1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEkMCIGA1UEAxMbVGhhd3Rl
IFBlcnNvbmFsIEZyZWVtYWlsIENBMSswKQYJKoZIhvcNAQkBFhxwZXJzb25hbC1mcmVlbWFp
bEB0aGF3dGUuY29tMB4XDTk5MDkxNjE0MDE0MFoXDTAxMDkxNTE0MDE0MFowgZQxCzAJBgNV
BAYTAlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxFDASBgNVBAcTC0R1cmJhbnZpbGxlMQ8w
DQYDVQQKEwZUaGF3dGUxHTAbBgNVBAsTFENlcnRpZmljYXRlIFNlcnZpY2VzMSgwJgYDVQQD
Ex9QZXJzb25hbCBGcmVlbWFpbCBSU0EgMTk5OS45LjE2MIGfMA0GCSqGSIb3DQEBAQUAA4GN
ADCBiQKBgQCzaVqX1NAWC3q1xV3pIZwjcs0STEv3fs/H+8pyJPRCUqxXleN7YXoXhOf9cjk4
lLTq7WWnkgZeveBl9hm7lHl2TD65aHB1hBz0EXQAvAUsTwkDFzHM9EHUcsamXeKIRLCLLsRN
8fDWhT5s85WUeJF+QOmc0Y0VV47Cc+Uw3kb1TwIDAQABozcwNTASBgNVHRMBAf8ECDAGAQH/
AgEAMB8GA1UdIwQYMBaAFHJJwnM0xlX0C3ZygX539IfnxrIOMA0GCSqGSIb3DQEBBAUAA4GB
AGvGWekx+um27LED2N9ycv6RYEjqxlXde/BnjsZhcOdtwqU32J23FyhWBYvdXHVvxpGQxmxm
cRPQEHxrkW+G4CE2LcHX6rIJrc8tbcaDUpv7u/6ch538t+l0kuRcl678fqzKDW9yemcsa3P1
hvmd9QBu9B0Hzp2egmMp75MJflXeMYIB9zCCAfMCAQEwgZwwgZQxCzAJBgNVBAYTAlpBMRUw
EwYDVQQIEwxXZXN0ZXJuIENhcGUxFDASBgNVBAcTC0R1cmJhbnZpbGxlMQ8wDQYDVQQKEwZU
aGF3dGUxHTAbBgNVBAsTFENlcnRpZmljYXRlIFNlcnZpY2VzMSgwJgYDVQQDEx9QZXJzb25h
bCBGcmVlbWFpbCBSU0EgMTk5OS45LjE2AgMCMHwwCQYFKw4DAhoFAKCBsTAYBgkqhkiG9w0B
CQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wMDA1MjUxNTM0MjlaMCMGCSqGSIb3
DQEJBDEWBBSMsvm2cmWBaA2taBrXXcFm+5hBnTBSBgkqhkiG9w0BCQ8xRTBDMAoGCCqGSIb3
DQMHMA4GCCqGSIb3DQMCAgIAgDAHBgUrDgMCBzANBggqhkiG9w0DAgIBQDANBggqhkiG9w0D
AgIBKDANBgkqhkiG9w0BAQEFAASBgEUrZSJ2amvUw4dKAmI1Jtgza7VAoQ1QhQ6UY6WEGEBb
3Oq3pUQH29dAw66PBlZvvQ50kwCXTH2U32fKmY38oi2qDWWtprFT+rkDR2wSyJcljVpVnUrY
tdHJf2JQ2panmgfc2fjLOwd+FkW/o0T/9ng3NDeuuk6GXWlX8ETD+Qbi
--------------ms579537E6BF48FFE1D4BA1E7B--



From Borgulya Gabor <borgulya@pons.sote.hu>  Sat May 27 00:26:46 2000
From: Borgulya Gabor <borgulya@pons.sote.hu> (Borgulya Gabor)
Date: Sat, 27 May 2000 01:26:46 +0200 (CEST)
Subject: [Tutor] Counting lines per 1st column from an text file ?
In-Reply-To: <1.5.4.32.20000525090710.006ee464@emirates.net.ae>
Message-ID: <Pine.LNX.3.96.1000527011424.2729A-100000@Pons.sote.hu>

Hi Khalid,
Here is a solution, I hope it helps you understand Python.
Cheers,
Gabor BORGULYA

--------------------------- kmlog.py --------------------------
import string

log_file = open('test.txt','r')
all_the_lines_in_one_list = log_file.readlines()
log_file.close()

lines_broken_into_columns = map(string.split,all_the_lines_in_one_list)

number_of_logins_by_user = {}
for line in lines_broken_into_columns:
    user = line[0]
    number_of_logins_by_user[user] = number_of_logins_by_user.get(user,0) + 1
    
print """
1/
        1st column      Nbr of lines"""
user_list = number_of_logins_by_user.keys()
user_list.sort()
number_of_logins_by_user_group = {}
for user in user_list:
    print "        %s            %s" % (user, number_of_logins_by_user[user])
    user_group = user[0]
    number_of_logins_by_user_group[user_group] = number_of_logins_by_user_group.get(user_group, 0)+number_of_logins_by_user[user]

print """
2/"""
user_group_list = number_of_logins_by_user_group.keys()
user_group_list.sort()
for user_group in user_group_list:
    print "                                %s -- %s" % (user_group, number_of_logins_by_user_group[user_group])
----------------------- end of kmlog.py -----------------------

--------------------------- test.txt --------------------------
1000    12345678        10/01/00        12:09:14        8
1005    12345678        10/01/00        12:09:14        8
1000    12345678        10/01/00        12:09:14        8
1006    12345678        10/01/00        12:09:14        8
1006    12345678        10/01/00        12:09:14        8
1005    12345678        10/01/00        12:09:14        8
1000    12345678        10/01/00        12:09:14        8
2004    12345678        10/01/00        12:09:14        8
2004    12345678        10/01/00        12:09:14        8
----------------------- end of test.txt -----------------------

--------------------------- output ----------------------------
1/
        1st column      Nbr of lines
        1000            3
        1005            2
        1006            2
        2004            2

2/
                                1 -- 7
                                2 -- 2
--------------------------- end of output ---------------------



From borgulya@pons.sote.hu  Sat May 27 01:16:36 2000
From: borgulya@pons.sote.hu (Borgulya Gabor)
Date: Sat, 27 May 2000 02:16:36 +0200 (CEST)
Subject: [Tutor] Counting lines per 1st column from an text file ?
In-Reply-To: <1.5.4.32.20000525090710.006ee464@emirates.net.ae>
Message-ID: <Pine.LNX.3.96.1000527021103.5432A-100000@Pons.sote.hu>

And here is a shorter version which is difficult to improve if you have
to define more than 9 user groups:

------------------------------ kmlog1.py --------------------------------
import string

def summarize(list):
    output_dict = {}
    for i in list:
        id = i[0]
        output_dict[id] = output_dict.get(id, 0) + 1
    return output_dict

def print_dictionary(dict):
    k=dict.keys(); k.sort()
    for i in k: print '%s\t%s' % (i, dict[i])

log_file = open('test.txt','r')
all_the_lines_in_one_list = log_file.readlines()
log_file.close()
lines_broken_into_columns = map(string.split,all_the_lines_in_one_list)
number_of_logins_by_user = summarize(lines_broken_into_columns)
number_of_logins_by_user_group = summarize(all_the_lines_in_one_list)

print "1/\nUser\tNoOfLogins"
print_dictionary(number_of_logins_by_user)
print "\n2/\nUserGr\tNoOfLogins"
print_dictionary(number_of_logins_by_user_group)
------------------------------- end of kmlog1.py --------------------
Gabor BORGULYA



From Moshe Zadka <moshez@math.huji.ac.il>  Sat May 27 01:57:56 2000
From: Moshe Zadka <moshez@math.huji.ac.il> (Moshe Zadka)
Date: Sat, 27 May 2000 03:57:56 +0300 (IDT)
Subject: [Tutor] printer output with Python
In-Reply-To: <000201bfc5d9$2b2fef00$521033c8@default>
Message-ID: <Pine.GSO.4.10.10005270356200.2081-100000@sundial>

On Wed, 24 May 2000, [iso-8859-1] Mart=EDn Pozzi wrote:

> I need to print a sort of form on paper (using a printer), instead of the
> screen. How can I do that in Phyton?. I read all the faqs and the tutoria=
ls,
> but I couldn't find any reference to working with printers in Phyton. Tha=
nk
> you very much.

Try using the PDF tools from Report Labs (www.reportlab.com) to create a
PDF file. Then you can use standard tools (like Adobe Acrobat Reader) to
print it on any platform.=20





From borgulya@pons.sote.hu  Sun May 28 19:35:24 2000
From: borgulya@pons.sote.hu (Borgulya Gabor)
Date: Sun, 28 May 2000 20:35:24 +0200 (CEST)
Subject: [Tutor] printing variable name and value?
Message-ID: <Pine.LNX.3.96.1000528202121.10686A-100000@Pons.sote.hu>

Hi!

When I am testing my scripts, I often need the following line:

print 'x =',x

But as I like verbose variable names I hate to type them twice.
I wanted to write a small function that works like this:

>>> x=5
>>> print_variable('x')
x = 5
>>>

But I was unable to do it. If I pass the print_variable function the value
of x, like print_variable(x), I can not access the variable name. And if I
pass it the variable name, like above, I can not access the value of the
variable, because I am in a new name space.

Do I need such complicated methods as Traceback?

Gabor



From emile@fenx.com  Sun May 28 20:12:17 2000
From: emile@fenx.com (Emile van Sebille)
Date: Sun, 28 May 2000 12:12:17 -0700
Subject: [Tutor] printing variable name and value?
References: <Pine.LNX.3.96.1000528202121.10686A-100000@Pons.sote.hu>
Message-ID: <043501bfc8d8$aac08ca0$1906a8c0@fc.fenx.com>

Does this do it?

def show_vars(varlist, namespace):
  for var in varlist:
    print "%s = %s" % (var, namespace[var])


>>> a = 1
>>> b = 2
>>> show_vars(('a','b'),locals())
a = 1
b = 2
>>>

Emile van Sebille
emile@fenx.com
-------------------


----- Original Message -----
From: Borgulya Gabor <borgulya@pons.sote.hu>
To: <tutor@python.org>
Sent: Sunday, May 28, 2000 11:35 AM
Subject: [Tutor] printing variable name and value?


> Hi!
>
> When I am testing my scripts, I often need the following line:
>
> print 'x =',x
>
> But as I like verbose variable names I hate to type them twice.
> I wanted to write a small function that works like this:
>
> >>> x=5
> >>> print_variable('x')
> x = 5
> >>>
>
> But I was unable to do it. If I pass the print_variable function the
value
> of x, like print_variable(x), I can not access the variable name. And
if I
> pass it the variable name, like above, I can not access the value of
the
> variable, because I am in a new name space.
>
> Do I need such complicated methods as Traceback?
>
> Gabor
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>



From emile@fenx.com  Mon May 29 19:02:16 2000
From: emile@fenx.com (Emile van Sebille)
Date: Mon, 29 May 2000 11:02:16 -0700
Subject: [Tutor] printing variable name and value?
References: <Pine.LNX.3.96.1000529191043.29164A-100000@Pons.sote.hu>
Message-ID: <069101bfc998$0d0e0da0$1906a8c0@fc.fenx.com>

Just be careful about adding entries.  It's not guaranteed
to work right.

From the docs:

locals ()
    Return a dictionary representing the current local symbol
    table. Warning: the contents of this dictionary should not
    be modified; changes may not affect the values of
    local variables used by the interpreter.

Even-though-it-may-look-like-it-ly y'rs,

Emile van Sebille
emile@fenx.com
-------------------


----- Original Message -----
From: Borgulya Gabor <borgulya@pons.sote.hu>
To: Emile van Sebille <emile@fenx.com>
Sent: Monday, May 29, 2000 10:12 AM
Subject: Re: [Tutor] printing variable name and value?


> On Sun, 28 May 2000, Emile van Sebille wrote:
> > Does this do it?
> >
> > def show_vars(varlist, namespace):
> >   for var in varlist:
> >     print "%s = %s" % (var, namespace[var])
> Hello, thanks for the idea. I is not exactly what I wanted, but you
have
> tought me something: I was not aware of the possibility of retrieving
the
> namespaces az dictionaries.
> Thanks,
> Gabor
>
>



From jgonzalez@gruposimplex.com  Tue May 30 17:05:54 2000
From: jgonzalez@gruposimplex.com (Jorge Eldis)
Date: Tue, 30 May 2000 11:05:54 -0500
Subject: [Tutor] Add me
Message-ID: <000801bfca50$f2458520$0201a8c0@mail.pty.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01BFCA27.0629C800
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Add me

------=_NextPart_000_0005_01BFCA27.0629C800
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=3Dwindows-1252" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Add me</FONT></DIV></BODY></HTML>

------=_NextPart_000_0005_01BFCA27.0629C800--



From wilson@visi.com  Tue May 30 20:41:29 2000
From: wilson@visi.com (Timothy Wilson)
Date: Tue, 30 May 2000 14:41:29 -0500 (CDT)
Subject: [Tutor] why the error?
Message-ID: <Pine.GSO.4.10.10005301432140.16039-100000@isis.visi.com>

Hi everyone,

I've been working on some simple python programs, and I'm running into some
differences between the code I create in the interpretor and what's in a
text file. An example:

I wrote a little function that determines whether a given number is prime or
not. (I'm pretty sure the algorithm is correct.)

--snip--
from math import *

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

if __name__ == '__main__':
   number = raw_input("Which number? ")
   if isPrime(number):
      print "%i is prime." % number
   print "%i is not prime." % number
--snip--

This code seems to work perfectly when imported in the interpretor. When I
run it by typing 'python prime.py', I get:

[wilsont@galileo python]$ python prime.py
Which number? 11
Traceback (innermost last):
  File "prime.py", line 15, in ?
    if isPrime(number):
  File "prime.py", line 8, in isPrime
    for j in range(2, sqrt(number)+1):
TypeError: illegal argument type for built-in operation

Any hints? Why the difference?

-Tim

--
Tim Wilson      | Visit Sibley online:         | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |                              | http://slashdot.org/
wilson@visi.com |   <dtml-var pithy_quote>     | http://linux.com/



From wesc@alpha.ece.ucsb.edu  Tue May 30 21:22:50 2000
From: wesc@alpha.ece.ucsb.edu (Wesley J. Chun)
Date: Tue, 30 May 2000 13:22:50 -0700 (PDT)
Subject: [Tutor] why the error?
Message-ID: <200005302022.NAA20813@alpha.ece.ucsb.edu>

    > Date: Tue, 30 May 2000 14:41:29 -0500 (CDT)
    > From: Timothy Wilson <wilson@visi.com>
    > 
    > I wrote a little function that determines whether a given number is prime or
    > not. (I'm pretty sure the algorithm is correct.)
    > 
    > --snip--
    > from math import *
    > 
    > def isPrime(number):
    >    for j in range(2, sqrt(number)+1):
    >       if number % j == 0:
    >          return 0
    >    return 1
    > 
    > if __name__ == '__main__':
    >    number = raw_input("Which number? ")
    >    if isPrime(number):
    >       print "%i is prime." % number
    >    print "%i is not prime." % number
    > --snip--
    > 
    > This code seems to work perfectly when imported in the interpretor. When I
    > run it by typing 'python prime.py', I get:
    > 
    > [wilsont@galileo python]$ python prime.py
    > Which number? 11
    > Traceback (innermost last):
    >   File "prime.py", line 15, in ?
    >     if isPrime(number):
    >   File "prime.py", line 8, in isPrime
    >     for j in range(2, sqrt(number)+1):
    > TypeError: illegal argument type for built-in operation
    > 
    > Any hints? Why the difference?


well, guess what.  it should *not* have worked in the interpreter either.
the problem with the code is here:

    >    for j in range(2, sqrt(number)+1):

the reason why you get a TypeError is because the sqrt()
function expects a floating point number.  you passed in
a string.  the string comes from raw_input():

    >    number = raw_input("Which number? ")

the raw_input() built-in function returns a raw string of
what the user enters.

to fix the bug, you have two choices:

1) leave it as a string input from the user using raw_input()
    and convert that value to a float, i.e. you can do it in
    different places, i.e.

    number = float(raw_input("Which number? "))

or

    if isPrime((float(number)):

or even

    for j in range(2, sqrt(float(number))+1):

note that if you are using an older version of python where
strings are not accepted input for float(), you would have
to use string.atof().

(2) use input() to evaluate the string expression input.
    input() is really the same as eval(raw_input()).
    
so if you type in any object, they will be represented as
such by eval() and returned, i.e. if the user enters an int,
you can an int, if they enter a list, you get a list, etc.

i would probably recommend option (1) because at least you
are guaranteed you get a float out of it.


finally, i am not familiar with the "%i" directive for the
string format operator:

    >       print "%i is prime." % number

do you mean "%d" for integer?


hope this helps!!

-wesley

"Core Python Programming", Prentice-Hall, TBP Summer 2000

wesley.j.chun :: wesc@alpha.ece.ucsb.edu
cyberweb.consulting :: silicon.valley, ca
http://www.roadkill.com/~wesc/cyberweb/


From emile@fenx.com  Tue May 30 21:17:20 2000
From: emile@fenx.com (Emile van Sebille)
Date: Tue, 30 May 2000 13:17:20 -0700
Subject: [Tutor] why the error?
References: <Pine.GSO.4.10.10005301432140.16039-100000@isis.visi.com>
Message-ID: <005101bfca74$159ea9c0$1906a8c0@fc.fenx.com>

It looks like there's some kind of conversion taking
place somewhere, because if you convert your input
to an integer before invoking isprime, it all works
out OK.  (see line added below)

Also, you probably want the final line in an else clause.
Right now it will always print.

Final note:  if you do
   for j in [2] + range(3, sqrt(number)+1,2):
you won't test all the even's after 2.

HTH,

Emile van Sebille
emile@fenx.com
-------------------


----- Original Message -----
From: Timothy Wilson <wilson@visi.com>
To: <tutor@python.org>
Sent: Tuesday, May 30, 2000 12:41 PM
Subject: [Tutor] why the error?


> Hi everyone,
>
> I've been working on some simple python programs, and I'm running into
some
> differences between the code I create in the interpretor and what's in
a
> text file. An example:
>
> I wrote a little function that determines whether a given number is
prime or
> not. (I'm pretty sure the algorithm is correct.)
>
> --snip--
> from math import *
>
> def isPrime(number):
>    for j in range(2, sqrt(number)+1):
>       if number % j == 0:
>          return 0
>    return 1
>
> if __name__ == '__main__':
>    number = raw_input("Which number? ")

     number = int(number)

>    if isPrime(number):
>       print "%i is prime." % number
>    print "%i is not prime." % number
> --snip--
>
> This code seems to work perfectly when imported in the interpretor.
When I
> run it by typing 'python prime.py', I get:
>
> [wilsont@galileo python]$ python prime.py
> Which number? 11
> Traceback (innermost last):
>   File "prime.py", line 15, in ?
>     if isPrime(number):
>   File "prime.py", line 8, in isPrime
>     for j in range(2, sqrt(number)+1):
> TypeError: illegal argument type for built-in operation
>
> Any hints? Why the difference?
>
> -Tim
>
> --
> Tim Wilson      | Visit Sibley online:         | Check out:
> Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
> W. St. Paul, MN |                              | http://slashdot.org/
> wilson@visi.com |   <dtml-var pithy_quote>     | http://linux.com/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>



From wilson@visi.com  Tue May 30 21:31:27 2000
From: wilson@visi.com (Timothy Wilson)
Date: Tue, 30 May 2000 15:31:27 -0500 (CDT)
Subject: [Tutor] why the error?
In-Reply-To: <200005302022.NAA20813@alpha.ece.ucsb.edu>
Message-ID: <Pine.GSO.4.10.10005301524500.16039-100000@isis.visi.com>

On Tue, 30 May 2000, Wesley J. Chun wrote:

> well, guess what.  it should *not* have worked in the interpreter either.
> the problem with the code is here:
> 
>     >    for j in range(2, sqrt(number)+1):

Isn't the reason that it worked in the interpreter because I was passing an
integer directly?

>>> isPrime(17)
17 is prime.

> the reason why you get a TypeError is because the sqrt()
> function expects a floating point number.  you passed in
> a string.  the string comes from raw_input():
> 
>     >    number = raw_input("Which number? ")
> 
> the raw_input() built-in function returns a raw string of
> what the user enters.

Of course. That makes complete sense.

> finally, i am not familiar with the "%i" directive for the
> string format operator:
> 
>     >       print "%i is prime." % number
> 
> do you mean "%d" for integer?

I didn't have any python docs handy at the time so I guessed. It works. Go
figure.

> hope this helps!!

Thanks very much.

-Tim

--
Tim Wilson      | Visit Sibley online:         | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |                              | http://slashdot.org/
wilson@visi.com |   <dtml-var pithy_quote>     | http://linux.com/



From spirou@carolo.net  Tue May 30 23:51:19 2000
From: spirou@carolo.net (Denis =?iso-8859-1?Q?Fr=E8re?=)
Date: Wed, 31 May 2000 00:51:19 +0200
Subject: [Tutor] Add me
References: <000801bfca50$f2458520$0201a8c0@mail.pty.com>
Message-ID: <393445E7.25E401CB@carolo.net>

> Jorge Eldis wrote:
> 
> Add me

send an e-mail to tutor-request@python.org
just write : 

   subscribe 

in the body

-- 
Denis Frère
P3B    : Club Free-Pytho-Linuxien Carolorégien http://www.p3b.org
Aragne : Internet - Réseaux - Formations  http://www.aragne.com


From scarblac@pino.selwerd.nl  Wed May 31 00:22:03 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 31 May 2000 01:22:03 +0200
Subject: [Tutor] why the error?
In-Reply-To: <Pine.GSO.4.10.10005301524500.16039-100000@isis.visi.com>; from wilson@visi.com on Tue, May 30, 2000 at 03:31:27PM -0500
References: <200005302022.NAA20813@alpha.ece.ucsb.edu> <Pine.GSO.4.10.10005301524500.16039-100000@isis.visi.com>
Message-ID: <20000531012203.A7103@pino.selwerd.nl>

On Tue, May 30, 2000 at 03:31:27PM -0500, Timothy Wilson wrote:
> Isn't the reason that it worked in the interpreter because I was passing an
> integer directly?
> 
> >>> isPrime(17)
> 17 is prime.

Yes, well, the poster probably thought you were doing all of it in the
interpreter, including the raw_input().

Btw, if you want to see a cool implementation of a prime number generator,
see Demo/scripts/prime.py in the source distribution (that was the reason
for this mail, noone mentioned this yet ;-)).

-- 
Remco Gerlich,  scarblac@pino.selwerd.nl


From vanzant3838@netscape.net  Wed May 31 00:57:54 2000
From: vanzant3838@netscape.net (tim)
Date: 30 May 00 19:57:54 EDT
Subject: [Tutor] Remove me from your mailing list please
Message-ID: <20000530235754.24634.qmail@ww183.netaddress.usa.net>

Please remove me from your mailing list please.  Thanks a lot.

tim

____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at http://webm=
ail.netscape.com.


From wilson@visi.com  Wed May 31 05:13:49 2000
From: wilson@visi.com (Timothy Wilson)
Date: Tue, 30 May 2000 23:13:49 -0500 (CDT)
Subject: [Tutor] best practice
Message-ID: <Pine.GSO.4.10.10005302302010.2746-100000@isis.visi.com>

Hi everyone,

Thanks for all of the suggestions with my little prime number program. As
several people pointed out, the problem was that raw_input gets a string
which sqrt() chokes on. In the interpreter, all it well because the function
gets called directly with an integer. OK, problem solved.

That brings up another very picky question though. Where should I handle
these type difficulties? Here's another little program I was playing around
with that takes an integer and returns a list of the integer's factors. The
algorithm is crude, but effective.

wilson@beethoven modules]$ cat factor.py
# This function factors an integer and returns a list

from math import *

def factor(number):
	factors = [1, int(number)]
	for i in range(2, sqrt(number) + 1):
		if number % i == 0:
			factors.append(i)
			if i != number/i:   # catch duplicates
				factors.append(int(number/i))
	factors.sort()
	return factors

if __name__ == '__main__':
	number = raw_input("Factor what? ")
	print factor(float(number))

As you can see, I convert the raw_input to a float before passing it to the
function. Also, I have a couple of int() functions in my factor function to
make sure that the list which is returned is a list of integers. **When run
from the interpreter, those int()s aren't needed.**

So here's the question (it's about time :-). Is it better python practice to
make those type conversion outside the function or inside as I've done?
Should the functions be made as "pure" as possible? It seems to me that for
maximum efficiency, a rule of thumb should be that functions should be made
to work in the interpreter with a minimum of fuss. The programmer who uses
the function (or module) should be the one who concerns himself with the
"types" of variables that are passed.

Does this make any sense? (I've been grading 10-page research papers from
9th graders for the last couple hours. It can cause your head to swim.)

-Tim

--
Tim Wilson      | Visit Sibley online:         | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |                              | http://slashdot.org/
wilson@visi.com |   <dtml-var pithy_quote>     | http://linux.com/



From scarblac@pino.selwerd.nl  Wed May 31 08:52:21 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 31 May 2000 09:52:21 +0200
Subject: [Tutor] best practice
In-Reply-To: <Pine.GSO.4.10.10005302302010.2746-100000@isis.visi.com>; from wilson@visi.com on Tue, May 30, 2000 at 11:13:49PM -0500
References: <Pine.GSO.4.10.10005302302010.2746-100000@isis.visi.com>
Message-ID: <20000531095221.A7643@pino.selwerd.nl>

On Tue, May 30, 2000 at 11:13:49PM -0500, Timothy Wilson wrote:
> Hi everyone,
> 
> Thanks for all of the suggestions with my little prime number program. As
> several people pointed out, the problem was that raw_input gets a string
> which sqrt() chokes on. In the interpreter, all it well because the function
> gets called directly with an integer. OK, problem solved.
> 
> That brings up another very picky question though. Where should I handle
> these type difficulties? Here's another little program I was playing around
> with that takes an integer and returns a list of the integer's factors. The
> algorithm is crude, but effective.
> 
> wilson@beethoven modules]$ cat factor.py
> # This function factors an integer and returns a list
> 
> from math import *
> 
> def factor(number):
> 	factors = [1, int(number)]
> 	for i in range(2, sqrt(number) + 1):
> 		if number % i == 0:
> 			factors.append(i)
> 			if i != number/i:   # catch duplicates
> 				factors.append(int(number/i))
> 	factors.sort()
> 	return factors
> 
> if __name__ == '__main__':
> 	number = raw_input("Factor what? ")
> 	print factor(float(number))
> 
> As you can see, I convert the raw_input to a float before passing it to the
> function. Also, I have a couple of int() functions in my factor function to
> make sure that the list which is returned is a list of integers. **When run
> from the interpreter, those int()s aren't needed.**
> 
> So here's the question (it's about time :-). Is it better python practice to
> make those type conversion outside the function or inside as I've done?

The function only makes sense for integer arguments, really. So I usually
assume that the argument is an integer, *put that in the doc string*, and
use an assert statement.

def factor(number):
   """factor(number)
   
   Return a list with the factors of a number. Argument must be an integer."""
   assert type(number) == type(1)
   
   etc.

Now it throws an exception when the wrong type of argument is passed in.

> Should the functions be made as "pure" as possible? It seems to me that for
> maximum efficiency, a rule of thumb should be that functions should be made
> to work in the interpreter with a minimum of fuss.

Well... This 'works in the interpreter' because you give it an integer
argument there. And in your program you use float()... that's just odd,
nothing to do with the interpreter :).

Functions can either only accept the correct type of input and fail
otherwise, or try to convert input to the correct type. I think the first is
more Pythonish (consistent, programmer has to spell out exactly what he
wants) and the second is more Perlish (try to guess what the programmer
wanted).

Whatever you do, be consistent about it, and document it :-)

> The programmer who uses
> the function (or module) should be the one who concerns himself with the
> "types" of variables that are passed.

Yes. But what if he doesn't? In Python I say, throw an exception. In Perl,
try to figure out what he meant.

-- 
Remco Gerlich,  scarblac@pino.selwerd.nl


From andre@beta.telenordia.se  Wed May 31 10:42:30 2000
From: andre@beta.telenordia.se (=?iso-8859-1?Q?Andr=E9_Dahlqvist?=)
Date: Wed, 31 May 2000 11:42:30 +0200
Subject: [Tutor] String searching
Message-ID: <20000531114230.A19852@beta.telenordia.se>

Hi everyone,

I'm trying to find out if a certain word in a string is a hyperlink, in
other words if it starts with http:// or ftp://. I've come up with a
way that works, but I think there must be some less uglier way of doing
this. Here's the solution I use now:

for word in string.split(text):
	if "http://" == word[0:7] or "ftp://" == word[0:6]
		do stuff with word...

The test itself is what I think is ugly, and I would have prefered to
use something like:

if "http://" or "ftp://" in string.split(text):
	get the whole word that matched...

But I don't know how to get this whole match. I would be greatful for
any advice.
-- 

// André

===================================================================
André Dahlqvist <andre@beta.telenordia.se>
GnuPG Key ID:	0x70A2994A
Fingerprint: 	E947 3297 331C CA30 5B88  EDF2 A830 3EBE 70A2 994A
===================================================================


From scarblac@pino.selwerd.nl  Wed May 31 11:43:04 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 31 May 2000 12:43:04 +0200
Subject: [Tutor] String searching
In-Reply-To: <20000531114230.A19852@beta.telenordia.se>; from andre@beta.telenordia.se on Wed, May 31, 2000 at 11:42:30AM +0200
References: <20000531114230.A19852@beta.telenordia.se>
Message-ID: <20000531124304.A7760@pino.selwerd.nl>

On Wed, May 31, 2000 at 11:42:30AM +0200, André Dahlqvist wrote:
> I'm trying to find out if a certain word in a string is a hyperlink, in
> other words if it starts with http:// or ftp://. I've come up with a
> way that works, but I think there must be some less uglier way of doing
> this. Here's the solution I use now:
> 
> for word in string.split(text):
> 	if "http://" == word[0:7] or "ftp://" == word[0:6]
> 		do stuff with word...
> 
> The test itself is what I think is ugly, and I would have prefered to
> use something like:
> 
> if "http://" or "ftp://" in string.split(text):
> 	get the whole word that matched...
> 
> But I don't know how to get this whole match. I would be greatful for
> any advice.

In Python 1.6, you will be able to use if word.startswith("http://"): ...
That would look a bit nicer, but isn't available yet.

Otherwise your current solution is probably the easiest for this case.

If you want to make it more generic, you could do something like

   i = string.find(word, '://')
   if i >= 0 and word[:i] in 'http','https','ftp','telnet','mailto','news':
      do stuff with word...
	  
There are actually a lot more types of URIs and they don't all use '://',
but this sort of thing is good enough for most purposes, I suppose :)

-- 
Remco Gerlich,  scarblac@pino.selwerd.nl


From andre@beta.telenordia.se  Wed May 31 12:31:06 2000
From: andre@beta.telenordia.se (=?iso-8859-1?Q?Andr=E9_Dahlqvist?=)
Date: Wed, 31 May 2000 13:31:06 +0200
Subject: [Tutor] String searching
Message-ID: <20000531133106.C20470@beta.telenordia.se>

> In Python 1.6, you will be able to use if word.startswith("http://"): ...
> That would look a bit nicer, but isn't available yet.

That would be nice indeed. And even after Python 1.6 is out I can't
really expect people to have the latest python interpreter installed.
Or is it showhow backwards compatible?

> There are actually a lot more types of URIs and they don't all use '://',
> but this sort of thing is good enough for most purposes, I suppose :)

Actually for my needs ftp:// and http:// will do, the rest of them are
very unlikely to show up.

Thanks for the tips!
-- 

// André


From craig@osa.att.ne.jp  Wed May 31 12:53:18 2000
From: craig@osa.att.ne.jp (Craig Hagerman)
Date: Wed, 31 May 2000 20:53:18 +0900
Subject: [Tutor] String searching
In-Reply-To: <20000531114230.A19852@beta.telenordia.se>
Message-ID: <v03102701b55aa9dc8bf2@[165.76.248.191]>

Hi Andr,

$B;*(J always think of regular expressions first for this kind of problem
instead of string methods. How about something like:

import re
isHyperlink = re.compile('(http|ftp)://["\'](.*?) ["\']',re.IGNORECASE)

for word in text.readlines():
	if isHyperlink.search(word):
		do stuff with word

You can use this regex to find a hyperlink AND extract the URL:
isHyperlink.search(word).group(2)

I haven't used re.findall() before but I *think* that you can also do this:

import re
for isHyperlink.findall(text):
	do stuff with word


>Hi everyone,
>
>I'm trying to find out if a certain word in a string is a hyperlink, in
>other words if it starts with http:// or ftp://. I've come up with a
>way that works, but I think there must be some less uglier way of doing
>this. Here's the solution I use now:
>
>for word in string.split(text):
>	if "http://" == word[0:7] or "ftp://" == word[0:6]
>		do stuff with word...
>
>The test itself is what I think is ugly, and I would have prefered to
>use something like:
>
>if "http://" or "ftp://" in string.split(text):
>	get the whole word that matched...
>
>But I don't know how to get this whole match. I would be greatful for
>any advice.






From emile@fenx.com  Wed May 31 13:48:07 2000
From: emile@fenx.com (Emile van Sebille)
Date: Wed, 31 May 2000 05:48:07 -0700
Subject: [Tutor] best practice
References: <Pine.GSO.4.10.10005302302010.2746-100000@isis.visi.com>
Message-ID: <018801bfcafe$7e588e60$1906a8c0@fc.fenx.com>

I always convert immediately upon input.

Emile van Sebille
emile@fenx.com
-------------------


----- Original Message -----
From: Timothy Wilson <wilson@visi.com>
To: <tutor@python.org>
Sent: Tuesday, May 30, 2000 9:13 PM
Subject: [Tutor] best practice


> Hi everyone,
>
> Thanks for all of the suggestions with my little prime number program.
As
> several people pointed out, the problem was that raw_input gets a
string
> which sqrt() chokes on. In the interpreter, all it well because the
function
> gets called directly with an integer. OK, problem solved.
>
> That brings up another very picky question though. Where should I
handle
> these type difficulties? Here's another little program I was playing
around
> with that takes an integer and returns a list of the integer's
factors. The
> algorithm is crude, but effective.
>
> wilson@beethoven modules]$ cat factor.py
> # This function factors an integer and returns a list
>
> from math import *
>
> def factor(number):
> factors = [1, int(number)]
> for i in range(2, sqrt(number) + 1):
> if number % i == 0:
> factors.append(i)
> if i != number/i:   # catch duplicates
> factors.append(int(number/i))
> factors.sort()
> return factors
>
> if __name__ == '__main__':
> number = raw_input("Factor what? ")
> print factor(float(number))
>
> As you can see, I convert the raw_input to a float before passing it
to the
> function. Also, I have a couple of int() functions in my factor
function to
> make sure that the list which is returned is a list of integers.
**When run
> from the interpreter, those int()s aren't needed.**
>
> So here's the question (it's about time :-). Is it better python
practice to
> make those type conversion outside the function or inside as I've
done?
> Should the functions be made as "pure" as possible? It seems to me
that for
> maximum efficiency, a rule of thumb should be that functions should be
made
> to work in the interpreter with a minimum of fuss. The programmer who
uses
> the function (or module) should be the one who concerns himself with
the
> "types" of variables that are passed.
>
> Does this make any sense? (I've been grading 10-page research papers
from
> 9th graders for the last couple hours. It can cause your head to
swim.)
>
> -Tim
>
> --
> Tim Wilson      | Visit Sibley online:         | Check out:
> Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
> W. St. Paul, MN |                              | http://slashdot.org/
> wilson@visi.com |   <dtml-var pithy_quote>     | http://linux.com/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>



From emile@fenx.com  Wed May 31 13:56:30 2000
From: emile@fenx.com (Emile van Sebille)
Date: Wed, 31 May 2000 05:56:30 -0700
Subject: [Tutor] String searching
References: <20000531114230.A19852@beta.telenordia.se>
Message-ID: <019a01bfcaff$aac87b80$1906a8c0@fc.fenx.com>

>>> word = "http://www.fenx.com"
>>> import string
>>> if string.split(word,'://')[0] in ('http','ftp'):
 print word , ' is a url.

or, in 1.6:

>>> if word.split('://')[0] in ('http','ftp'):
 print word,'is a url'


Emile van Sebille
emile@fenx.com
-------------------


----- Original Message -----
From: André Dahlqvist <andre@beta.telenordia.se>
To: Python Tutor Mailing List <tutor@python.org>
Sent: Wednesday, May 31, 2000 2:42 AM
Subject: [Tutor] String searching


> Hi everyone,
>
> I'm trying to find out if a certain word in a string is a hyperlink,
in
> other words if it starts with http:// or ftp://. I've come up with a
> way that works, but I think there must be some less uglier way of
doing
> this. Here's the solution I use now:
>
> for word in string.split(text):
> if "http://" == word[0:7] or "ftp://" == word[0:6]
> do stuff with word...
>
> The test itself is what I think is ugly, and I would have prefered to
> use something like:
>
> if "http://" or "ftp://" in string.split(text):
> get the whole word that matched...
>
> But I don't know how to get this whole match. I would be greatful for
> any advice.
> --
>
> // André
>
> ===================================================================
> André Dahlqvist <andre@beta.telenordia.se>
> GnuPG Key ID: 0x70A2994A
> Fingerprint: E947 3297 331C CA30 5B88  EDF2 A830 3EBE 70A2 994A
> ===================================================================
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>



From scarblac@pino.selwerd.nl  Wed May 31 14:13:07 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 31 May 2000 15:13:07 +0200
Subject: [Tutor] String searching
In-Reply-To: <019a01bfcaff$aac87b80$1906a8c0@fc.fenx.com>; from emile@fenx.com on Wed, May 31, 2000 at 05:56:30AM -0700
References: <20000531114230.A19852@beta.telenordia.se> <019a01bfcaff$aac87b80$1906a8c0@fc.fenx.com>
Message-ID: <20000531151307.A7904@pino.selwerd.nl>

On Wed, May 31, 2000 at 05:56:30AM -0700, Emile van Sebille wrote:
> >>> word = "http://www.fenx.com"
> >>> import string
> >>> if string.split(word,'://')[0] in ('http','ftp'):
>  print word , ' is a url.
> 
> or, in 1.6:
> 
> >>> if word.split('://')[0] in ('http','ftp'):
>  print word,'is a url'

This fails on the words 'http' and 'ftp'.

-- 
Remco Gerlich,  scarblac@pino.selwerd.nl


From emile@fenx.com  Wed May 31 14:31:00 2000
From: emile@fenx.com (Emile van Sebille)
Date: Wed, 31 May 2000 06:31:00 -0700
Subject: [Tutor] String searching
References: <20000531114230.A19852@beta.telenordia.se> <019a01bfcaff$aac87b80$1906a8c0@fc.fenx.com> <20000531151307.A7904@pino.selwerd.nl>
Message-ID: <023201bfcb04$7c4270e0$1906a8c0@fc.fenx.com>

Good point.  I knew the [0] reference would always 
be there, and hadn't considered a simple reference 
to the protocol name.  

Emile van Sebille
emile@fenx.com
-------------------


----- Original Message ----- 
From: Remco Gerlich <scarblac@pino.selwerd.nl>
To: <tutor@python.org>
Sent: Wednesday, May 31, 2000 6:13 AM
Subject: Re: [Tutor] String searching


> On Wed, May 31, 2000 at 05:56:30AM -0700, Emile van Sebille wrote:
> > >>> word = "http://www.fenx.com"
> > >>> import string
> > >>> if string.split(word,'://')[0] in ('http','ftp'):
> >  print word , ' is a url.
> > 
> > or, in 1.6:
> > 
> > >>> if word.split('://')[0] in ('http','ftp'):
> >  print word,'is a url'
> 
> This fails on the words 'http' and 'ftp'.
> 
> -- 
> Remco Gerlich,  scarblac@pino.selwerd.nl
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 



From arcege@shore.net  Wed May 31 17:12:14 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Wed, 31 May 2000 12:12:14 -0400 (EDT)
Subject: [Tutor] best practice
In-Reply-To: <Pine.GSO.4.10.10005302302010.2746-100000@isis.visi.com> from "Timothy Wilson" at May 30, 2000 11:13:49 PM
Message-ID: <200005311612.MAA24768@northshore.shore.net>

> 
> Hi everyone,
> 
> Thanks for all of the suggestions with my little prime number program. As
> several people pointed out, the problem was that raw_input gets a string
> which sqrt() chokes on. In the interpreter, all it well because the function
> gets called directly with an integer. OK, problem solved.
> 
> That brings up another very picky question though. Where should I handle
> these type difficulties? Here's another little program I was playing around
> with that takes an integer and returns a list of the integer's factors. The
> algorithm is crude, but effective.
> 
[code fragment snipped]
> 
> As you can see, I convert the raw_input to a float before passing it to the
> function. Also, I have a couple of int() functions in my factor function to
> make sure that the list which is returned is a list of integers. **When run
> from the interpreter, those int()s aren't needed.**
> 
> So here's the question (it's about time :-). Is it better python practice to
> make those type conversion outside the function or inside as I've done?
> Should the functions be made as "pure" as possible? It seems to me that for
> maximum efficiency, a rule of thumb should be that functions should be made
> to work in the interpreter with a minimum of fuss. The programmer who uses
> the function (or module) should be the one who concerns himself with the
> "types" of variables that are passed.

Myself, I have two different idioms I use depending on what the point
is:

1.  Do I want to deal with conversion of the data on input;  for
example, taking an IP address, the input could be an integer, a class
instance (representing an IP address), a string with the hostname, or
it could be a sequence of four integers (result of `map(int,
string.split(f, '.'))').

Here I generally deal with the conversion to some base type:
class IPaddr:
  def __init__(self, arg):
    if isinstance(arg, types.IntType):
      f = []
      while arg:
        v, arg = (arg & 0xff), (arg >> 8) & 0x00ffffff
        f.insert(0, v)
      del f[:-4]  # take only the last for
      for i in range(len(f), 4):
        f.insert(0, 0)
      arg = tuple(f)
    elif isinstance(arg, IPaddr):
      arg = arg.value
    elif isinstance(arg, types.StringType):
      while 1:
        try:
          f = map(int, string.split(arg, '.'))
        except ValueError:  # dotted hostname
          from socket import gethostbyname
          arg = gethostbyname(arg)
        else:
          break
      arg = tuple(f)
    else:
      raise TypeError('could not convert "%s" to a base type' %
                      type(arg).__name__)

This gives me a lot of flexibility.

2>  I want the function to be simple, taking set input and only that.

The second is easier, just raise a TypeError exception.  Something
like:

class Foo:
  def __init__(self, arg):
    if not isinstance(arg, types.IntType):
      raise TypeError("invalid type; expected int, got %s" %
                      type(arg).__name__)

The choice depends a lot of your function and the application.

  -Arcege

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


From borgulya@pons.sote.hu  Wed May 31 20:48:21 2000
From: borgulya@pons.sote.hu (Borgulya Gabor)
Date: Wed, 31 May 2000 21:48:21 +0200 (CEST)
Subject: [Tutor] printing variable name and value?
In-Reply-To: <069101bfc998$0d0e0da0$1906a8c0@fc.fenx.com>
Message-ID: <Pine.LNX.3.96.1000531213452.3901B-100000@Pons.sote.hu>

Hello,

I have found a working, but unstable solution for my own question:

import traceback
def prvar(__x):
    print traceback.extract_stack(limit=2)[0][3][6:][:-1],"=",__x

Lets's test it:

a=5; b=3
prvar(a)
prvar(a+b)
for i in range(10,8,-1):
    prvar(i)

The output:

a = 5
a+b = 8
i = 10
i = 9

It works, and I am going to use it for testing my scripts. But in many
cases this method will fail:
prvar (a)         #  because there is a space between prvar and the '('
(prvar(a))        #  such problems could be solved by cleverer search
                  #    for the parameter in the traceback string
prvar(a);prvar(b) #  would confuse the cleverer algorithms too

Unfortunately, the outcome is unpredictable when running the script from
IDLE. I don't understand, why.

Yours,

Gabor



From scarblac@pino.selwerd.nl  Wed May 31 21:20:04 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 31 May 2000 22:20:04 +0200
Subject: [Tutor] printing variable name and value?
In-Reply-To: <Pine.LNX.3.96.1000531213452.3901B-100000@Pons.sote.hu>; from borgulya@pons.sote.hu on Wed, May 31, 2000 at 09:48:21PM +0200
References: <069101bfc998$0d0e0da0$1906a8c0@fc.fenx.com> <Pine.LNX.3.96.1000531213452.3901B-100000@Pons.sote.hu>
Message-ID: <20000531222004.A9162@pino.selwerd.nl>

On Wed, May 31, 2000 at 09:48:21PM +0200, Borgulya Gabor wrote:
> I have found a working, but unstable solution for my own question:
> 
> import traceback
> def prvar(__x):
>     print traceback.extract_stack(limit=2)[0][3][6:][:-1],"=",__x

How horrific. I can't really think of another way either. I like it.

Are you sure you don't just want to do "prvar('x',x)"? :)

-- 
Remco Gerlich,  scarblac@pino.selwerd.nl