The version of this I have in my code: sorted((lower, val, upper))[1] but yes I’d like a builtin clamp. I’m neutral on the “should min > max raise an error” but would need answering. And prefer clamp to clip.
There’s an indepth previous discussion Mailman 3 Consider adding clip or clamp function to math - Python-ideas - python.org
And at least one other discussion Math.Clamp/Clip proposal - #4 by dirn that didn’t get very far