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

Home/Programming Video Tutorials/Python Video Tutorials/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:
https://github.com/CoreyMSchafer/code_snippets/tree/master/NamedTuples

If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms

Or a one-time contribution through PayPal:
https://goo.gl/649HFY

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

Support

You can find me on:
My website – http://coreyms.com/
Facebook – https://www.facebook.com/CoreyMSchafer
Twitter – https://twitter.com/CoreyMSchafer
Google Plus – https://plus.google.com/+CoreySchafer44/posts
Tumblr – https://www.tumblr.com/blog/mycms

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

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 (Empl_1.id) #output will be A12345
    print (Empl_2.id) #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

*