While playing with Python's typing
module I came across something curious:
>>> from typing import List, Tuple
>>> List[Tuple[int]]
typing.List<~T>[typing.Tuple[int]]
What's this Java-like syntax List<~T>
? What does it mean?
Let's see:
typing.List<~T>[typing.Tuple[int]]
typing.List
means a type from the typing
library, named List
<~T>
means this type is generic, it's defined in terms of another type T[typing.Tuple[int]]
means type T is the type Tuple[int]
.In natural language, you can read the definition like this:
typing.List<~T>[typing.Tuple[int]]
: a standard List of one-int tuples