Skip to content

Instantly share code, notes, and snippets.

@Michael0x2a
Created March 14, 2013 06:10
Show Gist options
  • Save Michael0x2a/5159204 to your computer and use it in GitHub Desktop.
Save Michael0x2a/5159204 to your computer and use it in GitHub Desktop.
class Test(object):
def __getattr__(self, attr):
print("hi!")
print(attr)
return self.default_func
def __setattr__(self, attr, value):
print("bye!")
print(attr)
print(value)
def default_func(self, *args, **kwargs):
print("foobar")
print(args)
print(kwargs)
if __name__ == '__main__':
t = Test()
print t.bleh
print t.asdf("hello", "world", color=14)
t.sfsf = "asdfasdfa"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment