Created
August 27, 2018 12:06
-
-
Save nokados/aff319683eab248d6d981cb6389dda32 to your computer and use it in GitHub Desktop.
method that allows to bind some function or method to the current class
This file contains hidden or 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
def bind(self, method): | |
def new_method(new_self, *args, **kwargs): | |
new_self.data = method(self.data, *args, **kwargs) | |
return new_self | |
setattr(self, method.__name__, types.MethodType(new_method, self)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment