[Python-ideas] Replacing the if __name__ == "__main__" idiom (was Re: making a module callable)
Gregory P. Smith
greg at krypto.org
Sat Nov 23 20:01:21 CET 2013
On Sat, Nov 23, 2013 at 10:00 AM, Bruce Leban <bruce at leapyear.org> wrote:
>
> On Nov 22, 2013 8:06 PM, "Steven D'Aprano" <steve at pearwood.info> wrote:
>
> > def __main__(argv):
> > ...
> >
> > is a cleaner (but less flexible) idiom that the current if __name__
> > business, and simpler for people to learn.
>
> If I had a time machine I would either do the __main__ function or
> alternatively:
>
> if __main__:
> ....
>
> but alas I can't time travel and changing it will *not* be simpler to
> learn because people will be seeing both the old idiom and the new idiom
> for a long time. While it's interesting to discuss from the standpoint of
> what's the best design, it's just not worth changing, IMHO.
>
That was why I said it'd be for the long long term... If we ever do
anything, I like this simple __main__ bool idea best. Decorators are too
much unnecessary complexity for the task.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131123/458a5a10/attachment.html>
More information about the Python-ideas
mailing list