title: Accessing dict keys like an attribute?
body: <p>I find it more convenient to access dict keys as <code>obj.foo</code> instead of <code>obj['foo']</code>, so I wrote this snippet:</p>
  
  <pre><code>class AttributeDict(dict):
      def __getattr__(self, attr):
          return self[attr]
      def __setattr__(self, attr, value):
          self[attr] = value
  </code></pre>
  
  <p>However, I assume that there must be some reason that Python doesn't provide this functionality out of the box. What would be the caveats and pitfalls of accessing dict keys in this manner?</p>