title: Can I create an object that receives arbitrary method invocation in python?
body: <p>In python, can I create a Class that, when instantiated, can receive arbitrary method invocation? I have read <a href="https://stackoverflow.com/questions/852308/how-the-method-resolution-and-invocation-works-internally-in-python">this</a> but couldn't put the pieces together</p>
  
  <p>I guess it has something to do with the <code>attribute lookup</code>. For a class <code>Foo</code>:</p>
  
  <pre><code>class Foo(object):
    def bar(self, a):
      print a
  </code></pre>
  
  <p>The class attribute can be obtained by <code>print Foo.__dict__</code>, which gives</p>
  
  <pre><code>{'__dict__': &lt;attribute '__dict__' of 'Foo' objects&gt;, '__weakref__': &lt;attribute '__weakref__' of 'Foo' objects&gt;, '__module__': '__main__', 'bar': &lt;function bar at 0x7facd91dac80&gt;, '__doc__': None}
  </code></pre>
  
  <p>So this code is valid</p>
  
  <pre><code>foo = Foo()
  foo.bar("xxx")
  </code></pre>
  
  <p>If I call <code>foo.someRandomMethod()</code>, <code>AttributeError: 'Foo' object has no attribute 'someRandomMethod'</code> would be resulted.</p>
  
  <p>I want <code>foo</code> object to receive any random invocations and defaults to no-op, ie.</p>
  
  <pre><code>def func():
      pass
  </code></pre>
  
  <p>How can I achieve this? I want this behaviour to mock an object for testing.</p>