Here is what I would like to achieve. I am trying to read a tree (let's say a folder structure). I would like to define a generic node in this tree and the initialization of this object should trigger the tree traversing like below
class node():
def __init__(self, name, parent, children=[]):
self.name = name
self.parent = parent
self.children = children
nodes = "code to find children"
for child in nodes:
children.append(node(childname, self.name))
def main():
Tree = node("root", "")
When this initial object is initialized it should contain the complete tree. This is for python. Would this work?