Identify class module from a class function
<p>I want to code the apply_method function:</p>

<pre><code>class A:
   def calc(self, num):
       return num 

def apply_method(class_method, *args, **kwargs):
    # Identify class module A from class_method: Is this possible?
    # Import class module A
    # Create an instance of the class A, say obj
    # return obj.class_method(*args, **kwargs)
    pass

class_method = A.calc
input_num = 5
return apply_method(class_method, 5) 
</code></pre>

<p>It is guaranteed that the module for class A is available to be imported wherever apply_method gets called. </p>

<p>Is all the information necessary to create <code>apply_method</code> available inside <code>class_method</code>?</p>

<p>The reason I need this: apply_method is a callback. The callback only contains a function and parameters. The callback needs to be made across hundreds of different classes. In the absence of this generic method, I will need to handle callbacks very specifically for each of the classes.</p>
