Overload __nonzero__ method to overwrite zero boolean behaviour

Overload __nonzero__


class NumStr(object):
    def __nonzero__(self):        # False if both are
        return self.__num  or len(self.__string)




















Home »
  Python »
    Language Basics »




Python Basics
Operator
Statements
Function Definition
Class
Buildin Functions
Buildin Modules