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".

--
Greg
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to