[Python-ideas] Implement __add__ for set and frozenset
Arnaud Delobelle
arnodel at googlemail.com
Tue Jun 3 21:02:24 CEST 2008
On 3 Jun 2008, at 19:44, Raymond Hettinger wrote:
> > Difference is not an associative operation though. E.g.
>
> A.difference(B, C, D) means A - B - C - D
> which can be (((A - B) - C) - D)
> or (((A - D) - C) - B)
> or (((A - C) - B) - D)
> or (((A - C) - D) - B)
>
> You can do the subtractions from A in any order.
That's true. However there no way to predict the output of this:
>>> set_of_sets = { {1, 2}, {2, 3} }
>>> set.difference(*set_of_sets)
And
A.difference(B, C, D)
could be rewritten as
A - set.union(B, C, D)
which may be just as clear.
--
Arnaud
More information about the Python-ideas
mailing list