Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51161
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'anyway.': 0.05; 'subject:Python': 0.06; 'skip:` 10': 0.07; 'apis': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'subject:()': 0.09; '~ethan~': 0.09; 'api': 0.11; 'python': 0.11; 'thread': 0.14; 'api,': 0.16; 'failure.': 0.16; 'previously,': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'stefan': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'gives': 0.31; 'commonly': 0.31; 'etc.).': 0.31; 'common': 0.35; 'problem.': 0.35; 'something': 0.35; 'operations': 0.35; 'but': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; 'so,': 0.37; 'two': 0.37; 'being': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'skip:. 10': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'received:173': 0.61; 'simply': 0.61; 'more': 0.64; 'different': 0.65; 'useful.': 0.68; 'subject: & ': 0.68; 'increase': 0.74; 'special': 0.74; 'hey,': 0.75; 'ethan': 0.84; 'everything.': 0.84; 'furman': 0.84; 'received:64.5': 0.84 |
| Date | Wed, 24 Jul 2013 11:31:58 -0700 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| 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> <ksnrr9$k4t$1@ger.gmane.org> <ksp2it$21p$1@ger.gmane.org> |
| In-Reply-To | <ksp2it$21p$1@ger.gmane.org> |
| 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 - 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]:44909 |
| X-Source-Auth | ethan+stoneleaf.us |
| X-Email-Count | 7 |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5061.1374692206.3114.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1374692206 news.xs4all.nl 15873 [2001:888:2000:d::a6]:54804 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51161 |
Show key headers only | View raw
On 07/24/2013 10:23 AM, Stefan Behnel wrote: > Peter Otten, 24.07.2013 08:23: >> Ethan Furman wrote: >>> >>> So, my question boils down to: in Python 3 how is dict.keys() different >>> from dict? What are the use cases? >> >> To me it looks like views are a solution waiting for a problem. > > They reduce the API overhead. Previously, you needed values() and > itervalues(), with values() being not more than a special case of what > itervalues() provides anyway. Now it's just one method that gives you > everything. It simply has corrected the tradeoff from two special purpose > APIs to one general purpose API, that's all. I started this thread for two reasons: 1) Increase awareness that using `list(dict)` is a cross-version replacement for `dict.keys()` 2) Hopefully learn something about when a view is useful. So far #2 is pretty much a failure. Only one use-case so far (and it feels pretty rare). But hey, I have learned that while some set operations are allowed (&, ^, |, .isdisjoint()), others are not (.remove(), .discard(), .union(), etc.). The old .keys(), .values(), and .items() (and their .iter...() variations) did something commonly useful. Of what common use are these views? -- ~Ethan~
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Python 3: dict & dict.keys() Ethan Furman <ethan@stoneleaf.us> - 2013-07-24 11:31 -0700
Re: Python 3: dict & dict.keys() alex23 <wuwei23@gmail.com> - 2013-07-25 16:01 +1000
Re: Python 3: dict & dict.keys() Ethan Furman <ethan@stoneleaf.us> - 2013-07-25 06:47 -0700
Re: Python 3: dict & dict.keys() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-25 07:04 +0000
Re: Python 3: dict & dict.keys() Chris Angelico <rosuav@gmail.com> - 2013-07-25 18:02 +1000
Re: Python 3: dict & dict.keys() Peter Otten <__peter__@web.de> - 2013-07-25 10:13 +0200
Re: Python 3: dict & dict.keys() Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-25 09:53 -0600
Re: Python 3: dict & dict.keys() Peter Otten <__peter__@web.de> - 2013-07-25 18:25 +0200
csiph-web