Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
483b1f16
Commit
483b1f16
authored
Apr 12, 2006
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mention access to ASTs
parent
93085332
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
Doc/whatsnew/whatsnew25.tex
Doc/whatsnew/whatsnew25.tex
+14
-1
No files found.
Doc/whatsnew/whatsnew25.tex
View file @
483b1f16
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment