main in mac?

Park997 park997 at aol.comnotospam
Wed Mar 14 09:47:57 EST 2001


>> >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
>> 
>> I knew that was the expected behavior, and the
>> disadvantage of replacing if __name__ is __main__. 
>> with if 1: is that it does run when imported. Turning the run as main
>option on
>> or off produces the expected behavior on the mac.
>
>It's not that you're running on a Mac, it's that you're using an IDE. If
>you double click the saved file in the Finder the __name__ would be set
>to '__main__' as you expect -- just like if a Windows or UN*X user runs
>the file directly.
>
>Doug

This is true for .pyc files (created after import in
interactive window), but .py files only invoke the
IDE if "run as main" is not saved. I have also learned
that the pull down menu "scripts" in the ide will give
run as main behavior.

Wendell



More information about the Python-list mailing list