def _key_to_index(keys, key, single_only=False):
if isinstance(key, int): <EOL><INDENT>try:<EOL><INDENT>keys[key]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise KeyError('<STR_LIT>' % (key,))<EOL><DEDENT>if key < <NUM_LIT:0>:<EOL><INDENT>key += len(keys) <EOL><DEDENT>return key<EOL>
convert ``key`` of various types to int or list of int