On this page
frozenset
Prev: format | Up: __builtins__ | Next: getattr
Rel: bool, int, float, complex, str
Ref: docs.python.org — frozenset
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import frozenset
Overview & Signature
frozenset(iterable=(), /)
Build an immutable unordered collection of unique elements.
Common Methods & Attributes
frozenset.copy(self, /)— Return a shallow copy of a set.frozenset.difference(self, /, *others)— Return a new set with elements in the set that are not in the others.frozenset.intersection(self, /, *others)— Return a new set with elements common to the set and all others.frozenset.isdisjoint(self, other, /)— Return True if two sets have a null intersection.frozenset.issubset(self, other, /)— Report whether another set contains this set.frozenset.issuperset(self, other, /)— Report whether this set contains another set.frozenset.symmetric_difference(self, other, /)— Return a new set with elements in either the set or other but not both.frozenset.union(self, /, *others)— Return a new set with elements from the set and all others.
Usage
fs = frozenset(["read", "write"])
assert "read" in fs and len({fs: "allowed"}) == 1
Gotchas
- Immutable & hashable
set: Can be used as adictkey or nested inside anotherset(unlike mutableset).
REPL Inspect
help(frozenset)
Linked from
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/format Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/getattr Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/bool Linked here; shared tags: #builtins
- tuts/python3/__builtins__/complex Linked here; shared tags: #builtins
- tuts/python3/__builtins__/float Linked here; shared tags: #builtins
- tuts/python3/__builtins__/int Linked here; shared tags: #builtins
- tuts/python3/__builtins__/str Linked here; shared tags: #builtins
- tuts/c/builtins shared tags: #builtins