Skip to content

Instantly share code, notes, and snippets.

@jaycosaur
Created August 9, 2020 11:47
Show Gist options
  • Save jaycosaur/258bf96c6d4f1e228fc8c3cc0edab352 to your computer and use it in GitHub Desktop.
Save jaycosaur/258bf96c6d4f1e228fc8c3cc0edab352 to your computer and use it in GitHub Desktop.
Intersection types [python] - Typescript to Python field guide
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