class documentation

class LocalsDictNodeNG(node_classes.LookupMixIn, node_classes.NodeNG): (source)

Known subclasses: astroid.nodes.scoped_nodes.ClassDef, astroid.nodes.scoped_nodes.ComprehensionScope, astroid.nodes.scoped_nodes.Lambda, astroid.nodes.scoped_nodes.Module

View In Hierarchy

this class provides locals handling common to Module, FunctionDef and ClassDef nodes, including a dict like interface for direct access to locals information
Method __contains__ Check if a local is defined in this scope.
Method __getitem__ The first node the defines the given local.
Method __iter__ Iterate over the names of locals defined in this scoped node.
Method add​_local​_node Append a child that should alter the locals of this scope node.
Method items Get the names of the locals and the node that defines the local.
Method keys The names of locals defined in this scoped node.
Method qname Get the 'qualified' name of the node.
Method scope The first parent node defining a new scope.
Method set​_local Define that the given name is declared in the given statement node.
Method values The nodes that define the locals in this scoped node.
Class Variable locals A map of the name of a local variable to the node defining the local.
Method _append​_node append a child, linking it in the tree
Method _scope​_lookup XXX method for interfacing the scope lookup

Inherited from LookupMixIn:

Method ilookup Lookup the inferred values of the given variable.
Method lookup Lookup where the given variable is assigned.
def __contains__(self, name): (source)
Check if a local is defined in this scope.
Parameters
name:strThe name of the local to check for.
Returns
boolTrue if this node has a local of the given name, False otherwise.
def __getitem__(self, item): (source)
The first node the defines the given local.
Parameters
item:strThe name of the locally defined object.
Raises
KeyErrorIf the name is not defined.
def __iter__(self): (source)
Iterate over the names of locals defined in this scoped node.
Returns
iterable(str)The names of the defined locals.
def add_local_node(self, child_node, name=None): (source)
Append a child that should alter the locals of this scope node.
Parameters
child​_node:NodeNGThe child node that will alter locals.
name:str or NoneThe name of the local that will be altered by the given child node.
def items(self): (source)
Get the names of the locals and the node that defines the local.
Returns
list(tuple(str, NodeNG))The names of locals and their associated node.
def keys(self): (source)
The names of locals defined in this scoped node.
Returns
list(str)The names of the defined locals.
def qname(self): (source)

Get the 'qualified' name of the node.

For example: module.name, module.class.name ...

Returns
strThe qualified name.
def scope(self): (source)
The first parent node defining a new scope.
Returns
Module or FunctionDef or ClassDef or Lambda or GenExprThe first parent scope node.
def set_local(self, name, stmt): (source)

Define that the given name is declared in the given statement node.

See Also

scope

Parameters
name:strThe name that is being defined.
stmt:NodeNGThe statement that defines the given name.
def values(self): (source)
The nodes that define the locals in this scoped node.
Returns
list(NodeNG)The nodes that define locals.
def _append_node(self, child): (source)
append a child, linking it in the tree
def _scope_lookup(self, node, name, offset=0): (source)
XXX method for interfacing the scope lookup