1、code结构:
class code(object)
| code(argcount, nlocals, stacksize, flags, codestring, constants, names,
| varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])
|
| Create a code object. Not for the faint of heart.
|
| Methods defined here:
|
| __cmp__(...)
| x.__cmp__(y) <==> cmp(x,y)
|
| __eq__(...)
| x.__eq__(y) <==> x==y
|
| __ge__(...)
| x.__ge__(y) <==> x>=y
|
| __getattribute__(...)
| x.__getattribute__('name') <==> x.name
|
| __gt__(...)
| x.__gt__(y) <==> x>y
|
| __hash__(...)
| x.__hash__() <==> hash(x)
|
| __le__(...)
| x.__le__(y) <==> x<=y
|
| __lt__(...)
| x.__lt__(y) <==> x<y
|
| __ne__(...)
| x.__ne__(y) <==> x!=y
|
| __repr__(...)
| x.__repr__() <==> repr(x)
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| co_argcount #CodeBlock中位置参数的个数,即:在调用时出现的位置参数的个数(不包含可变参数*varargs)
|
| co_cellvars #(cellvars:被内层代码所约束的变量):在本代码段中被赋值,且被内层代码段(嵌套的函数中)引用的变量
|
| co_code #Code Block编译所得的字节码指令序列
|
| co_consts #Code Block中的所有常量的元组
|
| co_filename #Code Block所对应的的.py文件的完整路径
|
| co_firstlineno #Code Block在对应的.py文件中的起始行
|
| co_flags #不知道什么意思
|
| co_freevars #(freevars:*变量):在本代码段中被引用,在外层代码段中被赋值的变量
|
| co_lnotab #字节码指令与.pyc文件中的source code行号的对于关系,不明白
|
| co_name #Code Block的名字,,通常是函数名或类名
|
| co_names #Code Block中的所有符号(名字)的元组,不懂
|
| co_nlocals #Code Block中的所有局部变量的个数,包括code block的参数(co_argcount+co_kwonlyargcount+可变参数个数)+code block内的局部变量
|
| co_stacksize #执行该段Code Block需要的栈空间数,怎么看?
|
| co_varnames #在本代码段中被赋值,但没有被内层代码段引用的变量.(内嵌的函数名也算。不包含内嵌函数中的局部变量)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __new__ = <built-in method __new__ of type object>
| T.__new__(S, ...) -> a new object with type S, a subtype of T
本地实例: