Created
August 9, 2020 11:47
-
-
Save jaycosaur/258bf96c6d4f1e228fc8c3cc0edab352 to your computer and use it in GitHub Desktop.
Intersection types [python] - Typescript to Python field guide
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
from dataclasses import dataclass | |
@dataclass | |
class HasAge: | |
age: int | |
@dataclass | |
class HasName: | |
name: str | |
class HasNameAndAge(HasName, HasAge): | |
def __init__(self, name: str, age: int): | |
HasName.__init__(self, name) | |
HasAge.__init__(self, age) | |
correct = HasNameAndAge("Tim", 23) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment