0

I've started to learn python about 2 weeks ago and I'm trying to grasp the concept of classes and subclasses which lead me to read the code of others.

I've noticed that sometimes, the programmer defines subclasses of some classes, and he would __init__ some of them but not all of them. I wonder what's the criteria to define a subclass and choose to use __init__ rather than inherit from the class.

Edit: It is not that I don't understand __init__, it's that I don't understand why one would use a subclass and use different variables compared to the class. Why use a subclass instead of a new class in that case?

  • 1
    When you want to change the way the objects are instantiated. For example, if you add data inputs to the constructor that you use in your overridden methods. – saarrrr Apr 23 '16 at 21:10
  • Possible duplicate of [Inheritance and init method in Python](http://stackoverflow.com/questions/5166473/inheritance-and-init-method-in-python) – user2390182 Apr 24 '16 at 00:37

0 Answers0