[Python-Dev] Readability of hex strings (Was: Use of coding cookie in 3.x stdlib)

Steven D'Aprano steve at pearwood.info
Tue Jul 27 02:12:43 CEST 2010


On Tue, 27 Jul 2010 04:29:31 am anatoly techtonik wrote:
> I find "\xXX\xXX\xXX\xXX..." notation for binary data totally
> unreadable. Everybody who uses and analyses binary data is more
> familiar with plain hex dumps in the form of "XX XX XX XX...".
>
> I wonder if it is possible to introduce an effective binary string
> type that will be represented as h"XX XX XX" in language syntax? It
> will be much easier to analyze printed binary data and copy/paste
> such data as-is from hex editors/views.

With the moratorium on new language features, this would not even be 
considered until Python 3.3.

If you are serious in pursuing this idea, it is off-topic for this list 
and should be taken to python-ideas, or even python-list for community 
feedback, first.

Since it only takes a pair of small helper functions to convert hex 
dumps in the form "XXXX XXXX ..." to and from byte strings, I don't see 
the need for new syntax and would vote -1 on the idea. However, I'd 
vote +0 on a matching bytes.tohex() method to partner with the existing 
bytes.fromhex().


-- 
Steven D'Aprano


More information about the Python-Dev mailing list