Created
October 12, 2012 19:59
-
-
Save millimoose/3881185 to your computer and use it in GitHub Desktop.
Python ridiculousness
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 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