Last active
March 17, 2021 21:58
-
-
Save MartinThoma/dc8ed53b8f48a708764371621eb27ab0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Old style, before Python 3.7 | |
from collections import namedtuple | |
attribute_names = ["longitude", "latitude", "address"] | |
Position = namedtuple("Position", attribute_names, defaults=(None,)) | |
# Python 3.7 and later: | |
from typing import NamedTuple | |
class Position(NamedTuple): | |
longitude: int | |
latitude: int | |
address: int | |
# Both are used in the same way | |
pos1 = Position(49.0127913, 8.4231381, "Parkstraße 17") | |
pos2 = Position(42.1238762, 9.1649964) | |
def get_distance(p1: Position, p2: Position) -> float: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment