Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:Python': 0.06; 'odd': 0.07; 'decision.': 0.09; 'subject:()': 0.09; 'choice,': 0.16; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterates': 0.16; 'iterating': 0.16; 'iteration': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'thu,': 0.19; 'connected': 0.24; 'options': 0.25; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '25,': 0.31; 'implicit': 0.31; 'produces': 0.31; "can't": 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'curious': 0.36; 'doing': 0.36; 'half': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'rather': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'even': 0.60; 'eventually': 0.60; 'side': 0.67; 'subject: & ': 0.68; 'default': 0.69; 'jul': 0.74; 'coupled': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=F8rn6d5yyM0pQ7Jeku3HphKWrUGiD2nybrTBh1aNCYY=; b=c7DsoacI8Tyyqw1/fQA/dwXWXlOoiikAghHdi9e42KWMZjhuHpoHtYtMZQ6vk7r163 DqVyTCTympOtbpdiNeCftC684wFrku8l7Mg9zArjhJXqv9Gw4EvwS7uNfVufx7Oa9OtJ L13f6pcwhdXfApFbQzjkuCdrD8fw4JrSckWcUVm80GsNhwxku2TxetMhW9ekCF7c2p1o KZFieQQyT+OIHDuE4zoisAxR1Vic0V3qOw1EYC6c7cPlOOv17h6pyJfMrtGPTZAiJ3p9 /upt6TKMZF3jCXagDbhVTxemwVpakPH9PqO82+0Wv3SCuEppWHxrzRA0slueF28vSJBI 2Vfw== MIME-Version: 1.0 X-Received: by 10.52.34.40 with SMTP id w8mr12684750vdi.7.1374688735339; Wed, 24 Jul 2013 10:58:55 -0700 (PDT) In-Reply-To: References: <51EF2AD8.3080105@stoneleaf.us> <51EFF957.1040707@stoneleaf.us> Date: Thu, 25 Jul 2013 03:58:55 +1000 Subject: Re: Python 3: dict & dict.keys() From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374688738 news.xs4all.nl 15959 [2001:888:2000:d::a6]:33257 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51156 On Thu, Jul 25, 2013 at 3:17 AM, Terry Reedy wrote: > On 7/24/2013 12:34 PM, Chris Angelico wrote: > >> Side point: Why is iterating over a dict equivalent to .keys() rather >> than .items()? It feels odd that, with both options viable, the >> implicit version iterates over half the dict instead of all of it. >> Obviously it can't be changed now, even if .items() were the better >> choice, but I'm curious as to the reason for the decision. > > This is > coupled with the fact that the default meaning of 'item in collection' is > that iterating over 'collection' eventually produces 'item' or a value equal > to 'item'. Ahh, that makes sense. I never thought of iteration and 'in' being connected like that, but yes, that's a solid reason for doing it that way. ChrisA