"for" with "else"?
tjreedy at udel.edu
Fri Sep 26 01:34:48 CEST 2003
"Michael Geary" <Mike at DeleteThis.Geary.com> wrote in message
news:vn67fhhom95896 at corp.supernews.com...
> Mark Jackson wrote:
> > (This happens to be the *reverse* of what my intuition expects -
> > would seem more natural if the syntax meant "do this for loop to
> > completion, else do this extra stuff," but this is the way it is
> > one must simply remember it.)
> I'm with you there--the use of "else" here has seemed a bit
confusing to me.
How I plan to remember now: if the abnormal exit is a return or
exception, then all code end of for block, including any else part, to
the end of the function or try block will be skipped, so else part can
only apply to normal exit.
Terry J. Reedy
More information about the Python-list