iteration (was RE: "sins" (aka, acknowledged language problems))

Aahz Maruch aahz at netcom.com
Fri Dec 17 10:02:53 EST 1999


In article <6D8A17398E28D3119F860090274DD7DB4B3D53 at pces.cadlab.it>,
Alex Martelli  <Alex.Martelli at think3.com> wrote:
>
>but what should I place instead of the 'pass' statements, to make the
>'for' construct terminate correctly...?  In other words, what does
>__getitem__ return, or what exception does it raise, to make a "for
>x in y" statement terminate correctly?  I see from the sources for
>fileinput.py that an IndexError gets raised -- is that the "right" way
>to do it (is it documented somewhere as such), or does it just "happen
>to work" on the current implementation of the interpreter...?

Yes, the "for" construct contains an implicit try/except on IndexError
that it uses for loop control.  It is documented somewhere, but I don't
off-hand know where -- this is not likely to change, though it may get
extended.
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Eighth Virtual Anniversary -- 14 days and counting!



More information about the Python-list mailing list