Skip to content

Instantly share code, notes, and snippets.

@millimoose
Created October 12, 2012 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save millimoose/3881185 to your computer and use it in GitHub Desktop.
Save millimoose/3881185 to your computer and use it in GitHub Desktop.
Python ridiculousness
class meta_delegate(type):
def __call__(cls, *args, **kwargs):
return cls.__delegate(*args, **kwargs)
@staticmethod
def to(delegate):
def __new__(*args, **kwargs):
cls = meta_delegate(*args, **kwargs)
cls.__delegate = staticmethod(delegate)
return cls
return __new__
class test(object):
__metaclass__ = meta_delegate.to(lambda x, y: x+y)
z = test(1, 2)
print z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment