Last active
July 12, 2016 14:50
-
-
Save wyattjoh/d87935f464e8970aaeb85ec814bcef15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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