Stefan Behnel added the comment: >> 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24017> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com