Inheritance but only partly?

2008-10-02 Thread process
Let's say I have a class X which has 10 methods. I want class Y to inherit 5 of them. Can I do that? Can I do something along the lines of super(Y, exclude method 3 4 7 9 10) ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance but only partly?

2008-10-02 Thread Gary Herron
process wrote: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? Can I do something along the lines of super(Y, exclude > method 3 4 7 9 10) ? > > -- > http://mail.python.org/mailman/listinfo/python-list > No. But why do yo care? Yo

Re: Inheritance but only partly?

2008-10-02 Thread Matimus
On Oct 2, 1:16 pm, process <[EMAIL PROTECTED]> wrote: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? Can I do something along the lines of super(Y, exclude > method 3 4 7 9 10) ? I think the noral way of doing that is to split the ori

Re: Inheritance but only partly?

2008-10-02 Thread Gary Herron
Gary Herron wrote: > process wrote: > >> Let's say I have a class X which has 10 methods. >> >> I want class Y to inherit 5 of them. >> >> Can I do that? Can I do something along the lines of super(Y, exclude >> method 3 4 7 9 10) ? >> >> -- >> http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance but only partly?

2008-10-02 Thread Aaron "Castironpi" Brady
On Oct 2, 3:16 pm, process <[EMAIL PROTECTED]> wrote: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? Can I do something along the lines of super(Y, exclude > method 3 4 7 9 10) ? That implies that the 5 you do include don't rely on or

Re: Inheritance but only partly?

2008-10-02 Thread bearophileHUGS
Gary Herron: > You can also redefine the ones you don't want inherited: > class A: > def DontInheritMe(self, ...): >... > Class B(A): > def DontInheritMe(self, ...): >raise NotImplementedError // Or some such I have never used something like this, but the OP may use a maski

Re: Inheritance but only partly?

2008-10-03 Thread greg
[EMAIL PROTECTED] wrote: class Mask(object): def m3(self): raise NotImplementedError def m4(self): raise NotImplementedError What's the name of this python design pattern? :-) Don't know. Perhaps we could call it the FigLeaf pattern (covering up what you don't want seen)? There's a

Re: Inheritance but only partly?

2008-10-03 Thread Peter Otten
greg wrote: >> class Mask(object): >> def m3(self): raise NotImplementedError >> def m4(self): raise NotImplementedError > >> What's the name of this python design pattern? :-) > > Don't know. Perhaps we could call it the FigLeaf pattern > (covering up what you don't want seen)? Braghettone ;)

Re: Inheritance but only partly?

2008-10-03 Thread Michele Simionato
On Oct 2, 10:16 pm, process <[EMAIL PROTECTED]> wrote: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? Can I do something along the lines of super(Y, exclude > method 3 4 7 9 10) ? Don't use inheritance, use delegation or just copy the

Re: Inheritance but only partly?

2008-10-03 Thread Tim Rowe
2008/10/2 process <[EMAIL PROTECTED]>: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? As others have said, no. What nobody seems to have said yet is why. If Y descends from X, you are saying that Y is an X; that a Y can be used anywhe

Re: Inheritance but only partly?

2008-10-03 Thread Simon Brunning
2008/10/3 Tim Rowe <[EMAIL PROTECTED]>: > As others have said, no. What nobody seems to have said yet is why. If > Y descends from X, you are saying that Y is an X; that a Y can be used > anywhere an X can. If Y doesn't support some methods of X then it is > *not* an X, and *can't* be used anywher

Re: Inheritance but only partly?

2008-10-03 Thread Steven D'Aprano
On Fri, 03 Oct 2008 03:32:52 -0700, Michele Simionato wrote: > IMO, if you have methods that you want to use in different classes, this > is hint that > you are in need of generic functions. See this blog post for an example: > > http://www.artima.com/weblogs/viewpost.jsp?thread=237764 That's a

Re: Inheritance but only partly?

2008-10-05 Thread George Sakkis
On Oct 3, 11:56 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 03 Oct 2008 03:32:52 -0700, Michele Simionato wrote: > > IMO, if you have methods that you want to use in different classes, this > > is hint that > > you are in need of generic functions. See this blog post