symtable
— 访问编译器的符号表
¶
源代码: Lib/symtable.py
Symbol tables are generated by the compiler from AST just before bytecode is generated. The symbol table is responsible for calculating the scope of every identifier in the code.
symtable
provides an interface to examine these tables.
生成符号表 ¶
- symtable. symtable ( code , filename , compile_type ) ¶
-
Return the toplevel
SymbolTablefor the Python source code . filename is the name of the file containing the code. compile_type is like the mode 自变量对于compile().
审查符号表 ¶
- class symtable. SymbolTableType ¶
-
An enumeration indicating the type of a
SymbolTable对象。- MODULE = "module" ¶
-
Used for the symbol table of a module.
- FUNCTION = "function" ¶
-
Used for the symbol table of a function.
- CLASS = "class" ¶
-
Used for the symbol table of a class.
The following members refer to different flavors of annotation scopes .
- ANNOTATION = "annotation" ¶
-
Used for annotations if
from __future__ import annotationsis active.
- TYPE_PARAMETERS = "type parameters" ¶
-
Used for the symbol table of generic functions or generic classes .
- TYPE_VARIABLE = "type variable" ¶
-
Used for the symbol table of the bound, the constraint tuple or the default value of a single type variable in the formal sense, i.e., a TypeVar, a TypeVarTuple or a ParamSpec object (the latter two do not support a bound or a constraint tuple).
3.13 版添加。