title: Recursively turn all dicts inside a dict into a custom Dict class
body: <p>Here's a class that returns <code>None</code> when a key doesn't exist (as opposed to crashing the entire application) and allows accessing keys like attributes:</p>
  <pre><code>class Dict(dict):  # a dictionary that returns @None when a key doesn't exist (as opposed to crashing the entire application...) and allows accessing keys like attributes
    def __init__(   self, *args,**kwargs):
      super(Dict,self).__init__(*args,**kwargs)
      self.__dict__ = self  # this allows accessing keys like attributes
    def __getitem__(self, key,default=None):
      return dict.get(self, key,default)  # return None if the key exists not
    def __getattribute__(self, attr):  # return None if the attribute exists not
      try:                    return object.__getattribute__(self,attr)
      except AttributeError:  return None
  </code></pre>
  <p>You can use it like so:</p>
  <pre><code>x = Dict({'a':0, 'b':1})
  print(x['a'], x.a)
  print(x['c'], x.c)
  </code></pre>
  <p>The problem is that this doesn't get applied recursively:</p>
  <pre><code>x = Dict({'a':{'aa':0x00}, 'b':1})
  print(x['a'], x.a)
  print(x.a['aa'])
  print(x.a.aa)  # AttributeError: 'dict' object has no attribute 'aa'
  </code></pre>
  <p>How can this be fixed.</p>