Turinys

Tuples'ai

Tuple - in a database, an ordered set of data constituting a record; a data structure consisting of comma-separated values passed to a program or operating system.

Pavyzdys

tuple = 12345, 67890, "Linas", "Valiukas"
 
print tuple # (12345, 67890, 'Linas', 'Valiukas')
 
print tuple[0] # 12345
 
dar_vienas = tuple, (1, 2, 3, 4, 5)
print dar_vienas # ((12345, 67890, 'Linas', 'Valiukas'), (1, 2, 3, 4, 5))
print dar_vienas[0][2] # Linas

Tuples, like strings, are immutable: it is not possible to assign to the individual items of a tuple (you can simulate much of the same effect with slicing and concatenation, though)

Tuple'as su vienu elementu

# Tuple'as su vienu elementu
tuple = "Linas",