def get_answer(message, answers='Yn', default='Y', quit=''):
    if quit and quit not in answers:
        answers = answers + quit
        
    message = message + '(' + '/'.join(answers) + ')[' + default + ']:'
    ans = raw_input(message).strip().upper()
    if default and not ans:
        ans = default.upper()
    while ans not in answers.upper():
        ans = raw_input(message).strip().upper()
    if quit and ans == quit.upper():
        print "Command be cancelled!"
        sys.exit(0)
    return ans
Get an answer from stdin, the answers should be 'Y/n' etc.
dataset/ETHPy150Open limodou/uliweb/uliweb/core/commands.py/get_answer