Module thunderlab.consoleinput

User input from console.

Global variables

var recorded_inputs

List of strings with all inputs received by read() and select().

Functions

def read(prompt, default=None, dtype=builtins.str, min=None, max=None)

Read a single input value from the console.

Parameters

prompt : string
prompt to be displayed.
default : string
default value if only 'return' is pressed.
dtype : type
data type to be returned (str, int, float, …)
min : dtype
input needs to be larger than min.
min : dtype
input needs to be smaller than max.

Returns

x : dtype
the value of the input.
def select(prompt, default, options, descriptions)

Print a menue from which the user can select an entry.

Parameters

prompt : string
A title for the menue.
default : string
The default selection.
options : list of single character strings
The characters by which the menue options are selected.
descriptions : list of strings
A description for each menue option.

Returns

s : string
the selected value (one of the characters in options).
def save_inputs(file)

Write all inputs from read() and select() into a file.

This file can then be used to pipe these inputs to the program instead of typing them in manually.

Parameters

file : string
Name of the file where to save the inputs.
def clear_inputs()

Clear list all inputs recorded from read() and select().

def main()