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.

Title: Use __spec__.__name__ instead of __name__ in the docs where appropriate
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Antony.Lee, docs@python
Priority: normal Keywords:

Created on 2015-12-19 22:39 by Antony.Lee, last changed 2022-04-11 14:58 by admin.

Messages (2)
msg256743 - (view) Author: Antony Lee (Antony.Lee) * Date: 2015-12-19 22:38
There are a couple of places in the docs where it would be appropriate to replace __name__ by __spec__.__name__ in order to support the case where the module is executed as the __main__ module:

- logging.getLogger should certainly use __spec__.__name__ so that the logger hierarchy be respected (otherwise, when running "python -mpkg.subpkg", the logger of pkg.subpkg is named "__main__" and thus not a child of the "pkg" logger).

- examples for argparse.ArgumentParser (e.g. in the docs for venv) should use __spec__.__name__ instead of __name__ for the "prog=" argument.

(not guaranteed to be exhaustive)
msg256776 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-12-20 17:24
Trick with all of these suggestions is going to be thinking through compatibility issues from the change (which also means it can only apply to the default branch).
Date User Action Args
2022-04-11 14:58:25adminsetgithub: 70100
2020-09-11 23:16:03brett.cannonsetnosy: - brett.cannon
2015-12-20 17:24:31brett.cannonsetnosy: + brett.cannon
messages: + msg256776
2015-12-20 17:23:06brett.cannonsetassignee: docs@python ->
stage: test needed
type: enhancement
components: + Library (Lib), - Documentation
versions: - Python 3.5
2015-12-19 22:39:00Antony.Leecreate