Runtime Data Attributes

function.__type_params__

Type parameter objects declared using generic function syntax, in declaration order; empty for a nongeneric function. Added in 3.12.

Formal Syntax & Structure

python syntaxpython
f.__type_params__

Return Value

tuple

Value exposed by this attribute; availability and mutability depend on the owner as described.

Working Example

Example Snippetpython
def f[T](x: T) -> T: return xprint(tuple(t.__name__ for t in f.__type_params__))
Python Reference