Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4241 > unrolled thread

Composition instead of inheritance

Started byEthan Furman <ethan@stoneleaf.us>
First post2011-04-28 10:15 -0700
Last post2011-05-02 13:30 -0400
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Composition instead of inheritance Ethan Furman <ethan@stoneleaf.us> - 2011-04-28 10:15 -0700
    Re: Composition instead of inheritance Ben Finney <ben+python@benfinney.id.au> - 2011-04-29 07:38 +1000
    Re: Composition instead of inheritance Alan Meyer <ameyer2@yahoo.com> - 2011-05-02 13:30 -0400

#4241 — Composition instead of inheritance

FromEthan Furman <ethan@stoneleaf.us>
Date2011-04-28 10:15 -0700
SubjectComposition instead of inheritance
Message-ID<mailman.946.1304010200.9059.python-list@python.org>
For anybody interested in composition instead of multiple inheritance, I 
have posted this recipe on ActiveState (for python 2.6/7, not 3.x):

http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/

Comments welcome!

~Ethan~

[toc] | [next] | [standalone]


#4272

FromBen Finney <ben+python@benfinney.id.au>
Date2011-04-29 07:38 +1000
Message-ID<8762pykqdr.fsf@benfinney.id.au>
In reply to#4241
Ethan Furman <ethan@stoneleaf.us> writes:

> For anybody interested in composition instead of multiple inheritance,
> I have posted this recipe on ActiveState (for python 2.6/7, not 3.x):
>
> http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/
>
> Comments welcome!

It doesn't look like composition at all, though. I understand
composition to be the setting of attributes on a class or instance; that
recipe doesn't show it very well IMO.

-- 
 \     “[The RIAA] have the patience to keep stomping. They're playing |
  `\         whack-a-mole with an infinite supply of tokens.” —kennon, |
_o__)                                             http://kuro5hin.org/ |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#4487

FromAlan Meyer <ameyer2@yahoo.com>
Date2011-05-02 13:30 -0400
Message-ID<4DBEEA1A.6000004@yahoo.com>
In reply to#4241
On 4/28/2011 1:15 PM, Ethan Furman wrote:
> For anybody interested in composition instead of multiple inheritance, I
> have posted this recipe on ActiveState (for python 2.6/7, not 3.x):
>
> http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/
>
>
> Comments welcome!
>
> ~Ethan~

That looks pretty clever.  I tried adding this method to Spam:

     def test_eggs_02(self):
         print('testing eggs_02 from spam')

and it did just what we wanted.

I'm going to have to study this one.

Thanks.

     Alan

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web