News for hackers. Stuff that matters.
Re:Why We Chose Typescript by Rotareti on Friday June 30, 2017 @09:58PM (#14674887)
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 [1] https://docs.python.org/3/library/typing.html

There are no comments on this comment yet.