Skip to content

Instantly share code, notes, and snippets.

@willrjmarshall
Created September 19, 2014 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willrjmarshall/d4152551a569c7741556 to your computer and use it in GitHub Desktop.
Save willrjmarshall/d4152551a569c7741556 to your computer and use it in GitHub Desktop.
class Parent(object):
def log_message(self, string):
self.c_instance.log_message(string) # Calling a C bridge
def create_children(self):
self.child1 = Child(self)
self.child2 = Child2(self)
class Child(object):
def __init__(self, parent):
self.parent = parent
self.grandchild1 = Grandchild(parent)
self.parent.log_message("some message")
class Child2(object):
def __init__(self, parent):
self.parent = parent
self.grandchild2 = Grandchild2(parent)
self.parent.log_message("another message")
class Grandchild(object):
def __init__(self):
self.parent = parent
self.parent.log_message("grandchild loaded")
class Grandchild2(object):
def __init__(self, parent):
self.parent = parent
self.parent.log_message("grandchild loaded")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment