[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 21:19:04 CEST 2012
On Sun, Oct 14, 2012 at 12:14 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On 15/10/12 03:15, Eric Snow 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()))
> How about this?
> r = yield from *(f1(), f2())
> which currently is a SyntaxError in 3.3.
I think it's too early to start proposing new syntax for a problem we
don't even know is common at all.
Greg Ewing's proposal works for me:
r = yield from par(f1(), f2())
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas