Modules in Python: namedtuple
Let's discover namedtuple and its functions.
We'll cover the following...
Overview of namedtuple
Let’s discuss the namedtuple
class from the collection module which we can use to replace Python’s tuple.
Of course, the namedtuple
is not a drop-in replacement as we will see soon.
We have
seen some programmers use it like a struct. If we haven’t used a language with a struct in it, then that needs a little explanation.
A
struct is basically a complex data type that groups a list of variables
under one name.
Creating
...Access this course and 1400+ top-rated courses and projects.