Definition
The term “named tuple” applies to any type or class that inherits from tuple and whose indexable elements are also accessible using named attributes. The type or class may have other features as well.
Several built-in types are named tuples, including the values returned
by time.localtime() and os.stat(). Another example is
sys.float_info:
>>> sys.float_info[1] # indexed access
1024
>>> sys.float_info.max_exp # named field access
1024
>>> isinstance(sys.float_info, tuple) # kind of tuple
True
Some named tuples are built-in types (such as the above examples).
Alternatively, a named tuple can be created from a regular class
definition that inherits from tuple and that defines named
fields. Such a class can be written by hand or it can be created with
the factory function collections.namedtuple(). The latter
technique also adds some extra methods that may not be found in
hand-written or built-in named tuples.