Chinaunix

标题: call和run的区别 [打印本页]

作者: CanuxCheng    时间: 2015-03-10 12:37
标题: call和run的区别
class ThreadFunc(object):

    def __init__(self, func, args, name=''):
        self.name = name
        self.func = func
        self.args = args

    def __call__(self):
        apply(self.func, self.args)


class MyThread(threading.Thread):
    def __init__(self, func, args, name=''):
        threading.Thread.__init__(self)
        self.name = name
        self.func = func
        self.args = args

    def run(self):
        apply(self.func, self.args)


哪位大侠解释下这两个类怎样移植到python3,而且特殊方法call和run有啥区别呢?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2