Visiting nodes in a syntax tree with Python ast module

前端 未结 2 351
遇见更好的自我
遇见更好的自我 2021-02-03 13:20

I\'m playing with python ast (abstract syntax tree).

I wrote the following and it visited all nodes of the AST.

import ast

class Py2Neko(ast.NodeVisito         


        
2条回答
  •  无人及你
    2021-02-03 14:01

    For non-terminal nodes, your visit function has to visit the children. See Simple example of how to use ast.NodeVisitor? for some more information.

提交回复
热议问题