This section shows several simple examples of ASTs for Python source
code. The examples demonstrate how to use the parse()
function, what the repr of an AST looks like, and how to access
attributes of an AST node.

The first module defines a single function. Assume it is stored in
/tmp/doublelib.py.

"""This is an example module.
This is the docstring.
"""
def double(x):
"Return twice the argument"
return x * 2

In the interactive interpreter session below, I have reformatted the
long AST reprs for readability. The AST reprs use unqualified class
names. If you want to create an instance from a repr, you must import
the class names from the compiler.ast module.