module documentation

Undocumented

Function ranged_type Return function handle of an argument type function for ArgumentParser checking a range:
Function string_from_valid_list_type Return function handle that checks whether input argument matches any of the valid_values
Type Variable T Undocumented
def ranged_type(value_type, min_value=None, max_value=None, min_inclusive=True, max_inclusive=True): (source)

Return function handle of an argument type function for ArgumentParser checking a range:

    min_value <= arg <= max_value

Example:

>>> ranged_type(float, 0.0, 1.0) # Checks the range ]0, 1[
>>> ranged_type(float, 0.0, 1.0, False, False) # Checks the range [0, 1]
Parameters
value_type:typevalue-type to convert arg to
min_value:T|Noneminimum acceptable argument value, can be None
max_value:T|Nonemaximum acceptable argument value, can be none
min_inclusive:boolboolean flag for including min_value as valid value
max_inclusive:boolboolean flag for including max_value as valid value
Returns
Callable[[str], T]function handle of an argument type function for ArgumentParser
Raises
ValueErrorif both min_value and max_value is None. In this case, simply use value_type directly instead of range_type(...)
def string_from_valid_list_type(valid_values): (source)

Return function handle that checks whether input argument matches any of the valid_values

Example:

>>> string_from_valid_list_type(['some_string', 'another'])
Parameters
valid_values:Iterable[str]List of accepted string values
Returns
Callable[[str], str]function handle of an argument type function for ArgumentParser

Undocumented

Value
TypeVar('T')