Paul Moore wrote:
> On Sun, 22 Mar 2020 at 20:01, 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.
> > What is the practical use case for this? It seems like it would be a
> pretty rare need, at best.
> Paul

Basically, it is for a sense of completeness. It feels weird that there is a 
way to check whether an iterable is a subset of a set or a superset of a set 
but no way to directly ask whether it is equivalent to the set.

Even though the need for it might not be common, I think that the collection of 
methods makes more sense if a method like this is present.
_______________________________________________
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/MRCHHRVCXEUAB3HBV4WRMZ56O3HUJQYL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to