title: Python method resolution mystery
body: <p>I can't figure out why this program is failing.</p>
  
  <pre><code>#!/usr/bin/env python
  from __future__ import division, print_function
  from future_builtins import *
  import types
  import libui as ui
  from PyQt4 import QtCore
  import sip
  
  p = ui.QPoint()
  q = QtCore.QPoint()
  
  def _q_getattr(self, attr):
      print("get %s" % attr)
      value = getattr(sip.wrapinstance(self.myself(), QtCore.QPoint), attr)
      print("get2 %s returned %s" % (attr, value))
      return value
  
  p.__getattr__ = types.MethodType(_q_getattr, p)
  
  print(p.__getattr__('x')())  # Works!  Prints "0"
  print(p.x())  # AttributeError: 'QPoint' object has no attribute 'x'
  </code></pre>
  
  <p>I used Boost.Python to create libui, which exposes the class QPoint.  I aso included PyQt4, which has a sip-exposed QPoint.  I'm trying to accomplish a mapping between the two types.</p>
  
  <p>I checked that <code>p</code> is a new-style class, so why isn't <code>__getattr__</code> being called for <code>p.x()</code>?</p>