PyDocs

Nav

Python Language Services

If

ast

class
  • If(test, body, orelse)
If(expr test, stmt* body, stmt* orelse)
1 Example
>>> print(ast.dump(ast.parse("""
... if x:
...    ...
... elif y:
...    ...
... else:
...    ...
... """), indent=4))
Module(
    body=[
        If(
            test=Name(id='x'),
            body=[
                Expr(
                    value=Constant(value=Ellipsis))],
            orelse=[
                If(
                    test=Name(id='y'),
                    body=[
                        Expr(
                            value=Constant(value=Ellipsis))],
                    orelse=[
                        Expr(
                            value=Constant(value=Ellipsis))])])])
from the Python docs
See Also
No see-alsos for ast/If
0 Notes
No notes for If