Inheritance but only partly?
Aaron "Castironpi" Brady
castironpi at gmail.com
Thu Oct 2 16:45:22 EDT 2008
More information about the Python-list mailing list
Thu Oct 2 16:45:22 EDT 2008
- Previous message (by thread): Inheritance but only partly?
- Next message (by thread): Inheritance but only partly?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Oct 2, 3:16 pm, process <circularf... at gmail.com> 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 call the 5 you don't. Otherwise you have to inherit them. Then you can refactor them into: class X5YouDo: ... class X5YouDont: ... class X( X5YouDo, X5YouDont ): ... class Y( X5YouDo ): ... If you're looking for restricted visibility, Python does not have it. It's just handcuffs, and makes things you can't do. After all, nothing would stop you user from calling: y= Y() X5YouDont.DontInheritMe( y, args ) to get at the uninherited methods.
- Previous message (by thread): Inheritance but only partly?
- Next message (by thread): Inheritance but only partly?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list