AI engineering glossary · Python advanced

What is namedtuple?

namedtuple: A factory in the collections module that creates tuple subclasses whose fields can be read by name as well as by position. They are lightweight, immutable records that make code more readable.

Level: intermediateTopic: Python advanced

namedtuple: an example

Point = namedtuple('Point', 'x y'); p = Point(3, 4); p.x returns 3.

Related terms

More Python advanced terms

Where you learn it

namedtuple is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.