You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [1]: fromtypingimportNamedTupleIn [2]: classX(NamedTuple):
...: x: int
...: defdouble(self):
...: return2*x
...:
In [3]: X(1).double()
At the moment it throws AttributeError as there is no double method on the constructed namedtuple.
The workaround is to define methods on subclass and set __slots__ = (). But unless I'm missing something, there is no reason why methods shouldn't work as expected.