pyqt4 - Detect method by self.sender() in Python -
is there way detect method has run other method detect object self.sender()?
for example have method enables checkboxes. on 1 page have 10 on other 15. depending on method b or c call method a, can define 2 scenarios in method a, rather copy code.
yes, there way. utilizes inspect module
import inspect  def echo():     """returns name of function called it"""     return inspect.getouterframes(inspect.currentframe(), 2)[1][3]  def caller():     return echo()  print(caller(), caller.func_name)   output:
('caller', 'caller')      
Comments
Post a Comment