title: Switchable dot access to Python dicts?
body: <p>I haven't seen a toggleable version of dictionary dot-access yet.</p>
  
  <p>My first-pass attempt here doesn't work:</p>
  
  <pre><code>class DottableDict (dict):
  
      def allowDotting (self, state=True):
          if state:
              self.__setattr__ = dict.__setitem__
              self.__getattr__ = dict.__getitem__
          else:
              del self.__setattr__
              del self.__getattr__
  
  &gt;&gt;&gt; import dot
  &gt;&gt;&gt; d = dot.DottableDict()
  &gt;&gt;&gt; d.allowDotting()
  &gt;&gt;&gt; d.foo = 'bar'
  &gt;&gt;&gt; d
  {}
  &gt;&gt;&gt; d.foo
  'bar'
  &gt;&gt;&gt; d.__dict__
  {'__setattr__': &lt;slot wrapper '__setitem__' of 'dict' objects&gt;, 'foo': 'bar',
  '__getattr__': &lt;method '__getitem__' of 'dict' objects&gt;}
  &gt;&gt;&gt; d.allowDotting(False)
  &gt;&gt;&gt; d.__dict__
  {'foo': 'bar'}
  </code></pre>
  
  <p>I think the signatures don't match up between setattr and setitem.</p>
  
  <p>My second pass also seems like it should work, but fails in the same ways:</p>
  
  <pre><code>class DottableDict (dict):
  
      def dotGet (self, attr):
          return dict.__getitem__(self, attr)
  
      def dotSet (self, attr, value):
          return dict.__setitem__(self, attr, value)
  
      def allowDotting (self, state=True):
          if state:
              self.__getattr__ = self.dotGet
              self.__setattr__ = self.dotSet
          else:
              del self.__setattr__
              del self.__getattr__
  </code></pre>