If you are using iPython, you will be importing some of the modules you have written. While playing with them, you may want to change them or if there is a bug, you will have to fix them. Since you have changed your code, you have to exit and start new instance of the interpreter or you can reload the module.
To reload the already imported modules:
In Python 2.x, you can do directly run
In Python 3.0–3.3 you have to use
In Python 3.4 you have to use
If you are developing something this will be annoying because for every small change you need to reload the module.
iPython has a cool extension called autoreload which automatically reloads modules. You can load it with
So, if you set autoreload to 2 it reloads modules everytime before executing code.
Also note that reload doesn't reloads c extensions automatically.
To reload the already imported modules:
In Python 2.x, you can do directly run
You can do this everytime you start iPython or you can add config iPython to that automatically.
Create a default profile using this command
Go to your default profile at ~/.ipython/profile_default/ipython_config.py and find these two lines
and change them to
Also note that reload doesn't reloads c extensions automatically.