Created
March 10, 2022 02:05
-
-
Save autf/43de0092e93b7433c4c90a4e2b36d632 to your computer and use it in GitHub Desktop.
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 T: | |
... | |
def _m(my): print('m', my) | |
T.m = _m | |
@classmethod | |
def _cm(cls): print('cm', cls) | |
T.cm = _cm | |
## ...OR | |
# def _cm(cls): print('cm', cls) | |
# T.cm = classmethod(cm) | |
def _sm(): print('sm') | |
T.sm = staticmethod(_sm) | |
# T.sm = _sm #=> Error! | |
t = T() | |
t.m() | |
T.m(t) | |
t.cm() | |
T.cm() | |
(T.cm)() | |
getattr(T, 'cm')() | |
t.sm() | |
T.sm() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment