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


Groups > comp.lang.python > #63953

Re: dictionary with tuples

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 <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.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 <emile@fenx.com>
Subject Re: dictionary with tuples
Date Tue, 14 Jan 2014 14:14:08 -0800
References <mailman.5476.1389733811.18130.python-list@python.org> <52d5aa4c$0$2196$426a74cc@news.free.fr> <GriBu.177658$Qi4.154313@fx11.iad>
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 <GriBu.177658$Qi4.154313@fx11.iad>
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 <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.5487.1389737708.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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 "<stdin>", line 1, in <module>
>>> 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

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


Thread

dictionary with tuples Igor Korot <ikorot01@gmail.com> - 2014-01-14 13:10 -0800
  Re: dictionary with tuples YBM <ybmess@nooos.fr.invalid> - 2014-01-14 22:21 +0100
    Re: dictionary with tuples Tobiah <toby@tobiah.org> - 2014-01-14 14:00 -0800
      Re: dictionary with tuples emile <emile@fenx.com> - 2014-01-14 14:14 -0800
      Re: dictionary with tuples YBM <ybmess@nooos.fr.invalid> - 2014-01-15 03:24 +0100

csiph-web