分类: LINUX
2010-02-08 19:39:31
想学习下Mixin技术,不过看到个基本的例子都报错,实在是没办法高手指定下吧,多谢! main.py: ------------------------------------------------- import Mixin import mPrint class A(Mixin.Mixin): __mixinname__ = 'a' def __init__(self): self.initmixin() self.callplugin('init', self) if __name__ == '__main__': a = A() a.Print() --------------------------------------- mPrint.py ------------------------------------- #! /usr/bin/env python #coding=utf-8 import Mixin def init(self): self.name = 'mPrint.py' Mixin.setPlugin('a', 'init', init) def Print(self): print self.name Mixin.setMixin('a', 'Print', Print) 报错信息如下: > "E:\Python25\pythonw.exe" -u "...\itipsource\Mixin\main.py" Traceback (most recent call last): File "....\itipsource\Mixin\main.py", line 16, in a = A() File "...\itipsource\Mixin\main.py", line 10, in __init__ self.initmixin() File "E:\Python25\Mixin.py", line 52, in initmixin debug.info('[Mixin] Dealing class [%s]' % self.__class__.__name__) AttributeError: 'NoneType' object has no attribute 'info' |