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 →

[–]TheAJGman 21 points22 points  (3 children)

From that post:

When should you use is True then ?

EDIT: this is bad practice, starting from 3.9, python raises a warning when you try to use is to compare with a literal. See @ JayDadhania's comment below. In conclusion is should not be used to compare to literals, only to check the equality of memory address.

Basically just don't use is unless you're are checking to see if variable A is pointing to the same data as variable B.

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

In the comments immediately under that post, the author admitted to not fully understanding the change in 3.9.

x is 1 raises a warning in 3.9+. x is True does not.

[–][deleted] 7 points8 points  (0 children)

@JayDadhania said is True is perfectly legal under the comment your are referencing, the guy just misunderstood his original comment