Answer the question
In order to leave comments, you need to log in
Why include the parent class in parentheses when defining a child class?
Hello, I have two versions of the code.
first:
class A:
def __init__(self):
print('nice')
class B(A):
def __init__(self):
A.__init__(self)
v = B()
class A:
def __init__(self):
print('nice')
class B:
def __init__(self):
A.__init__(self)
v = B()
Answer the question
In order to leave comments, you need to log in
To inherit the properties of the parent class. Add fields and methods to A, the difference will become noticeable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question