Going by the question in your title this is my answer.
To get the distance between two objects use this formula.
Then the python code is as follow. Comments are included in the code to help you understand what is going on.
from math import sqrt
lst =  # create list to store the location info
for obj in bpy.context.selected_objects: # iterate over the selection NOTE: two object should be selected
lst.append(obj.location) # populate the lst with the location info
# calulate the distance of the two objects
distance = sqrt((lst - lst)**2 + (lst - lst)**2 + (lst - lst)**2)
# display the distance