+
and +=
represent two different operators, respectively add
and iadd
From http://docs.python.org/2/reference/datamodel.html#object.iadd: the methods iadd(self,other), etc
These methods are called to implement the augmented arithmetic
assignments (+=, -=, =, /=, //=, %=, *=, <<=, >>=, &=, ^=, |=).
These methods should attempt to do the operation in-place (modifying
self) and return the result
p += test1
uses the iadd
operator and hence changes the value of p
while p = p + test1
uses the add
which does not modify any of the two operands.