On this page
  1. set
  2. Import & Availability
  3. Overview & Signature
  4. Common Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

set

Prev: round | Up: __builtins__ | Next: setattr
Rel: bool, int, float, complex, str
Ref: docs.python.org — set
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import set

Overview & Signature

set(iterable=(), /)

Build an unordered collection of unique elements.

Common Methods & Attributes

Usage

a, b = {1, 2, 3}, {3, 4, 5}
assert (a | b) == {1, 2, 3, 4, 5}
assert (a & b) == {3}
assert (a - b) == {1, 2}

Gotchas

REPL Inspect

help(set)

Linked from

Related notes