Skip to content

Instantly share code, notes, and snippets.

@nokados
Created August 27, 2018 12:06
Show Gist options
  • Save nokados/aff319683eab248d6d981cb6389dda32 to your computer and use it in GitHub Desktop.
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
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