Re: Finding the line number of an 'else' statement via ast

2012-05-11 Thread Terry Reedy
On 5/11/2012 12:35 AM, Michael Rene Armida wrote: Given this source: def do_something(val): if val: return 'a' else: return 'b' How do I get the line number of the "else:" line, using the ast module? The grammar only includes the 'orelse' list: If(expr test, s

Re: Finding the line number of an 'else' statement via ast

2012-05-11 Thread Mark Lawrence
On 11/05/2012 05:35, Michael Rene Armida wrote: Given this source: def do_something(val): if val: return 'a' else: return 'b' How do I get the line number of the "else:" line, using the ast module? The grammar only includes the 'orelse' list: If(expr test, stm

Finding the line number of an 'else' statement via ast

2012-05-10 Thread Michael Rene Armida
Given this source: def do_something(val): if val: return 'a' else: return 'b' How do I get the line number of the "else:" line, using the ast module? The grammar only includes the 'orelse' list: If(expr test, stmt* body, stmt* orelse) ...but 'orelse' is the list of