[Tutor] Notepad++ question

Alan Gauld alan.gauld at btinternet.com
Fri Jun 15 01:58:15 CEST 2012

On 14/06/12 23:18, Alexander Quest wrote:

>     so far, there is no variable called "_name_", and even if there was,
>     why is it comparing it to "_main_"? Why can't the main function just

Note that in both cases there are two '_' characters before and after 
the name. __name__ and '__main__'. Double underscores usually indicates 
a special variable used by Python internally.

Thus __name__ is something that Python sets when the file is either 
imported or run, as others have already explained.

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list