[Python-ideas] hexdump

Antoine Pitrou solipsis at pitrou.net
Mon Apr 29 13:43:15 CEST 2013


Le Mon, 29 Apr 2013 14:32:46 +0300,
Yuval Greenfield <ubershmekel at gmail.com>
a écrit :
> On Mon, Apr 29, 2013 at 11:59 AM, Antoine Pitrou
> <solipsis at 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.





More information about the Python-ideas mailing list