On 08.07.20 17:19, Jonathan Fine wrote:
This is related to discussion https://email@example.com/thread/KWAOQFS...
In Python, lists don't have a join method. Instead, it's strings that have the join method. Hence we have: >>> ', '.join('abcde') 'a, b, c, d, e'
The intermediate method we can save and store and use again. >>> joiner = ', '.join >>> joiner('fghijk') 'f, g, h, i, j, k'
We can do something similar when clamping, clipping or trimming a value. For example, suppose we want limits on the room temperature, that the thermostat cannot override. >>> aircon_clipper = Clamper(50, 80)
>>> thermostat_temp = 40 >>> target_temp = aircon_temp_clipper(thermostat_temp) >>> target_temp 50
You could also use `functools.partial` for that purpose:
aircon_clipper = partial(clamp, min=50, max=80)
So a (builtin) function serves this purpose as well.