try/except/finally
Frank B
fbicknel at gmail.com
Fri Jun 6 13:30:10 EDT 2014
Ok; this is a bit esoteric.
So finally is executed regardless of whether an exception occurs, so states the docs.
But, I thought, if I <return> from my function first, that should take precedence.
au contraire
Turns out that if you do this:
try:
failingthing()
except FailException:
return 0
finally:
return 1
Then finally really is executed regardless... even though you told it to return.
That seems odd to me.
More information about the Python-list
mailing list