If you’re trying to get the actual names, use the _fields attribute:
from collections import namedtuple
Point = namedtuple('Point', 'x, y')
p = Point(x=1, y=2)
for name in Point._fields:
print(name, getattr(p, name))
If you’re trying to get the actual names, use the _fields attribute:
from collections import namedtuple
Point = namedtuple('Point', 'x, y')
p = Point(x=1, y=2)
for name in Point._fields:
print(name, getattr(p, name))