[Tutor] Confusion about definition of proper subset in python set

Cameron Simpson cs at cskk.id.au
Fri Oct 30 17:28:36 EDT 2020


On 30Oct2020 09:00, Alan Gauld <alan.gauld at yahoo.co.uk> wrote:
>On 30/10/2020 02:52, Manprit Singh wrote:
>> Test whether the set is a proper subset of *other*, that is, set <= 
>> other and set != other.
>>
>> This confuses me actually.
>>
>> set <= other   and set != other , how it is possible at same time ?
>
>Very easily.

I think Manprit Singh has confused "subset" (set <= other) and proper 
subset (set < other). Well, not confused, because he's clearly well 
aware of the distinction. But confused about the docs.

He's correctly pointing out that being a proper subset excludes the "=" 
part of "<=". But I can't find anything in the documentation talking 
specificly about "proper subsets", which are themselves a proper subset 
of subsets in general.

The docs only talk about "subsets", which is what issubset() tests, 
along with the <= operator between sets.

Manprit: where in the docs did you find the term "proper subset"? I 
can't see it.

You're correct about the definition, but as far as I can see the 
documents don't bother with that.

>> Test whether the set is a proper subset of *other*, that is, set <= 
>> other and set != other.

Is this a task request from a tutorial? If so, it likely exists because 
the definitions of sets in Python do not directly address this, and this 
is an exercise to _construct_ a "proper subset" test _from_ the 
facilities available in the language. Which is easy.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Tutor mailing list