Skip to content

Instantly share code, notes, and snippets.

@doctaphred
Created September 7, 2016 23:55
Show Gist options
  • Select an option

  • Save doctaphred/bb74064bb65cb1e9dd04875919f7c018 to your computer and use it in GitHub Desktop.

Select an option

Save doctaphred/bb74064bb65cb1e9dd04875919f7c018 to your computer and use it in GitHub Desktop.
magic = lambda x: x()
class word:
def __init__(self, current, prev=None):
self.current = current
self.prev = prev
def __getattr__(self, name):
return self.__class__(name, self)
def __repr__(self):
if self.prev is None:
return self.current
else:
return repr(self.prev) + ' ' + self.current
@magic
class say:
def __getattr__(self, name):
return word(name)
say.hello.world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment