Skip to main content

Immutable sequences

Python Tuples: Immutable Records, Packing, and Unpacking

Tuples represent ordered values whose positions form a stable record. Their immutability prevents item replacement but does not freeze nested objects.

Pythonbeginner4 min readPython fundamentals

Learning overview

Estimated time
4 minutes
Difficulty
Beginner
Prerequisites
No prior experience required
Learning outcome
Explain python using a clear mental model · Apply python in practical Python work
Last updated
July 18, 2026

Use tuples for fixed positional records

Coordinates, RGB values, and small function returns can use tuples when each position has a clear meaning. For larger domain records, named tuples or frozen dataclasses communicate fields more clearly.

tuple-record.py
point = (12, 8)
x, y = point

head, *middle, tail = ("HTML", "CSS", "Python", "SQL")


def dimensions() -> tuple[int, int]:
    return 1280, 720

Understand tuple immutability

A tuple cannot replace, add, or remove positions. A tuple can still contain a mutable list, and that nested list can change. Hashability depends on every contained value being hashable.

Choose tuple, list, or dataclass

Use a list for a changing homogeneous sequence, a tuple for a compact fixed positional record, and a dataclass when named fields and domain behavior improve clarity.

Frequently asked questions

Are Python tuples always hashable?

No. A tuple is hashable only when every element it contains is hashable. A tuple containing a list cannot be a dictionary key.

Why does a one-item tuple need a comma?

The comma creates the tuple; parentheses primarily group expressions. Write (value,) or value, for a one-item tuple.

Topic graph

A taxonomy-generated path through this subject.

  1. Python
  2. Python fundamentals
  3. python
  4. tuples
  5. collections
  6. immutability
  7. What Is Python in Programming?
  8. Learn Python: From Fundamentals to Real Applications
  9. Python Tutorial: Build a Command-Line Expense Tracker

Recommended automatically from shared technologies, topics, intent, and difficulty.

Hand-picked companion pages that deepen this topic.

Your next steps

Continue learning

  1. 1glossaryWhat Is Python in Programming?
  2. 2guidesLearn Python: From Fundamentals to Real Applications
  3. 3guidesPython Tutorial: Build a Command-Line Expense Tracker
  4. 4cheatsheetsPython Cheatsheet: Syntax, Collections, Files, and OOP