On Thu, Sep 29, 2016 at 4:47 PM, Rustom Mody <rustompm...@gmail.com> wrote: >> Because True is the default, object need not and at least in CPython >> does not have a __bool__ (or __len__) method. Classes with no falsey >> objects, such as functions, generators, and codes, need not do anything >> either. In the absence of an override function, the internal bool code >> returns True. >> > Not sure what you are trying to say Terry... > Your English suggests you disagree with me > Your example is exactly what I am saying; if a type has a behavior in which > all values are always True (true-ish) its a rather strange kind of > bool-nature. > > Shall we say it has Buddha-nature? ;-)
There are a LOT of objects that are always true. Take this example: class Employee: def __init__(self, name): self.name = name self.boss = None def report(self): if self.boss: self.boss.emit_report("I have done nothing.") else: company_board.proclaim("I have done everything.") Every Employee object counts as true, and None counts as false. This is the most normal way to write something. Unless an object represents a collection, number, etc, that can meaningfully be "empty", it should be assumed that it is true, and *the absence of an object* is what's false. Not every object has a sane representation of nothingness. ChrisA -- https://mail.python.org/mailman/listinfo/python-list