How To Reference Creator Object In Python?
I have a question. There are two classes: A and B. A creates object of type B. So from A, it is easy to access methods of B, but how can I access methods of object A from object B?
Solution 1:
Pass the creator as an argument to the constructor:
classB(object):def__init__(self, creator):
self._creator = creator # or do something else with it
Use as:
classA(object):defsomemethod(self):
b = B(self)
Post a Comment for "How To Reference Creator Object In Python?"