Generator (computer programming): Difference between revisions

Content deleted Content added
m Reverted edits by S.Noman_shabbir (talk): addition of unnecessary/inappropriate external links (HG) (3.4.12)
Tags: Reverted Visual edit
Line 501:
</syntaxhighlight>
 
In [https://websolutioncode.com/introduction-of-python Python], a generator can be thought of as an [[iterator]] that contains a frozen [[stack frame]]. Whenever <code>next()</code> is called on the iterator, Python resumes the frozen frame, which executes normally until the next <code>yield</code> statement is reached. The generator's frame is then frozen again, and the yielded value is returned to the caller.
 
PEP 380 (implemented in Python 3.3) adds the <code>yield from</code> expression, allowing a generator to delegate part of its operations to another generator or iterable.<ref name="pep380">[https://www.python.org/dev/peps/pep-0380/ PEP 380 -- Syntax for Delegating to a Subgenerator]</ref>