def prompt_for_var(prompt_str, default=None, allow_empty=False, choices=None):
    prompt = prompt_str
    if default is not None:
        prompt += ' [' + default + ']: '
    else:
        prompt += ': '
    while True:
        try:
            value = input(prompt)
        except __HOLE__:
            print('')
            exit(1)
        except EOFError:
            print('')
            exit(1)
        if value != '':
            if choices is not None and value not in choices:
                print('Error: unrecognized response, expected one of ' + json.dumps(choices))
            else:
                return value
        elif default is not None:
            return default
        elif allow_empty:
            return value
dataset/ETHPy150Open dnanexus/dx-toolkit/src/python/dxpy/templating/utils.py/prompt_for_var