Imagine you have created a py file named funcs with a function called my_func().
While using Jupyter Notebook, you want to import said function with the following:
from funcs import my_func
Now you do something with it, i.e.
x = my_func(bla)
After that, there is something that you want to modify from my_func. So I change it and save it. If I re-run the code posted above, the change will not be seen, and therefore I am obliged to restart the kernel to run the function with said changes. Is there an efficient way to do it?
Note: I know the reload module allows you to reload the entire funcs py file, but I want to do this in a more specific function level. Not the entire script. With reload I would have to import funcs and not just my_func and therefore would have to write
x = funcs.my_func(bla)
Which isn't my objective.
Answer:
import sys, importlib
importlib.reload(sys.modules['funcs])
from funcs import my_func