I know in a function you can exit the function using return,
def function():
return
but can you exit a parent function from a child function?
Example:
def function()
print("This is the parent function")
def exit_both():
print("This is the child function")
# Somehow exit this function (exit_both) and exit the parent function (function)
exit_both()
print("This shouldn't print")
function()
print("This should still be able to print")
I tried raising an Exception, as this answer suggests, but that just exits the whole program.