[docs] [issue24088] yield expression confusion

Jim Jewett report at bugs.python.org
Mon May 4 16:10:50 CEST 2015


Jim Jewett added the comment:

OK, then how about

Current:
"""
When a generator function is called, it returns an iterator known as a generator. That generator then controls the execution of a generator function. The execution starts when one of the generator’s methods is called.
"""

Proposed:
"""
When a generator function is called, it does not complete its execution immediately.  Instead, it keeps its execution frame intact, and returns a special kind of iterator known as a generator. The iteration starts when one of the generator’s methods is called, and the generator executes within the existing generator frame, rather than creating a new one.
"""

This still seems to suggest that the generator uses the same frame as the generator function that created it; I was not aware that this was a guarantee.  (Reusing the same frame, yes.  Reusing that particular frame, no.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24088>
_______________________________________


More information about the docs mailing list