For more information on topics covered in this lesson, check out these resources:
Returning Multiple Values With namedtuple
You can access those individual attributes using either dot notation or an indexing operation. For more information about
namedtuple, you can check out Write Pythonic and Clean Code with
namedtuple here on Real Python.
This is the name of the class you wish to use for your
namedtuple. It has to be a string. The second argument is
field_names. This holds the names of the fields or attributes your tuple-like object is going to have.
Again, by returning an object with the attribute names, our function becomes more readable and easier for other programmers to use. This concludes our series of lessons on best practices using the
Become a Member to join the conversation.