Barry A. Warsaw <ba...@python.org> added the comment:

On Sep 13, 2021, at 13:38, STINNER Victor <rep...@bugs.python.org> wrote:
> It seems like your proposal is mostly guided by: convert an int to a byte 
> (bytes string of length 1). IMO this case is special enough to justify the 
> usage of a different function.

Like bchr() ? <wink>

> What if people expect int.to_bytes() always return a single byte, but then 
> get two bytes by mistake?
> 
> ch = 256
> byte = ch.to_bytes()

The OverflowError you’ll get seems reasonable.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45155>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to