Overriding “+=” in Python? (__iadd__() method)
Is it possible to override += in Python? John Kugelman Yes, override the __iadd__ method. Example: def __iadd__(self, other): self.number += other.number return self In addition to what's correctly given in answers above, it is worth explicitly clarifying that when __iadd__ is overriden, the x += y operation does NOT end with the end of __iadd__ method. Instead, it ends with x = x.__iadd__(y) . In other words, Python assigns the return value of your __iadd__ implementation to the object you're "adding to", AFTER the implementation completes. This means it is possible to mutate the left side of