[SciPy-user] reload
Ken Sugino
sugino at brandeis.edu
Thu Jan 30 09:51:11 EST 2003
If you do :
>>> from leo_ncd3D import *
after step 4, you can use 'leo_ncd3Dlin()' as newly defined function.
For instance objects, you have to assign __class__ to reloaded class:
>>> import foo # module foo
>>> a = foo.bar() # bar class in foo
>>> reload(foo)
>>> a.__class__ == foo.bar
0
# different class object
>>> a.__class__ = foo.bar
# have to reassign to use new class definition (like methods, class attributes)
There is a recipe for autoreloading in ASPN:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164
Cheers,
ken
On Thu, 30 Jan 2003 13:01:31 +0100 (MET)
Agustin Lobo <alobo at ija.csic.es> 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)
>
> Thanks!
>
> Agus
>
> Dr. Agustin Lobo
> Instituto de Ciencias de la Tierra (CSIC)
> Lluis Sole Sabaris s/n
> 08028 Barcelona SPAIN
> tel 34 93409 5410
> fax 34 93411 0012
> alobo at ija.csic.es
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
More information about the SciPy-User
mailing list