A note on Python Collections.NamedTuple()

Srikanth Potukuchi
Python in Plain English
2 min readNov 16, 2022

--

Why does this exist?

It makes you write more pythonic code. When you use a regular tuple, we need to use indices to fetch tuple values which can be error-prone especially when you have multiple values in a tuple. Named tuple solves the issue by giving us the ability to name the values and make our code more readable. Also, note that they have similar memory consumption to regular tuples.

--

--

I am working as a Lead Data Scientist in Canada. Passionate about data science since 2014. I started with SQL , R and SAS; later picked up Python.