[Python-Dev] Python 3.x and bytes

Glenn Linderman v+python at g.nevcal.com
Wed May 18 07:46:34 CEST 2011


On 5/17/2011 10:39 PM, Greg Ewing wrote:
> 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.

> Much nicer would be
>
>    some_var = x'deadbeef'
>
> As for
>
>> --> some_other_var[3] == b'd'
>
> there ought to be a literal for specifying an integer
> using an ascii character, so you could say something like
>
>   if some_other_var[3] == c'd':
>
> which would be equivalent to
>
>   if some_other_var[3] == ord(b'd')
>
> but without the overhead of computing the value each time
> at run time.

+1

Seems this could be added compatibly?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110517/17ceb88f/attachment.html>


More information about the Python-Dev mailing list