python - Difference between a loaded module and an initialized module? -
in reference manual stated that:
a complete python program executed in minimally initialized environment: built-in , standard modules available, none have been initialized, except
sys
(various system services),builtins
(built-in functions, exceptions , none) ,__main__
.
i uncertain "initialized" supposed mean here. thought module initialized if loaded , present in sys.modules
:
this dictionary maps module names modules have been loaded.
apparently, wrong because sys.modules
contains many other modules:
python -c "import sys; print(sys.modules.keys() - {'sys', 'builtins', '__main__'})" {'_stat', 'encodings.aliases', '_sitebuiltins', '_thread', 'io', '_weakrefset', 'genericpath', 'encodings.utf_8', 'codecs', 'os', '_weakref', '_codecs', '_frozen_importlib', '_io', '_frozen_importlib_external', 'os.path', '_warnings', '_bootlocale', '_signal', 'errno', '_imp', 'encodings.latin_1', 'sysconfig', 'marshal', 'encodings', 'usercustomize', 'site', 'posixpath', '_collections_abc', 'posix', '_sysconfigdata_m_linux_x86_64-linux-gnu', 'encodings.cp437', 'abc', 'zipimport', 'stat', '_locale'}
what difference between initialized , loaded module? i'm on python 3.
the language initialization has gotten lot more complicated since documentation written. (it's been unchanged since @ least python 1.4.) modules in sys.modules
loaded , initialized.
Comments
Post a Comment