PYTHON PROGRAMMING
Tuples are a robust Python type — but named tuples much more so!

The three hottest Python data types are the list, the dictionary, and the tuple. Lists and dictionaries are mutable, meaning that their elements could be altered after creation. Tuples, then again, are immutable, so that they can’t be modified after creation. In the event you do need to switch the contents of a tuple, it’s essential to create a brand new instance with the specified changes and assign it to the identical variable.
This text focuses on Python named tuples, a specialized kind of tuple that mixes the facility of normal tuples with the added flexibility of named fields. In comparison with regular tuples, named tuples could make code simpler, more readable and more maintainable — and much more Pythonic. Nonetheless, it’s essential to watch out, as sometimes using named tuples excessively can inadvertently reduce code readability somewhat than enhance it.
Read on to learn more!
To know named tuples, you’ve to first understand regular Python tuples. In the event you’re not aware of them, I strongly advise you to first read the next two articles about this data type:
What’s incredible about named tuples is that they function like regular tuples: the whole lot that works for a daily tuple will work for a named tuple. But that’s not all, as named tuples offer additional features — hence the moniker “tuple+”. Due to this fact, I’ll assume you’re aware of the important thing concepts covered in these two articles above, and we’ll give attention to some great benefits of named tuples.
At the start, take into accout that each one tuples are immutable. You could find it easy to forget this important characteristic if you start…