Building and accessing an array of dictionaries

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Jan 16 12:01:52 EST 2014


On 16/01/2014 09:48, Chris Angelico wrote:
> On Thu, Jan 16, 2014 at 8:41 PM, Sam <lightaiyee at 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.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list