2 ms·
This is how i understood it (from https://www.python.org/dev/peps/pep-0563/ https://www.python.org/dev/peps/pep-0563/). Correct me if im wrong please. One of t
by BozeWolf 6y ago
This is how i understood it (from https://www.python.org/dev/peps/pep-0563/ https://www.python.org/dev/peps/pep-0563/). Correct me if im wrong please.
One of the reasons was that `list[int]` could not be done, as that would refer to a list index. Same as you would do
`my_var = [1,2,3]`
`my_var[0]`
Therefore it was possible to use just `int` as a type.
From python 3.9 (unless you used from __future__ import annotations in 3.7+) type hints are not parsed "as python", at function definition time, but more or less as text.
In 3.9 `list[int]` does not want an item from object `list` at index 'int' when using it as a type annotation.
The typing library did not have these issues because the `types` altered the way the objects worked. Probably (didnt check it!) by overriding __getitem__ and the likes.