Message163157
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. |
|
Date |
User |
Action |
Args |
2012-06-19 12:48:16 | r.david.murray | set | recipients:
+ r.david.murray, loewis, techtonik, docs@python, hynek |
2012-06-19 12:48:16 | r.david.murray | set | messageid: <1340110096.11.0.0030469386472.issue15104@psf.upfronthosting.co.za> |
2012-06-19 12:48:15 | r.david.murray | link | issue15104 messages |
2012-06-19 12:48:13 | r.david.murray | create | |
|