Created
June 26, 2015 19:43
-
-
Save astrosilverio/7e402c6275981ce4195e to your computer and use it in GitHub Desktop.
bad ideas bears
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 Entity(object): | |
def __init__(self, guid): | |
self.guid = guid | |
self.components = set() | |
def __getattr__(self, name): | |
# if Entity doesn't have an attribute, check if any of its components do | |
for component in self.components: | |
try: | |
attr = getattr(component, name) | |
except AttributeError: | |
pass | |
else: | |
return attr | |
raise AttributeError | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment