Module thunderlab.consoleinput
User input from console.
read()
: read a single value from console.select()
: select a menue option.save_inputs()
: write all inputs fromread()
andselect()
into a file.clear_inputs()
: clear list all inputs recorded fromread()
andselect()
.recorded_inputs
: list of strings with all inputs received byread()
andselect()
.
Global variables
var recorded_inputs
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
ofsingle character strings
- The characters by which the menue options are selected.
descriptions
:list
ofstrings
- A description for each menue option.
Returns
s
:string
- the selected value (one of the characters in options).
def save_inputs(file)
def clear_inputs()
def main()