ByteBrief
We're a portrait publication through and through. Turn your phone back and your briefing picks up right where you left it.
(We tried widescreen once. It wasn't us.)
Python's `for x in y` does not loop over the collection directly. It calls `iter()` to get an iterator, then calls `next()` until `StopIteration` is raised. The author built the Memphis Python interpreter in Rust and had to implement this protocol. Understanding this explains exhausted iterators, generator behavior, and why `for` works on lists, strings, ranges, and custom objects.
Tap to vote and see what everyone thinks.
Summary by ByteBrief