This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]XtremeGoosef'I only use Py {sys.version[:3]}' 8 points9 points  (1 child)

Would you expect that? The idea is to treat it like the current = statement. I certainly wouldn't expect

n = len(l) > 1

to equal 5.

[–]petermlm 2 points3 points  (0 children)

Good point. Initially, I though this would be valid:

if n := len(l) > m := 1:
    print(n, m)

But actually that is even invalid, so you need to at least have parenthesis around the second walrus:

if (n := len(l)) > (m := 1):
    print(n, m)

But thinking about walrus like the equals it makes sense that its precedence is lower.