On Tue, May 12, 2009 at 11:02 AM, The Green Tea Leaf <
thegreenteal...@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. In this case, use different method
names, or factor out the parent class methods functionality into (probably)
a decorator. Code reuse should be strived for, but that's not the only
purpose of inheritance. If you need to override a method in a subclass, and
still need to call the parents method in that subclass, you're almost
definately using inheritance wrong, with the special exception of __init__.

In the case of __init__, you probably want to use Parent.__init__, and not
super, if only because of all the weird edge cases with super.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to