title: Python: inject new functions into an instance of class?
body: <p>I tried to manipulate the <code>__mro__</code> but it it read-only</p>
  
  <p>The use case is as follow:</p>
  
  <p>The Connection object created from pyodbc (a DBAPI) used to provide a property called 'autocommit'. Lately I have wrapped a SQLAlchemy db connection pool around the pyodbc for better resource management. The new db pool will return a <code>_ConnectionFairy</code>, a connection proxy class, which no longer exposes the <code>autocommit</code> property. </p>
  
  <p>I would very much want to leave the thrid party code alone. So inheritance of <code>_ConnectionFairy</code> is not really an option (I might need to override the Pool class to change how it creates a connection proxy. For source code, please see <a href="http://www.java2s.com/Open-Source/Python/Database/SQLAlchemy/SQLAlchemy-0.6.0/lib/sqlalchemy/pool.py.htm" rel="nofollow">here</a>)</p>
  
  <p>A rather not-so elegant solution is to change all occurance of </p>
  
  <pre><code>conn.autocommit = True
  </code></pre>
  
  <p>to </p>
  
  <pre><code># original connection object is accessible via .connection
  conn.connection.autocommit = True 
  </code></pre>
  
  <p>So, I would like to know if it is possible at all to inject a set of getter, setter and property to an instance of <code>_ConnectionFairy</code></p>