Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87512
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'syntax': 0.04; 'argument': 0.05; '"""': 0.07; 'feature,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'separating': 0.09; 'subject:skip:c 10': 0.09; 'wrote': 0.14; '4127:': 0.16; 'braces,': 0.16; 'brackets': 0.16; 'brackets,': 0.16; 'commas:': 0.16; 'constructor.': 0.16; 'denote': 0.16; 'dict': 0.16; 'dictionaries': 0.16; 'exist.': 0.16; 'optional': 0.16; 'pairs': 0.16; 'positional': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:n 70': 0.16; 'ways:': 0.16; 'language': 0.16; 'wrote:': 0.18; 'library': 0.18; "aren't": 0.24; '15,': 0.26; 'possibly': 0.26; 'defined': 0.27; 'header:X -Complaints-To:1': 0.27; 'list:': 0.30; 'initialized': 0.31; 'class': 0.32; 'lists': 0.32; 'covered': 0.32; 'says': 0.33; 'url:python': 0.33; 'at:': 0.34; 'created': 0.35; 'but': 0.35; 'there': 0.35; 'format.': 0.36; 'keyword': 0.36; 'library.': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'tell': 0.60; 'new': 0.61; 'url:3': 0.61; 'within': 0.65; 'mar': 0.68; 'frank': 0.68; 'square': 0.74; '2015': 0.84; 'url:reference': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | "Frank Millman" <frank@chagford.com> |
| Subject | Re: Dict comprehensions - improvement to docs? |
| Date | Mon, 16 Mar 2015 08:45:46 +0200 |
| References | <me5pgk$en5$1@ger.gmane.org> <CALwzidnTUifj_L=DSH_8s+z0L44pxVvdpG1+pfz1Tzm=ECTLsw@mail.gmail.com> |
| X-Gmane-NNTP-Posting-Host | 197.89.15.108 |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.3790.4657 |
| X-RFC2646 | Format=Flowed; Original |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.3790.4913 |
| 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.415.1426488358.21433.python-list@python.org> (permalink) |
| Lines | 55 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1426488358 news.xs4all.nl 2836 [2001:888:2000:d::a6]:41794 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:87512 |
Show key headers only | View raw
"Ian Kelly" <ian.g.kelly@gmail.com> wrote in message
news:CALwzidnTUifj_L=DSH_8s+z0L44pxVvdpG1+pfz1Tzm=ECTLsw@mail.gmail.com...
> 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.
>
[...]
>
> 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
>
This is what the library reference says about lists -
"""
Lists may be constructed in several ways:
Using a pair of square brackets to denote the empty list: []
Using square brackets, separating items with commas: [a], [a, b, c]
Using a list comprehension: [x for x in iterable]
Using the type constructor: list() or list(iterable)
"""
This is what it says about dictionaries -
"""
Dictionaries can be created by placing a comma-separated list of key: value
pairs within braces, for example: {'jack': 4098, 'sjoerd': 4127} or {4098:
'jack', 4127: 'sjoerd'}, or by the dict constructor.
class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)
Return a new dictionary initialized from an optional positional argument and
a possibly empty set of keyword arguments.
"""
If you did not know about dict comprehensions, there is nothing to tell you
that they even exist.
I feel that it should be mentioned.
Frank
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Dict comprehensions - improvement to docs? "Frank Millman" <frank@chagford.com> - 2015-03-16 08:45 +0200 Re: Dict comprehensions - improvement to docs? Paul Rubin <no.email@nospam.invalid> - 2015-03-15 23:55 -0700
csiph-web