I have the following class which represents a node of a tree:
class Node:
def __init__(self, name, parent=None):
self.name = name
self.parent = parent
self.children = []
# ...
if parent:
self.parent.children.append(self)
How to print such a tree?
This is my solution:
Example of use:
And this is the output:
UPDATE:
I pushed a more complete solution on PyPi.