"The Green Tea Leaf" <thegreenteal...@gmail.com> wrote
class Child(Parent):
def somemethod( self, bla ):
Parent.somemethod(self,bla)
or like this
class Child(Parent):
def somemethod( self, bla ):
super(Child,self).somemethod(bla)
The first version seem to have the obvious disadvantage that I need to
know the name of the parent class when I write the call,
But since you know the name of the parent when you write the
class thats seldom an issue.
that the second version was the "proper" way of doing it. But when
doing some research on the web it seem like the second version also
have some problems.
This has been much improved in Python v3 but the issues with super
in v2 are such that I usually recommend the explicit call (option 1)
My question is simple: what is the "best" way of doing this and why?
The one that works for you. In my case its option 1 because
its explicit and therefore clear what exactly I'm calling.
Or should I mix both these approaches?
No, do not mix them, that way leads to madness IMHO! :-)
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor