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

tuple

Prev: super | Up: __builtins__ | Next: type
Rel: bool, int, float, complex, str
Ref: docs.python.org โ€” tuple
Tags: #public #python3 #builtins


Import & Availability

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

Overview & Signature

tuple(iterable=(), /)

Built-in immutable sequence.

Common Methods & Attributes

Usage

single = (42,)   # trailing comma makes it a 1-tuple!
x, *rest = (1, 2, 3, 4)
assert isinstance(single, tuple) and x == 1 and rest == [2, 3, 4]

Gotchas

REPL Inspect

help(tuple)

Linked from

Related notes