[Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3

Ethan Furman ethan at stoneleaf.us
Tue Sep 16 22:36:10 CEST 2014


On 09/16/2014 01:09 PM, Andrew Barnert wrote:
>
> No, you're mixing up `format`, an explicit method on str that no one
>  is suggesting adding to bytes, and `__format__`, a dunder method on
>  every type that's used by `str.format` and `format`; the proposal is
>  to extend `bytes.__format__` in some way that I don't think is entirely
>  decided yet, but it would look something like this:
>
>      u'Hello, {:a}'.format(some_bytes_var)  --> u'Hello, <whatever>'
>
> Or:
>
>      u'Hello, {:#x}'.format(some_bytes_var) --> u'Hello, \\x2d\\x78\\x68\\x61...'

Ah, that makes more sense, thanks for the clarification!

--
~Ethan~


More information about the Python-ideas mailing list