Class inheritance: inherit member variable override function : Class Inheritance : Class : Python examples (example source code) Organized by topic

C++
PHP
Python
Python Home »  Class   » [  Class Inheritance  ]  Screenshots 
 



Class inheritance: inherit member variable override function




class B:
    a = 23
    b = 45
    def f(self)
       print "method f in class B"
    def g(self)
       print "method g in class B"

class C(B):
    b = 67
    c = 89
    d = 123
    def g(self)
       print "method g in class C"
    def h(self)
       print "method h in class C"


x = C()
x.d = 77
x.e = 88
x.g()
           
       
Related examples in the same category
1.  Use __class__, __bases__ and __dict__ for sub and super class Use __class__, __bases__ and __dict__ for sub and super class
2.  Print out class tree Print out class tree
3.  Class inherited Class inherited
4.  Inherited method Inherited method








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.