
On Mon, Mar 23, 2020 at 12:03:50AM -0000, Steve Jorgensen wrote:
Every set is a superset of itself and a subset of itself. A set may not be a "formal" subset or a "formal" superset of itself. `issubset` and `issuperset` refer to standard subsets and supersets, not formal subsets and supersets.
Sorry, I don't understand your terminology "formal" and "standard". I think you might mean "proper" rather than formal? But I don't know what you mean by "standard". We might have a terminology issue here, since according to Wikipedia there is some dispute over whether or not to include the equality case in subset/superset: https://en.wikipedia.org/wiki/Subset For what it is worth, I'm in the school that subset implies proper subset, i.e. A ⊂ B implies that A ≠ B and that sets are *not* subsets (or supersets) of themselves. To be explicit, A ⊂ B means the same as A ⊊ B not A ⊆ B. But I can see that people's usage on this varies, so I won't argue that one way or the other is "wrong". So long as we agree on which convention we are using. So to be clear, you are referring to the improper subset, which in Python we write as the first comparion, not the second: py> {1} <= {1} # like {1}.issubset({1}) True py> {1} < {1} False
In Python, you can trivially check that… ``` In [1]: {1, 2, 3}.issubset({1, 2, 3}) Out[1]: True
Okay, that's an *improper* subset, since the two sets are equal. That's documented as more-or-less equivalent to `A <= B`: https://docs.python.org/3/library/stdtypes.html#frozenset.issubset (The only difference is that the operator version requires actual sets, while the method version accepts any iterable.) Do you have an example of `A <= B and B <= A` aside from the `A == B` case? -- Steven