I have lots of experience object oriented programming with Java in that case it always call automatically it super class constructor in its inheritance class structure why python doesn't do that Why??
Asked
Active
Viewed 77 times
-3
-
Because Python is not Java? :-D On a more serious note... I find this an advantage, since it allows things like: not calling the `super` constructor if you don't want to, or call it after doing some initialization in your class **before** calling `super` (which Java doesn't allow, since the `super` constructor must be called in the first line of the inherited class' constructor...) Dunno... You could think as a way of providing more flexibility? – Savir Oct 22 '16 at 13:40
-
2I would ask: Why Java does this ? Why ?? – furas Oct 22 '16 at 13:40
-
Python is not Java. All instances of all user-defined classes are basically just dictionaries in which attributes can be inserted. Before any initialisation has been done, all instances of all user-defined classes are almost exactly the same; they're just places to store attributes that aren't storing any yet. – Tinwor Oct 22 '16 at 13:43
-
1Python supports multiple inheritance; Java does not. Python does not enforce any particular model of execution, leaving it the programmer to decide which, if any, inherited methods are called (and in which order) and in which order. – chepner Oct 22 '16 at 14:29
1 Answers
3
As you see in the comments, your question is actually an opinion. Please check __init__ as a constructor?
I would say init isn't really a constructor, at least not in the sense you think about it. Python's entire class model is a bit different and I would say it makes sense here. Inheritance has more emphasis on shared methods in python.