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
Trueif the symbol is used in its block.
-
is_imported() -
Return
Trueif the symbol is created from an import statement.
-
is_parameter() -
Return
Trueif the symbol is a parameter.
-
is_global() -
Return
Trueif the symbol is global.
-
is_declared_global() -
Return
Trueif the symbol is declared global with a global statement.
-
is_local() -
Return
Trueif the symbol is local to its block.
-
is_free() -
Return
Trueif the symbol is referenced in its block, but not assigned to.
-
is_assigned() -
Return
Trueif the symbol is assigned to in its block.
-
is_namespace() -
Return
Trueif 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() TrueNote 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,
ValueErroris raised.
Please login to continue.