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.

classification
Title: Lists within tuples mutability issue
Type: behavior Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, Владимир.Тырин
Priority: normal Keywords:

Created on 2014-09-24 14:20 by Владимир.Тырин, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg227451 - (view) Author: Владимир Тырин (Владимир.Тырин) Date: 2014-09-24 14:20
This behavior seems to be very strange. 

>>> l = [1, 2, 3]
>>> t = ('a', l)
>>> t
('a', [1, 2, 3])
>>> t[1] += [4]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> t
('a', [1, 2, 3, 4])
msg227452 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-09-24 14:22
See https://docs.python.org/3/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works
History
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66671
2014-09-24 14:22:16ezio.melottisetstatus: open -> closed

nosy: + ezio.melotti
messages: + msg227452

resolution: not a bug
stage: resolved
2014-09-24 14:20:48Владимир.Тыринcreate