Q? Calling nearest inherited method

Laurent POINTAL pointal at lure.u-psud.fr
Thu May 18 10:35:33 EDT 2000


On Thu, 18 May 2000 11:02:38 GMT, Fred Gansevles
<gansevle at cs.utwente.nl> wrote:


>: An intermediate approach could be:
>: 
>: def super(self):
>:     return self.__class__.__bases__[0]
>: 
>: class D(C):
>:     def hello(self):
>:         super(self).dothis(self)
>: 

Except that self.__class__ must already return the true class of the
object... so its only valid if you are at the bottom of the class
hierarchy. Sorry, not even the solution... I still prefer use the one
which does the work (just if I change my class hierarchy tree I must
think to change my code relatively to parents code --like
parent.__init__ calls--, but it may not occur before times).

Thanks for all your ideas. Maybe we will see an inherited keyword
later (Guido?), but I dont think it be a priority to extend the
langage, as calling parent class method explicitly is not so bad and
is well readable (to know where we are continuing in the execution
path).

A+

Laurent.

---
Laurent POINTAL - CNRS/LURE - Service Informatique Experiences
Tel/fax: 01 64 46 82 80 / 01 64 46 41 48
email  : pointal at lure.u-psud.fr  ou  lpointal at planete.net 



More information about the Python-list mailing list