-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