None in sys.modules.values()?

Rainer Deyke root at rainerdeyke.com
Sun Sep 10 11:50:12 EDT 2000


"Walter Dörwald" <walter at bnbt.de> wrote in message
news:8pg924$j8k$1 at nnrp1.deja.com...
> Python 2.0b1 seems to put stuff other than
> modules in sys.modules:
>
> > python
> Python 2.0b1 (#1, Sep  7 2000, 13:31:10)
> [GCC 2.95.2 19991024 (release)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> type(sys.modules["encodings.codecs"])
> <type 'None'>
>
> What's happening here?

This is an optimization related to imports from within packages.  Basically,
it says that 'encodings.codecs' does not exist, so any attempt to import
'codecs' from within the pacakage 'encodings' will get the global module
'codecs' instead of looking for a module named 'codecs' within package
'encodings'.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list