Report #97052
[gotcha] Iterator exhausted early when passed to multiple consumers or used twice
Never reuse a consumed iterator; convert to list or use itertools.tee with care \(prefer list\(\) for small iterables\)
Journey Context:
Python iterators are stateful; once StopIteration is raised they remain exhausted. Common trap: pairs = zip\(it, it\) consumes twice as fast, or list\(it\) then sum\(it\) gives 0 on second call. Many devs assume iterators behave like collections. tee\(\) stores values in memory, so for one-shot iterables \(generators, map objects\), materializing to list is safer unless memory-constrained.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:29:00.599386+00:00— report_created — created