multiple extensions to a class

Humpty Dumpty oliver.schoenborn at utoronto.ca
Mon Jul 12 05:20:57 CEST 2004


"Peter Otten" <__peter__ at web.de> wrote in message
news:ccof5d$t2b$06$1 at news.t-online.com...
> Humpty Dumpty wrote:
>
> > I.e.,  if I have a class A, and I want to add a block of functionality,
I
> > can derive it into a B that adds that fucntionality. If I want to add
more
> > functionality, I can derive B into a C. But if I want to add a third bit
> > of functionality D directly to A, such that D knows nothing about B or
C,
> > I won't be able to instantiate an object that has all three extensions,
> > namely an "ABCD". It will either be an "ABC" or an "AD".
>
> This sounds like the following inheritance tree would be the obvious
answer:
>
> class A: pass
> class B: pass
> class C: pass
> class D: pass
>
> class AB(A, B): pass
> class ABC(A, B, C): pass
> class AD(A, D): pass

Which one offers "ABCD"?  Plus, as I just mentioned in a reply to another
poster in this thread, B,C and D are discovered at run-time so anything
based on class Something(derived from combination of A,B,C,D) is doomed
since derivation is not dynamic.

Oliver





More information about the Python-list mailing list