Serhiy Storchaka added the comment:
This issue is related to the behavior of other composite iterators.
>>> from copy import copy
>>> it = map(ord, 'abc')
>>> list(copy(it))
[97, 98, 99]
>>> list(copy(it))
[]
>>> it = filter(None, 'abc')
>>> list(copy(it))
['a', 'b', 'c']
>>> list(copy(it))
[]
The copy is too shallow. If you consume an item from one copy, it is
disappeared for the original.
Compare with the behavior of iterators of builtin sequences:
>>> it = iter('abc')
>>> list(copy(it))
['a', 'b', 'c']
>>> list(copy(it))
['a', 'b', 'c']
>>> it = iter(list('abc'))
>>> list(copy(it))
['a', 'b', 'c']
>>> list(copy(it))
['a', 'b', 'c']
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue29897>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com