[issue46423] CLI: Addition assignment for tuples

2022-01-18 Thread Mark Dickinson


Mark Dickinson  added the comment:

Thanks for the report. This is a long-standing and known behaviour. It's been 
discussed a good few times before, and (quite apart from potential problems 
with backwards compatibility) no-one has yet come up with convincing 
alternative behaviours.

See 
https://docs.python.org/3/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works

Marking as a duplicate of https://bugs.python.org/issue40911

--
nosy: +mark.dickinson
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Unexpected behaviour for += assignment to list inside tuple

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46423] CLI: Addition assignment for tuples

2022-01-18 Thread Ali Ramezani


New submission from Ali Ramezani :

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 "", line 1, in 
TypeError: 'tuple' object does not support item assignment
>>> v
([1], [2])
>>> v[0]+=[3,4]
Traceback (most recent call last):
  File "", line 1, in 
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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com