On 23/03/2020 23:49, Steven D'Aprano wrote:
On Mon, Mar 23, 2020 at 02:05:49PM +0000, Rob Cliffe via Python-ideas wrote:

s = set("a")
t = list("aa")
s.issubset(t)
True
s.issuperset(t)
True

but it would be misleading IMO to say that s and t are in some sense
equal.
In *some* sense they are equal:

- every element in s is also in t;
- every element in t is also in s;
- no element in s is not in t;
- no element in t is not in s;
- modulo uniqueness, both s and t have the same elements;
- converting t to a set gives {'a'} which is equal to s.

I don't know that this is an *important* sense, but the OP Steve J isn't
wrong to notice it.

I shouldn't need to say this, but for the record I am not proposing and
do not want set equality to support lists; nor do I see the need for a
new method to perform "equivalent to equality" tests; but if the
consensus is that sets should have that method, I would prefer it to be
given the simpler name:

     set.superset  # not .equivalent_to_superset
     set.subset    # not .equivalent_to_subset
     set.equals    # not some variation of .equivalent_to_equals


I could have expressed myself more clearly.  What I mean is that if the new method accepts an arbitrary iterable, it should not have a name such as 'equals' or 'isequal' because that is just plain misleading - it should be called something
less definite like 'iscoextensive' or [your suggestion here].
Conversely, if the new method only accepts a set as argument, it's fine to call it 'isequal' or whatever, because when
it returns True the two sets *will* be equal.
Rob Cliffe
_______________________________________________
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/VQ3ZK3TYV4FUDPPIW4NKG4YBAZ7XMFJM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to