Re: [Pyunit-interest] comments on PyUnit
Brought to you by:
purcell
From: Fred L. D. Jr. <fd...@ac...> - 2001-04-23 15:06:41
|
Steve Purcell writes: > (The line number info doesn't seem to be available from the > 'parser' module's ASTs.) The methods of the syntax-tree objects that convert to tuples/lists accept a parameter that tells it to include an additional item that gives the line number. So you could do: import parser import pprint st = parser.suite(open("module.py").read()) pprint.pprint(st.totuple(1)) The last item in each tuple that represents a concrete token gives the line number for that token (for multi-line tokens, it gives the line the token *ends* on). It's a pretty pathetic interface, but the information is there. -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations |