F
Frank B
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.
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.