bag.console module

Functions for user interaction at the terminal/console.

bag.console.announce(*a)[source]

Make this message stand out from all the noise in the console.

Return type

None

bag.console.ask(prompt='', default='')[source]

Print the prompt, get user’s answer, return it – or a default.

Return type

str

bag.console.bool_input(prompt, default=None)[source]

Print prompt; return True or False based on the user’s choice.

Return type

bool

bag.console.int_input(prompt)[source]

Print prompt; ensure the user enters an integer and return it.

Return type

Optional[int]

bag.console.pick_one_of(options, prompt='Pick one: ', to_str=None)[source]

Let the user choose an item (from a sequence of options) by number.

to_str() is a callback that must take an item as argument and must return a corresponding string to be displayed.

Return type

Any

bag.console.screen_header(text, decor='=', max=79)[source]

Return a header to be displayed on screen, by decorating text.

Return type

str