For example :

class A: def atr_one(self): self.atr_two() def atr_two(self): print('atr_two') # Как узнать кто его вызывает 
  • Or in this way I do not know who caused it, since the desired object is inside another? - Valvea 5:58 pm

2 answers 2

 import inspect def f1(): f2() def f2(): print 'caller name:', inspect.stack()[1][3] f1() 

source: https://stackoverflow.com/questions/2654113/how-to-get-the-callers-method-name-in-the-called-method

     class A: def atr_one(self): self.atr_two("def atr_one") def atr_two(self, text="def atr_two"): print(text) # Как узнать кто его вызывает a = A() a.atr_one() def atr_one a.atr_two() def atr_two 
    • Just for clarity, go! But not at all, then! It is necessary to find out what kind of object it is. And this is how cunning comes in the form of a variable. - Valvea pm
    • although it will solve my problem, but I would still like to know the name of the objects. - Valvea 6:02 pm