Bar Harel wrote: > Hey Steve, > How about set.symmetric_difference()? > Does it not do what you want? > Best regards, > Bar Harel > On Sun, Mar 22, 2020, 10:03 PM Steve Jorgensen ste...@stevej.name 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. > > Should sets have an additional method, something like like(other), > > issimilar(other), or isequivalent(other), that returns > > True for any > > iterable that contains the all of the items in the set and no items that > > are not in the set? It would therefore be true in the same cases where > > <set> = set(other) or <set>.issubset(other) and > > <set>.issuperset(other) > > is 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/ULQQ7T... > > Code of Conduct: http://python.org/psf/codeofconduct/ > > Indirectly, it does, but that returns a set, not a `bool`. It would also, therefore, do more work than necessary to determine the result in many cases.
A python implementation for what I'm talking about would be something like the following. ``` def like(self, other): found = set() for item in other: if item not in self: return False found.add(item) return len(found) == len(self) ``` _______________________________________________ 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/XURB3B3RVM23ECR7BZZFFW7ISLLR63NQ/ Code of Conduct: http://python.org/psf/codeofconduct/