Namespaces, classes, and using standard modules

Dan Rawson daniel.rawson.take!this!out! at asml.nl
Wed Aug 13 10:36:18 EDT 2003


Fredrik Lundh wrote:
> Dan Rawson wrote:
> 
> 
>>I would have expected that importing os from the interactive prompt
>>would have worked, and that the 'import os' statement in MyClass.py
>>would have been ignored.
> 
> 
> every module has its own namespace.
> 
> 
>>Any comments or clues about how this SHOULD work would be appreciated!
> 
> 
> the manual is a good place to start:
> 
> http://www.python.org/doc/current/tut/node8.html#SECTION008100000000000000000
> http://www.python.org/doc/current/ref/naming.html
> 
Hmm . . .  I'm still a bit confused . . .  The naming doc says that

from MyClass import MyClass

will only import the stuff that is part of the class scope (if I read it correctly).  But it appears to also read and 
use the 'import os' at the module level for the MyClass.py file.

The second question is why "import os" doesn't work at the interactive prompt; once I say that, isn't that a 'global' ??

Thanks!

Dan





More information about the Python-list mailing list