__nonzero__() overridden to return False : nonzero « Class « Python Tutorial






class C:
    def __nonzero__(self):
        return False

c = C()
print bool(c)
print bool(C)








11.23.nonzero
11.23.1.no __nonzero__()
11.23.2.__nonzero__() overridden to return False