On Wed, Sep 10, 2014 at 6:54 AM, Wolfgang Maier email@example.com wrote:
I can see use-cases for both. After less than two minutes of thought, it seems to me that perhaps the most obvious APIs for these two different representations are:
hex(b'Abc') --> '0x416263'
This would require a change in the documented (https://docs.python.org/3/library/functions.html#hex) behavior of hex(), which I think is quite a big deal for a relatively special case.
I agree that we should leave hex alone.
b'Abc'.decode('hexescapes') --> '\x41\x62\x63'
This, OTOH, looks elegant (avoids a new method) and clear (no doubt about the returned type) to me. +1
Another +0.5 for me. I think this is quite elegant and reasonable. I'm not sure it needs to be unicode though. Perhaps it's too early for me, but does turning that into a unicode string make sense?