Sequence-length - Missing the obvious ?
Aahz Maruch
aahz at netcom.com
Fri Jun 2 16:42:42 EDT 2000
In article <3938090C.9FB5D057 at stud.ntnu.no>,
Peter Schneider-Kamp <peter at schneider-kamp.de> wrote:
>mlauer at trollinger-fe.rz.uni-frankfurt.de wrote:
>>
>> But why ? How does the for loop knows
>> how much elements the sequence contains ?
>> I did not program the __len__ function,
>> so... how ?
>
>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").
--
--- Aahz (Copyright 2000 by aahz at netcom.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
Have you coined a word today? --Aahz
More information about the Python-list
mailing list