[issue35756] Using `return value` in a generator function skips the returned value on for-loop iteration

Steven D'Aprano report at bugs.python.org
Wed Jan 16 19:53:13 EST 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

You say:

> The PEP reads as if returning a value via StopIteration was meant to signal that the generator was finished and that StopIteration.value was the final value.

To me, the PEP is clear that `return expr` is equivalent to `raise StopIteration(expr)` which is *not* used as an iteration value. Can you point to the passage in the PEP that suggests something different to you?

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35756>
_______________________________________


More information about the Python-bugs-list mailing list