R. David Murray added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16701>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to