
1.对是否是模块,框架,函数等进行类型检查。
2.获取源码。
3.获取类或者函数的参数的信息
4.解析堆栈
模块文档:
This module encapsulates the interface provided by the internal special attributes (func_, co_, im_, tb_, etc.) in a friendlier fashion.It also provides some help for examining source code and class layout.
Here are some of the useful functions provided by this module:
ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(),isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(),isroutine() - check object types
getmembers() - get members of an object that satisfy a given condition
getfile(), getsourcefile(), getsource() - find an object’s source code
getdoc(), getcomments() - get documentation on an object
getmodule() - determine the module that an object came from
getclasstree() - arrange classes so as to represent their hierarchy
getargspec(), getargvalues(), getcallargs() - get info about function arguments
formatargspec(), formatargvalues() - format an argument spec
getouterframes(), getinnerframes() - get info about frames
currentframe() - get the current stack frame
stack(), trace() - get info about frames on the stack or in a traceback




近期评论