Getting at line numbers with parsermodule

Bill Tutt billtut at microsoft.com
Tue Aug 10 20:00:09 EDT 1999


> From: Charles G Waldman [mailto:cgw at fnal.gov]
> 

> What I'd like to be able to do is, given any node in an AST object
> returned by compile.suite, is to know the line number in the input
> that corresponds to this node.  Is this doable?  Any suggestions?
> 

You could just use parser.ast2tuple(ast, 1)
The extra parameter adds the line # as the last element of each AST node
tuple.

Bill




More information about the Python-list mailing list