class Integer(object): def __init__(self, value=0): self._value = int(value) def __add__(self, other): if isinstance(other, Integer): return Integer(self._value + other._value) return Integer(self._value + other) def __iadd__(self, other): if isinstance(other, Integer): self._value += other._value else: self._value += other return self def __sub__(self, other): if isinstance(other, Integer): return Integer(self._value - other._value) return Integer(self._value - other) def __isub__(self, other): if isinstance(other, Integer): self._value -= other._value else: self._value -= other return self def __mul__(self, other): if isinstance(other, Integer): return Integer(self._value * other._value) return Integer(self._value * other) def __div__(self, other): if isinstance(other, Integer): return Integer(self._value / other._value) return Integer(self._value / other) def __str__(self): return str(self._value) def __int__(self): return self._value def __float__(self): return float(self._value) def __repr__(self): return 'Integer(%s)' % self._value
source share