October 2018
Beginner to intermediate
398 pages
11h 1m
English
The namedtuple method returns a tuple-like object that has fields accessible with named indexes as well as the integer indexes of normal tuples. This allows for code that is, to a certain extent, self-documenting and more readable. It can be especially useful in an application where there are a large number of tuples and we need to easily keep track of what each tuple represents. Furthermore, namedtuple inherits methods from tuple and it is backward-compatible with tuple.
The field names are passed to the namedtuple method as comma and/or whitespace-separated values. They can also be passed as a sequence of strings. Field names are single strings, and they can be any legal Python identifier that does not begin ...