How about some syntactic sugar for " __name__ == '__main__' "?
Joel Goldstick
joel.goldstick at gmail.com
Wed Nov 12 16:07:55 EST 2014
On Wed, Nov 12, 2014 at 4:02 PM, John Ladasky
<john_ladasky at sbcglobal.net> wrote:
> I have taught Python to several students over the past few years. As I have worked with my students, I find myself bothered by the programming idiom that we use to determine whether a module is being executed or merely imported:
>
> "if __name__ == '__main__':"
>
> The use of two dunder tokens -- one as a name in a namespace, and the other as a string, is intimidating. It exposes too much of Python's guts. As such, I think that it is less Pythonic than we might want. Myself, I've been programming in Python for a decade, and I still haven't dug very deeply into what exactly __name__ means or does.
>
> I would like to start a discussion about whether Python should include a function which executes this evaluation, and hides all of the unfriendly dunderish details. And if that's a good idea, I would invite a discussion of how, exactly, it should be implemented. I'm nowhere near proposing a PEP, but that may come later.
>
> Thanks for your thoughts.
> --
> https://mail.python.org/mailman/listinfo/python-list
How about a decorator?
--
Joel Goldstick
http://joelgoldstick.com
More information about the Python-list
mailing list