Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'explicitly': 0.05; 'subject:Python': 0.06; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'iterate': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'skip:/ 10': 0.09; 'subject:()': 0.09; 'wrapped': 0.09; '~ethan~': 0.09; 'python': 0.11; 'itself.': 0.14; '24,': 0.16; 'benjamin': 0.16; 'dict': 0.16; 'iterated': 0.16; 'once.': 0.16; 'set,': 0.16; 'wrote:': 0.18; 'appears': 0.22; 'header:User-Agent:1': 0.23; '2.x': 0.24; 'looks': 0.24; '(or': 0.24; 'question': 0.24; 'header :In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; '3.x': 0.31; 'used,': 0.33; 'could': 0.34; 'problem.': 0.35; 'something': 0.35; 'but': 0.35; 'so,': 0.37; 'list': 0.37; 'same.': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'even': 0.60; 'identify': 0.61; 'new': 0.61; 'received:173': 0.61; 'different': 0.65; 'temporary': 0.65; 'received:69.56': 0.68; 'subject: & ': 0.68; 'jul': 0.74; '7:25': 0.84; 'dict,': 0.84; 'ethan': 0.84; 'furman': 0.84; 'oscar': 0.84; 'received:gateway02.websitewelcome.com': 0.91; '2013': 0.98 Date: Wed, 24 Jul 2013 08:57:11 -0700 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: Python 3: dict & dict.keys() References: <51EF2AD8.3080105@stoneleaf.us> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; 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 - gator410.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: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:44846 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374682931 news.xs4all.nl 15937 [2001:888:2000:d::a6]:38752 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51147 On 07/24/2013 05:51 AM, Oscar Benjamin wrote: > > On Jul 24, 2013 7:25 AM, "Peter Otten" <__peter__@web.de > wrote: >> >> Ethan Furman wrote: >> >> > So, my question boils down to: in Python 3 how is dict.keys() different >> > from dict? What are the use cases? >> >> I just grepped through /usr/lib/python3, and could not identify a single >> line where some_object.keys() wasn't either wrapped in a list (or set, >> sorted, max) call, or iterated over. >> >> To me it looks like views are a solution waiting for a problem. > > What do you mean? Why would you want to create a temporary list just to iterate over it explicitly or implicitly (set, > sorted, max,...)? You wouldn't. But you don't need .keys() for that either as you can just use the dict itself. My point is that in 2.x .keys() did something different from the dict, while in 3.x it appears to me that they are the same. Peter's point is that in the stdlib the new functionality of .keys() is never used, not even once. -- ~Ethan~