set.issuperset()
Test set containment from the other side — does self contain every element of other?
Demo
issuperset returns True when every element of other appears in self. Any set is a superset of the empty set — including empty itself — because there is no element in the empty set that could fail the check. Neither input is modified.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| other | iterable | yes | A single iterable — set, list, tuple, generator, string, dict (keys). issuperset() accepts any iterable; the `>=` operator requires a set. |
Return value
bool — True if every element of other is contained in self — the mirror direction of issubset. Any set is a superset of the empty set (vacuously). The `>=` operator does the same thing but requires sets on both sides.
Common patterns
if granted_perms >= required_perms: allow()
if allowed_options >= set(user_selection): apply(user_selection)
if set(payload) >= required_fields: process(payload)
Examples
Pitfalls
{1, 2, 3}.issuperset(set())
if other and self >= other: ... # non-trivial superset
{1, 2, 3}.issuperset({1, 2, 3})
{1, 2, 3} > {1, 2, 3}
{1, 2, 3} >= [1, 2]
{1, 2, 3}.issuperset([1, 2])
{1, 2}.issuperset({1, 2, 3}) # expected True?
{1, 2, 3}.issuperset({1, 2})
When to use
- "Do we have everything they need?" — permission or capability grants
- Whitelist / allow-list checks
- Required-fields presence tests
- Any "self contains all of other" predicate
- Strict superset needed → `>` operator
- "No overlap at all" → set.isdisjoint
- Ordered containment → convert to sorted tuples and compare
- When issubset reads more naturally — pick the direction that matches the domain language
Notes
FAQ
Direction. `a.issuperset(b)` asks "does a contain everything in b?"; `a.issubset(b)` asks "is a contained inside b?". Same relation from opposite sides. Pick whichever reads clearest for the domain.