[Python-ideas] Fwd: Iterable unpacking within containers
Jonathan Slenders
jonathan at slenders.be
Mon Jun 24 13:51:06 CEST 2013
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130624/54f184ab/attachment.html>
More information about the Python-ideas
mailing list