if minimum is not None and value < minimum or maximum is not None and value > maximum:
    raise ValueError
return value
return restricted
Extending Python’s int type to accept only values within a given range