[SciPy-user] reload

Fernando Perez fperez at pizero.colorado.edu
Thu Jan 30 15:33:15 EST 2003


On Thu, 30 Jan 2003, Agustin Lobo wrote:

> 
> What's the best way to modify  function with the editor
> and then get this function actualized in the python
> shell?
> This is what I'm doing:
> 
> 1. import leo_ncd3D
> 2. from leo_ncd3D import *
> 3. I make a change in function leo_ncd3Dlin()
> which is within file leo_ncd3D.py.
> 4. reload(leo_ncd3D) 
> 5. leo_ncd3D.leo_ncd3Dlin()
> 
> If in (4) I do leo_ncd3Dlin() instead of
> leo_ncd3D.leo_ncd3Dlin(), I still use the older version.
> 
> Is this the normal way?
> (I'm using idle, which I don't know if it's the 
> best shell)

You may want to try out ipython 
(http://www-hep.colorado.edu/~fperez/ipython/). Instead of doing 'import', you 
can cd to the definition directory and type 'run leo_ncd3d'.  This executes 
the file in the current namespace, so any changes made to the source take 
effect immediately.  That's typically my approach, and for most single-level 
modules it works well.  If you have a complex package with nested structure, 
ipython offers a 'dreload' version of reload which helps doing recursive 
reloads.

Best regards,

Fernando.




More information about the SciPy-User mailing list