def ask(question, default=None):
    """
    Asks the user the question until he answers it with *yes* or *no*.

    Returns true if the user answered with yes.
    Returns *default* if the user only hit enter.
    """
    if default is None:
        prompt = question + " (yes|no) "
    elif default:
        prompt = question + " (YES|no) "
    else:
        prompt = question + " (yes|NO) "

    while True:
        temp = input(prompt)
        temp = temp.strip()
        temp = temp.upper()
        if default is not None and not temp:
            return default
        elif temp in ("Y", "YES"):
            return True
        elif temp in ("N", "NO"):
            return False