[Python-ideas] Implement __add__ for set and frozenset

Raymond Hettinger python at rcn.com
Tue Jun 3 21:48:27 CEST 2008


From: "Arnaud Delobelle" <arnodel at googlemail.com>
>  there no way to predict the output of this:
> 
> >>> set_of_sets = { {1, 2}, {2, 3} }
> >>> set.difference(*set_of_sets)

That's silly.  Lot's of functions do odd things with random argument ordering:

>>> s = set([9, 3])
>>> int.__sub__(*s)
6

Besides, you can already run the sample fragment in Py2.5:

>>> sos = set( [frozenset([1, 2]), frozenset([2, 3])])
>>> frozenset.difference(*sos)
frozenset([1])


Raymond



More information about the Python-ideas mailing list