Iterators and Generators Quick Review
Some Nice Summary Diagrams
These two diagrams are most of what you need to know about iterators and generators (great cheat sheet material!). The bolded expressions represent the steps you need to take to get to the next stage in the diagram.
Generator function (has a yield statement) ⇨ call function ⇨ Generator object ⇨ next(generator object) ⇨ Generator function runs until first yield ⇨ next(generator object) ⇨ Generator function runs until next yield or end of function
ONe Last Note
When you create an iterator object, it is bound to a specific iterable object, not a variable name. Even if you reassign your variable to a new iterable, the iterator is still bound to the old iterable object.