I thought I might be able to find more fuel for my anti-python argument by investigating exactly what objects are equal to each other (generate a truth table). Actually, the python truth table is actually, very reasonable.
Also, I wanted to be confident of what values are considered True or False.
The one best practice related to this – that a colleague taught me – is to use
x is None instead of use
if x == None: ... because None could be equal to any object 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.