3 ms·
I'm very satisfied with the new typing [0][1] module. It's part of the standard library since Python 3.5 and it provides type annotations similar to those of Ty
by Rotareti 9y ago
I'm very satisfied with the new typing [0][1] module. It's part of the standard library since Python 3.5 and it provides type annotations similar to those of Typescript. It's still missing some features (IMO), but it's also under active development, so I guess more useful features will come.
from typing import List
Vector = List[float]
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]
def greeting(name: str) -> str:
return 'Hello ' + name
[0] https://github.com/python/typing https://github.com/python/typing
[1] https://docs.python.org/3/library/typing.html https://docs.python.org/3/library/typing.html