Created
March 14, 2013 06:10
-
-
Save Michael0x2a/5159204 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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