python’s sum() and non-integer values
Its a bit tricky – the sum() function takes the start and adds it to the next and so on You need to implement the __radd__ method: class T: def __init__(self,x): self.x = x def __radd__(self, other): return other + self.x test = (T(1),T(2),T(3),200) print sum(test)