[Python-ideas] Fwd: Iterable unpacking within containers

Joshua Landau joshua.landau.ws at gmail.com
Mon Jun 24 13:59:24 CEST 2013


On 24 June 2013 05:23, SpaghettiToastBook .
<spaghettitoastbook at gmail.com> wrote:
> 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.

You might well want to read all of http://bugs.python.org/issue2292.

I'm a huge fan, but it's not here yet ;).


More information about the Python-ideas mailing list