Last active
November 27, 2021 18:52
-
-
Save Goldziher/2d4d870b9fd3f3e7c499fdf303d8a1a9 to your computer and use it in GitHub Desktop.
python duck typing example
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 Any | |
def is_duck(value: Any) -> bool: | |
try: | |
value.quack() | |
return True | |
except (Attribute, ValueError): | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment