Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '*not*': 0.07; 'indexing': 0.07; 'python3': 0.07; 'report.': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; '~ethan~': 0.09; 'python': 0.11; 'bug': 0.12; '2.7': 0.14; 'called.': 0.16; 'container,': 0.16; 'containers': 0.16; 'porting': 0.16; 'rationale': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'items.': 0.19; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'bytes': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; '[1]': 0.29; 'am,': 0.29; "i'm": 0.30; '3.x': 0.31; 'container': 0.31; "d'aprano": 0.31; 'explained': 0.31; 'libraries': 0.31; 'lies': 0.31; 'steven': 0.31; 'allows': 0.31; 'run': 0.32; 'problem': 0.35; 'etc.)': 0.35; 'no,': 0.35; 'indexed': 0.36; 'charset:us-ascii': 0.36; 'behind': 0.37; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:173': 0.61; 'between': 0.67; 'believe': 0.68; '(is': 0.84; 'contains.': 0.84; 'hate': 0.91 Date: Tue, 07 Jan 2014 09:02:33 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Bytes indexing returns an int References: <52cbe15a$0$29993$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3304.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source-IP: 173.12.184.233 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:44867 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389117017 news.xs4all.nl 2857 [2001:888:2000:d::a6]:45522 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63444 On 01/07/2014 07:19 AM, David Robinow wrote: > > Python 3 grudgingly allows the "abomination" of byte strings (is that > what they're called?) No, that is *not* what they're called. If you find any place in the Python3 docs that does call them bytestrings please submit a bug report. On 01/07/2014 08:12 AM, Steven D'Aprano wrote: > People trying to port these libraries from 2.7 to 3 run into this problem, > and it causes them grief. This little difference between bytes in 2.7 and > bytes in 3.x is a point of friction which makes porting harder, and I'm > trying to understand the reason for it. If I recall correctly the way it was explained to me: bytes (lists, arrays, etc.) is a container, and when a container is indexed you get whatever the container held. If you slice the container you get a smaller container with the appropriate items. bytes (and bytearrays) are containers of ints, so indexing returns an int. One big problem with this whole scenario is that bytes then lies about what it contains. (And I hate lies! [1]) Anyway, I believe that's the rationale behind the change. -- ~Ethan~ [1] http://www.quickmeme.com/meme/3ts325