kaityo256/python_zero

GraphVizのPNG化(Pythonが動く仕組み)

kaityo256 opened this issue · 0 comments

抽象構文木を表示するところをPNGで返すように修正。

def show_ast(src):
    graph = Digraph(format="png")
    tree = ast.parse(src)
    visit(tree, [], 0, graph)
    img = graph.render("test.png")
    return IPython.display.Image(img)