I wonder if there is a way in Python to access the class which the object which the method belongs to is being called from. For example:
class A:
    def __init__(self):
        self.b = B()
    def foo(self):
        print('A')
class B:
    def bar(self):
        <something here>.foo()
a = A()
a.b.bar()
Basically I would like B's method bar to invoke A's method foo. And if b was an attribute of some other class C, to invoke C's version of foo instead.
 
    