Open this example in the interactive library
Source code
from typing import TypedDict
class User(TypedDict):
name: str
active: bool
user: User = {'name':'Ada','active':True}
print(user)Sample output
{'name': 'Ada', 'active': True}
Describe a typed dictionary. A self-contained example using the Python standard library.
Open this example in the interactive library
from typing import TypedDict
class User(TypedDict):
name: str
active: bool
user: User = {'name':'Ada','active':True}
print(user){'name': 'Ada', 'active': True}