On Wed, Aug 13, 2014 at 8:51 PM, YBM <ybm...@nooos.fr.invalid> wrote:
> BTW, why iterators does not have such an index method ?

Because iterators don't support indexing. In order to support such a thing,
it would have to exhaust the iterator.

>>> iter(range(5))[3]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'range_iterator' object is not subscriptable

The only methods you can rely upon an arbitrary iterator to have are
__iter__ and __next__.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to