Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sivel/ipython-reload
IPython magic command to reload modules on demand
https://github.com/sivel/ipython-reload
Last synced: 3 months ago
JSON representation
IPython magic command to reload modules on demand
- Host: GitHub
- URL: https://github.com/sivel/ipython-reload
- Owner: sivel
- License: bsd-3-clause
- Created: 2020-04-29T18:36:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-29T19:08:56.000Z (over 4 years ago)
- Last Synced: 2024-09-28T18:40:56.275Z (3 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ipython-reload
IPython magic command to reload modules on demand## Install
```shell
pip install ipython-reload
```## Use
```
In [1]: %load_ext ipython_reloadIn [2]: from foo import some_function
In [3]: some_function()
Out[3]: 42In [4]: # open foo.py 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.