I want to insert two different paths with the same name of python file. Is it possible to reload goal_func without reestarting the kernel?
step 1:
path = 'a*/goal.py'
ruta_carpeta = path[:-8]
sys.path.insert(1, ruta_carpeta)
from goal import goal_func
step 2:
path = 'b*/goal.py'
ruta_carpeta = path[:-8]
sys.path.insert(1, ruta_carpeta)
from goal import goal_func
goal_func has not been updated.
Use importlib.reload on the module, then reimport the function:
import importlib
import goal
importlib.reload(goal) # reload the module
# now import the function
from goal import goal_func
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With