title: Pass object along with object method to function
body: <p>I know that in Python that if, say you want to pass two parameters to a function, one an object, and another that specifies the instance method that must be called on the object, the user can easily pass the object itself, along with the name of the method (as a string) then use the <code>getattr</code> function on the object and the string to call the method on the object. </p>
  
  <p>Now, I want to know if there is a way (as in C++, for those who know) where you pass the object, as well as the actual method (or rather a reference to the method, but not the method name as a string). An example:</p>
  
  <pre><code>def func(obj, method):
      obj.method();
  </code></pre>
  
  <p>I have tried passing it as follows:</p>
  
  <pre><code>func(obj, obj.method)
  </code></pre>
  
  <p>or as</p>
  
  <pre><code>func(obj, classname.method)
  </code></pre>
  
  <p>but neither works (the second one I know was a bit of a long shot, but I tried it anyway)</p>
  
  <p>I know that you can also just define a function that just accepts the method, then call it as </p>
  
  <pre><code>func2(obj.method)
  </code></pre>
  
  <p>but I am specifically asking about instances where you want a reference to the object itself, as well as a <em>reference</em> to a desired class instance (not static) method to be called on the object.</p>
  
  <p>EDIT:</p>
  
  <p>For those that are interested, I found quite an elegant way 'inspired' by the accepted answer below. I simply defined <code>func</code> as</p>
  
  <pre><code>def func(obj, method):
       #more code here
       method(obj, parameter);     #call method on object obj
  </code></pre>
  
  <p>and called it as</p>
  
  <pre><code>func(obj_ref, obj_class.method);
  </code></pre>
  
  <p>where obj_class is the actual class that obj_ref is an instance of.</p>