[Python-ideas] yield-from and @coroutine decorator [was:x=(yield from) confusion]
Jacob Holm
jh at improva.dk
Sat Apr 4 14:50:16 CEST 2009
Nick Coghlan wrote:
> This issue is still bouncing around in my brain, so I don't have a lot
> say about it yet, but a special attribute on the generator-iterator
> object that the yield from expression could check was the first possible
> approach that occurred to me.
>
Ok, keep it bouncing.
> Although, rather than it being the "latest yield" from the generator, I
> was thinking more of just an ordinary attribute that a @coroutine
> decorator could set to indicate what to yield when firing it up with
> 'yield from'.
>
I made it the latest yield because I have had a use case for that in the
past, and it seemed like a natural thing to do.
> On your syntax ideas, note that the parser can't do anything tricky with
> expressions of the form "yield EXPR" - the parser will treat that as a
> normal yield and get confused if you try to add anything after it.
>
I don't really like the idea of new syntax anyway, now that it seems
there is a way to avoid it. But thanks for the reminder.
- Jacob
More information about the Python-ideas
mailing list