title: Why doesn't Python call instance method __init__() on instance creation but calls class-provided __init__() instead?
body: <p>I'm overring the <code>__new__()</code> method of a class to return a class instance which has a specific <code>__init__()</code> set. Python seems to call the class-provided <code>__init__()</code> method instead of the instance-specific method, although the Python documentation at</p>
  
  <p><a href="http://docs.python.org/reference/datamodel.html" rel="noreferrer">http://docs.python.org/reference/datamodel.html</a></p>
  
  <p>says:</p>
  
  <blockquote>
    <p>Typical implementations create a new instance of the class by invoking the
    superclass’s __new__() method using super(currentclass, cls).__new__(cls[, ...])
    with appropriate arguments and then modifying the newly-created instance as
    necessary before returning it.</p>
    
    <p>If __new__() returns an instance of cls, then the new instance’s __init__() method
    will be invoked like __init__(self[, ...]), where self is the new instance and the
    remaining arguments are the same as were passed to __new__().</p>
  </blockquote>
  
  <p>Here's my test code:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import new
  
  def myinit(self, *args, **kwargs):
      print "myinit called, args = %s, kwargs = %s" % (args, kwargs)
  
  
  class myclass(object):
      def __new__(cls, *args, **kwargs):
          ret = object.__new__(cls)
  
          ret.__init__ = new.instancemethod(myinit, ret, cls)
          return ret
  
      def __init__(self, *args, **kwargs):
          print "myclass.__init__ called, self.__init__ is %s" % self.__init__
          self.__init__(*args, **kwargs)
  
  a = myclass()
  </code></pre>
  
  <p>which outputs</p>
  
  <pre><code>$ python --version
  Python 2.6.6
  $ ./mytest.py
  myclass.__init__ called, self.__init__ is &lt;bound method myclass.myinit of &lt;__main__.myclass object at 0x7fa72155c790&gt;&gt;
  myinit called, args = (), kwargs = {}
  </code></pre>
  
  <p>It seems the only way to get <code>myinit()</code> to run, is to call it explicitly as <code>self.__init__()</code> inside <code>myclass.__init__()</code>.</p>