def clamp(x=0.0, min=0.0, max=1.0) :
    """ Clamps the value x between min and max

    :rtype: float
    """
    # NOTE : in 2.5 can use 'caseTrue if condition else caseFalse'
    #realmin = min if min<max else max
    #realmax = max if min<max else min
    # orig C code :
    #    const double realmin=(min<max)?min:max;
    #    const double realmax=(min<max)?max:min;
    #    return ((x<realmin)?realmin:(x>realmax)?realmax:x);
    if min<max :
        realmin = min
        realmax = max
    else :
        realmin = max
        realmax = min
    if x<realmin :
        result = realmin
    elif x>realmax :
        result = realmax
    else :
        result = x
    return result
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.3/pymel/util/mathutils.py/clamp/original