[issue27668] list illogical affectation

antoine Zellmeyer report at bugs.python.org
Tue Aug 2 08:09:18 EDT 2016


New submission from antoine Zellmeyer:

>>> tab = [['x']*3]*3
>>> tab
[['x', 'x', 'x'], ['x', 'x', 'x'], ['x', 'x', 'x']]
>>> tab[1][0] = 5
>>> tab
[[5, 'x', 'x'], [5, 'x', 'x'], [5, 'x', 'x']]
>>> 

why not only the element tab[1][0] is changed ?

----------
assignee: terry.reedy
components: IDLE, Interpreter Core, Macintosh
messages: 271817
nosy: antoine Zellmeyer, ned.deily, ronaldoussoren, terry.reedy
priority: normal
severity: normal
status: open
title: list illogical affectation
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27668>
_______________________________________


More information about the Python-bugs-list mailing list