Nota: A tradução desta entrada está atualmente em revisão de qualidade, portanto parte do conteúdo é exibida temporariamente apenas em inglês.
Este verbete ainda não foi traduzido para o seu idioma, portanto o original é exibido abaixo.
tuple
This term is primarily used in technical registers, specifically within mathematics, computer science, and database management. It describes a fixed-size collection of elements where the order of the items is significant. In programming, it often contrasts with a list or an array by being immutable, meaning its contents cannot be changed after creation.
In the context of relational databases, a tuple is the formal term for a row or record. While a table is a set of tuples, each individual tuple represents a single entity or instance of the data structure defined by the table's schema.
Meanings
Examples
You can use a tuple to store a fixed set of values that should not change.
Wait, did you define this as a list or a tuple?
The API returns a 3-tuple consisting of a status code, a message, and a timestamp.
I need to unpack this tuple into three separate variables.
A tuple is immutable, meaning you cannot add or remove elements after it is created.
The database query returns each record as a tuple of strings.
Let's represent the player position as a 2-tuple of x and y coordinates.
I wonder if using a named tuple would make the code more readable.