Generics
Generics — typing documentation https://typing.python.org/en/latest/reference/generics.html
You may have seen type hints like list[str] or dict[str, int] in Python code. These types are interesting in that they are parametrised by other types! A list[str] isn’t just a list, it’s a list of strings. Types with type parameters like this are called generic types.
You can define your own generic classes that take type parameters, similar to built-in types such as list[X]. Note that such user-defined generics are a moderately advanced feature and you can get far without ever using them.

浙公网安备 33010602011771号