R. David Murray added the comment:
This is by design: namedtuples are tuples in which you can access the elements
by name. If you have a tuple with the same elements, but no name access, they
should compare equal, because they are fundamentally tuples. The names are
just a convenience.
Vlad Shcherbina added the comment:
While we are at it, namedtuple inherits other operations that make no sense for
fixed-length tuples:
>>> Rectangle(width=1, height=2) * 3
(1, 2, 1, 2, 1, 2)
>>> Rectangle(width=1, height=2) + Ellipse(x_axis=3, y_axis=4)
(1, 2, 3, 4)
But those are not so
New submission from Vlad Shcherbina:
Toy example:
>>> from collections import namedtuple
>>> Rectangle = namedtuple('Rectangle', 'width height')
>>> Ellipse = namedtuple('Ellipse', 'x_axis y_axis')
>>> Rectangle(width=1, height=2) == Ellipse(x_axis=1, y_axis=2)
True
I understand this happens