【发布时间】:2013-03-11 14:40:29
【问题描述】:
我用下面的代码get the caller's method name in the called method:
import inspect
def B():
outerframe = inspect.currentframe().f_back
functionname = outerframe.f_code.co_name
docstring = ??
return "caller's name: {0}, docsting: {1}".format(functionname, docstring)
def A():
"""docstring for A"""
return B()
print A()
但我也想在被调用方法中从调用者的方法中获取文档字符串。我该怎么做?
【问题讨论】:
标签: python introspection inspect