📝 Edit page
➕ Add page
Named tuple
Create tuples with named fields
Immutable, like a tuple.
See namedtuple in the docs.
factory function for creating tuple subclasses with named fields
Example
from collections import namedtuple
# Define a type.
Point = namedtuple('Point', ['x', 'y'])
# Instantiate using the type.
p = Point(11, y=22)
p
# => Point(x=11, y=22)
Access attributes with class-like attribute syntax.
p.x
# => 111