MCPcopy Create free account
hub / github.com/ActiveState/code / printAst

Function printAst

recipes/Python/533146_AST_Pretty_Printer/recipe-533146.py:14–17  ·  view source on GitHub ↗

Pretty-print an AST to the given output stream.

(ast, indent='  ', stream=sys.stdout, initlevel=0)

Source from the content-addressed store, hash-verified

12
13
14def printAst(ast, indent=' ', stream=sys.stdout, initlevel=0):
15 "Pretty-print an AST to the given output stream."
16 rec_node(ast, initlevel, indent, stream.write)
17 stream.write('\n')
18
19def rec_node(node, level, indent, write):
20 "Recurse through a node, pretty-printing it."

Callers 1

mainFunction · 0.85

Calls 2

rec_nodeFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected