[ python-Bugs-1624534 ] updating a set in a list of sets will update all of them

SourceForge.net noreply at sourceforge.net
Fri Dec 29 20:46:50 CET 2006


Bugs item #1624534, was opened at 2006-12-29 22:05
Message generated for change (Comment added) made by amir_reza
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1624534&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
>Status: Deleted
Resolution: None
Priority: 5
Private: No
Submitted By: Amir Reza Khosroshahi (amir_reza)
Assigned to: Nobody/Anonymous (nobody)
Summary: updating a set in a list of sets will update all of them

Initial Comment:
If you make a list of sets in this way:
l = [set()] * 10

And then update one of them, by another set, say y:
y = set([1,2,3])
l[0] |= y

Then all of the elements of l, that is, all the sets in l will be updated.

But if you use a direct union:
l[0] = l[0] | y

This will not happen.

You should define the list that way (using the * operator) in order for this situation to take place.

----------------------------------------------------------------------

>Comment By: Amir Reza Khosroshahi (amir_reza)
Date: 2006-12-29 23:16

Message:
Logged In: YES 
user_id=1470587
Originator: YES

Sorry! It is a feature, not a bug.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1624534&group_id=5470


More information about the Python-bugs-list mailing list