On Wed, Jul 08, 2020 at 04:19:32PM +0100, Jonathan Fine wrote: > 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
Here you go: aircon_clipper = functools.partial(math.clamp, lower=50, upper=80) Relevent: https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html -- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QU7F2LXJW7DPEJ3LMJNVUX6WK7WNNBXD/ Code of Conduct: http://python.org/psf/codeofconduct/