class EvenInt(int): def __init__(self, i): self.value = i def __add__(self, other): if (self.value + other) % 2 == 1: return (self.value + other + 1) else: return (self.value + other) def __radd__(self, other): return self.__add__(other) a = EvenInt(3) b = a + 2 c = 2 + a print(b) print(c)