def ensure_distance(dist):
 try:
  km = dist.km
 except AttributeError:
  raise SpatialError((u"'%s' does not appear to be a 'Distance' object." % dist))
 return dist

def ensure_distance ( dist ) : try : km = dist . km except AttributeError : raise SpatialError ( ( u"'%s' does not appear to be a 'Distance' object." % dist ) ) return dist
makes sure the parameter passed in is a distance object .