summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-04-12 12:16:31 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-04-12 12:16:31 (GMT)
commit4e86195a997f0bfff51ce4dd4b1fdac461348160 (patch)
treeb6337bbb6863c71051cde26e5606039f2361bc67
parente29002ccb009966bc23d632f534d62bad56d0fd3 (diff)
downloadcpython-4e86195a997f0bfff51ce4dd4b1fdac461348160.zip
cpython-4e86195a997f0bfff51ce4dd4b1fdac461348160.tar.gz
cpython-4e86195a997f0bfff51ce4dd4b1fdac461348160.tar.bz2
Mention access to ASTs
-rw-r--r--Doc/whatsnew/whatsnew25.tex15
1 files changed, 14 insertions, 1 deletions
diff --git a/Doc/whatsnew/whatsnew25.tex b/Doc/whatsnew/whatsnew25.tex
index 91385dc..958b3be 100644
--- a/Doc/whatsnew/whatsnew25.tex
+++ b/Doc/whatsnew/whatsnew25.tex
@@ -5,7 +5,6 @@
% Fix XXX comments
% Distutils upload (PEP 243)
% The easy_install stuff
-% Access to ASTs with compile() flag
% Stateful codec changes
% ASCII is now default encoding for modules
@@ -1380,6 +1379,20 @@ no longer generate bytecode by traversing the parse tree. Instead
the parse tree is converted to an abstract syntax tree (or AST), and it is
the abstract syntax tree that's traversed to produce the bytecode.
+It's possible for Python code to obtain AST objects by using the
+\function{compile()} built-in and specifying 0x400 as the value of the
+\var{flags} parameter:
+
+\begin{verbatim}
+ast = compile("""a=0
+for i in range(10):
+ a += i
+""", "<string>", 'exec', 0x0400)
+
+assignment = ast.body[0]
+for_loop = ast.body[1]
+\end{verbatim}
+
No documentation has been written for the AST code yet. To start
learning about it, read the definition of the various AST nodes in
\file{Parser/Python.asdl}. A Python script reads this file and