Comprehension¶
- class astroid.nodes.Comprehension(lineno: int | None, col_offset: int | None, parent: NodeNG | None, *, end_lineno: int | None, end_col_offset: int | None)[source]¶
Bases:
NodeNG
Class representing an
ast.comprehension
node.A
Comprehension
indicates the loop inside any type of comprehension including generator expressions.>>> import astroid >>> node = astroid.extract_node('[x for x in some_values]') >>> list(node.get_children()) [<Name.x l.1 at 0x7f23b2e352b0>, <Comprehension l.1 at 0x7f23b2e35320>] >>> list(node.get_children())[1].as_string() 'for x in some_values'
- assign_type()[source]¶
The type of assignment that this node performs.
- Returns:
The assignment type.
- Return type:
- assigned_stmts(**kwargs: _P.kwargs) Generator[InferenceResult] ¶
Returns the assigned statement (non inferred) according to the assignment type. See astroid/protocols.py for actual implementation.