main in mac?

Just van Rossum just at letterror.com
Tue Mar 13 16:18:28 CET 2001


Park997 wrote:
> 
> Hi,
> 
> I am using Python 2.0 on a PPC mac. I have a module
> that is set up as follows:
> 
> from Numeric import *
> 
> class Epower:
> 
>         3 class functions defined
> 
> if __name__ == '__main__':
> 
>         test class and print output
> 
> This code does nothing if the run all button is pressed
> or if it is imported into interactive python.
> 
> when the above if statement is replaced by:
> 
> if 1:
> 
> the program runs properly with output. I thought that
> if __name__ == '__main__':
> is standard syntax. Does this need to be changed for mac
> Python?

No: if you look at the option popup menu -- which is very well hidden
at the top right corner of your edit window, it looks like an arrow --
there's an option called "run as __main__". This will set the __name__
variable in the script to "__main__".

Hope this helped,

Just



More information about the Python-list mailing list