[Python-ideas] iterator length

Ivan Pozdeev vano at mail.mipt.ru
Mon Aug 9 23:42:12 CEST 2010


> Hello,

> Sometimes it's useful to get the number of elements yield by an
> iterator. For example (if ilen is the name of the function):

A generic iterator is something that inherently, by definition, has
unknown and unpredictable length
(think, for example, about berries you gather in a forest).

There is no guarantee two tries give the same results,
there isn't even a guarantee that it's finite.

You just can't, absolutely, by any means, know its length otherwise
than by exhausting it. If you can, it's not a generic iterator but
something else.

-- 
Regards,
 Ivan                          mailto:vano at mail.mipt.ru




More information about the Python-ideas mailing list