Title: Using Named Tuples To Store Data
Slug: using_named_tuples_to_store_data
Summary: Using Named Tuples To Store Data in Python.
Date: 2016-01-23 12:00
Category: Python
Tags: Basics
Authors: Chris Albon

Interesting in learning more? Check out Fluent Python

Preliminaries


In [1]:
from collections import namedtuple

Create A Named Tuple


In [2]:
Vehicle = namedtuple('Vehicle', 'make model wheels manual')

Create An Entry


In [3]:
forrester = Vehicle('Forrester', 'Subaru', 4, True)

View The Data In Entry


In [4]:
forrester.model


Out[4]:
'Subaru'

In [5]:
forrester.wheels


Out[5]:
4