[Tutor] __name__=='__main__'

Alan Gauld alan.gauld at btinternet.com
Tue Feb 21 09:27:12 CET 2012


On 21/02/12 03:07, Michael Lewis wrote:
> Now that I am better understanding '__name__'=='__main__',

 > if '__name__' == '__main__':
 >      GetUserInput()

Note that __name__ is a variable so it should NOT have quotes around it.
What you are doing is comparing two literal strings which are obviously 
different so the if block never gets executed.

It has to be:

if __name__ == '__main__':
       GetUserInput()


HTH

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list