Nested Dictionaries

Ruud de Rooij * at spam.ruud.org
Thu May 18 15:56:02 EDT 2000


"Chris Lada" <chris.lada at westgroup.com> writes:

> 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
> '12345'
> 
> tempCity = temp['city']   # yields the city value of the inner dictionary of
> the
>                                    #  outer dictionary entry with the key
> '12345'
> 
> Is there an easier or more direct way of doing this ?

outer['12345']['city']

	- Ruud de Rooij.
-- 
ruud de rooij | *@spam.ruud.org | http://ruud.org



More information about the Python-list mailing list