On 2021-09-09 00:29, Rob Cliffe via Python-Dev wrote:
On 08/09/2021 21:21, Christopher Barker wrote:
[snip] NOTE: my objection to “bchr”, whether as a builtin or not is not the functionality, it’s the name.
[snip] Why not byte() ?
I happened to need to convert an integer to a byte recently and I settled on bytes((i,)) I don't know if I missed a more elegant solution (suggestions welcome), but if I could write byte(i) that would feel more Pythonic to me.
Well, I tend to see a byte as a value like an int. If you slice a bytestring, you'd expect to get a bytestring, and you do. If you subscript a bytestring, you expect to get a byte. You get an int, and that suggests that a byte is an int. (In Python 2 you got a bytestring, in Python 3 you get an int.) The name could be misleading as byte(i) would return a bytestring, not a byte/int.