Created
August 9, 2020 13:40
-
-
Save jaycosaur/47c6c59a5168f0b5874de8f169bff3d0 to your computer and use it in GitHub Desktop.
Hybrid [python-protocol] - Typescript to Python field guide
This file contains hidden or 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 typing import Protocol | |
class Dog(Protocol): | |
type: str | |
def __call__(self, food: str) -> None: | |
pass | |
class Poodle: | |
type = "Poodle" | |
def __call__(self, food: str) -> None: | |
print(f"Eating {food}.") | |
poodle: Dog = Poodle() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment