[Tutor] Calling method in parent class

Alan Gauld alan.gauld at btinternet.com
Tue May 12 18:45:52 CEST 2009


"Jeremiah Dodds" <jeremiah.dodds at gmail.com> wrote

>> > That should not happen! Basic contract is: same name = same meaning.
>>
>> Same meaning yes, but that doesn't mean that I can't/shouldn't reuse
>> code that address a part of the problem.
>>
> If your superclass has a method with the same name (other than __init__
> here), that contains some logic that a subclass that overrides the method
> needs, it's written wrong in python.

No its not, this is standard OOP design in any OO language.
Polymorphism is where the power of OOP reallly comes into play.
If you have to write all of the code for every overridden method
then I'd say that was bad design.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list