typing
Type-hint building blocks: Any, Optional, Union, Callable, TypeVar, Protocol, TypedDict, Literal, Final and more.
Intermediate
from typing import Literal, Protocol, TypedDict
Mode = Literal["r", "w"]
class Readable(Protocol):
def read(self) -> float: ...
class Row(TypedDict):
name: str; ohms: int
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.