While it's fairly simple to monkeypatch instance methods to classes, e.g.
class A(object):
pass
def a(self):
print "a"
A.a = a
doing this with another class's @staticmethod
à la
class B(object):
@staticmethod
def b():
print "static b"
A.b = B.b
results in A.b()
yielding a
TypeError
: unbound methodb()
must be called withA
instance as first argument (got nothing instead)
Make A.b a static method and you should be fine:
A.b = staticmethod(B.b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With