In the reference manual it is stated that:
A complete Python program is executed in a minimally initialized environment: all built-in and standard modules are available, but none have been initialized, except for
sys(various system services),builtins(built-in functions, exceptions and None) and__main__.
I am uncertain about what "initialized" is supposed to mean here. I always thought that a module was initialized if it was loaded and present in sys.modules:
This is a dictionary that maps module names to modules which have already been loaded.
Apparently, I was 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 is the difference between an initialized and a loaded module? I'm on Python 3.