Chapter 9: Understanding Code through Abstract Syntax Tree
In this chapter, we will look at what abstract syntax trees are and how to understand the syntax tree of each unit of the Python code we write.
Any programming language is designed with its own syntax, which is used by developers while coding in the language following specific syntax. The interpreter or compiler of a programming language interprets the syntax of the language and compiles or interprets the code and executes it to achieve the desired result.
In Python, an abstract syntax tree (AST) provides an abstract representation of the syntax of the code in the form of a tree. Python has a library named ast
that can be used to understand the abstract syntax of the code that we develop.
Throughout this chapter, we will look at understanding the syntax tree of some of the important code snippets that we developed in previous chapters, and we will also look at modifying or adding more information to the code through...