A named tuple does not require a key and is not required to be hashable. Named tuples are ordered, unlike a dict. You can also use dot notation instead of [' '] which is a bit easier to type and has some readability improvements.
Thanks! I use python for data analysis but rarely use things like namedtuple and dictionary. By ordered I suppose you mean that if I want to, I can iterate through a namedtuple but not a dictionary?
A named tuple does not require a key and is not required to be hashable. Named tuples are ordered, unlike a dict. You can also use dot notation instead of [' '] which is a bit easier to type and has some readability improvements.
Thanks! I use python for data analysis but rarely use things like namedtuple and dictionary. By ordered I suppose you mean that if I want to, I can iterate through a namedtuple but not a dictionary?
When you use a dict, there is no guarantee you will get the keys in the order you created them. Access is typically by key so that's not important.
WIth named tuple, you know the first element, will always be returned first.
Cool! Thanks for the tips!