Skip to content

Instantly share code, notes, and snippets.

@anandkunal
Created March 10, 2010 06:11
Show Gist options
  • Save anandkunal/327585 to your computer and use it in GitHub Desktop.
Save anandkunal/327585 to your computer and use it in GitHub Desktop.
class Thing(object):
def __init__(self):
self.__missing_method_name = None # Hack!
def __getattribute__(self, name):
return object.__getattribute__(self, name)
def __getattr__(self, name):
self.__missing_method_name = name # Could also be a property
return getattr(self, '__methodmissing__')
def __methodmissing__(self, *args, **kwargs):
print "Missing method %s called (args = %s) and (kwargs = %s)" % (self.__missing_method_name, str(args), str(kwargs))
t = Thing()
t.badness(123, 'an arg', blah="another argument here", zesty="woot")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment