ID EN
Collections

namedtuple

Python 3.11

Returns a new tuple subclass named typename. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have a helpful docstring (with typename and field_names) and a helpful __repr__() method which lists the tuple contents in a name=value format.

Syntax

PYTHON
collections.namedtuple(typename, field_names, *, rename=False, defaults=None, module=None)

See Also

keyword iterable keyword-only arguments