[Tutor] Problem with module

Lloyd Kvam pythontutor@venix.com
Sat, 02 Feb 2002 19:43:08 -0500

def c(p):
        spy = 60*60*24*365.2422
        n = long (spy)*long (p)
        return n

if __name__ == "__main__" :
        n = c(186000)
        print n

Both name and main are surrounded by double underscores.  When I pasted
from your email, name only had single underscores.

Including the traceback with your problem makes it a LOT easier to solve!

Try pasting this back into a script and see how you do.

Alistair McGowan wrote:

> 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

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358