1

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?

Mastiff
  • 1,799
  • 1
  • 17
  • 30
  • FWIW, [this post](https://stackoverflow.com/a/1254379/4518341) gives a bit of detail and a workaround (use fully qualified names), but no solution. – wjandrea May 21 '20 at 18:25

1 Answers1

2

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
Viacheslav Z
  • 840
  • 7
  • 12