code:
class Node:
def __init__(self, key, children=[]):
self.key = key
self.children = children
def __repr__(self):
return self.key
execute:
root = Node("root")
child = Node("child")
root.children.append(child)
print child.children
print root.children[0].children
result:
[child]
[child]
This is really weird, why?
Python's version is 2.7.2.