When you start your Python interpreter it appears that some modules/packages are automatically imported during the startup process:
python
Python 2.7.6 (default, Jan 13 2014, 14:59:37)
...
>>> import sys
>>> for key in sys.modules.iterkeys():
... print(key)
...
os
sys
abc
others ...
However, these modules seem to have been loaded into a different scope/namespace because you can't access them without an additional import
:
>>> abc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'abc' is not defined
Here are my questions:
the sys
module is loading them into the sys.modules
dictionary namespace
if you wanted to I guess you could access them as
abc = sys.modules["abc"]
but not sure why you would want to
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With