distance functions in python