[docs] [issue15104] Unclear language in __main__ description
R. David Murray
report at bugs.python.org
Tue Jun 19 14:48:16 CEST 2012
R. David Murray <rdmurray at bitdance.com> added the comment:
Hmm. I think that chapter could use a more extensive rewrite with some additional information provided. For example, you actually can have a __main__ module in a package, and anything inside it will execute when the package is run via -m.
The "otherwise anonymous" is a bit misleading, I think. The real distinction is that when a module is run as a script, __name__ is set to __main__, whereas when it is imported, __name__ is the module name. This distinction allows a module to easily detect when it is being run as a script rather than imported, and the "idiomatic 'conditional script' stanza" is how to implement the behavior of a module conditionally acting as a script depending on how it is accessed.
stage: -> needs patch
title: abusive language in __name__ description -> Unclear language in __main__ description
versions: +Python 2.7, Python 3.2, Python 3.3
Python tracker <report at bugs.python.org>
More information about the docs