https://docs.python.org/2/reference/datamodel.html#object.__iadd__
------------------------------------------------------------------
[...] These methods should attempt to do the operation in-place (modifying self) and return the result (which could be, but does not have to be, self). If a specific method is not defined, the augmented assignment falls back to the normal methods. For instance, to execute the statement x += y, where x is an instance of a class that has an __iadd__() method, x.__iadd__(y) is called. If x is an instance of a class that does not define a __iadd__() method, x.__add__(y) and y.__radd__(x) are considered, as with the evaluation of x + y.
-------------------------------------------------------------------
Returning NotImplemented still allows a TypeError to be raised, is subclass friendly, and is the way Python is designed. |