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
>
> some_var = b'\xde\xad\xbe\xef'
>
> which is ugly and unreadable. Much nicer would be
>
> some_var = x'deadbeef'
We do have
bytes.fromhex('deadbeef')
Georg
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com