On Fri, Apr 6, 2012 at 2:50 AM, yag <yagn...@live.com> wrote:
>
> Hello,
>
> I am new to python (or to any programming language). My first post on this 
> list,
> so please go easy. Apologies if its a FAQ.

Welcome!

> class A(object):
>    def foo(self):
>        print('printing from foo in A = ',self.a)
>
> class B(A):
>    def foo(self):
>        print('printing from foo in B = ',self.b)
>
> class C(B):
>    def foo(self):
>        print('printing from foo in C = ',self.c)

In each case, you are overriding the foo() method, so your instance
will only execute the last one. If you want to chain to the others,
you need to write your methods to do so - which is what you've done
with __init__.

Hope that helps!

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

Reply via email to