<div dir="ltr">I meant:<div><br></div><div><div>class SomeBase:</div><div><br></div><div> def __init__(self, base_x, **kwargs):</div><div> super().__init__(**kwargs)</div><div> self.base_x = base_x</div><br>On Saturday, October 28, 2017 at 3:14:31 AM UTC-4, Neil Girdhar wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr"><br><br>On Friday, October 27, 2017 at 8:05:17 PM UTC-4, Steven D'Aprano wrote:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Oct 27, 2017 at 01:59:01PM -0700, Ilya Kulakov wrote:
<br>
<br>> Since one of the legit use-cases of using the Thread class is subclassing,
<br>> I think it's __init__ should call super() to support cooperative inheritance.
<br>>
<br>> Or perhaps there is a good reason for not doing so?
<br>
<br>Are you talking about threading.Thread or some other Thread?
<br>
<br>If you are talking about threading.Thread, its only superclass is
<br>object, so why bother calling super().__init__?
<br></blockquote><div><br></div><div>The way cooperative multiple inheritance works is that if someone defines</div><div><br></div><div><div>class SomeClass(Thread):</div><div><br></div><div> def __init__(self, **kwargs):</div><div> super().__init()</div><div><br></div><div>they expect this will initialize the base class Thread as desired.</div><div><br></div><div>Now, if they add another base class:</div><div><br></div><div>class SomeBase:</div><div><br></div><div> def __init__(self, base_x):</div><div> self.base_x = base_x</div><div><br></div><div>then they need to pass up the arguments:</div><div><br></div><div>class SomeClass(SomeBase, Thread):</div><div><br></div><div> def __init__(self, **kwargs):</div><div> super().__init(**kwargs)</div><div><br></div><div>Unfortunately, if the order of base classes is reversed, this no longer works because Thread doesn't call super:</div><div><br></div><div>class SomeClass(Thread, SomeBase):</div><div><br></div><div> def __init__(self, **kwargs):</div><div> super().__init(**kwargs) # SomeBase is not initialized!</div><div><br></div><div>As things get more complicated it's not always possible to ensure that Thread is the last class in the inheritance, e.g., if there are two classes like Thread that don't call super.</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>To be successful, it would need to strip out all the parameters and just
<br>call:
<br>
<br> super().__init__()
<br>
<br>with no args, as object.__init__() takes no parameters. And that does
<br>nothing, so what's the point?
<br>
<br>I'm afraid I don't see why you think that threading.Thread needs to call
<br>super. Can you explain?
<br>
<br>
<br>--
<br>Steve
<br>______________________________<wbr>_________________
<br>Python-ideas mailing list
<br><a rel="nofollow">Python...@python.org</a>
<br><a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-ideas\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-ideas\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return true;">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a>
<br>Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return true;">http://python.org/psf/<wbr>codeofconduct/</a>
<br></blockquote></div></blockquote></div></div>