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

Bases: LookupMixIn, ParentAssignNode

Variation of ast.Assign representing assignment to an attribute.

>>> import astroid
>>> node = astroid.extract_node('self.attribute = range(10)')
>>> node
<Assign l.1 at 0x7effe1d521d0>
>>> list(node.get_children())
[<AssignAttr.attribute l.1 at 0x7effe1d52320>, <Call l.1 at 0x7effe1d522e8>]
>>> list(node.get_children())[0].as_string()
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/ for actual implementation.


The name of the attribute being assigned to.

expr: NodeNG#

Get the child nodes below this node.

infer_lhs(**kwargs: _P.kwargs) Generator[InferenceResult, None, None]#
postinit(expr: NodeNG) None[source]#