Why does `TypeVar()` have the required argument `name`? even though we can differentiate type names with variable names

Why does TypeVar() have the required argument name? even though we can differentiate type names with variable names like below:

T1 = TypeVar()
T2 = TypeVar()
T3 = TypeVar()

Because repr(T1) should result in something that is clearly related to T1. And this is not possible in a reasonable way without giving the name to the constructor.

1 Like

You might be interested in this prior discussion of a possible new token or soft keyword to eliminate the redundant target name as the first argument to such a constructor:

Luckily there’s PEP 695 :slight_smile: