Re:Python 3.5.0
by dvlsg on Sunday September 13, 2015 @07:23PM
(#10213109)
Interesting. Javascript is actually adding something very similar, calling it destructuring. It's actually quite handy - although admittedly more handy for destructuring object arguments than array arguments.
[ Parent
| on HN ]
Python 2 & 3 have destructuring. This is talking about having
def fxn(a, (b, c), d):
pass
Be a valid function signature. So the destructuring is held in the function definition.Python 3 will still allow
def fxn(a, x, d):
(b, c) = x
pass
Both Python and ES6 JavaScript allow destructuring arrays://javascript
let [x, y] = [1,2]
#python
[x, y] = [1,2]
(x, y) = (1,2)
ES6 does allow that via destructuring - https://babeljs.io/repl/#?experimental=true&evaluate=true&lo...
function fxn(a, [b, c], d) {
console.log(a, b, c, d);
}