4 ms·
The proposal: https://www.python.org/dev/peps/pep-0572/ https://www.python.org/dev/peps/pep-0572/ Short version. (x =: y) is an expression that: 1. assigns t
by systoll 8y ago
The proposal: https://www.python.org/dev/peps/pep-0572/ https://www.python.org/dev/peps/pep-0572/
Short version.
(x =: y) is an expression that:
1. assigns the value y to the variable x
2. has the value y.
So `print((x := 1) + 1)` prints '2', and sets x=1.
A ton of languages [eg: c, js] have '=' work this way. And a ton of style guides for those languages tell you to avoid using it like that, because it's confusing. So this is a bit controversial.