Created
October 7, 2018 01:22
-
-
Save diogommartins/dfcd5cde3e399a688d4679916690bb6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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