[Python-Dev] (no subject)
Ethan Furman
ethan at stoneleaf.us
Tue Feb 10 03:10:36 CET 2015
On 02/09/2015 05:48 PM, Donald Stufft wrote:
>
> I don’t think * means “loop” anywhere else in Python and I would never “guess” that
>
> [*item for item in iterable]
>
> meant that. It’s completely non intuitive. Anywhere else you see *foo it’s unpacking a tuple not making an inner loop. That
> means that anywhere else in Python *item is the same thing as item[0], item[1], item[2], …, but this PEP makes it so
> just inside of a comprehension it actually means “make a second, inner loop” instead of what I think anyone who has
> learned that syntax would expect, which is it should be equivalent to [(item[0], item[1], item[2], …) for item in iterable].
I agree with Donald. I would expect a list of lists from that syntax... or maybe a list of tuples?
--
~Ethan~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150209/7326bb80/attachment.sig>
More information about the Python-Dev
mailing list