try...finally is more powerful than I thought.
Mauro Cicognini
mcicogni at siosistemi.it
Fri Nov 7 13:04:11 EST 2003
Alan Kennedy wrote:
> When an exception occurs in the try clause, the exception is
> temporarily saved, the finally clause is executed, and then the saved
> exception is re-raised.
I've always wondered, how does one use this in real life?
Since I cannot write try... except... finally..., which would be the
most intuitive construct to me, I understand I should write
try:
try:
...
finally:
...
except:
...
to achieve the same effect.
Am I right? I.e. (again) how do you people use try .. finally in real
use cases?
Does anyone else think Python could have a nicer syntax for this one?
Mauro
More information about the Python-list
mailing list