Python's Abstract Syntax Tree: Practical and Unpractical Uses

Experience Level: all

Peek under the hood of Python and unlock the power of its Abstract Syntax Tree! We’ll demystify the AST, explore how it powers tools like pytest, linters, and refactoring, and experiment with more… creative transformations.


  • Timeslot: Sunday 6th April 2025, 16:00-17;00, Room B
  • Tags: other

What is the Python Abstract Syntax Tree and why should you care? In this talk, we’ll demystify the Abstract Syntax Tree (AST) and show how it powers tools you probably already use - in Python and other languages.

We’ll take a close look at pytest assert rewrite as an motivating and empowering example of how AST transformations work.

ASTs (and their cousins, the Concrete Syntax Trees) drive many real-world applications, from linters to automatic refactoring. We’ll mention some modern tools you might want to use.

Armed with newfound confidence, we’ll explore more creative transformations.

You’ll leave this talk with a deeper understanding of Python’s internals and a few terrible ideas for AST-powered tools.

This talk is beginner-friendly, no prior AST knowledge required.


Laurent Direr

I’m a freelance web developer helping small teams ship reliable software. I’ve been working with Python for 10+ years and enjoy automating work for other developers.

These days I’m very interested in local-first software technologies. I attended the Recurse Center (a programming retreat) in 2018.

blank_avatar