Steven D'Aprano wrote:
Are you now supporting my argument that starring the list comprehension expression isn't meaningful?


The context it's in (a form of list display) has a clear
meaning for a comma-separated list of values, so there
is a reasonable interpretation that it *could* be given.

py> iterable = [(1, 'a'), (2, 'b')]
py> [(100, *t) for t in iterable]
[(100, 1, 'a'), (100, 2, 'b')]

The * there is in the context of constructing a tuple,
not the list into which the tuple is placed.

The difference is the same as the difference between
these:

>>> t = (10, 20)
>>> [1, (2, *t), 3]
[1, (2, 10, 20), 3]
>>> [1, 2, *t, 3]
[1, 2, 10, 20, 3]

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