Next / Previous / Contents / TCC Help System / NM Tech homepage

26.3.18. __nonzero__(): True/false evaluation

If a class defines it, this special method is called whenever an instance is converted to a Boolean value, either implicitly (for example, when it is the test in an “if” statement) or explicitly via the built-in bool() function. Here is the calling sequence:

    def __nonzero__(self):
        ...

Return a Boolean value, either True or False.