[Python-ideas] Replacing the if __name__ == "__main__" idiom (was Re: making a module callable)
Eric Snow
ericsnowcurrently at gmail.com
Fri Dec 6 17:31:47 CET 2013
On Dec 6, 2013 9:29 AM, "Eric Snow" <ericsnowcurrently at gmail.com> wrote:
> That said, I like how __main__.py makes a clear separation between the
package and its script form. As I said in my opening email, I think that
distinction is very fuzzy for modules in general and bites both beginners
and advanced users. For me anything that proposed replacing the current "if
__name__ == '__main__'" idiom should help make the script/module separation
more distinct.
Regardless, it may be worth adding an additional approach to highlighting
the script/module duality. We could raise a warning when a module
(findable on sys.path) is run as script unless via the "-m" flag.
-eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131206/a70e2e14/attachment.html>
More information about the Python-ideas
mailing list