Python symtable Module
Example
Examine symbols in Python code:
import symtable
code = 'x = 10'
table = symtable.symtable(code, 'string', 'exec')
symbols = table.get_symbols()
print(f'Found {len(symbols)} symbol(s)')
Try it Yourself »
Definition and Usage
The symtable module provides access to the compiler's internal symbol tables.
Use it to analyze Python source code, examine variable scopes, or build code analysis tools.
Members
| Member | Description |
|---|---|
| Class | Class representing a class symbol table. |
| Function | Class representing a function symbol table. |
| Symbol | Class representing a symbol in a symbol table. |
| SymbolTable | Base class for symbol tables. |
| symtable() | Return the top-level symbol table for Python source code. |