Index: operator.rst =================================================================== --- operator.rst (revision 84368) +++ operator.rst (working copy) @@ -234,6 +234,23 @@ ``z = operator.iadd(x, y)`` is equivalent to the compound statement ``z = x; z += y``. +For immutable objects, (such as integers), ``a.__iadd__(b)`` returns +``a + b`` *and then* this value is assigned to *a* (or rather *a* +is bound to the value). So for immutables objects, +``operator.iadd(a, b)`` is the same as ``a + b``. + +For mutable objects (such as lists), ``a.__iadd__(b)`` mutates the +object *and then* returns self so that when the assignement is +executed, *a* will still be bound the the same object. E.g. if +``a = [1, 2]`` then:: + + a += [3] + +will first append 3 to the list and then reassign the list to +*a* (it is unnecessary in this case but if this step was omitted, +the "in place" operators wouldn't work on immutables types). + + .. function:: iadd(a, b) __iadd__(a, b)