What do you want to save?
Add Code snippet
New code examples
-
Python 2021-10-30 00:42:09
python operator overloading deal with type
def __add__(self, other): if isinstance(other, self.__class__): return self.x + other.x elif isinstance(other, int): return self.x + other else: raise TypeError("unsupported operand type(s) for +: '{}' and '{}'&quo... Add solution