O'Reilly logo
  • You Wang thinks this is interesting:

This behavior is usually what we want, but notice that it implies that the += is an in-place change for lists; thus, it is not exactly like + concatenation, which always makes a new object. As for all shared reference cases, this difference might matter if other names reference the object being changed:


Cover of Learning Python, 5th Edition


augmented assignment can't be used when shared references must be broken