[Tutor] __name__=='__main__'
Jerry Hill
malaclypse2 at gmail.com
Tue Feb 21 00:53:38 CET 2012
On Mon, Feb 20, 2012 at 6:46 PM, Michael Lewis <mjolewis at gmail.com> wrote:
> I at first put it outside and after all my functions but got the error below
That's the right place for it, you just spelled it wrong.
> and then put it inside my last function and the program ran.
That's not the right place for it. Your program ran, but only because
nothing ever called your GetUserInput() function any more.
> 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
It needs to be spelled "__name__" -- that's two underscores on each side.
--
Jerry
More information about the Tutor
mailing list