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
Tutorial is unclear on multiple imports of a module. #59780
Comments
Opening this bug at Ben Finney's request. See https://groups.google.com/forum/?fromgroups#!topic/comp.lang.python/wmDUrpW2ZCU for the full thread discussing the problem. Here's a significant excerpt: -------------------------------------------------
but it doesn't make clear that a module can exist in the ‘sys.modules’ Also note: --------------------------------------------------
I think what it's supposed to say is "... the execution of a module-level def statement ..." |
Well, I don't think a full discussion of the subtlety about a module appearing under multiple names belongs in the tutorial, but I think the sentence could be amended to say "Statements in a module are executed only the *first* time the module name is encountered in an import statement". The other is indeed a bug (IMO the sentence is missing the word 'definition', as in 'execution of a function definition'). |
Howdy; attached is a patch containing the doc changes. I figured that some elaboration was in addition to what r.david.murray recommended, so I've included a brief allusion to the problem of equivalent paths. |
New changeset 9df9931fae96 by R David Murray in branch '3.3': New changeset dac847938326 by R David Murray in branch 'default': New changeset a1421d28393b by R David Murray in branch '2.7': |
Thanks, James. I wound up going with a different wording for the "elaboration": since the concept of running a python file as a script is mentioned just a bit earlier, I added a parenthetical that the statements are also executed if the module is run as a script. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: