I’m doing a lot of development in IPython where
In[3]: from mystuff import MyObject
and then I make lots of changes in mystuff.py. In order to update the namespace, I have to do
In[4]: reload(mystuff)
In[5]: from mystuff import MyObject
Is there a better way to do this? Note that I cannot import MyObject by referencing mystuff directly as with
In[6]: import mystuff
In[7]: mystuff.MyObject
since that’s not how it works in the code. Even better would be to have IPython automatically do this when I write the file (but that’s probably a question for another time).
Any help appreciated.
You can use the
deep_reloadfeature from IPython to do this.http://ipython.scipy.org/doc/manual/html/interactive/reference.html?highlight=dreload
If you run ipython with the
-deep_reloadparameter to replace the normalreload()method.And if that does not do what you want, it would be possible to write a script to replace all the imported modules in the scope automatically. Fairly hacky though, but it should work 😉
I’ve just found the
ipy_autoreloadmodule. Perhaps that can help you a bit. I’m not yet sure how it works but this should work according to the docs: