Is a reference exists from an attribute to the attribute holder?
Here is an example what I mean:
class classA(object):
def __init__(self):
pass
class classB(object):
def __init__(self):
self.a=classA()
def methodB(self):
print "ClassB-s methodB called"
b=classB()
a=b.a
Is it possible to reference b from a? I like to call methodB from a.
No, not really.
When you initialize
b.a, it becomes a reference to aclassAobject:To call the method, you could pass the parent object to
classA:From there, you have access to the whole parent.