[Python-ideas] yield from multiple iterables (was Re: The async API of the future: yield-from)

Guido van Rossum guido at python.org
Sun Oct 14 19:33:55 CEST 2012


On Sun, Oct 14, 2012 at 9:15 AM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> On Oct 14, 2012 8:42 AM, "Guido van Rossum" <guido at python.org> wrote:
>> Sadly it looks that
>>
>>   r = yield from (f1(), f2())
>>
>> ends up interpreting the tuple as the iterator, and you end up with
>>
>>   r = (f1(), f2())
>>
>> (i.e., a tuple of generators) rather than the desired
>>
>>  r = ((yield from f1()), (yield from f2()))
>
> Didn't want this tangent to get lost to the async discussion.  Would it be
> too late to make a change along these lines?  Would it be enough of an
> improvement to be warranted?

3.3 has been released. It's too late. Also I'm not sure what change
*could* be made. Surely yield from <a function returning a tuple>
should just iterate over that tuple -- that's fundamental to yield
from. The only thing that could be done might be to change "yield from
x, y" to mean something different than "yield from (x, y)" -- but
that's questionable at best, and violates many other contexts (e.g.
"return x, y", "yield x, y", "for i in x, y:").

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list