Set Methods
set.update()
Mutates the original set, so aliases observe the change. Add all members from each supplied iterable. 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. In local CPython, an iterator that raises after yielding some values can leave those earlier additions applied. Use the non-mutating counterpart when the original membership must be preserved.
Formal Syntax & Structure
python syntaxpython
items.update(*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
None
Mutates the existing set; no new set is returned.
Working Example
Example Snippetpython
tags = {"draft"}alias = tagsprint(tags.update(["review", "draft"], ("done",)))print(sorted(alias))