Distinguishing active generators from exhausted ones
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun Jul 26 23:18:53 EDT 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