Skip to content

gh-141924:Splitting of Unrelated mixed ideas in one paragraph of the tutorial (sys.path section) - #141935

Open
SkvProgrammer wants to merge 4 commits into
python:mainfrom
SkvProgrammer:fixes/docs
Open

gh-141924:Splitting of Unrelated mixed ideas in one paragraph of the tutorial (sys.path section)#141935
SkvProgrammer wants to merge 4 commits into
python:mainfrom
SkvProgrammer:fixes/docs

Conversation

@SkvProgrammer

@SkvProgrammer SkvProgrammer commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

Splitting of Unrelated mixed ideas in one paragraph of the tutorial (sys.path section)

What's the problem

After initialization, Python programs can modify :data:sys.path. The
directory containing the script being run is placed at the beginning of the
search path, ahead of the standard library path. This means that scripts in that
directory will be loaded instead of modules of the same name in the library
directory. This is an error unless the replacement is intended. See section
:ref:tut-standardmodules for more information.


The first sentence describes the fact that Python programs can modify sys.path manually after initialization. The following sentences describe a separate and independent behavior: the directory of the executed script is automatically placed at the beginning of the module search path, which may cause shadowing of library modules with the same name.

These two behaviors are not logically connected yet are presented within a single paragraph without any transition. This may lead readers to incorrectly assume a relationship between manual modification of sys.path and the automatic placement of the script directory.

Improvement

Spliting the paragraph into two separate paragraphs, indicating that these are independent aspects of module lookup behavior. This will improve clarity and reduce potential confusion for readers.

from:

After initialization, Python programs can modify :data:sys.path. The
directory containing the script being run is placed at the beginning of the
search path, ahead of the standard library path. This means that scripts in that
directory will be loaded instead of modules of the same name in the library
directory. This is an error unless the replacement is intended. See section
:ref:tut-standardmodules for more information.


to:

After initialization, Python programs may modify :data:sys.path directly. This
can be useful in some situations, but it may also lead to import-related issues
if misused.

Independently of any manual changes, Python automatically places the directory
containing the executed script at the beginning of the module search path.
Because this entry precedes the standard library path, modules in the script
directory can shadow standard library modules of the same name. This is usually
unintended and can lead to confusing errors. See section :ref:tut-standardmodules
for more information.

📚 Documentation preview 📚: https://cpython-previews--141935.org.readthedocs.build/

Comment thread Doc/tutorial/modules.rst Outdated
Comment on lines +208 to +217
After initialization, Python programs may modify :data:sys.path directly. This
can be useful in some situations, but it may also lead to import-related issues
if misused.

Independently of any manual changes, Python automatically places the directory
containing the executed script at the beginning of the module search path.
Because this entry precedes the standard library path, modules in the script
directory can shadow standard library modules of the same name. This is usually
unintended and can lead to confusing errors. See section :ref:tut-standardmodules
for more information.

@StanFromIreland StanFromIreland Nov 25, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dedent the text.

@SkvProgrammer

Copy link
Copy Markdown
Contributor Author

@StanFromIreland please review the changes

@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 2, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34194403 | 📁 Comparing 1f1a807 against main (43a1869)

  🔍 Preview build  

1 file changed
± tutorial/modules.html

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants