[Tutor] Calling method in parent class
Jeremiah Dodds
jeremiah.dodds at gmail.com
Tue May 12 11:11:24 CEST 2009
On Tue, May 12, 2009 at 9:55 AM, The Green Tea Leaf <
thegreentealeaf at gmail.com> wrote:
> OK, bad example. But assume I have the same method in both classes and
> want to call the method in the parent.
>
>
Can you give a concrete example of _why_ you would want to do this? You can
use super, if you really want to, but it can get ugly (I do not fully
understand all of supers caveats). I can't think of a case off the top of my
head where you would want to call a parent class's method that a child
instance has overriden, but I'm sure it happens sometimes.
My guess is that you probably want to re-organize your classes, or not use
inheritance in this instance, or rename the method in the child class. It's
hard to tell without knowing what exactly you're trying to do in your code.
(I mean on the end-result level, not on the "I'm trying to call a parent
classes method" level.
Sorry if this doesn't seem helpful, and I could be wrong here myself, but I
don't think that this is something that should happen very often at all, and
is probably a pretty rank code smell.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090512/466bd9a4/attachment.htm>
More information about the Tutor
mailing list