- sys.modules
- imp.reload
- reload
Modules: more
- sys.modules to list loaded modules
- imp.reload to reload module (Just reload before 3.3)
examples/modules/mod.py
import __builtin__ def xx(name): print("hello") __builtin__.__import__ = xx; print('body') def f(): print("in f")
examples/modules/a.py
import sys print('mod' in sys.modules) # False import mod print('mod' in sys.modules) # True print(sys.modules['mod']) # <module 'mod' from '/stuff/python/examples/modules/mod.py'> print(sys.modules["sys"]) # <module 'sys' (built-in)>