Skip to content

Instantly share code, notes, and snippets.

@astrosilverio
Created June 26, 2015 19:43
Show Gist options
  • Save astrosilverio/7e402c6275981ce4195e to your computer and use it in GitHub Desktop.
Save astrosilverio/7e402c6275981ce4195e to your computer and use it in GitHub Desktop.
bad ideas bears
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