Created
March 10, 2010 06:11
-
-
Save anandkunal/327585 to your computer and use it in GitHub Desktop.
This file contains 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 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