On this page
symtable.Class
Up: symtable | Next: symtable.Function
Rel: symtable.Function, symtable.Symbol, symtable.SymbolTable, symtable.SymbolTableType
Ref: docs.python.org — symtable.Class
Tags: #public #python3 #stdlib #symtable
Import
import symtable
from symtable import Class
Signature & Overview
symtable.Class(raw_table, filename)
symtable.Class class.
Methods & Attributes
Class.get_children(self)— Return a list of the nested symbol tables.Class.get_id(self)— Return an identifier for the table.Class.get_identifiers(self)— Return a view object containing the names of symbols in the table.Class.get_lineno(self)— Return the number of the first line in the block for the table.Class.get_methods(self)— Return a tuple of methods declared in the class.Class.get_name(self)— Return the table's name.Class.get_symbols(self)— Return a list of Symbol instances for names in the table.Class.get_type(self)— Return the type of the symbol table.Class.has_children(self)— Return True if the block has nested namespaces.Class.is_nested(self)— Return True if the block is a nested class or function.Class.is_optimized(self)— Return True if the locals in the table are optimizable.Class.lookup(self, name)— Lookup a name in the table.
Usage
import symtable
tbl = symtable.symtable('class C:\n def m(self): pass', '<m>', 'exec')
cls_tbl = tbl.get_children()[0]
assert isinstance(cls_tbl, symtable.Class) and cls_tbl.get_name() == 'C'
Gotchas
- Represents a class scope: Check
tbl.get_type() == 'class'.
REPL Inspect
from symtable import Class
help(Class)
Linked from
Related notes
- 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/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