2

I Have a 3 python scripts which i thought to call from one master script. To do this I did something like:

import sys
sys.path.insert(0,'C:\\path_to_scripts\\') #insert the path so I can import
import script1 
script1.my_func('arg') #my_func is a custom function

So, I was planning to call all the scripts in such manner,this works perfectly.

I then tampered the script intentionally and tried the below code to catch the exceptions:

import script1
try:
    script1.my_func('arg')
except Exception as e:
    print(e)

To my surprise, the script still executes like before instead of capturing the exception.

I read some articles where it says Jupyter notebook keeps cache. Can it be due to this ? (cant seem to find the correct solution online)

If yes , how do i overcome this problem. Can somebody show me the correct direction?

Thanks in advance.

anky
  • 74,114
  • 11
  • 41
  • 70
  • 1
    You need to restart the Jupyter kernel, of otherwise use `importlib.reload` to force the interpreter to reimport something that has already been imported – Karl Mar 13 '19 at 10:35
  • 1
    `importlib.reload(script1)` – Karl Mar 13 '19 at 11:10

0 Answers0