Skip to content

Instantly share code, notes, and snippets.

@holly
Forked from ukyo/method_missing.py
Created October 15, 2016 14:40
Show Gist options
  • Save holly/fbf9297c0b5bbad169b7a5c6331b1516 to your computer and use it in GitHub Desktop.
Save holly/fbf9297c0b5bbad169b7a5c6331b1516 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