inspection
set.issuperset
Returns True if every element of other is in s. Method form accepts any iterable; >= requires a set. Use > for strict (proper) superset.
s.issuperset(other) | s >= other Parameters
| Parameter | Purpose |
|---|---|
| other | An iterable (method) or set (operator) whose elements must all be in s |
| returns | bool |
Examples
>>> {1, 2, 3}.issuperset({1, 2})
True s contains every element of the argument.
>>> {1, 2} >= {1, 2}
True
>>> {1, 2} > {1, 2}
False >= allows equality; > is strict/proper superset.
>>> {1, 2, 3}.issuperset([1, 4])
False 4 is not in s, so it is not a superset.
>>> {1, 2}.issuperset([])
True Every set is a superset of the empty set/iterable.
Gotcha
>= and > require a set on the right; use .issuperset() for arbitrary iterables. It is the mirror of issubset: a >= b is equivalent to b <= a.
Related methods
← All Python set methods · List methods · list vs tuple vs set