On Tue, Nov 21, 2017 at 6:37 AM, Kirill Balunov <kirillbalunov@gmail.com> wrote:
Currently, __repr__ and __str__ representation of bytes is the same. Perhaps it is worth making them different, this will make it easier to visually perceive them as a container of integers from 0 to 255,
instead of a mixture of printable and non-printable ascii characters. It is proposed:

a) __str__ - leave unchanged
b) __repr__ - represent as sequence of escaped hex

>>> a = bytes([42,43,44,45,46])
>>> a    # Current
>>> a    # Proposed

supposedly __repr__ is supposed to give an eval-able version -- which your proposal is. But the way you did your example indicates that:

bytes((42, 43, 44, 45, 46))

would be an even better __repr__, if the goal is to make it clear and easy that it is a "container of integers from 0 to 255"

I've been programming since quite some time ago, and hex has NEVER come naturally to me :-)

But backward compatibility and all that :-(



Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception