Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-33944: note about the intended use of code in .pth files #10131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Doc/library/site.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ directory rather than a file. No item is added to ``sys.path`` more than
once. Blank lines and lines beginning with ``#`` are skipped. Lines starting
with ``import`` (followed by space or tab) are executed.

.. note::

An executable line in a :file:`.pth` file is run at every Python startup,
regardless of whether a particular module is actually going to be used.
Its impact should thus be kept to a minimum.
The primary intended purpose of executable lines is to make the
corresponding module(s) importable
(load 3rd-party import hooks, adjust :envvar:`PATH` etc).
Any other initialization is supposed to be done upon a module's
actual import, if and when it happens.
Limiting a code chunk to a single line is a deliberate measure
to discourage putting anything more complex here.

.. index::
single: package
triple: path; configuration; file
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a note about the intended use of code in .pth files.