Question about modules documentation

Tobiah toby at tobiah.org
Fri Sep 15 12:08:42 EDT 2017


Re-reading I guess the plural refers to the multiple modules
referenced in the first sentence.  It was probably written that
way before someone inserted the bit about the customary placement,
which greatly clouds the connection. 



On 09/15/2017 09:03 AM, Tobiah wrote:
> In this doc:
> 
> 	https://docs.python.org/2/tutorial/modules.html
> 
> Near the top it states:
> 
> 	Modules can import other modules. It is customary but not
> 	required to place all import statements at the beginning
> 	of a module (or script, for that matter). The imported
> 	module names are placed in the importing module’s global
> 	symbol table.
> 
> When it refers to 'the imported module names' it sounds as though
> it is referring to the top level variables and functions in the
> imported module.  This is not the case as far as I can tell.
> 
> 
> If bar.py has a function bar() and in foo.py I do:
> 
> 	import bar
> 	bar()
> 
> of course this fails.  I have to do:
> 	
> 	import bar
> 	bar.bar()
> 
> I know it would work if I went:
> 	
> 	from bar import *
> 	bar()
> 
> but that feature is only introduced in the next section
> of the doc.
> 
> It seems that if the statement read:
> 
> 	the imported module's name (singular) is placed in the
> 	importing module's global symbol table.
> 
> That it would be more accurate.
> 
> 
> 
> 




More information about the Python-list mailing list