Reloading a module

less than 1 minute read

Published:

Ever been actively editing a module while also using it? IPython (and JUPYTER) have some automagic to help with this.

autoreload reloads modules before excuting a line a code. If you’re working with some code and modify it you can use the below to ensure that the changes are applied before reexcuting the code.

%load_ext autoreload
%autoreload 2

Note, if you are loading a module by adding it to you sysem path be sure to import the module using import rather then import module as mod, for example. When using import as it doesn’t appear as though the autoreload magic works.

Read more about it at this stackoverflow post.