I have two classes, one is designed to contain the other
class Thing:
def __init__(self, parent: Box):
self.parent = parent
parent.add_to_box(self)
class Box:
def __init__(self):
self.children = []
def add_to_box(self, item: Thing):
self.children.append(item)
However I can't reference the class types (parent: Box
and item: Thing
) within each other, only either one or the other.
How can I reference both class types within each other? And otherwise what is the best way to do this?