ID EN
Collections

_fields

Python 3.11

Tuple of strings listing the field names. Useful for introspection and for creating new named tuple types from existing named tuples.

Syntax

PYTHON
somenamedtuple._fields

Examples

Example 1
PYTHON
>>> p._fields             view the field names
('x', 'y')

>>> Color = namedtuple('Color', 'red green blue')
>>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)
>>> Pixel(11, 22, 128, 255, 0)
Pixel(x=11, y=22, red=128, green=255, blue=0)