[issue44552] incomplete documentation of __main__.py

Jack DeVries report at bugs.python.org
Fri Jul 2 16:05:24 EDT 2021


Jack DeVries <jdevries3133 at gmail.com> added the comment:

This is documented in Doc/library/runpy.rst. Specifically, here:

> For a simple script, the specified code is simply executed in a fresh module namespace. For a valid sys.path entry (typically a zipfile or directory), the entry is first added to the beginning of sys.path. The function then looks for and executes a __main__ module using the updated path. Note that there is no special protection against invoking an existing __main__ entry located elsewhere on sys.path if there is no such module at the specified location.

https://docs.python.org/3/library/runpy.html#runpy.run_path


However, I fully agree that Doc/library/__main__.rst is severely lacking; that's why I've rewritten it! Please consider providing your feedback on the open PR, and see bpo-39452

https://github.com/python/cpython/pull/26883



Note that the new docs in __main__.rst does explicitly reference runpy, so once merged, it'll guide people looking for this information in __main__.rst to the right place.

----------
nosy: +jack__d

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44552>
_______________________________________


More information about the Python-bugs-list mailing list