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

Guido van Rossum guido at python.org
Mon Nov 25 22:57:57 CET 2013


On Mon, Nov 25, 2013 at 1:44 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Mon, 25 Nov 2013 13:22:53 -0800
> Guido van Rossum <guido at python.org> wrote:
> >
> > (I don't get the point against my is_main() proposal that it also uses
> > magic. It's a builtin. *Of course* it is allowed to use magic.)
>
> Just because it is allowed to use magic doesn't mean it's a good idea,
> though.


Really? Many builtins do huge amounts of magic.


> I can imagine people struggling to understand how it works
> (and how they can replicate it), while the current idiom is very easy to
> understand.
>

Hm. I think most people who wonder how it works would learn something from
figuring it out (like I did as a child disassembling my mother's vacuum
cleaner :-). But most everyone else wonders why this is such a strange
idiom.

>
> I still don't think the current idiom is problematic, so I'm -0.8 on
> the whole thing :-)
>

Check the length of this thread. (And the ones before it. :-)

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131125/5b471ccb/attachment-0001.html>


More information about the Python-ideas mailing list