Mega Code Archive

 
Categories / Python Tutorial / Class
 

Overriding Methods through Inheritance

class P(object):     def foo(self):         print 'Hi, I am P-foo()' p = P() print p.foo() class C(P):     def foo(self):         print 'Hi, I am C-foo()' c = C() print c.foo() P.foo(c) class C(P):     def foo(self):         super(C, self).foo()         print 'Hi, I am C-foo()' c = C() print c.foo()