←back to thread

317 points est | 1 comments | | HN request time: 0.215s | source
Show context
oooooof ◴[] No.17448560[source]
What is it? The link points to a discussion more deep than I’m willing to read.
replies(10): >>17448567 #>>17448570 #>>17448571 #>>17448572 #>>17448575 #>>17448579 #>>17448584 #>>17448591 #>>17448617 #>>17448638 #
1. systoll ◴[] No.17448638[source]
The proposal: 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.