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

Eric Snow ericsnowcurrently at gmail.com
Tue Oct 23 07:07:17 CEST 2012


On Mon, Oct 22, 2012 at 9:55 AM, Steve Dower <Steve.Dower at microsoft.com> wrote:
> I think the abstract for PEP 380 sums is up pretty well: "A syntax is proposed for a generator to
> delegate part of its operations to another generator." Using 'yield from' (YF, for convenience)
> requires (a) that the caller is a generator and (b) that the callee is a generator.

Rather, the callee must be some iterable:

  def f():
      yield from [1, 2, 3]

  for x in f():
      print(x)

-eric



More information about the Python-ideas mailing list