__main__ : What is this?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sat Oct 20 02:22:47 CEST 2007


En Fri, 19 Oct 2007 20:29:03 -0300, Robert Dailey <rcdailey at gmail.com>  
escribió:

> I've read various portions of the Python 2.5 documentation in an
> attempt to figure out exactly what the following condition represents:
>
> if __name__ == "__main__":
>     main()
>
> However, I was not able to determine what it is actually checking for.
> Could someone point me in the way of a tutorial or explain this for
> me? Thanks.

You won't find it (easily) on the 2.5 docs, but it's covered in the  
upcoming 2.6 tutorial:
http://docs.python.org/dev/tutorial/modules.html#executing-modules-as-scripts

-- 
Gabriel Genellina




More information about the Python-list mailing list