Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:keys': 0.09; 'subject:same': 0.09; 'cc:addr:python-list': 0.10; 'correspond.': 0.16; 'dictionary,': 0.16; 'filename:fname piece:signature': 0.16; 'intervening': 0.16; 'order?': 0.16; 'subject:values': 0.16; 'wrote:': 0.17; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; '[1]': 0.27; 'though.': 0.29; 'yes.': 0.29; 'lists': 0.31; 'url:python': 0.32; 'cases,': 0.33; 'received:192.168.2': 0.34; 'pm,': 0.35; 'subject:?': 0.35; 'url:org': 0.36; 'url:library': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'url:docs': 0.38; 'received:192': 0.39; 'called': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'most': 0.61; 'needing': 0.62; 'url:items': 0.84 Date: Mon, 23 Jul 2012 13:40:42 +0200 From: Philipp Hagemeister User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.5) Gecko/20120624 Icedove/10.0.5 MIME-Version: 1.0 To: Henrik Faber Subject: Re: dict: keys() and values() order guaranteed to be same? References: In-Reply-To: X-Enigmail-Version: 1.4 OpenPGP: id=FAFB085C Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigC72216755753D59E47BE29CD" Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343043655 news.xs4all.nl 6875 [2001:888:2000:d::a6]:34111 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25851 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC72216755753D59E47BE29CD Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/23/2012 01:23 PM, Henrik Faber wrote: > With an arbitrary dictionaty d, are d.keys() and d.values() > guaraneed to be in the same order? Yes. From the documentation[1]: If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond. In most cases, you should simply use items() though. Can you elaborate on the use case for needing both keys() and values(), where items() is not applicable? - Philipp [1] http://docs.python.org/library/stdtypes.html#dict.items --------------enigC72216755753D59E47BE29CD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEAREKAAYFAlANODwACgkQ9eq1gvr7CFy3LgCgokRrZS4Hem35lHGB710qzmZp UBYAoJ6Sn4KiJVu/ergs6UvgyW4eaBZ9 =Odni -----END PGP SIGNATURE----- --------------enigC72216755753D59E47BE29CD--