I have two files:
Content in fl_fn1.py:
import fl_fn2
def fn1():
print("hi")
try:
fl_fn2.fn2()
except:
print("inside except")
finally:
print("finally")
fn1()
Content in fl_fn2.py:
import sys
def fn2():
print("fn2")
sys.exit(0)
Now when I invoke fl_fn1.py from Windows command prompt like;
C:\Program Files\Anaconda3\python.exe C:\Users\User1\Desktop\fl_fn1.py
then my output is:
hi
fn2
inside except
finally
However when I change the exception part in fl_fn1.py to:
except Exception as ex:
print("inside except")
Then my output is:
hi
fn2
finally
The exception part is not executed!!!
Could someone please explain what is going on. I am new to Python.
Thanks in Advance :)