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 <rep...@bugs.python.org> <http://bugs.python.org/issue30497> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com