import inspect
def get_current_function_name():
return inspect.stack()[1][3]
class MyClass:
def function_one(self):
print("%s.%s invoked"%(self.__class__.__name__, get_current_function_name()))
if __name__ == "__main__":
myclass = MyClass()
myclass.function_one()
def wd():
print(get_current_function_name())
print(3)
wd()
python 获取当前调用函数名等log信息 - 道以万计 - 博客园 https://www.cnblogs.com/snow-backup/p/4152837.html