Issue
I do a lot of interactive work in iPython. Currently, I'm working with Jupyter QtConsole. Suppose I start with this:
from myFuncs import func1
Then I go out to myFuncs.py and add a new function, func2. If I try this:
from myFuncs import func2
It doesn't see it. Presumably myFuncs is somehow cached. I have read about reload
, but it seems to only work with entire modules, not cherry picked functions. autoreload
also seems ineffective here. Is there a way around, short of restarting the kernel?
Incidentally, ipython within Spyder is fine with files changing while interacting. It is also unusably slow, so maybe related?
Solution
As @jss367 mentioned here, you can achieve this with importlib
and sys
modules:
import importlib
import sys
importlib.reload(sys.modules['myFuncs'])
from myFuncs import func2
Answered By - Viacheslav Z
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.