This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients docs@python, ezio.melotti, hynek, loewis, r.david.murray, techtonik, terry.reedy
Date 2012-06-23.06:48:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
As a native speaker, I agree that the sentence, in isolation, is hardly comprehensible. The previous one is also a bit flakey.

The situation is that top-level code executes in a module named __main__, which has one joint global/local namespace that is the global namespace for all subsidiary contexts. '__main__':<__main__ module> is added to sys.modules before user code is executed. The name __main__ is not normally in the __main__ (global) namespace, hence the comment about 'anonymous' in the first sentence. (It is not anonymous in sys.modules.) However (1) __main__ or any other module/namespace can 'import __main__' and get the reference to __main__ from sys.modules and (2) __main__ does have name __name__ bound to the *string* '__main__'. Hence a module can discover whether or not it *is* the __main__ module.

Part of the quoting confusion is that unquoted names in code become strings in namespace dicts, and hence quoted literals when referring to them as keys. What I did not realize until just now is that the __name__ attribute of a module *is* its name (key) in the module namespace (sys.modules dict). For instance, after 'import x.y' or 'from x import y', x.y.__name__ or y.__name is 'x.y' and that is its name (key) in sys.modules. So it appears that the __name__ of a package (sub)module is never just the filename (which I expected), and "__name__ is the module name" only if one considers the package name as part of the module name (which I did not).

The only non-capi reference to module.__name__ in the index is

3.2. The standard type hierarchy
"__name__ is the module’s name"

But what is the modules name? Its name in sys.modules, which is either __main__ or the full dotted name for modules in packages (as I just learned). Perhaps this could be explained better here.
Date User Action Args
2012-06-23 06:48:10terry.reedysetrecipients: + terry.reedy, loewis, techtonik, ezio.melotti, r.david.murray, docs@python, hynek
2012-06-23 06:48:08terry.reedysetmessageid: <>
2012-06-23 06:48:07terry.reedylinkissue15104 messages
2012-06-23 06:48:05terry.reedycreate