How to inheritance overwrite non virtual?

anton muhin antonmuhin.REMOVE.ME.FOR.REAL.MAIL at rambler.ru
Thu Sep 18 11:54:32 EDT 2003


Axel Straschil wrote:

> Hi!
> 
> 
>>The following will do:
>>
>>class Derived(Base):
>>    def method(self):
>>        return Base.method(self) # call base class method
> 
> 
> I tried in my chield-class:
> class K2(KObject):
> 	def bestCaption(self):
> 		return "Overwritten"
> 	def bestCaptionlong(self):
> 		return KObject.bestCaptionlong(self)
> 
> The Problem ist inside of KObject.bestCaptionlong(self):
>   return self.bestCaption()
> 
> The mother-class is calling the method of the child-class, not
> it own method. I want the mother-method to be called like "the
> chield never was existing", but I find no way.
> 
> Anny other idea?
> 
> Thank, AXEL.

Change
	return self.bestCaption()

to
	return KObject.bestCaption(self)

hth,
anton.	





More information about the Python-list mailing list