[Python-Dev] Python 3.x and bytes (original) (raw)
Georg Brandl g.brandl at gmx.net
Wed May 18 08:31:28 CEST 2011
- Previous message: [Python-Dev] Python 3.x and bytes
- Next message: [Python-Dev] Python 3.x and bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 18.05.2011 07:39, Greg Ewing wrote:
Ethan Furman wrote:
On the one hand we have the 'bytes are ascii data' type interface, and on the other we have the 'bytes are a list of integers between 0 - 256' interface. I think the weird part is that there exists a literal for writing a byte array as an ascii string, and furthermore that it's the only kind of literal available for bytes. Personally I think that the default literal syntax for bytes, and also the form produced by repr(), should have been something more neutral, such as hex, with the ascii form available for use when it makes sense. Currently if you want to write a bytes literal in hex, you have to say something like somevar = b'\xde\xad\xbe\xef' which is ugly and unreadable. Much nicer would be somevar = x'deadbeef'
We do have
bytes.fromhex('deadbeef')
Georg
- Previous message: [Python-Dev] Python 3.x and bytes
- Next message: [Python-Dev] Python 3.x and bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]