def getwithinrange(value, min=0, max=255):
    if min is not None and value < min:
        return min
    elif max is not None and value > max:
        return max
    else:
        return value
Returns value if it is between the min and max number arguments. If value is greater than max, then max is returned. If value is less than min, then min is returned. If min and/or max is not specified, then the value is not limited in that direction.
dataset/ETHPy150Open asweigart/pygcurse/pygcurse/__init__.py/getwithinrange