-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
gh-137337: Clarify import statement namespace binding #144607
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
base: main
Are you sure you want to change the base?
Conversation
The import statement docs said names are defined "in the local namespace", which is inaccurate when the name has been declared global or nonlocal. Update to say "current namespace... just as an assignment statement would", per discussion with nedbat, serhiy-storchaka, and terryjreedy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
johnslavik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
Doc/reference/simple_stmts.rst
Outdated
| the :keyword:`import` statement occurs. | ||
| #. define a name or names in the current namespace for the scope where | ||
| the :keyword:`import` statement occurs, just as an assignment statement | ||
| would, including global, local, and nonlocal semantics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this would be a little clearer?
| would, including global, local, and nonlocal semantics. | |
| would (including :keyword:`global` and :keyword:`nonlocal` semantics). |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @nedbat: please review the changes made to this pull request. |
Summary
The import statement documentation says names are defined "in the local namespace," which is inaccurate when the imported name has been declared
globalornonlocal:Updates two places in
Doc/reference/simple_stmts.rst:importdescription (step 2): "local namespace" -> "current namespace... just as an assignment statement would, including global, local, and nonlocal semantics"from ... importdescription (step 2.d): "local namespace" -> "current namespace"This follows the wording proposed by @nedbat and discussed with @serhiy-storchaka and @terryjreedy in the issue thread.
Test plan
make -C Doc checkpassesmake -C Doc htmlpasses (no warnings)🤖 Generated with Claude Code
importstatement should include binding toglobalandnonlocalnamespaces #137337📚 Documentation preview 📚: https://cpython-previews--144607.org.readthedocs.build/