Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!ra.nrl.navy.mil!bloom-beacon.mit.edu!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Bytes indexing returns an int Date: Wed, 8 Jan 2014 02:34:29 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 21 Message-ID: References: <52cbe15a$0$29993$c3e8da3$5496439d@news.astraweb.com> <52cc988f$0$29976$c3e8da3$5496439d@news.astraweb.com> NNTP-Posting-Host: c-24-118-110-103.hsd1.mn.comcast.net X-Trace: reader1.panix.com 1389148469 14087 24.118.110.103 (8 Jan 2014 02:34:29 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 8 Jan 2014 02:34:29 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:63460 On 2014-01-08, Chris Angelico wrote: > On Wed, Jan 8, 2014 at 11:15 AM, Steven D'Aprano > wrote: >> Why decide that the bytes type is best considered as a list of >> bytes rather than a string of bytes? It doesn't have any list methods, it >> looks like a string and people use it as a string. As you have discovered, >> it is an inconvenient annoyance that indexing returns an int instead of a >> one-byte byte-string. >> >> I think that, in hindsight, this was a major screw-up in Python 3. > > Which part was? The fact that b'ASDF'[0] in Python2 yeilds something different than it does in Python3 -- one yields b'A' and the other yields 0x41. It makes portable code a lot harder to write. I don't really have any preference for one over the other, but changing it for no apparent reason was a horrible idea. -- Grant