Nested Dictionaries

Chris Lada chris.lada at
Thu May 18 15:42:04 EDT 2000

Is there some where of directly accessing information in a dictionary which
occurs as part of another dictionary i.e.:

inner = {'city':'This City','state':'This State'}
outer = {'12345':inner}

In order to access the 'city' information in the 12345 dictionary entry, I
do the following:

temp = outer['12345']    # yields the outer dictionary entry with the key

tempCity = temp['city']   # yields the city value of the inner dictionary of
                                   #  outer dictionary entry with the key

Is there an easier or more direct way of doing this ?


More information about the Python-list mailing list