From deng@ms.shlftdc.net.cn  Fri Sep  1 02:30:17 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Fri, 1 Sep 2000 9:30:17 +0800
Subject: [Tutor] Q?
Message-ID: <20000901004023093.AAA259.316@wd>

tutorHello:
  The Python said this is wrong.But I think it's right.Why?

	# The while practice:
	a=['hello','world','i','am','a','worker']
	i=0
	while i<len(a):
		b[i]=a[len(a)-i]
		i=i+1
	print b


                  

            DengWei
            deng@ms.shlftdc.net.cn



From deng@ms.shlftdc.net.cn  Fri Sep  1 03:40:32 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Fri, 1 Sep 2000 10:40:32 +0800
Subject: [Tutor] (no subject)
Message-ID: <20000901015039109.AAA259.386@wd>

Hello All:
  If I want to duplicate a list,how should I do?
  I had tried,for example:
  
  a=['Hello','world']
  b=a
  
  but obviously it's not right.
  
  Anyone knows? Thanks!


                  

            DengWei
            deng@ms.shlftdc.net.cn



From rsmaker@bom7.vsnl.net.in  Fri Sep  1 05:39:29 2000
From: rsmaker@bom7.vsnl.net.in (Rishi Maker)
Date: Fri, 1 Sep 2000 10:09:29 +0530
Subject: [Tutor] Q?
In-Reply-To: <20000901004023093.AAA259.316@wd>; from deng@ms.shlftdc.net.cn on Fri, Sep 01, 2000 at 09:30:17AM +0800
References: <20000901004023093.AAA259.316@wd>
Message-ID: <20000901100929.A1318@bom7.vsnl.net.in>

--y0ulUmNC+osPPQO6
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

This does not work for various reason .. Look at this script , you should f=
igure out why.
        # The while practice:
a=3D['hello','world','i','am','a','worker']
print a
i=3D0
x=3Dlen(a)-1
b=3D[]
while i<len(a):
        b.insert(i,a[x-i])
        i=3Di+1
print b



And Then  deng wei wrote .............=20
=20
> tutorHello:
>   The Python said this is wrong.But I think it's right.Why?
>=20
> 	# The while practice:
> 	a=3D['hello','world','i','am','a','worker']
> 	i=3D0
> 	while i<len(a):
> 		b[i]=3Da[len(a)-i]
> 		i=3Di+1
> 	print b
>=20
>=20
>                  =20
>=20
>             DengWei
>             deng@ms.shlftdc.net.cn
>=20
>=20
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

--=20
---------------------------------------------------------------------------=
----
Signature Follows :-

Rishi Maker			|------------Quote Of The Mail----------------|
Web Developer			|The church saves sinners, but science seeks  |=09
rishim@cyberspace.org		|to stop their manufacture.   -- Elbert       |
Tel : 91-22-5374892		|Hubbard                                      |
ICQ UIN :-56551784		|                                             |
---------------------------------------------------------------------------=
----
----------------The Following has been stolen from fortune cookies---------=
----
---------------------------------------------------------------------------=
----
	| ----:----:----:-----:----:----:----:----:----:----:----:----:|
--------|	guru, n:  A computer owner who can read the manual.    |-------=
=09
	| ----:----:----:-----:----:----:----:----:----:----:----:----:|
---------------------------------------------------------------------------=
----
    if (argc > 1 && strcmp(argv[1], "-advice") =3D=3D 0) {
	printf("Don't Panic!\n");
	exit(42);
    }
