On this page
symtable.SymbolTable
Prev: symtable.Symbol | Up: symtable | Next: symtable.SymbolTableType
Rel: symtable.Class, symtable.Function, symtable.Symbol, symtable.SymbolTableType
Ref: docs.python.org — symtable.SymbolTable
Tags: #public #python3 #stdlib #symtable
Import
import symtable
from symtable import SymbolTable
Signature & Overview
symtable.SymbolTable(raw_table, filename)
symtable.SymbolTable class.
Methods & Attributes
SymbolTable.get_children(self)— Return a list of the nested symbol tables.SymbolTable.get_id(self)— Return an identifier for the table.SymbolTable.get_identifiers(self)— Return a view object containing the names of symbols in the table.SymbolTable.get_lineno(self)— Return the number of the first line in the block for the table.SymbolTable.get_name(self)— Return the table's name.SymbolTable.get_symbols(self)— Return a list of Symbol instances for names in the table.SymbolTable.get_type(self)— Return the type of the symbol table.SymbolTable.has_children(self)— Return True if the block has nested namespaces.SymbolTable.is_nested(self)— Return True if the block is a nested class or function.SymbolTable.is_optimized(self)— Return True if the locals in the table are optimizable.SymbolTable.lookup(self, name)— Lookup a name in the table.
Usage
import symtable
tbl = symtable.symtable('x = 1', '<m>', 'exec')
assert isinstance(tbl, symtable.SymbolTable) and 'x' in tbl.get_identifiers()
Gotchas
- Walk nested scopes recursively with
tbl.get_children().
REPL Inspect
from symtable import SymbolTable
help(SymbolTable)
Linked from
Related notes
- tuts/python3/stdlib_module/symtable/Class Linked here; links to this page; shared tags: #stdlib, #symtable
- tuts/python3/stdlib_module/symtable/Function Linked here; links to this page; shared tags: #stdlib, #symtable
- tuts/python3/stdlib_module/symtable/Symbol Linked here; links to this page; shared tags: #stdlib, #symtable
- tuts/python3/stdlib_module/symtable/SymbolTableType Linked here; links to this page; shared tags: #stdlib, #symtable
- tuts/python3/stdlib_module/symtable/symtable Linked here; links to this page; shared tags: #stdlib, #symtable
- tuts/python3/stdlib_module/symtable links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib