title: Overriding special methods on an instance
body: <p>I hope someone can answer this that has a good deep understanding of Python :)</p>
  
  <p>Consider the following code:</p>
  
  <pre><code>&gt;&gt;&gt; class A(object):
  ...     pass
  ...
  &gt;&gt;&gt; def __repr__(self):
  ...     return "A"
  ...
  &gt;&gt;&gt; from types import MethodType
  &gt;&gt;&gt; a = A()
  &gt;&gt;&gt; a
  &lt;__main__.A object at 0x00AC6990&gt;
  &gt;&gt;&gt; repr(a)
  '&lt;__main__.A object at 0x00AC6990&gt;'
  &gt;&gt;&gt; setattr(a, "__repr__", MethodType(__repr__, a, a.__class__))
  &gt;&gt;&gt; a
  &lt;__main__.A object at 0x00AC6990&gt;
  &gt;&gt;&gt; repr(a)
  '&lt;__main__.A object at 0x00AC6990&gt;'
  &gt;&gt;&gt;
  </code></pre>
  
  <p>Notice how repr(a) does not yield the expected result of "A" ?
  I want to know why this is the case and if there is a way to achieve this...</p>
  
  <p>I contrast, the following example works however (<em>Maybe because we're not trying to override a special method?</em>):</p>
  
  <pre><code>&gt;&gt;&gt; class A(object):
  ...     def foo(self):
  ...             return "foo"
  ...
  &gt;&gt;&gt; def bar(self):
  ...     return "bar"
  ...
  &gt;&gt;&gt; from types import MethodType
  &gt;&gt;&gt; a = A()
  &gt;&gt;&gt; a.foo()
  'foo'
  &gt;&gt;&gt; setattr(a, "foo", MethodType(bar, a, a.__class__))
  &gt;&gt;&gt; a.foo()
  'bar'
  &gt;&gt;&gt;
  </code></pre>