def limit(value, v_min, v_max):
    """
    limit a float or int python var

    :param value: value to limit
    :param v_min: minimum value
    :param v_max: maximum value
    :return: limited value
    """
    try:
        return min(max(value, v_min), v_max)
    except TypeError:
        return None