console

Text console UI helpers and patterns, e.g. ‘Y/n’ prompts and the like.

invocations.console.confirm(question, assume_yes=True)

Ask user a yes/no question and return their response as a boolean.

question should be a simple, grammatically complete question such as “Do you wish to continue?”, and will have a string similar to " [Y/n] " appended automatically. This function will not append a question mark for you.

By default, when the user presses Enter without typing anything, “yes” is assumed. This can be changed by specifying assume_yes=False.

Note

If the user does not supplies input that is (case-insensitively) equal to “y”, “yes”, “n” or “no”, they will be re-prompted until they do.

Parameters:
  • question (str) – The question part of the prompt.
  • assume_yes (bool) – Whether to assume the affirmative answer by default. Default value: True.
Returns:

A bool.