def confirm(message=None, default=False, log=None):
    """prompts for yes or no response from the user. Returns True for yes and
    False for no.
    'default' should be set to the default value assumed by the caller when
    user simply types ENTER, and is marked in the prompt with square brackets.
    """
    if message is None:
        message = 'Confirm?'

    if default:
        message = '%s [y]|n: ' % (message)  # default answer = yes
    else:
        message = '%s y|[n]: ' % (message)  # default answer = no

    while True:
        answer = input(message)
        if log:
            log.info(">>>{}: [{}]".format(message, answer))
        if not answer:
            return default
        if answer not in ['y', 'Y', 'n', 'N']:
            print('Please enter y or n!')
            continue
        if answer == 'y' or answer == 'Y':
            return True
        if answer == 'n' or answer == 'N':
            return False