PyCon Israel 2023

πŸ‡ΊπŸ‡Έ Fun With ASTs
07-04, 13:00–13:20 (Africa/Cairo), Main hall

This talk will delve into the AST module's capabilities and limitations, covering its class hierarchy, general structure, and supported functions. Attendees will be presented with examples of cool code manipulations based on AST.


The AST (Abstract Syntax Tree) module in Python can be used to analyze code, alert it, and even generate new code. We can use programming to change the AST representation of python, resulting in code that looks and behaves differently than the original.
This is a really cool thing to do.

In this talk we will explore the AST module capabilities, and its lack of capabilities.
We will learn the general structure of ASTmodule, its class hierarchy and its supported functions. Our focus will be on acquiring the skill to recreate the initial code through its AST representation. It seems that even though transforming python code into an AST is a simple task, the inverse process of transforming AST into code fails to replicate the original code.

We will see some examples of fun code-manipulations. First, we will show how to automatically add meaningful logs to your code. Second, we will experiment with code reordering and last, we will explore ideas to manipulate code for mutant testing purposes.


Session language –

English

Target audience –

Developers

I'm a software engineer at heart. Currently I lead the Archive product development group in Ownbackup. My area of interest lies in exploring the inner workings of programming languages while developing scalable and relaiable SaaS software.

I hold a Ph.D. in Computer Sciences. I have published numerous papers in leading academic and industrial conferences.I have more than 20 years of experience developing software in areas like processor verification, intrusion detect, banking, and data protection.