[Python-checkins] r45306 - python/trunk/Doc/whatsnew/whatsnew25.tex

andrew.kuchling python-checkins at python.org
Wed Apr 12 14:16:32 CEST 2006


Author: andrew.kuchling
Date: Wed Apr 12 14:16:31 2006
New Revision: 45306

Modified:
   python/trunk/Doc/whatsnew/whatsnew25.tex
Log:
Mention access to ASTs

Modified: python/trunk/Doc/whatsnew/whatsnew25.tex
==============================================================================
--- python/trunk/Doc/whatsnew/whatsnew25.tex	(original)
+++ python/trunk/Doc/whatsnew/whatsnew25.tex	Wed Apr 12 14:16:31 2006
@@ -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 @@
 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


More information about the Python-checkins mailing list