编辑:这是一个愚蠢的错误,看看答案,但我的init方法没有定义self
变量。
我有几个 python 类是管道中的阶段。它们继承自基类。
class StageBase(object):
key = Segments.NONE
_preprocessors = []
def __init__():
self.closing = False
self.working = False
self._que = None
self._working_lock = None
self._que_lock = None
#whole bunch of other methods
继承类覆盖key
和_preprocessors
。在添加显式__init__()
方法之前,一切正常,现在我收到以下错误:
TypeError: __init__() takes no arguments (1 given)
错误所在的行是我覆盖的行_preprocessors
(在此示例中,此类变量表示应在此阶段之前执行的其他阶段)。
抛出此错误的示例类:
class StaticPageStage(StageBase):
key = Segments.STATICPAGE
_preprocessors = [FacebookGraphStage(), ]
def __init__():
pass
def process(self, data):
data = self._preprocess(data)
return self.handle_results(tuple(x for x in data))
谁能告诉我如何解决这个问题?