def _get_closest_match(s, keys):
 threshold = 3
 minmatch = None
 mindist = (threshold + 1)
 for key in keys:
  d = _levenshtein(s, key)
  if (d < mindist):
   minmatch = key
   mindist = d
 if (mindist <= threshold):
  return minmatch
 return None

def _get_closest_match ( s , keys ) : threshold = 3 minmatch = None mindist = ( threshold + 1 ) for key in keys : d = _levenshtein ( s , key ) if ( d < mindist ) : minmatch = key mindist = d if ( mindist <= threshold ) : return minmatch return None
returns a probable match for the given key s out of the possible keys in keys .