AssignName#

class astroid.nodes.AssignName(name: str, lineno: int, col_offset: int, parent: NodeNG, *, end_lineno: int | None, end_col_offset: int | None)[source]#

Bases: NoChildrenNode, LookupMixIn, ParentAssignNode

Variation of ast.Assign representing assignment to a name.

An AssignName is the name of something that is assigned to. This includes variables defined in a function signature or in a loop.

>>> import astroid
>>> node = astroid.extract_node('variable = range(10)')
>>> node
<Assign l.1 at 0x7effe1db8550>
>>> list(node.get_children())
[<AssignName.variable l.1 at 0x7effe1db8748>, <Call l.1 at 0x7effe1db8630>]
>>> list(node.get_children())[0].as_string()
'variable'
assigned_stmts(node: node_classes.AssignedStmtsPossibleNode = None, context: InferenceContext | None = None, assign_path: list[int] | None = None) Any#

Returns the assigned statement (non inferred) according to the assignment type. See astroid/protocols.py for actual implementation.

infer_lhs(**kwargs: _P.kwargs) Generator[InferenceResult, None, None]#
name#

The name that is assigned to.