[Python-Dev] Strings: '\012' -> '\n'
Tue, 16 Jan 2001 21:04:53 -0500
> Good idea [using string.encode()]! This could also be used to
> "hexify" a string, for which currently one of the quickest ways
> is still the hack
> "%02x"*len(s) % tuple(s)
Note that as of 2.0, a far quicker way is to use binascii.b2a_hex(), or its
absurdist (read "Barry" <wink>) synonym binascii.hexlify().
I'm wary of using string.encode() for this, because one normally hexlifies
binary data (e.g., like sha checksums), and 4 days of 7 we're more than not
in favor of moving away from strings to carry binary data.
Of course we can change our minds about this across releases, and have
even-numbered releases deprecate the function forms while odd-numbered ones
abjure methods. Works for me <wink>.