13 Oct
2016
13 Oct
'16
10:23 p.m.
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