When reading fmark answer the question What is "named tuples" in Python? I saw that the example here has the same name and link, that is, the word Point appears twice in the following expression:
Point = namedtuple('Point', 'x y')
So, I went to the original link:
https://docs.python.org/2/library/collections.html#collections.namedtuple
And here I also 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 example, the entire line (for the Point example) can be replaced by the following:
namedtuple('Point', 'x y')
OR
Point = namedtuple('x y')
Of course, it is assumed that a named tuple must have the same name and reference. Therefore, my question is: when is it appropriate (if at all permitted) that a named tuple should have a different name and link? I have yet to meet an example.
source share