Python‎ > ‎set‎ > ‎

set.symmetric_difference_update()

http://www.adilwaseem.com/

Definition
Update a set with the symmetric difference of itself and another.

Syntax
set(x).symmetric_difference_update(y)> z

Parameters
x,y,z=sets

Example
The output is:
 set1={3,1,44,66}
set2={2,3,33,44}
set3=set1.symmetric_difference(set2)
set3=set1.symmetric_difference_update(set2)
print(set1)

>>> 
{1, 66, 33, 2}
>>>

set.symmetric_difference_update()
The return is:
 >>> from decimal import Decimal
>>> a=set()
>>> a.add(Decimal(1).adjusted())
>>> a.add(Decimal(.55).canonical())
>>> a.add(Decimal(-1).compare_signal(1))
>>> a
{0, Decimal('0.5500000000000000444089209850062616169452667236328125'), Decimal('-1')}
>>> b=set()
>>> b.add(Decimal(1).compare_total(2))
>>> b.add(Decimal(0.1).copy_abs())
>>> b
{Decimal('0.1000000000000000055511151231257827021181583404541015625'), Decimal('-1')}
>>> a.symmetric_difference_update(b)
>>> a
{Decimal('0.1000000000000000055511151231257827021181583404541015625'), Decimal('-1')}


Comments