Python Tutorial: Namedtuple – When and why should you use namedtuples?

///Python Tutorial: Namedtuple – When and why should you use namedtuples?

Python Tutorial: Namedtuple – When and why should you use namedtuples?

FavoriteLoadingAdd to favorites

Named Tuples in Python are High-performance container datatypes. What advantage do namedtuples have over regular tuples and when should you use them? In this video, we’ll take a look at namedtuples and why you should use them.

The code from this video can be found at:

If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:

Or a one-time contribution through PayPal:

If you would like to see additional ways in which you can support the channel, you can check out my support page:

You can find me on:
My website –
Facebook –
Twitter –
Google Plus –
Tumblr –

By |2017-06-17T02:24:07+00:00June 17th, 2017|Python Video Tutorials|7 Comments


  1. Nishith Singhai June 17, 2017 at 2:34 am - Reply

    can u share when and why to use defaultdict. Thank you

  2. imxron June 17, 2017 at 2:43 am - Reply

    Why would we want to use a NamedTuple over just a color class? Because it’s immutable? Thanks for the great video!

  3. lkju tgcyktykc June 17, 2017 at 2:46 am - Reply

    Great tutorial.

  4. Tam Tran June 17, 2017 at 3:01 am - Reply

    You instruction is fine, but using color is very confusing. If you have used something else like Employee will make more sense.
    Employee = namedtuple("Employee", ["id", "title", "salary"])
    Empl_1 = Employee(‘A12345’, ‘Engineer’, 100000)
    Empl_2 = Employee(‘A54321’, ‘Manager’, 120000)

    print ( #output will be A12345
    print ( #output will be A54321

    print (Empl_1.title) #output will be Engineer
    print (Empl_2.title) #output will be Manager

    print (Empl_1.salary) #output will be 100000
    print (Empl_2.salary) #output will be 120000

    This example will make more sense than the color that you used, it lost me at white color that you defined when I first watch it.

  5. Prateek Anand June 17, 2017 at 3:04 am - Reply

    Seems like an enum of C!

  6. Mark ass trick June 17, 2017 at 3:06 am - Reply

    never even heard of these, but they look pretty cool. thanks!

  7. Jani Huttunen June 17, 2017 at 3:13 am - Reply

    I am liking all your Python videos. Well done and I am not exaggerating. (takes his hat off and applause)

Leave A Comment