[Python-ideas] Javascript Destructuring Assignment

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Mar 7 09:34:34 CET 2007

Ron Adam wrote:

> I have mixed feeling on it myself.  

As far as I remember, there weren't really any objective
reasons given against it, just gut feelings of dislike
from some people, including Guido. I'm living in hopes
that he may come round to the idea in time (as he did
with conditional expressions, for example).

 > The reason being, (to me), using the '*' for both packing
 > and unpacking is not the most readable solution.

To me it doesn't seem any less readable than using
[...,...] or (...,...) for both packing and unpacking,
or using * in both function definitions and calls. In
fact the symmetry is a large part of the beauty of
the idea.

> Also the '*' syntax can't be used to unpack nested items.

I'm not sure what you mean by that.

    >>> [[a, b, *c], [d, e, *f], *g] = [[1, 2, 3, 4], [5, 6, 7, 8], 9, 10]

    >>> print a, b, c, d, e, f, g
    1 2 [3, 4] 5 6 [7, 8] [9, 10]

Makes perfectly good sense to me.


More information about the Python-ideas mailing list