Sequence-length - Missing the obvious ?
Peter Schneider-Kamp
petersc at stud.ntnu.no
Sat Jun 3 03:38:19 EDT 2000
Aahz Maruch wrote:
>
> i = 0
> while 1:
> try:
> object.__getitem__(i)
> except IndexError:
> break
> i = i + 1
>
> Now, in Python terms (not C), what would you say happens to the
> exception at the break?
The exception gets caught and ignored, so I would rather say
it is "thrown away" than that the "error is cleared".
The point is that the standard for-loop actually used by
the original poster is implemented in C (not in Python). So
to understand why this implementation of the for-loop does
what it does I have to look at the C level. Of course giving
an explanation as an equivalent Python code snippet (like the
one above) is a nice way to put it. But I still don't see
where you object to the term "error is cleared" when that is
what actually happens in the Python interpreter.
maybe-my-problem-is-that-I-use-the-source-as-my-documentation-ly y'rs
Peter
--
Peter Schneider-Kamp ++47-7388-7331
Herman Krags veg 51-11 mailto:peter at schneider-kamp.de
N-7050 Trondheim http://schneider-kamp.de
More information about the Python-list
mailing list