iblrig.tools.get_number
- iblrig.tools.get_number(prompt='Enter number: ', numeric_type=<class 'int'>, validation=<function <lambda>>)[source]
Prompt the user for a number input of a specified numeric type and validate it.
- Parameters:
prompt (
str
, optional) – The message displayed to the user when asking for input. Defaults to ‘Enter number: ‘.numeric_type (
type
, optional) – The type of the number to be returned. Can be either int or float. Defaults to int.validation (
callable
, optional) – A function that takes a number as input and returns a boolean indicating whether the number is valid. Defaults to a function that always returns True.
- Returns:
The validated number input by the user, converted to the specified type.
- Return type:
- Parameters:
Notes
The function will continue to prompt the user until a valid number is entered that passes the validation function.