$> python2 ./multiple.py
A.v: 1
C.v: 101
B.v: 111
D.v: 1111
d: 1111
Created
February 11, 2016 17:27
-
-
Save sbinet/3cf75ba564e6d3a79d93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A(object): | |
def __init__(self, v): | |
self.v = v | |
print "A.v:",self.v | |
class B(A): | |
def __init__(self, v): | |
super(B, self).__init__(v) | |
self.v += 10 | |
print "B.v:",self.v | |
class C(A): | |
def __init__(self, v): | |
super(C, self).__init__(v) | |
self.v += 100 | |
print "C.v:",self.v | |
class D(B,C): | |
def __init__(self, v): | |
super(D,self).__init__(v) | |
self.v += 1000 | |
print "D.v:",self.v | |
d = D(1) | |
print "d:",d.v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment