[Tutor] Inheritance in classes
Santosh Kumar
rhce.san at gmail.com
Tue Apr 8 07:44:36 CEST 2014
Can i mask the parent attibutes in the child. let me give a quick example.
In [1]: class a:
...: value1 = 1
...: value2 = 2
...:
In [2]: class b(a):
...: value3 = 3
...:
In [3]: obj1 = b()
In [4]: obj1.value1
Out[4]: 1
In [5]: obj1.value2
Out[5]: 2
In [6]: obj1.value3
Out[6]: 3
If you notice in the below example you will see that the child class object
``obj1`` has inherited all the attibutes of the parent class. Is there a
way by which i can make the child class not inherit some of the properites
of parent class.
--
D. Santosh Kumar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140408/49de6722/attachment.html>
More information about the Tutor
mailing list