Tuple Reference
Immutable sequences for packing fixed records.
Count occurrences of a value inside the tuple.
Used In: Record metrics counters.
tuple.count(x)(1, 2, 1, 1).count(1)3Time Complexity: O(N)
Return index of the first occurrence of a value in the tuple.
Used In: Locating column offsets inside fixed schema tuples.
tuple.index(x)(10, 20, 30).index(20)1Time Complexity: O(N)
Pack multiple independent values into a single tuple object.
Used In: Returning multi-attribute structures from data parsers.
t = x, y, zrecord = 1, 'Alex', 'DE'
print(record)(1, 'Alex', 'DE')Time Complexity: O(1)
Related Methods: Tuple Unpacking
Assign individual elements of a tuple to separate variables.
Used In: Deconstructing database rows, reading zip objects.
x, y = tt = (1, 'DE')
id, dept = t
print(id, dept)1 DETime Complexity: O(1)
Related Methods: Tuple Packing
Define and assign values to multiple variables in a single line.
Used In: Boundary swaps in algorithms, bulk initializer settings.
x, y = val1, val2left, right = 0, 10
left, right = right, left
print(left, right)10 0Time Complexity: O(1)
Store tuples inside another tuple to represent immutable nested records.
Used In: Immutable matrices, coordinate lists.
t = ((x, y), (a, b))coord = ((10, 20), (30, 40))
print(coord[0][1])20Time Complexity: O(1)