[issue17868] pprint long non-printable bytes as hexdump
Antoine Pitrou
report at bugs.python.org
Sat May 4 13:17:24 CEST 2013
Antoine Pitrou added the comment:
Le samedi 04 mai 2013 à 09:42 +0000, Serhiy Storchaka a écrit :
>
> However a simple specialized code can be used for special purposes,
> i.e. internally in the pprint module. I don't see how it can be reused
> and don't interested in a general function.
I don't understand how it would be useful in the pprint module if it
can't be useful as a general function. The general intent is the same:
print something in a "nice" way. Just the nice way is different
depending on the situations: if my bytes object is simply a bunch of
HTTP headers, I don't want to have a hexdump.
> An alternative option is first output a bytes object as is (perhaps
> splitting it on multiple line as in issue17530) and then output a
> hexdamp as a comment.
>
> [b'\x7fELF\x01\x01\x01\x00\x00\n'
> b'\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00\x01'
> # 7F 45 4C 46 01 01 01 00 00 0A 00 00 00 00 00 00 | .ELF............
> # 02 00 03 00 01 | .....
> ]
This won't work very nicely in smaller display widths. You'll need too
many lines to represent a bytes object.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17868>
_______________________________________
More information about the Python-bugs-list
mailing list