(Arnold Robbins in the LJ of February '95, describing RCS)
---------------------------------------------------------------------------=
----
We are using Linux daily to UP our productivity - so UP yours!
(Adapted from Pat Paulsen by Joe Sloan)
---------------------------------------------------------------------------=
----
`When you say "I wrote a program that crashed Windows", people just stare at
you blankly and say "Hey, I got those with the system, *for free*".'
(By Linus Torvalds)
---------------------------------------------------------------------------=
----
			Copyleft --:- =AE=D8=A7h=EC M=E5k=EBr -:--
---------------------------------------------------------------------------=
----

--y0ulUmNC+osPPQO6
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: BkAtZlMcBXnBJJJ0CW/tQsS2NXGJzEyn

iQA/AwUBOa8zAMjbonC6FpvoEQKUjQCeL+63BE0IPOiHxz/b0/pb4v3VB2AAoIFF
3Rx4coXna78h+kVf2TLPjj9C
=w544
-----END PGP SIGNATURE-----

--y0ulUmNC+osPPQO6--


From dyoo@hkn.EECS.Berkeley.EDU  Fri Sep  1 05:23:33 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Thu, 31 Aug 2000 21:23:33 -0700 (PDT)
Subject: [Tutor] Q?
In-Reply-To: <20000901004023093.AAA259.316@wd>
Message-ID: <Pine.LNX.4.21.0008311913570.26898-100000@hkn.EECS.Berkeley.EDU>

On Fri, 1 Sep 2000, deng wei wrote:

>   The Python said this is wrong.But I think it's right.Why?
> 
> 	# The while practice:
> 	a=['hello','world','i','am','a','worker']
> 	i=0
> 	while i<len(a):
> 		b[i]=a[len(a)-i]
> 		i=i+1
> 	print b

I'm guessing that this piece of code reverses the order of list 'a', and
places it into list 'b'.  This would work, except that we haven't sized
'b' yet as a new list.  Try it on the interpreter:

###
>>> a = ['hello', 'world', 'i', 'am', 'a', 'worker']
>>> i = 0
>>> while i < len(a):
...     b[i] = a[len(a) - i]
...     i = i + 1
... 
Traceback (innermost last):
  File "<stdin>", line 2, in ?
IndexError: list index out of range
###

To fix this, we need to properly set b to a list of equal size to
a.  Here's one quick way of doing it:

###
>>> b = list(range(len(a)))
>>> b
[0, 1, 2, 3, 4, 5]
###


I create a tuple 'b' of size 'len(a)', and convert it to a list, so that
we can change elements of b.  Afterwards, we should be ok:

###
>>> i = 0
>>> while i < len(a):
...     b[i] = a[len(a) - i]
...     i = i + 1
... 
Traceback (innermost last):
  File "<stdin>", line 2, in ?
IndexError: list index out of range
###


Hmm... I spoke too soon!  Let's think about this.  When i=0, then we try
to execute:

    b[i] = a[5 - 0]


Ah!  That's off the list!  We can read from a[0], a[1], a[2], ..., a[4],
but not a[5].  This is why we're getting the IndexError.

The solution is to subtract 1 from the offset.  If we do this, then the
loop will go through through b[4], b[3], ..., b[0].

###
    b[i] = a[len(a) - i - 1]
###

should be the corrected line.
    



From rsmaker@bom7.vsnl.net.in  Fri Sep  1 06:08:17 2000
From: rsmaker@bom7.vsnl.net.in (Rishi Maker)
Date: Fri, 1 Sep 2000 10:38:17 +0530
Subject: [Tutor] Q? One additional query
In-Reply-To: <20000901100929.A1318@bom7.vsnl.net.in>; from rsmaker@bom7.vsnl.net.in on Fri, Sep 01, 2000 at 10:09:29AM +0530
References: <20000901004023093.AAA259.316@wd> <20000901100929.A1318@bom7.vsnl.net.in>
Message-ID: <20000901103817.A1569@bom7.vsnl.net.in>

This is a reply of my own mail
Some one just wrote a script in which b is initialized
b = list(range(len(a)))
I guess My script will be much slower than his script as memory has to be allocated at each loop
Just a point

 a=['hello','world','i','am','a','worker']
 print a
 i=0
 x=len(a)-1
 b=[]
 while i<len(a):
         b.insert(i,a[x-i])
         i=i+1
 print b
####Correction  
  a=['hello','world','i','am','a','worker']
 print a
 i=0
 x=len(a)-1
 b=list(range(len(a)))
 while i<len(a):
         b[i]=a[x-i]
         i=i+1
 print b

> 
> And Then  deng wei wrote ............. 
>  
> > tutorHello:
> >   The Python said this is wrong.But I think it's right.Why?
> > 
> > 	# The while practice:
> > 	a=['hello','world','i','am','a','worker']
> > 	i=0
> > 	while i<len(a):
> > 		b[i]=a[len(a)-i]
> > 		i=i+1
> > 	print b
> > 
> > 
> >                   
> > 
> >             DengWei
> >             deng@ms.shlftdc.net.cn
> > 
> > 
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://www.python.org/mailman/listinfo/tutor
> 
> -- 
> -------------------------------------------------------------------------------
> Signature Follows :-
> 
> Rishi Maker			|------------Quote Of The Mail----------------|
> Web Developer			|The church saves sinners, but science seeks  |	
> rishim@cyberspace.org		|to stop their manufacture.   -- Elbert       |
> Tel : 91-22-5374892		|Hubbard                                      |
> ICQ UIN :-56551784		|                                             |
> -------------------------------------------------------------------------------
> ----------------The Following has been stolen from fortune cookies-------------
> -------------------------------------------------------------------------------
> 	| ----:----:----:-----:----:----:----:----:----:----:----:----:|
> --------|	guru, n:  A computer owner who can read the manual.    |-------	
> 	| ----:----:----:-----:----:----:----:----:----:----:----:----:|
> -------------------------------------------------------------------------------
>     if (argc > 1 && strcmp(argv[1], "-advice") == 0) {
> 	printf("Don't Panic!\n");
> 	exit(42);
>     }
> (Arnold Robbins in the LJ of February '95, describing RCS)
> -------------------------------------------------------------------------------
> We are using Linux daily to UP our productivity - so UP yours!
> (Adapted from Pat Paulsen by Joe Sloan)
> -------------------------------------------------------------------------------
> `When you say "I wrote a program that crashed Windows", people just stare at
> you blankly and say "Hey, I got those with the system, *for free*".'
> (By Linus Torvalds)
> -------------------------------------------------------------------------------
> 			Copyleft --:- ®Ø§hì Måkër -:--
> -------------------------------------------------------------------------------



-- 
-------------------------------------------------------------------------------
Signature Follows :-

Rishi Maker			|------------Quote Of The Mail----------------|
Web Developer			|I have a hard time being attracted to anyone |	
rishim@cyberspace.org		|who can beat me up.   -- John McGrath,       |
Tel : 91-22-5374892		|Atlanta sportswriter, on women weightlifters.|
ICQ UIN :-56551784		|                                             |
-------------------------------------------------------------------------------
----------------The Following has been stolen from fortune cookies-------------
-------------------------------------------------------------------------------
	| ----:----:----:-----:----:----:----:----:----:----:----:----:|
--------|	guru, n:  A computer owner who can read the manual.    |-------	
	| ----:----:----:-----:----:----:----:----:----:----:----:----:|
-------------------------------------------------------------------------------
    if (argc > 1 && strcmp(argv[1], "-advice") == 0) {
	printf("Don't Panic!\n");
	exit(42);
    }
(Arnold Robbins in the LJ of February '95, describing RCS)
-------------------------------------------------------------------------------
We are using Linux daily to UP our productivity - so UP yours!
(Adapted from Pat Paulsen by Joe Sloan)
-------------------------------------------------------------------------------
`When you say "I wrote a program that crashed Windows", people just stare at
you blankly and say "Hey, I got those with the system, *for free*".'
(By Linus Torvalds)
-------------------------------------------------------------------------------
			Copyleft --:- ®Ø§hì Måkër -:--
-------------------------------------------------------------------------------


From dyoo@hkn.EECS.Berkeley.EDU  Fri Sep  1 09:39:20 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Fri, 1 Sep 2000 01:39:20 -0700 (PDT)
Subject: [Tutor] (no subject)
In-Reply-To: <20000901015039109.AAA259.386@wd>
Message-ID: <Pine.LNX.4.21.0008312133230.29849-100000@hkn.EECS.Berkeley.EDU>

On Fri, 1 Sep 2000, deng wei wrote:

> Hello All:
>   If I want to duplicate a list,how should I do?
>   I had tried,for example:
>   
>   a=['Hello','world']
>   b=a
>   
>   but obviously it's not right.
>   
>   Anyone knows? Thanks!


The quick answer is:

   b = a[:]

which will make a shallow copy of the list.  What this does is take a
slice of all of 'a'.  A better answer would be to use the 'copy' module,
which will make "deep" copies:

###
import copy
b = copy.deepcopy(a)
###

which guarantees that b has a completely separate copy of whatever 'a'
contained.


Here's a slightly more detailed explanation of what's happening: For the
immutable types (strings, tuples, numbers), you usually don't have to
worry about copying stuff.

###
>>> a = 42
>>> b = a
>>> b = 24
>>> a,b
(42, 24)
###

does what you expect.  Since these things don't change, it's fine when
they share the same thing.  This is, in fact, what's happening --- it's
sharing.  Here's a diagram of what it looks like in your computer after 
'b = a':

 |-|
 |a|----------|
 |-|          |      |--|
              |----> |42|
 |-|          |      |--|
 |b| ---------|
 |-|


However, since lists are "mutable", that is, modifiable, this rule causes
difficulties, as you noticed, if you're making changes to the shared
thing.

>>> a = ['hello', 'world']
>>> b = a
>>> a[0] = 'goodbye' 
>>> a
['goodbye', 'world']
>>> b
['goodbye', 'world']


Diagrammically, this looks like:

 |-|
 |a|----------|
 |-|          |      |----------------------|
              |----->| ['goodbye', 'world'] |
 |-|          |      |----------------------|
 |b| ---------|
 |-|


As explained above, the way to fix this is to give 'b' an independent copy
of the list:


>>> a = ['hello', 'world']
>>> import copy
>>> b = copy.deepcopy(a)
>>> a[0] = 'goodbye'
>>> a
['goodbye', 'world']
>>> b
['hello', 'world']

By using the [:] slice, or the copy.deepcopy() function, we'll get this
picture instead:

 |-|          |----------------------|
 |a|--------->| ['goodbye', 'world'] |
 |-|          |----------------------|


 |-|          |--------------------|
 |b|--------->| ['hello', 'world'] |
 |-|          |--------------------|

which does the thing you expect for your particular program.  Usually,
sharing is fine, but there are cases when you want to explicitly copy
stuff.

I hope this makes things clearer, even if the ASCII is a bit ugly...  
*grin*



From arcege@shore.net  Fri Sep  1 12:25:59 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Fri, 1 Sep 2000 07:25:59 -0400 (EDT)
Subject: [Tutor] Q? One additional query
In-Reply-To: <20000901103817.A1569@bom7.vsnl.net.in> from "Rishi Maker" at Sep 01, 2000 10:38:17 AM
Message-ID: <200009011125.HAA27872@northshore.shore.net>

> This is a reply of my own mail
> Some one just wrote a script in which b is initialized
> b = list(range(len(a)))
> I guess My script will be much slower than his script as memory has to be allocated at each loop
> Just a point

If you are going to reverse a sequence, then I suggest copying the
sequence and then reversing the resulting list.

>>> a = ('hello', 'world', 'i', 'am', 'a', 'worker')
>>> b = list(a)  # a could be a tuple or even a string, so do not use `[:]'
>>> b.reverse()
>>> print b

If you are looking for how to perform this manually in Python (without
using the reverse method), loop and insert at index zero.

>>> a = ['hello', 'world', 'i', 'am', 'a', 'worker']
>>> b = []
>>> for item in a:
...   b.insert(0, item)
...
>>> print b

In terms of the memory, the same amount of memory is to be allocated so
there is no real performance hit except with large lists (realloc on
many systems is fairly efficient).  But this is also why using the
list().reverse() idiom is more efficient.

  -Arcege

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


From deng@ms.shlftdc.net.cn  Sat Sep  2 11:41:29 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Sat, 2 Sep 2000 18:41:29 +0800
Subject: [Tutor] (no subject)
Message-ID: <20000901095139593.AAA301.419@192>

Hi,all:
   There is a mistake in the Python Manuals at "5.3 Tuples and Sequences".It said:
	a tuple with one item is constructed by following a value with a comma (it is not sufficient to enclose a single value in parentheses).  
   

   but if you type:
>>> b=('hello')
>>> b
'hello'
   
  No problem!?
  
  Am I right?


                  

            DengWei
            deng@ms.shlftdc.net.cn



From deng@ms.shlftdc.net.cn  Sat Sep  2 12:43:12 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Sat, 2 Sep 2000 19:43:12 +0800
Subject: [Tutor] Fw:
Message-ID: <20000901105322921.AAA301.350@192>

=C4=FA=BA=C3=A3=A1

*******=CF=C2=C3=E6=CA=C7=D7=AA=B7=A2=B5=C4=D3=CA=BC=FE*****
Hi,dyoo:
  I think the answer is not quite right.
  For example :
  When sum=3D99,then next loop.and maybe I input 199,therefore=
 sum=3D99+199>100.
  I think it should be added a *if* statement:
  ###
  sum =3D 0
  while sum < 100:
      print "Sum so far:", sum
      number =3D input("Please enter a number: ")
      sum =3D sum + number
  if sum>100:
      print "your number is exceeded 100."
  ###
  By the way:
  Your comments about how to program is helpful to me .Thank You=
 very much.

    



                  

            Sheng
            deng@ms.shlftdc.net.cn
*****=D7=AA=B7=A2=C4=DA=C8=DD=BD=E1=CA=F8*****



                    =D6=C2
=C0=F1=A3=A1

            DengWei
            deng@ms.shlftdc.net.cn



From insyte@emt-p.org  Fri Sep  1 16:32:07 2000
From: insyte@emt-p.org (Ben Beuchler)
Date: Fri, 1 Sep 2000 10:32:07 -0500
Subject: [Tutor] (no subject)
In-Reply-To: <20000901095139593.AAA301.419@192>; from deng@ms.shlftdc.net.cn on Sat, Sep 02, 2000 at 06:41:29PM +0800
References: <20000901095139593.AAA301.419@192>
Message-ID: <20000901103204.A11705@emt-p.org>

On Sat, Sep 02, 2000 at 06:41:29PM +0800, deng wei wrote:

> Hi,all:
>    There is a mistake in the Python Manuals at "5.3 Tuples and Sequences".It said:
> 	a tuple with one item is constructed by following a value with a comma (it is not sufficient to enclose a single value in parentheses).  
>    
> 
>    but if you type:
> >>> b=('hello')
> >>> b
> 'hello'
>    
>   No problem!?
>   
>   Am I right?

Nope.

>>> b=('hello')
>>> type(b)
<type 'string'>
>>> 
>>> b=('hello',)
>>> type(b)
<type 'tuple'>

Ben

-- 
Ben Beuchler                                         insyte@bitstream.net
MAILER-DAEMON                                         (612) 321-9290 x101
Bitstream Underground                                   www.bitstream.net


From gwperry@tva.gov  Fri Sep  1 18:33:46 2000
From: gwperry@tva.gov (Perry, George W.)
Date: Fri, 1 Sep 2000 13:33:46 -0400
Subject: [Tutor] First OOP Attempt
Message-ID: <2DACABE127B3D1119FC40000F8014EFC0184C799@chachaois4.cha.tva.gov>

The following appears to work, but I just now learning about OOP concepts,
and I was wondering if there is anything  that is obviously wrong or poor
technique. Comments would be appreciated.

Thanks
George Perry

"""
Apartments can have 0 or 1 persons as occupants.
Persons may move to an empty apartment but not to an occupied apartment.
Persons may have 0 or 1 pets.
Persons may give their pet to another person who has no pet.
"""

import sys
class Apt:
   def __init__(self,address=None,name=None):
      self.addr = address
      self.occ  = name
      if address != None: dicApt[address] = self

class Person:
   def __init__(self,name=None,addr=None,pet=None):
      self.name = name
      self.addr = addr
      self.petname  = pet
      if name != None: dicPer[name] = self

   def moveFrom(self):
      a1 = dicApt[self.addr]
      if a1.occ != self.name :
         print "Bug1 %s != %s"  % (a1.occ,self.name)
         sys.exit()
      print "%s moving from %s."  %  (self.name,self.addr)
      a1.occ = None     # apartment is now empty
      self.addr = None  # person is temporarily homeless

   def moveTo(self,dest):
      a1 = dicApt[dest]
      if a1.occ != None:
         print "%s moving  to  %s. Occupied by %s"  %
(self.name,a1.addr,a1.occ)
         sys.exit()
      a1.occ = self.name
      self.addr = a1.addr
      print "%s moved  to  %s."  %  (self.name,self.addr)

   def moving(self,dest):
      self.moveFrom()
      self.moveTo(dest)

class Pet:
   def __init__(self,petname,owner=None):
      self.petname = petname
      self.owner = owner

   def givePet(self):
      p1 = dicPer[self.owner]
      if p1.name != self.owner :
         print "Bug2 %s != %s"  % (p1.name,self.owner)
         sys.exit()
      print "%s giving away %s."  %  (self.owner,self.petname)
      p1.petname = None      # owner now has no pet
      self.owner = None      # pet is temporarily ownerless

   def takePet(self,receiver):
      p1 = dicPer[receiver]
      print "%s being given to  %s. Now owns %s"  %
(self.petname,p1.name,p1.petname)
      if p1.petname != None:
         sys.exit()
      p1.petname = self.petname
      self.owner = p1.name
      print "%s taken by %s."  %  (self.petname,self.owner)

   def giving(self,receiver):
      self.givePet()
      self.takePet(receiver)

def newPerson(name,addr):
   p1 = Person(name,addr)
   a1 = Apt(addr,name)
   return (p1,a1)

def main():
   global dicPer, dicApt
   dicApt = {}                    # to lookup Apt instance given an
apartment address
   dicPer = {}                    # to lookup Person instance given a
person's name

   p1,a1 = newPerson("Pat","Az1")    # Create a person & apartment
   p1.pet = 'Doggy'                  # ...with a pet
   d1 = Pet('Doggy','Pat')

   a2 = Apt("Az2")                   # Create 2 empty apts
   a3 = Apt("Az3")

   p1.moving("Az2")            # Move Pat from Az1 to Az2
   p1.moving("Az3")            # Move Pat from Az2 to Az3
   p1.moving("Az1")            # Move Pat from Az3 to Az1

   p4,a4 = newPerson("Mikie","Az4")   # Create a person & apartment
#   p4.petname = 'Kitty'              # pgm exits if these are uncommented
#   d4 = Pet('Kitty','Mikie')
   d1.giving("Mikie")


   for apt in (a1,a2,a3,a4):
      print 'Apt',apt.addr,apt.occ,dicApt.has_key(apt.addr)
   for per in (p1,p4):
      print 'Per',per.name,per.addr,per.petname,dicPer.has_key(per.name)
   for pet in (d1,):
      print 'Pet',pet.petname,pet.owner

main()
 


From shaleh@valinux.com  Fri Sep  1 19:56:26 2000
From: shaleh@valinux.com (Sean 'Shaleh' Perry)
Date: Fri, 01 Sep 2000 11:56:26 -0700 (PDT)
Subject: [Tutor] First OOP Attempt
In-Reply-To: <2DACABE127B3D1119FC40000F8014EFC0184C799@chachaois4.cha.tva.gov>
Message-ID: <XFMail.20000901115626.shaleh@valinux.com>

On 01-Sep-2000 Perry, George W. wrote:
> The following appears to work, but I just now learning about OOP concepts,
> and I was wondering if there is anything  that is obviously wrong or poor
> technique. Comments would be appreciated.
> 

looks good for a first run

Now, to really use this, we modify it slighty.

> 
> main()
>  

becomes :

if __name__ == '__main__:
   main()

What this does is check that the script is being run as a script by the
interpreter, if so, run main().  By adding this check you can now do:

import Apartment # or whatever you call the foo.py script
dog = Apartment.pet('fifi')

and use the classes in other code.


From dyoo@hkn.EECS.Berkeley.EDU  Sat Sep  2 04:00:17 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Fri, 1 Sep 2000 20:00:17 -0700 (PDT)
Subject: [Tutor] (no subject)
In-Reply-To: <20000901095139593.AAA301.419@192>
Message-ID: <Pine.LNX.4.21.0009011950390.23759-100000@hkn.EECS.Berkeley.EDU>

On Sat, 2 Sep 2000, deng wei wrote:

>    There is a mistake in the Python Manuals at "5.3 Tuples and
> Sequences".It said:
> 	a tuple with one item is constructed by following a value with a
> comma (it is not sufficient to enclose a single value in parentheses).
>
>    but if you type:
> >>> b=('hello')
> >>> b
> 'hello'


Parenthesis have two separate meanings in Python.  For example,
parenthesis are used to group stuff and lead Python to do certain things
first:

###
>>> 5 - (4 - 3)
4
>>> (5 - 4) - 3
-2
###

This shows how parenthesis can be used to indicate "precedence", that is,
what should be done first in an expression.  The other use for parenthesis
is in creating tuples.

###
>>> x = ('hello', 'world')
>>> x
('hello', 'world')
###

Usually, these two usages don't conflict, except for the case when you
want to make a tuple of one element.  Because

    x = (5 + (4 - 3))

can be taken both ways by someone reading the code, we need to make it
perfectly clear to Python what we mean.  That's why we have the "comma at
the end" rule:

###
>>> (5 - (4 - 3))
4
>>> (5 - (4 - 3),)
(4,)
###


Hope this clears things up.



From dyoo@hkn.EECS.Berkeley.EDU  Sat Sep  2 04:12:29 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Fri, 1 Sep 2000 20:12:29 -0700 (PDT)
Subject: [Tutor] A timer of some sort.
In-Reply-To: <20.ae48cb6.26e028bf@aol.com>
Message-ID: <Pine.LNX.4.21.0009012009550.23759-100000@hkn.EECS.Berkeley.EDU>

On Thu, 31 Aug 2000 FxItAL@aol.com wrote:

> Hello, 
> Does anyone know of a timer or a timimg module that I can use to activate a 
> loop at 15 minute intervals? 


Yes, you'll probably want to look at the 'sched' module to do this:

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

I don't have experience with this module, but the documentation looks ok
enough to get something running.



From dyoo@hkn.EECS.Berkeley.EDU  Sat Sep  2 04:16:26 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Fri, 1 Sep 2000 20:16:26 -0700 (PDT)
Subject: [Tutor] Python
In-Reply-To: <MABBIDAPBFNPPAAODIJAKEBACAAA.poste_br@yahoo.com>
Message-ID: <Pine.LNX.4.21.0009012012350.23759-100000@hkn.EECS.Berkeley.EDU>

On Thu, 31 Aug 2000, Guilherme wrote:

> 	I would like to know if python can be used to program CGI
> scripts, and where can I find a good tutorial on python?

Hello!  You'll definitely want to look at the tutorials and introduction
section of the Python website --- it has exactly what you're looking for.

    http://www.python.org/topics/web/basic-cgi.html
    http://www.python.org/doc/Intros.html

Also, you might want to look at:

    http://www.faqts.com/knowledge-base/index.phtml/fid/199/

It's a Python FAQ respository, and has a lot of good information and
links.

If you have any questions, feel free to ask us again.  Good luck!



From rm1@student.cs.ucc.ie  Sat Sep  2 21:25:28 2000
From: rm1@student.cs.ucc.ie (Robert Moloney)
Date: Sat, 2 Sep 2000 21:25:28 +0100 (BST)
Subject: [Tutor] Shelve error
Message-ID: <Pine.OSF.3.96.1000902211954.20971B-100000@student.cs.ucc.ie>

I keep getting this error I think it might be to do with the size of the
file 

>>> sh = shelve.open("searchPhrase")
>>> sh.keys()
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python1.5/shelve.py", line 55, in keys
    return self.dict.keys()
bsddb.error: (22, 'Invalid argument')
>>> sh["http://rory.calhoone.ie/manual/sections.html"]           
['Help']
>>> 

I can access individual key values but it won't give me a list of keys

Please Help 

Rob 




From chris_esen@hotmail.com  Sun Sep  3 03:04:48 2000
From: chris_esen@hotmail.com (Chris Esen)
Date: Sun, 03 Sep 2000 02:04:48 GMT
Subject: [Tutor] Arrays
Message-ID: <F98eRoXaXgBDu9CEIeq00001529@hotmail.com>

Hey,

I just spent the last hour looking over some python tutorials and I have a 
question, how can I define an array of classes or any other data type? I 
don't think a list would work for me. Let me show you what i mean in c:

int myArray[5];

myArray[0] = 22;
...
myArray[4] = 2;

how can you do something similar in python? I've looked through the docs. 
and I guess I'm over looking something.

Thanks



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

Share information about yourself, create your own public profile at 
http://profiles.msn.com.



From poste_br@yahoo.com  Sun Sep  3 04:12:46 2000
From: poste_br@yahoo.com (Guilherme)
Date: Sun, 3 Sep 2000 00:12:46 -0300
Subject: [Tutor] Python CGI
Message-ID: <MABBIDAPBFNPPAAODIJAEEBGCAAA.poste_br@yahoo.com>

	I was looking at some host web sites that support CGI, and they all talk
about perl.
	I was wondering if I can use python on those instead of perl.
	Thanks!!!


	poste_br@yahoo.com


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


From dyoo@hkn.EECS.Berkeley.EDU  Sun Sep  3 08:41:03 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Sun, 3 Sep 2000 00:41:03 -0700 (PDT)
Subject: [Tutor] Arrays
In-Reply-To: <F98eRoXaXgBDu9CEIeq00001529@hotmail.com>
Message-ID: <Pine.LNX.4.21.0009030007540.10986-100000@hkn.EECS.Berkeley.EDU>

> question, how can I define an array of classes or any other data type? I 
> don't think a list would work for me. Let me show you what i mean in c:
> 
> int myArray[5];
> 
> myArray[0] = 22;
> ...
> myArray[4] = 2;


Yes, you can use Python's lists to do this.  The thing you have to do is
initialize the list to be long enough.  For example, you probably ran into
the problem of IndexError's popping up:


###
>>> myArray = []
>>> myArray[0] = 22
Traceback (innermost last):
  File "<stdin>", line 1, in ?
IndexError: list assignment index out of range
###


This is because 'myArray = []' doesn't quite capture the idea of 
'int myArray[5];'.  At the very least, we need our myArray to hold 5
elements.  This isn't too hard to fix, though.  Take a look:


###
>>> myArray = [0] * 5    # Initialize myArray to a list of 5 zeros
>>> myArray
[0, 0, 0, 0, 0]
>>> myArray[0] = 22
>>> myArray
[22, 0, 0, 0, 0]
###


I'm not sure if it's the Pythonic way of doing things; there may be a more
idiomatic way of sizing the list.  However, '[0] * length' seems to be
sufficient for many casual cases, and it's nicer because we can still do
things like append() or insert() with our lists.  Furthermore, the list is
still heterogeneous --- we can put numbers, or strings, or whatever we
want in that list, and it will still work.


###
>>> myArray[4] = ('Ruronin', 'Kenshin')
>>> myArray
[22, 0, 0, 0, ('Ruronin', 'Kenshin')]
###


If you really need efficient arrays, you might want to look at Numerical
Python, which is a module that's specialized for very fast and lightweight
arrays and matrices:

    http://numpy.sourceforge.net/


Good luck!



From shaleh@valinux.com  Sun Sep  3 08:42:54 2000
From: shaleh@valinux.com (Sean 'Shaleh' Perry)
Date: Sun, 3 Sep 2000 00:42:54 -0700
Subject: [Tutor] Arrays
In-Reply-To: <F98eRoXaXgBDu9CEIeq00001529@hotmail.com>; from chris_esen@hotmail.com on Sun, Sep 03, 2000 at 02:04:48AM +0000
References: <F98eRoXaXgBDu9CEIeq00001529@hotmail.com>
Message-ID: <20000903004254.C15561@valinux.com>

On Sun, Sep 03, 2000 at 02:04:48AM +0000, Chris Esen wrote:
> Hey,
> 
> I just spent the last hour looking over some python tutorials and I have a 
> question, how can I define an array of classes or any other data type? I 
> don't think a list would work for me. Let me show you what i mean in c:
> 
> int myArray[5];
> 
> myArray[0] = 22;
> ...
> myArray[4] = 2;
>

Python 1.5.2 (#0, Apr  3 2000, 14:46:48)  [GCC 2.95.2 20000313 (Debian GNU/Linux)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
.>>> # just like C way
.>>> myArray = [0,0,0,0,0]
.>>> myArray[0] = 22
.>>> myArray[4] = 2
.>>> print myArray
[22, 0, 0, 0, 2]
.>>> # python way
.>>> otherArray = [] # make an empty list
.>>> otherArray.append(22)
.>>> otherArray.append(0)
.>>> otherArray.append(0)
.>>> otherArray.append(0)
.>>> otherArray.append(2)
.>>> print otherArray
[22, 0, 0, 0, 2]


From shaleh@valinux.com  Sun Sep  3 08:45:50 2000
From: shaleh@valinux.com (Sean 'Shaleh' Perry)
Date: Sun, 3 Sep 2000 00:45:50 -0700
Subject: [Tutor] Python CGI
In-Reply-To: <MABBIDAPBFNPPAAODIJAEEBGCAAA.poste_br@yahoo.com>; from poste_br@yahoo.com on Sun, Sep 03, 2000 at 12:12:46AM -0300
References: <MABBIDAPBFNPPAAODIJAEEBGCAAA.poste_br@yahoo.com>
Message-ID: <20000903004550.D15561@valinux.com>

On Sun, Sep 03, 2000 at 12:12:46AM -0300, Guilherme wrote:
> 	I was looking at some host web sites that support CGI, and they all talk
> about perl.
> 	I was wondering if I can use python on those instead of perl.
> 	Thanks!!!
>

there is a python cgi module, 'import cgi', there is also a python apache
module.

For almost all cases, if you can do it in perl it can be done in python and
vice versa.  That is the point of a general purpose programming language -- you
can write arbitrary programs in it.  The difference is simply choice and
learning the idioms of the language.

As we tell every other new poster to the list, read www.python.org.  It has
tutorials, docs, other lists, etc.


From rsmaker@bom7.vsnl.net.in  Sun Sep  3 09:17:56 2000
From: rsmaker@bom7.vsnl.net.in (Rishi Maker)
Date: Sun, 3 Sep 2000 13:47:56 +0530
Subject: [Tutor] Python CGI
In-Reply-To: <MABBIDAPBFNPPAAODIJAEEBGCAAA.poste_br@yahoo.com>; from poste_br@yahoo.com on Sun, Sep 03, 2000 at 12:12:46AM -0300
References: <MABBIDAPBFNPPAAODIJAEEBGCAAA.poste_br@yahoo.com>
Message-ID: <20000903134756.A1842@bom7.vsnl.net.in>

Actually most of the CGi stuff we do these days is in python ....
read the cgi.py module...... There are scores of methods that would impress you


And Then  Guilherme wrote ............. 
 
> 	I was looking at some host web sites that support CGI, and they all talk
> about perl.
> 	I was wondering if I can use python on those instead of perl.
> 	Thanks!!!
> 
> 
> 	poste_br@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

-- 
-------------------------------------------------------------------------------
Signature Follows :-

Rishi Maker			|------------Quote Of The Mail----------------|
Senior Developer		|VICARIOUSLY experience some reason to LIVE!! |	
rishim@cyberspace.org		|                                             |
Tel : 91-22-5374892		|                                             |
ICQ UIN :-56551784		|                                             |
www.rishimaker.com		|                                             |
-------------------------------------------------------------------------------
----------------The Following has been stolen from fortune cookies-------------
-------------------------------------------------------------------------------
	| ----:----:----:-----:----:----:----:----:----:----:----:----:|
--------|	guru, n:  A computer owner who can read the manual.    |-------	
	| ----:----:----:-----:----:----:----:----:----:----:----:----:|
-------------------------------------------------------------------------------
    if (argc > 1 && strcmp(argv[1], "-advice") == 0) {
	printf("Don't Panic!\n");
	exit(42);
    }
(Arnold Robbins in the LJ of February '95, describing RCS)
-------------------------------------------------------------------------------
We are using Linux daily to UP our productivity - so UP yours!
(Adapted from Pat Paulsen by Joe Sloan)
-------------------------------------------------------------------------------
`When you say "I wrote a program that crashed Windows", people just stare at
you blankly and say "Hey, I got those with the system, *for free*".'
(By Linus Torvalds)
-------------------------------------------------------------------------------
			Copyleft --:- ®Ø§hì Måkër -:--
-------------------------------------------------------------------------------


From spirou@aragne.com  Sun Sep  3 14:16:58 2000
From: spirou@aragne.com (Denis)
Date: Sun, 3 Sep 2000 15:16:58 +0200
Subject: [Tutor] Python CGI
In-Reply-To: <MABBIDAPBFNPPAAODIJAEEBGCAAA.poste_br@yahoo.com>; from poste_br@yahoo.com on Sun, Sep 03, 2000 at 12:12:46AM -0300
References: <MABBIDAPBFNPPAAODIJAEEBGCAAA.poste_br@yahoo.com>
Message-ID: <20000903151658.E24394@aragne.com>

Le Sun, Sep 03, 2000 at 12:12:46AM -0300, Guilherme pianota:
> 	I was looking at some host web sites that support CGI,
> and they all talk about perl.

The old-fashioned ones do ...  
The modern ones talk about Python.
;-)

> 	I was wondering if I can use python on those instead
> of perl.

First, go and have a look at :
http://starship.python.net/crew/davem/cgifaq/faqw.cgi

Just like you were told : start with a "Hello World" cgi-script,
go on with the Cgi module, the Cookie module, ...

And then have a look at http://webware.sourceforge.net

I've just started playing with Webware, it's quite pleasant
and I hope it'll be a good alternative to http://www.zope.org.
(Well, at least, it's clear, documented and more python-minded
than Zope, IMHO).

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


From protrans" <protrans@371.net  Sun Sep  3 16:43:11 2000
From: protrans" <protrans@371.net (protrans)
Date: Sun, 3 Sep 2000 23:43:11 +0800
Subject: [Tutor] free web space with Python cgi
Message-ID: <000a01c015bd$aa5eb6b0$c5f49e3d@w2k>

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C01600.B81B93C0
Content-Type: text/plain;
	charset="gb2312"
Content-Transfer-Encoding: base64

SGVsbG8sIGFsbCENCg0KQXMgSSBhbSB0aGlua2luZyBvZiBkb2luZyBteSBob21lcGFnZXMgd2l0
aCBweXRob24gY2dpLCBJIHdvbmRlciB3aGV0aGVyIHRoZXJlIGFyZSBhbnkgc2l0ZXMgcHJvdmlk
aW5nIGZyZWUgd2ViIHNwYWNlIHdpdGggUHl0aG9uIGNnaSBzdXBwb3J0Lg0KDQpBbnkgaGludCB3
b3VsZCBiZSBtdWNoIGFwcHJlY2lhdGVkLg0KDQoNCkpvc2VwaCBZLg0K

------=_NextPart_000_0007_01C01600.B81B93C0
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
L0VOIj4NCjxIVE1MPjxIRUFEPg0KPE1FVEEgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PWdi
MjMxMiIgaHR0cC1lcXVpdj1Db250ZW50LVR5cGU+DQo8TUVUQSBjb250ZW50PSJNU0hUTUwgNS4w
MC4yOTIwLjAiIG5hbWU9R0VORVJBVE9SPg0KPFNUWUxFPjwvU1RZTEU+DQo8L0hFQUQ+DQo8Qk9E
WSBiZ0NvbG9yPSNmZmZmZmY+DQo8RElWPjxGT05UIHNpemU9Mj5IZWxsbywgYWxsITwvRk9OVD48
L0RJVj4NCjxESVY+Jm5ic3A7PC9ESVY+DQo8RElWPjxGT05UIHNpemU9Mj5BcyBJIGFtIHRoaW5r
aW5nIG9mIGRvaW5nIG15IGhvbWVwYWdlcyB3aXRoIHB5dGhvbiBjZ2ksIEkgDQp3b25kZXIgd2hl
dGhlciB0aGVyZSBhcmUgYW55IHNpdGVzIHByb3ZpZGluZyBmcmVlIHdlYiBzcGFjZSB3aXRoIFB5
dGhvbiBjZ2kgDQpzdXBwb3J0LjwvRk9OVD48L0RJVj4NCjxESVY+Jm5ic3A7PC9ESVY+DQo8RElW
PjxGT05UIHNpemU9Mj5BbnkgaGludCB3b3VsZCBiZSBtdWNoIGFwcHJlY2lhdGVkLjwvRk9OVD48
L0RJVj4NCjxESVY+Jm5ic3A7PC9ESVY+DQo8RElWPjxGT05UIHNpemU9Mj48L0ZPTlQ+Jm5ic3A7
PC9ESVY+DQo8RElWPjxGT05UIHNpemU9Mj5Kb3NlcGggWS48L0ZPTlQ+PC9ESVY+PC9CT0RZPjwv
SFRNTD4NCg==

------=_NextPart_000_0007_01C01600.B81B93C0--



From denis@aragne.com  Sun Sep  3 17:50:31 2000
From: denis@aragne.com (Denis Frere)
Date: Sun, 3 Sep 2000 18:50:31 +0200
Subject: [Tutor] free web space with Python cgi
In-Reply-To: <000a01c015bd$aa5eb6b0$c5f49e3d@w2k>; from protrans@371.net on Sun, Sep 03, 2000 at 11:43:11PM +0800
References: <000a01c015bd$aa5eb6b0$c5f49e3d@w2k>
Message-ID: <20000903185031.I24394@aragne.com>

Le Sun, Sep 03, 2000 at 11:43:11PM +0800, protrans pianota:
> Hello, all!
> 
> As I am thinking of doing my homepages with python cgi, 
> I wonder whether there are any sites providing free web 
> space with Python cgi support.

Just find a free host and check
http://starship.python.net/crew/lemburg/mxCGIPython.html

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


From dyoo@hkn.EECS.Berkeley.EDU  Mon Sep  4 02:17:57 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Sun, 3 Sep 2000 18:17:57 -0700 (PDT)
Subject: [Tutor] Python CGI
In-Reply-To: <MABBIDAPBFNPPAAODIJAEEBGCAAA.poste_br@yahoo.com>
Message-ID: <Pine.LNX.4.21.0009031815140.27369-100000@hkn.EECS.Berkeley.EDU>

On Sun, 3 Sep 2000, Guilherme wrote:

> 	I was looking at some host web sites that support CGI, and they
> all talk about perl.
> 	I was wondering if I can use python on those instead of perl.
> 	Thanks!!!

Sure, Python is a good CGI language --- However, you might also want to
look at the material for Perl too.  A lot of the information is
translatable between the two languages.

Here is a link to resources you'll want to look at:

    http://www.python.org/topics/web/basic-cgi.html

It has specific details and tutorials on learning CGI programming.  I hope
this is helpful for you.



From c.gruschow@prodigy.net  Mon Sep  4 02:33:01 2000
From: c.gruschow@prodigy.net (Charles Gruschow, Jr.)
Date: Sun, 3 Sep 2000 20:33:01 -0500
Subject: [Tutor] how do you code Python to produce and/or generate a sound?
Message-ID: <005801c01610$10fbd040$2cdf6520@gruschow>

how do you code Python to produce and/or generate a sound?

c.gruschow@prodigy.net





From c.gruschow@prodigy.net  Mon Sep  4 02:37:17 2000
From: c.gruschow@prodigy.net (Charles Gruschow, Jr.)
Date: Sun, 3 Sep 2000 20:37:17 -0500
Subject: [Tutor] another ?, can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary?
Message-ID: <007301c01610$a9b3e200$2cdf6520@gruschow>

another ?, can Python be learned and used instead of CGI, Perl, and
Java/JavaScript or are those still necessary?

c.gruschow@prodigy.net





From c.gruschow@prodigy.net  Mon Sep  4 02:41:25 2000
From: c.gruschow@prodigy.net (Charles Gruschow, Jr.)
Date: Sun, 3 Sep 2000 20:41:25 -0500
Subject: [Tutor] 3rd ? for today: can Python do integration (numeric and/or trigonometric) and how is the best way to go about this?
Message-ID: <007f01c01611$4066ade0$2cdf6520@gruschow>

3rd ? for today: can Python do integration (numeric and/or trigonometric)
and how is the best way to go about this?

and if it can:
                can f(x) and/or f(x,y) functions be plotted?

more important part is the integration ? of this posting.

thank you


c.gruschow@prodigy.net





From dyoo@hkn.EECS.Berkeley.EDU  Mon Sep  4 03:19:57 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Sun, 3 Sep 2000 19:19:57 -0700 (PDT)
Subject: [Tutor] 3rd ? for today: can Python do integration (numeric
 and/or trigonometric) and how is the best way to go about this?
In-Reply-To: <007f01c01611$4066ade0$2cdf6520@gruschow>
Message-ID: <Pine.LNX.4.21.0009031846550.28092-100000@hkn.EECS.Berkeley.EDU>

I'll try to answer your three questions here:

1.  "how do you code Python to produce and/or generate a sound?"

I haven't done this myself yet, but there's a Python module for Windows
called 'winsound'.  You'll need to learn enough Python to use modules, but
it shouldn't be too bad.  Here's a link to the reference material on
winsound:

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


2. "can Python be learned and used instead of CGI, Perl, and
Java/JavaScript or are those still necessary?"

Computer languages are made to do different things --- It is true that
some things are more appropriate to do in the other languages.  It really
depends on what sort of stuff you'll be doing.  It wouldn't hurt at all to
expand your knowledge by learning the other languages.

Of course, I'm answering this way because, otherwise, it would inflame the
advocates of those other languages... *grin*  For clarification: CGI isn't
really a language but a way of tying programs to HTML forms.  CGI can be
done with any reasonable programming language.


3. "can Python do integration (numeric and/or trigonometric)
and how is the best way to go about this?"

Sure!  You can write a quick Python program to do numerical integration.  
Doing things symbolically might be more work though, and I don't have the
background yet to talk about symbolic integration.  There are languages
suited to do symbolic stuff --- there's Maple and Mathematica.  However,
both of those programs cost money.  Does anyone know of a free symbolic
math package?

It's not too hard to write a program to do integration.  There are several
methods to choose from.  Here's one method:

Let's say we're working with the function y(x) = x.  We'd like to find
the area underneath this curve.  For now, we'll pretend that we don't know
it's a triangle with area A = (x**2)/2.

y
|   .
|  .
| .
|.
--------x
0   1

An approximate way of doing this is to fit a rectangle underneath the
triangle, like this:

-----.    
    .|
   . |
  .  |
 .   |
.    |
-----|

We can take the area of this rectangle easily.  This is admittedly silly
--- a triangle isn't a rectangle!  But let's say we use two rectangles
instead of just one:

  ---.    
  | .|
  |. |
---  |
 .|  |
. |  |
-----|

It's still silly, but not quite as much.  Let's try three thinner
rectangles:

   ---    
   |.|
 --| |
 |.| |
-| | |
 | | |
-----|

In fact, calculus says that as we use more rectangles, this silly way of
approximating the integral through rectangles approaches the true area
underneath that curve.  I think the term for this method is called a
"Riemann Sum".

This description is meant to be fuzzy --- you'll want to experiment with
the idea, and then write it as a program.  Try to program it yourself
first, and we can help you if you run into problems.



From scarblac@pino.selwerd.nl  Mon Sep  4 07:46:04 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Mon, 4 Sep 2000 08:46:04 +0200
Subject: [Tutor] another ?, can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary?
In-Reply-To: <007301c01610$a9b3e200$2cdf6520@gruschow>; from c.gruschow@prodigy.net on Sun, Sep 03, 2000 at 08:37:17PM -0500
References: <007301c01610$a9b3e200$2cdf6520@gruschow>
Message-ID: <20000904084604.A22582@pino.selwerd.nl>

On Sun, Sep 03, 2000 at 08:37:17PM -0500, Charles Gruschow, Jr. wrote:
> another ?, can Python be learned and used instead of CGI, Perl, and
> Java/JavaScript or are those still necessary?

It depends on what you need to do.

"CGI" is not a programming language, it's a protocol. You could do CGI
with any programming language.

You write "Java/JavaScript", but don't think they are at all alike! Netscape
bought the "JavaScript" name from Sun to hop on the bandwagon with their own
language, but the two have nothing to do with each other otherwise.

Java can be used for many things, and most of those can be done by other
languages as well. The exception is mostly applets; there are things like
a Python applet plugin, but your users won't have it installed; and there
is JPython, which runs on the Java machine so in applets too, but it's even
slower than Java itself and should only be used as a tool, not to write a
whole Java app in, I think. So Java is good for applets, but then, when was
the last time you saw a really useful applet? :-)

JavaScript is usually used inside pages to work in the client's browser,
and it doesn't have a lot of competition there (but I feel a site shouldn't
depend on it, it should work without JS too). For many things JS is used
for, Flash may be a good alternative. Flash is pretty cool (but shuts out
some browsers again). You can't use Python client-side that way.

So, the question if you can stick to Python and do without the other languages
still depends on what you need to do :). 

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


From david@verso.org  Mon Sep  4 08:32:23 2000
From: david@verso.org (David Maclagan)
Date: Mon, 4 Sep 2000 17:32:23 +1000
Subject: [Tutor] Python in windows
Message-ID: <39B3DCA7.20877.C80162@localhost>

Can anyone reccomend any primers out there for using python in 
Windows? Particularly the GUI/windowing bits.

The primers I have managed to find seem to assume you're working 
on a *nix machine, and I'm finding the help in pythonwin not very 
obvious.

Thanks
David
-------
David Maclagan
David@verso.org


From dyoo@hkn.EECS.Berkeley.EDU  Mon Sep  4 10:57:57 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Mon, 4 Sep 2000 02:57:57 -0700 (PDT)
Subject: [Tutor] input() on IDLE?
Message-ID: <Pine.LNX.4.21.0009040252340.1493-100000@hkn.EECS.Berkeley.EDU>

I've been trying to figure out how to use raw_input()/input() in an IDLE
session.  For me, the *Output* window seems to not respond to input, and
someone else has reported getting EOF from it.  I'm using IDLE 0.5 under a
Linux system.

Here's the sample program:

###
print "Hello world!"
x  = input()
print "Here's what x has:", x
###

And a partial output:

###
Hello world!
42
# but nothing happens.
###


Does anyone know if these input functions work well in IDLE?  Thanks for
any help on this.



From dyoo@hkn.EECS.Berkeley.EDU  Mon Sep  4 11:24:08 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Mon, 4 Sep 2000 03:24:08 -0700 (PDT)
Subject: [Tutor] Python in windows
In-Reply-To: <39B3DCA7.20877.C80162@localhost>
Message-ID: <Pine.LNX.4.21.0009040315420.1685-100000@hkn.EECS.Berkeley.EDU>

On Mon, 4 Sep 2000, David Maclagan wrote:

> Can anyone reccomend any primers out there for using python in 
> Windows? Particularly the GUI/windowing bits.

Here's documentation on using IDLE:

    http://www.python.org/idle/doc/idlemain.html

It appears to be Windows oriented, so it should help you learn your
editing environment.  Ideally, the tutorials attempt to be os-agnostic and
focus more on the language itself.  Also, you might want to try looking at
the Windows section on Josh Cogliati's "Non-Programmers Tutorial For
Python":

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


Finally, I found another site which goes through a sample "Hello World" in
PythonWin:

    http://www.best.com/~cphoenix/python/


Hopefully, those resources should make your transition to these tools
easier.  Good luck!



From wesm@the-bridge.net  Mon Sep  4 14:22:43 2000
From: wesm@the-bridge.net (Wes Millis)
Date: Mon, 04 Sep 2000 08:22:43 -0500
Subject: [Tutor] input problem
Message-ID: <39B3A223.6930@the-bridge.net>

Hi,

Every time I try to run the 5th example ,Area Calculation Program, it
sends me an error on the 12th line of code. The line of code looks like
this.

shape = input ("> ")

I'm doing all of this through "Python Idel/The Python Shell. Thank you
for all of your help and effort.

                                                    CYA
                                                 Ryan*Halo*


From marcos@ifctr.mi.cnr.it  Mon Sep  4 14:37:10 2000
From: marcos@ifctr.mi.cnr.it (Marco Scodeggio)
Date: Mon, 4 Sep 2000 15:37:10 +0200 (MET DST)
Subject: [Tutor] a question on the BLT plotting library
Message-ID: <200009041337.PAA27101@hestia.ifctr.mi.cnr.it>

Hallo everybody.

I'm still completely new to Python, and I'm trying to figure out a =
relatively
simple method to produce some "decent looking" (scientific) plots.

Looking around on the web I have found Python megawidgets, that provide =
an=20
interface to the BLT plotting library.

I have installed the current verison of BLT (version 2.4u), to go along =
with the=20
tcl/tk installation that is standard on my workstation (version 8.2), =
and I did=20
put in the lib/python1.5/site-packages/ directory the Pmw installation.
I'm working on a Sun worstation using Solaris 2.5.1, and I have =
installed both=20
Python and the BLT library in my private directories.

Now, I can use the BLT library (which means I can run succesfully the =
self-test=20
program provided with it), and the Pmw widgets (again, the self-test =
works), but=20
when I try to run any simple demo using the Pmw.Blt class I get error =
messages=20
like this one:

>>> from Tkinter import *=20
>>> import Pmw
>>> root =3D Tk()
>>> g =3D Pmw.Blt.Graph(root)
Traceback (innermost last):
  File "<pyshell#3>", line 1, in ?
    g =3D Pmw.Blt.Graph(root)
  File=20
"/hestia/marcos/software/Python-1.5.2/lib/python1.5/site-packages/Pmw/Pmw=
_0_8_4/
lib/PmwBlt.py", line 260, in __init__
    Tkinter.Widget.__init__(self, master, _graphCommand, cnf, kw)
  File =
"/hestia/marcos/software/Python-1.5.2/lib/python1.5/lib-tk/Tkinter.py",=20
line 1084, in __init__
    self.tk.call(
TclError: invalid command name "::blt::graph"
>>>=20

Also the initialisation suggested by the Pmw folks
(  >>> import Pmw
   >>> root =3D Pmw.initialise()   )
produces the same identical error message.

Along the same lines, when I run the Pmw demos program, if I try the BLT =
related=20
tests, I get the message=20

"Sorry, the BLT package has not been installed on this system. Please =
install it=20
and try again"

Does anyone have any idea on what is happening ??? I presume Python =
cannot find=20
the BLT installation, but how do I let it know about it ??

Your help on this would be much appreciated. Thanks a lot.

		Marco Scodeggio



From alan.gauld@bt.com  Mon Sep  4 17:32:04 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 4 Sep 2000 17:32:04 +0100
Subject: [Tutor] another ?, can Python be learned and used instead of CGI,
 Perl, and Java/JavaScript or are those still necessary?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D2F1@mbtlipnt02.btlabs.bt.co.uk>

> then, when was
> the last time you saw a really useful applet? :-)

Smiley noted but I do have to jump in and defend applets.
There are a lot of real world applications being written for 
the web now that use full client/server applet/servlet technology. 

For instance in house I book my timeevery month using a Java 
applet to replace the previous VB application. I also log faults 
in our in house reporting tool using an applet to replace 
an Oracle Forms application.

Finally the Genesys Internet Suite is a commercial application 
that uses applet technmology to allow co-browsing, web chat 
etc etc into a traditional call-centre environment. I think the 
applet has become well established as the means to get performant 
UI's on the web - far beyond the early Mickey Mouse animations etc.

Sorry, I guess you hit one of my 'hot buttons' there :-)

Alan G.

PS This has nothing to do with the original question since you can 
use JPython for applets....albeit slowly!


From alan.gauld@bt.com  Mon Sep  4 17:38:02 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 4 Sep 2000 17:38:02 +0100
Subject: [Tutor] input() on IDLE?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D2F2@mbtlipnt02.btlabs.bt.co.uk>

> I've been trying to figure out how to use raw_input()/input() 
> in an IDLE session.  

Works OK in the Windows version of IDLE 0.5

> Here's the sample program:
> And a partial output:
> 
> ###
> Hello world!
> 42
> # but nothing happens.
> ###

I get:

Program:
print "Hello world"
x = input()
print "x = ", x

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
IDLE 0.5 -- press F1 for help
>>> 
Hello world
42
x =  42

Have you tried putting a prompt into the input() just to check 
its really getting there:

Alan G.


From scarblac@pino.selwerd.nl  Tue Sep  5 01:48:03 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 5 Sep 2000 02:48:03 +0200
Subject: [Tutor] another ?, can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary?
In-Reply-To: <302F8EC50419D411ABA500508B44DEFB4BDD2D@smit002.naa.gov.au>; from simond@naa.gov.au on Tue, Sep 05, 2000 at 10:23:03AM +1000
References: <302F8EC50419D411ABA500508B44DEFB4BDD2D@smit002.naa.gov.au>
Message-ID: <20000905024803.A23261@pino.selwerd.nl>

On Tue, Sep 05, 2000 at 10:23:03AM +1000, Simon Davis wrote:
> 
> Remco Gerlich wrote:
> [snip] 
> >Java can be used for many things, and most of those can be done by other
> >languages as well. The exception is mostly applets; there are things like
> >a Python applet plugin, but your users won't have it installed;
> 
> Is there a Python virtual machine plug-in for web browsers that would allow
> me to write Python applets a la Java applets? If so does anybody know where
> it is? It doesn't seem to be on a prominent part of python.org (but perhaps
> I'm just blind).

I knew, somewhere in the back of my mind, that such a beast existed. But it's
obscure. (That's why I said "your users won't have it installed", usually
I would add a "probably" there). Now I went searching for it, and it seems
the last version is from '96, was still 16-bit, and for Netscape 2.0 
(http://www.python.org/psa/Projects.html).

Other search results seem to indicate that there's still work going on on
a modern version
(http://classic.zope.org/pipermail/zope/1999-April/003789.html), well that's
still one and half years ago...

So it would have been more accurate if I had said "there *used to be* a
Python plugin", I guess...

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


From deng@ms.shlftdc.net.cn  Wed Sep  6 11:58:07 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Wed, 6 Sep 2000 18:58:7 +0800
Subject: [Tutor] (no subject)
Message-ID: <20000905100826718.AAA335.511@192>

Hi:
  My OS is Windows98.And I found the same problem.But I don't know how to deal with.
                  

            DengWei
            deng@ms.shlftdc.net.cn



From deng@ms.shlftdc.net.cn  Wed Sep  6 12:00:46 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Wed, 6 Sep 2000 19:0:46 +0800
Subject: [Tutor] (no subject)
Message-ID: <20000905101105421.AAA335.406@192>

Hi:
  Sorry for the pre-reply.
  Again,I found the same problem in the IDLE under Windows98.:)



Message: 9
Date: Mon, 4 Sep 2000 02:57:57 -0700 (PDT)
From: Daniel Yoo <dyoo@hkn.EECS.Berkeley.EDU>
To: tutor@python.org
Subject: [Tutor] input() on IDLE?

I've been trying to figure out how to use raw_input()/input() in an IDLE
session.  For me, the *Output* window seems to not respond to input, and
someone else has reported getting EOF from it.  I'm using IDLE 0.5 under a
Linux system.

Here's the sample program:

###
print "Hello world!"
x  = input()
print "Here's what x has:", x
###

And a partial output:

###
Hello world!
42
# but nothing happens.
###


Does anyone know if these input functions work well in IDLE?  Thanks for
any help on this.



                  

            DengWei
            deng@ms.shlftdc.net.cn



From deng@ms.shlftdc.net.cn  Wed Sep  6 12:37:01 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Wed, 6 Sep 2000 19:37:1 +0800
Subject: [Tutor] help!
Message-ID: <20000905104720968.AAA335.481@192>

Hi,all:
  Maybe it's not a question.Sorry for disturbing you.
  When I finished the tutorial,I lost my way.What I should do next?
  Can someone give me any suggestion?
  Thanks a lot. 



                  

            DengWei
            deng@ms.shlftdc.net.cn



From scarblac@pino.selwerd.nl  Tue Sep  5 12:56:21 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 5 Sep 2000 13:56:21 +0200
Subject: [Tutor] help!
In-Reply-To: <20000905104720968.AAA335.481@192>; from deng@ms.shlftdc.net.cn on Wed, Sep 06, 2000 at 07:37:01PM +0800
References: <20000905104720968.AAA335.481@192>
Message-ID: <20000905135621.A24617@pino.selwerd.nl>

On Wed, Sep 06, 2000 at 07:37:01PM +0800, deng wei wrote:
> Hi,all:
>   Maybe it's not a question.Sorry for disturbing you.
>   When I finished the tutorial,I lost my way.What I should do next?
>   Can someone give me any suggestion?

Well, why did you start learning Python?

Pick something interesting to make and try to find out how to make it?

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


From c.gruschow@prodigy.net  Wed Sep  6 04:01:42 2000
From: c.gruschow@prodigy.net (Charles Gruschow, Jr.)
Date: Tue, 5 Sep 2000 22:01:42 -0500
Subject: [Tutor] I found a module set called PyOpenGL, but I can't find documentation, can you help please?
Message-ID: <000b01c017ae$c9e74860$10df6520@gruschow>

I found a module set called PyOpenGL, but I can't find documentation, can
you help please?
It acts as an interface between Python and OpenGL.


c.gruschow@prodigy.net





From dyoo@hkn.EECS.Berkeley.EDU  Wed Sep  6 09:36:47 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Wed, 6 Sep 2000 01:36:47 -0700 (PDT)
Subject: [Tutor] help!
In-Reply-To: <20000905104720968.AAA335.481@192>
Message-ID: <Pine.LNX.4.21.0009060132050.18818-100000@hkn.EECS.Berkeley.EDU>

On Wed, 6 Sep 2000, deng wei wrote:

>   Maybe it's not a question.Sorry for disturbing you.
>   When I finished the tutorial,I lost my way.What I should do next?
>   Can someone give me any suggestion?
>   Thanks a lot. 

Hmmm... it really does depend on your interests.  Many people get into CGI
programming, which is pretty practical and fun.  Others have done database
programming, or user interfaces, or scientific computing.  As a starter,
you might want to take a look at the topic guides for some suggested
additional reading:

    http://www.python.org/topics/

Also, if you want, we can suggest sample problems for you to try out, to
solidify your knowledge of Python.  Tell us more about your interests ---
perhaps we can point you toward something relevant to your interests
that's Python related.  *grin*



From phillipmross@hotmail.com  Wed Sep  6 13:57:49 2000
From: phillipmross@hotmail.com (Phillip Ross)
Date: Wed, 06 Sep 2000 05:57:49 PDT
Subject: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready for some help
Message-ID: <F2188m4ZQJXs7k46ls70000448b@hotmail.com>


I would love to have someone spoon feed me the steps for getting Microsoft's 
cmd shell to "see" python.  I can't seem to get it to run even though...
1) I know where Python lives...  c:\python16
2) I know where the control panel for environment settings are.  (although I 
am not sure how to set them so python can be run from the MS cmd line.) :P

Thank you

-Phillip

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

Share information about yourself, create your own public profile at 
http://profiles.msn.com.



From griff@netdoor.com  Wed Sep  6 14:34:50 2000
From: griff@netdoor.com (R. A.)
Date: Wed, 06 Sep 2000 08:34:50 -0500
Subject: [Tutor] Installing Python 1.6
Message-ID: <39B647FA.AA5F1302@netdoor.com>

Does anyone know if it would be a good idea to uninstall 1.5 before
installing 1.6?


From alan.gauld@bt.com  Wed Sep  6 17:25:15 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 6 Sep 2000 17:25:15 +0100
Subject: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready for
 some        help
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D309@mbtlipnt02.btlabs.bt.co.uk>

> I would love to have someone spoon feed me the steps for 
> getting Microsoft's 
> cmd shell to "see" python.  I can't seem to get it to run 
> even though...
> 1) I know where Python lives...  c:\python16
> 2) I know where the control panel for environment settings 

I don't know W2K but assume that PATH still works?

in which case it should be:

PATH <existing path>;C:\python16

ie tag on ;C:\python16 to whatever value of path is there already.

Alan G.

Should therefore suffice....

Alan G.


From dyoo@hkn.EECS.Berkeley.EDU  Wed Sep  6 18:52:09 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Wed, 6 Sep 2000 10:52:09 -0700 (PDT)
Subject: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready
 for some help
In-Reply-To: <F2188m4ZQJXs7k46ls70000448b@hotmail.com>
Message-ID: <Pine.LNX.4.21.0009061046380.26879-100000@hkn.EECS.Berkeley.EDU>

On Wed, 6 Sep 2000, Phillip Ross wrote:

> I would love to have someone spoon feed me the steps for getting Microsoft's 
> cmd shell to "see" python.  I can't seem to get it to run even though...
> 1) I know where Python lives...  c:\python16
> 2) I know where the control panel for environment settings are.  (although I 
> am not sure how to set them so python can be run from the MS cmd line.) :P

Ok, you'll want to get to the environment settings window.  You'll see two
large textfields, one for system environment variable, and the other for
user environment variables.

The environment variable you'll touch is PATH --- Windows searches the
directories in PATH whenever you enter a command through the cmd window.

It's probably best to edit the PATH variable for the system environment.  
(I think that you'll need to be an Administrator account to do this.)

Append to the end of the PATH variable:

    [bunch of other path statements];C:\Python16

Afterwards, apply your settings, save, and see if a newly-opened command
prompt allows you to call Python from any directory.  If that works, you
should be all set up.



From CaliGirl62540486@aol.com  Wed Sep  6 21:08:38 2000
From: CaliGirl62540486@aol.com (CaliGirl62540486@aol.com)
Date: Wed, 6 Sep 2000 16:08:38 EDT
Subject: [Tutor] tutor
Message-ID: <6d.8f7356e.26e7fe46@aol.com>

I need help in learning to program with python


From peep427@ptdprolog.net  Wed Sep  6 22:00:50 2000
From: peep427@ptdprolog.net (carol engle)
Date: Wed, 6 Sep 2000 17:00:50 -0400
Subject: [Tutor] open files
Message-ID: <000901c01845$8cdd5760$9f0ffea9@d8nf001>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C01824.025B48C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

how do i open files. I read a book about Python and i wright programs =
but
i cannot open them what is wrong somebody please tell me.

------=_NextPart_000_0005_01C01824.025B48C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>how do i open files. I read a book =
about Python and=20
i wright programs but</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i cannot open them what is wrong =
somebody please=20
tell me.</FONT></DIV></BODY></HTML>

------=_NextPart_000_0005_01C01824.025B48C0--



From shaleh@valinux.com  Wed Sep  6 22:25:19 2000
From: shaleh@valinux.com (Sean 'Shaleh' Perry)
Date: Wed, 06 Sep 2000 14:25:19 -0700 (PDT)
Subject: [Tutor] open files
In-Reply-To: <000901c01845$8cdd5760$9f0ffea9@d8nf001>
Message-ID: <XFMail.20000906142519.shaleh@valinux.com>

On 06-Sep-2000 carol engle wrote:
> how do i open files. I read a book about Python and i wright programs but
> i cannot open them what is wrong somebody please tell me.

fp = open('/path/to/file', 'r')
for line in fp.readlines():
  print line, # comma is to suppress the new line character
close(fp)

A robust version would catch the exception open raises when it errors out.


From deng@ms.shlftdc.net.cn  Fri Sep  8 02:00:17 2000
From: deng@ms.shlftdc.net.cn (deng wei)
Date: Fri, 8 Sep 2000 9:0:17 +0800
Subject: [Tutor] Help!
Message-ID: <20000907001038859.AAA272.363@192>

Hi:
  Thank you for your kindness.
  Hmm....Now I have found a interest problem.
  I want to write  something like Matlab.
  When I write Python script and run it,it should be act like Matlab do.
  For example:
  In Matlab:
	t=0:0.01:1;
 	plot(t,sin(t));
  it would plot a sine curve.
  My goal would be write a function like plot in Matlab.
  

  Now I found I had to make a choice between Tcl and VC++.I am confused.
What should I do?  I am unfamiliar with programming under windows although I 
can write C code under DOS.
  



                  

            DengWei
            deng@ms.shlftdc.net.cn



From dyoo@hkn.EECS.Berkeley.EDU  Thu Sep  7 03:12:15 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Wed, 6 Sep 2000 19:12:15 -0700 (PDT)
Subject: [Tutor] tutor
In-Reply-To: <6d.8f7356e.26e7fe46@aol.com>
Message-ID: <Pine.LNX.4.21.0009061910590.7506-100000@hkn.EECS.Berkeley.EDU>

On Wed, 6 Sep 2000 CaliGirl62540486@aol.com wrote:

> I need help in learning to program with python

Hmmm...  What questions do you have?  If you want, you can take a look at
the introductions and tutorials on python.org.  They should help get you
up to speed:

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

Hope this helps!



From rcb@babione.com  Thu Sep  7 03:55:15 2000
From: rcb@babione.com (Robert C. Babione)
Date: Wed, 06 Sep 2000 21:55:15 -0500
Subject: [Tutor] Installing Python 1.5.2, where is C compiler
Message-ID: <4.3.2.20000906213741.00c4ec90@mail.anet-stl.com>

I am trying to upgrade to Python 1.5.2.  I've done almost nothing with 
1.5.1-10 that came with the installation.  I am just starting and want to 
have Idle.

I've downloaded 1.5.2, unzipped it, and extracted the files.

When I do ./configure, I get a message that there is no gcc or cc in $PATH.

If I add --without -gcc, I get "C compiler cannot create executables."

I have Red Hat 6.0, Linux 2.2.5-15.

I am working at the command line and am very new to Linux - I'm not even 
sure what the question is.

Do I need to install a C compiler?  Just find where the C compiler already 
installed is and fix the path?  (I know about path in DOS, but do not know 
what the parallel command is in Linux.)

Thanks for any information or pointers (I found nothing in the FAQ, the 
tutor, or by searching the Python site).

Bob



From dyoo@hkn.EECS.Berkeley.EDU  Thu Sep  7 06:20:13 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Wed, 6 Sep 2000 22:20:13 -0700 (PDT)
Subject: [Tutor] Installing Python 1.5.2, where is C compiler
In-Reply-To: <4.3.2.20000906213741.00c4ec90@mail.anet-stl.com>
Message-ID: <Pine.LNX.4.21.0009062209040.10832-100000@hkn.EECS.Berkeley.EDU>

> When I do ./configure, I get a message that there is no gcc or cc in $PATH.
> 
> If I add --without -gcc, I get "C compiler cannot create executables."
> 
> I have Red Hat 6.0, Linux 2.2.5-15.
> 
> I am working at the command line and am very new to Linux - I'm not even 
> sure what the question is.
> 
> Do I need to install a C compiler?  Just find where the C compiler already 
> installed is and fix the path?  (I know about path in DOS, but do not know 
> what the parallel command is in Linux.)

Hmmm... Can you check to see if you have gcc?  Try:

    which gcc

and see if that turns up anything.  Here's what shows up for me:

###
[dyoo@c82114-a dyoo]$ which gcc
/usr/bin/gcc
###

You do need the gcc compiler to do a source install.  However, why not
upgrade your Python installation using RPM's?  It's easier to do:

    rpm -Uvh python-1.5.2-13.i386.rpm

RPM is a package management system --- it allows you to install/uninstall
software very easily.

You can find the Python RPM here:

    http://www.rpmfind.org/RPM/redhat/6.2/i386/python-1.5.2-13.i386.html

The RPM is meant for Redhat 6.2, but it should install on your system with
few problems.



From phillipmross@hotmail.com  Thu Sep  7 06:25:41 2000
From: phillipmross@hotmail.com (Phillip Ross)
Date: Wed, 06 Sep 2000 22:25:41 PDT
Subject: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready for some help
Message-ID: <F35UtI9dm5UxP9Fekza000051cd@hotmail.com>

Thank you.  The step by step really helped... and yes you need to be logged 
on as admin for this to work... oops ;-p

-Phillip

----Original Message Follows----
From: Daniel Yoo <dyoo@hkn.EECS.Berkeley.EDU>
To: Phillip Ross <phillipmross@hotmail.com>
CC: tutor@python.org
Subject: Re: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready 
for some help
Date: Wed, 6 Sep 2000 10:52:09 -0700 (PDT)

On Wed, 6 Sep 2000, Phillip Ross wrote:

 > I would love to have someone spoon feed me the steps for getting 
Microsoft's
 > cmd shell to "see" python.  I can't seem to get it to run even though...
 > 1) I know where Python lives...  c:\python16
 > 2) I know where the control panel for environment settings are.  
(although I
 > am not sure how to set them so python can be run from the MS cmd line.) 
:P

Ok, you'll want to get to the environment settings window.  You'll see two
large textfields, one for system environment variable, and the other for
user environment variables.

The environment variable you'll touch is PATH --- Windows searches the
directories in PATH whenever you enter a command through the cmd window.

It's probably best to edit the PATH variable for the system environment.
(I think that you'll need to be an Administrator account to do this.)

Append to the end of the PATH variable:

     [bunch of other path statements];C:\Python16

Afterwards, apply your settings, save, and see if a newly-opened command
prompt allows you to call Python from any directory.  If that works, you
should be all set up.


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

Share information about yourself, create your own public profile at 
http://profiles.msn.com.



From deirdre@deirdre.net  Thu Sep  7 10:02:39 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Thu, 7 Sep 2000 02:02:39 -0700 (PDT)
Subject: [Tutor] tutor
In-Reply-To: <6d.8f7356e.26e7fe46@aol.com>
Message-ID: <Pine.LNX.4.10.10009070202230.24162-100000@rockhopper.deirdre.org>

On Wed, 6 Sep 2000 CaliGirl62540486@aol.com wrote:

> I need help in learning to program with python

Please ask a specific question.

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"More damage has been caused by innocent program crashes than by 
malicious viruses, but they don't make great stories."
                   --  Jean-Louis Gassee, Be Newsletter, Issue 69



From tim_one@email.msn.com  Thu Sep  7 10:27:06 2000
From: tim_one@email.msn.com (Tim Peters)
Date: Thu, 7 Sep 2000 05:27:06 -0400
Subject: [Tutor] Installing Python 1.6
In-Reply-To: <39B647FA.AA5F1302@netdoor.com>
Message-ID: <LNBBLJKPBEHFEDALKOLCOEIPHEAA.tim_one@email.msn.com>

[R. A.]
> Does anyone know if it would be a good idea to uninstall 1.5 before
> installing 1.6?

Unless you're an expert, it never hurts!  If something goes wrong, and you
didn't uninstall 1.5 first, you'll have a darned hard time trying to figure
out whether that's because you didn't uninstall 1.5 first <0.9 wink>.

If you're just starting out, don't complicate your life.




From Melissa Holden <melissa@thinice.com>  Thu Sep  7 20:33:19 2000
From: Melissa Holden <melissa@thinice.com> (Melissa Holden)
Date: 07 Sep 2000 14:33:19 -0500
Subject: [Tutor] string matching and replacement
Message-ID: <3051181938melissa@thinice.com>

I am trying to learn Python, and have used it for a few cgi scripts, but =
am still very much a beginner.  Any help with this problem would be =
appreciated:

I am trying to search a file for 2 markers, and replace the text in =
between them.  My first thought was to use regular expressions, but I =
haven't been able to get it to work.  So far, I have come up with =
something like this:

p =3D re.compile(r'<!-- beginning text -->')
m =3D p.search( file )
if m:
        print 'Match found: ', m.group()
else:
        print 'No match'

As it is, this works, but when I try to add something in the middle and =
the end text marker (e.g., p=3Dre.compile(r'<!-- beginning text -->.*<!-- =
ending text -->')), it breaks.  If I could get this part to work, I was =
planning to use sub to replace the section with something else.  Basically,=
 I want to find the beginning and ending tags, and replace what's in =
between them (which will vary in length).

Any help will be greatly appreciated.

Thanks!
Melissa


From shaleh@valinux.com  Thu Sep  7 20:51:00 2000
From: shaleh@valinux.com (Sean 'Shaleh' Perry)
Date: Thu, 07 Sep 2000 12:51:00 -0700 (PDT)
Subject: [Tutor] string matching and replacement
In-Reply-To: <3051181938melissa@thinice.com>
Message-ID: <XFMail.20000907125100.shaleh@valinux.com>

$ python
>>> import re
>>> p = re.compile('<!-- beginning text -->(.*)<!-- ending text -->')
>>> string = '<!-- beginning text -->This is a comment<!-- ending text -->'
>>> m = p.search(string)
>>> if m:
...    print 'Match', m.group()
... else:
...   print 'No Match'
... 
Match <!-- beginning text -->This is a comment<!-- ending text -->
>>> m.groups() # returns a tuple of the matched groups
('This is a comment',)

There ya go (-:



From Melissa Holden <melissa@thinice.com>  Thu Sep  7 21:07:02 2000
From: Melissa Holden <melissa@thinice.com> (Melissa Holden)
Date: 07 Sep 2000 15:07:02 -0500
Subject: [Tutor] string matching and replacement
Message-ID: <3051183989melissa@thinice.com>

Thank you for your help.  This may be a dumb question, but is it possible =
to search a file?  For example, instead of string =3D '<!-- beginning text =
-->This is a comment<!-- ending text -->'
m =3D p.search(string)
I was trying to get it to search an external file that I had referenced =
earlier in the program by=20
file =3D open('../index5.html').read()

Thanks for your assistance!


On 9/7/00, Sean 'Shaleh' Perry <shaleh@valinux.com> wrote:
>$ python
>>>> import re
>>>> p =3D re.compile('<!-- beginning text -->(.*)<!-- ending text -->')
>>>> string =3D '<!-- beginning text -->This is a comment<!-- ending=20
>text -->'
>>>> m =3D p.search(string)
>>>> if m:
>...    print 'Match', m.group()
>... else:
>...   print 'No Match'
>...=20
>Match <!-- beginning text -->This is a comment<!-- ending text -->
>>>> m.groups() # returns a tuple of the matched groups
>('This is a comment',)
>
>There ya go (-:
>


From shaleh@valinux.com  Thu Sep  7 21:17:34 2000
From: shaleh@valinux.com (Sean 'Shaleh' Perry)
Date: Thu, 07 Sep 2000 13:17:34 -0700 (PDT)
Subject: [Tutor] string matching and replacement
In-Reply-To: <3051183989melissa@thinice.com>
Message-ID: <XFMail.20000907131734.shaleh@valinux.com>

On 07-Sep-2000 Melissa Holden wrote:
> Thank you for your help.  This may be a dumb question, but is it possible to
> search a file?  For example, instead of string = '<!-- beginning text -->This
> is a comment<!-- ending text -->'
> m = p.search(string)
> I was trying to get it to search an external file that I had referenced
> earlier in the program by 
> file = open('../index5.html').read()
> 

I am sure with some playing you could do this.  The regex search has to have a
string to look thru though.


From form1l1b@Rotorua-Intermediate.org.nz  Fri Sep  8 02:45:32 2000
From: form1l1b@Rotorua-Intermediate.org.nz (form1l1b)
Date: Fri, 8 Sep 2000 13:45:32 +1200
Subject: [Tutor] python
Message-ID: <C1DD731C37EBD311A8B700A0C98C062ED96C@NT_SERVER>

please please! can you send me a email with a lesson in python in it. please
email me at midolawton@hotmail.com 


From dyoo@hkn.EECS.Berkeley.EDU  Fri Sep  8 05:44:55 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Thu, 7 Sep 2000 21:44:55 -0700 (PDT)
Subject: [Tutor] string matching and replacement
In-Reply-To: <3051183989melissa@thinice.com>
Message-ID: <Pine.LNX.4.21.0009072127460.4881-100000@hkn.EECS.Berkeley.EDU>

On 7 Sep 2000, Melissa Holden wrote:

> Thank you for your help.  This may be a dumb question, but is it
> possible to search a file?  For example, instead of string = '<!--

It's not a dumb question.  What you'll want to do is suck a string out of
an open file.  Opening files is easy:

    in_file = open("data.txt")

After the file has been opened, you can extract its contents into a string
using its "read()" method:

    contents = in_file.read()

and you can do the string searching on 'contents'.


A shorthand for this is:

    contents = open("data.txt").read()


You'll probably want to look at some more information on file I/O.  Here
are a bunch of references on I/O:

The official tutorial has a section on it:
http://www.python.org/doc/current/tut/node9.html#SECTION009210000000000000000

Alan Gauld's tutorial:

    http://members.xoom.com/alan_gauld/tutor/tutindex.htm

Josh Cogliati's tutorial:

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




From dyoo@hkn.EECS.Berkeley.EDU  Fri Sep  8 05:55:28 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Thu, 7 Sep 2000 21:55:28 -0700 (PDT)
Subject: [Tutor] python
In-Reply-To: <C1DD731C37EBD311A8B700A0C98C062ED96C@NT_SERVER>
Message-ID: <Pine.LNX.4.21.0009072149010.4881-100000@hkn.EECS.Berkeley.EDU>

On Fri, 8 Sep 2000, form1l1b wrote:

> please please! can you send me a email with a lesson in python in it.
> please email me at midolawton@hotmail.com

We'd be happy to --- You need to tell us what you're looking for though,
because there's a lot of material to choose from.  If you can ask for a
specific topic, we can focus our efforts there.


In the meantime, you might want to look at the tutorials section:

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

because they've done a very good job in distilling the essence of Python
to beginners.


These links below are especially good:

Magnus Lie Hetland's "Instant Hacking"
    http://www.idi.ntnu.no/~mlh/python/programming.html

Josh Coliati's "A Non-Programmers Tutorial for Python"
    http://www.honors.montana.edu/~jjc/easytut/easytut/

Alan Gauld's "Learning to Program"
    http://members.xoom.com/alan_gauld/tutor/tutindex.htm


Email us again when you have questions.  Good luck!



From c.gruschow@prodigy.net  Fri Sep  8 06:22:38 2000
From: c.gruschow@prodigy.net (Charles Gruschow, Jr.)
Date: Fri, 8 Sep 2000 00:22:38 -0500
Subject: [Tutor] ? about PyOpenGL
Message-ID: <005201c01954$d19dc960$c3df6520@gruschow>

I found a module set called PyOpenGL, but I can't find documentation, can
you help please?
It acts as an interface between Python and OpenGL.


c.gruschow@prodigy.net






From c.gruschow@prodigy.net  Fri Sep  8 06:27:35 2000
From: c.gruschow@prodigy.net (Charles Gruschow, Jr.)
Date: Fri, 8 Sep 2000 00:27:35 -0500
Subject: [Tutor] ? about NumPy...has anyone got it to work, I can't figure it out...can you help?
Message-ID: <005301c01955$7f540060$c3df6520@gruschow>

? about NumPy...has anyone got it to work, I can't figure it out...

I have Python 1.5.2, Idle 0.5, Windows 98SE, MS Internet 5.1.

I have tried several sites and several versions.

I downloaded cl.exe and link.exe off ftp sites.

I get link errors and library errors.

I get MatrixArray module not found errors.

Can you help., and/or can someone just give me an already setup module and
instructions on what to do with it.

c.gruschow@prodigy.net






From midolawton@hotmail.com  Fri Sep  8 20:27:48 2000
From: midolawton@hotmail.com (Mido Lawton)
Date: Fri, 08 Sep 2000 19:27:48 CHAST
Subject: [Tutor] (no subject)
Message-ID: <F224uNY1SWoBDyseVwr000074c2@hotmail.com>

<html><DIV><FONT face="Arial Black, Geneva, Arial, Sans-serif">well im just looking for a way to madly impress my mates by pulling off cool stunts such as going into the schools coputers with out doing damage so can you send me ways to get into it or learn the python language so I can get in. but like i said i dont want to do any harm. email address= <A href="mailto:midolawton@hotmail.com">midolawton@hotmail.com</A></FONT></DIV>
<DIV><FONT face="Arial Black">please write back soon......</FONT></DIV><p><hr>Get Your Private, Free E-mail from MSN Hotmail at <a href="http://www.hotmail.com">http://www.hotmail.com</a>.<p>Share information about yourself, create your own public profile at <a href="http://profiles.msn.com">http://profiles.msn.com </a>.<br></p></html>


From dyoo@hkn.EECS.Berkeley.EDU  Fri Sep  8 09:53:38 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Fri, 8 Sep 2000 01:53:38 -0700 (PDT)
Subject: [Tutor] ? about PyOpenGL
In-Reply-To: <005201c01954$d19dc960$c3df6520@gruschow>
Message-ID: <Pine.LNX.4.21.0009080148290.9982-100000@hkn.EECS.Berkeley.EDU>

On Fri, 8 Sep 2000, Charles Gruschow, Jr. wrote:

> I found a module set called PyOpenGL, but I can't find documentation, can
> you help please?
> It acts as an interface between Python and OpenGL.

Unfortunately, I don't know too much on PyOpenGL --- does it come with
example programs that you could look at?  The page:

    http://www.python.de/

seems to have a few examples that might help you get started
working with it.  Apparently, it's a thin layer around OpenGL
itself, so tutorials on

    http://www.opengl.org/

should be relevant for you.  Also, you might want to ask the
comp.lang.python folks, because there's bound to be someone there who uses
PyOpenGL regularly.


I hope this helps!



From dyoo@hkn.EECS.Berkeley.EDU  Fri Sep  8 10:24:44 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Fri, 8 Sep 2000 02:24:44 -0700 (PDT)
Subject: [Tutor] (no subject)
In-Reply-To: <F224uNY1SWoBDyseVwr000074c2@hotmail.com>
Message-ID: <Pine.LNX.4.21.0009080153430.9982-100000@hkn.EECS.Berkeley.EDU>

On Fri, 8 Sep 2000, Mido Lawton wrote:

> well im just looking for a way to madly impress my mates by pulling
> off cool stunts such as going into the schools coputers with out doing
> damage so can you send me ways to get into it or learn the python
> language so I can get in. but like i said i dont want to do any harm.
> email address= midolawton@hotmail.com please write back soon......

Hello Mido,

Sorry, we can't help there; as far as I know, Python's not particularly
useful for getting into a school computer.

An easier way to get some computer access might also be less glamourous at
first: Can you ask them to give you an account to play around with?  It
might be better if you could get a legitimate account on their machines,
so that you can learn Python without getting the adults rilled up.

With Python, you can write cool programs --- to me, that's pretty
impressive, because you're making ideas that actually do things.

For example, have you gotten into trigonometry yet?  There's a theorem
that says that if you keep doing 'cos()' on a number, over and over,
you'll eventually reach a number that doesn't change?  Take a look:

###
>>> import math
>>> number = 1
>>> while math.cos(number) != number: 
...     number = math.cos(number)
... 
>>> print number
0.739085133215
>>> math.cos(number)
0.739085133215
###

It's called the "fixed-point" theorem.  Python lets me test out and play
with ideas.  Again, I sorry, but Python's not meant to be used to break
into systems.  We can't help you with getting access.  Instead, we can
help you learn to use Python as a tool, if you want.



From wbateman@epicrealm.com  Fri Sep  8 16:35:47 2000
From: wbateman@epicrealm.com (Wes Bateman)
Date: Fri, 8 Sep 2000 10:35:47 -0500 (CDT)
Subject: [Tutor] using shell environment variables
Message-ID: <Pine.LNX.4.21.0009081030220.1184-100000@jackwebb.wesnetworks.com>

How can one use environment variables that the shell has?  I am trying to
rewrite a single section of a co-worker's bash script to run in python
instead.  In order to accomplish this though, I need to be able to access
environment variables that he has set and was passing to the smaller bash
script that I'm trying to replace.

Just for an example, the $PATH variable in the shell.  I need more than
the path for my actual script, but an example using $PATH or anything else
would help me out quite a bit :)

Thanks! :)

Wes



From denis@aragne.com  Fri Sep  8 16:58:52 2000
From: denis@aragne.com (Denis Frere)
Date: Fri, 8 Sep 2000 17:58:52 +0200
Subject: [Tutor] using shell environment variables
In-Reply-To: <Pine.LNX.4.21.0009081030220.1184-100000@jackwebb.wesnetworks.com>; from wbateman@epicrealm.com on Fri, Sep 08, 2000 at 10:35:47AM -0500
References: <Pine.LNX.4.21.0009081030220.1184-100000@jackwebb.wesnetworks.com>
Message-ID: <20000908175852.D18245@aragne.com>

Le Fri, Sep 08, 2000 at 10:35:47AM -0500, Wes Bateman pianota:
> How can one use environment variables that the shell has?

>>> import os
>>> for el in os.environ.keys():
	print el, os.environ[el]

That should do.

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


From dsh8290@rit.edu  Fri Sep  8 17:02:59 2000
From: dsh8290@rit.edu (D-Man)
Date: Fri, 8 Sep 2000 12:02:59 -0400
Subject: [Tutor] using shell environment variables
In-Reply-To: <Pine.LNX.4.21.0009081030220.1184-100000@jackwebb.wesnetworks.com>; from wbateman@epicrealm.com on Fri, Sep 08, 2000 at 11:35:47 -0400
References: <Pine.LNX.4.21.0009081030220.1184-100000@jackwebb.wesnetworks.com>
Message-ID: <20000908120259.A8437@dman>

I don't have the documentation in front of me at the moment, but I believe in
the os or the sys module there are routines for accessing and maniputlating the
environemnt.  Check the Library Reference.

-D

On Fri, 08 Sep 2000 11:35:47 Wes Bateman wrote:
> How can one use environment variables that the shell has?  I am trying to
> rewrite a single section of a co-worker's bash script to run in python
> instead.  In order to accomplish this though, I need to be able to access
> environment variables that he has set and was passing to the smaller bash
> script that I'm trying to replace.
> 
> Just for an example, the $PATH variable in the shell.  I need more than
> the path for my actual script, but an example using $PATH or anything else
> would help me out quite a bit :)
> 
> Thanks! :)
> 
> Wes
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor




From wbateman@epicrealm.com  Fri Sep  8 17:41:18 2000
From: wbateman@epicrealm.com (Wes Bateman)
Date: Fri, 8 Sep 2000 11:41:18 -0500 (CDT)
Subject: [Tutor] using shell environment variables
In-Reply-To: <20000908175852.D18245@aragne.com>
Message-ID: <Pine.LNX.4.21.0009081140260.1184-100000@jackwebb.wesnetworks.com>

Ah, thanks.  I was close (in the right module) but not using the right
syntax :)

Many thanks, and enjoy your weekend too :)

Wes


On Fri, 8 Sep 2000, Denis Frere wrote:

> Le Fri, Sep 08, 2000 at 10:35:47AM -0500, Wes Bateman pianota:
> > How can one use environment variables that the shell has?
> 
> >>> import os
> >>> for el in os.environ.keys():
> 	print el, os.environ[el]
> 
> That should do.
> 
> Have a nice week-end.
> 



From griff@netdoor.com  Fri Sep  8 23:51:11 2000
From: griff@netdoor.com (R. A.)
Date: Fri, 08 Sep 2000 17:51:11 -0500
Subject: [Tutor] simple (fnord) newbie question
Message-ID: <39B96D5F.A2C2A033@netdoor.com>

As the following code illustrates, I'm just learning the absolute basics 
at this point, and I'm trying to pin down a minor detail.  The function 
performs a couple of simple math formulas, but my question is about the 
period standing by itself in quotes at the end of a couple of printed 
statements.

The way I have it now, an additional empty character space is printed 
before the "." such that the first statement printed (for example), 

	Variable 'a' equals 1 and variable 'b' equals 100 .

How can I make it read, instead:

	Variable 'a' equals 1 and variable 'b' equals 100.

Here's the function:

>>> def addnum(a, b):
	print "Variable 'a' equals", a, "and variable 'b' equals", b, "."
	while a <= b:
		print b, "minus variable 'a' equals", b - a
		print "Variable 'a' is added to its own value."
		a = a + a
		print "Variable 'a' now equals", a, "."

Thanks in advance,
Rob


From dyoo@hkn.EECS.Berkeley.EDU  Sat Sep  9 00:38:27 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Fri, 8 Sep 2000 16:38:27 -0700 (PDT)
Subject: [Tutor] simple (fnord) newbie question
In-Reply-To: <39B96D5F.A2C2A033@netdoor.com>
Message-ID: <Pine.LNX.4.21.0009081631130.24647-100000@hkn.EECS.Berkeley.EDU>

On Fri, 8 Sep 2000, R. A. wrote:

> As the following code illustrates, I'm just learning the absolute basics 
> at this point, and I'm trying to pin down a minor detail.  The function 
> performs a couple of simple math formulas, but my question is about the 
> period standing by itself in quotes at the end of a couple of printed 
> statements.

Ah!  Ok, what's happening is when you using the 'print' statement, the
comma adds a space between elements.


> 		print "Variable 'a' now equals", a, "."


Usually, this does the right thing, but if you don't want that space,
you'll need to do something different.  One way to fix this is to
"concatenate" your 'a' with the period.  Strings can be concatenated with
"+".  The obvious way to write this doesn't quite work:

###
>>> a = 10     # just for this example
>>> print "Variable 'a' now equals " + a + "."
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: illegal argument type for built-in operation
###


The reason it's complaining is because string concatenation has to
concatenate only strings --- Strings do not consort with other things.  
To get this to work, we get the value of 'a' as a string:

###
>>> print "Variable 'a' now equals " + str(a) + "."
Variable 'a' now equals 10.
###


I hope this helps!



From midolawton@hotmail.com  Sat Sep  9 18:30:11 2000
From: midolawton@hotmail.com (Mido Lawton)
Date: Sat, 09 Sep 2000 17:30:11 CHAST
Subject: [Tutor] (no subject)
Message-ID: <F2157j1HaKtKufVma0o00008089@hotmail.com>

<html><DIV><FONT face="Arial Black, Geneva, Arial, Sans-serif">well please can you tell me a way to get into the schools computer? (sorry for being so bothering) email: <A href="mailto:midolawton@hotmail.com">midolawton@hotmail.com</A> </FONT></DIV>
<DIV><FONT face="Arial Black">from mido</FONT></DIV><p><hr>Get Your Private, Free E-mail from MSN Hotmail at <a href="http://www.hotmail.com">http://www.hotmail.com</a>.<p>Share information about yourself, create your own public profile at <a href="http://profiles.msn.com">http://profiles.msn.com </a>.<br></p></html>


From yaseentt@yahoo.com  Sat Sep  9 09:03:01 2000
From: yaseentt@yahoo.com (yaseen titi)
Date: Sat, 9 Sep 2000 01:03:01 -0700 (PDT)
Subject: [Tutor] re:is ok
Message-ID: <20000909080301.10365.qmail@web6202.mail.yahoo.com>

confirm 114392



__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/


From Danie Roux <droux@tuks.co.za>  Sat Sep  9 10:52:20 2000
From: Danie Roux <droux@tuks.co.za> (Danie Roux)
Date: Sat, 9 Sep 2000 11:52:20 +0200 (SAST)
Subject: [Tutor] Indenting and multiple developers
Message-ID: <Pine.LNX.4.10.10009091146520.27110-100000@kanagawa.up.ac.za>

Hi all,

I love Python and it lack of brackets.

But now I ran into a problem. My friend absolutely refuse to indent my
way (4), and I refuse to do it his way (3).

And we're working on a single file. Any ideas how to handle these
situations? Aside from tossing a coin, or settling!

Danie



From scarblac@pino.selwerd.nl  Sat Sep  9 19:58:10 2000
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Sat, 9 Sep 2000 20:58:10 +0200
Subject: [Tutor] Indenting and multiple developers
In-Reply-To: <Pine.LNX.4.10.10009091146520.27110-100000@kanagawa.up.ac.za>; from s9806673@student.up.ac.za on Sat, Sep 09, 2000 at 11:52:20AM +0200
References: <Pine.LNX.4.10.10009091146520.27110-100000@kanagawa.up.ac.za>
Message-ID: <20000909205810.A21002@pino.selwerd.nl>

On Sat, Sep 09, 2000 at 11:52:20AM +0200, Danie Roux wrote:
> I love Python and it lack of brackets.
> 
> But now I ran into a problem. My friend absolutely refuse to indent my
> way (4), and I refuse to do it his way (3).
> 
> And we're working on a single file. Any ideas how to handle these
> situations? Aside from tossing a coin, or settling!

Use a tab (a real '\t') and set your editor's tab stops the way you want
to see them.

But of course, settle. If you can't even agree on this, naming of variables
etc will be hell :)

It *is* legal to use different indentation inside the same file, btw. Only a
single block needs to be indented consistently.

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


From tim_one@email.msn.com  Sat Sep  9 20:46:54 2000
From: tim_one@email.msn.com (Tim Peters)
Date: Sat, 9 Sep 2000 15:46:54 -0400
Subject: [Tutor] Indenting and multiple developers
In-Reply-To: <Pine.LNX.4.10.10009091146520.27110-100000@kanagawa.up.ac.za>
Message-ID: <LNBBLJKPBEHFEDALKOLCOECFHFAA.tim_one@email.msn.com>

[Danie Roux]
> I love Python and it lack of brackets.

Good!  Python loves you back.

> But now I ran into a problem. My friend absolutely refuse to indent my
> way (4), and I refuse to do it his way (3).
>
> And we're working on a single file. Any ideas how to handle these
> situations? Aside from tossing a coin, or settling!

Get a new friend <wink> -- life is too short to argue about stuff like this.
The language's designer recommends using 4-space indents, and no hard tab
characters (indeed, Python code using any other convention is not accepted
for the std distribution):

    http://www.python.org/doc/essays/styleguide.html

Just do the stuff recommended, and you'll save tons of other useless debates
down the road.  Guido is called Python's Benevolent Dictator for Life (BDFL)
because if you *don't* do what he says, he'll come to your house at 4AM and
tickle you in your sleep!

you-think-that's-funny-now-but-just-wait<wink>-ly y'rs  - tim




From Paul Yachnes" <paul.yachnes@netzero.net  Sun Sep 10 00:55:44 2000
From: Paul Yachnes" <paul.yachnes@netzero.net (Paul Yachnes)
Date: Sat, 9 Sep 2000 19:55:44 -0400
Subject: [Tutor] My first program
Message-ID: <005401c01ab9$88eed7c0$8bd4f4d1@safwan>

This is a multi-part message in MIME format.

------=_NextPart_000_004D_01C01A97.F0D74EC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

I am trying to write a program that takes a text file (it prompts you for
the file name)  and creates a new file (adding a .ent extension) with the
same text , but converting ANSI characters to character entites. This almost
works, but it seems only to convert the even numbered lines in the file. Is
this because "oldfile.readline()" is called twice in my control loop? If so,
how do I avoid this? Could someone please take a look at this for me (file
attached). Thank you.

Paul Yachnes

P.S. I realize someone has probably already written a program like this, but
it is still a great learning experience for me.






------=_NextPart_000_004D_01C01A97.F0D74EC0
Content-Type: text/plain;
	name="ansi2ent.py"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="ansi2ent.py"

import string
print 'THIS PROGRAM CONVERTS ANSI CHARACTERS TO CHARACTER ENTITIES.\n'
file =3D raw_input('Please enter name of file to convert: ')
oldfile =3D open(file, 'r')
newfile =3D open(file + '.ent', 'w')
dict =3D {'=91':'&lsquo;', '=92':'&rsquo;', '=A1':'&iexcl;', =
'=A2':'&cent;', '=A3':'&pound;', '=A4':'&curren;',
'=A5':'&yen;', '=A6':'&brvbar;', '=A7':'&sect;', '=A8':'&uml;', =
'=A9':'&copy;', '=AA':'&ordf;', '=AB':'&laquo;',=20
'=AC':'&not;', '=AD':'&shy;', '=AE':'&reg;', '=AF':'&macr;', =
'=B0':'&deg;', '=B1':'&plusmn;', '=B2':'&sup2;',=20
'=B3':'&sup3;', '=B4':'&;acute', '=B5':'&;micro', '=B6':'&;para', =
'=B7':'&;middot', '=B8':'&;cedil',=20
'=B9':'&;sup1', '=BA':'&ordm;', '=BB':'&raquo;', '=BC':'&frac14;', =
'=BD':'&frac12;', '=BE':'&frac34;',=20
'=BF':'&iquest;', '=C0':'&Agrave;', '=C1':'&Aacute;', '=C2':'&Acirc;', =
'=C3':'&Atilde;', '=C4':'&Auml;',=20
'=C5':'&Aring;', '=C6':'&AElig;', '=C7':'&Ccedil;', '=C8':'&Egrave;', =
'=C9':'&Eacute;', '=CA':'&Ecirc;',=20
'=CB':'&Euml;', '=CC':'&Igrave;', '=CD':'&Iacute;', '=CE':'&Icirc;', =
'=CF':'&Iuml;', '=D0':'&ETH;',=20
'=D1':'&Ntilde;', '=D2':'&Ograve;', '=D3':'&Oacute;', '=D4':'&Ocirc;', =
'=D5':'&Otilde;', '=D6':'&Ouml;',=20
'=D7':'&times;', '=D8':'&Oslash;', '=D9':'&Ugrave;', '=DA':'&Uacute;', =
'=DB':'&Ucirc;', '=DC':'&Uuml;',=20
'=DD':'&Yacute;', '=DE':'&THORN;', '=DF':'&szlig;', '=E0':'&agrave;', =
'=E1':'&aacute;', '=E2':'&acirc;',=20
'=E3':'&atilde;', '=E4':'&auml;', '=E5':'&aring;', '=E6':'&aelig;', =
'=E7':'&ccedil;',  '=E8':'&egrave;',=20
'=E9':'&eacute;', '=EA':'&ecirc;', '=EB':'&euml;', '=EC':'&igrave;', =
'=ED':'&iacute;', '=EE':'&icirc;',=20
'=EF':'&iuml;', '=F0':'&eth;', '=F1':'&ntilde;', '=F2':'&ograve;', =
'=F3':'&oacute;', '=F4':'&ocirc;',=20
'=F5':'&otilde;', '=F6':'&ouml;', '=F7':'&divide;', '=F8':'&oslash;', =
'=F9':'&ugrave;', '=FA':'&uacute;',=20
'=FB':'&ucirc;', '=FC':'&uuml;', '=FD':'&yacute;', '=FE':'&thorn;', =
'=FF':'&yuml;'}
list =3D dict.items()
while oldfile.readline() !=3D "":
    line =3D oldfile.readline()
    newline =3D string.replace(line, '&', '&amp;')
    for x, y in list:
        newline =3D string.replace(newline, x, y)
    newfile.write(newline)
oldfile.close()=09
newfile.close()
------=_NextPart_000_004D_01C01A97.F0D74EC0--

_______________________________________________
Why pay for something you could get for free?
NetZero provides FREE Internet Access and Email
http://www.netzero.net/download/index.html


From dyoo@hkn.EECS.Berkeley.EDU  Sun Sep 10 01:46:22 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Sat, 9 Sep 2000 17:46:22 -0700 (PDT)
Subject: [Tutor] My first program
In-Reply-To: <005401c01ab9$88eed7c0$8bd4f4d1@safwan>
Message-ID: <Pine.LNX.4.21.0009091732500.13282-100000@hkn.EECS.Berkeley.EDU>

On Sat, 9 Sep 2000, Paul Yachnes wrote:

> I am trying to write a program that takes a text file (it prompts you for
> the file name)  and creates a new file (adding a .ent extension) with the
> same text , but converting ANSI characters to character entites. This almost
> works, but it seems only to convert the even numbered lines in the file. Is
> this because "oldfile.readline()" is called twice in my control loop? If so,
> how do I avoid this? Could someone please take a look at this for me (file
> attached). Thank you.

Yes, it's because readline() is being called twice; this causes your
program to skip the conversion of every other line.  Let's take a look at
your loop:

###
while oldfile.readline() != "":
    line = oldfile.readline()
    newline = string.replace(line, '&', '&amp;')
    for x, y in list:
        newline = string.replace(newline, x, y)
    newfile.write(newline)
###


One way to avoid this skipping is to use a 'for/in' style loop with
readlines().  Like this:

###
for line in oldfile.readlines():
    newline = string.replace(line, '&', '&amp;')
    for x, y in list:
        newline = string.replace(newline, x, y)
    newfile.write(newline)
###

It makes the loop more concise, and it's a nice way of writing the loop.  
"For every line in your oldfile, write a newline into the newfile."  If
you can't grab all the lines at once because of memory constraints...
hmm... I guess you could do something like:

###
line = oldfile.readline()
while line != "":
   # same stuff as before, but make the line-reading
   # the last action of the loop.
   line = oldfile.readline()
###

which avoids the skipping problem, at the cost of some verbosity.


> P.S. I realize someone has probably already written a program like this, but
> it is still a great learning experience for me.

That's ok --- it's good that you're writing useful programs, unlike me.  
*grin* If you polish it up, you can send it off to the Vaults of Parnassus
as a 3rd party module.  I don't think I saw an ANSI converter there:

    http://www.vex.net/parnassus

Good luck to you!



From david@verso.org  Sun Sep 10 02:34:14 2000
From: david@verso.org (David Maclagan)
Date: Sun, 10 Sep 2000 11:34:14 +1000
Subject: [Tutor] Is this me or is it something odd in tkInter?
Message-ID: <39BB71B6.9638.2DFA93@localhost>

I'm trying to use some of the prepackaged dialogs that tkinter comes 
with, specifically askopenfile in tkFileDialog.py, and get the following 
error:
_____________________
Traceback (innermost last):
  File "C:\PROGRA~1\PYTHON\TOOLS\IDLE\ScriptBinding.py", line 
131, in run_module_event
    execfile(filename, mod.__dict__)
  File "C:/Program Files/Python/tests/toygui2.py", line 12, in ?
    filemenu.add_command(label="Open", command = openfile())
  File "C:/Program Files/Python/tests/toygui2.py", line 7, in openfile
    filename = tkFileDialog.askopenfilename()
  File "C:\Program Files\Python\Lib\lib-tk\tkFileDialog.py", line 74, in 
askopenfilename
    return apply(Open, (), options).show()
  File "C:\Program Files\Python\Lib\lib-tk\tkCommonDialog.py", line 
49, in show
    w = Frame(self.master)
  File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1406, in 
__init__
    Widget.__init__(self, master, 'frame', cnf, {}, extra)
  File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1084, in 
__init__
    self.tk.call(
TclError: can't invoke "frame" command:  application has been 
destroyed
-------------------

The program that's generating this is:
(well, okay, there was originally more to it, but I hacked it back to 
the smallest I could, and still got the same problem.)

-----------
from Tkinter import *
import tkFileDialog

root=Tk()

def openfile():
    filename = tkFileDialog.askopenfilename()

menubar = Menu(root)

filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Open", command = openfile())
# display the menu
root.config(menu=menubar)

frame = Frame(root)

frame.pack()

root.mainloop()
--------------------

Am I making a (or some) fundamental error(s)?

I'm using IDLE 0.4, and python 1.5.2 on a win98 system

David



-------
David Maclagan
David@verso.org


From dyoo@hkn.EECS.Berkeley.EDU  Sun Sep 10 09:30:16 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Sun, 10 Sep 2000 01:30:16 -0700 (PDT)
Subject: [Tutor] help!
In-Reply-To: <LPBBIKILAMKMODGHMKFEKEDHCEAA.lee.hunter@hum.com>
Message-ID: <Pine.LNX.4.21.0009091836130.14151-100000@hkn.EECS.Berkeley.EDU>

On Wed, 6 Sep 2000, Lee Hunter wrote:

> > Daniel Yoo wrote:
> 
> > Also, if you want, we can suggest sample problems for you to try out, to
> > solidify your knowledge of Python.  Tell us more about your interests ---
> 
> Actually, I've been looking for some sample problems. Any suggestions would
> be much appreciated.

Dear Lee,

I ran into a document that talked about a comparison between popular
computer languages.  As a benchmark, the author asked many people to write
a "Phonecode" program that would transform a telephone number into a set
of all legal words from a large dictionary.

The contest was over by the time I heard of it, but I thought, "What the
heck, why not?"  It was a hard program to write, but by the time I
finished, I had my Python syntax down cold.  *grin*

Phonecode is fun to write, and it's nontrivial.  The link to the paper is
here:

    http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.ps.gz



From dyoo@hkn.EECS.Berkeley.EDU  Sun Sep 10 09:36:25 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Sun, 10 Sep 2000 01:36:25 -0700 (PDT)
Subject: [Tutor] My first program (fwd)
Message-ID: <Pine.LNX.4.21.0009091946540.14151-100000@hkn.EECS.Berkeley.EDU>

I'll forward your questions to the other people on tutor@python.org.  
(Someday, I must learn how to get my pine emailer to do the reply-to thing
properly.)

I remember hearing about XML specific stuff for Python.  Supposedly, there
are very good tools to parse XML nicely.  You might want to keep an eye
out for them.

It should be ok to embed the ANSI into your file.  Does anyone else have
experience dealing with ANSI programs?

Good luck with your program.


---------- Forwarded message ----------
Date: Sat, 9 Sep 2000 22:20:09 -0400
From: Paul Yachnes <paul.yachnes@netzero.net>
To: Daniel Yoo <dyoo@hkn.EECS.Berkeley.EDU>
Subject: Re: [Tutor] My first program

Daniel,

Thank you for your quick reply. I had tried the first suggestion using a for
loop, beginning:

for line in oldfile.readlines():

but had left in the following line:

line = oldfile.readline()

so of course it didn't work. I don't know why I made this mistake; this loop
is really a lot like my second loop.

I want to be able to use this program on extremely large XML files, and I
was a bit concerned with using the readlines() method. So I am very happy to
see your second suggestion which I will try if I run into memory problems.
Thanks again. With help like this, I'm much more hopeful about being able to
learn this stuff "on my own."

As far as sending it off to the Vaults of Parnassus, I have some questions
about its general usefulness. Since I intended it to process XML, I left out
the characters that can be displayed without problem by Web browsers (I may
add a few more), and I also left out angle brackets, "<" and" >", since you
wouldn't want to convert these in your XML document. So people would need to
be aware of this. Also, is it legitimate to use the actual ANSI
characters
in the program (i.e. is this a legitimate cross-platform approach) or should
I be referring to them by number (how do you do this in Python)? If you have
any thoughts on this, I'd greatly appreciate it!

Paul



From ankban4@indya.com  Sun Sep 10 10:23:26 2000
From: ankban4@indya.com (ankban4@indya.com)
Date: Sun, 10 Sep 2000 14:53:26 +0530
Subject: [Tutor] reading strings
Message-ID: <63496BD96C684D1178A30005B823A263@ankban4.indya.com>

Hi,
    I am new to python (1 day).I have downloaded the python for 
windows platform ver 1.5. Well i was tinkering around with it for 
some time reading the tutorial that came along with it . Well , i 
couldnt figure out 1 thing . How do i input  strings in python?
In other words what is the python equivalent of the followig piece of 
code :-
print "Whats your name?";#perl code
$name=<STDIN>;
chomp($name);
****************************************
print "Whats your name?"; /* C code */
gets(name);/* name[10] defined earlier */

i  tried with input but with no success.
Thanks for answering a newbie question.
ankur


Enter your default signature here
Sent by Indya Messaging Service


From richard_chamberlain@ntlworld.com  Sun Sep 10 11:13:29 2000
From: richard_chamberlain@ntlworld.com (Richard Chamberlain)
Date: Sun, 10 Sep 2000 11:13:29 +0100
Subject: [Tutor] reading strings
References: <63496BD96C684D1178A30005B823A263@ankban4.indya.com>
Message-ID: <001701c01b0f$c4a23cc0$c7e9ff3e@richardc>

Hi Ankur,

Probably something like:

name=raw_input("What's your name? ");
print name

Richard
----- Original Message ----- 
From: <ankban4@indya.com>
To: <tutor@python.org>
Sent: Sunday, September 10, 2000 10:23 AM
Subject: [Tutor] reading strings


> Hi,
>     I am new to python (1 day).I have downloaded the python for 
> windows platform ver 1.5. Well i was tinkering around with it for 
> some time reading the tutorial that came along with it . Well , i 
> couldnt figure out 1 thing . How do i input  strings in python?
> In other words what is the python equivalent of the followig piece of 
> code :-
> print "Whats your name?";#perl code
> $name=<STDIN>;
> chomp($name);
> ****************************************
> print "Whats your name?"; /* C code */
> gets(name);/* name[10] defined earlier */
> 
> i  tried with input but with no success.
> Thanks for answering a newbie question.
> ankur
> 
> 
> Enter your default signature here
> Sent by Indya Messaging Service
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor



From genius@idirect.com  Sun Sep 10 17:02:31 2000
From: genius@idirect.com (Charles Takacs)
Date: Sun, 10 Sep 2000 12:02:31 -0400
Subject: [Tutor] reading strings
References: <63496BD96C684D1178A30005B823A263@ankban4.indya.com>
Message-ID: <39BBB097.C93101DC@idirect.com>

ankban4@indya.com wrote:
> 
> Hi,
>     I am new to python (1 day).I have downloaded the python for
> windows platform ver 1.5. Well i was tinkering around with it for
> some time reading the tutorial that came along with it . Well , i
> couldnt figure out 1 thing . How do i input  strings in python?
> In other words what is the python equivalent of the followig piece of
> code :-
> print "Whats your name?";#perl code
> $name=<STDIN>;
> chomp($name);
> ****************************************
> print "Whats your name?"; /* C code */
> gets(name);/* name[10] defined earlier */
> 
> i  tried with input but with no success.
> Thanks for answering a newbie question.
> ankur
> 
> Enter your default signature here
> Sent by Indya Messaging Service
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

If you really looked into the Tutorial, you could have very easily found
the answer.  It's very clear about the difference between "Input and
Raw_input".
Here is your answer:

name=raw_input("What's your name? ");
print name

You should look it some of the other Tutorials found on the Python.org
website. I am sure you will find them very beneficial.

BTY: According to my experience as a Newbie; The Python gurus treat us
very well, however they do expect so demonstration of initiatives.

Best regards
Charles


From dyoo@uclink4.berkeley.edu  Sun Sep 10 20:26:28 2000
From: dyoo@uclink4.berkeley.edu (Danny Yoo)
Date: Sun, 10 Sep 2000 12:26:28 -0700 (PDT)
Subject: [Tutor] reading strings
In-Reply-To: <63496BD96C684D1178A30005B823A263@ankban4.indya.com>
Message-ID: <Pine.LNX.4.21.0009101214360.10928-100000@c82114-a.pinol1.sfba.home.com>

>     I am new to python (1 day).I have downloaded the python for 
> windows platform ver 1.5. Well i was tinkering around with it for 
> some time reading the tutorial that came along with it . Well , i 
> couldnt figure out 1 thing . How do i input  strings in python?
> In other words what is the python equivalent of the followig piece of 
> code :-
> print "Whats your name?";#perl code
> $name=<STDIN>;
> chomp($name);

There are two methods that allow easy input, input() and raw_input().  
What makes input() different is that it will try to evaluate whatever you
type in.  For example:

###
>>> x = input("Please enter a number: ")
Please enter a number: 42
>>> type(x)
<type 'int'>
###


On the other hand, raw_input() will leave what you type untouched --- it
will just be a string.

###
>>> x = raw_input("Please enter a number: ")
Please enter a number: 42
>>> type(x)
<type 'string'>
###


It's very strange, though, that the tutorial doesn't obviously mention
input() or raw_input()!  I did a quick scan-through, and nothing stood out
to me either.



Also, you can grab at the stdin filehandle to do input.  In Python, this
is exposed as an object with methods such as readline().  The code closest
in spirit to your perl is below:

###
>>> from sys import stdin
>>> line = stdin.readline()
Hello, this is a test.
>>> print line
Hello, this is a test.

# note, there's a trailing '\n' there.  We use string.strip to 'chomp'.
>>> from string import strip
>>> print strip(line)
Hello, this is a test.
###




From michaelbaker@operamail.com  Mon Sep 11 06:50:46 2000
From: michaelbaker@operamail.com (michaelbaker@operamail.com)
Date: Sun, 10 Sep 2000 22:50:46 -0700
Subject: [Tutor] random numbers
In-Reply-To: <20000910160105.D5C581D03E@dinsdale.python.org>
Message-ID: <4.3.2.7.1.20000910223158.00b3a100@operamail.com>

I'm using Python in the freeware 3D package called Blender 
(http://www.blender.nl). I have a script that evaluates the movement of one 
object and attempts to generate matching animation curves. I'd like to add 
some non-pseudo randomness. can Python access bios info like CPU speed and 
temp or time and date - or what about getting weather info from 
http://www.weather.com or other http data? other suggestions appreciated. 
I'm happy to post the .blend file for any Blender users out there.

mb



From jstok@bluedog.apana.org.au  Mon Sep 11 07:20:15 2000
From: jstok@bluedog.apana.org.au (Jason Stokes)
Date: Mon, 11 Sep 2000 17:20:15 +1100
Subject: [Tutor] random numbers
References: <4.3.2.7.1.20000910223158.00b3a100@operamail.com>
Message-ID: <39BC799F.A6F486CE@bluedog.apana.org.au>

michaelbaker@operamail.com wrote:
> 
> I'm using Python in the freeware 3D package called Blender
> (http://www.blender.nl). I have a script that evaluates the movement of one
> object and attempts to generate matching animation curves. I'd like to add
> some non-pseudo randomness.

If you're on Linux, you can read in true random numbers from the special
device /dev/rand and psuedorandom numbers from the special device
/dev/urand.  There's also the "random" module in the standard python
distribution.  Getting data from a website -- www.random.net, for
example -- is also perfectly doable with some HTTP scripting.

Cheers,
Jason Stokes: jstok@bluedog.apana.org.au


From Danie Roux <droux@tuks.co.za>  Mon Sep 11 09:19:15 2000
From: Danie Roux <droux@tuks.co.za> (Danie Roux)
Date: Mon, 11 Sep 2000 10:19:15 +0200 (SAST)
Subject: [Tutor] Indenting and multiple developers
In-Reply-To: <LNBBLJKPBEHFEDALKOLCOECFHFAA.tim_one@email.msn.com>
Message-ID: <Pine.LNX.4.10.10009111014280.13265-100000@kanagawa.up.ac.za>

> > But now I ran into a problem. My friend absolutely refuse to indent my
> > way (4), and I refuse to do it his way (3).
> >
> > And we're working on a single file. Any ideas how to handle these
> > situations? Aside from tossing a coin, or settling!
> 
> Get a new friend <wink> -- life is too short to argue about stuff like this.

We have been arguing about this from 5 years back when we started to do
Pascal at school! I guess it only became a problem with Python

> The language's designer recommends using 4-space indents, and no hard tab
> characters (indeed, Python code using any other convention is not accepted
> for the std distribution):
 

>     http://www.python.org/doc/essays/styleguide.html

Thank you for this!
 
> Just do the stuff recommended, and you'll save tons of other useless debates
> down the road.  Guido is called Python's Benevolent Dictator for Life (BDFL)
> because if you *don't* do what he says, he'll come to your house at 4AM and
> tickle you in your sleep!
 
Luckily I was (and will be) awake at that time these coming weeks. :-)
 

Actually I just decided bugger it, all of us can indent as we want. And
work on different blocks of code with different indents. But when we
release, I'll just run a vim macro/Python script through it.

Danie.



From KOOL1234@email.msn.com  Tue Sep 12 04:50:22 2000
From: KOOL1234@email.msn.com (Wylie)
Date: Mon, 11 Sep 2000 20:50:22 -0700
Subject: [Tutor] (no subject)
Message-ID: <000101c01c6c$957396c0$20da0f3f@computer>

please ad goboom@hackermail.com to your list





From FxItAL@aol.com  Tue Sep 12 14:14:10 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Tue, 12 Sep 2000 09:14:10 EDT
Subject: [Tutor] Threading
Message-ID: <b3.6d927a.26ef8622@aol.com>

Hello,

From the advice I've receieved, it has become apparent that I need to 
incorporate threading into my program.  I have no formal programming training 
and need the basics on this subject and on classes.  I've read "The Quick 
Python" book and was moving along quite well until this point.  I'm just 
looking for a good referance book.

Thanks to all the Python Tutors for their patience.
Al


From dyoo@hkn.EECS.Berkeley.EDU  Tue Sep 12 16:37:36 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Tue, 12 Sep 2000 08:37:36 -0700 (PDT)
Subject: [Tutor] Threading
In-Reply-To: <b3.6d927a.26ef8622@aol.com>
Message-ID: <Pine.LNX.4.21.0009120741260.9790-100000@hkn.EECS.Berkeley.EDU>

On Tue, 12 Sep 2000 FxItAL@aol.com wrote:

> >From the advice I've receieved, it has become apparent that I need to 
> incorporate threading into my program.  I have no formal programming training 
> and need the basics on this subject and on classes.  I've read "The Quick 
> Python" book and was moving along quite well until this point.  I'm just 
> looking for a good referance book.

The "Python Essential Reference" by David Beazley is very good as a
general Python reference.  It has concise examples and is easy to hold in
one's hand.  *grin*



From pinbal@cfl.rr.com  Wed Sep 13 05:47:56 2000
From: pinbal@cfl.rr.com (Pinbal)
Date: Wed, 13 Sep 2000 00:47:56 -0400
Subject: [Tutor] Python
Message-ID: <003001c01d3d$cb0fe140$52cb8118@cfl.rr.com>

They say your never to old to learn. Well, here I am to prove it one way or
the other.
Greg



From dyoo@uclink4.berkeley.edu  Wed Sep 13 08:03:43 2000
From: dyoo@uclink4.berkeley.edu (Danny Yoo)
Date: Wed, 13 Sep 2000 00:03:43 -0700 (PDT)
Subject: [Tutor] Python
In-Reply-To: <003001c01d3d$cb0fe140$52cb8118@cfl.rr.com>
Message-ID: <Pine.LNX.4.21.0009130002410.25186-100000@c82114-a.pinol1.sfba.home.com>

On Wed, 13 Sep 2000, Pinbal wrote:

> They say your never to old to learn. Well, here I am to prove it one way or
> the other.

That's the spirit!  *grin*

What questions do you have in particular?  If you're just starting out
learning Python, you've come to the right place.



From wbateman@epicrealm.com  Wed Sep 13 21:42:11 2000
From: wbateman@epicrealm.com (Wes Bateman)
Date: Wed, 13 Sep 2000 15:42:11 -0500 (CDT)
Subject: [Tutor] open/closing files and system limits
Message-ID: <Pine.LNX.4.21.0009131530220.1184-100000@jackwebb.wesnetworks.com>

Hello all:

I've got a small python script that rapidly opens a file, reads the lines
and closes the file.  This procedure is in a for loop.

for file in catalogoffilestoprocess.readlines():
	currentfile = open(file[:-1]) # Only way I could figure to strip
					newline from filename
	for line in currentfile.readlines():
		if blah
			blah
		elif blah
			blah
	currentfile.close()


Well that works alright except for this.  My list of files contains about
1100 files to process.  It takes an extraordinary amount of time to
run.  Watching it work, I can see that it rushes through a couple hundred,
stops for several (i.e. 1-4) minutes, then continues.

I believe it has something to do with the default file limits set in my
kernel (Linux).  I was thinking that the system wasn't keeping track of
the fact that the files were closed?  Somehow hitting that system ceiling?

Also running "time ./script catalogoffiles"
returns (look at the time elapsed!  also just now noticed the pagefault
and swap info, but am not familiar with time's output or what this
indicates).

463.40user 8.89system 8:05.39elapsed 97%CPU (0avgtext+0avgdata 
0maxresident)k
0inputs+0outputs (11017major+100694minor)pagefaults 1556swaps


Any ideas?

Thanks :)

Wes



From Skais03@aol.com  Wed Sep 13 21:38:52 2000
From: Skais03@aol.com (Skais03@aol.com)
Date: Wed, 13 Sep 2000 16:38:52 EDT
Subject: [Tutor] tutor
Message-ID: <ba.ad80b2f.26f13fdc@aol.com>

help for newbie


From wbateman@epicrealm.com  Wed Sep 13 22:20:21 2000
From: wbateman@epicrealm.com (Wes Bateman)
Date: Wed, 13 Sep 2000 16:20:21 -0500 (CDT)
Subject: [Tutor] reading strings
In-Reply-To: <Pine.LNX.4.21.0009101214360.10928-100000@c82114-a.pinol1.sfba.home.com>
Message-ID: <Pine.LNX.4.21.0009131618180.1184-100000@jackwebb.wesnetworks.com>

Ooh, string.strip  Well that resolves my newline issues which I was
inelegantly hacking around by slicing off the \012

Cool :)  Sorry I didn't catch up on my e-mail reading before I sent my
last post :)  I still am puzzled by the performance part of my
other question though.

Wes

On Sun, 10 Sep 2000, Danny Yoo wrote:
> 
> # note, there's a trailing '\n' there.  We use string.strip to 'chomp'.
> >>> from string import strip
> >>> print strip(line)
> Hello, this is a test.
> ###



From arcege@shore.net  Wed Sep 13 22:39:54 2000
From: arcege@shore.net (Michael P. Reilly)
Date: Wed, 13 Sep 2000 17:39:54 -0400 (EDT)
Subject: [Tutor] open/closing files and system limits
In-Reply-To: <Pine.LNX.4.21.0009131530220.1184-100000@jackwebb.wesnetworks.com> from "Wes Bateman" at Sep 13, 2000 03:42:11 PM
Message-ID: <200009132139.RAA28950@northshore.shore.net>

> 
> Hello all:
> 
> I've got a small python script that rapidly opens a file, reads the lines
> and closes the file.  This procedure is in a for loop.
> 
> for file in catalogoffilestoprocess.readlines():
>     currentfile = open(file[:-1]) # Only way I could figure to strip
>                                     newline from filename
>     for line in currentfile.readlines():
>         if blah
>             blah
>         elif blah
>             blah
>     currentfile.close()
> 
> 
> Well that works alright except for this.  My list of files contains about
> 1100 files to process.  It takes an extraordinary amount of time to
> run.  Watching it work, I can see that it rushes through a couple hundred,
> stops for several (i.e. 1-4) minutes, then continues.
> 
> I believe it has something to do with the default file limits set in my
> kernel (Linux).  I was thinking that the system wasn't keeping track of
> the fact that the files were closed?  Somehow hitting that system ceiling?
> 
> Also running "time ./script catalogoffiles"
> returns (look at the time elapsed!  also just now noticed the pagefault
> and swap info, but am not familiar with time's output or what this
> indicates).
> 
> 463.40user 8.89system 8:05.39elapsed 97%CPU (0avgtext+0avgdata 
> 0maxresident)k
> 0inputs+0outputs (11017major+100694minor)pagefaults 1556swaps
> 

I think this is in the FAQ somewhere as a performance problem.  There
are a few solutions, but my "favorite" is:
  for lines in catalog.readlines(8192):  # get a "block" of lines
    for line in lines:
      file = open(line[:-1])
      ...

This reads a disk block, breaks it into lines (leaving the left over
for the next read), and returns those lines; then you can iterate
through that set of lines, until the outer loop returns no lines left.

You can think of the break down as:
  Block  0  line 0
            line 1
            line 2
            line 3
            line 4
            line 5
  Block 1   line 6
            line 7
            long line 8
            part of line 9
  Block 2   rest of line 9 (returned in third call to catalog.readlines)
            line 10
            line 11
            line 12
            line 13
  Block 3   line 14

I hope this helps.

  -Arcege

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


From wbateman@epicrealm.com  Wed Sep 13 23:52:01 2000
From: wbateman@epicrealm.com (Wes Bateman)
Date: Wed, 13 Sep 2000 17:52:01 -0500 (CDT)
Subject: [Tutor] open/closing files and system limits
In-Reply-To: <200009132139.RAA28950@northshore.shore.net>
Message-ID: <Pine.LNX.4.21.0009131746150.1907-100000@jackwebb.wesnetworks.com>

Thanks for the help :)  That's interesting.  I set the (8192) after
readlines and it came back in .3 seconds.  It didn't do all of the files
in the list though.  It did the first 146 items, then stopped.  I
experimented with numbers other than 8192 and it always stopped in the
same place.  :( ?  I don't get it.  I didn't see reference to this in the
FAQ either, I'd like to read more about it though.

My catalog file is just under 1100 lines and each file it parses is approx
36 lines long.  The blocksize (or whatever that is called) in the
parentheses makes a HUGE performance difference, but I'm not understanding
why it doesn't complete the whole job.

Thanks for any additional insight :)

Wes

On Wed, 13 Sep 2000, Michael P. Reilly wrote:
<SNIP>
> 
> I think this is in the FAQ somewhere as a performance problem.  There
> are a few solutions, but my "favorite" is:
>   for lines in catalog.readlines(8192):  # get a "block" of lines
>     for line in lines:
>       file = open(line[:-1])
>       ...
> 
>   -Arcege
> 
> 



From midolawton@hotmail.com  Thu Sep 14 14:58:12 2000
From: midolawton@hotmail.com (Mido Lawton)
Date: Thu, 14 Sep 2000 13:58:12 CHAST
Subject: [Tutor] (no subject)
Message-ID: <F118Ff70DQLGJZGT9KP000035f4@hotmail.com>

<html><DIV><FONT face="Arial Black, Geneva, Arial, Sans-serif">Is any one working on my request??</FONT></DIV>
<DIV><FONT face="Arial Black">email me at <A href="mailto:midolawton@hotmail.com">midolawton@hotmail.com</A> </FONT></DIV><p><hr>Get Your Private, Free E-mail from MSN Hotmail at <a href="http://www.hotmail.com">http://www.hotmail.com</a>.<p>Share information about yourself, create your own public profile at <a href="http://profiles.msn.com">http://profiles.msn.com </a>.<br></p></html>


From dyoo@hkn.EECS.Berkeley.EDU  Thu Sep 14 06:03:34 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Wed, 13 Sep 2000 22:03:34 -0700 (PDT)
Subject: [Tutor] (no subject)
In-Reply-To: <F118Ff70DQLGJZGT9KP000035f4@hotmail.com>
Message-ID: <Pine.LNX.4.21.0009132201390.7047-100000@hkn.EECS.Berkeley.EDU>

On Thu, 14 Sep 2000, Mido Lawton wrote:

> Is any one working on my request??
> email me at midolawton@hotmail.com

Mido, I'm sorry, we don't have any expertise in getting into computer
systems.  I don't think anyone else on the list can help either.



From Isaac@compuserve.com  Thu Sep 14 06:17:35 2000
From: Isaac@compuserve.com (Isaac)
Date: Wed, 13 Sep 2000 22:17:35 -0700
Subject: [Tutor] spawnve env path updates not getting passed
Message-ID: <39C05F6F.47BCE8E9@compuserve.com>

in python 1.5.2 on windows98, is there a problem with spawnve?

I'm passing a modified os.environ:

  os.environ['PATH']=os.environ['PATH']+";c:\\cps_prod\\bin"

retVal = os.spawnve( os.P_WAIT, "mybatchfile.bat", self.args, os.environ
)

the args DO contain as the first item the "mybatchfile.bat".

The path looks right when I display it, but when I pass it to the
os.spawnve, the programs in the directory I've added to the path aren't
found.  (The file mybatchfile.bat DOES run, but all programs it calls
that are in the "cps_prod\bin" directory are not found.

There are workarounds: I could put the directory in the path command in
autoexec.bat on every cpu that needs to run this.  I could make the
batch files cd to the directories.  Neither are preferred solutions:
Why isn't the path getting passed with the environment?

Thanks!

Best,
Isaac




From The Majestic Moined Mogul" <mogul@primus.ca  Thu Sep 14 10:55:02 2000
From: The Majestic Moined Mogul" <mogul@primus.ca (The Majestic Moined Mogul)
Date: Thu, 14 Sep 2000 05:55:02 -0400
Subject: [Tutor] (no subject)
Message-ID: <001701c01e31$da3dfc20$621aa7d1@v1o9g4>

This is a multi-part message in MIME format.

------=_NextPart_000_0014_01C01E10.52A61520
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

subscribe

------=_NextPart_000_0014_01C01E10.52A61520
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>subscribe</FONT></DIV></BODY></HTML>

------=_NextPart_000_0014_01C01E10.52A61520--



From phil.bertram@clear.net.nz  Thu Sep 14 22:40:17 2000
From: phil.bertram@clear.net.nz (Phil Bertram)
Date: Fri, 15 Sep 2000 09:40:17 +1200
Subject: [Tutor] Help with Re to extract fixed width data fields
Message-ID: <000901c01e94$7f313be0$55c6a7cb@pf05>

This is a multi-part message in MIME format.

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

Hi all,

I have data that is of fixed length but with no deliminaters

eg. 3456Customer9878Product    etc etc etc

I have been using a regular expression (in the form as shown below) to =
extract the fields. The real data has over 30 fields so the expression =
is very large.
Is there a better way ?

fields=3Dre.match('(.{4,4})(.{8,8})(.{4,4})(.{7,7})',line,0)=20



Regards
Phil Bertram     phil.bertram@clear.net.nz     07 850 9305     025 426 =
825

------=_NextPart_000_0006_01C01EF8.F519B800
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.3612.1706"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2>Hi all,</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2>I have data that is =
of fixed length=20
but with no deliminaters</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2>eg.=20
3456Customer9878Product&nbsp;&nbsp;&nbsp; etc etc etc</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DVerdana size=3D2>I have been using a regular =
expression (in the=20
form as shown below) to extract the fields. The real data has over 30 =
fields so=20
the expression is very large.</FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2>Is there a better way ?</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DVerdana=20
size=3D2>fields=3Dre.match('(.{4,4})(.{8,8})(.{4,4})(.{7,7})',line,0)=20
<BR></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DVerdana size=3D2>Regards<BR>Phil=20
Bertram&nbsp;&nbsp;&nbsp;&nbsp; <A=20
href=3D"mailto:phil.bertram@clear.net.nz">phil.bertram@clear.net.nz</A>&n=
bsp;&nbsp;&nbsp;&nbsp;=20
07 850 9305&nbsp;&nbsp;&nbsp;&nbsp; 025 426 =
825</FONT></DIV></BODY></HTML>

------=_NextPart_000_0006_01C01EF8.F519B800--



From insyte@emt-p.org  Fri Sep 15 00:25:52 2000
From: insyte@emt-p.org (Ben Beuchler)
Date: Thu, 14 Sep 2000 18:25:52 -0500
Subject: [Tutor] Help with Re to extract fixed width data fields
In-Reply-To: <000901c01e94$7f313be0$55c6a7cb@pf05>; from phil.bertram@clear.net.nz on Fri, Sep 15, 2000 at 09:40:17AM +1200
References: <000901c01e94$7f313be0$55c6a7cb@pf05>
Message-ID: <20000914182551.E22336@emt-p.org>

On Fri, Sep 15, 2000 at 09:40:17AM +1200, Phil Bertram wrote:

> I have data that is of fixed length but with no deliminaters
> 
> eg. 3456Customer9878Product    etc etc etc
> 
> I have been using a regular expression (in the form as shown below) to extract the fields. The real data has over 30 fields so the expression is very large.
> Is there a better way ?
> 
> fields=re.match('(.{4,4})(.{8,8})(.{4,4})(.{7,7})',line,0) 

You say it is always fixed length?  If so, you can use indices
(indexes?) to extract it, like so:

>>> mystring = "3456Customer9878Product"
>>> mystring[4:12]
'Customer'

Very spiffy, fast, and requires no extra modules...

Ben

-- 
Ben Beuchler                                         insyte@bitstream.net
MAILER-DAEMON                                         (612) 321-9290 x101
Bitstream Underground                                   www.bitstream.net

From stever@cfu.net  Sun Sep 17 02:29:53 2000
From: stever@cfu.net (steve)
Date: Sat, 16 Sep 2000 20:29:53 -0500
Subject: [Tutor] sample program
Message-ID: <000a01c02046$c96653e0$abef1dce@cfu.net>

This is a multi-part message in MIME format.

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

Hi=20

I am jerry farrell,  a cs teacher at hawkeye community college in =
waterloo, ia. I am new at python language. I would like to get your =
textbook on Internet programming with python. M&T publishers don't seem =
to carry it any more.  I am also, looking for some samples programs on =
internet programming with python such as socket programming and maybe =
simple chat program, I can show the students.

I appreciate any help you can give me.

Thanks for your time

jerry farrell

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4207.2601" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Hi </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am jerry farrell, &nbsp;a cs =
teacher&nbsp;at=20
hawkeye community college in waterloo, ia. I am new at python language.=20
I&nbsp;would like to get your textbook on Internet programming =
with&nbsp;python.=20
M&amp;T publishers don't seem to carry it any more.&nbsp; I am also, =
looking for=20
some samples programs on internet programming with python such as socket =

programming and maybe simple chat program, I can show the =
students.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I appreciate any help you can give =
me.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your time</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>jerry=20
farrell</FONT></DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_0007_01C0201C.DEFEFD80--


From dyoo@hkn.EECS.Berkeley.EDU  Sun Sep 17 21:47:00 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Sun, 17 Sep 2000 13:47:00 -0700 (PDT)
Subject: [Tutor] sample program
In-Reply-To: <000a01c02046$c96653e0$abef1dce@cfu.net>
Message-ID: <Pine.LNX.4.21.0009171337240.17573-100000@hkn.EECS.Berkeley.EDU>

On Sat, 16 Sep 2000, steve wrote:

> I am jerry farrell, a cs teacher at hawkeye community college in
> waterloo, ia. I am new at python language. I would like to get your
> textbook on Internet programming with python. M&T publishers don't
> seem to carry it any more.  I am also, looking for some samples
> programs on internet programming with python such as socket
> programming and maybe simple chat program, I can show the students.

You may want to look at the reference documentation for the socket stuff
--- I believe that Python provides a nice interface through the socket
module:

http://pythonlabs.com/pub/www.python.org/doc/current/lib/module-socket.html



As a first exercise, you can show them that grabbing URL's as files is
very easy:

>>> import urllib
>>> f = urllib.urlopen("http://www.yahoo.com")
>>> print f.read()
# lots and lots of html output


Python provides an HTML parser to nicely read HTML:

http://pythonlabs.com/pub/www.python.org/doc/current/lib/module-httplib.html


Also, your students can pick an internet protocol from the library
reference, and experiment with it.  The library reference can be found
here:

http://pythonlabs.com/pub/www.python.org/doc/current/lib/lib.html


I'm beginning to read Richard Steven's "Unix Network Programming", so if I
have time, I'll try to cook up a rudimentary chat server.

Good luck to you!


From michaelbaker@operamail.com  Sun Sep 17 22:15:58 2000
From: michaelbaker@operamail.com (michaelbaker@operamail.com)
Date: Sun, 17 Sep 2000 14:15:58 -0700
Subject: [Tutor] parsing html
In-Reply-To: <20000917160145.D850E1CFCA@dinsdale.python.org>
Message-ID: <4.3.2.7.1.20000917140015.00b46570@operamail.com>

>I've tried the docs and searching python.org and I check the tutor 
>archives back to Jan 2000 - I'm trying to write a little program that will 
>select keywords from a dictionary or list and submit them to 
>www.google.com. I can submit and read results from google using urllib and 
>file.read() just fine, but this returns raw html. I'd like to cut through 
>the html I can't get the sgmllib.SGLMParser to work :(. can someone point 
>me to some examples of using sgmllib or suggest another way?  thanks in 
>advance, m baker



From fok@mcrane.co.uk  Mon Sep 18 09:17:38 2000
From: fok@mcrane.co.uk (Finbarr O'Keeffe)
Date: Mon, 18 Sep 2000 09:17:38 +0100
Subject: [Tutor] DCOracle binarys  for python
Message-ID: <01C02151.4B059AE0@FOK>

------ =_NextPart_000_01C02151.4B0EC2A0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Would anyone be able to mail me the binary extensions for the DCOracle =
module for oracle 8.0.5 running on Windows 95? I do not have access to a =
C compiler to generate them myself

Regards

Finbarr O'Keeffe

------ =_NextPart_000_01C02151.4B0EC2A0
Content-Type: application/ms-tnef
Content-Transfer-Encoding: base64

eJ8+IigIAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy
b3NvZnQgTWFpbC5Ob3RlADEIAQ2ABAACAAAAAgACAAEEkAYAiAEAAAEAAAAQAAAAAwAAMAIAAAAL
AA8OAAAAAAIB/w8BAAAAPwAAAAAAAACBKx+kvqMQGZ1uAN0BD1QCAAAAAHR1dG9yQHB5dGhvbi5v
cmcAU01UUAB0dXRvckBweXRob24ub3JnAAAeAAIwAQAAAAUAAABTTVRQAAAAAB4AAzABAAAAEQAA
AHR1dG9yQHB5dGhvbi5vcmcAAAAAAwAVDAEAAAADAP4PBgAAAB4AATABAAAAEwAAACd0dXRvckBw
eXRob24ub3JnJwAAAgELMAEAAAAWAAAAU01UUDpUVVRPUkBQWVRIT04uT1JHAAAAAwAAOQAAAAAL
AEA6AQAAAB4A9l8BAAAAEQAAAHR1dG9yQHB5dGhvbi5vcmcAAAAAAgH3XwEAAAA/AAAAAAAAAIEr
H6S+oxAZnW4A3QEPVAIAAAAAdHV0b3JAcHl0aG9uLm9yZwBTTVRQAHR1dG9yQHB5dGhvbi5vcmcA
AAMA/V8BAAAAAwD/XwAAAAACAfYPAQAAAAQAAAAAAAACMU8BBIABAB0AAABEQ09yYWNsZSBiaW5h
cnlzICBmb3IgcHl0aG9uAD4KAQWAAwAOAAAA0AcJABIACQARACYAAQAzAQEggAMADgAAANAHCQAS
AAkADQAtAAEANgEBCYABACEAAAAxOEVDNENGQjQxOERENDExQTJBQjAwQzBGMDI4Q0E2MAA+BwED
kAYA5AgAACEAAAALAAIAAQAAAAsAIwAAAAAAAwAmAAAAAAALACkAAAAAAAMALgAAAAAAAwA2AAAA
AABAADkA4KQ06EghwAEeAHAAAQAAAB0AAABEQ09yYWNsZSBiaW5hcnlzICBmb3IgcHl0aG9uAAAA
AAIBcQABAAAAFgAAAAHAIUjoE/tM7B2NQRHUoqsAwPAoymAAAB4AHgwBAAAABQAAAFNNVFAAAAAA
HgAfDAEAAAARAAAAZm9rQG1jcmFuZS5jby51awAAAAADAAYQyzm65wMABxCkAAAAHgAIEAEAAABl
AAAAV09VTERBTllPTkVCRUFCTEVUT01BSUxNRVRIRUJJTkFSWUVYVEVOU0lPTlNGT1JUSEVEQ09S
QUNMRU1PRFVMRUZPUk9SQUNMRTgwNVJVTk5JTkdPTldJTkRPV1M5NT9JRE9OTwAAAAACAQkQAQAA
AMYFAADCBQAABA4AAExaRnXcYrlxAwAKAHJjcGcxMjVyMgxgYzEDMAEHC2BukQ4QMDMzDxZmZQ+S
TwH3AqQDYwIAY2gKwHOEZXQC0XBycTIAAJIqCqFubxJQIDAB0IUB0DYPoDA1MDQUIfMB0BQQNH0H
bQKDAFAD1PsR/xMLYhPhFFATshj0FND7BxMV5DYE1ha/EwkUEAEw3jcUgxQQGTYIUG0N4AYEiwXg
FeQ3EY4yMzgblOIgB20gQ0UV5CBRH13nFEAgbyF1eXICgwwBEZ2vGlAWMSO/A4JHCdFrJTTfFjEl
zg5QJu8Dc1QIcCU0uyohJc04GmEqXwOCQgdA/nQN4CU0D8AWXSA4BxMhxv4yI4Ev3SN3MVUlFhpi
Fnv/JqgxVChJHyE1DiomMVQrp38gUTUNLVcxVC7mApEI5jvVCW8wPX9lDjA1Pqo/wf8/f0CJPpRA
sj8fQu9CrUIv/0BfPq8QYDogSHpJkUlPSln/PpRKgkjvTL9MfUv/Si9N9H45DlBRRFKhSsNSoAKC
c6h0eWwHkGgJ4HQAAEMTUAPwZGN0bAqxXGFU+GFkanVUEAUQZ75oBUIaUwwBD1IB0DUfIA5jCcBV
AAMwc25leF8bcAewBbAAwAJzcwBQcyZiMiABQHNhE/Bca/0J4HALkFTfVUMIYFUwC4D6ZVRAdlyg
AUBWOwwwFiP/OiFXl1qABKALgFfAIFBYJvRiYRtQZAIgWOBYhlRw81YwX2EgMVPTDlBZ31rv/1v/
AFFdPACgXhRXf2AvYTj/U8QPwGJfY29kfw5QXS9XL9tn32DtMwKCExBjWaBwoU9WMGGALxBc0CBE
ARBhUnUvACBQCsBhCcBhcHBoIEYCIVlkR+Bm1GktD5A4bwFpdTNrb/VVQ2ILIHIJUHdSFqB3Uux3
NEfhG0BwAdByclZfd27/cA8mkDVzkAUQAjAtK3QwA2E6LdBvfVBTdRRiagWQdH1QRGF0/GU6WWQa
YXUfdi93P3hP/3lXVGBhcw4hcKFudw5Qen+be498llJcwRtBIEhhYf8EkFlkHyF/L4A/gU+CW1xP
L4NfD5CPsAjQYgqwdDj/bl8PkDIhhg98FZBAiBALULx5L3RAglALEYiFc1lk/yBRiY+Kn4uvgl95
X4Vvki/vkz59cn0Ufkk5lg9V3wMwPY/zOZnvmv+G6KGQRG/8Y3UHgAIwBdB0ADyhn8LvnyCfYJeh
AYBufdAAYAnw33KgpJACAVkgg/JlAPCkkCVUIHBBIFx2CJB3a/0LgGQjgKgyBPAHQBBhAUDfDgCX
cmFSqZUCEG8FQhthOxLyfmBtC1F+YCHAOlzqXHygb3PhbXQwAxAHkE2sQE0N4ANgc28BgCAuTwEg
DeCngFyt9kVNgEFJTC5ET1SlYO8bUJ9gWGGNsngBQGFSBJA+eRzwnvCqsrDFCOFzeHuw8qaRblRw
PZCvlHM0Y88DIBLzAIAFkGx2ZXFrMP8OcFkgtBIBkAAgtKKogaTR/wHBtBEbIA9wAABrMAzQAZD8
IC48srQIDlC0wi8An7D/tT+2T7dfD8BrMAWBuP+6D+27H2wjgGswbLi/vX++hT4pt4xH4LxfwT++
dGIg/igCkcJftFMaYMAPxM/F3//G77SAHyDIMrUPyZ/Kr7eM/yBQyD/Nv87Pz9+0gJ7wzL//0k/T
X9RkCvkDMJ8foC+hv2lYBntXCGBsWGAAcHk7AiATgGITgAGgVEAgdPxvIADAAxEHgN8AVHDegPML
gArAeSBYsQnwAJACIMcEIKcB37NEQ09zwLOwfxOABGFzYBOA4SIFsOHjOIguMC58gHJ1bl9SO+LQ
A6BXqIHaEAQgOTXQPyBJIHBwIBNQBUB/GyBy8QDQrjAEEd8RvtBDviAFoKuwrPHhQd8gZwnwTwSQ
q+LfwazAbXkbUGyuZgqFCoWIEGcLEXPo7C+s4KZACsAFwE8AEHF12bFRIEsJ4AEgZQqFPLAEAADt
MAAAAwAQEAAAAAADABEQAAAAAAMAgBD/////QAAHMKCLh11IIcABQAAIMKCLh11IIcABCwAAgAgg
BgAAAAAAwAAAAAAAAEYAAAAAA4UAAAAAAAADAAKACCAGAAAAAADAAAAAAAAARgAAAAAQhQAAAAAA
AAMABYAIIAYAAAAAAMAAAAAAAABGAAAAAFKFAAC3DQAAHgAlgAggBgAAAAAAwAAAAAAAAEYAAAAA
VIUAAAEAAAAEAAAAOC4wAAMAJoAIIAYAAAAAAMAAAAAAAABGAAAAAAGFAAAAAAAACwAvgAggBgAA
AAAAwAAAAAAAAEYAAAAADoUAAAAAAAADADCACCAGAAAAAADAAAAAAAAARgAAAAARhQAAAAAAAAMA
MoAIIAYAAAAAAMAAAAAAAABGAAAAABiFAAAAAAAAHgBBgAggBgAAAAAAwAAAAAAAAEYAAAAANoUA
AAEAAAABAAAAAAAAAB4AQoAIIAYAAAAAAMAAAAAAAABGAAAAADeFAAABAAAAAQAAAAAAAAAeAEOA
CCAGAAAAAADAAAAAAAAARgAAAAA4hQAAAQAAAAEAAAAAAAAAHgA9AAEAAAABAAAAAAAAAAMADTT9
NwAAXqI=

------ =_NextPart_000_01C02151.4B0EC2A0--


From jcm@bigskytel.com  Wed Sep 20 02:39:22 2000
From: jcm@bigskytel.com (David Porter)
Date: Tue, 19 Sep 2000 19:39:22 -0600
Subject: [Tutor] parsing html
In-Reply-To: <4.3.2.7.1.20000917140015.00b46570@operamail.com>; from michaelbaker@operamail.com on Sun, Sep 17, 2000 at 02:15:58PM -0700
References: <20000917160145.D850E1CFCA@dinsdale.python.org> <4.3.2.7.1.20000917140015.00b46570@operamail.com>
Message-ID: <20000919193922.A1762@bigskytel.com>

* michaelbaker@operamail.com <michaelbaker@operamail.com>:
> 
> >I've tried the docs and searching python.org and I check the tutor 
> >archives back to Jan 2000 - I'm trying to write a little program that will 
> >select keywords from a dictionary or list and submit them to 
> >www.google.com. I can submit and read results from google using urllib and 
> >file.read() just fine, but this returns raw html. I'd like to cut through 
> >the html I can't get the sgmllib.SGLMParser to work :(. can someone point 
> >me to some examples of using sgmllib or suggest another way?  thanks in 
> >advance, m baker

The following thread from comp.lang.python includes both explanations and 
examples of using sgmllib and htmllib:

http://x51.deja.com/viewthread.xp?AN=669758132&search=thread&svcclass=dncurrent&ST=PS&CONTEXT=969413393.1966866459&HIT_CONTEXT=969413393.1966866459&HIT_NUM=3&recnum=%3cNQ9w5.346$n4.24503@newsc.telia.net%3e%231/1&group=comp.lang.python&frpage=viewthread.xp&back=clarinet

That is one line.

This example from the effbot would be very easy to alter:

http://www.deja.com/threadmsg_ct.xp?AN=669758132&fmt=text

Right now it extracts the strings from <img src=""> tags.


  David

From jcm@bigskytel.com  Wed Sep 20 02:49:31 2000
From: jcm@bigskytel.com (David Porter)
Date: Tue, 19 Sep 2000 19:49:31 -0600
Subject: [Tutor] sample program
In-Reply-To: <000a01c02046$c96653e0$abef1dce@cfu.net>; from stever@cfu.net on Sat, Sep 16, 2000 at 08:29:53PM -0500
References: <000a01c02046$c96653e0$abef1dce@cfu.net>
Message-ID: <20000919194931.B1762@bigskytel.com>

* steve <stever@cfu.net>:

> I am also, looking for some samples programs on internet programming with
> python such as socket programming and maybe simple chat program, I can show
> the students.

A simple chat server: http://strout.net/python/server.py

Users telnet to port 4000 to use it.


  David

From robert.wigetman@eurocontrol.be  Wed Sep 20 08:54:23 2000
From: robert.wigetman@eurocontrol.be (WIGETMAN Robert)
Date: Wed, 20 Sep 2000 08:54:23 +0100
Subject: [Tutor] question: how do you pass a function as argument for application?
Message-ID: <5983E4DAC939D311B2F20008C7E62E7A025840C3@clsh01xch.office.cfmu.eurocontrol.be>

Hello,

I am new to python and trying to do something like this:

def toto(x):
	print 'toto', x

def applyAFunction(f, arg):
	??? f(arg)


Also, I am trying to do this in the object framwork:

class C:
	def method(sefl, arg):
		print self, arg

	def methodApply(self, meth, arg):
	????	self.meth(arg)

This doesn't weem to work and I can't find anything in the documentation on
the solution?

Can anyone help?

Thanks,
Rob.

From dyoo@hkn.EECS.Berkeley.EDU  Wed Sep 20 10:23:19 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Wed, 20 Sep 2000 02:23:19 -0700 (PDT)
Subject: [Tutor] question: how do you pass a function as argument for
 application?
In-Reply-To: <5983E4DAC939D311B2F20008C7E62E7A025840C3@clsh01xch.office.cfmu.eurocontrol.be>
Message-ID: <Pine.LNX.4.21.0009200220320.13610-100000@hkn.EECS.Berkeley.EDU>

On Wed, 20 Sep 2000, WIGETMAN Robert wrote:
> def toto(x):
> 	print 'toto', x
> 
> def applyAFunction(f, arg):
> 	??? f(arg)

I'm guessing that you're coming from a Scheme or Lisp background?  Your
program should work.  Here's is an interpreter session:

###
>>> def todo(x):
...     print 'todo', x
... 
>>> def applyAFunction(f, arg):
...     f(arg)
... 
>>> applyAFunction(todo, "foobarish!")
todo foobarish!
###

So this works perfectly --- what sort of error do you get when you do
this?

Good luck!


From FxItAL@aol.com  Wed Sep 20 11:21:48 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Wed, 20 Sep 2000 06:21:48 EDT
Subject: [Tutor] Program Critique
Message-ID: <e4.a9a9998.26f9e9bd@aol.com>

Hello,

I'm new to python and programming in general. I wrote the following as practice and beleive I should have used classes. Would someone critique this so I can learn from my mistakes?

Also, why doesn't the #win.title('Alarm') line work?

Sorry for the line idention my AOL doesn't allow the long lines. I've tried to make the format as clear as possible.

Thanks for your time and patience, Al


from Tkinter import *
from time import time, localtime, sleep
import thread
from winsound import *

root = Tk()
root.title('Reminder')

HourLabel = Label(root, text="Hour")
HourLabel.grid(row=0, column=1, padx=1, sticky=S)
MinLabel = Label(root, text="Minute")
MinLabel.grid(row=2, column=1, padx=1, sticky=N)
MessLabel = Label(root, text="Enter Message To Be Displayed On Alarm.")
MessLabel.grid(row=0, padx=10, pady=10, column=0)

UserEntryHour = IntVar()
HourEntry = Entry(root, state=NORMAL, textvariable=UserEntryHour, width=3)
HourEntry.grid(row=1, column=1, padx=1, sticky=N)
EntryHour = UserEntryHour.get()

UserEntryMin = IntVar()
MinEntry = Entry(root, state=NORMAL, textvariable=UserEntryMin, width=3)
MinEntry.grid(row=3, column=1, padx=1, sticky=N)
EntryMin = UserEntryMin.get()

MessEntry = StringVar()
EntryBox = Entry(root, state=NORMAL, textvariable=MessEntry, width=25)
EntryBox.grid(row=1, pady=1, padx=1, column=0)
MessInput = MessEntry.get()


Hour_Min=localtime(time())
ClockMin=Hour_Min[4] 
ClockHour=Hour_Min[3] 
InputMin=EntryMin
InputHour=EntryHour

def worker_thread():
    global ClockMin, ClockHour, InputMin, InputHour, var

    SetLabel = Label(root, text="Alarm Is    Set!").grid(row=2)

    EntryMin = UserEntryMin.get()
    EntryHour = UserEntryHour.get()
    Hour_Min=localtime(time())
    ClockMin=Hour_Min[4] 
    ClockHour=Hour_Min[3] 
    InputMin=EntryMin
    InputHour=EntryHour
    if ClockHour<InputHour or ClockMin<InputMin:
        while ClockHour<InputHour or ClockMin<InputMin:
            sleep(5)
            Hour_Min=localtime(time())                              ClockMin=Hour_Min[4]
            ClockHour=Hour_Min[3]
            #print EntryMin
    if ClockHour>=InputHour or ClockMin>=InputMin:
        win = Tk()
        #win.title('Alarm')
        MessInput = MessEntry.get()

        Message(win, text=MessInput, bg='royalblue',           fg='ivory', width=500, relief=GROOVE).pack()

        OkBut = Button(win, text='OK',               command=win.destroy, width=10)
       
        OkBut.pack()
        display = win
        PlaySound("c:\\windows\\media\\office97\\
       reminder.wav",SND_FILENAME)

def ActionButCmd():
    thread.start_new_thread(worker_thread, ())

def CancelButCmd():
    SetLabel = Label(root, text="                          ").grid(row=2)

    UserEntryMin.set("0")
    UserEntryHour.set("0")


CancelBut = Button(root, text='Cancel', command=CancelButCmd, width=10)
CancelBut.grid(row=4, padx=10, pady=10, sticky=E)

ActionBut = Button(root, text='Set Alarm', command=ActionButCmd, width=10)
ActionBut.grid(row=4, padx=10, pady=10, sticky=W)

QuitBut = Button(root, text='Quit', command=root.quit, width=10)

QuitBut.grid(row=4, padx=10, pady=10, column=1, sticky=E)

root.mainloop()

From dsh8290@rit.edu  Wed Sep 20 16:25:08 2000
From: dsh8290@rit.edu (D-Man)
Date: Wed, 20 Sep 2000 11:25:08 -0400
Subject: [Tutor] CGI fails
Message-ID: <20000920112508.A2714@dman>

--AWniW0JNca5xppdA
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Hi.

I'm trying to use Python to do some CGI scripting on my webserver.  I followed
the directions in the FAQ to enable CGI on the server's conf files (Apache on
Linux x86).

I was trying the "Hello World" example (attached), but I get an "Internal
Server Error".  The error log file says:

[Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] Premature end of
script headers: /home/dman/public_html/script.py.cgi
[Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] Premature end of
script headers: /home/dman/public_html/script.py.cgi


What does this mean and how do I fix it?

-D
--AWniW0JNca5xppdA
Content-Type: application/x-cgi; charset=us-ascii
Content-Disposition: attachment; filename="script.py.cgi"

#!/usr/bin/python

def main():
   print "Content-type: text/html"
   print
   print "<HTML>\n"
   print "<TITLE> Hello, World!</TITLE>"
   print "<BODY>\n"
   print "Hello, World!"
   print "</BODY>\n\n</HTML>"

if (__name__ == "__main__"):
   main()


--AWniW0JNca5xppdA--



From marcel@punto.it  Wed Sep 20 17:04:18 2000
From: marcel@punto.it (Marcel Preda)
Date: Wed, 20 Sep 2000 18:04:18 +0200 (CEST)
Subject: [Tutor] CGI fails
In-Reply-To: <20000920112508.A2714@dman>
Message-ID: <Pine.LNX.4.20.0009201759030.6295-100000@marcel.punto.it>

On Wed, 20 Sep 2000, D-Man wrote:

> Hi.
> 
> I'm trying to use Python to do some CGI scripting on my webserver.  I followed
> the directions in the FAQ to enable CGI on the server's conf files (Apache on
> Linux x86).
> 
> I was trying the "Hello World" example (attached), but I get an "Internal
> Server Error".  The error log file says:
> 
> [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] Premature end of
> script headers: /home/dman/public_html/script.py.cgi
> [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] Premature end of
> script headers: /home/dman/public_html/script.py.cgi

The frist `output' in the python script (CGI)
must be: 
print "\n"
or
print "Content-type: <yourType>\n"
<yourType> could be:
text/html
text/plain
...
[look in `mime.types' file]


PM


From spirou@aragne.com  Wed Sep 20 17:13:35 2000
From: spirou@aragne.com (Denis)
Date: Wed, 20 Sep 2000 18:13:35 +0200
Subject: [Tutor] CGI fails
In-Reply-To: <20000920112508.A2714@dman>; from dsh8290@rit.edu on Wed, Sep 20, 2000 at 11:25:08AM -0400
References: <20000920112508.A2714@dman>
Message-ID: <20000920181335.A865@aragne.com>

Le Wed, Sep 20, 2000 at 11:25:08AM -0400, D-Man pianota:
>
> I was trying the "Hello World" example (attached), but I get an
>"Internal Server Error".  The error log file says:
> 
> [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] 
> Premature end of script headers: /home/dman/public_html/script.py.cgi
> [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] 
> Premature end of script headers: /home/dman/public_html/script.py.cgi
> 
> What does this mean and how do I fix it?

Your script.py is just fine.

If your WebServer is correctly configured, you should
verify if your script is executable.

You are very near. :-)

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

From shaleh@valinux.com  Wed Sep 20 18:23:40 2000
From: shaleh@valinux.com (Sean 'Shaleh' Perry)
Date: Wed, 20 Sep 2000 10:23:40 -0700
Subject: [Tutor] CGI fails
In-Reply-To: <Pine.LNX.4.20.0009201759030.6295-100000@marcel.punto.it>; from marcel@punto.it on Wed, Sep 20, 2000 at 06:04:18PM +0200
References: <20000920112508.A2714@dman> <Pine.LNX.4.20.0009201759030.6295-100000@marcel.punto.it>
Message-ID: <20000920102340.C15335@valinux.com>

On Wed, Sep 20, 2000 at 06:04:18PM +0200, Marcel Preda wrote:
> On Wed, 20 Sep 2000, D-Man wrote:
> 
> > [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] Premature end of
> > script headers: /home/dman/public_html/script.py.cgi
> > [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] Premature end of
> > script headers: /home/dman/public_html/script.py.cgi
> 
> The frist `output' in the python script (CGI)
> must be: 
> print "\n"
> or
> print "Content-type: <yourType>\n"

To be more clear, cgis MUST output:
Content-Type: <mimeType>\n
\n
(content type, then *two* newlines) which is your header.

Because of this not happening, you are getting a "premature end" message.  The
server is not seeing the cgi header and flagging and error.

From Gil Tucker [ateliermobile]" <gil@ateliermobile.de  Wed Sep 20 11:39:57 2000
From: Gil Tucker [ateliermobile]" <gil@ateliermobile.de (Gil Tucker [ateliermobile])
Date: Wed, 20 Sep 2000 18:39:57 +0800
Subject: [Tutor] generate ascii symbols
Message-ID: <000301c022f8$db890e00$de0aa8c0@p400>



From dsh8290@rit.edu  Wed Sep 20 19:07:51 2000
From: dsh8290@rit.edu (D-Man)
Date: Wed, 20 Sep 2000 14:07:51 -0400
Subject: [Tutor] CGI fails
In-Reply-To: <20000920181335.A865@aragne.com>; from spirou@aragne.com on Wed, Sep 20, 2000 at 12:13:35 -0400
References: <20000920181335.A865@aragne.com>
Message-ID: <20000920140751.A12644@dman>

--AWniW0JNca5xppdA
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit


$ ls -l script.py.cgi
-rwxrwxr-x   1 dman     dman          252 Sep 20 11:11 script.py.cgi

Here's my apache configuration files.

What is wrong with them?

Thanks,
-D

On Wed, 20 Sep 2000 12:13:35 Denis wrote:
> Le Wed, Sep 20, 2000 at 11:25:08AM -0400, D-Man pianota:
> >
> > I was trying the "Hello World" example (attached), but I get an
> >"Internal Server Error".  The error log file says:
> > 
> > [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] 
> > Premature end of script headers: /home/dman/public_html/script.py.cgi
> > [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] 
> > Premature end of script headers: /home/dman/public_html/script.py.cgi
> > 
> > What does this mean and how do I fix it?
> 
> Your script.py is just fine.
> 
> If your WebServer is correctly configured, you should
> verify if your script is executable.
> 
> You are very near. :-)
> 
> -- 
> Denis FRERE
> P3B    : Club Free-Pytho-Linuxien Caroloregien http://www.p3b.org
> Aragne : Internet - Reseaux - Formations  http://www.aragne.com

--AWniW0JNca5xppdA
Content-Type: application/octet-stream; charset=us-ascii
Content-Disposition: attachment; filename="access.conf"

##
## access.conf -- Apache HTTP server configuration file
##

# access.conf: Global access configuration
# Online docs at http://www.apache.org/

# This file defines server settings which affect which types of services
# are allowed, and in what circumstances. 

# Each directory to which Apache has access, can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 

# Originally by Rob McCool

# First, we configure the "default" to be a very restrictive set of 
# permissions.  

<Directory />
	Options None
	AllowOverride None
</Directory>

#??????
<Directory ~>
	Options ExecCGI Indexes
	AllowOverride None
</Directory>

# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.


# This should be changed to whatever you set DocumentRoot to.

# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.

# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo", 
# "AuthConfig", and "Limit"

# Controls who can get stuff from this server.

<Directory /home/httpd/html>
	Options Indexes ExecCGI FollowSymLinks 
	AllowOverride None
	order allow,deny
	allow from all
</Directory>


# /home/httpd/cgi-bin should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.

<Directory /home/httpd/cgi-bin>
	AllowOverride None
	Options ExecCGI
</Directory>

# Allow server status reports, with the URL of http://servername/server-status
# Change the ".your_domain.com" to match your domain to enable.

#<Location /server-status>
#SetHandler server-status

#order deny,allow
#deny from all
#allow from .your_domain.com
#</Location>

# Allow access to local system documentation from localhost
Alias /doc /usr/doc
<Directory /usr/doc>
order deny,allow
deny from all
allow from localhost
Options Indexes FollowSymLinks
</Directory>

# There have been reports of people trying to abuse an old bug from pre-1.1
# days.  This bug involved a CGI script distributed as a part of Apache.
# By uncommenting these lines you can redirect these attacks to a logging 
# script on phf.apache.org.  Or, you can record them yourself, using the script
# support/phf_abuse_log.cgi.

#<Location /cgi-bin/phf*>
#deny from all
#ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi
#</Location>

# You may place any other directories or locations you wish to have
# access information for after this one.

--AWniW0JNca5xppdA
Content-Type: application/octet-stream; charset=us-ascii
Content-Disposition: attachment; filename="srm.conf"

##
## srm.conf -- Apache HTTP server configuration file
##

# With this document, you define the name space that users see of your http
# server.  This file also defines server settings which affect how requests are
# serviced, and how results should be formatted. 

# See the tutorials at http://www.apache.org/ for
# more information.

# Originally by Rob McCool; Adapted for Apache


# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.

DocumentRoot /home/httpd/html

# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is recieved.

UserDir public_html

# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index.  Separate multiple entries with spaces.

DirectoryIndex index.html index.shtml index.cgi

# FancyIndexing is whether you want fancy directory indexing or standard

FancyIndexing on

# AddIcon tells the server which icon to show for different files or filename
# extensions

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

# DefaultIcon is which icon to show for files which do not have an icon
# explicitly set.

DefaultIcon /icons/unknown.gif

# AddDescription allows you to place a short description after a file in
# server-generated indexes.
# Format: AddDescription "description" filename

# ReadmeName is the name of the README file the server will look for by
# default. Format: ReadmeName name
#
# The server will first look for name.html, include it if found, and it will
# then look for name and include it as plaintext if found.
#
# HeaderName is the name of a file which should be prepended to
# directory indexes. 

ReadmeName README
HeaderName HEADER

# IndexIgnore is a set of filenames which directory indexing should ignore
# Format: IndexIgnore name1 name2...

IndexIgnore .??* *~ *# HEADER* README* RCS

# AccessFileName: The name of the file to look for in each directory
# for access control information.

AccessFileName .htaccess

# TypesConfig describes where the mime.types file (or equivalent) is
# to be found.

TypesConfig /etc/mime.types

# DefaultType is the default MIME type for documents which the server
# cannot find the type of from filename extensions.

DefaultType text/plain

# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
# information on the fly. Note: Not all browsers support this.

AddEncoding x-compress Z
AddEncoding x-gzip gz

# AddLanguage allows you to specify the language of a document. You can
# then use content negotiation to give a browser a file in a language
# it can understand.  Note that the suffix does not have to be the same
# as the language keyword --- those with documents in Polish (whose
# net-standard language code is pl) may wish to use "AddLanguage pl .po" 
# to avoid the ambiguity with the common suffix for perl scripts.

AddLanguage en .en
AddLanguage fr .fr
AddLanguage de .de
AddLanguage da .da
AddLanguage el .el
AddLanguage it .it

# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
# Just list the languages in decreasing order of preference.

LanguagePriority en fr de

# Redirect allows you to tell clients about documents which used to exist in
# your server's namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
# Format: Redirect fakename url


# Aliases: Add here as many aliases as you need (with no limit). The format is 
# Alias fakename realname

# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL.  So "/icons" isn't aliased in this
# example.

Alias /icons/ /home/httpd/icons/

# ScriptAlias: This controls which directories contain server scripts.
# Format: ScriptAlias fakename realname

ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/

# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.

# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
# Format: AddType type/subtype ext1

# For example, the PHP3 module (not part of the Apache distribution)
# will typically use:
#AddType application/x-httpd-php3 .php3
#AddType application/x-httpd-php3-source .phps
# The following is for PHP/FI (PHP2):
#AddType application/x-httpd-php .phtml

# AddHandler allows you to map certain file extensions to "handlers",
# actions unrelated to filetype. These can be either built into the server
# or added with the Action command (see below)
# Format: AddHandler action-name ext1

# To use CGI scripts:
AddHandler cgi-script .cgi
#AddHandler cgi-script .py  # Make python code default to cgi
#AddHandler cgi-script .scm  # Make Scheme code default to cgi

# To use server-parsed HTML files
AddType text/html .shtml
AddHandler server-parsed .shtml

# Uncomment the following line to enable Apache's send-asis HTTP file
# feature
#AddHandler send-as-is asis

# If you wish to use server-parsed imagemap files, use
AddHandler imap-file map

# To enable type maps, you might want to use
#AddHandler type-map var

# To enable the perl module (if you have it installed), uncomment
# the following section 
#
#Alias /perl/ /home/httpd/perl/
#<Location /perl>
#SetHandler perl-script
#PerlHandler Apache::Registry
#Options +ExecCGI
#</Location>

# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location

# MetaDir: specifies the name of the directory in which Apache can find
# meta information files. These files contain additional HTTP headers
# to include when sending the document

#MetaDir .web

# MetaSuffix: specifies the file name suffix for the file containing the
# meta information.

#MetaSuffix .meta

# Customizable error response (Apache style)
#  these come in three flavors
#
#    1) plain text
#ErrorDocument 500 "The server made a boo boo.
#  n.b.  the (") marks it as text, it does not get output
#
#    2) local redirects
#ErrorDocument 404 /missing.html
#  to redirect to local url /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
#  n.b. can redirect to a script or a document using server-side-includes.
#
#    3) external redirects
#ErrorDocument 402 http://some.other_server.com/subscription_info.html
#

# mod_mime_magic allows the server to use various hints from the file itself
# to determine its type.
#MimeMagicFile /etc/httpd/conf/magic

# The following directives disable keepalives and HTTP header flushes.
# The first directive disables it for Netscape 2.x and browsers which
# spoof it. There are known problems with these.
# The second directive is for Microsoft Internet Explorer 4.0b2
# which has a broken HTTP/1.1 implementation and does not properly
# support keepalive when it is used on 301 or 302 (redirect) responses.

BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

# The following directive disables HTTP/1.1 responses to browsers which
# are in violation of the HTTP/1.0 spec by not being able to grok a
# basic 1.1 response.

BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

--AWniW0JNca5xppdA
Content-Type: application/octet-stream; charset=us-ascii
Content-Disposition: attachment; filename="httpd.conf"

# #
# # httpd.conf -- Apache HTTP server configuration file
# #

# This is the main server configuration file. See URL http://www.apache.org/
# for instructions.

# Do NOT simply read the instructions in here without understanding
# what they do, if you are unsure consult the online docs. You have been
# warned.

# Originally by Rob McCool

# ServerType is either inetd, or standalone.

ServerType standalone

# If you are running from inetd, go to "ServerAdmin".

# Port: The port the standalone listens to. For ports < 1023, you will
# need httpd to be run as root initially.

Port 80

# Number of servers to start --- should be a reasonable ballpark figure.

StartServers 5

# Server-pool size regulation.  Rather than making you guess how many
# server processes you need, Apache dynamically adapts to the load it
# sees --- that is, it tries to maintain enough server processes to
# handle the current load, plus a few spare servers to handle transient
# load spikes (e.g., multiple simultaneous requests from a single
# Netscape browser).

# It does this by periodically checking how many servers are waiting
# for a request.  If there are fewer than MinSpareServers, it creates
# a new spare.  If there are more than MaxSpareServers, some of the
# spares die off.  These values are probably OK for most sites ---

MinSpareServers 2
MaxSpareServers 10

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We reccomend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request

KeepAliveTimeout 15

# Limit on total number of servers running, i.e., limit on the number
# of clients who can simultaneously connect --- if this limit is ever
# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW.
# It is intended mainly as a brake to keep a runaway server from taking
# Unix with it as it spirals down...

MaxClients 150

# MaxRequestsPerChild: the number of requests each child process is
# allowed to process before the child dies.
# The child will exit so as to avoid problems after prolonged use when
# Apache (and maybe the libraries it uses) leak.  On most systems, this
# isn't really needed, but a few (such as Solaris) do have notable leaks
# in the libraries.

MaxRequestsPerChild 100

# If you would like to have an agent and referer logfile uncomment the
# following directives.

# CustomLog logs/referer_log referer
# CustomLog logs/agent_log agent

# If you prefer a single logfile with access, agent and referer information
# (Combined Logfile Format) you can use the following directive.

# CustomLog logs/access_log combined

# PidFile: The file the server should log its pid to
PidFile /var/run/httpd.pid

# CacheNegotiatedDocs: By default, Apache sends Pragma: no-cache with each
# document that was negotiated on the basis of content. This asks proxy
# servers not to cache the document. Uncommenting the following line disables
# this behavior, and proxies will be allowed to cache the documents.

# CacheNegotiatedDocs

# Timeout: The number of seconds before receives and sends time out

Timeout 300

# ScoreBoardFile: File used to store internal server process information.
# Not all architectures require this.  But if yours does (you'll know because
# this file is created when you run Apache) then you *must* ensure that
# no two invocations of Apache share the same scoreboard file.
ScoreBoardFile /var/run/httpd.scoreboard

# ServerRoot: The directory the server's config, error, and log files
# are kept in.
# NOTE!  If you intend to place this on a NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation,
# you will save yourself a lot of trouble.

ServerRoot /etc/httpd

# HostnameLookups: Log the names of clients or just their IP numbers
# e.g.   www.apache.org (on) or 204.62.129.132 (off)
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on.

HostnameLookups off

# Dynamic Shared Object (DSO) Support

# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Please read the file README.DSO in the Apache 1.3 distribution for more
# details about the DSO mechanism and run `httpd -l' for the list of already
# built-in (statically linked and thus always available) modules in your httpd
# binary.

# Example:
# LoadModule foo_module libexec/mod_foo.so

# Documentation for modules is in "/home/httpd/manual/mod" in HTML format.

# LoadModule mmap_static_module modules/mod_mmap_static.so
LoadModule env_module         modules/mod_env.so
LoadModule config_log_module  modules/mod_log_config.so
LoadModule agent_log_module   modules/mod_log_agent.so
LoadModule referer_log_module modules/mod_log_referer.so
# LoadModule mime_magic_module  modules/mod_mime_magic.so
LoadModule mime_module        modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule status_module      modules/mod_status.so
LoadModule info_module        modules/mod_info.so
LoadModule includes_module    modules/mod_include.so
LoadModule autoindex_module   modules/mod_autoindex.so
LoadModule dir_module         modules/mod_dir.so
LoadModule cgi_module         modules/mod_cgi.so
LoadModule asis_module        modules/mod_asis.so
LoadModule imap_module        modules/mod_imap.so
LoadModule action_module      modules/mod_actions.so
# LoadModule speling_module     modules/mod_speling.so
LoadModule userdir_module     modules/mod_userdir.so
LoadModule proxy_module       modules/libproxy.so
LoadModule alias_module       modules/mod_alias.so
LoadModule rewrite_module     modules/mod_rewrite.so
LoadModule access_module      modules/mod_access.so
LoadModule auth_module        modules/mod_auth.so
LoadModule anon_auth_module   modules/mod_auth_anon.so
# LoadModule dbm_auth_module    modules/mod_auth_dbm.so
LoadModule db_auth_module     modules/mod_auth_db.so
LoadModule digest_module      modules/mod_digest.so
# LoadModule cern_meta_module   modules/mod_cern_meta.so
LoadModule expires_module     modules/mod_expires.so
LoadModule headers_module     modules/mod_headers.so
LoadModule usertrack_module   modules/mod_usertrack.so
# LoadModule example_module     modules/mod_example.so
# LoadModule unique_id_module   modules/mod_unique_id.so
LoadModule setenvif_module    modules/mod_setenvif.so
ClearModuleList

# Extra Modules
# LoadModule php_module         modules/mod_php.so
# LoadModule php3_module        modules/libphp3.so
# LoadModule perl_module        modules/libperl.so

# Reconstruction of the complete module list from all available modules
# (static and shared ones) to achieve correct module execution order.
# [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO]
# AddModule mod_mmap_static.c
AddModule mod_env.c
AddModule mod_log_config.c
AddModule mod_log_agent.c
AddModule mod_log_referer.c
# AddModule mod_mime_magic.c
AddModule mod_mime.c
AddModule mod_negotiation.c
AddModule mod_status.c
AddModule mod_info.c
AddModule mod_include.c
AddModule mod_autoindex.c
AddModule mod_dir.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
# AddModule mod_speling.c
AddModule mod_userdir.c
AddModule mod_proxy.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_auth_anon.c
# AddModule mod_auth_dbm.c
AddModule mod_auth_db.c
AddModule mod_digest.c
# AddModule mod_cern_meta.c
AddModule mod_expires.c
AddModule mod_headers.c
AddModule mod_usertrack.c
# AddModule mod_example.c
# AddModule mod_unique_id.c
AddModule mod_so.c
AddModule mod_setenvif.c

# ServerAdmin: Your address, where problems with the server should be
# e-mailed.

ServerAdmin dsh8290@rit.edu

# BindAddress: You can support virtual hosts with this option. This option
# is used to tell the server which IP address to listen to. It can either
# contain "*", an IP address, or a fully qualified Internet domain name.
# See also the VirtualHost directive.

# BindAddress *

# ErrorLog: The location of the error log file. If this does not start
# with /, ServerRoot is prepended to it.

ErrorLog logs/error_log

# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.

# User/Group: The name (or #number) of the user/group to run httpd as.
# On SCO (ODT 3) use User nouser and Group nogroup
# On HPUX you may not be able to use shared memory as nobody, and the
# suggested workaround is to create a user www and use that user.
# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
# when the value of (unsigned)Group is above 60000;
# don't use Group nobody on these systems!

User nobody
Group nobody

# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.

LogLevel warn

# Extra Modules
# AddModule mod_php.c
# AddModule mod_php3.c
# AddModule mod_perl.c


# The following directives define some format nicknames for use with
# a CustomLog directive (see below).

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# The location of the access logfile (Common Logfile Format).
# If this does not start with /, ServerRoot is prepended to it.

CustomLog logs/access_log common

# The LockFile directive sets the path to the lockfile used when Apache
# is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or
# USE_FLOCK_SERIALIZED_ACCEPT. This directive should normally be left at
# its default value. The main reason for changing it is if the logs
# directory is NFS mounted, since the lockfile MUST BE STORED ON A LOCAL
# DISK. The PID of the main server process is automatically appended to
# the filename.

# LockFile /var/lock/httpd.lock

# ServerName allows you to set a host name which is sent back to clients for
# your server if it's different than the one the program would get (i.e. use
# "www" instead of the host's real name).

# Note: You cannot just invent host names and hope they work. The name you
# define here must be a valid DNS name for your host. If you don't understand
# this, ask your network administrator.

# ServerName new.host.name

# UseCanonicalName:  (new for 1.3)  With this setting turned on, whenever
# Apache needs to construct a self-referencing URL (a url that refers back
# to the server the response is coming from) it will use ServerName and
# Port to form a "canonical" name.  With this setting off, Apache will
# use the hostname:port that the client supplied, when possible.  This
# also affects SERVER_NAME and SERVER_PORT in CGIs.
UseCanonicalName on


--AWniW0JNca5xppdA--



From marcel@punto.it  Wed Sep 20 19:38:02 2000
From: marcel@punto.it (Marcel Preda)
Date: Wed, 20 Sep 2000 20:38:02 +0200 (CEST)
Subject: [Tutor] generate ascii symbols
In-Reply-To: <000301c022f8$db890e00$de0aa8c0@p400>
Message-ID: <Pine.LNX.4.20.0009202035120.6671-100000@marcel.punto.it>

On Wed, 20 Sep 2000, Gil Tucker [ateliermobile] wrote:

> 
> 

???

Ih `subject' was a question:
>>> for i in range(0,255):
...     print chr(i)

PM



From michaelbaker@operamail.com  Wed Sep 20 19:45:47 2000
From: michaelbaker@operamail.com (michaelbaker@operamail.com)
Date: Wed, 20 Sep 2000 11:45:47 -0700
Subject: [Tutor] TypeError and audio input
In-Reply-To: <20000918160106.7040C1CF8E@dinsdale.python.org>
Message-ID: <4.3.2.7.1.20000920114003.00b4a6a0@operamail.com>

I'm not sure what this means:

 >>> a=('D:\\Temp\pentagon.wav')
 >>> import wave
 >>> l=wave.Wave_read.getnframes
 >>> l(a)
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: unbound method must be called with class instance 1st argument

how can I remedy this?

Also, can Python analyze input from a hardware audio in device like a 
microphone port? maybe with fileinput? stdin?

thanks, a newbie couldn't survive without tutor@python.org!

m baker


From Gil Tucker [ateliermobile]" <gil@ateliermobile.de  Wed Sep 20 12:50:54 2000
From: Gil Tucker [ateliermobile]" <gil@ateliermobile.de (Gil Tucker [ateliermobile])
Date: Wed, 20 Sep 2000 19:50:54 +0800
Subject: [Tutor] generate ascii symbols
Message-ID: <004601c02305$f15593e0$de0aa8c0@p400>

I am looking for routines in python that i  can generate ascii sybomls into
art in otherwords making ascii art genered with the python lasnguage
thanks gil  tucker



http://www.ateliermobile.de


From DOUGS@oceanic.com  Wed Sep 20 21:31:47 2000
From: DOUGS@oceanic.com (Doug Stanfield)
Date: Wed, 20 Sep 2000 10:31:47 -1000
Subject: [Tutor] generate ascii symbols
Message-ID: <8457258D741DD411BD3D0050DA62365907A338@huina.oceanic.com>

I'd guess there isn't an existing library of routines to do this.  I may be
wrong about that, but it should be easy enough to do anyway.  I'd say that
its a good task to learn some basics of Python, which I'd assume is the
intent.  

In general you need to figure out how to approach the problem.  Do you know
what algorithm you'd like to implement?  In other words, break down the
problem into a sequence of tasks.  Think about what the input is that starts
the process and what is output at the end.  If you can explain that to us we
can help you more easily.  The next steps would be to figure out what data
structures you need to keep intermediate results and specific manipulations
that need to be done.  Again, we can help figure that out and how to apply
Python to do it.

-Doug-

> -----Original Message-----
> From: Gil Tucker [ateliermobile] [mailto:gil@ateliermobile.de]
> Sent: Wednesday, September 20, 2000 1:51 AM
> To: tutor@python.org
> Subject: [Tutor] generate ascii symbols
> 
> 
> 
> I am looking for routines in python that i  can generate 
> ascii sybomls into
> art in otherwords making ascii art genered with the python lasnguage
> thanks gil  tucker
> 
> 
> 
> http://www.ateliermobile.de
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 

From scott@zenplex.com  Thu Sep 21 20:04:31 2000
From: scott@zenplex.com (Scott Ralph)
Date: Thu, 21 Sep 2000 15:04:31 -0400
Subject: [Tutor] Modules
Message-ID: <39CA5BBF.A2AFA9B7@zenplex.com>

Question?  I just started out learning Python and would like to
manipulate Mac Files under python for Linux.   Can I import the mac
modules macfs, findertools and macostools? If so were do I get them?
Thanks All
Scott

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scott Ralph
Zenplex, Inc.
317 Madison Ave
Suite 1500
New York,  NY 10017
212.499.0668
http://www.zenplex.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




From dsh8290@rit.edu  Fri Sep 22 04:31:26 2000
From: dsh8290@rit.edu (D-Man)
Date: Thu, 21 Sep 2000 23:31:26 -0400
Subject: [Tutor] CGI fails
Message-ID: <20000921233126.G6982@dman>

Thanks all for the suggestions and help.

I still can't get it to work though.  I think it must be my server
configuration.  I created a simple page using Netscape Composer.  Then I made my script
print that page in a tqs.  Opening the html from the file composer made is fine. 
Getting it from the script still fails.

Any more help?

-D


From dyoo@hkn.EECS.Berkeley.EDU  Fri Sep 22 05:26:39 2000
From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo)
Date: Thu, 21 Sep 2000 21:26:39 -0700 (PDT)
Subject: [Tutor] question: how do you pass a function as argument for
 application?
In-Reply-To: <5983E4DAC939D311B2F20008C7E62E7A025840C9@clsh01xch.office.cfmu.eurocontrol.be>
Message-ID: <Pine.LNX.4.21.0009202339420.3696-100000@hkn.EECS.Berkeley.EDU>

On Wed, 20 Sep 2000, WIGETMAN Robert wrote:

> thanks for the help, your suggestion works, but how do I do it in a class
> instance method?
> 
> class C:
> 	def __init__(self,x):
> 		self.val = x
> 	def foo(self):
> 		print self.val
> 	def doit(self, func):
> 		self.func()  # this is where I can't get it to work??
> 
> >>> x = C(1)
> >>> x.foo()
> 1
> >>> x.doit(x.g)


Tricky!  What's happening is that x.doit is a "bound" method to your 'x'
instance:

###
>>> x = C(1)
>>> x.doit
<method C.doit of C instance at 8101e60>
###

This is in contrast to an "unbound method" from the C class:

###
>>> C.doit
<unbound method C.doit>
###

When you make an instance of a class, its methods gets bound into with
self.  This example might make things clearer:

###
>>> myfunc = x.doit
>>> myfunc()
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: not enough arguments; expected 2, got 1
###

Where did the first argument come from?  What's happening is a little
"behind-the-scenes" action --- since we pulled the bound doit() method
from x, the self argument will implicitly be attached as the first
argument.


*some time later*

I have to end this message abruptly --- I won't be able to check Python
stuff for a while because of a slight time constraint.  Sorry!  Hopefully
another tutor can help explain how to get your code working.


From marcel@punto.it  Fri Sep 22 09:34:47 2000
From: marcel@punto.it (Marcel Preda)
Date: Fri, 22 Sep 2000 10:34:47 +0200 (CEST)
Subject: [Tutor] question: how do you pass a function as argument for
 application?
In-Reply-To: <Pine.LNX.4.21.0009202339420.3696-100000@hkn.EECS.Berkeley.EDU>
Message-ID: <Pine.LNX.4.20.0009221029410.10116-100000@marcel.punto.it>

I think that I was lucky :) 

>>> class C:
...     def f(self,a):
...              print(a)
...     def f2(self,x):
...             C.f(self,x)
... 
>>> x=C()
>>> x.f('xxx')
xxx
>>> x.f2('xxx')
xxx
>>> 


PM


On Thu, 21 Sep 2000, Daniel Yoo wrote:

> On Wed, 20 Sep 2000, WIGETMAN Robert wrote:
> 
> > thanks for the help, your suggestion works, but how do I do it in a class
> > instance method?
> > 
> > class C:
> > 	def __init__(self,x):
> > 		self.val = x
> > 	def foo(self):
> > 		print self.val
> > 	def doit(self, func):
> > 		self.func()  # this is where I can't get it to work??
> > 
> > >>> x = C(1)
> > >>> x.foo()
> > 1
> > >>> x.doit(x.g)
> 
> 
> Tricky!  What's happening is that x.doit is a "bound" method to your 'x'
> instance:
> 
> ###
> >>> x = C(1)
> >>> x.doit
> <method C.doit of C instance at 8101e60>
> ###
> 
> This is in contrast to an "unbound method" from the C class:
> 
> ###
> >>> C.doit
> <unbound method C.doit>
> ###
> 
> When you make an instance of a class, its methods gets bound into with
> self.  This example might make things clearer:
> 
> ###
> >>> myfunc = x.doit
> >>> myfunc()
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> TypeError: not enough arguments; expected 2, got 1
> ###
> 
> Where did the first argument come from?  What's happening is a little
> "behind-the-scenes" action --- since we pulled the bound doit() method
> from x, the self argument will implicitly be attached as the first
> argument.
> 
> 
> *some time later*
> 
> I have to end this message abruptly --- I won't be able to check Python
> stuff for a while because of a slight time constraint.  Sorry!  Hopefully
> another tutor can help explain how to get your code working.


From marcel@punto.it  Fri Sep 22 12:21:57 2000
From: marcel@punto.it (Marcel Preda)
Date: Fri, 22 Sep 2000 13:21:57 +0200 (CEST)
Subject: [Tutor] Re: question: how do you pass a function as argument for application?
Message-ID: <Pine.LNX.4.20.0009221309320.10602-100000@marcel.punto.it>

I have send a stupid pice of code before.

Check this code:


>>> class C:
...     def f(self,a):
...             print(a)
...     def callMethod(self,method,arg):
...             method(arg)
... 
>>> d=C()
>>> d.callMethod(d.f,'dddddddd')
dddddddd
>>> def f2(a):  
...     print "I'm f2, and I'm printing ",a
... 
>>> d.callMethod(f2,'fff')
I'm f2, and I'm printing  fff



PM




From wesc@deirdre.org  Fri Sep 22 19:18:35 2000
From: wesc@deirdre.org (Wesley Chun)
Date: Fri, 22 Sep 2000 11:18:35 -0700
Subject: [Tutor] EVENT: Python course in Silicon Valley
Message-ID: <200009221818.LAA09445@adelie.deirdre.org>

below is an announcement for another Python course i'm giving for
UC Santa Cruz for Fall 2000 quarter. it is targeted for those
who are familiar with at least one other high-level programming
language.

for complete newbies, we are working on developing a course for
those completely new to programming period.  this class is ten-
tatively scheduled for sometime late next year, not to mention a
Python Programming II class, which covers more advanced stuff
that we don't get a chance to address in the first class.

let me know if you have any questions.  hope to see some
of you in class this quarter!!

-wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

UC Santa Cruz Extension Python course in Silicon Valley, Fall 2000

When:   Tuesdays, October 3 - November 21, 2000, 6:30pm-9:30pm

Where:  Sunnyvale, CA

Who:    Wesley Chun

What:   intro to Python, data types, statements, errors and
        exception handling, functions and modules, OOP and
        classes, execution environment, regular expressions,
        network/Internet programming, interfacing to your
        operating system, creating GUIs with Tkinter, intro
        to JPython, and Extending Python

Info:   for more info, see the UCSC Extension website:

http://www.ucsc-extension.edu/knowledge_is_timeless/qd/softlist.taf?func
tion=detail&X_Number=X444.3

        (if the above link fails, just go to the Events page
        at http://www.python.org )

--
* "Core Python Programming", Prentice Hall PTR, TBP Fall 2000

* Silicon Valley/SF Bay Area Python UG: http://www.baypiggies.org

* wesley.j.chun :: cyberweb.consulting :: silicon.valley, ca
* http://www.roadkill.com/~wesc/cyberweb/

From nothingisgoingtochangemyworld@yahoo.com  Sat Sep 23 22:33:02 2000
From: nothingisgoingtochangemyworld@yahoo.com (Joseph Stubenrauch)
Date: Sat, 23 Sep 2000 14:33:02 -0700 (PDT)
Subject: [Tutor] Unicode, Tkinter, and Duct Repairs
Message-ID: <20000923213302.4249.qmail@web1901.mail.yahoo.com>

Hello all,

Thanks for all the help on my last question.  The
advice from Denis of http://www.p3b.com was especially
helpful.

I am wondering what sort of support python and tkinter
offer for unicode.  There are a few unusual characters
which are supported by unicode, yet do not appear in
fonts claiming to have unicode support.  Is there
anyway through python or tkinter that I can get at
these characters?

Secondly, and simply, I need a kick in the right
direction.  I am trying to delete the last character
that has been entered into an entry widget.  I have
the whole insert thing down pat, but I can't seem to
delete things properly.  I just need a good example to
get me going (since man pages seem to just boggle me).
I was hoping entrywidget.delete(END - 1) would work,
but I suppose that was a bit optimistic of me. =)

Help on either question is much appreciated.

Cheers,

Joe


__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

From DOUGS@oceanic.com  Sat Sep 23 22:57:39 2000
From: DOUGS@oceanic.com (Doug Stanfield)
Date: Sat, 23 Sep 2000 11:57:39 -1000
Subject: [Tutor] Unicode, Tkinter, and Duct Repairs
Message-ID: <8457258D741DD411BD3D0050DA62365907A346@huina.oceanic.com>

[Joseph Stubenrauch asked:]
> I am trying to delete the last character
> that has been entered into an entry widget.  I have
> the whole insert thing down pat, but I can't seem to
> delete things properly.  I just need a good example to
> get me going (since man pages seem to just boggle me).
> I was hoping entrywidget.delete(END - 1) would work,
> but I suppose that was a bit optimistic of me. =)

I don't do Tkinter, but I'll give you a generic answer.  

Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201
(egcs-1.1.1
  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> test = 'this is a string'
>>> test = test[:-1]
>>> test
'this is a strin'
>>>

You'll undoubtably have a way to get and set the string from the
entrywidget, so I'll assume they are just using an attribute such as
entrywidget.text:

entrywidget.text = entrywidget.text[:-1]

Hope this is what you were looking for.

-Doug-

From chris_esen@hotmail.com  Sun Sep 24 15:13:45 2000
From: chris_esen@hotmail.com (Chris Esen)
Date: Sun, 24 Sep 2000 14:13:45 GMT
Subject: [Tutor] Python's Virtual Machine, etc...
Message-ID: <F201WSEVU29AhsFt4cw00001058@hotmail.com>

I'm doing a science report and I'm looking for information on Python's 
virtual machine or any other information dealing w/ how Pythons code is 
executed. I looked through the Python site and couldn't find much, if you 
guys can point me to some sites I would be more than greatful.

Thanks,

Chris E.


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

Share information about yourself, create your own public profile at 
http://profiles.msn.com.



From gerrit.haase@t-online.de  Sun Sep 24 15:31:26 2000
From: gerrit.haase@t-online.de (Gerrit Haase)
Date: Sun, 24 Sep 2000 16:31:26 +0200
Subject: [Tutor] Reference Card
Message-ID: <39CE2C5E.11170.14AE2C48@localhost>

Hello,

i'm completly new to python.
I'm looking for sth like a 'reference card' for python, like there 
are some on this page: http://www.refcards.com ?

regards
Gerrit
-- 
Gerrit Peter Haase


From srichter@cbu.edu  Sun Sep 24 18:19:23 2000
From: srichter@cbu.edu (Stephan Richter)
Date: Sun, 24 Sep 2000 12:19:23 -0500
Subject: [Tutor] exec versus execfile
Message-ID: <4.3.1.0.20000924115322.00aa3790@198.78.130.6>

Hello everyone,

I have a little Web application that will allow the user to type in some 
code which is then interpreted and the result (in this case an image - 
generated with PIL) will be returned.

Here my problem:
When I say: 'exec code' it gives me a syntax error. But if I save my code 
into a file and use 'execfile(filename)' everything works fine. This 
problem only occurs, if I have multiple lines in my code string. I noticed 
that the file uses '\015\012' to finish a line and my code string only uses 
'\012'. Is that a problem?
If I read the code I just saved to the file and try to exec it, the syntax 
error is thrown again.

I am really confused, why it is not working. I am using Python 1.5.2. Can 
someone shine some light on my situation?

Thanks in advance.

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



From lgwb@no_spam.home.com  Mon Sep 25 04:41:03 2000
From: lgwb@no_spam.home.com (Michael Schmitt)
Date: Sun, 24 Sep 2000 22:41:03 -0500
Subject: [Tutor] Reference Card
Message-ID: <001501c026a2$6e103fd0$0a0a0a0a@c175700-a.mntp1.il.home.com>

Not quite as concise as the reference cards you mention, but take a look at
http://starship.python.net/quick-ref1_52.html

Michael

-----Original Message-----
From: Gerrit Haase <gerrit.haase@t-online.de>
To: tutor@python.org <tutor@python.org>
Date: Sunday, September 24, 2000 9:42 AM
Subject: [Tutor] Reference Card


Hello,

i'm completly new to python.
I'm looking for sth like a 'reference card' for python, like there 
are some on this page: http://www.refcards.com ?

regards
Gerrit
-- 
Gerrit Peter Haase

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



From dlaskey@laskeycpa.com  Mon Sep 25 04:49:01 2000
From: dlaskey@laskeycpa.com (Daniel D. Laskey)
Date: Sun, 24 Sep 2000 23:49:01 -0400
Subject: [Tutor] Bad Operand Type
Message-ID: <01C02682.087A2340@o1b-53.i2k.com>

When I type this program in the python command prompt everthing works =
well.  When I put it inside the file and try to run it I get the =
following error message.

milesTraveled =3D raw_input("How many miles did you travel? ")
gallonsUsed =3D raw_input("How many gallons of gas did you use? ")
pricePerGallon =3D raw_input("How much did one gallon of gas cost? ")

print milesTraveled
print gallonsUsed
print pricePerGallon

# Divide the number of miles by the number of gallons
# used to get MPG.
milesPerGallon =3D milesTraveled / gallonsUsed
print milesPerGallon

Traceback (innermost last):
  File "travel.py", line 24, in ?
    milesPerGallon =3D milesTraveled / gallonsUsed
TypeError: bad operand type(s) for /

Thanks,
Dan


From srichter@cbu.edu  Mon Sep 25 05:35:14 2000
From: srichter@cbu.edu (Stephan Richter)
Date: Sun, 24 Sep 2000 23:35:14 -0500
Subject: [Tutor] Bad Operand Type
In-Reply-To: <01C02682.087A2340@o1b-53.i2k.com>
Message-ID: <4.3.1.0.20000924233251.00aa3e90@198.78.130.6>

Daniel,

I think you need to convert the input (string) to a float.

>milesTraveled = raw_input("How many miles did you travel? ")
>gallonsUsed = raw_input("How many gallons of gas did you use? ")
>pricePerGallon = raw_input("How much did one gallon of gas cost? ")

float(milesTraveled) = raw_input("How many miles did you travel? ")
float(gallonsUsed) = raw_input("How many gallons of gas did you use? ")
float(pricePerGallon) = raw_input("How much did one gallon of gas cost? ")

That should solve your problem.

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



From lgwb@no_spam.home.com  Mon Sep 25 12:42:47 2000
From: lgwb@no_spam.home.com (Michael Schmitt)
Date: Mon, 25 Sep 2000 06:42:47 -0500
Subject: [Tutor] Bad Operand Type
Message-ID: <002d01c026e5$ba389310$0a0a0a0a@c175700-a.mntp1.il.home.com>

I got the same message running the code in the interactive python command
prompt as you did running it in a file.
The error you received "TypeError: bad operand type(s) for /" was indicating
that you can't do division
on a string.

Instead of raw_input use input, as follows:

milesTraveled = input("How many miles did you travel? ")
gallonsUsed = input("How many gallons of gas did you use? ")
pricePerGallon = input("How much did one gallon of gas cost? ")

That way the input will be evaluated and found to be of type floating-point
or integer.

Also, you  probably want the value milesPerGallon to be of type
floating point.  That way your answer will not be truncated at the decimal
point.  This will happen just fine
if the user enters one of the values with a decimal point.  In case they
don't, you will  want to change
the line:

milesPerGallon = milesTraveled / gallonsUsed

to

milesPerGallon = float(milesTraveled) / gallonsUsed

Michael

-----Original Message-----
From: Daniel D. Laskey <dlaskey@laskeycpa.com>
To: 'tutor@python.org' <tutor@python.org>
Date: Sunday, September 24, 2000 10:51 PM
Subject: [Tutor] Bad Operand Type


When I type this program in the python command prompt everthing works well.
When I put it inside the file and try to run it I get the following error
message.

milesTraveled = raw_input("How many miles did you travel? ")
gallonsUsed = raw_input("How many gallons of gas did you use? ")
pricePerGallon = raw_input("How much did one gallon of gas cost? ")

print milesTraveled
print gallonsUsed
print pricePerGallon

# Divide the number of miles by the number of gallons
# used to get MPG.
milesPerGallon = milesTraveled / gallonsUsed
print milesPerGallon

Traceback (innermost last):
  File "travel.py", line 24, in ?
    milesPerGallon = milesTraveled / gallonsUsed
TypeError: bad operand type(s) for /

Thanks,
Dan

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



From alan.gauld@freenet.co.uk  Mon Sep 25 23:13:35 2000
From: alan.gauld@freenet.co.uk (Alan Gauld)
Date: Mon, 25 Sep 2000 22:13:35 +0000
Subject: [Tutor] book cover now on show
Message-ID: <3.0.1.32.20000925221335.00769398@mail.freenet.co.uk>

Hi fellow tutorists,

A bit of blatant self promotion, but my forthcoming book 
is now on Addison Wesley's web site, including the cover art 
and a bit of OTT write up (not of my origination I hasten 
to add!)

http://www.awl.com/product/0,2627,0201709384,00.html

Just back from vacation,

Alan G.



From deirdre@deirdre.net  Tue Sep 26 00:46:49 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Mon, 25 Sep 2000 16:46:49 -0700 (PDT)
Subject: [Tutor] TypeError and audio input
In-Reply-To: <4.3.2.7.1.20000920114003.00b4a6a0@operamail.com>
Message-ID: <Pine.LNX.4.10.10009251644510.7940-100000@rockhopper.deirdre.org>

On Wed, 20 Sep 2000 michaelbaker@operamail.com wrote:

> I'm not sure what this means:
> 
>  >>> a=('D:\\Temp\pentagon.wav')
>  >>> import wave
>  >>> l=wave.Wave_read.getnframes
>  >>> l(a)
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
> TypeError: unbound method must be called with class instance 1st argument
> 
> how can I remedy this?

is getnframes a function? If so, it should be:

l=wave.Wave_read.getnframes()

> Also, can Python analyze input from a hardware audio in device like a
> microphone port? maybe with fileinput? stdin?

I dunno about on windows, but on unix audio is a pseudofile device. So it
can be opened the same way anything else can.

> thanks, a newbie couldn't survive without tutor@python.org!

Sorry it took so long to get back to you on this (and if there were other
answers, I deleted them in my mailbox cleanup): I was getting married and
have been really busy the last few days in particular.

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"More damage has been caused by innocent program crashes than by 
malicious viruses, but they don't make great stories."
                   --  Jean-Louis Gassee, Be Newsletter, Issue 69



From dizznog@yahoo.com  Tue Sep 26 00:55:47 2000
From: dizznog@yahoo.com (Peter Curran)
Date: Mon, 25 Sep 2000 16:55:47 -0700 (PDT)
Subject: [Tutor] Stepping backwards through a FOR loop?
Message-ID: <20000925235547.22548.qmail@web311.mail.yahoo.com>

Hello.

This should be an easy one.  How do I use a for loop
to step backwards through a list of strings?

I've got a list of strings that I created with the
string.split function, now I want to step through them
in reverse order, but I'm not having any luck.  I
tried appending a ".reverse" to my list variable
before stepping through it with the for loop, but that
didn't seem to do any good -- the list still comes out
in the original order.  Here's a condensed version of
what I've got right now.

m_lstSplitStrings = string.split(sRawText,';')
m_lstSplitStrings.reverse
for sItem in m_lstSplitStrings:
	#process items

Perhaps I'm going about this in the wrong way because
I have looked for the answer in a few places and
haven't found anything.

Thanks in advance.

Peter Curran


__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/


From insyte@emt-p.org  Tue Sep 26 01:05:43 2000
From: insyte@emt-p.org (Ben Beuchler)
Date: Mon, 25 Sep 2000 19:05:43 -0500
Subject: [Tutor] Stepping backwards through a FOR loop?
In-Reply-To: <20000925235547.22548.qmail@web311.mail.yahoo.com>; from dizznog@yahoo.com on Mon, Sep 25, 2000 at 04:55:47PM -0700
References: <20000925235547.22548.qmail@web311.mail.yahoo.com>
Message-ID: <20000925190543.A8748@emt-p.org>

On Mon, Sep 25, 2000 at 04:55:47PM -0700, Peter Curran wrote:

> I've got a list of strings that I created with the
> string.split function, now I want to step through them
> in reverse order, but I'm not having any luck.  I
> tried appending a ".reverse" to my list variable

Make that a .reverse() and you're all set.

It's the easy stuff that'll get ya every time.

Ben

-- 
Ben Beuchler                                         insyte@bitstream.net
MAILER-DAEMON                                         (612) 321-9290 x101
Bitstream Underground                                   www.bitstream.net


From deirdre@deirdre.net  Tue Sep 26 00:57:15 2000
From: deirdre@deirdre.net (Deirdre Saoirse)
Date: Mon, 25 Sep 2000 16:57:15 -0700 (PDT)
Subject: [Tutor] CGI fails
In-Reply-To: <20000920112508.A2714@dman>
Message-ID: <Pine.LNX.4.10.10009251647360.7940-100000@rockhopper.deirdre.org>

On Wed, 20 Sep 2000, D-Man wrote:

> I was trying the "Hello World" example (attached), but I get an
> "Internal Server Error".  The error log file says:

Please put code in the body of the email message, not as an attachment. As
it has the wrong MIME type for text, Pine didn't want to read it. bah.

> [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] Premature end of
> script headers: /home/dman/public_html/script.py.cgi
> [Wed Sep 20 11:19:16 2000] [error] [client 129.21.137.39] Premature end of
> script headers: /home/dman/public_html/script.py.cgi
> 
> What does this mean and how do I fix it?

Usually it means you forgot the extra print statement after the headers.

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"More damage has been caused by innocent program crashes than by 
malicious viruses, but they don't make great stories."
                   --  Jean-Louis Gassee, Be Newsletter, Issue 69



From griff@netdoor.com  Tue Sep 26 03:53:06 2000
From: griff@netdoor.com (R. A.)
Date: Mon, 25 Sep 2000 21:53:06 -0500
Subject: [Tutor] text file parsing question
Message-ID: <39D00F92.D033DC8A@netdoor.com>

Python seems great so far for working with text.  Can anyone point out a
good source of info relating to parsing files.  The example that causes
me to bring it up is taking a text file containing directory info and
performing calculations on given columns.

I'm not looking for the code to do this, but any pointers on where to
look for more info.

Thanks,

Rob Andrews
-- 
GIT/P/TW d---(++) s++:s a? C+++++ U$>+++ P+ L+>++++ E@ W++ N++ o? K- w$
?O ?M ?V PS+++ PE Y+@ PGP- t+@ 5 X@ R+ tv+ b+++ DI+@ D+ Q3A++ e++* h* r
y++* UF+++


From alan.gauld@freenet.co.uk  Tue Sep 26 14:25:46 2000
From: alan.gauld@freenet.co.uk (Alan Gauld)
Date: Tue, 26 Sep 2000 13:25:46 +0000
Subject: [Tutor] Parsing text files
Message-ID: <3.0.1.32.20000926132546.0076c594@mail.freenet.co.uk>

Re parsing text files.

1st AWK is even better for the sort of thing 
you want to do. If you have it available give it a whirl.

AWK reads each line and splits it into numbered fields for you: 
$0 = whole line
$1 = 1st field
$2...$NF = fields 2 up to the last field

Now in Python you can do something similar with the 
string.split() function or for more power try the 
re.split() function which uses a regex as a field 
separator... something like:

for line in file.readlines():
	fields = line.split()
      total = total + fields[5]  # or whichever dir field you need

Alan G.



From griff@netdoor.com  Tue Sep 26 13:47:04 2000
From: griff@netdoor.com (R. A.)
Date: Tue, 26 Sep 2000 07:47:04 -0500
Subject: [Tutor] Parsing text files
References: <3.0.1.32.20000926132546.0076c594@mail.freenet.co.uk>
Message-ID: <39D09AC8.203B1B6E@netdoor.com>

Much appreciated.  I love an excuse to add another tool to my belt, and
I may well try both lines of attack, as this is as much a learning
experiment as an administration problem.

Rob Andrews

Alan Gauld wrote:
> 
> Re parsing text files.
> 
> 1st AWK is even better for the sort of thing
> you want to do. If you have it available give it a whirl.
> 
> AWK reads each line and splits it into numbered fields for you:
> $0 = whole line
> $1 = 1st field
> $2...$NF = fields 2 up to the last field
> 
> Now in Python you can do something similar with the
> string.split() function or for more power try the
> re.split() function which uses a regex as a field
> separator... something like:
> 
> for line in file.readlines():
>         fields = line.split()
>       total = total + fields[5]  # or whichever dir field you need
> 
> Alan G.
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

-- 
GIT/P/TW d---(++) s++:s a? C+++++ U$>+++ P+ L+>++++ E@ W++ N++ o? K- w$
?O ?M ?V PS+++ PE Y+@ PGP- t+@ 5 X@ R+ tv+ b+++ DI+@ D+ Q3A++ e++* h* r
y++* UF+++


From rhayden@amsusa.com  Tue Sep 26 19:52:28 2000
From: rhayden@amsusa.com (Richard Hayden)
Date: Tue, 26 Sep 2000 14:52:28 -0400
Subject: [Tutor] Looking for a random number generator that supports asymmmetric triangular and Gaussian distributions
Message-ID: <002801c027ea$ebaa2200$0500a8c0@richard>

Any pointers for asymmetric (skewed) random number generators for Gaussian
and triangular distributions?

Thanks, Richard Hayden




From alan.gauld@bt.com  Wed Sep 27 11:19:53 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 27 Sep 2000 11:19:53 +0100
Subject: [Tutor] question: how do you pass a function as argument for
 application?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D322@mbtlipnt02.btlabs.bt.co.uk>

> Also, I am trying to do this in the object framwork:
> 
> class C:
> 	def method(sefl, arg):
> 		print self, arg
> 
> 	def methodApply(self, meth, arg):
> 	????	self.meth(arg)

>>> class foo:
...   def doit(self,arg):
...       print self, arg
...   def call(self,meth,arg):
...       meth(arg)
...
>>> f = foo()
>>> f.call(f.doit,'foobar')
<__main__.foo instance at 7f8140> foobar
>>>

Alan G.


From alan.gauld@bt.com  Wed Sep 27 11:22:48 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 27 Sep 2000 11:22:48 +0100
Subject: [Tutor] RE: Tutor digest, Vol 1 #430 - 7 msgs
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D323@mbtlipnt02.btlabs.bt.co.uk>

Dunno if this is answered already, I'm just back from vacation...

You can only have 1 Tk() in a program, you already have 
root = Tk() 
so will need to use 
root.title().

At least I think that's the problem, I haven't tried it :-)

Alan G.

> -----Original Message-----
> From: tutor-admin@python.org 
> [mailto:tutor-admin@python.org]On Behalf Of
> tutor-request@python.org
> Sent: Wednesday, September 20, 2000 5:03 PM
> To: tutor@python.org
> Subject: Tutor digest, Vol 1 #430 - 7 msgs
> 
> 
> 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..."
> 
> 


From alan.gauld@bt.com  Wed Sep 27 18:19:59 2000
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 27 Sep 2000 18:19:59 +0100
Subject: [Tutor] RE: Tutor digest, Vol 1 #430 - 7 msgs
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D32D@mbtlipnt02.btlabs.bt.co.uk>

> Dunno if this is answered already, I'm just back from vacation...

Doh, and it shows!

I meant to send that directly to the original poster, 
not to the list.

Apologies to all.

Alan G.

> 
> You can only have 1 Tk() in a program, you already have 
> root = Tk() 
> so will need to use 
> root.title().
> 
> At least I think that's the problem, I haven't tried it :-)
> 
> Alan G.
> 
> > -----Original Message-----
> > From: tutor-admin@python.org 
> > [mailto:tutor-admin@python.org]On Behalf Of
> > tutor-request@python.org
> > Sent: Wednesday, September 20, 2000 5:03 PM
> > To: tutor@python.org
> > Subject: Tutor digest, Vol 1 #430 - 7 msgs
> > 
> > 
> > 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..."
> > 
> > 
> 
> 
> 
> 


From s349929@student.uq.edu.au  Wed Sep 27 23:32:40 2000
From: s349929@student.uq.edu.au (Suzanne Little)
Date: Thu, 28 Sep 2000 08:32:40 +1000 (GMT+1000)
Subject: [Tutor] arguements
Message-ID: <Pine.OSF.4.21.0009280821370.29052-100000@student.uq.edu.au>

Hello, 

Would someone be able to explain to me (or point me to an
explanation) what the * and ** mean? These occur in the argument list to
some methods I've been reading in Tkinter. For example the keyword
dictionary **kw. What is included in this dictionary and how does it
work? How can I access it or use it? Why, when I pass it to another method
in the init method do I need to do it as just kw? I've also seen the *
used in things like *args. How does this work? And what does it do?

Sorry if this is blatantly obvious or in an obvious spot but I can't find
anything that explains it in depth. My suspicions are that it's used
when you could have any number of arguments but what restrictions and
how they're used - I don't know. The questions I've asked above are just
so you have an idea of what I'm looking for.

As always, thank-you very much for any and all help.

Suzanne

--------------------------------------------------------------------------
"Contrariwise," continued Tweedledee, "If it was so, it might be; and if
it were so, it would be; but as it isn't, it ain't.  That's logic"
                             -Lewis Carroll
--------------------------------------------------------------------------



From prospero@bigwig.net  Thu Sep 28 02:02:12 2000
From: prospero@bigwig.net (Prospero)
Date: Thu, 28 Sep 2000 02:02:12 +0100
Subject: [Tutor] File types
Message-ID: <002501c028e7$df2d0580$f131fea9@miranda>

Greetings!

I am writing a program which requires the use of two data files, both very
large, both containing groups of integers and one possibly containing
one-letter or one-word entries with each group. I know a little about text
files but nothing about numeric files or databases. Can anyone tell me
either how to set these up or where (preferably on the web) to find this
information?

TIA,

Prospero.

"Never be bullied into silence. Never allow yourself to be made a victim.
Accept no one's definition of your life; define yourself."
--Harvey Fierstein

Prospero's World:  http://www.bigwig.net/prospero



From wilkins@iinet.net.au  Thu Sep 28 03:58:35 2000
From: wilkins@iinet.net.au (Richard Wilkins)
Date: Thu, 28 Sep 2000 10:58:35 +0800
Subject: [Tutor] Help with cmd, Cmd() & cmdloop
Message-ID: <LPBBLIGDAGDBFLEGANCGKEOJCBAA.wilkins@iinet.net.au>

SGkgYWxsLA0KDQpJJ20gbmV3IHRvIFB5dGhvbiwgYW5kIHdhcyB3b25kZXJpbmcgaWYgc29tZW9u
ZSBjb3VsZCBoZWxwIG1lIHdpdGggY21kbG9vcC4gSXQgc2F5cyBpbiB0aGUgZG9jdW1lbnRhdGlv
biB0byBoYXZlIGEgbWV0aG9kIGNhbGxlZCBkb19zb21ldGhpbmcgd2hpY2ggd2lsbCBiZSBjYWxs
ZWQgdXBvbiBhIHN0cmluZyBlbnRyeSBvZiAnc29tZXRoaW5nJyBpbiB0aGUgY21kbG9vcC4gQ291
bGQgc29tZW9uZSBwbGVhc2UgdGVsbCBtZSBob3cgdG8gaW5jb3Jwb3JhdGUgdGhlc2UgbWV0aG9k
cyB3aXRoIHRoZSBjbWRsb29wLCBiZWNhdXNlIEkgcmVhbGx5IGhhdmUgbm8gaWRlYS4uLg0KDQpU
aGFua3MsDQoNCkFuZHJldyBXaWxraW5z



From jstok@bluedog.apana.org.au  Thu Sep 28 03:58:36 2000
From: jstok@bluedog.apana.org.au (Jason Stokes)
Date: Thu, 28 Sep 2000 13:58:36 +1100
Subject: [Tutor] arguements
References: <Pine.OSF.4.21.0009280821370.29052-100000@student.uq.edu.au>
Message-ID: <39D2B3DC.B5E042D9@bluedog.apana.org.au>

Suzanne Little wrote:
> 
> Hello,
> 
> Would someone be able to explain to me (or point me to an
> explanation) what the * and ** mean? These occur in the argument list to
> some methods I've been reading in Tkinter. For example the keyword
> dictionary **kw. What is included in this dictionary and how does it
> work? How can I access it or use it? Why, when I pass it to another method
> in the init method do I need to do it as just kw? I've also seen the *
> used in things like *args. How does this work? And what does it do?

The * character in a function signature indicates that function accepts
a variable number of positional arguments.  The arguments are provided
at a call site thusly:

foo(a, b, optional1, optional2, ...)

But actually passed to the function as a tuple referred to by the name
given in the signature -- in this case, "args".

The ** declarer means the same thing, but this time referring to a
variable number of keyword arguments of the form:

foo(a, b, option1 = q, option2 = p)

These are passed as pairs in a dictionary referred to by the name given
in the signature -- in this case, kw.

If these two declarers are used together in a function, that means it
accepts a variable number of positional arguments and a variable number
of keyword arguments. The syntax for this is clear if you always put the
positional arguments first and the keyword arguments second.

The main use of the variable-sized keyword arguments in the Tkinter
module is to provide support for the extensive use of variable numbers
of keyword arguments used within Tk/TCL itself.  

* has no relationship at all with the C pointer dereferencing operator
that uses the same Ascii symbol.

The reason you need to pass kw to another method called from init is
simply because it's not a special datatype, simply a dictionary with the
special property that, before the call is executed, the interpreter
examines the keyword arguments, takes ones that don't match any of the
formal paramaters, and inserts them in the dictionary so you can get
access to them.  You'd have no way of accessing those variables
otherwise.

Cheers,
Jason Stokes: jstok@bluedog.apana.org.au


From jstok@bluedog.apana.org.au  Thu Sep 28 09:23:33 2000
From: jstok@bluedog.apana.org.au (Jason Stokes)
Date: Thu, 28 Sep 2000 19:23:33 +1100
Subject: [Tutor] Help with cmd, Cmd() & cmdloop
References: <LPBBLIGDAGDBFLEGANCGKEOJCBAA.wilkins@iinet.net.au>
Message-ID: <39D30005.C276BD5B@bluedog.apana.org.au>

Richard Wilkins wrote:
> 
> Hi all,
> 
> I'm new to Python, and was wondering if someone could help me with cmdloop. It 
> says in the documentation to have a method called do_something which will be 
> called upon a string entry of 'something' in the cmdloop. Could someone please 
> tell me how to incorporate these methods with the cmdloop, because I really have 
> no idea...

Ok.  class Cmd is a skeleton implementation of a simple command
interpreter that takes commands on input and dispatches methods
associated with them.  Cmd is an abstract base class that shouldn't be
instantiated directly.  Instead, you should inherit from Cmd and
override its methods to provide your own behaviour for the interpreter. 
For every command "x" you wish your interpreter to understand, define a
"do_x" method in your derived class.  This will be called when the
associated command is inputted into the interpreter's session.  You can
also define a method "help_x" that is called when the user types the
command "help x".  Here's an example of how this works: a simple "Echo"
interpreter with two commands: "echo", and "quit":

import cmd
class EchoString(cmd.Cmd):
   def do_echo(self, message):
      print message
      return(0)
   def help_echo(self):
      print "Echoes the line right back at ya!"
      return(0)
   def do_quit(self, message):
      print "Goodbye"
      return(1)
   def help_quit(self):
      print "Quits the session"

Example of use:

echo = EchoString()
echo.cmdloop()

The prompt now changes to indicate we're giving input to the Cmd
interpreter:

(Cmd) help 

Documented commands (type help <topic>):
========================================
echo            quit            

Undocumented commands:
======================
help            

(Cmd) help echo
Echoes the line right back at ya!
(Cmd) help quit
Quits the session
(Cmd) echo Hello, world!
Hello, world!
(Cmd) quit
Goodbye

Hope this helps,
Jason Stokes: jstok@bluedog.apana.org.au


From pyachnes@worldshare.net  Sat Sep 30 15:59:16 2000
From: pyachnes@worldshare.net (Paul Yachnes)
Date: Sat, 30 Sep 2000 10:59:16 -0400
Subject: [Tutor] Freeze
Message-ID: <001701c02aef$0207f480$51d0f4d1@safwan>

I have a fairly simple script that I want to turn into a standalone
application. I read that I can do this with a tool calle "Freeze" but I
cannot find it in my Python -->Tools subdirectory. I have also looked on the
python.org web site but can't find it. Can anyone tell me where I can find
this and if it works well?

Paul Yachnes



From griff@netdoor.com  Sat Sep 30 18:04:55 2000
From: griff@netdoor.com (R. A.)
Date: Sat, 30 Sep 2000 12:04:55 -0500
Subject: [Tutor] Freeze
References: <001701c02aef$0207f480$51d0f4d1@safwan>
Message-ID: <39D61D37.CCB62A55@netdoor.com>

I haven't used it yet, m'self, but the Python FAQ reads thusly:

Even though there are Python compilers being developed, you probably
don't need a real compiler, if all you want is a stand-alone program.
There are three solutions
to that. 

One is to use the freeze tool, which is included in the Python source
tree as Tools/freeze. It converts Python byte code to C arrays. Using a
C compiler, you can embed
all your modules into a new program, which is then linked with the
standard Python modules. 

On Windows, another alternative exists which does not require a C
compiler. Christian Tismer's SQFREEZE
(http://starship.python.net/crew/pirx/) appends the byte
code to a specially-prepared Python interpreter, which will find the
byte code in executable. 

Gordon McMillian offers with Installer
(http://starship.python.net/crew/gmcm/distribute.html) a third
alternative, which works similar to SQFREEZE, but allows to
include arbitraty additional files in the stand-alone binary as well. 

Rob Andrews

Paul Yachnes wrote:
> 
> I have a fairly simple script that I want to turn into a standalone
> application. I read that I can do this with a tool calle "Freeze" but I
> cannot find it in my Python -->Tools subdirectory. I have also looked on the
> python.org web site but can't find it. Can anyone tell me where I can find
> this and if it works well?
> 
> Paul Yachnes
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

-- 
GIT/P/TW d---(++) s++:s a? C+++++ U$>+++ P+ L+>++++ E@ W++ N++ o? K- w$
?O ?M ?V PS+++ PE Y+@ PGP- t+@ 5 X@ R+ tv+ b+++ DI+@ D+ Q3A++ e++* h* r
y++* UF+++


From duckpond@early.com  Sat Sep 30 19:48:32 2000
From: duckpond@early.com (Tom Connor)
Date: Sat, 30 Sep 2000 14:48:32 -0400
Subject: [Tutor] Re: Tutor digest, Vol 1 #440 - 1 msg
References: <20000930160107.21B3C1CDEF@dinsdale.python.org>
Message-ID: <39D63580.A8C04D92@early.com>

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

>   Learning Python, P. 138, has a box which discusses this briefly.  I just
> read it 2 days ago.  It suggests a search on the Python web site for
> details.  (Disucussion includes "squeeze", and compiled code.

Tom Connor



> I have a fairly simple script that I want to turn into a standalone
> application. I read that I can do this with a tool calle "Freeze" but I
> cannot find it in my Python -->Tools subdirectory. I have also looked on the
> python.org web site but can't find it. Can anyone tell me where I can find
> this and if it works well?
>
> Paul Yachnes
>
> --__--__--
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>
> End of Tutor Digest

--------------94C77CB9089356769B55753B
Content-Type: text/x-vcard; charset=us-ascii;
 name="duckpond.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Tom Connor
Content-Disposition: attachment;
 filename="duckpond.vcf"

begin:vcard 
n:Connor;Tom
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:duckpond@early.com 
note:Remove (no spam) from email address to respond.
x-mozilla-cpt:;-10272
fn:Tom Connor
end:vcard

--------------94C77CB9089356769B55753B--



From DOUGS@oceanic.com  Sat Sep 30 20:22:06 2000
From: DOUGS@oceanic.com (Doug Stanfield)
Date: Sat, 30 Sep 2000 09:22:06 -1000
Subject: [Tutor] Freeze
Message-ID: <8457258D741DD411BD3D0050DA62365907A36A@huina.oceanic.com>

[ Paul Yachnes wrote: ]
> > 
> > I have a fairly simple script that I want to turn into a standalone
> > application.

[To which Rob Andrews with a list of options]
> There are three solutions to that. 
> 
> the freeze tool, which is included in the Python source tree as
Tools/freeze. 
> On Windows, another alternative ...Christian Tismer's SQFREEZE
>                 (http://starship.python.net/crew/pirx/) 
> Gordon McMillian offers with Installer
>            (http://starship.python.net/crew/gmcm/distribute.html)

These days I think the consensus is that the best choice is Gordan
McMillan's installer.

This message was posted recently on c.l.py:

------------included message-------------
jpl@remotejava.NOSPAM.com (Jan Ploski) writes:

> This is certainly a very newbie-ish question, but is it possible to write
> code in Python and then compile it into a win32 executable?

It's not really compiling, but you can use Gordan McMillan's installer
package (at http://www.mcmillan-inc.com/install1.html).

This automatically tracks down the various dependencies of your script
and puts it all together (along with some very nice archive formats
for the various library routines) into an executable that can be run
directly.  You generally end up with the exe, a pyz for python library
files a few standlone files (like exceptions.pyc) and any external
modules (dll/pyd).  That collection of files is all you need to run
your application.

The installer package has a simple installation script (console based
- prompts for a directory and unpacks), but you can combine the
installer with a Windows installation package.  That can be
InstallShield, Wise, or for my purposes, I use the free Inno Setup
(http://www.jrsoftware.org), and you end up with your Python
application looking just like a native installed Windows application,
and being totally self-contained within its installation directory.
Users install/uninstall it just like any other Windows application.

> Specifically, I would like to know whether it makes sense to try to write
> a custom installer in Python for a Java application (some file copying,
> extraction, and manipulation of the Windows registry is needed). I would
not
> like to buy nor learn Visual C++ for that purpose. Buying a shrink-wrapped
> installer like InstallAnywhere is an alternative, but I am curious if
Python
> could come to rescue. If that's completely unrealistic (i.e. a 5 MB Python
> interpreter needed to get started), let me know. I have no idea.

I'd probably go with an established solution (which doesn't have to
mean commercial) if it were me.  Not because Python couldn't do it -
I'm sure you could - but because there can be a lot of messiness with
Windows installations (locked files, DLL registration, etc...).  Also,
while it wouldn't be 5MB, any Python installation tool would certainly
take at least the 500-600K of the Python DLL and whatever extensions
(such as the win32 registry module) you used.  That contrasts with
about 275K for Inno Setup, for example.  Not much of an issue with
network based installs, but could hurt on a diskette setup.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l@fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/
-- 
http://www.python.org/mailman/listinfo/python-list


From FxItAL@aol.com  Sat Sep 30 21:12:02 2000
From: FxItAL@aol.com (FxItAL@aol.com)
Date: Sat, 30 Sep 2000 16:12:02 EDT
Subject: [Tutor] winsound
Message-ID: <7f.a531b0e.2707a312@aol.com>

Hello,

I'm having difficulty getting the SND_LOOP flag to work. The sound will play 
if I use SND_ASYNC, but only once.  I'd like to loop the sound and then be 
able to stop it with SND_PURGE.  Any help is greatly appreciated.

Python 1.6 on Windows ME

Thanks Al