main in mac?
David Porter
jcm at bigskytel.com
Tue Mar 13 10:25:08 EST 2001
* Park997 <park997 at aol.comnotospam>:
> 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.
I don't know what the run all button is (not on mac), but the whole reason
for this idiom is so it wont 'do anything' when imported. If a file named
x.py is imported, then it's __name__ is x. If it is being run as a program,
then it's __name__ is __main__.
David
More information about the Python-list
mailing list