[Tutor] __name__=='__main__'

Steven D'Aprano steve at pearwood.info
Tue Feb 21 00:54:47 CET 2012


Michael Lewis wrote:

> Error I got when __name == ' __main__' was outside of any function:
> 
> Traceback (most recent call last):
>   File "C:/Python27/Homework/Homework5_1.py", line 24, in <module>
>     if __name == '__main__':
> NameError: name '__name' is not defined


You have misspelled __name__ as __name.


-- 
Steven



More information about the Tutor mailing list