import geopy.distance import math class Location: def __init__(self, name, x, y): self.name = name self.x = x self.y = y self.coords = (x, y) def distance(self, otherLocation): dist = geopy.distance.distance(self.coords, otherLocation.coords).km return dist l1 = Location("Bob's diner", 42.344250, -75.170448) l2 = Location("My own location", 51.903969, 4.484250) print('The distance between {} and {} is {:.2f} km'.format(l2.name, l1.name, l2.distance(l1)))