Instance method to test equivalence between set and iterable
22 Mar
2020
22 Mar
'20
7:59 p.m.
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.
1485
Age (days ago)
1488
Last active (days ago)
29 comments
13 participants
participants (13)
-
Andrew Barnert
-
Bar Harel
-
Chris Angelico
-
Christopher Barker
-
Greg Ewing
-
Guido van Rossum
-
Kyle Stanley
-
M.-A. Lemburg
-
Paul Moore
-
Rob Cliffe
-
Stephen J. Turnbull
-
Steve Jorgensen
-
Steven D'Aprano