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


Groups > comp.lang.python > #64193

Re: Building and accessing an array of dictionaries

From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Building and accessing an array of dictionaries
Date 2014-01-17 20:53 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <lbc593$16s$1@reader1.panix.com> (permalink)
References <ad743135-a552-4cd6-ba1f-c492bf8bbb37@googlegroups.com> <CAPTjJmrMwTNmei6g92ArsdaWa6Y2Uw5ZFgpZXHkKWa=8M4U1Bw@mail.gmail.com> <mailman.5593.1389891738.18130.python-list@python.org>

Show all headers | View raw


On 2014-01-16, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> On 16/01/2014 09:48, Chris Angelico wrote:
>> On Thu, Jan 16, 2014 at 8:41 PM, Sam <lightaiyee@gmail.com> wrote:
>>> I would like to build an array of dictionaries. Most of the dictionary example on the net are for single dictionary.
>>>
>>> dict = {'a':'a','b':'b','c':'c'}
>>> dict2 = {'a':'a','b':'b','c':'c'}
>>> dict3 = {'a':'a','b':'b','c':'c'}
>>>
>>> arr = (dict,dict2,dict3)
>>>
>>> What is the syntax to access the value of dict3->'a'?
>>
>> Technically, that's a tuple of dictionaries
>
> For the benefit of lurkers, newbies or whatever it's the commas that 
> make the tuple, not the brackets.  

In _that_ example, yes.  There are other cases where it's the
brackets (sort of):

    foo('a','b','c')    # three separate string objects are passed

    foo(('a','b','c'))  # a single tuple object is passed    

-- 
Grant Edwards               grant.b.edwards        Yow! Being a BALD HERO
                                  at               is almost as FESTIVE as a
                              gmail.com            TATTOOED KNOCKWURST.

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


Thread

Building and accessing an array of dictionaries Sam <lightaiyee@gmail.com> - 2014-01-16 01:41 -0800
  Re: Building and accessing an array of dictionaries Chris Angelico <rosuav@gmail.com> - 2014-01-16 20:48 +1100
  Re: Building and accessing an array of dictionaries Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-16 11:52 +0200
  Re: Building and accessing an array of dictionaries Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-16 17:01 +0000
    Re: Building and accessing an array of dictionaries Grant Edwards <invalid@invalid.invalid> - 2014-01-17 20:53 +0000

csiph-web