0
Why do we need a constructor for our class instead of declare variable or just put parameters into class and using that all?
10 Answers
+ 2
Naufal Fatihul Ihsan you just created classes ,but you didn't actually tried out printing the result ,maybe play around with it and also learn why constructors are used,and you haven't even touched the oop concept in python atleast here ,I dunno where you got the idea of not using a constructor but also you didn't experimented yourself ,
And constructor let you pass value when creating an instance of class so you don't have to access the class everytime and pass the value on your own ,
+ 1
~ swim ~ so I can do the second things than using initializer for just what you said? Or there's a rule that you must using OOP Concept?
0
Does this answers your question?
https://www.geeksforgeeks.org/constructors-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/
0
Not really
0
Do you have any code without using constructor and what you are talking about ,I never tried so just asking!
0
Abhay it just for example, not really to used it, but thanks, I just thought for the other way instead of using OOP Concept cause I'm new to constructor
0
The answer you looking for would be, the init constructer initializes the variable, and thus gives the code a systematic order of arrangement and also it gets easy to understand the code .