The table below shows what values are considered equal in the python programming language. I thought I might be able to find more reasons for Why I hate Python, but actually the python truth table is very reasonable. Also, This truth table will help you be confident of what values are considered True or False.
This table demonstrates why it is best practice to use
x is None instead of
if x == None. None can be equal to any object instance depending on its implementation of
 ==  since I would expect them to be two different list instances, but I would expect equality for
(,) = (,) (identical tuples).
There are a few nuances when considering truthiness, however. If you’ve got code that reads
if x: ... The following values for x are treated as false:
- zero of any numeric type. Like these:
- any empty string, tuple, or array.
- an empty dictionary, for example,
- instances of user-defined classes, if the class defines a
__len__()method and that method returns the integer
0or boolean value
Everything else is truthy (considered equal to True).
Here’s the code I used to generate the tables above.