On 01/04/16 15:34, Marko Rauhamaa wrote:
Chris Angelico <ros...@gmail.com>:
*A range object is not an iterator.*
We now have learned as much.
However, doesn't that extra level of indirection seem like an odd
choice?
If you write your own class which has an __iter__ method, would you expect:
>>> o = MyClass()
>>> i1 = iter(o)
>>> i2 = iter(o)
>>> list(i1)
['foo', 'bar', 'baz']
>>> list(i2)
[]
?
Or, would you expect both iterators to be independent and both return
the 'foo', 'bar', 'baz' sequence (where that is the hypothetical result
of iterating over your object)?
If you now replace MyClass() with range(10), why would you expect the
two iterators to be related?
E.
--
https://mail.python.org/mailman/listinfo/python-list