def _get_index(names, key):
 if _is_int(key):
  indx = int(key)
 elif isinstance(key, string_types):
  try:
   indx = names.index(key.rstrip())
  except ValueError:
   _key = key.lower().rstrip()
   names = [n.lower().rstrip() for n in names]
   count = names.count(_key)
   if (count == 1):
    indx = names.index(_key)
   elif (count == 0):
    raise KeyError("Key '{}' does not exist.".format(key))
   else:
    raise KeyError("Ambiguous key name '{}'.".format(key))
 else:
  raise KeyError("Illegal key '{}'.".format(repr(key)))
 return indx

def _get_index ( names , key ) : if _is_int ( key ) : indx = int ( key ) elif isinstance ( key , string_types ) : try : indx = names . index ( key . rstrip ( ) ) except ValueError : _key = key . lower ( ) . rstrip ( ) names = [ n . lower ( ) . rstrip ( ) for n in names ] count = names . count ( _key ) if ( count == 1 ) : indx = names . index ( _key ) elif ( count == 0 ) : raise KeyError ( "Key '{}' does not exist." . format ( key ) ) else : raise KeyError ( "Ambiguous key name '{}'." . format ( key ) ) else : raise KeyError ( "Illegal key '{}'." . format ( repr ( key ) ) ) return indx
get the index of the key in the names list .