Dispatch with multiple inheritance

Michael Spencer mahs at telcopartners.com
Wed Jul 19 19:04:34 EDT 2006


Michael J. Fromberger wrote:
...
> 
> Of course, I could just bypass super, and explicitly invoke them as:
> 
>   C.__init__(self, ...)
>   D.__init__(self, ...)
> 
> ... but that seems to me to defeat the purpose of having super in the 
> first place.

As others have pointed out, super, is designed to do something different from 
what you want.  See 
http://www.python.org/download/releases/2.2.3/descrintro/#cooperation for GvR's 
  explanation of super's intent, limitations, and a pure-python implementation 
that you might alter for your purposes.

Some people argue that effective use cases for super are rare and that it's 
awkward to use correctly even in these cases.  See for example, 
http://fuhm.net/super-harmful/.  So don't feel bad about not using it ;-)

Given what you assert about your inheritance graph (two independent ancestor 
chains, that do not propagate super calls from their respective base classes), 
what is objectionable about:
 >   C.__init__(self, ...)
 >   D.__init__(self, ...)

Michael





More information about the Python-list mailing list