[Python-Dev] Fwd: try...else

Guido van Rossum guido@digicool.com
Mon, 01 Jan 2001 13:58:36 -0500


Thomas just checked this in, using Tim's words:

> *** ref7.tex	2000/07/16 19:05:38	1.20
> --- ref7.tex	2000/12/31 22:52:59	1.21
> ***************
> *** 243,249 ****
>     \ttindex{exc_value}\ttindex{exc_traceback}}
>   
> ! The optional \keyword{else} clause is executed when no exception occurs
> ! in the \keyword{try} clause.  Exceptions in the \keyword{else} clause are
> ! not handled by the preceding \keyword{except} clauses.
>   \kwindex{else}
>   
> --- 243,251 ----
>     \ttindex{exc_value}\ttindex{exc_traceback}}
>   
> ! The optional \keyword{else} clause is executed when the \keyword{try} clause
> ! terminates by any means other than an exception or executing a
> ! \keyword{return}, \keyword{continue} or \keyword{break} statement.  
> ! Exceptions in the \keyword{else} clause are not handled by the preceding
> ! \keyword{except} clauses.
>   \kwindex{else}

How is this different from "when control flow reaches the end of the
try clause", which is what I really had in mind?  Using the current
wording, this paragraph would have to be changed each time a new
control-flow keyword is added.  Based upon the historical record
that's not a grave concern ;-), but I think the new wording relies too
much on accidentals such as the fact that these are the only control
flow altering events.  It may be that control flow is not rigidly
defined -- but as it is what was really intended, maybe the fix should
be to explain the right concept rather than the current ad-hoc
solution.  This also avoids concerns of readers who are trying to read
too much into the words and might become worried that there are other
ways of altering the control flow that *would* cause the else clause
to be executed; and guides implementors of other Pyhon-like languages
(like vyper) that might have more control-flow altering statements or
events.

--Guido van Rossum (home page: http://www.python.org/~guido/)