module documentation
Undocumented
Function | ranged |
Return function handle of an argument type function for ArgumentParser checking a range: |
Function | string |
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 | |
valuetype | value-type to convert arg to |
minT|None | minimum acceptable argument value, can be None |
maxT|None | maximum acceptable argument value, can be none |
minbool | boolean flag for including min_value as valid value |
maxbool | boolean flag for including max_value as valid value |
Returns | |
Callable[ | function handle of an argument type function for ArgumentParser |
Raises | |
ValueError | if both min_value and max_value is None. In this case, simply use value_type directly instead of range_type(...) |
Return function handle that checks whether input argument matches any of the valid_values
Example:
>>> string_from_valid_list_type(['some_string', 'another'])
Parameters | |
validIterable[ | List of accepted string values |
Returns | |
Callable[ | function handle of an argument type function for ArgumentParser |