[SciPy-user] interactive work with extension modules

Alexandre Fayolle alexandre.fayolle@logilab...
Mon Aug 4 10:27:43 CDT 2008

On Mon, Aug 04, 2008 at 05:04:56PM +0200, Steve Schmerler wrote:
> Hi all
> I've read in the scipy and IPython archives that Python cannot reload extension
> modules (C and Fortran). So if I change and re-compile my extension and do
>     >>> reload(foo) 
>     >>> foo.some_function(args)
> in the [i]python shell, there is no change to "foo". Even
>     >>> del foo
>     >>> import foo
>     >>> foo.some_function(args)

I suspect that some_function is imported indirectly in foo.py (and not
defined in that module), because I'm able to do the following:

alf@lacapelle:~$ cat toto.py
def foo(a):
    return a

alf@lacapelle:~$ ipython
In [1]: import toto

In [2]: toto.foo(1)

#edit toto.py in another window so that:
#alf@lacapelle:~$ cat toto.py
#def foo(a, b):
#    return a + b

In [3]: reload(toto)
Out[3]: <module 'toto' from 'toto.py'>

In [4]: toto.foo(1,2)
Out[4]: 3

Alexandre Fayolle                              LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
Informatique scientifique:               http://www.logilab.fr/science
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: Digital signature
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20080804/5258d2a3/attachment.bin 

More information about the SciPy-user mailing list