[Python-ideas] Implement __add__ for set and frozenset

Arnaud Delobelle arnodel at googlemail.com
Tue Jun 3 20:32:53 CEST 2008


On 3 Jun 2008, at 19:04, Raymond Hettinger wrote:

>> Perhaps it would be nice to have set.union (and set.intersection)  
>> to  accept more than one argument, i.e. have
>>    A = S.union(T, U, V)
>> mean
>>    A = S.union(T)
>>    A.update(U)
>>    A.update(V)
>
> Something like this has been on my todo list for a while.
>
> Patches are welcome.  It should be done for union,
> intersection, difference, and symmetric difference.

Difference is not an associative operation though. E.g.

     A - (B - B) = A  but  (A - B) - B = A - B

Same for symmetric difference (here "^" stands for symmetric  
difference). E.g.

     A ^ (B ^ B) = A  but  (A ^ B) ^ B = A | B

-- 
Arnaud




More information about the Python-ideas mailing list