Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'filename:fname piece:signature': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'igor': 0.16; 'unpack': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'error': 0.23; 'paul': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'getting': 0.31; 'writes:': 0.31; 'stuff': 0.32; 'subject:the': 0.34; 'subject:with': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'even': 0.60; '"too': 0.84; 'received:50.22': 0.84 Date: Sun, 25 May 2014 08:07:14 -0500 From: Tim Chase To: Paul Rubin Subject: Re: Loop thru the dictionary with tuples In-Reply-To: <7x61kuc8uc.fsf@ruckus.brouhaha.com> References: <7x61kuc8uc.fsf@ruckus.brouhaha.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA512; boundary="Sig_/O2qfNsFI=g.UQF=_eevYSqz"; protocol="application/pgp-signature" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401023275 news.xs4all.nl 2869 [2001:888:2000:d::a6]:47123 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72004 --Sig_/O2qfNsFI=g.UQF=_eevYSqz Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On 2014-05-25 05:59, Paul Rubin wrote: > Igor Korot writes: > > for (key,value) in my_dict: > > #Do some stuff > > > > but I'm getting an error "Too many values to unpack". >=20 > Use=20 > for (key,value) in mydict.iteritems(): ... You can even use for ((k1,k2,k3), value) in mydict.iteritems(): ... if you need to unpack the key at the same time. -tkc --Sig_/O2qfNsFI=g.UQF=_eevYSqz Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBCgAGBQJTgesCAAoJEN385Nh6n9aQk4UH/3+OF3sZ9wa4WFEnQpnyUaEv vEebZwWSdvHreG+WYjuT3modBuXSLTLWlSJhYCaHYWZn0boYbcoOKuz+D4XCwJYD RLbuehlHCyumwfnwSsIpL0C2YxbUsV8z5E7ffIFaE2KSli9F52CXN2F0e6O4eCY1 0iBvNhxZU3hVCMRDJws/nXB1KCSTmWAYXNGQYTq8vYcYolLTM3EdjXOD02RsXLTr 9eru+QanL6Ccddzf9ehaMuP0ke/hY9sw36uRpNr13QxDMLC9P9aXi3ymz2eFO8Tl vvqfLMTtVlHr5QQO2dYuXW9DhwvxGnpue4PVo7Nixizj4EgYSA1/wtvR9IW1jUA= =4/Po -----END PGP SIGNATURE----- --Sig_/O2qfNsFI=g.UQF=_eevYSqz--