I meant:
class SomeBase:
def __init__(self, base_x, **kwargs):
super().__init__(**kwargs)
self.base_x = base_x
On Saturday, October 28, 2017 at 3:14:31 AM UTC-4, Neil Girdhar wrote:
>
>
>
> On Friday, October 27, 2017 at 8:05:17 PM UTC-4, Steven D'Aprano wrote:
>>
>> On Fri, Oct 27, 2017 at 01:59:01PM -0700, Ilya Kulakov wrote:
>>
>> > Since one of the legit use-cases of using the Thread class is
>> subclassing,
>> > I think it's __init__ should call super() to support cooperative
>> inheritance.
>> >
>> > Or perhaps there is a good reason for not doing so?
>>
>> Are you talking about threading.Thread or some other Thread?
>>
>> If you are talking about threading.Thread, its only superclass is
>> object, so why bother calling super().__init__?
>>
>
> The way cooperative multiple inheritance works is that if someone defines
>
> class SomeClass(Thread):
>
> def __init__(self, **kwargs):
> super().__init()
>
> they expect this will initialize the base class Thread as desired.
>
> Now, if they add another base class:
>
> class SomeBase:
>
> def __init__(self, base_x):
> self.base_x = base_x
>
> then they need to pass up the arguments:
>
> class SomeClass(SomeBase, Thread):
>
> def __init__(self, **kwargs):
> super().__init(**kwargs)
>
> Unfortunately, if the order of base classes is reversed, this no longer
> works because Thread doesn't call super:
>
> class SomeClass(Thread, SomeBase):
>
> def __init__(self, **kwargs):
> super().__init(**kwargs) # SomeBase is not initialized!
>
> 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.
>
>
>> To be successful, it would need to strip out all the parameters and just
>> call:
>>
>> super().__init__()
>>
>> with no args, as object.__init__() takes no parameters. And that does
>> nothing, so what's the point?
>>
>> I'm afraid I don't see why you think that threading.Thread needs to call
>> super. Can you explain?
>>
>>
>> --
>> Steve
>> _______________________________________________
>> Python-ideas mailing list
>> python...@python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/