Runtime Data Attributes
type.__type_params__
Declared generic class type parameters in declaration order, or empty for an ordinary nongeneric class. Added in Python 3.12.
Formal Syntax & Structure
python syntaxpython
Cls.__type_params__Return Value
tuple
Type parameter tuple for an ordinary Python-defined class; do not assume every extension or built-in type exposes it.
Working Example
Example Snippetpython
class Box[T]: passprint(tuple(t.__name__ for t in Box.__type_params__))