Module tuples
source code
Python uses parentheses to enclose tuples.
>>> X = (24, 3.14, 'w', 7)
>>> Y = (100,)
>>> Z = ()
The following is not a tuple:
>>> Q = (7)
>>> Q == 7
True
>>> L = tuple('hi!')
>>> L
('h', 'i', '!')
>>> M = tuple()
>>> M
()
>>> X(0)
24
>>> X(1)
3.1400000000000001
>>> X(-1)
7
>>> X(0:2)
(24, 3.1400000000000001)
>>> X(:-1)
The following raises an IndexError
>>> X[4]
...
IndexError: tuple index out of range
Concatenation of tuples:
>>> X + Y
(24, 3.1400000000000001, 'w', 7, 100)