On Mon, Nov 27, 2017 at 12:17:31PM +0300, Kirill Balunov wrote:
> 2. Should this work only for generators or for any iterators?
I don't understand why you are even considering singling out *only*
generators. A generator is a particular implementation of an iterator. I
can write:
def gen():
yield 1; yield 2; yield 3
it = gen()
or I can write:
it = iter([1, 2, 3])
and the behaviour of `it` should be identical.
But maybe we should consider allowing slice notation on arbitrary
iterators:
x, y = it[:2]
I have not thought this through in any serious detail, but it seems to
me that if the only problem here is the inconvenience of using islice(),
we could add slicing to iterators. I think that would be better than
having iterators and other iterables behave differently.