Distinguishing active generators from exhausted ones

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Jul 27 05:18:53 CEST 2009


On Sun, 26 Jul 2009 20:10:00 -0400, Terry Reedy wrote:

> 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.


And hope that the generator doesn't have side-effects...


-- 
Steven



More information about the Python-list mailing list