[Python-ideas] Make bytes __repr__ and __str__ representation different?
kirillbalunov at gmail.com
Tue Nov 21 09:37:36 EST 2017
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
a) __str__ - leave unchanged
b) __repr__ - represent as sequence of escaped hex
>>> a = bytes([42,43,44,45,46])
>>> a # Current
>>> a # Proposed
As you can see, the second example is more easily perceived as a sequence,
in which '\' is also perceived as ',' in list or tuple. In addition, 2020
is close, it allows the new Pythonistas not to take them as an ascii
With kind regards, -gdg
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas