Nested Dictionaries

Paul Prescod paul at prescod.net
Thu May 18 15:53:04 EDT 2000


Hello again Chris!

Chris Lada wrote:
> 
> 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}


outer['12345']['city']

On the other hand. Your "inner" dictionary seems more like an object in
its structure. You could also do this:

class Address: pass

Address.city="This City"
Address.state="This State"

outer['12345'].city


-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for himself
Just how compassionate can a Republican get before he has to leave the 
GOP and join Vegans for Global Justice? ... One moment, George W. Bush
is holding a get-to-know-you meeting with a bunch of gay Republicans.
The next he is holding forth on education or the environment ... It is
enough to make a red-blooded conservative choke on his spotted-owl
drumstick.     - April 29th, Economist




More information about the Python-list mailing list