[issue24589] Wrong behavior for list of lists
Bastiaan Albarda
report at bugs.python.org
Wed Jul 8 11:53:24 CEST 2015
Bastiaan Albarda added the comment:
The * operator lets you use the same object multiple times, thereby saving resources.
If you want unique objects use comprehension:
>>> v = [[] for x in range(10)]
>>> v[3].append(3)
>>> v
[[], [], [], [3], [], [], [], [], [], []]
>>> v[3] += [3]
>>> v
[[], [], [], [3, 3], [], [], [], [], [], []]
----------
nosy: +Bastiaan Albarda
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24589>
_______________________________________
More information about the Python-bugs-list
mailing list