What is init???

In python, what is init and what is the function of it in loops?

4/8/2020 5:43:29 AM

🌼Fariha Falaq🌼

13 Answers

New Answer


If you are referring to the __init__ method, this is the constructor method of Python classes, meaning it is invoked when you create an instance class and it "builds" the instance that you created using its own implementation. for example, class Cat: def __init__(self): self.name = "Sophie" new_cat = Cat() # This is where you create an instance of the Cat class, the __init__ method is invoked setting the name attribute to "Sophie". print(new_cat.name()) # This will output "Sophie" thanks to the constructor method setting this object's name to "Sophie" when the object (or instance) was created.


OK, so init is a constructor which is used in python loops. I think I understood something. Thanks to Ganapathy P T and Kevin Star .😆🙏


Thanks Goodwill Motaung Maswanganye for your help and thanks Hilla Sh for your hard work!❤❤


Thank you Mursalatul Pallob and syed ibrahim for your help!🙏🙏🎓




google it for more details. w3shool is a nice website for this .


__init__, popular called dunder init(majorly because it has two underscores as a predix and suffix) is used to set up instantiation logic for each object run in a class It's like a kind of self built-in method in every class definition that runs implicitly when u instantiate an object of a class You don't have to involve this method explicitly. It calls itself to action when u run an object of a class I hope this help Fariha Falaq


It is a constructor method while using in classes.


i hope this will also help you https://www.sololearn.com/learn/Python/2467/




I thought about Linux init when seeing this. 🐧(That was supposed to be Tux)


Init means initialize and it is a constructor in python.


Initialization refers to defining a constant or variable values that are used in the code for executing a computer program.