Skip to content

gh-71261: Add paragraph on shadowing submodules with star imports #107004

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

Conversation

wulmer
Copy link
Contributor

@wulmer wulmer commented Jul 22, 2023

This PR extends the tutorial on modules and packages by adding a paragraph on the from abc import * problem in case of duplicate names for submodules and locally defined objects (e.g. functions).

It intends to solve #71261 by providing an example of how a locally defined function breaks the import of submodules.


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

]

def reverse(msg: str): # <-- this name shadows the 'reverse.py' submodule
return msg[::-1] # in case of an 'from sound.effects import *'
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest: "in the case of a ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Done.

@hugovk hugovk merged commit 680f3e1 into python:main Jul 23, 2023
@miss-islington
Copy link
Contributor

Thanks @wulmer for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @wulmer for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 23, 2023
…ts (pythonGH-107004)

(cherry picked from commit 680f3e1)

Co-authored-by: wulmer <wulmer@users.noreply.github.com>
@bedevere-bot
Copy link

GH-107099 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 23, 2023
@bedevere-bot
Copy link

GH-107100 is a backport of this pull request to the 3.12 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 23, 2023
…ts (pythonGH-107004)

(cherry picked from commit 680f3e1)

Co-authored-by: wulmer <wulmer@users.noreply.github.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jul 23, 2023
hugovk pushed a commit that referenced this pull request Jul 23, 2023
…rts (GH-107004) (#107100)

Co-authored-by: wulmer <wulmer@users.noreply.github.com>
hugovk pushed a commit that referenced this pull request Jul 23, 2023
…rts (GH-107004) (#107099)

Co-authored-by: wulmer <wulmer@users.noreply.github.com>
jtcave pushed a commit to jtcave/cpython that referenced this pull request Jul 23, 2023
mementum pushed a commit to mementum/cpython that referenced this pull request Jul 23, 2023
@wulmer wulmer deleted the clarify-import-star-with-locally-defined-names branch August 7, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants