-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path030classOverridesDiffList.py
36 lines (32 loc) · 1.04 KB
/
030classOverridesDiffList.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#py3.7
class VeryBase(object):
classvar ='1somevar'
classvarToOverride ='2somevar'
def __init__(self):
self.instvar ='3somevar'
self.instvarToOverride ='4somevar'
def method(self):
print('5method')
def methodToOverride(self):
print('6methodToOverride')
class WillOverride(VeryBase):
classvarToOverride = '7Overriden_classVar'
classvarSomeOther = '8someotherVarOfChildClass'
def childMethod(self):
print('9childMethod')
def methodToOverride(self):
print('9Overriden_methodToOverride')
print('differences:')
test = WillOverride()
baseDir = dir(VeryBase)
childDir = dir(WillOverride)
for m in baseDir:
method = getattr(VeryBase, m)
if method != getattr(WillOverride, m):
print (f'{m} is {type(method)} and different in VeryBase and WillOverride')
print('child unique:')
childDir = dir(WillOverride)
for m in childDir:
method = getattr(WillOverride, m)
if m not in baseDir:
print(f'{m} is {type(method)} and unique to WillOverride')