Steven D'Aprano wrote:

py> def gen():
...     for t in [(1, 'a'), (2, 'b'), (3, 'c')]:
...             yield *t
  File "<stdin>", line 3
    yield *t
SyntaxError: invalid syntax

Even if it was allowed, what would it mean? It could only mean "unpack the sequence t, and collect the values into a tuple; then yield the tuple".

To maintain the identity

  list(*x for x in y) == [*x for x in y]

it would be necessary for the *x in (*x for x in y) to expand
to "yield from x".

Python-ideas mailing list
Code of Conduct:

Reply via email to