[Python-ideas] Javascript Destructuring Assignment

Jim Jewett jimjjewett at gmail.com
Wed Mar 7 23:14:06 CET 2007


On 3/7/07, Ron Adam <rrr at ronadam.com> wrote:
> The example from above could then be...
>
>     >>> data = [[1, 2, 3, 4], [5, 6, 7, 8], 9, 10]
>     >>> a, b, c, d, e, f, g = "[[,,*],[,,*],*]" %% data
>
>     >>> print a, b, c, d, e, f, g
>     1 2 [3, 4] 5 6 [7, 8] [9, 10]

...

>     >>> data = [[1, 2, 3, 4], [5, 6, 7, 8], 9, 10]
>     >>> a, b, c, d = ",,,*" %% "[,[],,]" %% data
>     >>> print a, b, c, d
>     [1, 2, 3, 4] 5 6 [7, 8, 9, 10]

...

> This type of abstraction may make it easier to interface different types of
> objects and data structures dynamically.

I can see how this might be made efficient.

I'm not seeing how I could ever maintain code that used it.

-jJ



More information about the Python-ideas mailing list