Remove multiple inheritance in Python 3000

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Apr 22 11:18:35 EDT 2008


Carl Banks a écrit :
> On Apr 22, 10:36 am, George Sakkis <george.sak... at gmail.com> wrote:
>> On Apr 22, 10:22 am, Carl Banks <pavlovevide... at gmail.com> wrote:
>>
>>> Java (for example) allows a class to share behavior with only one
>>> other class, and that *severely* limits the opportunities to minimize
>>> redundancy.
>> Not really; composition is usually a better way to share functionality
>> and reduce redundancy than inheritance.
> 
> I should have known this was coming.  I disagree: inheritance is a
> much better way to share behavior.
 >
(snip)
> With composition you're burdening the user with having to learn the
> shared relationships that ought to be implementation details of the
> class.  E.g.,
> 
> obj.action_style.perform_action()
 >
> With inheritance, the user doesn't have to worry about these
> relationships.
> 
> obj.perform_action()
> 
(snip)
Unless you use composition + delegation (which is a PITA in Java and 
close to a no-brainer in Python). In which case this is mostly 
transparent to the user code.

Anyway, in Python, inheritence is kind of a special case of 
composition+delegation.



More information about the Python-list mailing list