ListComp#

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

Bases: ComprehensionScope

Class representing an ast.ListComp node.

>>> import astroid
>>> node = astroid.extract_node('[thing for thing in things if thing]')
>>> node
<ListComp l.1 at 0x7f23b2e418d0>
bool_value(context: InferenceContext | None = None)[source]#

Determine the boolean value of this node.

Returns:

The boolean value of this node. For a ListComp this is always Uninferable.

Return type:

Uninferable

elt: NodeNG#

The element that forms the output of the expression.

generators: list[nodes.Comprehension]#

The generators that are looped through.

get_children()[source]#

Get the child nodes below this node.

locals: dict[str, list[InferenceResult]]#

A map of the name of a local variable to the node defining it.

postinit(elt: NodeNG, generators: list[nodes.Comprehension])[source]#