symtable.Symbol

class symtable.Symbol

An entry in a SymbolTable corresponding to an identifier in the source. The constructor is not public.

get_name()

Return the symbol’s name.

is_referenced()

Return True if the symbol is used in its block.

is_imported()

Return True if the symbol is created from an import statement.

is_parameter()

Return True if the symbol is a parameter.

is_global()

Return True if the symbol is global.

is_declared_global()

Return True if the symbol is declared global with a global statement.

is_local()

Return True if the symbol is local to its block.

is_free()

Return True if the symbol is referenced in its block, but not assigned to.

is_assigned()

Return True if the symbol is assigned to in its block.

is_namespace()

Return True if name binding introduces new namespace.

If the name is used as the target of a function or class statement, this will be true.

For example:

>>> table = symtable.symtable("def some_func(): pass", "string", "exec")
>>> table.lookup("some_func").is_namespace()
True

Note that a single name can be bound to multiple objects. If the result is True, the name may also be bound to other objects, like an int or list, that does not introduce a new namespace.

get_namespaces()

Return a list of namespaces bound to this name.

get_namespace()

Return the namespace bound to this name. If more than one namespace is bound, ValueError is raised.

doc_python
2016-10-07 17:43:41
Comments
Leave a Comment

Please login to continue.