News for hackers. Stuff that matters.
Re:Math.min(Math.max(num, min), max) by parliament32 on Thursday August 20, 2020 @12:22PM (#24224866)
Python also doesn't have a built-in clamp function (I think there might be one in numpy), I usually use

    sorted((floor, x, ceiling))[1]
Throw it in a function with some asserts if you're worried about x not being a number and giving you weird results.
Re:Math.min(Math.max(num, min), max) by doukdouk on Thursday August 20, 2020 @12:27PM (#24224925)
Re:Math.min(Math.max(num, min), max) by dagurp on Thursday August 20, 2020 @12:45PM (#24225224)
You could use statistics.median (in python 3.6+)