Python Language Copy a set


Example

Sets also have a copymethod. You can use this method to perform a shallow copy.

>>> s1 = {()}
>>> s2 = s1.copy()
>>> s1 is s2
False
>>> s2.add(3)
>>> s1
{[]}
>>> s2
{3,[]}