title: Using the UserDict module of python
body: <p>I am learning python from the book diveintopython .
  Before asking this question, I have consulted the answers given <a href="http://www.gossamer-threads.com/lists/python/bugs/749658" rel="nofollow">here</a> and read the documentation given <a href="https://docs.python.org/2/library/userdict.html" rel="nofollow">here</a>, but they don't clarify exactly what i want to know.</p>
  
  <p>In the book, a class UserDict has been written like,</p>
  
  <pre><code>class UserDict:
      def __init__(self, dict=None):
          self.data = {}
          if dict is not None: self.update(dict)
  </code></pre>
  
  <p>next another class FileInfo has been mentioned,</p>
  
  <pre><code>class FileInfo(UserDict):
      "store file metadata"
       def __init__(self, filename=None):
           UserDict.__init__(self)
           self["name"] = filename
  </code></pre>
  
  <p>My question is an object of the UserDict class has an attribute <strong>data</strong> which is a dictionary. When i create an object of FileInfo class, the object inherits this but why is the object itself a dictionary rather than having its <strong>data</strong> attribute as a dictionary?</p>
  
  <p>Please tell if there is something i have misunderstood here.</p>