Language Delimiters

-> — return annotation arrow

Introduces a function return annotation between the parameter list and the colon. It describes an intended result type but does not by itself enforce that type at runtime.

Formal Syntax & Structure

python syntaxpython
->

Return Value

Not applicable

Grammar token; the enclosing construct determines any result.

Working Example

Example Snippetpython
def double(n: int) -> int:    return n * 2print(double(4), double.__annotations__['return'].__name__)
Python Reference