Given an AST, is there a working library for getti

2019-01-24 06:28发布

Is there a way to convert a given Python abstract syntax tree (AST) to a source code?

Here is a good example of how to use Python's ast module, specifically a NodeTransformer. I was looking for a way to convert the resulting AST back to source, so the changes can be inspected visually.

2条回答
狗以群分
3楼-- · 2019-01-24 06:52

The Python source tree contains an implementation of this: unparse.py in the Demo/parser directory: https://github.com/python/cpython/blob/master/Tools/parser/unparse.py

查看更多
登录 后发表回答