Message 244281 - Python tracker

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Content
>> 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.