An error passes through two functions, each with a finally part, and a new error is raised on the way.
log = []
def inner():
try:
raise KeyError("k")
finally:
log.append("inner")
def outer():
try:
inner()
except LookupError as e:
log.append(type(e).__name__)
raise ValueError("v")
finally:
log.append("outer")
try:
outer()
except Exception as e:
log.append(repr(e))
print(log)
What does the program print?
Log in to join the discussion.
Loading…