inheritance

Chris Angelico rosuav at gmail.com
Thu Apr 5 13:57:02 EDT 2012


On Fri, Apr 6, 2012 at 3:50 AM, Yagnesh Raghava Yakkala
<yagnesh at live.com> wrote:
> After follow up, I see one problem(can i say that?) with this. With python
> overwriting methods of super class(es), one need to keep track of all the
> methods ever defined in the super class(es). do everybody do a check before
> writing a new method for existing method with the same name.?

If you're subclassing something, you should generally work with the
intention that an instance of your class will function viably in any
situation in which an instance of the parent is wanted. So if you're
writing a method of the same name as one in the parent, you should be
performing the exact same task and with the same parameters (possibly
having more parameters accepted, but default values set for them).
That's part of what it means to subclass.

ChrisA



More information about the Python-list mailing list