AWS, Rust, Python, High Performance Computing

Metaprogramming

Automatic code changing in Python with the ast module

Most language compilers and interpreters create Abstract Syntax Trees (ASTs) to represent your code before translation or execution. Python makes these trees accessible to the developer via the ast module. This allows for pretty powerful program analysis and even transformation. This article is a primer on Python's ast module. After reading this you will understand the basics of automated code traversing and manipulation by exploring a illustrative example dealing with converting Python 2 to 3 code.

Posted

#Metaprogramming #Python