[Python-ideas] PEP for issue2292, "Missing *-unpacking generalizations"

Guido van Rossum guido at python.org
Mon Jul 15 19:25:44 CEST 2013


On Sun, Jul 14, 2013 at 7:12 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> One interesting point I see is that the "*expr" syntax in comprehensions is
> getting close to a nested "yield from":
[...]
>     # Flattening generator expression
>     g = (*x for x in iterable)
>
>     def _g(outermost_iterable):
>         for x in outermost_iterable:
>             yield from x
>
>     g = _g(iterable)
>
> The meaning for list and set comprehensions then follows from the generator
> expression semantics.

Interesting. I don't know if Joshua intended this translation, but
given that it's special syntax anyway it does sound interesting. I'd
like to see an implementation though -- to verify that it's not too
hard to implement correct, and that the syntax is actually
unambiguous.

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


More information about the Python-ideas mailing list