GeneratorExp#

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

Bases: ComprehensionScope

Class representing an ast.GeneratorExp node.

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

Determine the boolean value of this node.

Returns:

The boolean value of this node. For a GeneratorExp this is always True.

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 the local.

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