Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37639

Re: Dict comp help

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <robertkday@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.052
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'cpython': 0.05; 'subject:help': 0.07; 'python': 0.09; 'benjamin': 0.16; "{'a':": 0.16; 'wrote:': 0.17; 'sender:addr:gmail.com': 0.18; 'versions': 0.20; 'to:name:python-list@python.org': 0.20; 'received:209.85.216.46': 0.21; 'seems': 0.23; 'header:In-Reply- To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; '>>>>': 0.29; "skip:' 10": 0.30; 'url:python': 0.32; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'robert': 0.35; 'received:209.85': 0.35; 'url:org': 0.36; 'url:library': 0.36; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'different': 0.63; 'day': 0.73; '2013': 0.84; 'oscar': 0.84; 'url:items': 0.84; 'subject:comp': 0.96
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=4SxGnqE7ZJkEU2fqlvVCyyb3gkRN8PwloN293/++axw=; b=gBSj2uDb7/CmSc71E8FjdSSPM2rhtjMLugwmed16tT0GWczmBxCWVsyZ+2HxTRUSka ejvUH2BSOCOqSsIw6UQrlr+Atobbb3ytFNud01lDL0tUyfl6tlfyZ5MFyfUg1JWf5u6a y7YWBy8Mse0YWhPesnd/5CH1WhSv0yVBO0gj/fp4VKBgUoVpjQhanldDXP0kkmTvbxCM 7neYw5q3Vs5Eqbxy5/Z8gnhbDSGLWgH8tXPbzGtIBB6Hyx/lf/o4RZEBaafYGRN78W3D FH+VoV1CTq9ubWEWDxLjn2gfn+lUuZZ05Y2gmtqi6PGqFYvgoxnxcvS5tF1w3XDDF755 UdvA==
MIME-Version 1.0
X-Received by 10.49.34.146 with SMTP id z18mr4309538qei.29.1359063679809; Thu, 24 Jan 2013 13:41:19 -0800 (PST)
Sender robertkday@gmail.com
In-Reply-To <CAHVvXxSVH_-3VHx1VLwSah7-Y8ZwvQ9MZB7e_ZevEUcjG7ZBEQ@mail.gmail.com>
References <assp.07360d00b0.753cb595af8449f689dabf8b28611e52@exch.activenetwerx.com> <CAHVvXxSVH_-3VHx1VLwSah7-Y8ZwvQ9MZB7e_ZevEUcjG7ZBEQ@mail.gmail.com>
Date Thu, 24 Jan 2013 21:41:19 +0000
X-Google-Sender-Auth plIsMKLCf7jA49eZqNMeyToHDHY
Subject Re: Dict comp help
From Rob Day <robert.day@merton.oxon.org>
To "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
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.1021.1359063688.2939.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1359063688 news.xs4all.nl 6889 [2001:888:2000:d::a6]:38110
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37639

Show key headers only | View raw


On 24 January 2013 21:11, Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:
>>>> l = [{'a': 'xx', 'b': 'yy', 'c': 'zz'}, {'a': 'dd', 'b': 'ee', 'c': 'ff'}]
>>>> dict(d.values()[:2] for d in l)
> {'xx': 'zz', 'dd': 'ff'}

Python doesn't guarantee any ordering of items in a dictionary; {'a':
'xx', 'b': 'yy', 'c': 'zz'}.values()[:2] may not return ['xx', 'zz']
in different Python implementations or future versions (though it
seems to work consistently in CPython 2.7). See
http://docs.python.org/2/library/stdtypes.html#dict.items.

--
Robert K. Day
robert.day@merton.oxon.org

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Dict comp help Rob Day <robert.day@merton.oxon.org> - 2013-01-24 21:41 +0000

csiph-web