[New-bugs-announce] [issue24589] Wrong behavior for list of lists
Jos Dechamps
report at bugs.python.org
Wed Jul 8 10:01:16 CEST 2015
New submission from Jos Dechamps:
After creating a list of lists, changing one element, leads to changes of all the elements:
>>> v=[[]]*10
>>> v
[[], [], [], [], [], [], [], [], [], []]
>>> v[3].append(3)
>>> v
[[3], [3], [3], [3], [3], [3], [3], [3], [3], [3]]
>>>
>>> v=[[]]*10
>>> v
[[], [], [], [], [], [], [], [], [], []]
>>> v[3] += [3]
>>> v
[[3], [3], [3], [3], [3], [3], [3], [3], [3], [3]]
>>>
----------
components: Interpreter Core
messages: 246450
nosy: dechamps
priority: normal
severity: normal
status: open
title: Wrong behavior for list of lists
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24589>
_______________________________________
More information about the New-bugs-announce
mailing list