[Tutor] Doubt
Mats Wichmann
mats at wichmann.us
Tue Feb 26 19:55:05 EST 2019
On 2/26/19 11:36 AM, Maninath sahoo wrote:
> is it possible reverse inheritance?
> mean child class to parent class
Well, it's Python, so you can do all sorts of things, some of them good
ideas, some bad...
Like Alan says, the question as asked doesn't really make a lot of sense
to us, but the way classes (really, user-defined types) work does give
you a lot of flexibility. Some people feel like we should express it as
code reuse at a sophisticated level: if you see a method in another
class that you'd like to use for your own class, you can inherit that
method by listing the class in your definition. Or, if you don't want
to do so, you write your own method. So while I wouldn't call it
reverse inheritance, you as author of your class have all the control of
what you do and don't take from other classes, and maybe it's not
entirely accurate to call them child and parent classes because of that?
More information about the Tutor
mailing list