Distinguishing active generators from exhausted ones

Jason Tackaberry tack at urandom.ca
Sat Jul 25 16:00:02 EDT 2009


On Sat, 2009-07-25 at 11:30 -0700, Michal Kwiatkowski wrote:
> Is there a way to tell if a generator has been exhausted using pure
> Python code? I've looked at CPython sources and it seems that

Upon a cursory look, after a generator 'gen' is exhausted (meaning
gen.next() has raised StopIteration), it seems that gen.gi_frame will be
None.

Cheers,
Jason.	




More information about the Python-list mailing list