[Python-ideas] Fwd: Iterable unpacking within containers
Michele Lacchia
michelelacchia at gmail.com
Mon Jun 24 13:57:26 CEST 2013
Well, honestly the * syntax is a lot more readable and immediate to
understand,
given the fact the it is already used in function arguments.
On Mon, Jun 24, 2013 at 1:51 PM, Jonathan Slenders <jonathan at slenders.be>wrote:
> What about:
>
> >>> y = [-2] + list((-1, 0)) + list(x) + [4, 5]
>
> or itertools.chain?
>
>
>
>
> 2013/6/24 SpaghettiToastBook . <spaghettitoastbook at gmail.com>
>
> 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.
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>
--
Michele Lacchia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130624/a2c6cd0d/attachment.html>
More information about the Python-ideas
mailing list