Sequence-length - Missing the obvious ?
François Pinard
pinard at iro.umontreal.ca
Tue Jun 6 10:55:46 EDT 2000
aahz at netcom.com (Aahz Maruch) writes:
> In article <3938090C.9FB5D057 at stud.ntnu.no>,
> Peter Schneider-Kamp <peter at schneider-kamp.de> wrote:
> >As far as I understand the for loop goes on until an IndexError is
> >raised. Then the error is cleared and the for loop ends.
> Let's be technically precise here: an exception is raised and caught
> by the "for" handler; the for loop is then broken (precisely as if
> the break statement was executed). Like any other caught exception,
> the exception is thrown away (not "error is cleared"). --
Are we precise? If the `for' loop runs to completion, the `else:' clause
of the for-loop gets executed. If a `break' statement is executed, the
`else:' clause is not. So, the `for' loop is not broken "precisely". :-)
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list