autoreload is an IPython extension that reloads modules automatically before executing the line of code typed.
This makes for example the following workflow possible:
In : %load_ext autoreload In : %autoreload 2 In : from foo import some_function In : some_function() Out: 42 In : # open foo.py in an editor and change some_function to return 43 In : some_function() Out: 43
The module was reloaded without reloading it explicitly, and the object imported with from foo import ... was also updated.
The following magic commands are provided:
Reload all modules (except those excluded by %aimport) automatically now.
Disable automatic reloading.
Reload all modules imported with %aimport every time before executing the Python code typed.
Reload all modules (except those excluded by %aimport) every time before executing the Python code typed.
List modules which are to be automatically imported or not to be imported.
Import module ‘foo’ and mark it to be autoreloaded for %autoreload 1
Mark module ‘foo’ to not be autoreloaded.
Reloading Python modules in a reliable way is in general difficult, and unexpected things may occur. %autoreload tries to work around common pitfalls by replacing function code objects and parts of classes previously in the module with new versions. This makes the following things to work:
Some of the known remaining caveats are: