I'm trying to do a simple tree, with name for each child.
Here is a minimal code :
class Node:
def __init__(self, msg, childs={}):
self.msg = msg
self.childs=childs
tree = Node('1')
tree.childs['2'] = Node('2')
tree.childs['3'] = Node('3')
Executing print(tree.childs)
give me an expected output :
{'3': <main.Page object at 0x7f1fda9f77b8>, '2': <main.Page object at 0x7f1fda9f77f0>}
But executing print(tree.childs['2'].childs)
give me :
{'3': <main.Page object at 0x7f1fda9f77b8>, '2': <main.Page object at 0x7f1fda9f77f0>}
Where the expected output would be :
{}
Where am I wrong ? Why am I wrong ?