I have two class and methods having same name .I have the object of derived class. When i call the method (foo) from derived class object it should call the base class method.
class A:
def foo(self):
print "A Foo"
class B(A):
def foo(self):
print "B Foo"
b = B()
b.foo() # "B Foo"
After doing some search i got some solution as below and not sure whether it is proper way of doing it or not
a = A()
b.__class__.__bases__[0].foo(a) # A Foo
Is there any better way of doing it.
Ashould inherit fromobjectto make it a new-style class (where "new" means Python 2.2 and up, or about 17 years old!), then you can usesuper.