[Python-ideas] exclusively1, common, exclusively2 = set1 - set2, set1 & set2, set2 - set1

Steven D'Aprano steve at pearwood.info
Sun Jul 7 04:23:00 CEST 2013


On 07/07/13 07:40, Joshua Landau wrote:

> (I still don't get what people have against my version though. A 2-way
> partition makes sense)

For the record, your suggestion was to add a convenience method:

set1.partition(set2) => (set1 - set2, set1 & set2)

and then call it as a two-liner:

only1, both = set1.partition(set2)
only2 = set2 - set1


instead of Paddy's suggestion (with the method name left unknown):

only1, both, only2 = set1.???????(set2)


I don't think much of your suggestion. It doesn't solve the stated use-case, where you want a three-way partition of two sets. And I'm having difficulty in thinking of practical examples where I might only want two out of the three "Venn subsets". Since this is a convenience method, it doesn't add any new functionality, it needs to be *more* rather than *less* convenient than what it replaces.



-- 
Steven


More information about the Python-ideas mailing list