I am trying to understand how __add__ works:
__add__
class MyNum: def __init__(self,num): self.num=num def __add__(self,other):
Another option is reduce (functools.reduce in Python 3.x).
from functools import reduce from operators import add d=[MyNum(i) for i in range(10)] my_sum = reduce(add,d)