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
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/UST6SGY4GSJZC367IJJKSQYYEDE4MWMS/
Code of Conduct: http://python.org/psf/codeofconduct/