[Tutor] Problem with module

Alistair McGowan bigal@geosci.uchicago.edu
Sat, 2 Feb 2002 17:25:53 -0500


--============_-1199433740==_ma============
Content-Type: text/plain; charset="us-ascii" ; format="flowed"

Dear Python Wranglers,
			Finally I am making the transition from 
BASIC. Most impressed by Python after the horrific encounters I had 
with C, which frustrated me so much I gave up.. I am having some 
problems getting a couple of programs in Ivan Van Laningham's 
otherwise great TY Python book to run. In case it makes any 
difference I am working on a Mac in OS 9. My stumbling block is the
if  __name__ == "_main_" :
 
Here is the code, which I have tried to run both as a script and 
within the interpreter. I can get the syntax error indicator to move 
around in the lines by in the _name_ part of the line, but can't get 
it to run.  I tried substituting console for main in the IDE. I have 
tried various iterations of the line spacing and numer to no avail. I 
also tried the MacPython site to look for some model code. I tried 
inserting the above line with only single quotes, but no joy. 
Apologies if this is a trival problem, but I hope I can repay the 
favor in the future.
	Cheers,
		Al

def c (p) :
	spy  = 60*60*24*365.2422
	n = long (spy)*long (p)
	return n
if  _name_  ==  "__main__" :
	n = c (186000)
	print n

Alistair J. McGowan
Department of Geophysical Sciences,
University of Chicago
Chicago
IL 60637

Phone: 773-955-4040 x5-1170
Fax: 773-702-9505

"Hope is a duty from which paleontologists are exempt."
				David Quammen
--============_-1199433740==_ma============
Content-Type: text/enriched; charset="us-ascii"

Dear Python Wranglers,

			Finally I am making the transition from BASIC. Most impressed by
Python after the horrific encounters I had with C, which frustrated me
so much I gave up.. I am having some problems getting a couple of
programs in Ivan Van Laningham's otherwise great TY Python book to run.
In case it makes any difference I am working on a Mac in OS 9. My
stumbling block is the

if  __name__ == "_main_" :

     

Here is the code, which I have tried to run both as a script and within
the interpreter. I can get the syntax error indicator to move around in
the lines by in the _name_ part of the line, but can't get it to run. 
I tried substituting console for main in the IDE. I have tried various
iterations of the line spacing and numer to no avail. I also tried the
MacPython site to look for some model code. I tried inserting the above
line with only single quotes, but no joy. Apologies if this is a trival
problem, but I hope I can repay the favor in the future.

	Cheers,

		Al


<fontfamily><param>Geneva</param><bigger>def c (p) :

	spy  = 60*60*24*365.2422

	n = long (spy)*long (p)

	return n

if  _name_  ==  "__main__" :

	n = c (186000)

	print n
</bigger></fontfamily>

Alistair J. McGowan

Department of Geophysical Sciences,

University of Chicago

Chicago

IL 60637


Phone: 773-955-4040 x5-1170 

Fax: 773-702-9505


"Hope is a duty from which paleontologists are exempt."

				David Quammen

--============_-1199433740==_ma============--