Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; 'iterate': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'dict': 0.16; 'igor': 0.16; 'iterable': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'typeerror:': 0.16; '\xe9crit': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'bit': 0.19; '>>>': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'skip:( 20': 0.30; '"",': 0.31; 'file': 0.32; '(most': 0.33; 'subject:with': 0.35; 'but': 0.35; 'done': 0.36; 'doing': 0.36; 'hi,': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'more': 0.64; 'received:pacbell.net': 0.84; '2013,': 0.91; 'items,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: emile Subject: Re: dictionary with tuples Date: Tue, 14 Jan 2014 14:14:08 -0800 References: <52d5aa4c$0$2196$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: adsl-69-226-129-65.dsl.pltn13.pacbell.net User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389737708 news.xs4all.nl 2926 [2001:888:2000:d::a6]:55805 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63953 On 01/14/2014 02:00 PM, Tobiah wrote: > On 01/14/2014 01:21 PM, YBM wrote: >> Le 14/01/2014 22:10, Igor Korot a écrit : >>> Hi, ALL, >>> C:\Documents and Settings\Igor.FORDANWORK\Desktop\winpdb>python >>> Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit >>> (Intel)] on win32 >>> Type "help", "copyright", "credits" or "license" for more information. >>>>>> dict = {} >>>>>> dict[(1,2)] = ('a','b') >>>>>> dict[(3,4)] = ('c','d') >>>>>> for (key1,key2),(value1,value2) in dict: >>> ... print key1, " ", key2 >>> ... print value1, " ", value2 >>> ... >>> Traceback (most recent call last): >>> File "", line 1, in >>> TypeError: 'int' object is not iterable >>>>>> >>> >>> What am I doing wrong? >> >> for ... in dict: >> >> is a way to iterate through dictionnary items, >> >> what you want to do can be done so: >> >> for (key1,key2),(value1,value2) in dict.items(): >> >> >> > > But it's (key1, value1), (key2, value2) No it isn't. :) Emile