Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Created May 19, 2020 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/0824c1b19f81c1dc5552f2d3f1dafc39 to your computer and use it in GitHub Desktop.
Save Allwin12/0824c1b19f81c1dc5552f2d3f1dafc39 to your computer and use it in GitHub Desktop.
from anytree import Node, RenderTree
grandpa = Node('Grandpa')
father = Node('Father', parent=grandpa)
uncle = Node('Uncle', parent=grandpa)
child = Node('Child', parent=father)
sibling = Node('Sibling', parent=father)
for pre, fill, node in RenderTree(grandpa):
print("%s%s" % (pre, node.name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment