Skip to content

Instantly share code, notes, and snippets.

@vene
Created June 7, 2017 08:33
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 vene/def1a57b5c233bde285d9da5ac616ba0 to your computer and use it in GitHub Desktop.
Save vene/def1a57b5c233bde285d9da5ac616ba0 to your computer and use it in GitHub Desktop.
if_delegate_has_method adds explicit self
from sklearn.utils.metaestimators import if_delegate_has_method
from sklearn.utils.fixes import signature
class Test(object):
def hi(self, what):
return 1 + what
class Kid(object):
def __init__(self, delegate):
self.delegate = delegate
@if_delegate_has_method('delegate')
def hi(self, what):
return self.delegate(what)
test = Test()
kid = Kid(test)
print(signature(test.hi))
print(signature(kid.hi))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment