class A(object):
def __nikunj__(self):
print("Inside :: A")
def __nike__(self):
print("Something")
class B(A):
def __nike__(self):
print("inside :: B")
super(B,self).__nike__()
object_B = B()
print(object_B.__nike__())
Above code works fine.
class A(object):
def __nikunj__(self):
print("Inside :: A")
def __nike__(self):
print("Something")
class B(A):
test = super(B,self).__nike__()
def __nike__(self):
print("inside :: B")
object_B = B()
print(object_B.test)
This code throws Error :
Traceback (most recent call last):
File "C:\Users\Nikunj Parmar\AppData\Local\Programs\Python\Python36 \test_test.py", line 7, in <module>
class B(A):
File "C:\Users\Nikunj Parmar\AppData\Local\Programs\Python\Python36\test_test.py", line 8, in B
test = super(B,self).__nike__()
NameError: name 'B' is not defined
Why? I don't understand why it shows that B is not found (in second case).