Created
June 7, 2017 08:33
-
-
Save vene/def1a57b5c233bde285d9da5ac616ba0 to your computer and use it in GitHub Desktop.
if_delegate_has_method adds explicit self
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
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