Skip to main content

Python Tuples

Satellite · Data Types

Python Tuples

Tuples give you fixed-length, read-only sequences—perfect for coordinates, return values, and dictionary keys.

Creation

coords = (41.9, 12.5)
single = ("only",) # trailing comma required
implicit = 1, 2, 3

Tuple unpacking

x, y = coords
user_id, role, *extras = payload

Tuples vs lists

FeatureTupleList
MutabilityImmutableMutable
HashableYes (if members hashable)No
Use casesKeys, fixed records, function returnsDynamic collections

Next up in your learning path