You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2011-01-24.22:29:04.824>created_at=<Date2011-01-24.20:07:57.713>labels= ['docs']
title='Doc: ast.parse parses source, not just expressions'updated_at=<Date2011-01-24.22:29:04.823>user='https://github.com/terryjreedy'
"ast.parse(expr, filename='<unknown>', mode='exec')
Parse an expression into an AST node. Equivalent to compile(expr, filename, mode, ast.PyCF_ONLY_AST)."
but
"compile(source, ...)
Compile the source into a code or AST object.
...
The mode argument specifies what kind of code must be compiled; it can be 'exec' if source consists of a sequence of statements,"
Attached patch (untested) changes doc and doc string.
Inquiry: I suspect that the filename is *not* attached to the ast. (In any case, it must be explicitly supplied to a subsequent compile() call.) If so, it is a useless parameter and the api and doc should be
parse(source, mode) ... Equivalent to compile(source, '<unknown>', ...
If so, and failing such a change, should the doc warn people to not bother supplying a filename arg?
I also wonder whether the mode arg has any effect on the ast. If not, same question.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: