Why doesn't super(Thread, self).__init__() work for a threading.Thread subclass?

后端 未结 1 579
夕颜
夕颜 2021-02-19 04:58

Every object I know of in Python can take care of its base class initialization by calling:

super(BaseClass, self).__init__()

This doesn\'t see

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-19 05:28

    This works fine:

    >>> class MyThread(threading.Thread):
    ...   def __init__(self):
    ...     super(MyThread, self).__init__()
    

    I think your code's bug is that you're passing the base class, rather than the current class, to super -- i.e. you're calling super(threading.Thread, ..., and that's just wrong. Hard to say since you don't show your failing code, but that's what I infer obliquely from the language you're using!-)

    0 讨论(0)
提交回复
热议问题