Skip to main content

IPython magic command to reload modules on demand

Project description


IPython magic command to reload modules on demand


pip install ipython-reload


In [1]: %load_ext ipython_reload

In [2]: from foo import some_function

In [3]: some_function()
Out[3]: 42

In [4]: # open in an editor and change some_function to return 43

In [5]: %reload some_function

In [6]: some_function()
Out[6]: 43

The %reload magic can reload modules not directly imported, imported modules in the local namespace, and imported variables.

Reloading imported variables may produce unexpected results if the name is generic, such as in the case of __version__. Python does not track the source of where a variable was defined, so this code loops all imported modules, and looks for a matching name, that is the same type as the variable you want to reload. If you have imported a variable using from foo import bar as baz this functionality will not work.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ipython-reload, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size ipython_reload-0.0.1-py2.py3-none-any.whl (5.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size ipython-reload-0.0.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page