def choose_key(somemap, default=0, prompt="choose", input=raw_input, error=default_error):
    """Select a key from a mapping.
    Returns the key selected.
    """
    keytype = type(print_menu_map(somemap))
    while 1:
        try:
            userinput = get_input(prompt, default, input)
        except EOFError:
            return default
        if not userinput:
            return default
        try:
            idx = keytype(userinput)
        except __HOLE__:
            error("Not a valid entry. Please try again.")
            continue
        if idx not in somemap:
            error("Not a valid selection. Please try again.")
            continue
        return idx
dataset/ETHPy150Open kdart/pycopia/core/pycopia/cliutils.py/choose_key