I think this is a bad design. If you need to take any action if (and only if) an exception has not been thrown, this is what the proposal is else. If you need to unconditionally take some action, what is needed finally. here is a demo:
def myraise(arg):
try:
if arg:
raise ValueError('arg is True')
except ValueError as e:
print(e)
else:
print('arg is False')
finally:
print("see this no matter what")
myraise(1)
myraise(0)
You need to specify an unconditional code on finallyand put other material in except/ elseas needed.
source
share