Example Code From Typing Library Causes Typeerror: 'type' Object Is Not Subscriptable, Why?
Considering to Python Docs for typing why code below isn't working? >>> Vector = list[float] Traceback (most recent call last): File '', line 1, in
Solution 1:
The ability to use the [] operator on types like list for type hinting was added in 3.9.
https://docs.python.org/3/whatsnew/3.9.html#type-hinting-generics-in-standard-collections
In earlier versions it will generate the error you describe, and you need to import List object from typing instead.
from typing importListList[float]
Post a Comment for "Example Code From Typing Library Causes Typeerror: 'type' Object Is Not Subscriptable, Why?"