How to inheritance overwrite non virtual?

Peter Otten __peter__ at web.de
Thu Sep 18 11:09:35 EDT 2003


Axel Straschil wrote:

> I've tryed (in K2) something like:
>  def bestCaptionlong(self):
> return KObject().bestCaptionlong()
> which I expected to be like KObject::bestCaptionlong() in
> C++, but it doesn't work ;-(

The following will do:

class Derived(Base):
    def method(self):
        return Base.method(self) # call base class method

(Of course you need not override the method if the body of the derived class
only calls the base class method.)

Peter




More information about the Python-list mailing list