我希望有一些函数在调用我的对象的方法时被调用。这些函数不是由方法定义的——它们稍后会提供给方法(或者可能根本不提供)。有没有比使用更优雅的占位符解决方案:
class MyObj:
def __init__(self):
self.bind = self.donothing #variable that may or may not be set by the parent
def func(self):
"""Function to be called by the parent"""
self.bind()
## do stuff
@staticmethod
def donothing():
pass
翻过高山走不出你
DIEA
相关分类