Learn about Python's Abstract Syntax Tree (AST) module in this 18-minute PyCon Israel conference talk that explores code analysis, alteration, and generation capabilities. Discover the AST module's structure, class hierarchy, and supported functions while focusing on recreating initial code through AST representation. Examine the challenges of transforming AST back into code and explore practical applications through hands-on examples, including automatic log insertion, code reordering, and mutant testing manipulations. Master the fundamentals of AST manipulation while understanding both its potential and limitations in Python development.
Overview
Syllabus
Introduction
Abstract Syntax Trees
Python
Preserve Source Code
The AST Model
Adding Nodes
If Invert
Preserve Original Source Code
Challenges
Taught by
PyCon Israel