Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
Hi. Subclasses can have __init__() method. However unlike other languages the subclass's __init__() method does not automatically call the superclass's __init__() method. Try this out... class Superclass(object): def __init__(self): print ('Do something') class Subclass(Superclass): def __init__(self): # super(Subclass, self).__init__() # Uncomment to call superclass __init__() print ('Do something else') Subclass () Happy Coding!!!
22nd Mar 2017, 10:20 AM
wmik