On Thu, Sep 09, 2021 at 10:57:26AM +0200, Victor Stinner wrote:
I propose to rename PEP 467 method bytes.fromint(n) to => bytes.fromchar(n) <= to convert an integer to a single *character*: it fails if n is not in the [0; 255] range. "char" comes from "character", as "bchr()" means "bytes character".
Integers 0...255 are not characters. They are ints. `bytes.fromchar` would have to accept a string of length 1, as in: bytes.fromchar('a') # returns b'a' otherwise the name is completely inaccurate.
For C programmers,
We're Python programmers. To Python programmers, the int 20 is not a space character.
I suggest to *not* add a builtin function bchr(), it's not common enough to justify to add it
Agreed, having a builtin bchr() function doesn't seem to be justified. We can always add it in the future if needed, but using a bytes method should be fine. -- Steve