Inheritance but only partly?
Gary Herron
gherron at islandtraining.com
Thu Oct 2 16:36:16 EDT 2008
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? You can just ignore the 5 you don't want -- their
existence costs you nothing in either memory or execution speed.
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
Gary Herron
More information about the Python-list
mailing list