On Thu, Sep 11, 2014 at 4:35 AM, Chris Lasher chris.lasher@gmail.com wrote:
Unless printable representation of bytes objects appears as part of the language specification for Python 3, it's an implementation detail, thus, it is a candidate for change, especially if the BDFL wills it so.
So this is all about the output of repr(), right? The question then is: How important is backward compatibility with repr? Will there be code breakage?
I've generally considered repr() to be exclusively "take this object and turn it into something a human can use".Nothing about what the exact string returned is. Something like this description:
"""Any value, debug style. Do not rely on the exact formatting; how the result looks can vary depending on locale, phase of the moon or anything else the lfun::_sprintf() method implementor wanted for debugging."""
(Replace lfun::_sprintf() with __repr__() for that to make sense for Python.)
If repr's meant to be treated that way, then there's no problem changing bytes.__repr__ to produce hex-only output in 3.5 or 3.6. If it's NOT meant to be treated as opaque (and I've seen some Stack Overflow posts where people are parsing repr()), then what is the guarantee?
ChrisA