Language Syntax

Type alias — Python syntax

Create a typing.TypeAliasType object with lazily evaluated value. The optional type parameter list declares scoped parameters. Introduced in 3.12; this alias is not itself a constructor.

Formal Syntax & Structure

python syntaxpython
type Alias = expressiontype GenericAlias[T] = expression

Working Example

Example Snippetpython
type Pair[T] = tuple[T,T]print((Pair.__name__,len(Pair.__type_params__)))
Python Reference