Skip to content

Instantly share code, notes, and snippets.

@iisaka51
Created October 25, 2022 04:34
Show Gist options
  • Save iisaka51/a2c8bf60269218e8db00046c0d4d7bd6 to your computer and use it in GitHub Desktop.
Save iisaka51/a2c8bf60269218e8db00046c0d4d7bd6 to your computer and use it in GitHub Desktop.
example of inheritance of NamedTuple
In [20]: from typing import NamedTuple
...:
...: class UserBase(NamedTuple):
...: id: int
...: name: str
...: age: int
...: belongs: str
...:
...: class User(UserBase):
...: def __new__(cls, profile):
...: return super().__new__(cls, **dict(profile))
...:
In [21]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment