[IPython-user] reset, then import, behavior

Christopher Burns cburns@berkeley....
Tue Oct 16 16:57:24 CDT 2007


I discovered some unexpected behavior with the %reset command.  After a
reset, issuing an import appears to reinstate the previous module bindings,
not perform a 'fresh' import of the module.  As a result, any edits to the
module since the previous import (or reload) and my current reset/import are
not exposed and my .py and .pyc files are out of sync.

Ex:
In[ ]: import mymod    # builds mymod.pyc if necessary and imports
....use module....
....Edit mymod in emacs.
In[ ]: reload(mymod)    # builds mymod.pyc and reloads
....Everything works.  Expected Python behavior.

In[ ]: reset    # Resets the namespace except IO history.  This is confirmed
with a dir()
....Edit mymod in emacs.
In[ ]: import mymod    # Adds mymod to the namespace, but DOES NOT build
mymod.pyc.
.... # mymod.py and mymod.pyc are now out of sync.  Loaded cached bindings
of the module?

In[ ]: reload(mymod)    # builds mymod.pyc and reloads.  Normal behavior.


The reset/import/reload trifecta works (or a full exit and restart of
ipython), but is there a way to get reset to fully 'flush' my previous
bindings?


-- 
Christopher Burns, Software Engineer
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20071016/77bd5882/attachment.html 


More information about the IPython-user mailing list