I just spent two hours chasing a bug down and realized it was due to this odd behavior. Why does iterating through a Python zip
object also empties it? Sometimes I want to print(list(zip))
for debug purposes while not changing the zip object. Is there a way to do that?
In [11]: a = zip([1,2,3],['one','two','three'])
In [12]: print(list(a))
[(1, 'one'), (2, 'two'), (3, 'three')]
In [13]: print(list(a))
[]