When using the typing
module to write type hints, I'm not sure when and when not I am supposed to use TypeVar
instances.
For example, what's the practical "difference" between
str_or_int = typing.TypeVar('str_or_int', str, int)
and
str_or_int = typing.Union[str, int]
used in a hint like this?
def foo(bar: str_or_int):
pass