18.4 inspect:检查现场对象
inspect模块提供了一些函数来了解现场对象,包括模块、类、实例、函数和方法。这个模块中的函数可以用来获取一个函数的原始源代码,查看栈中一个方法的参数,以及抽取对生成源代码库文档有用的信息。
18.4.1 示例模块
这一节余下的例子都会使用这个示例文件example.py。
# This comment appears first
# and spans 2 lines.
# This comment does not show up in the output of getcomments().
"""Sample file to serve as the basis for inspect examples.
"""
def module_level_function(arg1,arg2='default',