Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 610 Bytes

File metadata and controls

30 lines (20 loc) · 610 Bytes

Pattern: Use of equality comparison for singleton object

Issue: -

Description

Comparisons to the singleton objects, like True, False, and None, should be done with identity, not equality. Use is or is not.

Example of incorrect code:

if var != True:
    print("var is not equal to True")
if var == None:
    print("var is equal to None")

Example of correct code:

if var is not True
    print("var is not True")
if var is None
    print("var is None")
   

Further Reading