title: Python override dictionary access methods
body: <p>I have a class <code>devices</code> that inherits from the dict class. devices is a dictionary of dictionaries. I would like to access its keys and values by using a method call syntax, and as well as using the normal syntax. i.e.</p>
  
  <pre><code>class Devices(dict):
      def __init__(self):
          self['device'] = {'name':'device_name'}
      def __getattr__(self, name):
          value = self[name]
          return value
  ...
  
  mydevices = Devices()
  mydevice = mydevices.device #works and mydevices['device'] also works
  
  #But what code do I need for the following?
  name = mydevices.device.name 
  mydevices.device.name = 'another_name'
  </code></pre>
  
  <p>I know that if I override the <code>__getattr__</code> and <code>__setattr__</code> methods I can achieve this, but as you can see from my code I am not sure how to access a nested dictionary. 
  Does anyone know how to achieve this?</p>
  
  <p>thanks, labjunky</p>