v Using Named Tuples To Store Data - Python

Using Named Tuples To Store Data

Interesting in learning more? Check out Fluent Python

Preliminaries

from collections import namedtuple

Create A Named Tuple

Vehicle = namedtuple('Vehicle', 'make model wheels manual')

Create An Entry

forrester = Vehicle('Forrester', 'Subaru', 4, True)

View The Data In Entry

forrester.model
'Subaru'
forrester.wheels
4