title: How to use dot notation for dict in python?
body: <p>I'm very new to python and I wish I could do <code>.</code> notation to access values of a <code>dict</code>. </p>
  
  <p>Lets say I have <code>test</code> like this:</p>
  
  <pre><code>&gt;&gt;&gt; test = dict()
  &gt;&gt;&gt; test['name'] = 'value'
  &gt;&gt;&gt; print(test['name'])
  value
  </code></pre>
  
  <p>But I wish I could do <code>test.name</code> to get <code>value</code>. Infact I did it by overriding the <code>__getattr__</code> method in my class like this:</p>
  
  <pre><code>class JuspayObject:
  
      def __init__(self,response):
          self.__dict__['_response'] = response
  
      def __getattr__(self,key): 
          try:
              return self._response[key]
          except KeyError,err:
              sys.stderr.write('Sorry no key matches')
  </code></pre>
  
  <p>and this works! when I do:</p>
  
  <pre><code>test.name // I get value.
  </code></pre>
  
  <p>But the problem is when I just print <code>test</code> alone I get the error as:</p>
  
  <pre><code>'Sorry no key matches'
  </code></pre>
  
  <p>Why is this happening?</p>