__main__ : What is this?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Oct 20 00:27:50 EDT 2007


On Sat, 20 Oct 2007 00:26:22 +0000, Matimus wrote:

> The common pattern:
> 
> if __name__ == "__main__":
>   # do stuff
> 
> IMHO better written:
> 
> if "__main__" == __name__:
>     # do stuff

Apart from looking weird, what's the difference?


-- 
Steven.



More information about the Python-list mailing list