On Apr 14, 2011, at 3:32 PM, Ricardo Kirkner wrote:

>> 
>> What would the semantics be of a super that intentially calls all siblings? 
>> In particular what is the return value of such a call? The implementation 
>> can't know how to combine the implementations in the inheritance chain and 
>> should refuse the tempation to guess.
> 
> I'll give you the example I came upon:
> 
> I have a TestCase class, which inherits from both Django's TestCase
> and from some custom TestCases that act as mixin classes. So I have
> something like
> 
> class MyTestCase(TestCase, Mixin1, Mixin2):
>   ...
> 
> now django's TestCase class inherits from unittest2.TestCase, which we
> found was not calling super. Even if this is a bug and should be fixed
> in unittest2, this is an example where I, as a consumer of django,
> shouldn't have to be worried about how django's TestCase class is
> implemented. Since I explicitely base off 3 classes, I expected all 3
> classes to be initialized, and I expect the setUp method to be called
> on all of them.
> 
> If I'm assuming/expecting unreasonable things, please enlighten me.

For cooperative-multiple-inheritance to work, the classes
need to cooperate by having been designed to work together
in a series of cooperative super calls.

If an external non-cooperative class needs to be used, then
it should be wrapped in a class that makes an explicit
__init__ call to the external class and then calls super().__init__()
to continue the forwarding.


Raymond
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to