I think the question is answered but here's an alternative DIY solution if anyone needs it:
def clip(value, lower, upper):
return lower if value < lower else upper if value > upper else value
(Slightly faster than @Sven Marnach's answer - even when in bounds).