Named tuple
A named tuple is a tuple-like record whose fields are accessible by descriptive names as well as positional indexes.
Python How-To
A named tuple is an immutable tuple-like data structure whose elements can be accessed by descriptive field names as well as by position.
- How it is used
- Uses named tuples as lightweight, mostly read-only models for structured application data.
- How deep it goes
- Explains creation, field access, parsing, alternatives, and immutability, with challenges on updates and serialization.
- Examples
- Builds task records from delimited strings and proposes grouping latitude and longitude as one return value.
- What you can do after
- Apply it via Python’s collections.namedtuple to create and access lightweight records.
Tiny Python Projects: Learn coding and testing with puzzles and games
A typed named tuple is an immutable tuple-like record whose fields have names and declared types.
- How it is used
- Models explicit, carefully controlled program state in an interactive Tic-Tac-Toe game.
- How deep it goes
- Defines construction, indexing, named access, immutability, typed fields, defaults, and _replace(), but not implementation internals.
- Examples
- Uses cell-and-player records, a full Tic-Tac-Toe state, default initialization, invalid fields, and immutable turn updates.
- What you can do after
- Apply typed named tuples to represent state, update them with _replace(), and check type misuse with mypy.
.NET in Action, Second Edition
A named tuple is a C# tuple whose elements have programmer-defined names in addition to positional access.
- How it is used
- Carries font names alongside FiggleFont objects for filtering and sorting an HTTP response.
- How deep it goes
- Defines named and unnamed tuple elements and shows a typed LINQ projection, without exploring tuple internals.
- Examples
- Uses an AllFonts collection pairing reflected property names with FiggleFont objects.
- What you can do after
- Apply it via C# named tuples to carry related values through a LINQ query without declaring a new type.
Read how .NET in Action, Second Edition explains named tuple →
Also covered in
- Deep Learning with PyTorch, Second Edition
- Julia as a Second Language
- Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi
- Python Workout: 50 ten-minute exercises
- Python Workout, Second Edition
What to know first
- tupleA tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- keyA key is an identifier or value used to locate or access an associated entry or property in a mapping or object.
- classA class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
Related concepts
- tuplekind of · A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
- data modelkind of · A data model is a structured representation that defines how data is organized, including its entities, attributes, relationships, and applicable constraints.
- stateincludes · State is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
- collectionuses · A collection is a container or abstraction that groups multiple elements for storage, access, traversal, or processing.
Questions about named tuple
What is named tuple?
A named tuple is a tuple-like record whose fields are accessible by descriptive names as well as positional indexes.
Which Manning books explain named tuple?
Python How-To, Tiny Python Projects: Learn coding and testing with puzzles and games and .NET in Action, Second Edition.
What should I know before learning named tuple?
Manning books that teach named tuple usually introduce tuple, function, key and class first.
What kinds of named tuple are there?
Kinds of named tuple include state.
What is named tuple a kind of?
Named tuple is a kind of tuple. A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
What is named tuple part of?
Named tuple is part of collections module. The collections module is a Python standard-library module providing specialized container data types and related utilities.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


