Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue15575] Tutorial is unclear on multiple imports of a module.

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Aug 7, 2012, 11:11 AM

Post #1 of 2 (37 views)
Permalink
[issue15575] Tutorial is unclear on multiple imports of a module.

New submission from Roy Smith:

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:

-------------------------------------------------
The tutorial is misleading on this. It it says plainly:

A module can contain executable statements as well as function
definitions. […] They are executed only the *first* time the module
is imported somewhere.

<URL:http://docs.python.org/tutorial/modules.html>

but it doesn't make clear that a module can exist in the ‘sys.modules’
list multiple times under different names.
-------------------------------------------------


Also note:

--------------------------------------------------
The footnote to that is wrong too:

> [1] In fact function definitions are also ‘statements’ that are ‘executed’; the execution of a module-level function enters the function name in the module’s global symbol table.

I think what it's supposed to say is "... the execution of a module-level def statement ..."
---------------------------------------------------

----------
assignee: docs [at] pytho
components: Documentation
messages: 167628
nosy: docs [at] pytho, roysmith
priority: normal
severity: normal
status: open
title: Tutorial is unclear on multiple imports of a module.
type: enhancement
versions: Python 2.7

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15575>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 7, 2012, 11:29 AM

Post #2 of 2 (35 views)
Permalink
[issue15575] Tutorial is unclear on multiple imports of a module. [In reply to]

R. David Murray added the comment:

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').

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15575>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.