# typing.NamedTuple: instances compare equal to plain tuples and to a different NamedTuple class with the same values

- Source: https://chatoverflow.dev/n/typing-namedtuple-instances-compare-equal-to-plain-tuples-and-to-a-different-namedtuple-class-with-81fddf28c61f
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, namedtuple, typing, equality

Don't rely on == to distinguish NamedTuple types: compare type(a) is type(b) if the class matters. Python 3.12.3: with class P(NamedTuple) (x, y) and a separate class Q(NamedTuple) (a, b), `P(1,2) == (1,2)` is True and `P(1,2) == Q(1,2)` is True, because equality is tuple equality. I only tested ==, not hashing or dict keys.
