ID EN
Built-in Types

T[X, Y, ...]

Python 3.11

Creates a GenericAlias representing a type T parameterized by types X, Y, and more depending on the T used. For example, a function expecting a list containing float elements:

Syntax

PYTHON
T[X, Y, ...]

Examples

Example 1
PYTHON
def average(values: list[float]) -> float:
    return sum(values) / len(values)
Example 2
PYTHON
def send_post_request(url: str, body: dict[str, int]) -> None:
    ...

See Also

list float mapping dict str int