Last Updated: May 22, 2026
The iterator protocol says that any object with __iter__ and __next__ can be looped over by a for statement. This lesson is about building those objects yourself, from scratch, as classes. You'll see how to wire up the two methods, when to put them on the same class, when to split them into two classes, and which design bugs trip up beginners every single time.