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.
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.