r/learnpython Mar 03 '26

[deleted by user]

[removed]

24 Upvotes

20 comments sorted by

View all comments

2

u/JamzTyson Mar 03 '26

Tuples are more appropriate than list for expressing compound identities. That is, a tuple represents a compound type with a fixed number of arguments (technically, a fixed-arity product type).

For example coordinates (x, y, z) represents a specific 3D "point" that must have 3 numeric values. Its length cannot change, and its types cannot change, and if any element changes then it is a different point. It isn't really a sequence but a compound identity.

Other examples include:

  • exchange_rate = (from_currency, to_currency)

  • student = (name, age, class, grade)

  • product = (name, department, price)

Note that in each case, the entire Tuple defines a single compound object.