Open this example in the interactive library
Source code
from collections import namedtuple
Point = namedtuple('Point', 'x y')
p = Point(3, 4)
print(p.x, p.y)Sample output
3 4

Use namedtuple fields. A self-contained example using the Python standard library.
Open this example in the interactive library
from collections import namedtuple
Point = namedtuple('Point', 'x y')
p = Point(3, 4)
print(p.x, p.y)3 4