List#

class astroid.nodes.List(ctx: Context | None = None, lineno: int | None = None, col_offset: int | None = None, parent: NodeNG | None = None, *, end_lineno: int | None = None, end_col_offset: int | None = None)[source]#

Bases: BaseContainer

Class representing an ast.List node.

>>> import astroid
>>> node = astroid.extract_node('[1, 2, 3]')
>>> node
<List.list l.1 at 0x7f23b2e9e128>
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.

ctx: Context | None#

Whether the list is assigned to or loaded from.

getitem(index, context: InferenceContext | None = None)[source]#

Get an item from this node.

Parameters:

index (Const or Slice) – The node to use as a subscript index.

infer_binary_op(**kwargs: _P.kwargs) Generator[InferenceResult, None, None]#
infer_unary_op(op)#
pytype() Literal['builtins.list'][source]#

Get the name of the type that this node represents.

Returns:

The name of the type.