title: How can I intercept calls to python's "magic" methods in new style classes?
body: <p>I'm trying to intercept calls to python's double underscore magic methods in new style classes. This is a trivial example but it show's the intent:</p>
  
  <pre><code>class ShowMeList(object):
      def __init__(self, it):
          self._data = list(it)
  
      def __getattr__(self, name):
          attr = object.__getattribute__(self._data, name)
          if callable(attr):
              def wrapper(*a, **kw):
                  print "before the call"
                  result = attr(*a, **kw)
                  print "after the call"
                  return result
              return wrapper
          return attr
  </code></pre>
  
  <p>If I use that proxy object around list I get the expected behavior for non-magic methods but my wrapper function is never called for magic methods.</p>
  
  <pre><code>&gt;&gt;&gt; l = ShowMeList(range(8))
  
  &gt;&gt;&gt; l #call to __repr__
  &lt;__main__.ShowMeList object at 0x9640eac&gt;
  
  &gt;&gt;&gt; l.append(9)
  before the call
  after the call
  
  &gt;&gt; len(l._data)
  9
  </code></pre>
  
  <p>If I don't inherit from object (first line <code>class ShowMeList:</code>) everything works as expected:</p>
  
  <pre><code>&gt;&gt;&gt; l = ShowMeList(range(8))
  
  &gt;&gt;&gt; l #call to __repr__
  before the call
  after the call
  [0, 1, 2, 3, 4, 5, 6, 7]
  
  &gt;&gt;&gt; l.append(9)
  before the call
  after the call
  
  &gt;&gt; len(l._data)
  9
  </code></pre>
  
  <p>How do I accomplish this intercept with new style classes?</p>