Created
October 25, 2022 04:34
-
-
Save iisaka51/a2c8bf60269218e8db00046c0d4d7bd6 to your computer and use it in GitHub Desktop.
example of inheritance of NamedTuple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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