Python AST: Parsing loop lengh using is missing line numbers -


i trying parse line numbers of loop using python ast. using ast.walk

for in ast.walk(file):     if isinstance(i,(ast.while,ast.for)):        start=i.lineno;        end=i.body[-1]        while isinstance(end,(ast.while,ast.for,ast.if)):           end = end.body[-1] 

what trying offset node, when like;

attributeerror: 'if' object has no attribute 'body'.

i need can line numbers start of loop end.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -