Frozenset Methods
frozenset.difference()
Keep receiver members absent from every supplied iterable. This operation is directional: exchanging the operands generally changes the answer. Returns a frozenset result without changing the receiver. The immutable receiver remains usable as a hashable key; do not rely on result identity. The method accepts iterable inputs such as lists or generators, unlike the built-in - operator between sets. With zero arguments, the result has the same members as the receiver. Elements used in hashing must be hashable. Input iteration can raise exceptions; no ordering is guaranteed.
Formal Syntax & Structure
python syntaxpython
items.difference(*others)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| others | Iterable[Hashable] | Zero or more iterables of elements; each iterable is supplied as a separate positional argument. |
Return Value
frozenset
frozenset containing the calculated members.
Working Example
Example Snippetpython
a = frozenset({"read", "write", "export"})b = a.difference(["write"], {"export"})print(sorted(b), type(b).__name__)print(sorted(a))