
On Fri, Jul 03, 2020 at 09:24:47PM -0300, Soni L. wrote:
how do you plan to clamp a numpy array or a string?
I'm not saying it is meaningful, but it certainly works to clamp strings: py> s = "hello" py> min(max(s, "a"), "z") 'hello' Likewise other indexable types can be compared with min and max: py> min(['a', 1], ['b', 2]) ['a', 1] The traditional meaning of slice notation is to take a slice of a sequence, i.e. to extract a sub-sequence. I don't see the conceptual connection between "take a sub-sequence" and "clamp to within some bounds", and if I saw something like this: (45)[2:18] I would interpret it as some form of bit-masking, i.e. extracting bits 2 to 18 in some form or another. I'd certainly never guess in a million years that it was a clamping operation. -- Steven