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

2010-07-27 Thread Greg Ewing
anatoly techtonik wrote: 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? Rather than a new type, maybe bytes objects could just have a bit indicating whether they were best thought of as containing characterish

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

2010-07-26 Thread Steven D'Aprano
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

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

2010-07-26 Thread Georg Brandl
Am 26.07.2010 20:42, schrieb Alexandre Vassalotti: > [+Python-ideas -Python-Dev] > > import binascii > def h(s): > return binascii.unhexlify("".join(s.split())) > > h("DE AD BE EF CA FE BA BE") In Py3k: h = bytes.fromhex Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No

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

2010-07-26 Thread Alexandre Vassalotti
[+Python-ideas -Python-Dev] import binascii def h(s): return binascii.unhexlify("".join(s.split())) h("DE AD BE EF CA FE BA BE") -- Alexandre On Mon, Jul 26, 2010 at 11:29 AM, anatoly techtonik wrote: > I find "\xXX\xXX\xXX\xXX..." notation for binary data totally > unreadable. Everybody who

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

2010-07-26 Thread anatoly techtonik
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 X