我想实现一个功能:
class FooBar():
def __init__(self):
self.foobar = foobar
def foo(self):
pass
def bar(self):
pass
a = Foobar()
获得实例 a 后, 可以使用 bar() 方法:
a.bar()
现在,我想让 a 的 foobar 属性和 foo() 方法也同样可以使用 bar() 方法:
a.foobar.bar()
a.foo().bar()
请问这样要如何写才合适,谢谢
classmethod 和 staticmethod了解一下