Python - Kann ich auf das Objekt zugreifen, das mich anruft?
Wenn ich das habe:
class A:
def callFunction(self, obj):
obj.otherFunction()
class B:
def callFunction(self, obj):
obj.otherFunction()
class C:
def otherFunction(self):
# here I wan't to have acces to the instance of A or B who call me.
...
# in main or other object (not matter where)
a = A()
b = B()
c = C()
a.callFunction(c) # How 'c' know that is called by an instance of A...
b.callFunction(c) # ... or B
Trotz des Designs oder anderer Probleme ist dies nur eine Frage eines fragenden Verstandes.
Hinweis: Dies muss ohne Änderung erfolgen otherFunction
Unterschrift