Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87509
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'tutorial': 0.03; 'syntax': 0.04; 'suppose': 0.07; 'feature,': 0.09; 'subject:skip:c 10': 0.09; 'posted': 0.15; '[x]': 0.16; 'curve.': 0.16; 'dict': 0.16; 'surprises': 0.16; 'types,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'library': 0.18; 'all,': 0.19; 'memory': 0.22; 'example': 0.22; "aren't": 0.24; '15,': 0.26; 'least': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'location,': 0.31; 'covered': 0.32; 'url:python': 0.33; 'updated': 0.34; 'at:': 0.34; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'explains': 0.36; 'format.': 0.36; 'library.': 0.36; 'shows': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'turn': 0.37; 'list': 0.37; 'list.': 0.37; 'mapping': 0.38; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'url:3': 0.61; 'information': 0.63; 'mar': 0.68; 'frank': 0.68; 'obvious': 0.74; '2015': 0.84; 'dict.': 0.84; 'url:reference': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=MrGVme/Mj9vnlJVaV7Zu/CNrR597TT9AJcGhClWEEq8=; b=SgHLWtRuew/hiZGWUFefUFhCNvtjOe8v2G9/PkNfD+9T0HDfcKZB41ZcSjkPm4LL3y KiehDV9RSW4vIOiw1XKou9G14gdG8fzHvT++SPVOKVeNeDAZxlzd0C3f8AB0WYyQEa0I raqekGOYHIIATGHYOnJFhYV+KgraP3ewU6e9Ewhl2Q5swvri2HG5vKJSTnhyHq7hxEoN VBsr8FKys5bT6lRCODuKbYAFfkZ42oXsJPjLzhOHGQCfp3Rpc2405itwgcRHQjlI4qMw fcUqMpSs8z8cNMBetTnjyRsZnV87YOyruBPP29R3O9lLVA2Pz8gjHlFqvdQlsx6j1WWW 09Qw== |
| X-Received | by 10.66.178.139 with SMTP id cy11mr132517000pac.146.1426486697271; Sun, 15 Mar 2015 23:18:17 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <me5pgk$en5$1@ger.gmane.org> |
| References | <me5pgk$en5$1@ger.gmane.org> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 16 Mar 2015 00:17:36 -0600 |
| Subject | Re: Dict comprehensions - improvement to docs? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.413.1426486700.21433.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1426486700 news.xs4all.nl 2851 [2001:888:2000:d::a6]:56663 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:87509 |
Show key headers only | View raw
On Sun, Mar 15, 2015 at 11:25 PM, Frank Millman <frank@chagford.com> wrote:
> Hi all
>
> I like dict comprehensions, but I don't use them very often, so when I do I
> need to look up the format.
This surprises me, because I find the syntax very intuitive, at least
if you regularly use other kinds of comprehensions. If you don't often
use comprehensions at all, then I suppose there could be a memory
curve.
[x] is a list. [x for x in y] is a list comprehension. {x:y} is a
dict. {x:y for x,y in z} is a dict comprehension.
> I always struggle to find the information in the Library Reference. The
> obvious location, Mapping Types, shows various constructors, but not the
> comprehension.
>
> https://docs.python.org/3/library/stdtypes.html#mapping-types-dict
>
> So I turn to Google. It shows a couple of StackOverflow questions, and then
> a link to the Data Structures section of the Tutorial, which explains it
> succinctly.
>
> https://docs.python.org/3/tutorial/datastructures.html#dictionaries
>
> I feel that the Library Reference should be updated to include dict
> comprehensions.
Dict comprehensions aren't covered in the library reference because
they're a language feature, not a part of the standard library. The
syntax is defined at:
https://docs.python.org/3/reference/expressions.html#dictionary-displays
And an example usage can be found in the tutorial at the link you posted above.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Dict comprehensions - improvement to docs? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-16 00:17 -0600
csiph-web