[Python-ideas] PEP 448

Adam Bartoš drekin at gmail.com
Sat Aug 22 13:40:26 CEST 2015


On Fri, Aug 21, 2015 at 9:47 PM, Balakrishnan Balasubramanian
<balakrishnan.erode at gmail.com
<https://mail.python.org/mailman/listinfo/python-ideas>> wrote:
>* I tried out the new python3.5 rc1. I feel there is an inconsistency in
*>* unpacking generalizations. *iterable is considered error but *iterable,
*>* is a tuple. Should we make *iterable a list instead? This will be a
*>* nice shortcut to expand an iterable?
*

That is no inconsitency. The fact that `*iterable,` is a tuple has nothing
to do with unpacking generalizations. It is a tuple, because it's a tuple
literal.

>>> *range(5),
(0, 1, 2, 3, 4)
>>> (*range(5),)
(0, 1, 2, 3, 4)
>>> (-1, *range(5), 5)
(-1, 0, 1, 2, 3, 4, 5)
>>> [-1, *range(5), 5]
[-1, 0, 1, 2, 3, 4, 5]
>>> [*range(5)]
[0, 1, 2, 3, 4]
>>> {*range(5)}
{0, 1, 2, 3, 4}


Regards, Adam Bartoš
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150822/f9f63edf/attachment.html>


More information about the Python-ideas mailing list