Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7)

Side by Side Diff: Lib/ast.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Include/unicodeobject.h ('k') | Lib/asyncore.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """ 1 """
2 ast 2 ast
3 ~~~ 3 ~~~
4 4
5 The `ast` module helps Python applications to process trees of the Python 5 The `ast` module helps Python applications to process trees of the Python
6 abstract syntax grammar. The abstract syntax itself might change with 6 abstract syntax grammar. The abstract syntax itself might change with
7 each Python release; this module helps to find out programmatically what 7 each Python release; this module helps to find out programmatically what
8 the current grammar looks like and allows modifications of it. 8 the current grammar looks like and allows modifications of it.
9 9
10 An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as 10 An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as
11 a flag to the `compile()` builtin function or by using the `parse()` 11 a flag to the `compile()` builtin function or by using the `parse()`
12 function from this module. The result will be a tree of objects whose 12 function from this module. The result will be a tree of objects whose
13 classes all inherit from `ast.AST`. 13 classes all inherit from `ast.AST`.
14 14
15 A modified abstract syntax tree can be compiled into a Python code object 15 A modified abstract syntax tree can be compiled into a Python code object
16 using the built-in `compile()` function. 16 using the built-in `compile()` function.
17 17
18 Additionally various helper functions are provided that make working with 18 Additionally various helper functions are provided that make working with
19 the trees simpler. The main intention of the helper functions and this 19 the trees simpler. The main intention of the helper functions and this
20 module in general is to provide an easy to use interface for libraries 20 module in general is to provide an easy to use interface for libraries
21 that work tightly with the python syntax (template engines for example). 21 that work tightly with the python syntax (template engines for example).
22 22
23 23
24 :copyright: Copyright 2008 by Armin Ronacher. 24 :copyright: Copyright 2008 by Armin Ronacher.
25 :license: Python License. 25 :license: Python License.
26 """ 26 """
27 from _ast import * 27 from _ast import *
28 from _ast import __version__
28 29
29 30
30 def parse(source, filename='<unknown>', mode='exec'): 31 def parse(source, filename='<unknown>', mode='exec'):
31 """ 32 """
32 Parse the source into an AST node. 33 Parse the source into an AST node.
33 Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). 34 Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
34 """ 35 """
35 return compile(source, filename, mode, PyCF_ONLY_AST) 36 return compile(source, filename, mode, PyCF_ONLY_AST)
36 37
37 38
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 continue 309 continue
309 new_values.append(value) 310 new_values.append(value)
310 old_value[:] = new_values 311 old_value[:] = new_values
311 elif isinstance(old_value, AST): 312 elif isinstance(old_value, AST):
312 new_node = self.visit(old_value) 313 new_node = self.visit(old_value)
313 if new_node is None: 314 if new_node is None:
314 delattr(node, field) 315 delattr(node, field)
315 else: 316 else:
316 setattr(node, field, new_node) 317 setattr(node, field, new_node)
317 return node 318 return node
OLDNEW
« no previous file with comments | « Include/unicodeobject.h ('k') | Lib/asyncore.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+