代码发布了here,我试图编译程序,但每次编译都会控制这个回溯:
Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 187, in bot = DateTemplates() File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 19, in __init__ super(DateTemplates, self).__init__() File "cerabot/bot.py", line 51, in __init__ self.setup() File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 110, in setup self._load_templates() File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 61, in _load_templates self._to_date.append(template.get(1).value.lower()) AttributeError: 'DateTemplates' object has no attribute '_to_date'
我迷路了,有人能帮我弄清楚吗?你知道吗
当您调用
super(DateTemplates, self).__init__()
时,它运行Bot.__init__
,它调用self.setup()
,它运行DateTemplates.setup()
,但是这发生在初始化self._to_date
之前,因此还没有要附加到的列表。将super
中的DateTemplates.__init__
调用移到方法的末尾,这样应该可以工作。你知道吗相关问题 更多 >
编程相关推荐