If you want to know distance between two objects use this syntax:
(object1 distance object2)
It gives distance in meters.
You can also compare x, y or z co-ordinates with select command:
x = getpos object select 0
y = getpos object select 1
z = getpos object select 2
So position array is [x,y,z]