title: Format self, which is a dictionary
body: <p>How to make <code>format(self)</code> work in this case?</p>
  
  <pre><code>class Commit:
      number = None
      sha = None
      message = None
      identity = None
  
      def __init__(self, raw, number):
          r = raw.commits[number]
  
          self.number = number
          self.sha = r['sha']
          self.message = r['message']
          self.identity = raw.identities[r['identity']]
  
      def __str__(self):
          return """
  Commit {number} {sha}
  Message {message}
  Identity {identity}
  """.format(self)
  
      def __getitem__(self, attr):
          return getattr(self, attr)
      def __contains__(self, attr):
          return hasattr(self, attr)
  </code></pre>
  
  <p>If I then try to access individual attributes as</p>
  
  <pre><code>c = Commit(raw, 170)
  print(c['sha'])
  </code></pre>
  
  <p>for instance, it works. However, if I <code>print(c)</code> directly, it says:</p>
  
  <blockquote>
    <p>KeyError: 'number'</p>
  </blockquote>
  
  <p>I would have expected <code>format()</code> to pull the attributes it needs via <code>__getitem__()</code>.</p>
  
  <p>How to make it work?</p>