# __nonzero__() overridden to return False
d = D()
print '__nonzero__() overridden to return False: ', bool(d)
print '__nonzero__() overridden to return False: ', bool(D)
Called to implement truth value testing and the built-in operation bool(); should return False or True, or their integer equivalents 0 or 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 __len__() nor __nonzero__(), all its instances are considered true.