Skip to content

Instantly share code, notes, and snippets.

@ukyo
Created July 15, 2011 13:21
Show Gist options
  • Save ukyo/1084662 to your computer and use it in GitHub Desktop.
Save ukyo/1084662 to your computer and use it in GitHub Desktop.
method missing in python
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