Steven D'Aprano wrote: > On Sun, Mar 22, 2020 at 07:59:59PM -0000, Steve Jorgensen wrote: > > Currently, the issubset and > > issuperset methods of set objects > > accept arbitrary iterables as arguments. An iterable that is both a > > subset and superset is, in a sense, "equal" to the set. It would be > > inappropriate for == to return True for such a comparison, > > however, since that would break the Hashable contract. > > I think the "arbitrary iterables" part is a distraction. We are > fundamentally talking about a comparison on sets, even if Python relaxes > the requirements and also allows one operand to be a arbitrary iterable. > I don't believe that a set A can be both a superset and subset of > another set B at the same time. On a Venn Diagram, that would require A > to be both completely surrounded by B and B to be completely surrounded > by A at the same time, which is impossible. > I think you might be talking about sets which partially overlap: > A = {1, 2, 3, 4} > B = {2, 3, 4, 5}
Every set is a superset of itself and a subset of itself. A set may not be a "formal" subset or a "formal" superset of itself. `issubset` and `issuperset` refer to standard subsets and supersets, not formal subsets and supersets. In Python, you can trivially check that… ``` In [1]: {1, 2, 3}.issubset({1, 2, 3}) Out[1]: True In [2]: {1, 2, 3}.issuperset({1, 2, 3}) Out[2]: True In [3]: {1, 2, 3}.issubset((1, 2, 3)) Out[3]: True In [4]: {1, 2, 3}.issuperset((1, 2, 3)) Out[4]: True ``` _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QRI7LQAR7TZXSWOVYY5KLS52HK2GU7IK/ Code of Conduct: http://python.org/psf/codeofconduct/