Distinguishing active generators from exhausted ones
Aahz
aahz at pythoncraft.com
Mon Jul 27 10:41:45 EDT 2009
In article <1c8ae01e-2e9c-497c-9f8d-408f56f9c0bd at g31g2000yqc.googlegroups.com>,
Michal Kwiatkowski <constant.beta at gmail.com> wrote:
>On Jul 27, 1:56 am, a... at pythoncraft.com (Aahz) wrote:
>>>> 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.
>>>
>>>Only in Python 2.5 or higher though. I need to support Python 2.3 and
>>>2.4 as well, sorry for not making that clear in the original post.
>>
>> Are you sure? It appears to work in Python 2.4; I don't have time to
>> check 2.3.
>
>No, it does not work in Python 2.4. gi_frame can be None only in
>Python 2.5 and higher.
You're right, I guess I must have made a boo-boo when I was switching
versions.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
More information about the Python-list
mailing list