-1
我下面舉個例子扭曲loopingcall訪問類瓦爾
class Intake:
def __init__(self):
#
# aggregate dict to store all the counters
#
self.counters = {}
#
# start a looping call to run reach minute
#
self.lc = task.LoopingCall(self.aggregate, self.counters)
self.lc.start(60)
def aggregate(self, counters):
print counters
使作品就好了..但在我的聚合函數,我需要清除出self.counters字典。我有問題,這樣做..
我要像做
def aggregate(self, counters):
print counters
self.counters = {}
如果我在那個函數引用self.counters我得到
exceptions.AttributeError: Intake instance has no attribute 'counters'
...那麼問題是什麼?這不行嗎? – kindall 2012-01-06 21:29:44
我編輯了問題,在底部添加錯誤 – Mike 2012-01-06 21:39:35