(msg, default="y", help_msg=None)
return (response == "y")
Yes or no question

    Args:
        msg      : the message or question to ask the user
        default  : default response
        help_msg : Optional help message

    Returns:
        True if answer is yes, False otherwise.
Yes or no question
Yes or no question
def ask_yes_or_no(msg, default="y", help_msg=None):
    """Yes or no question

    Args:
        msg      : the message or question to ask the user
        default  : default response
        help_msg : Optional help message

    Returns:
        True if answer is yes, False otherwise.

    """
    response = None

    if (default == "y"):
        options = "[Y/n]"
    else:
        options = "[N/y]"

    while response not in {"y", "n"}:
        if (help_msg is None):
            question = msg + " " + options + " "
            raw_resp = _input(question) or default
        else:
            print(textwrap.fill(msg))
            print()
            print(textwrap.fill(help_msg))
            print()
            raw_resp = _input("Answer " + options + " ") or default

        response = raw_resp.lower()

        if (response not in ["y", "n"]):
            print("Please enter \"y\" or \"n\"")

    return (response == "y")
def ask_yes_or_no ( msg , default = "y" , help_msg = None ) : response = None if ( default == "y" ) : options = "[Y/n]" else : options = "[N/y]" while response not in { "y" , "n" } : if ( help_msg is None ) : question = msg + " " + options + " " raw_resp = _input ( question ) or default else : print ( textwrap . fill ( msg ) ) print ( ) print ( textwrap . fill ( help_msg ) ) print ( ) raw_resp = _input ( "Answer " + options + " " ) or default response = raw_resp . lower ( ) if ( response not in [ "y" , "n" ] ) : print ( "Please enter \"y\" or \"n\"" ) return ( response == "y" )