[Python-Dev] Python 3.x and bytes
R. David Murray
rdmurray at bitdance.com
Wed May 18 19:10:17 CEST 2011
On Thu, 19 May 2011 01:16:44 +0900, "Stephen J. Turnbull" <stephen at xemacs.org> wrote:
> Robert Collins writes:
> > Its probably too late to change, but please don't try to argue that
> > its correct: the continued confusion of folk running into this is
> > evidence that confusion *is happening*. Treat that as evidence and
> > think about how to fix it going forward.
> Sorry, Rob, but you're just wrong here, and Nick is right. It's
> possible to improve Python 3, but not to "fix" it in this respect.
> The Python 3 solution is correct, the Python 2 approach is not.
> There's no way to avoid discontinuity and confusion here.
> Confusion is indeed happening, but it's real confusion in the way
> people think about the problem space, not a language design cockup.
Note that the more common idiom (not that I can measure it, mind)
when dealing with byte strings is something analogous to
if my_byte_string[i:i+1] == b'x':
if my_byte_string[i] == 170:
and the former is a lot more readable than the latter, even though
you have to stare at the slice for a couple seconds the first time
you encounter it to realize what is going on.
So *something* is wrong with Python3's approach. Python2 was wronger,
More information about the Python-Dev