[New-bugs-announce] [issue46423] CLI: Addition assignment for tuples

Ali Ramezani report at bugs.python.org
Tue Jan 18 08:28:36 EST 2022


New submission from Ali Ramezani <ramezaniua at gmail.com>:

In CLI (Command Line Interpreter):
A tuple has a list component then try to += that component. Since tuple doesn't allow assignment then it raises error but actually does that.
If you try actual equivalence (A=A+B) it does not.


Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> v=([1],[2])
>>> v[0]=v[0]+[3,4]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> v
([1], [2])
>>> v[0]+=[3,4]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> v
([1, 3, 4], [2])
>>>

----------
messages: 410861
nosy: ramezaniua
priority: normal
severity: normal
status: open
title: CLI: Addition assignment for tuples
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46423>
_______________________________________


More information about the New-bugs-announce mailing list