def _isValid(argname, arg, validArgs=None, condition=None):
    """ Checks that 'arg' is in validArgs and satisfies the given condition. """
    if validArgs is not None:
        if arg not in validArgs:
            print(
                f"Invalid value for '{argname}': '{arg}' is not in the set {validArgs}."
                )
            return False
    if condition is not None:
        validator = eval(f'lambda v: {condition}')
        if validator(arg) is not True:
            print(
                f"Invalid value for '{argname}': '{arg}' does not satisfy '{condition}'."
                )
            return False
    return True
