On 05/07/2020 23:55, Rob Cliffe wrote:
I think None should be allowed as a missing bound.
+1
I don't think the new function should be restricted to numbers. There
may be uses for strings, or for user-built classes; why restrict it
unnecessarily?
If it quacks like supporting __lt__ and
On 05/07/2020 16:15, Steven D'Aprano wrote:
Perhaps you should reconsider your expectations there. They do different
things because they are different functions with different signatures
and different purposes. It isn't even necessary to use min and max in
the implementation of clamp, in fact it
On the topic of NaNs: I think in the face of ambiguity, we should refuse
the temptation to guess and raise ValueError when the values given are
not comparable to the point of clearly determining whether `value` is or
isn't within `minimum` and `maximum` or which of the two bounds it
exceeds.
On 04/07/2020 02:01, MRAB wrote:
Should it raise an exception if minimum > maximum? If it doesn't, then
you'll get a different answer depending on whether it's
`min(max(value, minimum), maximum)` or `max(min(value, maximum),
minimum)`.
Yes, I'd expect ValueError if min > max or max < min.
Even after years of coding it sometimes takes me a moment to correctly
parse expressions like `min(max(value, minimum), maximum)`, especially
when the parentheses enclose some local computation instead of only
references, and the fact that `min` actually needs the *maximum* value
as an