Green Tree Snakes - the missing Python AST docs

Abstract Syntax Trees, ASTs, are a powerful feature of Python. You can write programs that inspect and modify Python code, after the syntax has been parsed, but before it gets compiled to byte code. That opens up a world of possibilities for introspection, testing, and mischief.

The official documentation for the ast module is good, but somewhat brief. Green Tree Snakes is more like a field guide (or should that be forest guide?) for working with ASTs. To contribute to the guide, see the source repository.


See also

Instrumenting the AST
Using AST tools to assess code coverage.
A simple GUI for exploring ASTs
A Python IDE with AST explorer built in (Main menu => View => AST).

Indices and tables