(gt=None, lt=None)
return ValidateRange
Create an argparse.Action subclass for validating comparable inputs.

    :param gt: value which the argument must be greater than
    :param lt: value which the argument must be less than
    :returns: argparse.Action subclass

    Example:
    parser.add_argument('--fraction', action=validate_range(gt=0.0, lt=1.0),
        type=float, help="Number between 0 and 1")
Create an argparse.Action subclass for validating comparable inputs.
Create an argparse . Action subclass for validating comparable inputs .
def validate_range(gt=None, lt=None):
    """Create an argparse.Action subclass for validating comparable inputs.

    :param gt: value which the argument must be greater than
    :param lt: value which the argument must be less than
    :returns: argparse.Action subclass

    Example:
    parser.add_argument('--fraction', action=validate_range(gt=0.0, lt=1.0),
        type=float, help="Number between 0 and 1")
    """

    class ValidateRange(argparse.Action):
        def __call__(self, parser, namespace, values, option_string=None):

            if gt is not None and gt >= values:
                raise argparse.ArgumentError(self, f"Must be greater than {gt}")

            if lt is not None and lt <= values:
                raise argparse.ArgumentError(self, f"Must be less than {lt}")

            setattr(namespace, self.dest, values)

    return ValidateRange
def validate_range ( gt = None , lt = None ) : class ValidateRange ( argparse . Action ) : def __call__ ( self , parser , namespace , values , option_string = None ) : if gt is not None and gt >= values : raise argparse . ArgumentError ( self , f"Must be greater than {gt}" ) if lt is not None and lt <= values : raise argparse . ArgumentError ( self , f"Must be less than {lt}" ) setattr ( namespace , self . dest , values ) return ValidateRange