Apart from the node classes, :mod:`ast` module defines these utility functions
and classes for traversing abstract syntax trees:
-.. function:: parse(expr, filename='<unknown>', mode='exec')
+.. function:: parse(source, filename='<unknown>', mode='exec')
- Parse an expression into an AST node. Equivalent to ``compile(expr,
+ Parse the source into an AST node. Equivalent to ``compile(source,
filename, mode, ast.PyCF_ONLY_AST)``.
from _ast import __version__
-def parse(expr, filename='<unknown>', mode='exec'):
+def parse(source, filename='<unknown>', mode='exec'):
"""
- Parse an expression into an AST node.
- Equivalent to compile(expr, filename, mode, PyCF_ONLY_AST).
+ Parse the source into an AST node.
+ Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
"""
- return compile(expr, filename, mode, PyCF_ONLY_AST)
+ return compile(source, filename, mode, PyCF_ONLY_AST)
def literal_eval(node_or_string):