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

Oscar Benjamin oscar.j.benjamin at gmail.com
Fri Jul 5 11:48:49 CEST 2013


On 5 July 2013 08:09, Paddy3118 <paddy3118 at gmail.com> wrote:
> On Friday, 5 July 2013 07:19:24 UTC+1, Greg Ewing wrote:
>> Oscar Benjamin wrote:
>> > On 4 July 2013 03:10, Steven D'Aprano <st... at pearwood.info> wrote:
>> >>
>> >>Does any other language with sets offer this as a set primitive?
>> >
>> > I'd be interested to know what they call it if they do.
>>
>> I think it should be called vennerate().
>
> Vennerate?
> Cute; but we have str1.partition(str2), and set1.partition(set2) would be
> mathematical partition of the union of both sets returning a tuple of three
> elements - just like str.partition, which makes me vote for the name
> "partition".

I didn't know about the str.partition method but having looked at it
now what it does is closer to what I think of as a partition of a set
i.e. after

    head, sep, tail = str1.partition(str2)

we have that

    str1 == head + sep + tail

By analogy I would expect that after

    set2, set3, set4 = set1.partition(...)

we would have

    set1 == set2 | set3 | set4

because that is (one property of) a "partition" of set1. However this
is not the meaning you intend.


Oscar


More information about the Python-ideas mailing list