main in mac?

Doug Hellmann doughellmann at
Wed Mar 14 12:37:01 CET 2001

On 13 Mar 2001 17:32:30 +0000, Park997 wrote:
> >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
> > 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.


More information about the Python-list mailing list