Created
October 21, 2019 12:56
-
-
Save NMZivkovic/e32c380740b48dfa196972545067eee6 to your computer and use it in GitHub Desktop.
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 TypedDict | |
class Song(TypedDict): | |
artist: str | |
title: str | |
album: str | |
year: int | |
song: Song = {'artist': 'Nikola Nezit', 'title': 'Three Suns Halo', 'album': 'Triad', 'year': 2013} | |
def getAlbum(song: Song): | |
return song['album'] | |
# Wrong types | |
getAlbum({'artist': 11, 'title': 'Three Suns Halo', 'album': 'Triad', 'year': '2013'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment