3 ms·
There you have it folks, Python supports destructuring assignment. :-)
by alrex021 16y ago
There you have it folks, Python supports destructuring assignment. :-)
- jerf 16y agoWhat's the smiley for? Python 2.6.5... Type "help", "copyright", "credits" or "license" for more information. >>> (a, (b, c, (d, e))) = (1, (2, 3, (4, 5))) >>> a, b, c, d, e (1, 2, 3, 4, 5) >>> (a, (b, c, (d, e))) = (1, (2, 3, (4, 5, 6))) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: too many values to unpack It isn't quite as flexible as functional languages and it's not as idiomatic as it is in functional languages, but it's not a hack or quirky edge-case either.