【发布时间】:2012-01-06 20:23:32
【问题描述】:
我有下面的例子
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,我会得到 p>
exceptions.AttributeError: Intake instance has no attribute 'counters'
【问题讨论】:
-
...那么问题是什么?那不行吗?
-
我编辑了问题以在底部添加错误