title: Why can't I replace the __str__ method of a Python object with another function?
body: <p>Here is the code:</p>
  
  <pre><code>class Dummy(object):
      def __init__(self, v):
          self.ticker = v
  
  
  def main():
          def _assign_custom_str(x):
              def _show_ticker(t):                
                  return t.ticker
              x.__str__ = _show_ticker
              x.__repr__ = _show_ticker
              return x
  
  
      a = [Dummy(1), Dummy(2)]
  
      a1 = [_assign_custom_str(t) for t in a]
      print a1[1]
      # print a1[1].__str__ # test to if orig __str__ is replaced
  </code></pre>
  
  <p>I was hoping to see the output like this</p>
  
  <pre><code>2
  </code></pre>
  
  <p>However, instead I see the standard representation:</p>
  
  <pre><code>&lt;__main__.Dummy object at 0x01237730&gt;
  </code></pre>
  
  <p>Why?</p>