[issue29646] ast.parse parses string literals as docstrings
Serhiy Storchaka
report at bugs.python.org
Sat Feb 25 05:18:17 EST 2017
Serhiy Storchaka added the comment:
If someone wants to parse a simple expression that may be a string he should use the "eval" mode.
>>> ast.dump(ast.parse("'test'"))
"Module(body=[], docstring='test')"
>>> ast.dump(ast.parse("'test'", mode='eval'))
"Expression(body=Str(s='test'))"
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29646>
_______________________________________
More information about the Python-bugs-list
mailing list