3025 shaares
1 result
tagged
Abstract
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.