Cheat Sheets

A collection of cheat sheets.

Hosted on GitHub Pages — Theme by mattgraham

Typing

Official documentation

Types

Any
str
int
float
Sequence[T]
MutableSequence[T]
List[T]
Tuple[T1, T2, ...]
AbstractSet[T]
MutableSet[T]
Mapping[K, V]
MutableMapping[K, V]
Callable[[P1, P2, ...], R]

NewType

from typing import NewType

Age = NewType('Age', int)

Generics

from typing import TypeVar, Generic


T = TypeVar('T')

class SomeClass(Generic[T]):
    ...