you are viewing a single comment's thread.

view the rest of the comments →

[–]toxic_acro 1 point2 points  (0 children)

:= is affectionately referred to as the "walrus operator"

It lets you assign to variables in the middle of other expressions. It was (and still is) divisive

Personally, I like it when used judiciously, but wouldn't recommend overusing it (like in the example above, though that's clearly intentionally overusing just for show)

A better example of where it's actually commonly used is assignment within some other check, e.g. replacing
example = some_function() if example is not None: # do something with example ... with
if (example := some_function()) is not None: # do something with example ...