Sam writes:

> 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'?

This isn't a special case.

arr[2] to get the dictionary
arr[2]['a'] to get the value in the dictionary

'a' in arr[2] to find if there is such a key

arr[2].get('a') to get the value or None if the key isn't there
arr[2].get('a', 'd') to get a value even if the key isn't there

help(dict.get)

for key in arr[2]:
   # to iterate over the keys

The exact same mechanisms are used no matter where you get the
dictionary from.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to