Created
July 15, 2011 13:21
-
-
Save ukyo/1084662 to your computer and use it in GitHub Desktop.
method missing in python
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 MethodMissing(object): | |
def __getattr__(self, name): | |
try: | |
return self.__getattribute__(name) | |
except AttributeError: | |
def method(*args, **kw): | |
return self.method_missing(name, *args, **kw) | |
return method | |
def method_missing(self, name, *args, **kw): | |
raise AttributeError, name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment