While

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

Bases: MultiLineWithElseBlockNode, Statement

Class representing an ast.While node.

>>> import astroid
>>> node = astroid.extract_node('''
while condition():
    print("True")
''')
>>> node
<While l.2 at 0x7f23b2e4e390>
property blockstart_tolineno

The line on which the beginning of this block ends.

Type:

int

body: list[NodeNG]

The contents of the loop.

get_children()[source]

Get the child nodes below this node.

orelse: list[NodeNG]

The contents of the else block.

postinit(test: NodeNG, body: list[NodeNG], orelse: list[NodeNG]) None[source]
test: NodeNG

The condition that the loop tests.