How can one find Class of calling function in python?
<p>I am trying to determine the owning class of a calling function in python. For example, I have two classes, ClassA and ClassB.  I want to know when classb_instance.call_class_a_method() is the caller of class_a.class_a_method() such that:</p>

<pre><code>class ClassA(object):
    def class_a_method(self):
        # Some unknown process would occur here to
        # define caller. 
        if caller.__class__ == ClassB:
            print 'ClassB is calling.'
        else:
            print 'ClassB is not calling.'

class ClassB(object):
    def __init__(self):
        self.class_a_instance = ClassA()
    def call_class_a_method(self):
        self.class_a_instance.class_a_method()

classa_instance = ClassA()
classa_instance.class_a_method()
classb_instance = ClassB()
classb_instance.call_class_a_method()
</code></pre>

<p>the output would be:</p>

<pre><code>'ClassB is not calling.'
'ClassB is calling.'
</code></pre>

<p>It seems as though <strong>inspect</strong> should be able to do this, but I cant puzzle out how.</p>
