While reading fmark
's answer to the question What are "named tuples" in Python? I saw that the example given there had the same name and reference, i.e. the word Point
appears twice in the following statement:
Point = namedtuple('Point', 'x y')
So I went to the original reference:
https://docs.python.org/2/library/collections.html#collections.namedtuple
And here too I found two more examples:
EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade')
Color = namedtuple('Color', 'red green blue')
Ideally words are not repeated in Python. For instance the whole line (for the the Point
example) could be replaced by the following:
namedtuple('Point', 'x y')
OR
Point = namedtuple('x y')
Of course, that's assuming that the named tuple has to have the same name and reference. So my question is: when is it advisable (if at all it is permitted) that a named tuple should have a different name and reference? I am yet to come across an example.