Set Methods

set.intersection_update()

Mutates the original set, so aliases observe the change. Retain only members common to every supplied iterable and the original set. The method accepts iterables rather than requiring set operands. With no arguments, membership is unchanged. Invalid iteration or hashing can raise exceptions. Do not assume transactional rollback on failure. Use the non-mutating counterpart when the original membership must be preserved.

Formal Syntax & Structure

python syntaxpython
items.intersection_update(*others)

Parameters & Attributes

NameTypeDescription
othersIterable[Hashable]Zero or more iterables of elements; each iterable is supplied as a separate positional argument.

Return Value

None

Mutates the existing set; no new set is returned.

Working Example

Example Snippetpython
active = {"build", "test", "ship"}alias = activeprint(active.intersection_update(["test", "ship"], ["test"]))print(sorted(alias))
Python Reference