Next / Previous / Contents / TCC Help System / NM Tech homepage

20.42. tuple(): Convert to a tuple

To convert some iterable S to a tuple, use this general form:

tuple(s)

The result will be a new tuple with the same elements as S in the same order. For general information, see Section 12, “Type tuple: Immutable sequences”.

To create an empty tuple, omit the argument. Examples:

>>> tuple()
()
>>> tuple ( ['swallow', 'coconut'] )
('swallow', 'coconut')
>>> tuple ( 'shrubbery' )
('s', 'h', 'r', 'u', 'b', 'b', 'e', 'r', 'y')
>>> tuple ( ['singleton'] )
('singleton',)