def check():
if (cond):
how to return back to explore()
else:
return 1 # here return to f2
def cannot_be_modified():
try:
check() # inserted
print("hello from cannot_be_modified")
return 2
except Exception as e:
print(e)
def explore():
cannot_be_modified()
print("hello from explore")
return 0
explore()
Call stack is: explore() -> cannot_be_modified() --> check()
If I meet some conditions in check
, I want to quit check
and cannot_be_modified
and come back to explore
.
So how can I achieve this?
I thought about raising a specific type of exception in check
function and catch it in explore
but that exception can be caught in function cannot_be_modified
Does anyone have ideas?
Thanks