[Python-ideas] Javascript Destructuring Assignment

Jim Jewett jimjjewett at gmail.com
Tue Mar 6 18:47:05 CET 2007


On 3/5/07, Brett Cannon <brett at python.org> wrote:
> On 3/5/07, Talin <talin at acm.org> wrote:
> >     http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7
...

> >    [a,,b] = [1,2,3]
> >
> > In other words, a is assigned the value 1, the value 2 is thrown away,
> > and b is assigned the value 3. In today's Python, this requires a dummy
> > variable.

> It skips in the middle?!?  Yuck.

Are you assuming variable-length skips, so that

    [a,,b] = [1,2,3,4,5]   would mean a=1;b=5 ?

I had read it is just not requiring a name for the unused dummy
variable.  It doesn't really seem worse than

    [a, _junk, b] = [1,2,3]

or less explicit than

    [a,_,b] = [1,2,3]

-jJ



More information about the Python-ideas mailing list