[issue17868] pprint long non-printable bytes as hexdump

Serhiy Storchaka report at bugs.python.org
Sat May 4 17:41:30 CEST 2013


Serhiy Storchaka added the comment:

> I don't understand your question. Do you never print some data at the
> command-line prompt? Or even as part of small test programs?

To be honest, I very rarely even use pprint. I'm too lazy to import it. If I want to quickly get a hexdump, I use something like `' '.join('%02X'%i for i in data)`. It is shorter than `import pprint; pprint.hexdump(data)`. For a small program most likely the standard hexdump() will not be enough.

> Passing type-specific parameters to pprint/pformat sounds like a bad
> idea to me.

Agree. Of course it would be better to automatically determine a "nice" display (use hexdump only for large non-printable bytes).

> And I don't think you'd want to print *all* integers as hex.

If you want to print bytes in hex, why not ints and floats? ;)  In fact I don't want to print data as hex, so shut up.

> Which is why the proposal doesn't fit well with pprint/pformat.

Perhaps I misunderstood your wish. I'm not against consider pprint as a black box, which does all good magic inside by default. The use of this feature does not require anything from the users and does not impose obligations on the maintainers. But I'm not interested in a separate function.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17868>
_______________________________________


More information about the Python-bugs-list mailing list