Distinguishing active generators from exhausted ones

Terry Reedy tjreedy at udel.edu
Sun Jul 26 20:10:00 EDT 2009


Michal Kwiatkowski wrote:

> The thing is I don't need the next item. I need to know if the
> generator has stopped without invoking it.

Write a one-ahead iterator class, which I have posted before, that sets 
.exhausted to True when next fails.

tjr




More information about the Python-list mailing list