title: python __str__ for an object
body: <p>While trying to figure out how BeautifulSoup works, I incidentally learnt the <code>__str__</code> method (I'm new to python). So if I did not misperceived then the <code>__str__</code> method helps to shape how the class will be represented if printed out. For instance:</p>
  
  <pre><code>class Foo:
      def __str__(self):
          return "bar"
  
  &gt;&gt;&gt; x = Foo()
  &gt;&gt;&gt; print x
  bar
  </code></pre>
  
  <p>Right? So asserting that I'm right, is it possible to override the <code>__str__</code> method of a list of dictionaries? I mean say that in class Foo you have:</p>
  
  <pre><code>class Foo:
     def __init__(self):
        self.l = [{"Susan": ("Boyle", 50, "alive")}, {"Albert": ("Speer", 106, "dead")}]
  </code></pre>
  
  <p>Now is it possible to have the following outcome?</p>
  
  <pre><code>&gt;&gt;&gt; x = Foo()
  &gt;&gt;&gt; print x.l
  "Susan Boyle is 50 and alive. Albert Speer is 106 and dead."
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Considering agf's solution, how can I access the dictionary once again? I mean if I define <code>__str__</code> method then apparently I should define something else to retrieve the dictionary as it is. Please consider the following example:</p>
  
  <pre><code>class PClass(dict):
      def __str__(self):
          # code to return the result that I want 
  
  class Foo:
      def __init__(self):
          self.l = PClass({"Susan": ["Boyle", ........ })
  
  &gt;&gt;&gt; x = Foo()
  &gt;&gt;&gt; print x.l 
  # result that works great
  &gt;&gt;&gt; y = x.l["Susan"] # this would not work. How can I achieve it? 
  </code></pre>