What about something like:

class A(object):
        def my_method(self):
                print "A.my_method"
        def call_my_method(self):
                if type(self).my_method == A.my_method:
                        print "Calling base class method."
                else:
                        print "Calling derived class method."
                self.my_method()
                
class B(A):
        pass

class C(A):
        def my_method(self):
                print "C.my_method"

a = A()
b = B()
c = C()

a.call_my_method()
b.call_my_method()
c.call_my_method()


Stéphane



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to