[Python-Dev] Fwd: try...else
Michael Hudson
mwh21@cam.ac.uk
Thu, 28 Dec 2000 18:27:48 +0000 (GMT)
On Thu, 28 Dec 2000, M.-A. Lemburg wrote:
> I think Robin mixed up try...finally with try...except...else.
I think so too.
> The finally clause is executed even in case an exception occurred.
>
> He does have a point however that 'return' will bypass
> try...else and try...finally clauses. I don't think we can change
> that behaviour, though, as it would break code.
return does not skip finally clauses[1]. In my not especially humble
opinion, the current behaviour is the Right Thing. I'd have to think for
a moment before saying what Robin's example would print, but I think the
alternative would disturb me far more.
Cheers,
M.
[1] In fact the flow of control on return is very similar to that of an
exception - ooh, look at that implementation...