Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87530
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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; 'jan': 0.12; '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; 'entry.': 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; 'reedy': 0.16; 'skip:n 70': 0.16; 'ways:': 0.16; 'language': 0.16; 'wrote:': 0.18; 'library': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; "aren't": 0.24; '15,': 0.26; 'possibly': 0.26; 'tracker': 0.26; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'list:': 0.30; 'initialized': 0.31; 'class': 0.32; 'lists': 0.32; 'covered': 0.32; 'open': 0.33; 'says': 0.33; 'url:python': 0.33; 'at:': 0.34; 'agree': 0.35; '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; 'issue': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'tell': 0.60; 'mentioned': 0.61; 'new': 0.61; 'url:3': 0.61; 'within': 0.65; 'mar': 0.68; 'frank': 0.68; 'square': 0.74; '2015': 0.84; 'received:fios.verizon.net': 0.84; 'url:reference': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Dict comprehensions - improvement to docs? |
| Date | Mon, 16 Mar 2015 04:26:46 -0400 |
| References | <me5pgk$en5$1@ger.gmane.org> <CALwzidnTUifj_L=DSH_8s+z0L44pxVvdpG1+pfz1Tzm=ECTLsw@mail.gmail.com> <me5u6p$jmr$1@ger.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-98-114-97-173.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
| In-Reply-To | <me5u6p$jmr$1@ger.gmane.org> |
| 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.426.1426494442.21433.python-list@python.org> (permalink) |
| Lines | 61 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1426494442 news.xs4all.nl 2867 [2001:888:2000:d::a6]:57771 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:87530 |
Show key headers only | View raw
On 3/16/2015 2:45 AM, Frank Millman wrote:
>
> "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.
Given that list comprehensions are mentioned in the library reference, I
agree that set and dict comprehensions should be also. Open an issue on
the tracker pointing to the list entry.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Dict comprehensions - improvement to docs? Terry Reedy <tjreedy@udel.edu> - 2015-03-16 04:26 -0400
csiph-web