Message333918
Thank you both for the clarifications. I agree these's no bug in `yield from` however is there a way to reference the return value when a generator with a return is invoked using `for val in gen` i.e. when the generator is invoked without delegation?
I could write my own wrapper around using `next` to work around this but it might be an oversight of the new grammar (new being relative) that the return value is only available when invoked from the `yield from` syntax.
Essentially I have code that looks like
`
for value in generator:
do thing with value
yield value
`
where I need to do something before yielding the value. It would be awesome if invoking a generator above would throw a SyntaxError iff it contained a return and it wasn't invoked through `yield from`.
The below isn't valid Python and I'm not sure that it should be but it's what I need to do.
`
return_value = for value in generator:
do thing with value
yield value
if return_value:
do something with return_value
` |
|
Date |
User |
Action |
Args |
2019-01-18 00:31:47 | Bryan Koch | set | recipients:
+ Bryan Koch, steven.daprano, greg.ewing |
2019-01-18 00:31:45 | Bryan Koch | set | messageid: <1547771505.97.0.32419395184.issue35756@roundup.psfhosted.org> |
2019-01-18 00:31:45 | Bryan Koch | link | issue35756 messages |
2019-01-18 00:31:45 | Bryan Koch | create | |
|