[solved] Re: inheritance
Yagnesh Raghava Yakkala
yagnesh at live.com
Thu Apr 5 14:17:27 EDT 2012
Hello,
With Chris and Ian help (Thank you both)
I end up writing the example script like this,(just for the record)
-------------------------------------
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
class A(object):
def __init__(self, a):
print('a = ', a)
self.a = a
def foo(self):
print('printing from foo in A = ',self.a)
class B(A):
def __init__(self, b, a):
super(B, self).__init__(a)
print('b = ', b)
self.b = b
def foo(self):
print('printing from foo in B = ',self.b)
def bar(self):
print('printing from foo in B = ',self.b)
class C(B):
def __init__(self, c, b, a):
super(C, self).__init__(b, a)
print('c = ', c)
self.c = c
def foo(self):
print('printing from foo in C = ',self.c)
def baz(self):
print('printing from foo in C = ',self.c)
x = C(3,2,1)
x.bar()
x.baz()
print("")
x.foo()
B.foo(x)
A.foo(x)
# inheritance.py ends here
-------------------------------------
--
YYR
More information about the Python-list
mailing list