Daily Shaarli

All links of one day in a single page.

July 21, 2025

Green Tree Snakes - the missing Python AST docs — Green Tree Snakes 1.0 documentation

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 used to be rather brief. A large part of the material from Green Tree Snakes, describing all of the AST node classes, has now been merged into the ast module docs. The remainder here aims to serve as a field guide (or forest guide?) to working with ASTs in practice.