[issue29897] itertools.chain behaves strangly when copied with copy.copy
Serhiy Storchaka
report at bugs.python.org
Fri Mar 24 17:30:17 EDT 2017
Serhiy Storchaka added the comment:
chain(x) is a shortcut for chain.from_iterable(iter(x)).
Neither copy.copy() nor __reduce__ don't have particular relation to this. Consider following example:
>>> from itertools import chain
>>> i = iter([[1, 2, 3], [4, 5, 6]])
>>> a = chain.from_iterable(i)
>>> b = chain.from_iterable(i)
>>> next(a)
1
>>> next(b)
4
>>> tuple(a)
(2, 3)
>>> tuple(b)
(5, 6)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29897>
_______________________________________
More information about the Python-bugs-list
mailing list