A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-May/111417.html below:

[Python-Dev] Python 3.x and bytes

[Python-Dev] Python 3.x and bytes [Python-Dev] Python 3.x and bytesGeorg Brandl g.brandl at gmx.net
Wed May 18 08:31:28 CEST 2011
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

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4