Over & Super in python.

 Over & Super in python.

Code -

------------------------------


class A:
classvar1 = "Class variable of class A"

def __init__(self):
self.var1 = "Instance variable of class A"
self.special = "This is special variable"
self.instance_variable = "Instance variable of class A"


class B(A):
classvar1 = "Class variable of class B"

def __init__(self):
self.var1 = "Instance variable of class B"
self.instance_variable = "Instance variable of class B"
super().__init__()
# print(super(B, self).classvar1)


hello = A()
by = B()
# print(by.special)
print(by.var1, by.instance_variable)
# print(by.var1)
# print(by.classvar1)

Comments

Popular posts from this blog

Shopping Bill Generator In python.

Should we start preparation for BCA/MCA from class 11th ? How ?

Python program to check that a list have elements in it or not .