Get parent function

后端 未结 4 442
不思量自难忘°
不思量自难忘° 2021-01-02 00:39

Is there a way to find what function called the current function? So for example:

def first():
    second()

def second():
    # print out here what function         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 01:09

    The inspect module allows for many forms of introspection including this one, but note that it's only recommended to use such information for purposes such as debugging, not as part of your production code's functionality. See the docs for all details.

提交回复
热议问题