[Python-ideas] Fwd: Iterable unpacking within containers
Nick Coghlan
ncoghlan at gmail.com
Mon Jun 24 14:16:44 CEST 2013
On 24 June 2013 21:59, Joshua Landau <joshua.landau.ws at gmail.com> wrote:
> 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 ;).
Yeah, what's needed is for a sufficiently motivated individual to take
the existing patch, update it to target 3.4, and write up a PEP that
details the exact changes proposed (not necessarily in that order).
The core developer reaction has generally been mildly positive, it's
just something that's on our "nice to have" lists rather than our
respective "I want this enough to work on it myself" lists :)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list