On 09/09/2021 18:54, firstname.lastname@example.org wrote:
I would rather keep `bchr` and lose the `.fromint()` methods.
For me, "bchr" isn't a readable name. If I expand mentally expand it to "byte_character", it becomes an oxymoron that opposes what we try teach about bytes and characters being different things.
Can you show examples in existing code of how this would be used? I'm unclear on how frequently users need to create a single byte from an integer. For me, it is very rare.
It's probably rare, but recently I was converting from Python 2 to Python 3 a program that implements a data compression algorithm (LZW). It (now) constructs the compressed data as a bytes object. Sometimes it needs to add a series of bytes, sometimes a single byte converted from an int. Not knowing if there was a "recommended" way to do the latter, I found something that worked, viz. bytes((i,)) But it felt a bit of a kludge. I would have used something like bchr if (a) it existed (b) I knew about it. Rob Cliffe