Question about binary file reading

Hendrik van Rooyen mail at
Thu Mar 5 08:37:12 CET 2009

"Benjamin Peterson" <be.. at> wrote:

>So called encodings like "hex" and "rot13" are abuse of
>encode() method. encode() should translate
>between byte strings and unicode, not preform
>transformations like that. This has been removed
>in 3.x, so you should use binascii.

When all else fails, and just for fun, go to first principles:

>>> hextab = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
>>> s = 'the quick brown fox jums OVER the lazy dog'
>>> h = []
>>> for x in s:

>>> print ''.join(h)

- Hendrik

More information about the Python-list mailing list