为具有多个 superclass 的 class 调用 superclass 函数
Calling a superclass function for a class with multiple superclass
我有一个扩展了两个 class 的 class,其中一个包括 threading.Thread。如何从 subclass 调用 threading.Thread 的 start 方法?
class Poller(threading.Thread, <some other class>):
"""
poller code
"""
def start():
return super(Poller,self).start()
我想启动线程class'启动函数。这行不通吧?
start() 方法缺少 "self" 关键字
class Poller(threading.Thread, <some other class>):
"""
poller code
"""
def start(self):
return super(Poller,self).start()
如果你想确保只调用线程的启动,你可以这样做:
def start(self):
threading.Thread.start(self)
请注意,这将避免其他基础 class 的启动方法,并且可能不是您想要的
我有一个扩展了两个 class 的 class,其中一个包括 threading.Thread。如何从 subclass 调用 threading.Thread 的 start 方法?
class Poller(threading.Thread, <some other class>):
"""
poller code
"""
def start():
return super(Poller,self).start()
我想启动线程class'启动函数。这行不通吧?
start() 方法缺少 "self" 关键字
class Poller(threading.Thread, <some other class>):
"""
poller code
"""
def start(self):
return super(Poller,self).start()
如果你想确保只调用线程的启动,你可以这样做:
def start(self):
threading.Thread.start(self)
请注意,这将避免其他基础 class 的启动方法,并且可能不是您想要的