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
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/R3XOET3YXZCWJYSQENIULAZBKPL5GZVW/
Code of Conduct: http://python.org/psf/codeofconduct/