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.

classification
Title: updating a set in a list of sets will update all of them
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amir_reza
Priority: normal Keywords:

Created on 2006-12-29 18:35 by amir_reza, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg30882 - (view) Author: Amir Reza Khosroshahi (amir_reza) Date: 2006-12-29 18:35
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.
msg30883 - (view) Author: Amir Reza Khosroshahi (amir_reza) Date: 2006-12-29 19:46
Sorry! It is a feature, not a bug.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44386
2006-12-29 18:35:20amir_rezacreate