[New-bugs-announce] [issue9932] List of sets initialization behavior problems
report at bugs.python.org
Thu Sep 23 22:39:08 CEST 2010
New submission from Adam Nemecek <adamnemecek at gmail.com>:
I'm not sure if this is the intended behavior, but it seems unusual to me.
a = [set() for i in range(2)] evaluates to a list [set(),set()] and
b= 2*[set()] evaluates to [set(),set()].
Nothing wrong here.
Nevertheless, if I do a.add(1), a has the value [set(), set()] but b.add(1) evaluates to [set(), set()].
I understand that in list b, all of the sets refer to the same object in memory, nevertheless, I do not feel like this is the correct behavior.
title: List of sets initialization behavior problems
versions: Python 2.7, Python 3.1
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce