A.__nonzero__() (see Special method names documentation) and use the return value of that function. Here’s the summary:
Called to implement truth value testing and the built-in operation
bool(); should return
True, or their integer equivalents
1. When this method is not defined,
__len__() is called, if it is defined, and the object is considered true if its result is nonzero. If a class defines neither
__nonzero__(), all its instances are considered true.
On the other hand,
if A is not None:
compares only the reference
None to see whether it is the same or not.