Example code from typing library causes TypeError: 'type' object is not subscriptable, why?

Viewed 3091

Considering to Python Docs for typing why code below isn't working?

>>> Vector = list[float]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: 'type' object is not subscriptable

In docs there is the same example as I mentioned above. here

Vector = list[float]

def scale(scalar: float, vector: Vector) -> Vector:
    return [scalar * num for num in vector]

I didn't find question about this example.

1 Answers
Related