Skip to content

Instantly share code, notes, and snippets.

@diogommartins
Created October 7, 2018 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogommartins/dfcd5cde3e399a688d4679916690bb6a to your computer and use it in GitHub Desktop.
Save diogommartins/dfcd5cde3e399a688d4679916690bb6a to your computer and use it in GitHub Desktop.
from typing import NewType
Metros = NewType('Metros', float)
Pes = NewType('Pes', float)
Segundos = NewType('Segundos', float)
MetrosPorSegundo = NewType('MetrosPorSegundo', float)
def velocidade(distancia: Metros, tempo: Segundos) ->MetrosPorSegundo:
return MetrosPorSegundo(distancia / tempo)
velocidade(42, Segundos(10))
velocidade(Pes(42), Segundos(10))
velocidade(Metros(42), Segundos(10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment