On this page
symtable.Function
Prev: symtable.Class | Up: symtable | Next: symtable.Symbol
Rel: symtable.Class, symtable.Symbol, symtable.SymbolTable, symtable.SymbolTableType
Ref: docs.python.org — symtable.Function
Tags: #public #python3 #stdlib #symtable
Import
import symtable
from symtable import Function
Signature & Overview
symtable.Function(raw_table, filename)
symtable.Function class.
Methods & Attributes
Function.get_children(self)— Return a list of the nested symbol tables.Function.get_frees(self)— Return a tuple of free variables in the function.Function.get_globals(self)— Return a tuple of globals in the function.Function.get_id(self)— Return an identifier for the table.Function.get_identifiers(self)— Return a view object containing the names of symbols in the table.Function.get_lineno(self)— Return the number of the first line in the block for the table.Function.get_locals(self)— Return a tuple of locals in the function.Function.get_name(self)— Return the table's name.Function.get_nonlocals(self)— Return a tuple of nonlocals in the function.Function.get_parameters(self)— Return a tuple of parameters to the function.Function.get_symbols(self)— Return a list of Symbol instances for names in the table.Function.get_type(self)— Return the type of the symbol table.Function.has_children(self)— Return True if the block has nested namespaces.Function.is_nested(self)— Return True if the block is a nested class or function.Function.is_optimized(self)— Return True if the locals in the table are optimizable.Function.lookup(self, name)— Lookup a name in the table.
Usage
import symtable
tbl = symtable.symtable('def f(a): b = a + 1', '<m>', 'exec')
fn_tbl = tbl.get_children()[0]
assert isinstance(fn_tbl, symtable.Function) and fn_tbl.get_parameters() == ('a',)
Gotchas
- Exposes
get_parameters(),get_locals(),get_frees(), andget_globals().
REPL Inspect
from symtable import Function
help(Function)
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/Symbol Linked here; links to this page; shared tags: #stdlib, #symtable
- tuts/python3/stdlib_module/symtable/SymbolTable 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