named tuple

In Python, a named tuple is a variation of the built-in tuple data type that allows you to create tuple-like objects with items that have descriptive names. You can access each item by its name using dot notation.

Named tuples are part of the collections module and are especially useful when you want to write more readable and self-documenting code.

Named tuples are immutable, just like regular tuples, which means that once you create a named tuple, you can’t change its values.

Example

Here’s a quick example of how to use named tuples in Python:

Python
>>> from collections import namedtuple
>>> Point = namedtuple("Point", ["x", "y"])
>>> point = Point(11, 22)
>>> point.x
11
>>> point.y
22

In this example, Point is a named tuple with two fields, .x and .y. You can create an instance of Point by providing values for these fields. Then, you can access those items using dot notation, which makes the code more readable.

Tutorial

Write Pythonic and Clean Code With namedtuple

Discover how Python's namedtuple lets you create simple, readable data structures with named fields you can access using dot notation.

intermediate data-structures python

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Sept. 25, 2025