[python] How to clamp an integer to some range?