我想知道为什么Python 3.3会因return
语句中的try/finally
而导致异常,请查看此代码:
import sys
def action1():
try:
action2()
finally:
return # try/finally doesn't kill exceptions
# But with return, exceptions not propagated
def action2():
raise Exception()
try:
action1()
except Exception as e:
print("except clause")
这种行为是否可取,我们可以在哪里应用它?