Python 类中访问模块中的函数
from CbayCommon import *import traceback,sysclass CbayDevice(CbayCommon): ''' Parser class base. ''' def make(self): ''' make data by using parser ''' k = 0 if not self.pBlock: print "Device make block empty,page:",self.page return for p in self.pBlock: k += 1 p = self.filterRegResult(p) try: self.parser.reset() self.parser.feed(p) self.parser.close() self.data.append(self.parser.data) except: [color=#FF0000]traceback.print_exc(file=sys.stdout)[/color] print "page:",self.page," make Product fail in ",k,",block:",p continue
import traceback,sysclass ca(object): def method1(self): try: pass #raise ValueError except: traceback.print_exc(file=sys.stdout) print 'ex'if __name__=='__main__': a=ca() a.method1()