type_ranged_num(arg,
top=None,
bottom=0.0,
top_allowed=False,
bottom_allowed=False,
typer=<type 'float'>)
|
|
Validate that the argument is a number over a given range.
- Parameters:
arg (str) - The argument to validate
top (float or int) - The upper limit of the allowed range
bottom (float or int) - The lower limit of the allowed range
top_allowed (bool) - Whether arg may take the top value or not (whether the upper
limit is inclusive or exclusive)
bottom_allowed (bool) - Whether arg may take the bottom value or not (whether the bottom
limit is inclusive or exclusive)
typer (callable) - Should be one of the built-in float or int functions and defines
the type of the value returned from this function.
- Returns: float or int
- The argument converted to a float or int, depending on the value
of the typer keyword argument
@raise argparse.ArgumentTypeError :
If the argument cannot be converted to a ranged floating point
number in the given range
|