Dev HelpersOpen library
← Back

Describe a typed dictionary

Describe a typed dictionary. A self-contained example using the Python standard library.

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}