Operator overloading

a + b calls a.__add__(b). Likewise * calls __mul__, - calls __sub__, and so on. Define them and your objects work with operators.

If your method can't handle the other value, return NotImplemented (don't raise). Python then tries the reflected method on the right-hand object, b.__radd__(a). If both give up, you get a clean TypeError.

That's why 3 * m needs __rmul__: int.__mul__ doesn't know about Minutes, so Python asks m.__rmul__(3).

The surprise is sum(). It starts from 0, so its first step is 0 + m. Make __radd__ accept 0 and sum works on your objects.

Operators should return a new object, not change self. Use += (__iadd__) only if you really want in-place changes.

Run it, then try m - Minutes(5) and add __sub__ to make it work.