[Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
Cameron Simpson
cs at zip.com.au
Thu Sep 11 01:48:38 CEST 2014
More information about the Python-ideas mailing list
Thu Sep 11 01:48:38 CEST 2014
- Previous message: [Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
- Next message: [Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
As someone who uses ASCII or more commonly UTF-8 byte sequences, I find the current ascii-ish default display handy. That said... On 10Sep2014 20:57, Steven D'Aprano <steve at pearwood.info> wrote: >However, I do support Terry's suggestion that bytes (and, I presume, >bytearray) grow some sort of easy way of displaying the bytes in hex. >The trouble is, what do we actually want? > >b'Abc' --> '0x416263' To my eye that is a single number expressed in base 16 and would imply an endianness. I imagine you really mean a transcription of the bytes in hex, with a leading 0x to indicate the transcription. But it is not what my eye sees. Of course, the natural transcription above implies big endianness, as is only right and proper:-) Why not give bytes objects a .hex method, emitting bare hex with no leading 0x? That would be my first approach. >b'Abc'.decode('hexescapes') --> '\x41\x62\x63' OTOH, this is really neat. And .decode('hex') for the former? Cheers, Cameron Simpson <cs at zip.com.au> It never will rain roses; when we want to have more roses we must plant more trees. - George Eliot, The Spanish Gypsy
- Previous message: [Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
- Next message: [Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list