-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPS12.py
More file actions
21 lines (15 loc) · 760 Bytes
/
OOPS12.py
File metadata and controls
21 lines (15 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class A:
classvar1="I am a class variable in class A"
def __init__(self):
self.var1="I am inside class A's constructor"
self.classvar1="I am an instance variable in class A"
self.special="special"
class B(A):
classvar1="I am class variable in class B"
def __init__(self): # Will show an warning on init as the fucntion is overwriten
super().__init__() # super is written in code as to call the original init
self.var1="I am inside class B's constructor"
self.classvar1="I am an instance variable in class B"
a=A()
b=B()
print(b.special, b.var1, b.classvar1) # this fucntion will search for instance varibles first and then class variables