Message333817
I understood the PEP to include `return expr` in the iteration values as per the first bullet of the proposal.
> Any values that the iterator yields are passed directly to the caller.
This bullet doesn't have any additional formatting on the word "yields" so I consider it as not directly referring to the "yield" keyword.
With the current implementation, I have to concern myself if a generator function was created with the intention of being called using `last_ret = yield from function(); yield last_ret` or as `for ret in function(): yield ret`. The first also yields the return value but would also yield an additional `None` if a `return` was not the terminal cause; the second will miss the last value if the generator uses `return`.
Essentially, allowing `return expr` in generator functions without invoking the generator using `yield from generator` will lose the last value.
I support either of the below resolutions:
* `return expr` being invoked from a generator that is not being iterated using `yield from generator` is a SyntaxError
* `return expr` being invoked from a generator that is not being iterated using `yield from generator` includes the final return value in the iterated set |
|
Date |
User |
Action |
Args |
2019-01-17 02:59:41 | Bryan Koch | set | recipients:
+ Bryan Koch, steven.daprano |
2019-01-17 02:59:39 | Bryan Koch | set | messageid: <1547693979.62.0.927229132748.issue35756@roundup.psfhosted.org> |
2019-01-17 02:59:39 | Bryan Koch | link | issue35756 messages |
2019-01-17 02:59:39 | Bryan Koch | create | |
|