why we use __init__ in class? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

why we use __init__ in class?

21st Oct 2016, 6:07 PM
Anurag Sharma
Anurag Sharma - avatar
7 Respostas
+ 6
It is the synthax to declare a constructor in python.
21st Oct 2016, 6:15 PM
Zen
Zen - avatar
+ 6
constructor gets called internally when instance is created...it is used to allocate all attributes of a class for each instance
23rd Oct 2016, 10:11 AM
Gokul Kishore
Gokul Kishore - avatar
+ 3
A constructor is a method that is called when creating an object of your class. Typically, it will initialize the attributes of your object.
21st Oct 2016, 6:53 PM
Zen
Zen - avatar
+ 2
constructor is a method ,Python calls while creating object. It uses to initialize (assigning values) to instance variables or attributes.
22nd Oct 2016, 12:20 PM
Anandamayee Nanda
Anandamayee Nanda - avatar
+ 2
Init is to initialize a constructor, variable, etc.
22nd Oct 2016, 8:05 PM
violet
+ 1
what is constructor?? thnx for result
21st Oct 2016, 6:17 PM
Anurag Sharma
Anurag Sharma - avatar
+ 1
it's for initialization of class and called constructor method
29th Oct 2016, 12:35 AM
Shekhar Bahuguna
Shekhar Bahuguna - avatar