Note
This documentation is for a development version of IPython. There may be significant differences from the latest stable release (1.2.1).
Provides a reload() function that acts recursively.
Python’s normal reload() function only reloads the module that it’s passed. The reload() function in this module also reloads everything imported from that module, which is useful when you’re changing files deep inside a package.
To use this as your default reload function, type this for Python 2:
import __builtin__
from IPython.lib import deepreload
__builtin__.reload = deepreload.reload
Or this for Python 3:
import builtins
from IPython.lib import deepreload
builtins.reload = deepreload.reload
A reference to the original reload() is stored in this module as original_reload, so you can restore it later.
This code is almost entirely based on knee.py, which is a Python re-implementation of hierarchical module import.
Return the package that an import is being performed in. If globals comes from the module foo.bar.bat (not itself a package), this returns the sys.modules entry for foo.bar. If globals is from a package’s __init__.py, the package’s entry in sys.modules is returned.
If globals doesn’t come from a package or a module in a package, or a corresponding entry is not found in sys.modules, None is returned.
altmod is either None or same as mod
mod.{subname} = submod
Handle ‘from module import a, b, c’ imports.
Replacement for __import__()
Replacement for reload().
Recursively reload all modules used in the given module. Optionally takes a list of modules to exclude from reloading. The default exclude list contains sys, __main__, and __builtin__, to prevent, e.g., resetting display, exception, and io hooks.