Le Tue, 12 May 2009 10:55:18 +0200,
The Green Tea Leaf <[email protected]> s'exprima ainsi:

> OK, bad example. But assume I have the same method in both classes and
> want to call the method in the parent.

That should not happen! Basic contract is: same name = same meaning.

Either you implement a method in a parent class to let all instances of child 
classes use it; with possible overriding in specific child classes. Or you have 
two different methods with different names that implement different semantics.

Having two methods with the name that both need two be used on the same object 
is clearly a design flaw. What do you think?

The only case is when the parent method performs a part of what child class 
methods have to do. E.g a common case for __init__:

class Parent(object):
        def __init__(self,arg0):
                self.arg0 = arg0

class OneChild(Parent):
        def __init__(self,arg0,arg1):
                Parent.__init__(self,arg0)
                self.arg1 = arg1

one = OneChild(0,1)
print one.arg0,one.arg1

==>
0 1

Denis
------
la vita e estrany
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to