Skip to content

Instantly share code, notes, and snippets.

@wyattjoh
Last active July 12, 2016 14:50
Show Gist options
  • Save wyattjoh/d87935f464e8970aaeb85ec814bcef15 to your computer and use it in GitHub Desktop.
Save wyattjoh/d87935f464e8970aaeb85ec814bcef15 to your computer and use it in GitHub Desktop.
class Node:
def __init__(self, parent, name):
self.parent = parent
self.name = name
def get(self, name):
return Node(self, ".".join([self.name, name]))
def root(self):
node = self
while node.parent != None:
node = node.parent
return node
a = Node(None, "a")
b = a.get("b")
c = b.get("c")
d = c.get("d")
droot = d.root()
if droot != a or droot.name != "a":
print("something went wrong!")
else:
print("all good")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment