[Python-ideas] Replacing the if __name__ == "__main__" idiom (was Re: making a module callable)

Barry Warsaw barry at python.org
Mon Nov 25 20:42:44 CET 2013


On Nov 26, 2013, at 01:12 AM, Steven D'Aprano wrote:

>(1) Keep the status quo.

I'd have no problem with this.  The current idiom doesn't seem broken to me,
nor is it that hard to type.  I also don't think it's very hard to discover
given how common it is.

>if __main__:

If we *had* to make this easier to type, this would be my choice.  It doesn't
even have to be read-only, given that __name__ can be messed with, but usually
isn't.  Why then worry about __main__ getting messed with?

-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131125/677c5d37/attachment.sig>


More information about the Python-ideas mailing list