[IPython-user] Autoreload (Re: Food for thought on python and interactive work

Ville M. Vainio vivainio@gmail....
Tue Jun 3 03:37:08 CDT 2008


On Tue, Jun 3, 2008 at 11:18 AM, Johann Cohen-Tanugi
<cohen@slac.stanford.edu> wrote:
> well, can you actually add a description or a pointer, now that you opened
> the Pandora's box in front of all "those that are not aware"

Here is is (along with the usual way to find out about extensions) ;-):

[c:/ipython]|10> import ipy_autoreload
[c:/ipython]|11> ipy_autoreload?

Docstring:
    IPython extension: autoreload modules before executing the next line

Try::

    %autoreload?

for documentation.

[c:/ipython]|12> %autoreload?
Type:           Magic function
Base Class:     <type 'instancemethod'>
String Form:    <bound method InteractiveShell.autoreload_f of <IPython.iplib.In
teractiveShell object at 0x00A40870>>
Namespace:      IPython internal
File:           c:\ipython\ipython\extensions\ipy_autoreload.py
Definition:     %autoreload(self, parameter_s='')
Docstring:
    %autoreload => Reload modules automatically

%autoreload
Reload all modules (except thoses excluded by %aimport) automatically now.

%autoreload 1
Reload all modules imported with %aimport every time before executing
the Python code typed.

%autoreload 2
Reload all modules (except thoses excluded by %aimport) every time
before executing the Python code typed.

Reloading Python modules in a reliable way is in general
difficult, and unexpected things may occur. Some of the common
caveats relevant for 'autoreload' are:

- Modules are not reloaded in any specific order, and no dependency
  analysis is done. For example, modules with 'from xxx import foo'
  retain old versions of 'foo' when 'xxx' is autoreloaded.
- Functions or objects imported from the autoreloaded module to
  the interactive namespace are not updated.
- C extension modules cannot be reloaded, and so cannot be
  autoreloaded.


-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-user mailing list