
April 29, 2013
11:43 a.m.
Le Mon, 29 Apr 2013 14:32:46 +0300, Yuval Greenfield <ubershmekel@gmail.com> a écrit :
On Mon, Apr 29, 2013 at 11:59 AM, Antoine Pitrou <solipsis@pitrou.net>wrote:
Actually, I think a hexdump() function in pprint would be a nice addition. I find myself wanting it when inspecting some binary protocols (e.g. pickle :-)).
Python 2.7 had
'alkdjfa'.encode('hex') '616c6b646a6661'
So why not:
b'asdf'.decode('hexdump') '61 73 64 66'
Command-line hexdump has a bit more options and abilities, such as wrapping to N character width, printing an ASCII transcript beside the representation, etc. To support this flexibility, a module function is better than a codec :-) Regards Antoine.