This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients ashwch, benrg, docs@python, ezio.melotti, r.david.murray
Date 2013-01-24.04:10:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359000602.86.0.893833148802.issue16701@psf.upfronthosting.co.za>
In-reply-to
Content
If you really want to freak out, try this:

>>> x = ([],)
>>> x[0] += [1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> x
([1],)

but to answer your question, it has *always* worked that way, from the time augmented assignment was introduced (see, eg, issue 1306777, which was reported against python 2.4).  

Remember, Python names refer to pointers to objects, they are not variables in the sense that other languages have variables.

Guido resisted augmented assignment for a long time.  These confusions speak to why.

As far as I know Ezio is correct, "when possible" means "when the target is mutable".  The documentation should probably be clarified on that point.  I'm not sure it is practical to let whether or not the target is mutated be an implementation detail. IMO the behavior must be clearly defined for each type that is built in to Python.
History
Date User Action Args
2013-01-24 04:10:02r.david.murraysetrecipients: + r.david.murray, ezio.melotti, docs@python, benrg, ashwch
2013-01-24 04:10:02r.david.murraysetmessageid: <1359000602.86.0.893833148802.issue16701@psf.upfronthosting.co.za>
2013-01-24 04:10:02r.david.murraylinkissue16701 messages
2013-01-24 04:10:02r.david.murraycreate