[Python-ideas] Fwd: Iterable unpacking within containers
SpaghettiToastBook .
spaghettitoastbook at gmail.com
Mon Jun 24 06:23:24 CEST 2013
I think it would be very convenient if the * syntax was extended to
allow unpacking iterables inside containers. For example:
>>> x = range(1, 4)
>>> y = [-2, *(-1, 0), *x, 4, 5]
>>> print(y)
[-2, -1, 0, 1, 2, 3, 4, 5]
This would be especially convenient if two lists needed to be
combined, but one list's contents needed to be the the middle of the
other one. I don't think any code would break because the suggested
syntax currently raises a SyntaxError.
More information about the Python-ideas
mailing list