Message244281
>> Yield-from iterates, and a coroutine is not supposed to be iterable, only awaitable (at least, that's what all error messages tell me when I try it). So why should "yield from" work on them? What if foo() was not an Iterable but a Coroutine? Should "yield from" then call "__await__" on it internally? I would find that *really* surprising, but given the above, I think it would be necessary to achieve consistency.
>
> This is a special backwards-compatibility thing.
That only answers the half-serious first part of my question. ;)
This code only works if foo() returns an Iterable, including a (yield)
coroutine:
@types.coroutine
def bar():
return (yield from foo())
It does not work for arbitrary Coroutines as they are not iterable, but it
might trick people into writing code that fails for non-coroutine
Coroutines. I'd rather like to have this either work for any Coroutine or
not at all. |
|
Date |
User |
Action |
Args |
2015-05-28 06:48:01 | scoder | set | recipients:
+ scoder, gvanrossum, ncoghlan, vstinner, asvetlov, python-dev, yselivanov |
2015-05-28 06:48:01 | scoder | link | issue24017 messages |
2015-05-28 06:48:01 | scoder | create | |
|