This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author adamnemecek
Recipients adamnemecek
Date 2010-09-23.20:39:06
SpamBayes Score 0.0001732083
Marked as misclassified No
Message-id <1285274348.08.0.841759888392.issue9932@psf.upfronthosting.co.za>
In-reply-to
Content
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[0].add(1), a has the value [set([1]), set([])] but  b[0].add(1) evaluates to [set([1]), set([1])]. 
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.
History
Date User Action Args
2010-09-23 20:39:08adamnemeceksetrecipients: + adamnemecek
2010-09-23 20:39:08adamnemeceksetmessageid: <1285274348.08.0.841759888392.issue9932@psf.upfronthosting.co.za>
2010-09-23 20:39:06adamnemeceklinkissue9932 messages
2010-09-23 20:39:06adamnemecekcreate