[Tutor] (no subject)

Alan Gauld alan.gauld at btinternet.com
Sat Nov 12 10:33:58 CET 2011


On 11/11/11 22:17, Andreas Perstinger wrote:

> I don't know about windows but if you want to run the script from the
> command line you have to add:
>
> if __name__ == "__main__":
> main()

No, you only need to do that if you plan on using the file as a module 
at some point. If you don't need a module then the OPs style will work 
just fine on any OS.

But since having module facilities is so easy it is good practice to 
always use the if main clause...

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



More information about the Tutor mailing list