[New-bugs-announce] [issue30497] Line number of docstring in AST
Steven Myint
report at bugs.python.org
Sun May 28 14:44:26 EDT 2017
New submission from Steven Myint:
Since #29463, it is no longer obvious how to get the line number of a docstring in the AST:
import ast
x = ast.parse('''\
def foo():
"""This is a docstring."""
''')
# In Python 3.6, the docstring and line number would be:
print(x.body[0].body[0].value.s)
print(x.body[0].body[0].value.lineno)
# In Python 3.7, I don't know what the equivalent would be.
print(x.body[0].docstring)
# Line number?
We use this feature in pyflakes (https://github.com/PyCQA/pyflakes/issues/271).
----------
components: Interpreter Core
messages: 294654
nosy: myint
priority: normal
severity: normal
status: open
title: Line number of docstring in AST
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30497>
_______________________________________
More information about the New-bugs-announce
mailing list