Since the parentObject member is of
the same type as the class itself, I
need to declare this as an empty
variable of type "self".
No, you do not need to declare anything in Python. You just define things.
And self is not a type, but the conventional name for the first parameter of instance methods, which is set by the language to the object of the method.
Here's an example:
class Tree(object):
def __init__(self, label=None):
self.label = label
self.parent = None
self.children = []
def append(self, node):
self.children.append(node)
node.parent = self
And here's how that could be used:
empty_tree = Tree()
simple_tree = Tree()
simple_tree.append(Tree('hello'))
simple_tree.append(Tree('world'))