[issue25681] Assignment of one element in nested list changes multiple elements

Yan report at bugs.python.org
Fri Nov 20 09:39:48 EST 2015


New submission from Yan:

Is this the correct behavior?

>>> l=[['']*2]*3
>>> b=[['', ''], ['', ''], ['', '']]
>>> l == b
True
>>> l[0][1]='A'
>>> b[0][1]='A'
>>> l == b
False
>>> l
[['', 'A'], ['', 'A'], ['', 'A']]
>>> b
[['', 'A'], ['', ''], ['', '']]

----------
messages: 254978
nosy: ydu
priority: normal
severity: normal
status: open
title: Assignment of one element in nested list changes multiple elements
type: behavior
versions: Python 2.7

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


More information about the Python-bugs-list mailing list