1def __add__(self, other):
2 if isinstance(other, self.__class__):
3 return self.x + other.x
4 elif isinstance(other, int):
5 return self.x + other
6 else:
7 raise TypeError("unsupported operand type(s) for +: '{}' and '{}'").format(self.__class__, type(other))