+ 6
What is __init and __main__ in python
I know that __init__ is a constructor but please explain me what is a contractor with example
2 ответов
+ 7
Maybe you should review the OOP lessons more carefully.
A class is a template for an object, it describes what properties and methods an object has. The __init__ method (constructor) is invoked automatically when a new object is created in memory from the class template, usually it assigns instance variables, based on the constructor parameters.
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2467/
+ 2
__init__ is the class constructor and __main__ is used for :
if __name__ == "__main__":
#runs as program
else:
#runs as module