Re: Composition instead of inheritance

2011-05-02 Thread Alan Meyer
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

Re: Composition instead of inheritance

2011-04-29 Thread Ian Kelly
On Fri, Apr 29, 2011 at 5:54 PM, Carl Banks wrote: >> Really, *any* class that uses super().__init__ should take its >> arguments and pass them along in this manner. > > If you are programming defensively for any possible scenario, you might try > this (and you'd still fail). > > In the real worl

Re: Composition instead of inheritance

2011-04-29 Thread Carl Banks
On Friday, April 29, 2011 2:44:56 PM UTC-7, Ian wrote: > On Fri, Apr 29, 2011 at 3:09 PM, Carl Banks > wrote: > > Here is my advice on mixins: > > > > Mixins should almost always be listed first in the bases.  (The only > > exception is to work around a technicality.  Otherwise mixins go first.)

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
Ian Kelly wrote: On Thu, Apr 28, 2011 at 11:15 AM, 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-multi

Re: Composition instead of inheritance

2011-04-29 Thread Ian Kelly
On Fri, Apr 29, 2011 at 3:09 PM, Carl Banks wrote: > Here is my advice on mixins: > > Mixins should almost always be listed first in the bases.  (The only > exception is to work around a technicality.  Otherwise mixins go first.) > > If a mixin defines __init__, it should always accept self, *arg

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
Carl Banks wrote: Here is my advice on mixins: [snip] Cool. Thanks! ~Ethan -- http://mail.python.org/mailman/listinfo/python-list

Re: Composition instead of inheritance

2011-04-29 Thread Carl Banks
On Thursday, April 28, 2011 6:43:35 PM UTC-7, Ethan Furman wrote: > Carl Banks wrote: > > The sorts of class that this decorator will work for are probably not > > the ones that are going to have problems cooperating in the first place. > > So you might as well just use inheritance; that way peop

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
James Mills wrote: On Fri, Apr 29, 2011 at 11:43 AM, Ethan Furman wrote: Hmmm. Okay -- any ideas for a better term? Something that describes taking different source classes and fusing them into a new whole, possibly using single-inheritance... Frankenstein, maybe? ;) I'd have to say that th

Re: Composition instead of inheritance

2011-04-29 Thread Jean-Michel Pichavant
Ben Finney wrote: Ethan Furman writes: Carl Banks wrote: That's not what we mean by composition. Composition is when one object calls upon another object that it owns to implement some of its behavior. Often used to model a part/whole relationship, hence the name. Hmmm. Okay -

Re: Composition instead of inheritance

2011-04-28 Thread John Nagle
On 4/28/2011 3:35 PM, Carl Banks wrote: On Thursday, April 28, 2011 10:15:02 AM UTC-7, 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-comp

Re: Composition instead of inheritance

2011-04-28 Thread Ian Kelly
On Thu, Apr 28, 2011 at 11:15 AM, 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/

Re: Composition instead of inheritance

2011-04-28 Thread Ben Finney
Dan Stromberg writes: > On Thu, Apr 28, 2011 at 3:35 PM, Carl Banks wrote: > > That's not what we mean by composition.  Composition is when one > > object calls upon another object that it owns to implement some of > > its behavior.  Often used to model a part/whole relationship, hence > > the n

Re: Composition instead of inheritance

2011-04-28 Thread Dan Stromberg
On Thu, Apr 28, 2011 at 3:35 PM, Carl Banks wrote: > On Thursday, April 28, 2011 10:15:02 AM UTC-7, 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.c

Re: Composition instead of inheritance

2011-04-28 Thread Ben Finney
Steven D'Aprano writes: > On Thu, 28 Apr 2011 15:35:47 -0700, Carl Banks wrote: > > > That's not what we mean by composition. Composition is when one > > object calls upon another object that it owns to implement some of > > its behavior. > > I thought that was delegation. As in, when one object

Re: Composition instead of inheritance

2011-04-28 Thread Ben Finney
Ethan Furman writes: > Carl Banks wrote: > > That's not what we mean by composition. Composition is when one > > object calls upon another object that it owns to implement some of > > its behavior. Often used to model a part/whole relationship, hence > > the name. > > Hmmm. Okay -- any ideas for

Re: Composition instead of inheritance

2011-04-28 Thread James Mills
On Fri, Apr 29, 2011 at 11:43 AM, Ethan Furman wrote: > Hmmm. Okay -- any ideas for a better term?  Something that describes taking > different source classes and fusing them into a new whole, possibly using > single-inheritance... Frankenstein, maybe?  ;) I'd have to say that this is typical of

Re: Composition instead of inheritance

2011-04-28 Thread Steven D'Aprano
On Thu, 28 Apr 2011 15:35:47 -0700, Carl Banks wrote: > On Thursday, April 28, 2011 10:15:02 AM UTC-7, 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.activesta

Re: Composition instead of inheritance

2011-04-28 Thread MRAB
On 29/04/2011 02:43, Ethan Furman wrote: Carl Banks wrote: That's not what we mean by composition. Composition is when one object > calls upon another object that it owns to implement some of its behavior. > Often used to model a part/whole relationship, hence the name. Hmmm. Okay -- any ide

Re: Composition instead of inheritance

2011-04-28 Thread Ethan Furman
Carl Banks wrote: That's not what we mean by composition. Composition is when one object > calls upon another object that it owns to implement some of its behavior. > Often used to model a part/whole relationship, hence the name. Hmmm. Okay -- any ideas for a better term? Something that descr

Re: Composition instead of inheritance

2011-04-28 Thread Carl Banks
On Thursday, April 28, 2011 10:15:02 AM UTC-7, 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-mult

Re: Composition instead of inheritance

2011-04-28 Thread Ben Finney
Ethan Furman 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'

Re: Composition instead of inheritance

2011-04-28 Thread Jean-Michel Pichavant
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~ Sounds

Re: Composition instead of inheritance

2011-04-28 Thread Eric Snow
On Thu, Apr 28, 2011 at 11:15 AM, 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-inheri