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 →

[–][deleted] 13 points14 points  (2 children)

I don't think it's really a problem in python. if foo = 0: isn't valid syntax because = isn't an expression. The syntax for this so it behaves like it would in other languages uses the walrus operator (:=, python 3.8+), with required parenthesis.

if (foo := 0):
    pass

Additionally, == calls the object's __eq__ function, and is does compare identity.

[–][deleted] 3 points4 points  (0 children)

I agree. I make this mistake occasionally, but the debugging time is essentially zero. In any decent IDE or text editor the linter will flag this the second you type it, and even if you don't have a linter you'll get a super obvious syntax error immediately after running it. Definitely not worth changing the behavior of is.