On this page
  1. ast.AST
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

ast.AST

Prev: ast.Assign | Up: ast | Next: ast.AsyncFor
Rel: ast.Add, ast.alias, ast.And, ast.AnnAssign
Ref: docs.python.org — ast.AST
Tags: #public #python3 #stdlib #ast


Import

import ast
from ast import AST

Signature & Overview

ast.AST(...)

ast.AST class.

Usage

import ast

tree = ast.parse("x = 1")
assert isinstance(tree, ast.AST) and tree._fields == ("body", "type_ignores")

Gotchas

REPL Inspect

from ast import AST
help(AST)

Linked from

Related notes