[issue7910] immutability w/r to tuple.__add__

Jean-Paul Calderone report at bugs.python.org
Thu Feb 11 16:28:23 CET 2010


Jean-Paul Calderone <exarkun at divmod.com> added the comment:

Your output looks fishy.  Anyway, the behavior of += isn't a bug:

>>> a = b = (1, 2)
>>> a += (1, 2, 3)
>>> a
(1, 2, 1, 2, 3)
>>> a is b
False
>>> 

It's confusing, to be sure, but no mutation is going on.  += is only in-place if applied to something that supports mutation this way (by implementing __iadd__).

----------
nosy: +exarkun

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7910>
_______________________________________


More information about the Python-bugs-list mailing list