Generic Types
suggest changeThe typing.TypeVar
is a generic type factory. It’s primary goal is to serve as a parameter/placeholder for generic function/class/method annotations:
import typing
T = typing.TypeVar("T")
def get_first_element(l: typing.Sequence[T]) -> T:
return l[0]
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents